mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user