ENH: Simplified externalCoupled BC - removed collate option

This commit is contained in:
andy
2013-07-24 10:45:30 +01:00
parent d719430c84
commit 73bedc413c
2 changed files with 71 additions and 181 deletions

View File

@ -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,8 +80,6 @@ void Foam::externalCoupledMixedFvPatchField<Type>::setMaster
offsets_[i] = 0; offsets_[i] = 0;
} }
if (collate_)
{
// set the master patch // set the master patch
forAll(patchIDs, i) forAll(patchIDs, i)
{ {
@ -143,30 +124,6 @@ void Foam::externalCoupledMixedFvPatchField<Type>::setMaster
} }
patchOffset += sumOffset; patchOffset += sumOffset;
} }
}
else
{
// check that collated flag is not set on any other patches
forAll(patchIDs, i)
{
label patchI = patchIDs[i];
const patchType& pf = refCast<const patchType>(bf[patchI]);
if (pf.collate())
{
FatalErrorIn
(
"void Foam::externalCoupledMixedFvPatchField<Type>::"
"setMaster()"
) << "All " << type() << " patches should either use "
<< "collate = true OR false, but not a mix of both"
<< exit(FatalError);
}
}
master_ = true;
}
} }
@ -281,8 +238,6 @@ 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 // only wait on master patch
const volFieldType& cvf = const volFieldType& cvf =
@ -303,11 +258,6 @@ void Foam::externalCoupledMixedFvPatchField<Type>::startWait() const
break; break;
} }
} }
}
else
{
wait();
}
} }
@ -471,8 +421,6 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeData
writeHeader(os); writeHeader(os);
if (collate_)
{
const volFieldType& cvf = const volFieldType& cvf =
static_cast<const volFieldType&>(this->dimensionedInternalField()); static_cast<const volFieldType&>(this->dimensionedInternalField());
@ -487,11 +435,6 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeData
pf.transferData(os); 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,17 +795,13 @@ 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 osPoints(baseDir()/"patchPoints");
OFstream osFaces(baseDir()/"patchFaces"); OFstream osFaces(baseDir()/"patchFaces");
if (log_) if (log_)
{ {
Info<< "writing collated patch points to: " Info<< "writing collated patch points to: " << osPoints.name() << nl
<< osPoints.name() << endl; << "writing collated patch faces to: " << osFaces.name() << endl;
Info<< "writing collated patch faces to: "
<< osFaces.name() << endl;
} }
forAll(bf, patchI) forAll(bf, patchI)
@ -879,32 +813,6 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeGeometry() const
pf.writeGeometry(osPoints, osFaces); pf.writeGeometry(osPoints, osFaces);
} }
} }
}
else
{
forAll(bf, patchI)
{
if (isA<patchType>(bf[patchI]))
{
const word& patchName = this->patch().name();
OFstream osPoints(baseDir(patchName)/"patchPoints");
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;

View File

@ -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
{ {