mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Simplified externalCoupled BC - removed collate option
This commit is contained in:
@ -41,10 +41,7 @@ Foam::externalCoupledMixedFvPatchField<Type>::patchKey = "# Patch: ";
|
|||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::fileName Foam::externalCoupledMixedFvPatchField<Type>::baseDir
|
Foam::fileName Foam::externalCoupledMixedFvPatchField<Type>::baseDir() const
|
||||||
(
|
|
||||||
const word& patchName
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
word regionName(this->dimensionedInternalField().mesh().name());
|
word regionName(this->dimensionedInternalField().mesh().name());
|
||||||
if (regionName == polyMesh::defaultRegion)
|
if (regionName == polyMesh::defaultRegion)
|
||||||
@ -55,21 +52,7 @@ Foam::fileName Foam::externalCoupledMixedFvPatchField<Type>::baseDir
|
|||||||
fileName result(commsDir_/regionName);
|
fileName result(commsDir_/regionName);
|
||||||
result.clean();
|
result.clean();
|
||||||
|
|
||||||
if (collate_)
|
return result;
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (patchName == word::null)
|
|
||||||
{
|
|
||||||
return fileName(result/this->patch().name());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return fileName(result/patchName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,75 +80,49 @@ void Foam::externalCoupledMixedFvPatchField<Type>::setMaster
|
|||||||
offsets_[i] = 0;
|
offsets_[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collate_)
|
// set the master patch
|
||||||
|
forAll(patchIDs, i)
|
||||||
{
|
{
|
||||||
// set the master patch
|
label patchI = patchIDs[i];
|
||||||
forAll(patchIDs, i)
|
|
||||||
|
patchType& pf = refCast<patchType>(bf[patchI]);
|
||||||
|
|
||||||
|
offsets_[patchI][Pstream::myProcNo()] = pf.size();
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
{
|
{
|
||||||
label patchI = patchIDs[i];
|
pf.master() = true;
|
||||||
|
|
||||||
patchType& pf = refCast<patchType>(bf[patchI]);
|
|
||||||
|
|
||||||
offsets_[patchI][Pstream::myProcNo()] = pf.size();
|
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
pf.master() = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pf.master() = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// set the patch offsets
|
|
||||||
int tag = Pstream::msgType() + 1;
|
|
||||||
forAll(offsets_, i)
|
|
||||||
{
|
{
|
||||||
Pstream::gatherList(offsets_[i], tag);
|
pf.master() = false;
|
||||||
Pstream::scatterList(offsets_[i], tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
label patchOffset = 0;
|
|
||||||
forAll(offsets_, patchI)
|
|
||||||
{
|
|
||||||
label sumOffset = 0;
|
|
||||||
List<label>& procOffsets = offsets_[patchI];
|
|
||||||
|
|
||||||
forAll(procOffsets, procI)
|
|
||||||
{
|
|
||||||
label o = procOffsets[procI];
|
|
||||||
if (o > 0)
|
|
||||||
{
|
|
||||||
procOffsets[procI] = patchOffset + sumOffset;
|
|
||||||
sumOffset += o;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
patchOffset += sumOffset;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// set the patch offsets
|
||||||
|
int tag = Pstream::msgType() + 1;
|
||||||
|
forAll(offsets_, i)
|
||||||
{
|
{
|
||||||
// check that collated flag is not set on any other patches
|
Pstream::gatherList(offsets_[i], tag);
|
||||||
forAll(patchIDs, i)
|
Pstream::scatterList(offsets_[i], tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
label patchOffset = 0;
|
||||||
|
forAll(offsets_, patchI)
|
||||||
|
{
|
||||||
|
label sumOffset = 0;
|
||||||
|
List<label>& procOffsets = offsets_[patchI];
|
||||||
|
|
||||||
|
forAll(procOffsets, procI)
|
||||||
{
|
{
|
||||||
label patchI = patchIDs[i];
|
label o = procOffsets[procI];
|
||||||
|
if (o > 0)
|
||||||
const patchType& pf = refCast<const patchType>(bf[patchI]);
|
|
||||||
|
|
||||||
if (pf.collate())
|
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
procOffsets[procI] = patchOffset + sumOffset;
|
||||||
(
|
sumOffset += o;
|
||||||
"void Foam::externalCoupledMixedFvPatchField<Type>::"
|
|
||||||
"setMaster()"
|
|
||||||
) << "All " << type() << " patches should either use "
|
|
||||||
<< "collate = true OR false, but not a mix of both"
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
patchOffset += sumOffset;
|
||||||
master_ = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,33 +238,26 @@ void Foam::externalCoupledMixedFvPatchField<Type>::removeLockFile() const
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::externalCoupledMixedFvPatchField<Type>::startWait() const
|
void Foam::externalCoupledMixedFvPatchField<Type>::startWait() const
|
||||||
{
|
{
|
||||||
if (collate_)
|
// only wait on master patch
|
||||||
|
|
||||||
|
const volFieldType& cvf =
|
||||||
|
static_cast<const volFieldType&>(this->dimensionedInternalField());
|
||||||
|
|
||||||
|
const typename volFieldType::GeometricBoundaryField& bf =
|
||||||
|
cvf.boundaryField();
|
||||||
|
|
||||||
|
forAll(coupledPatchIDs_, i)
|
||||||
{
|
{
|
||||||
// only wait on master patch
|
label patchI = coupledPatchIDs_[i];
|
||||||
|
|
||||||
const volFieldType& cvf =
|
const patchType& pf = refCast<const patchType>(bf[patchI]);
|
||||||
static_cast<const volFieldType&>(this->dimensionedInternalField());
|
|
||||||
|
|
||||||
const typename volFieldType::GeometricBoundaryField& bf =
|
if (pf.master())
|
||||||
cvf.boundaryField();
|
|
||||||
|
|
||||||
forAll(coupledPatchIDs_, i)
|
|
||||||
{
|
{
|
||||||
label patchI = coupledPatchIDs_[i];
|
pf.wait();
|
||||||
|
break;
|
||||||
const patchType& pf = refCast<const patchType>(bf[patchI]);
|
|
||||||
|
|
||||||
if (pf.master())
|
|
||||||
{
|
|
||||||
pf.wait();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
wait();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -471,26 +421,19 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeData
|
|||||||
|
|
||||||
writeHeader(os);
|
writeHeader(os);
|
||||||
|
|
||||||
if (collate_)
|
const volFieldType& cvf =
|
||||||
|
static_cast<const volFieldType&>(this->dimensionedInternalField());
|
||||||
|
|
||||||
|
const typename volFieldType::GeometricBoundaryField& bf =
|
||||||
|
cvf.boundaryField();
|
||||||
|
|
||||||
|
forAll(coupledPatchIDs_, i)
|
||||||
{
|
{
|
||||||
const volFieldType& cvf =
|
label patchI = coupledPatchIDs_[i];
|
||||||
static_cast<const volFieldType&>(this->dimensionedInternalField());
|
|
||||||
|
|
||||||
const typename volFieldType::GeometricBoundaryField& bf =
|
const patchType& pf = refCast<const patchType>(bf[patchI]);
|
||||||
cvf.boundaryField();
|
|
||||||
|
|
||||||
forAll(coupledPatchIDs_, i)
|
pf.transferData(os);
|
||||||
{
|
|
||||||
label patchI = coupledPatchIDs_[i];
|
|
||||||
|
|
||||||
const patchType& pf = refCast<const patchType>(bf[patchI]);
|
|
||||||
|
|
||||||
pf.transferData(os);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
transferData(os);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,7 +461,6 @@ externalCoupledMixedFvPatchField
|
|||||||
mixedFvPatchField<Type>(p, iF),
|
mixedFvPatchField<Type>(p, iF),
|
||||||
commsDir_("unknown-commsDir"),
|
commsDir_("unknown-commsDir"),
|
||||||
fName_("unknown-fName"),
|
fName_("unknown-fName"),
|
||||||
collate_(false),
|
|
||||||
waitInterval_(0),
|
waitInterval_(0),
|
||||||
timeOut_(0),
|
timeOut_(0),
|
||||||
calcFrequency_(0),
|
calcFrequency_(0),
|
||||||
@ -548,7 +490,6 @@ externalCoupledMixedFvPatchField
|
|||||||
mixedFvPatchField<Type>(ptf, p, iF, mapper),
|
mixedFvPatchField<Type>(ptf, p, iF, mapper),
|
||||||
commsDir_(ptf.commsDir_),
|
commsDir_(ptf.commsDir_),
|
||||||
fName_(ptf.fName_),
|
fName_(ptf.fName_),
|
||||||
collate_(ptf.collate_),
|
|
||||||
waitInterval_(ptf.waitInterval_),
|
waitInterval_(ptf.waitInterval_),
|
||||||
timeOut_(ptf.timeOut_),
|
timeOut_(ptf.timeOut_),
|
||||||
calcFrequency_(ptf.calcFrequency_),
|
calcFrequency_(ptf.calcFrequency_),
|
||||||
@ -573,7 +514,6 @@ externalCoupledMixedFvPatchField
|
|||||||
mixedFvPatchField<Type>(p, iF),
|
mixedFvPatchField<Type>(p, iF),
|
||||||
commsDir_(dict.lookup("commsDir")),
|
commsDir_(dict.lookup("commsDir")),
|
||||||
fName_(dict.lookup("fileName")),
|
fName_(dict.lookup("fileName")),
|
||||||
collate_(readBool(dict.lookup("collate"))),
|
|
||||||
waitInterval_(dict.lookupOrDefault("waitInterval", 1)),
|
waitInterval_(dict.lookupOrDefault("waitInterval", 1)),
|
||||||
timeOut_(dict.lookupOrDefault("timeOut", 100*waitInterval_)),
|
timeOut_(dict.lookupOrDefault("timeOut", 100*waitInterval_)),
|
||||||
calcFrequency_(dict.lookupOrDefault("calcFrequency", 1)),
|
calcFrequency_(dict.lookupOrDefault("calcFrequency", 1)),
|
||||||
@ -624,7 +564,6 @@ externalCoupledMixedFvPatchField
|
|||||||
mixedFvPatchField<Type>(ecmpf),
|
mixedFvPatchField<Type>(ecmpf),
|
||||||
commsDir_(ecmpf.commsDir_),
|
commsDir_(ecmpf.commsDir_),
|
||||||
fName_(ecmpf.fName_),
|
fName_(ecmpf.fName_),
|
||||||
collate_(ecmpf.collate_),
|
|
||||||
waitInterval_(ecmpf.waitInterval_),
|
waitInterval_(ecmpf.waitInterval_),
|
||||||
timeOut_(ecmpf.timeOut_),
|
timeOut_(ecmpf.timeOut_),
|
||||||
calcFrequency_(ecmpf.calcFrequency_),
|
calcFrequency_(ecmpf.calcFrequency_),
|
||||||
@ -648,7 +587,6 @@ externalCoupledMixedFvPatchField
|
|||||||
mixedFvPatchField<Type>(ecmpf, iF),
|
mixedFvPatchField<Type>(ecmpf, iF),
|
||||||
commsDir_(ecmpf.commsDir_),
|
commsDir_(ecmpf.commsDir_),
|
||||||
fName_(ecmpf.fName_),
|
fName_(ecmpf.fName_),
|
||||||
collate_(ecmpf.collate_),
|
|
||||||
waitInterval_(ecmpf.waitInterval_),
|
waitInterval_(ecmpf.waitInterval_),
|
||||||
timeOut_(ecmpf.timeOut_),
|
timeOut_(ecmpf.timeOut_),
|
||||||
calcFrequency_(ecmpf.calcFrequency_),
|
calcFrequency_(ecmpf.calcFrequency_),
|
||||||
@ -857,52 +795,22 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeGeometry() const
|
|||||||
const typename volFieldType::GeometricBoundaryField& bf =
|
const typename volFieldType::GeometricBoundaryField& bf =
|
||||||
cvf.boundaryField();
|
cvf.boundaryField();
|
||||||
|
|
||||||
if (collate_)
|
OFstream osPoints(baseDir()/"patchPoints");
|
||||||
|
OFstream osFaces(baseDir()/"patchFaces");
|
||||||
|
|
||||||
|
if (log_)
|
||||||
{
|
{
|
||||||
OFstream osPoints(baseDir()/"patchPoints");
|
Info<< "writing collated patch points to: " << osPoints.name() << nl
|
||||||
OFstream osFaces(baseDir()/"patchFaces");
|
<< "writing collated patch faces to: " << osFaces.name() << endl;
|
||||||
|
|
||||||
if (log_)
|
|
||||||
{
|
|
||||||
Info<< "writing collated patch points to: "
|
|
||||||
<< osPoints.name() << endl;
|
|
||||||
Info<< "writing collated patch faces to: "
|
|
||||||
<< osFaces.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(bf, patchI)
|
|
||||||
{
|
|
||||||
if (isA<patchType>(bf[patchI]))
|
|
||||||
{
|
|
||||||
const patchType& pf = refCast<const patchType>(bf[patchI]);
|
|
||||||
|
|
||||||
pf.writeGeometry(osPoints, osFaces);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
forAll(bf, patchI)
|
||||||
{
|
{
|
||||||
forAll(bf, patchI)
|
if (isA<patchType>(bf[patchI]))
|
||||||
{
|
{
|
||||||
if (isA<patchType>(bf[patchI]))
|
const patchType& pf = refCast<const patchType>(bf[patchI]);
|
||||||
{
|
|
||||||
const word& patchName = this->patch().name();
|
|
||||||
|
|
||||||
OFstream osPoints(baseDir(patchName)/"patchPoints");
|
pf.writeGeometry(osPoints, osFaces);
|
||||||
OFstream osFaces(baseDir(patchName)/"patchFaces");
|
|
||||||
|
|
||||||
if (log_)
|
|
||||||
{
|
|
||||||
Info<< "writing patch " << patchName << " points to: "
|
|
||||||
<< osPoints.name() << endl;
|
|
||||||
Info<< "writing patch " << patchName << " faces to: "
|
|
||||||
<< osFaces.name() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const patchType& pf = refCast<const patchType>(bf[patchI]);
|
|
||||||
|
|
||||||
pf.writeGeometry(osPoints, osFaces);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -915,7 +823,6 @@ void Foam::externalCoupledMixedFvPatchField<Type>::write(Ostream& os) const
|
|||||||
|
|
||||||
os.writeKeyword("commsDir") << commsDir_ << token::END_STATEMENT << nl;
|
os.writeKeyword("commsDir") << commsDir_ << token::END_STATEMENT << nl;
|
||||||
os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl;
|
os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl;
|
||||||
os.writeKeyword("collate") << collate_ << token::END_STATEMENT << nl;
|
|
||||||
os.writeKeyword("waitInterval") << waitInterval_ << token::END_STATEMENT
|
os.writeKeyword("waitInterval") << waitInterval_ << token::END_STATEMENT
|
||||||
<< nl;
|
<< nl;
|
||||||
os.writeKeyword("timeOut") << timeOut_ << token::END_STATEMENT << nl;
|
os.writeKeyword("timeOut") << timeOut_ << token::END_STATEMENT << nl;
|
||||||
|
|||||||
@ -48,13 +48,7 @@ Description
|
|||||||
...
|
...
|
||||||
<valueN> <gradientN> <valueFracionN>
|
<valueN> <gradientN> <valueFracionN>
|
||||||
|
|
||||||
Data is either sent/received as one file per patch, or as a single file
|
Data is sent/received as a single file for all patches from the folder
|
||||||
for all patches, based on the \c collate flag. In the former case, the
|
|
||||||
folder used for communications is:
|
|
||||||
|
|
||||||
$FOAM_CASE/<commsDir>/patchName
|
|
||||||
|
|
||||||
and when using the \c collate option:
|
|
||||||
|
|
||||||
$FOAM_CASE/<commsDir>
|
$FOAM_CASE/<commsDir>
|
||||||
|
|
||||||
@ -83,7 +77,6 @@ Description
|
|||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
commsDir | communications folder | yes |
|
commsDir | communications folder | yes |
|
||||||
fileName | transfer file name | yes |
|
fileName | transfer file name | yes |
|
||||||
collate | collate all patch data into single file | yes |
|
|
||||||
waitInterval | interval [s] between file checks | no | 1
|
waitInterval | interval [s] between file checks | no | 1
|
||||||
timeOut | time after which error invoked [s] |no |100*waitInterval
|
timeOut | time after which error invoked [s] |no |100*waitInterval
|
||||||
calcFrequency | calculation frequency | no | 1
|
calcFrequency | calculation frequency | no | 1
|
||||||
@ -98,7 +91,6 @@ Description
|
|||||||
type externalCoupled;
|
type externalCoupled;
|
||||||
commsDir "$FOAM_CASE/comms";
|
commsDir "$FOAM_CASE/comms";
|
||||||
fileName data;
|
fileName data;
|
||||||
collate yes;
|
|
||||||
calcFrequency 1;
|
calcFrequency 1;
|
||||||
initByExternal yes;
|
initByExternal yes;
|
||||||
}
|
}
|
||||||
@ -149,9 +141,6 @@ private:
|
|||||||
//- Name of data file
|
//- Name of data file
|
||||||
word fName_;
|
word fName_;
|
||||||
|
|
||||||
//- Flag to collate all data into single transfer file
|
|
||||||
bool collate_;
|
|
||||||
|
|
||||||
//- Interval time between checking for return data [s]
|
//- Interval time between checking for return data [s]
|
||||||
label waitInterval_;
|
label waitInterval_;
|
||||||
|
|
||||||
@ -190,7 +179,7 @@ private:
|
|||||||
void setMaster(const labelList& patchIDs);
|
void setMaster(const labelList& patchIDs);
|
||||||
|
|
||||||
//- Return the file path to the base communications folder
|
//- Return the file path to the base communications folder
|
||||||
fileName baseDir(const word& patchName = word::null) const;
|
fileName baseDir() const;
|
||||||
|
|
||||||
//- Write the geometry to the comms dir
|
//- Write the geometry to the comms dir
|
||||||
void writeGeometry(OFstream& osPoints, OFstream& osFaces) const;
|
void writeGeometry(OFstream& osPoints, OFstream& osFaces) const;
|
||||||
@ -316,12 +305,6 @@ public:
|
|||||||
return log_;
|
return log_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return the collate flag
|
|
||||||
bool collate() const
|
|
||||||
{
|
|
||||||
return collate_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return the master flag
|
//- Return the master flag
|
||||||
bool master() const
|
bool master() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user