ENH: Added GeometricField copy constructor with additional BC handling. See #1620

Often we want to copy a field and replace boundary conditions, e.g. change type
to calculated for some patches.  This has typically been achieved by creating a
word list of new patch types which are then fed through to the fvPatchField::New
factory method.  This is OK for types that require no additional input (usually
from dictionary) but leaves other more complex types partially
constructed/usable.

The new constructor clones all BCs except those with indices specified, for
which the fvPatchField::New method is called for the supplied patch field type.
This commit is contained in:
Andrew Heather
2020-03-11 15:16:52 +00:00
parent 149c1b66f3
commit 0eecec4811
3 changed files with 134 additions and 63 deletions

View File

@ -660,6 +660,37 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
(
const IOobject& io,
const GeometricField<Type, PatchField, GeoMesh>& gf,
const labelList& patchIDs,
const word& patchFieldType
)
:
Internal(io, gf),
timeIndex_(gf.timeIndex()),
field0Ptr_(nullptr),
fieldPrevIterPtr_(nullptr),
boundaryField_(*this, gf.boundaryField_, patchIDs, patchFieldType)
{
DebugInFunction
<< "Copy construct, resetting IO params and setting patchFieldType "
<< "for patchIDs" << nl
<< this->info() << endl;
if (!readIfPresent() && gf.field0Ptr_)
{
field0Ptr_ = new GeometricField<Type, PatchField, GeoMesh>
(
io.name() + "_0",
*gf.field0Ptr_
);
}
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
(