mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: GeometricBoundaryField evaluate with specified communication type
- evaluate() the communication type is exposed as a parameter to allow for more tuning, but default parameter remains defaultCommsType so there is no change in behaviour for existing code - evaluate_if() supports a general selection predicate - evaluateSelected() now does initEvaluate() for all patches, waits and then calls evaluate(). This avoids potential deadlocks when multiple patches are inter-communicating. ENH: align DimensionedField reading with GeometricField treatment - use localIOdictionary to obtain the dictionary contents ENH: update GeometricField code - change GeometricField writeData() as primary output method (not operator<<) for better clarity of purpose - use unique_ptr for GeometricField demand-driven data
This commit is contained in:
@ -115,8 +115,12 @@ private:
|
|||||||
//- Assert that non-zero field size == mesh size
|
//- Assert that non-zero field size == mesh size
|
||||||
void checkFieldSize() const;
|
void checkFieldSize() const;
|
||||||
|
|
||||||
|
//- Read from file if it is present. Checks the readOption flag
|
||||||
void readIfPresent(const word& fieldDictEntry = "value");
|
void readIfPresent(const word& fieldDictEntry = "value");
|
||||||
|
|
||||||
|
//- Read the field - create the field dictionary on-the-fly
|
||||||
|
void readField(const word& fieldDictEntry = "value");
|
||||||
|
|
||||||
//- Implementation for 'New' with specified registerObject preference.
|
//- Implementation for 'New' with specified registerObject preference.
|
||||||
// For LEGACY_REGISTER, registration is determined by
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
// objectRegistry::is_cacheTemporaryObject().
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
@ -580,8 +584,8 @@ public:
|
|||||||
bool writeData(Ostream& os, const word& fieldDictEntry) const;
|
bool writeData(Ostream& os, const word& fieldDictEntry) const;
|
||||||
|
|
||||||
//- The writeData function (required by regIOobject),
|
//- The writeData function (required by regIOobject),
|
||||||
//- call writeData with dictionary entry name = "value"
|
//- calls writeData with dictionary entry name = "value"
|
||||||
bool writeData(Ostream& os) const;
|
bool writeData(Ostream& os) const { return writeData(os, "value"); }
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
@ -613,12 +617,14 @@ public:
|
|||||||
|
|
||||||
// Ostream Operators
|
// Ostream Operators
|
||||||
|
|
||||||
|
//- Calls DimensionedField::writeData()
|
||||||
friend Ostream& operator<< <Type, GeoMesh>
|
friend Ostream& operator<< <Type, GeoMesh>
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const DimensionedField<Type, GeoMesh>& df
|
const DimensionedField<Type, GeoMesh>& df
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Calls DimensionedField::writeData()
|
||||||
friend Ostream& operator<< <Type, GeoMesh>
|
friend Ostream& operator<< <Type, GeoMesh>
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
|
|||||||
@ -28,6 +28,7 @@ License
|
|||||||
|
|
||||||
#include "DimensionedField.H"
|
#include "DimensionedField.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
#include "localIOdictionary.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -58,15 +59,49 @@ void Foam::DimensionedField<Type, GeoMesh>::readField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class GeoMesh>
|
||||||
|
void Foam::DimensionedField<Type, GeoMesh>::readField
|
||||||
|
(
|
||||||
|
const word& fieldDictEntry
|
||||||
|
)
|
||||||
|
{
|
||||||
|
dictionary dict
|
||||||
|
(
|
||||||
|
localIOdictionary::readContents
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
this->name(),
|
||||||
|
this->instance(),
|
||||||
|
this->local(),
|
||||||
|
this->db(),
|
||||||
|
IOobjectOption::MUST_READ,
|
||||||
|
IOobjectOption::NO_WRITE,
|
||||||
|
IOobjectOption::NO_REGISTER
|
||||||
|
),
|
||||||
|
typeName
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
this->close();
|
||||||
|
|
||||||
|
readField(dict, fieldDictEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
template<class Type, class GeoMesh>
|
||||||
void Foam::DimensionedField<Type, GeoMesh>::readIfPresent
|
void Foam::DimensionedField<Type, GeoMesh>::readIfPresent
|
||||||
(
|
(
|
||||||
const word& fieldDictEntry
|
const word& fieldDictEntry
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (this->isReadRequired() || (this->isReadOptional() && this->headerOk()))
|
if
|
||||||
|
(
|
||||||
|
this->isReadRequired()
|
||||||
|
|| (this->isReadOptional() && this->headerOk())
|
||||||
|
)
|
||||||
{
|
{
|
||||||
readField(dictionary(readStream(typeName)), fieldDictEntry);
|
readField(fieldDictEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +122,7 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
|||||||
dimensions_(dimless),
|
dimensions_(dimless),
|
||||||
oriented_()
|
oriented_()
|
||||||
{
|
{
|
||||||
readField(dictionary(readStream(typeName)), fieldDictEntry);
|
readField(fieldDictEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,23 +169,16 @@ bool Foam::DimensionedField<Type, GeoMesh>::writeData
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
|
||||||
bool Foam::DimensionedField<Type, GeoMesh>::writeData(Ostream& os) const
|
|
||||||
{
|
|
||||||
return writeData(os, "value");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
template<class Type, class GeoMesh>
|
||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const DimensionedField<Type, GeoMesh>& df
|
const DimensionedField<Type, GeoMesh>& fld
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
df.writeData(os);
|
fld.writeData(os);
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
@ -160,11 +188,11 @@ template<class Type, class GeoMesh>
|
|||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf
|
const tmp<DimensionedField<Type, GeoMesh>>& tfld
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
tdf().writeData(os);
|
tfld().writeData(os);
|
||||||
tdf.clear();
|
tfld.clear();
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ bool Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::checkConsistency
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for outstanding requests
|
// Wait for outstanding requests (non-blocking)
|
||||||
UPstream::waitRequests(startOfRequests);
|
UPstream::waitRequests(startOfRequests);
|
||||||
|
|
||||||
for (auto& pfld : bfld)
|
for (auto& pfld : bfld)
|
||||||
@ -193,10 +193,7 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// DebugInFunction << nl;
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
// Clear the boundary field if already initialised
|
// Clear the boundary field if already initialised
|
||||||
this->clear();
|
this->clear();
|
||||||
@ -363,10 +360,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
|
|||||||
FieldField<PatchField, Type>(bmesh.size()),
|
FieldField<PatchField, Type>(bmesh.size()),
|
||||||
bmesh_(bmesh)
|
bmesh_(bmesh)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// DebugInFunction << nl;
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
forAll(bmesh_, patchi)
|
forAll(bmesh_, patchi)
|
||||||
{
|
{
|
||||||
@ -396,10 +390,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
|
|||||||
FieldField<PatchField, Type>(bmesh.size()),
|
FieldField<PatchField, Type>(bmesh.size()),
|
||||||
bmesh_(bmesh)
|
bmesh_(bmesh)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// DebugInFunction << nl;
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -462,10 +453,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
|
|||||||
FieldField<PatchField, Type>(bmesh.size()),
|
FieldField<PatchField, Type>(bmesh.size()),
|
||||||
bmesh_(bmesh)
|
bmesh_(bmesh)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// DebugInFunction << nl;
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
forAll(bmesh_, patchi)
|
forAll(bmesh_, patchi)
|
||||||
{
|
{
|
||||||
@ -484,10 +472,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
|
|||||||
FieldField<PatchField, Type>(btf.size()),
|
FieldField<PatchField, Type>(btf.size()),
|
||||||
bmesh_(btf.bmesh_)
|
bmesh_(btf.bmesh_)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// DebugInFunction << nl;
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
forAll(bmesh_, patchi)
|
forAll(bmesh_, patchi)
|
||||||
{
|
{
|
||||||
@ -508,10 +493,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
|
|||||||
FieldField<PatchField, Type>(btf.size()),
|
FieldField<PatchField, Type>(btf.size()),
|
||||||
bmesh_(btf.bmesh_)
|
bmesh_(btf.bmesh_)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// DebugInFunction << nl;
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
for (const label patchi : patchIDs)
|
for (const label patchi : patchIDs)
|
||||||
{
|
{
|
||||||
@ -545,12 +527,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
|
|||||||
:
|
:
|
||||||
FieldField<PatchField, Type>(btf),
|
FieldField<PatchField, Type>(btf),
|
||||||
bmesh_(btf.bmesh_)
|
bmesh_(btf.bmesh_)
|
||||||
{
|
{}
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
@ -573,10 +550,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
|
|||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::updateCoeffs()
|
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::updateCoeffs()
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// DebugInFunction << nl;
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
for (auto& pfld : *this)
|
for (auto& pfld : *this)
|
||||||
{
|
{
|
||||||
@ -586,32 +560,26 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::updateCoeffs()
|
|||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
|
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType
|
||||||
|
)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
|
||||||
const label startOfRequests = UPstream::nRequests();
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
commsType == UPstream::commsTypes::buffered
|
commsType == UPstream::commsTypes::buffered
|
||||||
|| commsType == UPstream::commsTypes::nonBlocking
|
|| commsType == UPstream::commsTypes::nonBlocking
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
const label startOfRequests = UPstream::nRequests();
|
||||||
|
|
||||||
for (auto& pfld : *this)
|
for (auto& pfld : *this)
|
||||||
{
|
{
|
||||||
pfld.initEvaluate(commsType);
|
pfld.initEvaluate(commsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for outstanding requests
|
// Wait for outstanding requests (non-blocking)
|
||||||
if (commsType == Pstream::commsTypes::nonBlocking)
|
UPstream::waitRequests(startOfRequests);
|
||||||
{
|
|
||||||
UPstream::waitRequests(startOfRequests);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& pfld : *this)
|
for (auto& pfld : *this)
|
||||||
{
|
{
|
||||||
@ -641,8 +609,74 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unsupported communications type "
|
<< "Unsupported communications type " << int(commsType) << nl
|
||||||
<< UPstream::commsTypeNames[commsType]
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
template<class UnaryPredicate>
|
||||||
|
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate_if
|
||||||
|
(
|
||||||
|
const UnaryPredicate& pred,
|
||||||
|
const UPstream::commsTypes commsType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
commsType == UPstream::commsTypes::buffered
|
||||||
|
|| commsType == UPstream::commsTypes::nonBlocking
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const label startOfRequests = UPstream::nRequests();
|
||||||
|
|
||||||
|
for (auto& pfld : *this)
|
||||||
|
{
|
||||||
|
if (pred(pfld))
|
||||||
|
{
|
||||||
|
pfld.initEvaluate(commsType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for outstanding requests (non-blocking)
|
||||||
|
UPstream::waitRequests(startOfRequests);
|
||||||
|
|
||||||
|
for (auto& pfld : *this)
|
||||||
|
{
|
||||||
|
if (pred(pfld))
|
||||||
|
{
|
||||||
|
pfld.evaluate(commsType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (commsType == UPstream::commsTypes::scheduled)
|
||||||
|
{
|
||||||
|
const lduSchedule& patchSchedule =
|
||||||
|
bmesh_.mesh().globalData().patchSchedule();
|
||||||
|
|
||||||
|
for (const auto& schedEval : patchSchedule)
|
||||||
|
{
|
||||||
|
const label patchi = schedEval.patch;
|
||||||
|
auto& pfld = (*this)[patchi];
|
||||||
|
|
||||||
|
if (pred(pfld))
|
||||||
|
{
|
||||||
|
if (schedEval.init)
|
||||||
|
{
|
||||||
|
pfld.initEvaluate(commsType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pfld.evaluate(commsType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Unsupported communications type " << int(commsType) << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -651,58 +685,60 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
|
|||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateSelected
|
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateSelected
|
||||||
(
|
(
|
||||||
const UList<label>& patchIDs
|
const labelUList& patchIDs
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
const label startOfRequests = UPstream::nRequests();
|
||||||
|
|
||||||
for (const label patchi : patchIDs)
|
for (const label patchi : patchIDs)
|
||||||
{
|
{
|
||||||
auto& pf = (*this)[patchi];
|
auto& pfld = (*this)[patchi];
|
||||||
|
|
||||||
DebugInfo<< "Updating " << pf.patch().name() << endl;
|
DebugInfo<< "Updating " << pfld.patch().name() << endl;
|
||||||
|
|
||||||
const label startOfRequests = UPstream::nRequests();
|
pfld.initEvaluate(UPstream::commsTypes::nonBlocking);
|
||||||
|
}
|
||||||
|
|
||||||
pf.initEvaluate(UPstream::commsTypes::nonBlocking);
|
// Wait for outstanding requests (non-blocking)
|
||||||
|
UPstream::waitRequests(startOfRequests);
|
||||||
|
|
||||||
UPstream::waitRequests(startOfRequests);
|
for (const label patchi : patchIDs)
|
||||||
|
{
|
||||||
|
auto& pfld = (*this)[patchi];
|
||||||
|
|
||||||
pf.evaluate(UPstream::commsTypes::nonBlocking);
|
pfld.evaluate(UPstream::commsTypes::nonBlocking);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateLocal()
|
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateLocal
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType
|
||||||
|
)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// DebugInFunction << nl;
|
||||||
///{
|
|
||||||
/// InfoInFunction << nl;
|
|
||||||
///}
|
|
||||||
|
|
||||||
if (!localConsistency)
|
if (!localConsistency)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
|
||||||
const label startOfRequests = UPstream::nRequests();
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
commsType == UPstream::commsTypes::buffered
|
commsType == UPstream::commsTypes::buffered
|
||||||
|| commsType == UPstream::commsTypes::nonBlocking
|
|| commsType == UPstream::commsTypes::nonBlocking
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
const label startOfRequests = UPstream::nRequests();
|
||||||
|
|
||||||
for (auto& pfld : *this)
|
for (auto& pfld : *this)
|
||||||
{
|
{
|
||||||
pfld.initEvaluateLocal(commsType);
|
pfld.initEvaluateLocal(commsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for outstanding requests
|
// Wait for outstanding requests (non-blocking)
|
||||||
if (commsType == Pstream::commsTypes::nonBlocking)
|
UPstream::waitRequests(startOfRequests);
|
||||||
{
|
|
||||||
UPstream::waitRequests(startOfRequests);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& pfld : *this)
|
for (auto& pfld : *this)
|
||||||
{
|
{
|
||||||
@ -732,8 +768,7 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateLocal()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unsupported communications type "
|
<< "Unsupported communications type " << int(commsType) << nl
|
||||||
<< UPstream::commsTypeNames[commsType]
|
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -741,17 +776,24 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateLocal()
|
|||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
template<class CoupledPatchType>
|
template<class CoupledPatchType>
|
||||||
void
|
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateCoupled
|
||||||
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>
|
(
|
||||||
::evaluateCoupled()
|
const UPstream::commsTypes commsType
|
||||||
|
)
|
||||||
{
|
{
|
||||||
///if (GeometricField<Type, PatchField, GeoMesh::debug)
|
// Alternative (C++14)
|
||||||
///{
|
//
|
||||||
/// InfoInFunction << nl;
|
// this->evaluate_if
|
||||||
///}
|
// (
|
||||||
|
// [](const auto& pfld) -> bool
|
||||||
|
// {
|
||||||
|
// const auto* cpp = isA<CoupledPatchType>(pfld.patch());
|
||||||
|
// return (cpp && cpp->coupled());
|
||||||
|
// },
|
||||||
|
// commsType
|
||||||
|
// );
|
||||||
|
|
||||||
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
|
// DebugInFunction << nl;
|
||||||
const label startOfRequests = UPstream::nRequests();
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -759,6 +801,8 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>
|
|||||||
|| commsType == UPstream::commsTypes::nonBlocking
|
|| commsType == UPstream::commsTypes::nonBlocking
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
const label startOfRequests = UPstream::nRequests();
|
||||||
|
|
||||||
for (auto& pfld : *this)
|
for (auto& pfld : *this)
|
||||||
{
|
{
|
||||||
const auto* cpp = isA<CoupledPatchType>(pfld.patch());
|
const auto* cpp = isA<CoupledPatchType>(pfld.patch());
|
||||||
@ -769,11 +813,8 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for outstanding requests
|
// Wait for outstanding requests (non-blocking)
|
||||||
if (commsType == UPstream::commsTypes::nonBlocking)
|
UPstream::waitRequests(startOfRequests);
|
||||||
{
|
|
||||||
UPstream::waitRequests(startOfRequests);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& pfld : *this)
|
for (auto& pfld : *this)
|
||||||
{
|
{
|
||||||
@ -813,8 +854,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unsupported communications type "
|
<< "Unsupported communications type " << int(commsType) << nl
|
||||||
<< UPstream::commsTypeNames[commsType]
|
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017,2022 OpenFOAM Foundation
|
Copyright (C) 2011-2017,2022 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -49,12 +49,6 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward Declarations
|
|
||||||
class dictionary;
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
|
||||||
class GeometricField;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class GeometricBoundaryField Declaration
|
Class GeometricBoundaryField Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -74,6 +68,9 @@ public:
|
|||||||
//- The internal field type associated with the boundary fields
|
//- The internal field type associated with the boundary fields
|
||||||
typedef DimensionedField<Type, GeoMesh> Internal;
|
typedef DimensionedField<Type, GeoMesh> Internal;
|
||||||
|
|
||||||
|
//- This boundary field type
|
||||||
|
typedef GeometricBoundaryField<Type, PatchField, GeoMesh> Boundary;
|
||||||
|
|
||||||
//- The patch field type for the boundary fields
|
//- The patch field type for the boundary fields
|
||||||
typedef PatchField<Type> Patch;
|
typedef PatchField<Type> Patch;
|
||||||
|
|
||||||
@ -182,18 +179,40 @@ public:
|
|||||||
//- Update the boundary condition coefficients
|
//- Update the boundary condition coefficients
|
||||||
void updateCoeffs();
|
void updateCoeffs();
|
||||||
|
|
||||||
//- Evaluate boundary conditions
|
//- Evaluate boundary conditions for each patch field.
|
||||||
void evaluate();
|
//- Uses specified or default comms.
|
||||||
|
void evaluate
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType = UPstream::defaultCommsType
|
||||||
|
);
|
||||||
|
|
||||||
//- Evaluate boundary conditions after change in local values
|
//- Evaluate boundary conditions for patch fields matching the
|
||||||
void evaluateLocal();
|
//- given predicate. Uses specified or default comms.
|
||||||
|
template<class UnaryPredicate>
|
||||||
|
void evaluate_if
|
||||||
|
(
|
||||||
|
const UnaryPredicate& pred,
|
||||||
|
const UPstream::commsTypes commsType = UPstream::defaultCommsType
|
||||||
|
);
|
||||||
|
|
||||||
//- Evaluate boundary conditions on a subset of coupled patches
|
//- Evaluate boundary conditions after change in local values.
|
||||||
|
//- Uses specified or default comms.
|
||||||
|
void evaluateLocal
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType = UPstream::defaultCommsType
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Evaluate boundary conditions on coupled patches of given type.
|
||||||
|
//- Uses specified or default comms.
|
||||||
template<class CoupledPatchType>
|
template<class CoupledPatchType>
|
||||||
void evaluateCoupled();
|
void evaluateCoupled
|
||||||
|
(
|
||||||
|
const UPstream::commsTypes commsType = UPstream::defaultCommsType
|
||||||
|
);
|
||||||
|
|
||||||
//- Evaluate boundary conditions for selected patches
|
//- Evaluate boundary conditions for selected patches.
|
||||||
void evaluateSelected(const UList<label>& patchIDs);
|
//- Uses non-blocking comms.
|
||||||
|
void evaluateSelected(const labelUList& patchIDs);
|
||||||
|
|
||||||
//- Return a list of the patch types
|
//- Return a list of the patch types
|
||||||
wordList types() const;
|
wordList types() const;
|
||||||
@ -209,15 +228,18 @@ public:
|
|||||||
//- pointing to interfaces being set
|
//- pointing to interfaces being set
|
||||||
lduInterfaceFieldPtrsList scalarInterfaces() const;
|
lduInterfaceFieldPtrsList scalarInterfaces() const;
|
||||||
|
|
||||||
|
//- Helper: check if field has been evaluated. See instantiations.
|
||||||
|
bool check() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
//- Write boundary field as dictionary entry
|
//- Write boundary field as dictionary entry
|
||||||
void writeEntry(const word& keyword, Ostream& os) const;
|
void writeEntry(const word& keyword, Ostream& os) const;
|
||||||
|
|
||||||
//- Write dictionary entries of the individual boundary fields.
|
//- Write dictionary entries of the individual boundary fields.
|
||||||
void writeEntries(Ostream& os) const;
|
void writeEntries(Ostream& os) const;
|
||||||
|
|
||||||
//- Helper: check if field has been evaluated. See instantiations.
|
|
||||||
bool check() const;
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,7 +28,6 @@ License
|
|||||||
|
|
||||||
#include "GeometricField.H"
|
#include "GeometricField.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "demandDrivenData.H"
|
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "localIOdictionary.H"
|
#include "localIOdictionary.H"
|
||||||
#include "meshState.H"
|
#include "meshState.H"
|
||||||
@ -77,19 +76,22 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::readFields
|
|||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::readFields()
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::readFields()
|
||||||
{
|
{
|
||||||
const localIOdictionary dict
|
dictionary dict
|
||||||
(
|
(
|
||||||
IOobject
|
localIOdictionary::readContents
|
||||||
(
|
(
|
||||||
this->name(),
|
IOobject
|
||||||
this->instance(),
|
(
|
||||||
this->local(),
|
this->name(),
|
||||||
this->db(),
|
this->instance(),
|
||||||
IOobjectOption::MUST_READ,
|
this->local(),
|
||||||
IOobjectOption::NO_WRITE,
|
this->db(),
|
||||||
IOobjectOption::NO_REGISTER
|
IOobjectOption::MUST_READ,
|
||||||
),
|
IOobjectOption::NO_WRITE,
|
||||||
typeName
|
IOobjectOption::NO_REGISTER
|
||||||
|
),
|
||||||
|
typeName
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
this->close();
|
this->close();
|
||||||
@ -111,10 +113,7 @@ bool Foam::GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
|
|||||||
else if
|
else if
|
||||||
(
|
(
|
||||||
this->isReadOptional()
|
this->isReadOptional()
|
||||||
&& this->template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
|
&& this->template typeHeaderOk<this_type>(true) // checkType = true
|
||||||
(
|
|
||||||
true
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
readFields();
|
readFields();
|
||||||
@ -143,20 +142,13 @@ bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent()
|
|||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
field0.template typeHeaderOk<GeometricField<Type, PatchField, GeoMesh>>
|
field0.template typeHeaderOk<this_type>(true) // checkType = true
|
||||||
(
|
|
||||||
true
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
<< "Reading old time level for field" << nl << this->info() << endl;
|
<< "Reading old time level for field" << nl << this->info() << endl;
|
||||||
|
|
||||||
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
|
field0Ptr_ = std::make_unique<this_type>(field0, this->mesh());
|
||||||
(
|
|
||||||
field0,
|
|
||||||
this->mesh()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Ensure the old time field oriented flag is set to the parent's state
|
// Ensure the old time field oriented flag is set to the parent's state
|
||||||
// Note: required for backwards compatibility in case of restarting from
|
// Note: required for backwards compatibility in case of restarting from
|
||||||
@ -190,8 +182,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dims, false),
|
Internal(io, mesh, dims, false),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -213,8 +203,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dims, false),
|
Internal(io, mesh, dims, false),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes)
|
boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -236,8 +224,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, value, dims, false),
|
Internal(io, mesh, value, dims, false),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -262,8 +248,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, value, dims, false),
|
Internal(io, mesh, value, dims, false),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes)
|
boundaryField_(mesh.boundary(), *this, patchFieldTypes, actualPatchTypes)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -327,8 +311,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, diField),
|
Internal(io, diField),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -348,8 +330,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, std::move(diField)),
|
Internal(io, std::move(diField)),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -369,8 +349,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, tfield),
|
Internal(io, tfield),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -389,8 +367,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(diField),
|
Internal(diField),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -409,8 +385,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(std::move(diField)),
|
Internal(std::move(diField)),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
boundaryField_(this->mesh().boundary(), *this, ptfl)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -432,8 +406,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dims, iField),
|
Internal(io, mesh, dims, iField),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -455,8 +427,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dims, std::move(iField)),
|
Internal(io, mesh, dims, std::move(iField)),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -478,8 +448,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dims, iField),
|
Internal(io, mesh, dims, iField),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, ptfl)
|
boundaryField_(mesh.boundary(), *this, ptfl)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -501,8 +469,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dims, std::move(iField)),
|
Internal(io, mesh, dims, std::move(iField)),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, ptfl)
|
boundaryField_(mesh.boundary(), *this, ptfl)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -524,8 +490,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dims, tfield),
|
Internal(io, mesh, dims, tfield),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary(), *this, ptfl)
|
boundaryField_(mesh.boundary(), *this, ptfl)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -545,8 +509,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dimless, false),
|
Internal(io, mesh, dimless, false),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary())
|
boundaryField_(mesh.boundary())
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -584,8 +546,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, mesh, dimless, false),
|
Internal(io, mesh, dimless, false),
|
||||||
timeIndex_(this->time().timeIndex()),
|
timeIndex_(this->time().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(mesh.boundary())
|
boundaryField_(mesh.boundary())
|
||||||
{
|
{
|
||||||
readFields(dict);
|
readFields(dict);
|
||||||
@ -603,8 +563,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(gf),
|
Internal(gf),
|
||||||
timeIndex_(gf.timeIndex()),
|
timeIndex_(gf.timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(*this, gf.boundaryField_)
|
boundaryField_(*this, gf.boundaryField_)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -612,10 +570,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
|
|
||||||
if (gf.field0Ptr_)
|
if (gf.field0Ptr_)
|
||||||
{
|
{
|
||||||
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
|
field0Ptr_ = std::make_unique<this_type>(*gf.field0Ptr_);
|
||||||
(
|
|
||||||
*gf.field0Ptr_
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->writeOpt(IOobjectOption::NO_WRITE);
|
this->writeOpt(IOobjectOption::NO_WRITE);
|
||||||
@ -630,8 +585,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(tgf.constCast(), tgf.movable()),
|
Internal(tgf.constCast(), tgf.movable()),
|
||||||
timeIndex_(tgf().timeIndex()),
|
timeIndex_(tgf().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(*this, tgf().boundaryField_)
|
boundaryField_(*this, tgf().boundaryField_)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -652,8 +605,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, gf),
|
Internal(io, gf),
|
||||||
timeIndex_(gf.timeIndex()),
|
timeIndex_(gf.timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(*this, gf.boundaryField_)
|
boundaryField_(*this, gf.boundaryField_)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -662,7 +613,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
|
|
||||||
if (!readIfPresent() && gf.field0Ptr_)
|
if (!readIfPresent() && gf.field0Ptr_)
|
||||||
{
|
{
|
||||||
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
|
field0Ptr_ = std::make_unique<this_type>
|
||||||
(
|
(
|
||||||
io.name() + "_0",
|
io.name() + "_0",
|
||||||
*gf.field0Ptr_
|
*gf.field0Ptr_
|
||||||
@ -680,8 +631,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, tgf.constCast(), tgf.movable()),
|
Internal(io, tgf.constCast(), tgf.movable()),
|
||||||
timeIndex_(tgf().timeIndex()),
|
timeIndex_(tgf().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(*this, tgf().boundaryField_)
|
boundaryField_(*this, tgf().boundaryField_)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -703,8 +652,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(newName, gf),
|
Internal(newName, gf),
|
||||||
timeIndex_(gf.timeIndex()),
|
timeIndex_(gf.timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(*this, gf.boundaryField_)
|
boundaryField_(*this, gf.boundaryField_)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -713,7 +660,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
|
|
||||||
if (!readIfPresent() && gf.field0Ptr_)
|
if (!readIfPresent() && gf.field0Ptr_)
|
||||||
{
|
{
|
||||||
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
|
field0Ptr_ = std::make_unique<this_type>
|
||||||
(
|
(
|
||||||
newName + "_0",
|
newName + "_0",
|
||||||
*gf.field0Ptr_
|
*gf.field0Ptr_
|
||||||
@ -731,8 +678,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(newName, tgf.constCast(), tgf.movable()),
|
Internal(newName, tgf.constCast(), tgf.movable()),
|
||||||
timeIndex_(tgf().timeIndex()),
|
timeIndex_(tgf().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(*this, tgf().boundaryField_)
|
boundaryField_(*this, tgf().boundaryField_)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -753,8 +698,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, gf),
|
Internal(io, gf),
|
||||||
timeIndex_(gf.timeIndex()),
|
timeIndex_(gf.timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(this->mesh().boundary(), *this, patchFieldType)
|
boundaryField_(this->mesh().boundary(), *this, patchFieldType)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -765,7 +708,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
|
|
||||||
if (!readIfPresent() && gf.field0Ptr_)
|
if (!readIfPresent() && gf.field0Ptr_)
|
||||||
{
|
{
|
||||||
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
|
field0Ptr_ = std::make_unique<this_type>
|
||||||
(
|
(
|
||||||
io.name() + "_0",
|
io.name() + "_0",
|
||||||
*gf.field0Ptr_
|
*gf.field0Ptr_
|
||||||
@ -785,8 +728,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, gf),
|
Internal(io, gf),
|
||||||
timeIndex_(gf.timeIndex()),
|
timeIndex_(gf.timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_
|
boundaryField_
|
||||||
(
|
(
|
||||||
this->mesh().boundary(),
|
this->mesh().boundary(),
|
||||||
@ -803,7 +744,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
|
|
||||||
if (!readIfPresent() && gf.field0Ptr_)
|
if (!readIfPresent() && gf.field0Ptr_)
|
||||||
{
|
{
|
||||||
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
|
field0Ptr_ = std::make_unique<this_type>
|
||||||
(
|
(
|
||||||
io.name() + "_0",
|
io.name() + "_0",
|
||||||
*gf.field0Ptr_
|
*gf.field0Ptr_
|
||||||
@ -823,8 +764,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, gf),
|
Internal(io, gf),
|
||||||
timeIndex_(gf.timeIndex()),
|
timeIndex_(gf.timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_(*this, gf.boundaryField_, patchIDs, patchFieldType)
|
boundaryField_(*this, gf.boundaryField_, patchIDs, patchFieldType)
|
||||||
{
|
{
|
||||||
DebugInFunction
|
DebugInFunction
|
||||||
@ -834,7 +773,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
|
|
||||||
if (!readIfPresent() && gf.field0Ptr_)
|
if (!readIfPresent() && gf.field0Ptr_)
|
||||||
{
|
{
|
||||||
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
|
field0Ptr_ = std::make_unique<this_type>
|
||||||
(
|
(
|
||||||
io.name() + "_0",
|
io.name() + "_0",
|
||||||
*gf.field0Ptr_
|
*gf.field0Ptr_
|
||||||
@ -854,8 +793,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
|||||||
:
|
:
|
||||||
Internal(io, tgf.constCast(), tgf.movable()),
|
Internal(io, tgf.constCast(), tgf.movable()),
|
||||||
timeIndex_(tgf().timeIndex()),
|
timeIndex_(tgf().timeIndex()),
|
||||||
field0Ptr_(nullptr),
|
|
||||||
fieldPrevIterPtr_(nullptr),
|
|
||||||
boundaryField_
|
boundaryField_
|
||||||
(
|
(
|
||||||
this->mesh().boundary(),
|
this->mesh().boundary(),
|
||||||
@ -897,13 +834,8 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::~GeometricField()
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
deleteDemandDrivenData(field0Ptr_);
|
|
||||||
deleteDemandDrivenData(fieldPrevIterPtr_);
|
|
||||||
|
|
||||||
// FUTURE: register cache field info
|
// FUTURE: register cache field info
|
||||||
// // this->db().cacheTemporaryObject(*this);
|
// // this->db().cacheTemporaryObject(*this);
|
||||||
|
|
||||||
clearOldTimes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1014,7 +946,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() const
|
|||||||
{
|
{
|
||||||
if (!field0Ptr_)
|
if (!field0Ptr_)
|
||||||
{
|
{
|
||||||
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
|
field0Ptr_ = std::make_unique<this_type>
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
@ -1068,7 +1000,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::storePrevIter() const
|
|||||||
<< "Allocating previous iteration field" << nl
|
<< "Allocating previous iteration field" << nl
|
||||||
<< this->info() << endl;
|
<< this->info() << endl;
|
||||||
|
|
||||||
fieldPrevIterPtr_ = new GeometricField<Type, PatchField, GeoMesh>
|
fieldPrevIterPtr_ = std::make_unique<this_type>
|
||||||
(
|
(
|
||||||
this->name() + "PrevIter",
|
this->name() + "PrevIter",
|
||||||
*this
|
*this
|
||||||
@ -1101,8 +1033,8 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::prevIter() const
|
|||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::clearOldTimes()
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::clearOldTimes()
|
||||||
{
|
{
|
||||||
deleteDemandDrivenData(field0Ptr_);
|
field0Ptr_.reset(nullptr);
|
||||||
deleteDemandDrivenData(fieldPrevIterPtr_);
|
fieldPrevIterPtr_.reset(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1110,8 +1042,11 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
|||||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::
|
||||||
correctBoundaryConditions()
|
correctBoundaryConditions()
|
||||||
{
|
{
|
||||||
this->setUpToDate();
|
// updateAccessTime
|
||||||
storeOldTimes();
|
{
|
||||||
|
this->setUpToDate();
|
||||||
|
storeOldTimes();
|
||||||
|
}
|
||||||
boundaryField_.evaluate();
|
boundaryField_.evaluate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1120,8 +1055,11 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
|||||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::
|
||||||
correctLocalBoundaryConditions()
|
correctLocalBoundaryConditions()
|
||||||
{
|
{
|
||||||
this->setUpToDate();
|
// updateAccessTime
|
||||||
storeOldTimes();
|
{
|
||||||
|
this->setUpToDate();
|
||||||
|
storeOldTimes();
|
||||||
|
}
|
||||||
boundaryField_.evaluateLocal();
|
boundaryField_.evaluateLocal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1208,7 +1146,11 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
|||||||
bool Foam::GeometricField<Type, PatchField, GeoMesh>::
|
bool Foam::GeometricField<Type, PatchField, GeoMesh>::
|
||||||
writeData(Ostream& os) const
|
writeData(Ostream& os) const
|
||||||
{
|
{
|
||||||
os << *this;
|
this->internalField().writeData(os, "internalField");
|
||||||
|
os << nl;
|
||||||
|
this->boundaryField().writeEntry("boundaryField", os);
|
||||||
|
|
||||||
|
os.check(FUNCTION_NAME);
|
||||||
return os.good();
|
return os.good();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1540,14 +1482,10 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
|||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const GeometricField<Type, PatchField, GeoMesh>& gf
|
const GeometricField<Type, PatchField, GeoMesh>& fld
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
gf.internalField().writeData(os, "internalField");
|
fld.writeData(os);
|
||||||
os << nl;
|
|
||||||
gf.boundaryField().writeEntry("boundaryField", os);
|
|
||||||
|
|
||||||
os.check(FUNCTION_NAME);
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1556,11 +1494,12 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
|||||||
Foam::Ostream& Foam::operator<<
|
Foam::Ostream& Foam::operator<<
|
||||||
(
|
(
|
||||||
Ostream& os,
|
Ostream& os,
|
||||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
os << tgf();
|
tfld().writeData(os);
|
||||||
tgf.clear();
|
tfld.clear();
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,6 @@ SourceFiles
|
|||||||
#ifndef Foam_GeometricField_H
|
#ifndef Foam_GeometricField_H
|
||||||
#define Foam_GeometricField_H
|
#define Foam_GeometricField_H
|
||||||
|
|
||||||
#include "regIOobject.H"
|
|
||||||
#include "GeometricBoundaryField.H"
|
#include "GeometricBoundaryField.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -50,7 +49,6 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
class dictionary;
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
class GeometricField;
|
class GeometricField;
|
||||||
@ -104,6 +102,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// Private Typedefs
|
||||||
|
|
||||||
|
//- The GeometricField type
|
||||||
|
typedef GeometricField<Type, PatchField, GeoMesh> this_type;
|
||||||
|
|
||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
//- Current time index.
|
//- Current time index.
|
||||||
@ -111,10 +115,10 @@ private:
|
|||||||
mutable label timeIndex_;
|
mutable label timeIndex_;
|
||||||
|
|
||||||
//- Pointer to old time field
|
//- Pointer to old time field
|
||||||
mutable GeometricField<Type, PatchField, GeoMesh>* field0Ptr_;
|
mutable std::unique_ptr<this_type> field0Ptr_;
|
||||||
|
|
||||||
//- Pointer to previous iteration (used for under-relaxation)
|
//- Pointer to previous iteration (used for under-relaxation)
|
||||||
mutable GeometricField<Type, PatchField, GeoMesh>* fieldPrevIterPtr_;
|
mutable std::unique_ptr<this_type> fieldPrevIterPtr_;
|
||||||
|
|
||||||
//- Boundary field containing boundary field values
|
//- Boundary field containing boundary field values
|
||||||
Boundary boundaryField_;
|
Boundary boundaryField_;
|
||||||
@ -871,8 +875,8 @@ public:
|
|||||||
//- Correct boundary field
|
//- Correct boundary field
|
||||||
void correctBoundaryConditions();
|
void correctBoundaryConditions();
|
||||||
|
|
||||||
//- Correct boundary conditions after a purely local operation. Is
|
//- Correct boundary conditions after a purely local operation.
|
||||||
// dummy for e.g. processor boundary conditions
|
// Is dummy for processor boundary conditions etc
|
||||||
void correctLocalBoundaryConditions();
|
void correctLocalBoundaryConditions();
|
||||||
|
|
||||||
//- Does the field need a reference level for solution
|
//- Does the field need a reference level for solution
|
||||||
@ -1008,19 +1012,20 @@ public:
|
|||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
//- The writeData function (required by regIOobject),
|
//- The writeData function (required by regIOobject)
|
||||||
//- calls operator<<
|
|
||||||
bool writeData(Ostream& os) const;
|
bool writeData(Ostream& os) const;
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operators
|
// Ostream Operators
|
||||||
|
|
||||||
|
//- Calls GeometricField::writeData()
|
||||||
friend Ostream& operator<< <Type, PatchField, GeoMesh>
|
friend Ostream& operator<< <Type, PatchField, GeoMesh>
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
const GeometricField<Type, PatchField, GeoMesh>&
|
const GeometricField<Type, PatchField, GeoMesh>&
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Calls GeometricField::writeData()
|
||||||
friend Ostream& operator<< <Type, PatchField, GeoMesh>
|
friend Ostream& operator<< <Type, PatchField, GeoMesh>
|
||||||
(
|
(
|
||||||
Ostream&,
|
Ostream&,
|
||||||
|
|||||||
Reference in New Issue
Block a user