From bc5a55f7e65d07fc91cf9b08f23a645ad7297671 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Fri, 12 Nov 2021 18:22:54 +0000 Subject: [PATCH] ENH: regIOobject: factory method from IO. - compiles - deepClone (not needed at the moment) - objectRegistry::subRegistry with fileName - Time::null object so IOobject can be constructed without objectRegistry --- .../dragModels/PDRDragModel/PDRDragModel.H | 7 + .../IOobjects/CompactIOField/CompactIOField.H | 6 + .../IOobjects/CompactIOList/CompactIOList.H | 7 + .../IOobjects/GlobalIOField/GlobalIOField.H | 6 + .../db/IOobjects/GlobalIOList/GlobalIOList.H | 6 + src/OpenFOAM/db/IOobjects/IOField/IOField.H | 6 + src/OpenFOAM/db/IOobjects/IOList/IOList.H | 6 + src/OpenFOAM/db/IOobjects/IOMap/IOMap.H | 8 +- .../db/IOobjects/IOPtrList/IOPtrList.H | 6 + .../db/IOobjects/IOdictionary/IOdictionary.H | 9 + .../IOdictionary/localIOdictionary.H | 9 + .../IOdictionary/unwatchedIOdictionary.H | 9 + src/OpenFOAM/db/Time/Time.H | 3 + .../db/objectRegistry/objectRegistry.C | 18 ++ .../db/objectRegistry/objectRegistry.H | 30 ++- src/OpenFOAM/db/regIOobject/regIOobject.C | 37 ++++ src/OpenFOAM/db/regIOobject/regIOobject.H | 40 ++++ .../construction/addToRunTimeSelectionTable.H | 9 + .../construction/runTimeSelectionTables.H | 109 ++++++++++- .../Function1/Function1Expression.C | 4 +- .../Function1/Function1Expression.H | 2 +- .../exprResult/exprResultGlobals.H | 12 ++ .../DimensionedField/DimensionedField.H | 6 + .../GeometricField/GeometricField.H | 12 +- .../GeometricField/GeometricFieldNew.C | 26 ++- .../GeometricFields/pointFields/pointFields.C | 32 ++++ .../UniformDimensionedField.H | 14 ++ .../uniformDimensionedFields.C | 34 ++++ src/OpenFOAM/global/globals.C | 12 ++ src/OpenFOAM/meshes/GeoMesh/GeoMesh.H | 20 +- src/OpenFOAM/meshes/MeshObject/MeshObject.H | 7 + src/OpenFOAM/meshes/pointMesh/pointMesh.C | 14 +- src/OpenFOAM/meshes/pointMesh/pointMesh.H | 16 +- .../mapDistribute/IOmapDistribute.H | 9 + .../polyBoundaryMesh/polyBoundaryMesh.H | 7 + .../polyBoundaryMeshEntries.H | 14 ++ .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H | 7 + .../primitives/functions/Function1/CSV/CSV.C | 30 ++- .../primitives/functions/Function1/CSV/CSV.H | 16 +- .../functions/Function1/Constant/Constant.C | 40 +++- .../functions/Function1/Constant/Constant.H | 5 +- .../functions/Function1/Cosine/Cosine.H | 7 + .../functions/Function1/Function1/Function1.C | 24 ++- .../functions/Function1/Function1/Function1.H | 84 ++++++++- .../Function1/Function1/Function1New.C | 173 ++++++++++++++++++ .../Function1/Function1/function1Base.C | 49 ++++- .../Function1/Function1/function1Base.H | 28 +-- .../Function1/LimitRange/LimitRange.C | 21 ++- .../Function1/LimitRange/LimitRange.H | 7 +- .../functions/Function1/One/OneConstant.C | 16 +- .../functions/Function1/One/OneConstant.H | 5 +- .../Function1/Polynomial/PolynomialEntry.C | 43 ++++- .../Function1/Polynomial/PolynomialEntry.H | 5 +- .../functions/Function1/Scale/Scale.C | 21 ++- .../functions/Function1/Scale/Scale.H | 11 +- .../functions/Function1/Sine/Sine.C | 26 ++- .../functions/Function1/Sine/Sine.H | 5 +- .../functions/Function1/Square/Square.C | 17 +- .../functions/Function1/Square/Square.H | 5 +- .../functions/Function1/Table/Table.C | 62 ++++++- .../functions/Function1/Table/Table.H | 5 +- .../functions/Function1/Table/TableBase.C | 36 +++- .../functions/Function1/Table/TableBase.H | 5 +- .../functions/Function1/TableFile/TableFile.C | 34 +++- .../functions/Function1/TableFile/TableFile.H | 5 +- .../functions/Function1/Uniform/Uniform.C | 11 ++ .../functions/Function1/Uniform/Uniform.H | 3 + .../functions/Function1/Zero/ZeroConstant.C | 16 +- .../functions/Function1/Zero/ZeroConstant.H | 5 +- .../Function1/halfCosineRamp/halfCosineRamp.C | 10 + .../Function1/halfCosineRamp/halfCosineRamp.H | 3 + .../Function1/linearRamp/linearRamp.C | 10 + .../Function1/linearRamp/linearRamp.H | 3 + .../functions/Function1/makeFunction1s.C | 42 +++++ .../Function1/quadraticRamp/quadraticRamp.C | 10 + .../Function1/quadraticRamp/quadraticRamp.H | 3 + .../quarterCosineRamp/quarterCosineRamp.C | 10 + .../quarterCosineRamp/quarterCosineRamp.H | 3 + .../quarterSineRamp/quarterSineRamp.C | 10 + .../quarterSineRamp/quarterSineRamp.H | 3 + .../functions/Function1/ramp/ramp.C | 20 +- .../functions/Function1/ramp/ramp.H | 11 +- .../functions/Function1/step/stepFunction.C | 13 ++ .../functions/Function1/step/stepFunction.H | 7 + .../surfactantProperties.H | 2 +- .../hexRef8/refinementHistory.H | 9 + .../polyTopoChanger/polyTopoChanger.H | 7 + src/finiteArea/edgeMesh/edgeFaMesh.H | 1 + .../faMesh/faBoundaryMesh/faBoundaryMesh.H | 7 + .../porosityModel/porosityModel.H | 7 + .../solutionControl/solutionControl.H | 7 + .../expressions/base/fvExprDriverWriter.H | 7 + .../fields/surfaceFields/surfaceFields.C | 13 +- src/finiteVolume/fields/volFields/volFields.C | 9 +- .../lduPrimitiveMeshAssembly.H | 7 + src/finiteVolume/surfaceMesh/surfaceMesh.H | 13 ++ src/finiteVolume/volMesh/volMesh.H | 12 ++ src/lagrangian/basic/IOPosition/IOPosition.H | 7 + .../MPPIC/AveragingMethods/Basic/Basic.H | 6 + .../MPPIC/AveragingMethods/Dual/Dual.H | 6 + .../MPPIC/AveragingMethods/Moment/Moment.H | 6 + .../movement/lumpedPointIOMovement.H | 7 + .../cyclicAMIPointPatch/cyclicAMIPointPatch.C | 2 +- .../PatchFunction1/MappedFile/rawIOField.H | 6 + .../coordinate/systems/coordinateSystems.H | 7 + .../extendedFeatureEdgeMesh.H | 7 + .../featureEdgeMesh/featureEdgeMesh.H | 9 + .../searchableBox/searchableBox.H | 7 + .../searchableCone/searchableCone.H | 7 + .../searchableCylinder/searchableCylinder.H | 7 + .../searchableDisk/searchableDisk.H | 7 + .../searchableExtrudedCircle.H | 7 + .../searchablePlane/searchablePlane.H | 7 + .../searchablePlate/searchablePlate.H | 7 + .../searchableRotatedBox.H | 7 + .../searchableSphere/searchableSphere.H | 7 + .../searchableSurface/searchableSurface.H | 11 +- .../searchableSurfaceCollection.H | 7 + .../searchableSurfaceWithGaps.H | 8 + .../triSurfaceMesh/triSurfaceMesh.H | 8 + .../cellSources/fieldToCell/fieldDictionary.H | 9 + src/meshTools/sets/topoSets/cellSet.H | 8 + src/meshTools/sets/topoSets/faceSet.H | 7 + src/meshTools/sets/topoSets/pointSet.H | 7 + src/meshTools/sets/topoSets/topoBitSet.H | 8 + src/meshTools/sets/topoSets/topoBoolSet.H | 8 + .../adjoint/ATCModel/ATCModel/ATCModel.H | 7 + .../objectiveManager/objectiveManager.H | 7 + .../adjointSolverManager.H | 7 + .../adjointRASModel/adjointRASModel.H | 7 + .../porousModels/porousModel/porousModel.H | 7 + .../surfaceTensionModel/surfaceTensionModel.H | 7 + .../BlendedInterfacialModel.H | 7 + .../surfaceTensionModel/surfaceTensionModel.H | 7 + .../dragModels/dragModel/dragModel.H | 7 + .../virtualMassModel/virtualMassModel.H | 7 + .../populationBalanceModel.H | 7 + .../dragModels/dragModel/dragModel.H | 7 + .../virtualMassModel/virtualMassModel.H | 7 + src/surfMesh/surfZone/surfZoneIOList.H | 9 + .../SLGThermo/SLGThermo/SLGThermo.H | 7 + .../constant/constantSurfaceTension.H | 7 + .../temperatureDependentSurfaceTension.H | 7 + 143 files changed, 1892 insertions(+), 94 deletions(-) diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H index 1d9b49cc4a3..42b27946d34 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H @@ -138,6 +138,13 @@ public: const surfaceScalarField& phi ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~PDRDragModel(); diff --git a/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.H b/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.H index 09b6fb943fe..0a43e80a180 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.H +++ b/src/OpenFOAM/db/IOobjects/CompactIOField/CompactIOField.H @@ -106,6 +106,12 @@ public: //- Construct by transferring the Field contents CompactIOField(const IOobject& io, Field<T>&& content); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~CompactIOField() = default; diff --git a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H index 555114418bb..d555c7d752e 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H +++ b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H @@ -107,6 +107,13 @@ public: //- Construct by transferring the List content CompactIOList(const IOobject& io, List<T>&& content); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + + // Destructor virtual ~CompactIOList() = default; diff --git a/src/OpenFOAM/db/IOobjects/GlobalIOField/GlobalIOField.H b/src/OpenFOAM/db/IOobjects/GlobalIOField/GlobalIOField.H index 165ea0f22a3..b48b4c0752f 100644 --- a/src/OpenFOAM/db/IOobjects/GlobalIOField/GlobalIOField.H +++ b/src/OpenFOAM/db/IOobjects/GlobalIOField/GlobalIOField.H @@ -82,6 +82,12 @@ public: //- Construct by copying/moving tmp content GlobalIOField(const IOobject& io, const tmp<Field<Type>>& tf); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~GlobalIOField() = default; diff --git a/src/OpenFOAM/db/IOobjects/GlobalIOList/GlobalIOList.H b/src/OpenFOAM/db/IOobjects/GlobalIOList/GlobalIOList.H index 2cf6f9e39f8..f0cdebddda3 100644 --- a/src/OpenFOAM/db/IOobjects/GlobalIOList/GlobalIOList.H +++ b/src/OpenFOAM/db/IOobjects/GlobalIOList/GlobalIOList.H @@ -78,6 +78,12 @@ public: //- Construct by transferring the List content GlobalIOList(const IOobject& io, List<Type>&& content); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~GlobalIOList() = default; diff --git a/src/OpenFOAM/db/IOobjects/IOField/IOField.H b/src/OpenFOAM/db/IOobjects/IOField/IOField.H index 8edee8ee108..8ff5146a615 100644 --- a/src/OpenFOAM/db/IOobjects/IOField/IOField.H +++ b/src/OpenFOAM/db/IOobjects/IOField/IOField.H @@ -84,6 +84,12 @@ public: //- Construct by copying/moving tmp content IOField(const IOobject& io, const tmp<Field<Type>>& tfld); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~IOField() = default; diff --git a/src/OpenFOAM/db/IOobjects/IOList/IOList.H b/src/OpenFOAM/db/IOobjects/IOList/IOList.H index c36e78ab169..c80a250c829 100644 --- a/src/OpenFOAM/db/IOobjects/IOList/IOList.H +++ b/src/OpenFOAM/db/IOobjects/IOList/IOList.H @@ -79,6 +79,12 @@ public: //- Construct by transferring the List content IOList(const IOobject& io, List<T>&& content); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~IOList() = default; diff --git a/src/OpenFOAM/db/IOobjects/IOMap/IOMap.H b/src/OpenFOAM/db/IOobjects/IOMap/IOMap.H index 68fa5fe9855..cb3871ddda0 100644 --- a/src/OpenFOAM/db/IOobjects/IOMap/IOMap.H +++ b/src/OpenFOAM/db/IOobjects/IOMap/IOMap.H @@ -66,7 +66,7 @@ public: // Constructors //- Default copy construct - IOMap(const IOMap&) = default; + explicit IOMap(const IOMap&) = default; //- Construct from IOobject explicit IOMap(const IOobject& io); @@ -80,6 +80,12 @@ public: //- Construct by transferring the Map content IOMap(const IOobject&, Map<T>&& content); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~IOMap() = default; diff --git a/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.H b/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.H index aa829d34a58..ba94ad9a579 100644 --- a/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.H +++ b/src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.H @@ -83,6 +83,12 @@ public: //- Construct by transferring the PtrList content IOPtrList(const IOobject& io, PtrList<T>&& content); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~IOPtrList() = default; diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H index 2ba3eb25136..2c866a9806a 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.H @@ -60,6 +60,9 @@ public: // Constructors + //- Copy construct + IOdictionary(const IOdictionary&) = default; + //- Construct given an IOobject //- and optional fallback dictionary content // A null dictionary pointer is treated like an empty dictionary. @@ -86,6 +89,12 @@ public: //- Construct given an IOobject and Istream IOdictionary(const IOobject& io, Istream& is); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~IOdictionary() = default; diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/localIOdictionary.H b/src/OpenFOAM/db/IOobjects/IOdictionary/localIOdictionary.H index d2e03213930..56b9ae99c41 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/localIOdictionary.H +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/localIOdictionary.H @@ -83,6 +83,15 @@ public: //- Construct given an IOobject and Istream localIOdictionary(const IOobject& io, Istream& is); + //- Copy construct + localIOdictionary(const localIOdictionary&) = default; + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~localIOdictionary() = default; diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.H b/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.H index b38f5cf165e..22bc9b6f415 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.H +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/unwatchedIOdictionary.H @@ -94,6 +94,15 @@ public: //- Construct given an IOobject and Istream unwatchedIOdictionary(const IOobject& io, Istream& is); + //- Default copy construct + explicit unwatchedIOdictionary(const unwatchedIOdictionary&) = default; + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~unwatchedIOdictionary() = default; diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 75f0a01eae6..1c8a228cc68 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -226,6 +226,9 @@ public: //- The default control dictionary name (normally "controlDict") static word controlDictName; + //- Default null Time - does not load any dictionary + static const Time null; + //- Runtime type information TypeName("time"); diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.C b/src/OpenFOAM/db/objectRegistry/objectRegistry.C index 1ada4259502..6988fee5f66 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.C @@ -214,6 +214,24 @@ const Foam::objectRegistry& Foam::objectRegistry::subRegistry } +const Foam::objectRegistry& Foam::objectRegistry::findSubRegistry +( + const fileName& path, + const bool forceCreate +) const +{ + const wordList names(path.components()); + + refPtr<objectRegistry> subObr(*this); + + for (const word& name : names) + { + subObr = subObr().subRegistry(name, forceCreate); + } + return subObr(); +} + + Foam::label Foam::objectRegistry::getEvent() const { label curEvent = event_++; diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index 578391a1d68..a1578acc613 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -132,7 +132,7 @@ class objectRegistry //- No copy construct - objectRegistry(const objectRegistry&) = delete; + //objectRegistry(const objectRegistry&) = delete; //- No copy assignment void operator=(const objectRegistry&) = delete; @@ -158,6 +158,15 @@ public: TypeName("objectRegistry"); + // Static Member Functions + + //- Return nullObject reference field + inline static const objectRegistry& null() + { + return NullObjectRef<objectRegistry>(); + } + + // Constructors //- Construct the time objectRegistry, @@ -168,6 +177,15 @@ public: //- with estimated table capacity (default: 128) explicit objectRegistry(const IOobject& io, const label nObjects=128); + //- Default copy construct + explicit objectRegistry(const objectRegistry&) = default; + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor, with checkOut() for all objects that are ownedByRegistry virtual ~objectRegistry(); @@ -342,6 +360,16 @@ public: const bool recursive = false ) const; + //- Lookup and return a const sub-objectRegistry using a relative + // path (with '/' separator) + // + // \param forceCreate create it if it does not exist. + const objectRegistry& findSubRegistry + ( + const fileName& relativePath, + const bool forceCreate = false + ) const; + //- Return all objects with a class satisfying \c isA\<Type\> // diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index dcb7ed0cdc9..f4d59a2bb9d 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.C +++ b/src/OpenFOAM/db/regIOobject/regIOobject.C @@ -37,6 +37,7 @@ License namespace Foam { defineTypeNameAndDebug(regIOobject, 0); + defineRunTimeSelectionTable(regIOobject, IOobject); } bool Foam::regIOobject::masterOnlyReading = false; @@ -454,6 +455,42 @@ bool Foam::regIOobject::headerOk() } +Foam::refPtr<Foam::regIOobject> Foam::regIOobject::New +( + const word& objectType, + const IOobject& io +) +{ + DebugInFunction << "Constructing regIOobject " << io.name() + << " of type " << objectType << endl; + + auto* ctorPtr = IOobjectConstructorTable(objectType); + + if (!ctorPtr) + { + return nullptr; + } + + return refPtr<regIOobject>(ctorPtr(io)); +} + + +Foam::refPtr<Foam::regIOobject> Foam::regIOobject::New(const IOobject& io) +{ + DebugInFunction << "Constructing regIOobject" << endl; + + if (io.headerClassName().empty()) + { + //FatalIOErrorInFunction(io.objectPath()) + // << "No className in header for object " + // << io.info() << exit(FatalIOError); + return nullptr; + } + + return New(io.headerClassName(), io); +} + + void Foam::regIOobject::operator=(const IOobject& io) { // Close any file diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index 8ace12cc3be..c341b1193aa 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -158,6 +158,46 @@ public: regIOobject(const IOobject& io, const regIOobject& rio); + // Selectors + + //- Return reference or pointer to a new regIOobject from an IOobject. + // \returns nullptr if no constructor found + static refPtr<regIOobject> New + ( + const word& objectType, + const IOobject& io + ); + + //- Return reference or pointer to a new regIOobject from an IOobject. + //- Assumes IOobject contains header information. + // \returns nullptr if no constructor found + static refPtr<regIOobject> New(const IOobject& io); + + //- Clone a regIOobject + template<class Derived> + static refPtr<regIOobject> DeepClone(const Derived& io) + { + return refPtr<regIOobject>(new Derived(io)); + } + + //- Return a clone. + virtual refPtr<regIOobject> deepClone() const = 0; + + + // Declare run-time constructor selection tables + + declareRunTimeRefPtrSelectionTable + ( + refPtr, + regIOobject, + IOobject, + ( + const IOobject& io + ), + (io) + ); + + //- Destructor virtual ~regIOobject(); diff --git a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H index 885c8bcab40..94fcbf11e80 100644 --- a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H +++ b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H @@ -86,6 +86,15 @@ Note ##lookup##_##other##_(#lookup,#other,ver) +//- Add to construction table with typeName as the key, using factory New +#define addToRunTimeFactorySelectionTable\ +(baseType,thisType,factoryType,argNames) \ + \ + /* Add factoryType factory method to the table */ \ + baseType::add##argNames##ConstructorToTable<thisType,factoryType> \ + add##thisType##factoryType##argNames##ConstructorTo##baseType##Table_ + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Add to construction table with typeName as the key. diff --git a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H index 976bd6e7df9..e0385c40e1b 100644 --- a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H @@ -276,7 +276,7 @@ Description ptrWrapper<baseType>,argNames##Constructor,argList); \ \ /* Helper to add compatibility/alias for runtime selection table */ \ - template<class baseType##Type> \ + template<class baseType##Type, class Factory = baseType##Type> \ struct addAlias##argNames##ConstructorToTable \ { \ explicit addAlias##argNames##ConstructorToTable \ @@ -292,12 +292,12 @@ Description }; \ \ /* Helper to add constructor from argList to table */ \ - template<class baseType##Type> \ + template<class baseType##Type, class Factory = baseType##Type> \ struct add##argNames##ConstructorToTable \ { \ static ptrWrapper<baseType> New##baseType argList \ { \ - return ptrWrapper<baseType>(baseType##Type::New parList.ptr()); \ + return ptrWrapper<baseType>(Factory::New parList.ptr()); \ } \ \ explicit add##argNames##ConstructorToTable \ @@ -328,14 +328,14 @@ Description }; \ \ /* Helper to add constructor from argList to table */ \ - template<class baseType##Type> \ + template<class baseType##Type, class Factory = baseType##Type> \ struct addRemovable##argNames##ConstructorToTable \ { \ const ::Foam::word name; /* Retain name for later removal */ \ \ static ptrWrapper<baseType> New##baseType argList \ { \ - return ptrWrapper<baseType>(baseType##Type::New parList.ptr()); \ + return ptrWrapper<baseType>(Factory::New parList.ptr()); \ } \ \ explicit addRemovable##argNames##ConstructorToTable \ @@ -365,6 +365,105 @@ Description }; + +//MEJ +//- Declare a run-time selection for derived classes +#define declareRunTimeRefPtrSelectionTable\ +(ptrWrapper,baseType,argNames,argList,parList) \ + \ + declareRunTimeSelectionTableBase( \ + ptrWrapper<baseType>,argNames##Constructor,argList); \ + \ + /* Helper to add compatibility/alias for runtime selection table */ \ + template<class baseType##Type, class Factory = baseType##Type> \ + struct addAlias##argNames##ConstructorToTable \ + { \ + explicit addAlias##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k, \ + const ::Foam::word& alias, \ + const int ver \ + ) \ + { \ + argNames##ConstructorCompatTable() \ + .set(alias, std::pair<::Foam::word,int>(k,ver)); \ + } \ + }; \ + \ + /* Helper to add constructor from argList to table */ \ + template<class baseType##Type, class Factory = baseType##Type> \ + struct add##argNames##ConstructorToTable \ + { \ + static ptrWrapper<baseType> New##baseType argList \ + { \ + return ptrWrapper<baseType>(Factory::New parList); \ + } \ + \ + explicit add##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k = baseType##Type::typeName \ + ) \ + { \ + argNames##ConstructorTablePtr_construct(true); \ + if (!argNames##ConstructorTablePtr_->insert(k, New##baseType)) \ + { \ + std::cerr \ + << "Duplicate entry " << k << " in runtime table " \ + << #baseType << std::endl; \ + ::Foam::error::safePrintStack(std::cerr); \ + } \ + } \ + \ + ~add##argNames##ConstructorToTable() \ + { \ + argNames##ConstructorTablePtr_construct(false); \ + } \ + \ + add##argNames##ConstructorToTable \ + (const add##argNames##ConstructorToTable&) = delete; \ + \ + void operator= \ + (const add##argNames##ConstructorToTable&) = delete; \ + }; \ + \ + /* Helper to add constructor from argList to table */ \ + template<class baseType##Type, class Factory = baseType##Type> \ + struct addRemovable##argNames##ConstructorToTable \ + { \ + const ::Foam::word name; /* Retain name for later removal */ \ + \ + static ptrWrapper<baseType> New##baseType argList \ + { \ + return ptrWrapper<baseType>(Factory::New parList.ptr()); \ + } \ + \ + explicit addRemovable##argNames##ConstructorToTable \ + ( \ + const ::Foam::word& k = baseType##Type::typeName \ + ) \ + : \ + name(k) \ + { \ + argNames##ConstructorTablePtr_construct(true); \ + argNames##ConstructorTablePtr_->set(k, New##baseType); \ + } \ + \ + ~addRemovable##argNames##ConstructorToTable() \ + { \ + if (argNames##ConstructorTablePtr_) \ + { \ + argNames##ConstructorTablePtr_->erase(name); \ + } \ + } \ + \ + addRemovable##argNames##ConstructorToTable \ + (const addRemovable##argNames##ConstructorToTable&) = delete; \ + \ + void operator= \ + (const addRemovable##argNames##ConstructorToTable&) = delete; \ + }; +//MEJ + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // diff --git a/src/OpenFOAM/expressions/Function1/Function1Expression.C b/src/OpenFOAM/expressions/Function1/Function1Expression.C index 2575e0cb014..1437a150061 100644 --- a/src/OpenFOAM/expressions/Function1/Function1Expression.C +++ b/src/OpenFOAM/expressions/Function1/Function1Expression.C @@ -119,7 +119,7 @@ Type Foam::Function1Types::Function1Expression<Type>::integrate template<class Type> -void Foam::Function1Types::Function1Expression<Type>::writeData +bool Foam::Function1Types::Function1Expression<Type>::writeData ( Ostream& os ) const @@ -127,6 +127,8 @@ void Foam::Function1Types::Function1Expression<Type>::writeData // Function1-from-subdict so out dictionary contains // only the relevant entries. dict_.writeEntry(this->name(), os); + + return os.good(); } diff --git a/src/OpenFOAM/expressions/Function1/Function1Expression.H b/src/OpenFOAM/expressions/Function1/Function1Expression.H index ccb91b9f6e0..0ae353d6b10 100644 --- a/src/OpenFOAM/expressions/Function1/Function1Expression.H +++ b/src/OpenFOAM/expressions/Function1/Function1Expression.H @@ -138,7 +138,7 @@ public: ) const; //- Write in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/expressions/exprResult/exprResultGlobals.H b/src/OpenFOAM/expressions/exprResult/exprResultGlobals.H index 49a4dbc6782..3e4b4e9d914 100644 --- a/src/OpenFOAM/expressions/exprResult/exprResultGlobals.H +++ b/src/OpenFOAM/expressions/exprResult/exprResultGlobals.H @@ -129,6 +129,18 @@ public: static bool Delete(const objectRegistry& obr); + // Constructors + + //- Default copy construct + explicit exprResultGlobals(const exprResultGlobals&) = default; + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + + //- Destructor virtual ~exprResultGlobals() = default; diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H index 6b6931051b8..151e2e816af 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H @@ -281,6 +281,12 @@ public: //- Clone tmp<DimensionedField<Type, GeoMesh>> clone() const; + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~DimensionedField() = default; diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index 78cfc3e5724..2e9bb6b3ad0 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -477,6 +477,12 @@ public: //- Clone tmp<GeometricField<Type, PatchField, GeoMesh>> clone() const; + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + // Static Constructors @@ -562,6 +568,10 @@ public: const wordList& actualPatchTypes = wordList() ); + //- Return new field from IOobject if iodb() is correct type. + //- Returns null otherwise + static refPtr<regIOobject> New(const IOobject& io); + //- Destructor virtual ~GeometricField(); diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldNew.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldNew.C index 7d8c91d0a5d..cc73047d96c 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldNew.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldNew.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -228,4 +228,28 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New } +template<class Type, template<class> class PatchField, class GeoMesh> +Foam::refPtr<Foam::regIOobject> +Foam::GeometricField<Type, PatchField, GeoMesh>::New(const IOobject& io) +{ + DebugInFunction + << "Testing db:" << io.db().type() + << " for type " << Mesh::typeName + << " io:" << io.name() << endl; + + refPtr<regIOobject> ret; + + const auto meshPtr = GeoMesh::mesh(io.db()); + if (meshPtr) + { + ret.reset + ( + new GeometricField<Type, PatchField, GeoMesh>(io, *meshPtr) + ); + } + + return ret; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/pointFields/pointFields.C b/src/OpenFOAM/fields/GeometricFields/pointFields/pointFields.C index 7701ff24f3b..f439b80b786 100644 --- a/src/OpenFOAM/fields/GeometricFields/pointFields/pointFields.C +++ b/src/OpenFOAM/fields/GeometricFields/pointFields/pointFields.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +28,7 @@ License #include "polyMesh.H" #include "pointFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -53,6 +55,36 @@ namespace Foam defineTemplateTypeNameAndDebug(pointSymmTensorField, 0); defineTemplateTypeNameAndDebug(pointTensorField, 0); + addToRunTimeSelectionTable + ( + regIOobject, + pointScalarField, + IOobject + ); + addToRunTimeSelectionTable + ( + regIOobject, + pointVectorField, + IOobject + ); + addToRunTimeSelectionTable + ( + regIOobject, + pointSphericalTensorField, + IOobject + ); + addToRunTimeSelectionTable + ( + regIOobject, + pointSymmTensorField, + IOobject + ); + addToRunTimeSelectionTable + ( + regIOobject, + pointTensorField, + IOobject + ); } // End namespace Foam diff --git a/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.H b/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.H index 77b9f520df2..504983a1edf 100644 --- a/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.H +++ b/src/OpenFOAM/fields/UniformDimensionedFields/UniformDimensionedField.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,6 +84,19 @@ public: //- Construct from Istream UniformDimensionedField(const IOobject& io); + //- Return wrapped pointer to a new regIOobject from an IOobject. + //- Assumes IOobject contains header information and io.db is polyMesh + static refPtr<regIOobject> New(const IOobject& io) + { + return refPtr<regIOobject>(new UniformDimensionedField<Type>(io)); + } + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~UniformDimensionedField(); diff --git a/src/OpenFOAM/fields/UniformDimensionedFields/uniformDimensionedFields.C b/src/OpenFOAM/fields/UniformDimensionedFields/uniformDimensionedFields.C index 0e5c1094842..04bf1a83c12 100644 --- a/src/OpenFOAM/fields/UniformDimensionedFields/uniformDimensionedFields.C +++ b/src/OpenFOAM/fields/UniformDimensionedFields/uniformDimensionedFields.C @@ -25,7 +25,10 @@ License \*---------------------------------------------------------------------------*/ +#include "addToRunTimeSelectionTable.H" +#include "regIOobject.H" #include "uniformDimensionedFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -40,6 +43,37 @@ defineTemplateTypeNameAndDebug(uniformDimensionedSphericalTensorField, 0); defineTemplateTypeNameAndDebug(uniformDimensionedSymmTensorField, 0); defineTemplateTypeNameAndDebug(uniformDimensionedTensorField, 0); +addToRunTimeSelectionTable +( + regIOobject, + uniformDimensionedScalarField, + IOobject +); +addToRunTimeSelectionTable +( + regIOobject, + uniformDimensionedVectorField, + IOobject +); +addToRunTimeSelectionTable +( + regIOobject, + uniformDimensionedSphericalTensorField, + IOobject +); +addToRunTimeSelectionTable +( + regIOobject, + uniformDimensionedSymmTensorField, + IOobject +); +addToRunTimeSelectionTable +( + regIOobject, + uniformDimensionedTensorField, + IOobject +); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/global/globals.C b/src/OpenFOAM/global/globals.C index 08a130f6fb3..8eea21bb74c 100644 --- a/src/OpenFOAM/global/globals.C +++ b/src/OpenFOAM/global/globals.C @@ -87,6 +87,18 @@ bool Foam::JobInfo::constructed(false); #include "debug.C" +//MEJ +#include "Time.H" +const Foam::Time Foam::Time::null +( + fileName("."), // root-path + fileName("."), // case-name + false, // No enableFunctionObjects + false // No enableLibs +); + +//MEJ + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Read file modification checking switches diff --git a/src/OpenFOAM/meshes/GeoMesh/GeoMesh.H b/src/OpenFOAM/meshes/GeoMesh/GeoMesh.H index 21f0377d1f9..fc2f4a2461c 100644 --- a/src/OpenFOAM/meshes/GeoMesh/GeoMesh.H +++ b/src/OpenFOAM/meshes/GeoMesh/GeoMesh.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,7 +68,7 @@ public: // Constructors //- Construct from mesh reference - explicit GeoMesh(const MESH& mesh) + explicit GeoMesh(const Mesh& mesh) : mesh_(mesh) {} @@ -75,23 +76,32 @@ public: // Member Functions - //- Return true if thisDb() is a valid DB - here = false - bool hasDb() const + //- Return true if thisDb() is a valid DB + bool hasDb() const noexcept { return true; } //- Return the object registry - const objectRegistry& thisDb() const + const objectRegistry& thisDb() const noexcept { return mesh_; } + //- Return mesh given objectRegistry (reverse of thisDb). + // \return null if objectRegistry does not hold Mesh + static refPtr<Mesh> mesh(const objectRegistry& db) + { + refPtr<Mesh> wrapped; + wrapped.cref(dynamic_cast<const Mesh*>(&db)); + return wrapped; + } + // Member Operators //- Return reference to the underlying mesh - const MESH& operator()() const + const Mesh& operator()() const noexcept { return mesh_; } diff --git a/src/OpenFOAM/meshes/MeshObject/MeshObject.H b/src/OpenFOAM/meshes/MeshObject/MeshObject.H index 4500261f948..52d8c8c8333 100644 --- a/src/OpenFOAM/meshes/MeshObject/MeshObject.H +++ b/src/OpenFOAM/meshes/MeshObject/MeshObject.H @@ -110,6 +110,13 @@ public: template<class... Args> static const Type& New(const Mesh& mesh, Args&&... args); + //- Return a clone. Not applicable for singleton + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~MeshObject() = default; diff --git a/src/OpenFOAM/meshes/pointMesh/pointMesh.C b/src/OpenFOAM/meshes/pointMesh/pointMesh.C index 383cf15dd17..651c8d829b4 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMesh.C +++ b/src/OpenFOAM/meshes/pointMesh/pointMesh.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -90,11 +91,22 @@ Foam::pointMesh::pointMesh(const polyMesh& pMesh) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::refPtr<Foam::pointMesh> Foam::pointMesh::mesh(const objectRegistry& db) +{ + const auto* polyPtr = isA<polyMesh>(db); + if (polyPtr) + { + return pointMesh::New(*polyPtr); + } + return nullptr; +} + + bool Foam::pointMesh::movePoints() { if (debug) { - Pout<< "pointMesh::movePoints(const pointField&): " + Pout<< "pointMesh::movePoints(): " << "Moving points." << endl; } diff --git a/src/OpenFOAM/meshes/pointMesh/pointMesh.H b/src/OpenFOAM/meshes/pointMesh/pointMesh.H index a651a74424c..8ee9269b05a 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMesh.H +++ b/src/OpenFOAM/meshes/pointMesh/pointMesh.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,7 +54,7 @@ class pointMesh public MeshObject<polyMesh, UpdateableMeshObject, pointMesh>, public GeoMesh<polyMesh> { - // Permanent data + // Permanent Data //- Boundary mesh pointBoundaryMesh boundary_; @@ -123,6 +124,19 @@ public: return GeoMesh<polyMesh>::mesh_.thisDb(); } + //- Return Time from polyMesh. + const Time& time() const + { + return GeoMesh<polyMesh>::mesh_.time(); + } + + //- Parent mesh (polyMesh) + using MeshObject<polyMesh, UpdateableMeshObject, pointMesh>::mesh; + + //- Return mesh given objectRegistry (reverse of thisDb). + // \return null if objectRegistry does not hold Mesh + static refPtr<pointMesh> mesh(const objectRegistry& db); + // Mesh motion diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.H index d277c5723b9..1e1d1d32a4e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.H @@ -74,6 +74,15 @@ public: //- Construct, moving mapDistribute contents IOmapDistribute(const IOobject& io, mapDistribute&& map); + //- Default copy construct + IOmapDistribute(const IOmapDistribute&) = default; + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~IOmapDistribute() = default; diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index 8dcf87f41d2..d7977e75765 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -135,6 +135,13 @@ public: const polyPatchList& ppl ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor ~polyBoundaryMesh() = default; diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMeshEntries.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMeshEntries.H index 4b89aa41b71..f2fe5ae0d15 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMeshEntries.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMeshEntries.H @@ -56,6 +56,13 @@ class polyBoundaryMeshEntries public regIOobject, public PtrList<entry> { + + // Private Member Functions + + //- No copy construct + polyBoundaryMeshEntries(const polyBoundaryMeshEntries&) = delete; + + public: //- Runtime type information @@ -82,6 +89,13 @@ public: } } + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + // Member Functions diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H index 25f99e1fed1..a8dca7d55cd 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H @@ -132,6 +132,13 @@ public: const PtrList<ZoneType>& pzm ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor ~ZoneMesh(); diff --git a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C index 03fb6b86c0c..cec15ef8999 100644 --- a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C +++ b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.C @@ -102,7 +102,7 @@ Type Foam::Function1Types::CSV<Type>::readValue template<class Type> -void Foam::Function1Types::CSV<Type>::read() +bool Foam::Function1Types::CSV<Type>::read() { fileName expandedFile(fName_); autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile.expand())); @@ -200,6 +200,8 @@ void Foam::Function1Types::CSV<Type>::read() } this->table_.transfer(values); + + return true; } @@ -227,6 +229,28 @@ Foam::Function1Types::CSV<Type>::CSV } +template<class Type> +Foam::Function1Types::CSV<Type>::CSV +( + const IOobject& io, + const dictionary& dict, + const fileName& fName +) +: + TableBase<Type>(io.name(), dict), + nHeaderLine_(dict.get<label>("nHeaderLine")), + refColumn_(dict.get<label>("refColumn")), + componentColumns_(getComponentColumns("componentColumns", dict)), + separator_(dict.getOrDefault<string>("separator", ",")[0]), + mergeSeparators_(dict.get<bool>("mergeSeparators")), + fName_(fName.empty() ? dict.get<fileName>("file") : fName) +{ + read(); + + TableBase<Type>::check(); +} + + template<class Type> Foam::Function1Types::CSV<Type>::CSV(const CSV<Type>& csv) : @@ -271,7 +295,7 @@ void Foam::Function1Types::CSV<Type>::writeEntries(Ostream& os) const template<class Type> -void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os.endEntry(); @@ -279,6 +303,8 @@ void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); os.endBlock(); + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H index 1c5a2bb693e..4f6ce3795e3 100644 --- a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H +++ b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H @@ -107,9 +107,6 @@ class CSV const dictionary& dict ); - //- Read csv data table - void read(); - //- Read component values from the split string Type readValue(const List<string>& strings) const; @@ -133,6 +130,14 @@ public: const fileName& fName = fileName::null ); + //- Construct from IOobject and dictionary + CSV + ( + const IOobject& io, + const dictionary& dict, + const fileName& fName = fileName::null + ); + //- Copy construct explicit CSV(const CSV<Type>& csv); @@ -152,8 +157,11 @@ public: //- Return const access to the file name virtual const fileName& fName() const; + //- Read csv data table + virtual bool read(); + //- Write in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; //- Write coefficient entries in dictionary format void writeEntries(Ostream& os) const; diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C index 36c764e895e..7cf16c46801 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C +++ b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.C @@ -78,6 +78,42 @@ Foam::Function1Types::Constant<Type>::Constant } +template<class Type> +Foam::Function1Types::Constant<Type>::Constant +( + const IOobject& io, + const dictionary& dict +) +: + Function1<Type>(io, dict), + value_(Zero) +{ + const entry* eptr = dict.findEntry(io.name(), keyType::LITERAL); + + if (eptr && eptr->isStream()) + { + // Primitive (inline) format. Eg, + // - key constant 1.2; + // - key 1.2; + + ITstream& is = eptr->stream(); + if (is.peek().isWord()) + { + is.skip(); // Discard leading 'constant' + } + is >> value_; + dict.checkITstream(is, io.name()); + } + else + { + // Dictionary format. Eg, + // key { type constant; value 1.2; } + + dict.readEntry("value", value_); + } +} + + template<class Type> Foam::Function1Types::Constant<Type>::Constant ( @@ -111,11 +147,13 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::value template<class Type> -void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os << token::SPACE << value_ << token::END_STATEMENT << nl; + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H index 4dfac6e68a7..ba2db1dcd55 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H +++ b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H @@ -100,6 +100,9 @@ public: //- Construct from entry name and dictionary Constant(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + Constant(const IOobject& io, const dictionary& dict); + //- Construct from entry name and Istream // Reads the constant value without the Function1 type // for backward compatibility @@ -131,7 +134,7 @@ public: virtual tmp<Field<Type>> value(const scalarField& x) const; //- Write as primitive (inline) format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H b/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H index 08383ac1c93..eb74d029c6b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H +++ b/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H @@ -137,6 +137,13 @@ public: Sine<Type>(entryName, dict) {} + + //- Construct from IOobject and dictionary + Cosine(const IOobject& io, const dictionary& dict) + : + Sine<Type>(io, dict) + {} + //- Copy construct explicit Cosine(const Cosine<Type>& rhs) : diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C index 84900b63f74..1cd7c61d0b3 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C @@ -54,6 +54,14 @@ Foam::Function1<Type>::Function1(const Function1<Type>& rhs) {} +template<class Type> +Foam::Function1<Type>::Function1(const IOobject& io, const dictionary& dict) +: + function1Base(io, dict) +{} + + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> @@ -126,6 +134,17 @@ Foam::FieldFunction1<Function1Type>::FieldFunction1 {} +template<class Function1Type> +Foam::FieldFunction1<Function1Type>::FieldFunction1 +( + const IOobject& io, + const dictionary& dict +) +: + Function1Type(io, dict) +{} + + template<class Function1Type> Foam::tmp<Foam::Function1<typename Function1Type::returnType>> Foam::FieldFunction1<Function1Type>::clone() const @@ -163,9 +182,10 @@ void Foam::Function1<Type>::writeEntries(Ostream& os) const template<class Type> -void Foam::Function1<Type>::writeData(Ostream& os) const +bool Foam::Function1<Type>::writeData(Ostream& os) const { - os.writeKeyword(name_) << type(); + os.writeKeyword(name()) << type(); + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H index 41d4f5e06e5..b1dfd1aeadc 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H @@ -152,6 +152,12 @@ public: //- Construct and return a clone virtual tmp<Function1<Type>> clone() const = 0; + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return refPtr<regIOobject>(clone()); + } + // Selectors @@ -191,6 +197,52 @@ public: ); + // Caching Selectors - accept wildcards in dictionary + + //- Selector with external storage of Function1. + //- This also allows wildcard matches in a dictionary + static refPtr<Function1<Type>> New + ( + HashPtrTable<Function1<Type>>& cache, + const word& entryName, + const dictionary& dict, + enum keyType::option matchOpt = keyType::LITERAL, + const bool mandatory = true + ); + + //- Selector, without fallback redirection + static refPtr<Function1<Type>> New + ( + const IOobject& io, + const dictionary& dict, + enum keyType::option matchOpt = keyType::LITERAL, + const bool mandatory = true + ); + + + // Constructors from IOobject + + //- Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + refPtr, + Function1, + IOobject, + ( + const IOobject& io, + const dictionary& dict + ), + (io, dict) + ); + + //- Construct from IOobject and dictionary (unused) + Function1 + ( + const IOobject& io, + const dictionary& dict + ); + + //- Destructor virtual ~Function1() = default; @@ -228,7 +280,7 @@ public: //- Write in dictionary format. // \note The base output is \em without an END_STATEMENT - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; //- Write coefficient entries in dictionary format void writeEntries(Ostream& os) const; @@ -254,9 +306,22 @@ public: //- Construct from entry name and dictionary FieldFunction1(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary (unused) + FieldFunction1 + ( + const IOobject& io, + const dictionary& dict + ); + //- Construct and return a clone virtual tmp<Function1<Type>> clone() const; + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return refPtr<regIOobject>(clone()); + } + //- Destructor virtual ~FieldFunction1() = default; @@ -325,6 +390,23 @@ public: makeConcreteFunction1(SS, scalar); + +// Define a non-templated Function1 and add to (templated) run-time selection +#define makeConcreteIOobjectFunction1(SS, Type) \ + \ + Function1<Type>::addIOobjectConstructorToTable \ + <FieldFunction1<SS>> \ + add##SS##Type##IOobjectConstructorToTable_; + +// Define a non-templated Function1 and add to (templated) run-time selection +#define makeIOobjectFunction1Type(SS, Type) \ + \ + Function1<Type>::addIOobjectConstructorToTable \ + <FieldFunction1<Function1Types::SS<Type>>> \ + add##SS##Type##IOobjectConstructorToTable_; + + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C index 3e8727606aa..71fd732b8ea 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1New.C @@ -209,4 +209,177 @@ Foam::Function1<Type>::NewIfPresent } +template<class Type> +Foam::refPtr<Foam::Function1<Type>> +Foam::Function1<Type>::New +( + HashPtrTable<Function1<Type>>& cache, + + const word& entryName, + const dictionary& dict, + enum keyType::option matchOpt, + const bool mandatory +) +{ + // Use the dictionary to find the keyword (allowing wildcards). + // Alternative would be to have + // a HashTable where the key type uses a wildcard match + + + refPtr<Function1<Type>> fref; // return value + + // Try for direct cache hit + fref.cref(cache.get(entryName)); + + if (fref) + { + return fref; + } + + + // Lookup from dictionary + const entry* eptr = dict.findEntry(entryName, matchOpt); + + if (eptr) + { + // Use keyword (potentially a wildcard) instead of entry name + const auto& kw = eptr->keyword(); + + // Try for a cache hit + fref.cref(cache.get(kw)); + + if (!fref) + { + // Create new entry + auto fauto + ( + Function1<Type>::New + ( + kw, + eptr, // Already resolved + dict, + word::null, + mandatory + ) + ); + + if (fauto) + { + // Cache the newly created function + fref.cref(fauto.get()); + cache.set(kw, fauto); + } + } + } + + if (mandatory && !fref) + { + FatalIOErrorInFunction(dict) + << "No match for " << entryName << nl + << exit(FatalIOError); + } + + return fref; +} + + +template<class Type> +Foam::refPtr<Foam::Function1<Type>> +Foam::Function1<Type>::New +( + const IOobject& io, + const dictionary& dict, + enum keyType::option matchOpt, + const bool mandatory +) +{ + // Use the dictionary to find the keyword (allowing wildcards). + // Alternative would be to have + // a HashTable where the key type uses a wildcard match + + + refPtr<Function1<Type>> fref; // return value + + // Lookup from dictionary + const entry* eptr = dict.findEntry(io.name(), matchOpt); + + const dictionary* coeffs = (eptr ? eptr->dictPtr() : nullptr); + + word modelType; + + if (coeffs) + { + // Dictionary entry + + DebugInFunction + << "For " << io.name() << " with dictionary entries: " + << flatOutput(coeffs->toc()) << nl; + + coeffs->readEntry + ( + "type", + modelType, + keyType::LITERAL, + modelType.empty() // "type" entry is mandatory if no 'redirect' + ); + + auto* ctorPtr = IOobjectConstructorTable(modelType); + + if (ctorPtr) + { + fref = ctorPtr(io, *coeffs); + } + + // Fallthrough + } + else if (eptr) + { + // Use keyword (potentially a wildcard) instead of entry name + //const auto& kw = eptr->keyword(); + + ITstream& is = eptr->stream(); + + if (is.peek().isWord()) + { + modelType = is.peek().wordToken(); + } +// else +// { +// // A value - compatibility for reading constant +// +// const Type constValue = pTraits<Type>(is); +// +// return autoPtr<Function1<Type>> +// ( +// new Function1Types::Constant<Type>(io.name(), constValue) +// ); +// } + + Pout<< "io:" << io.name() + << " kw:" << eptr->keyword() + << " modelType:" << modelType + << endl; + + auto* ctorPtr = IOobjectConstructorTable(modelType); + + if (ctorPtr) + { + fref = ctorPtr(io, *coeffs); + } + } + + if (mandatory && !fref) + { + FatalIOErrorInFunction(dict) + << "Unknown Function1 type " + << modelType << " for " << io.name() + << "\n\nValid Function1 types :\n" + << IOobjectConstructorTablePtr_->sortedToc() << nl + << exit(FatalIOError); + } + + return fref; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.C b/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.C index c4a6e0a1940..37db62628ce 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.C @@ -32,8 +32,19 @@ License Foam::function1Base::function1Base(const word& entryName) : - refCount(), - name_(entryName) + regIOobject + ( + IOobject + ( + entryName, + "constant", // instance + Time::null, // objectRegistry + IOobject::NO_READ, + IOobject::NO_WRITE, + false // registerObject + ) + ), + refCount() {} @@ -43,18 +54,44 @@ Foam::function1Base::function1Base const dictionary& dict ) : - refCount(), - name_(entryName) + regIOobject + ( + IOobject + ( + entryName, + "constant", // instance + Time::null, // objectRegistry + IOobject::NO_READ, + IOobject::NO_WRITE, + false // registerObject + ) + ), + refCount() {} Foam::function1Base::function1Base(const function1Base& rhs) : - refCount(), - name_(rhs.name_) + regIOobject(rhs), + refCount() {} +Foam::function1Base::function1Base(const IOobject& io) +: + regIOobject(io), + refCount() +{} + + +Foam::function1Base::function1Base(const IOobject& io, const dictionary& dict) +: + regIOobject(io), + refCount() +{} + + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::function1Base::convertTimeBase(const Time& t) diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.H b/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.H index a3191c7924e..d232d3c27f8 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/function1Base.H @@ -43,6 +43,8 @@ SourceFiles #define function1Base_H #include "dictionary.H" +#include "regIOobject.H" +#include "Time.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,7 +52,7 @@ namespace Foam { // Forward Declarations -class Time; +//class Time; /*---------------------------------------------------------------------------*\ Class function1Base Declaration @@ -58,16 +60,11 @@ class Time; class function1Base : + public regIOobject, public refCount { protected: - // Protected Data - - //- Name of entry - const word name_; - - // Protected Member Functions //- No copy assignment @@ -87,20 +84,15 @@ public: //- Copy construct explicit function1Base(const function1Base& rhs); + //- Construct from IOobject + function1Base(const IOobject& io); - //- Destructor - virtual ~function1Base() = default; + //- Construct from IOobject and dictionary (unused) + function1Base(const IOobject& io, const dictionary& dict); - // Member Functions - - // Access - - //- The name of the entry - const word& name() const - { - return name_; - } + //- Destructor + virtual ~function1Base() = default; // Manipulation diff --git a/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.C b/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.C index 8578cec6b7e..2699afa9cf8 100644 --- a/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.C +++ b/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.C @@ -30,7 +30,7 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Type> -void Foam::Function1Types::LimitRange<Type>::read(const dictionary& coeffs) +void Foam::Function1Types::LimitRange<Type>::readDict(const dictionary& coeffs) { min_ = coeffs.get<scalar>("min"); max_ = coeffs.get<scalar>("max"); @@ -47,7 +47,20 @@ Foam::Function1Types::LimitRange<Type>::LimitRange : Function1<Type>(entryName) { - read(dict); + readDict(dict); +} + + +template<class Type> +Foam::Function1Types::LimitRange<Type>::LimitRange +( + const IOobject& io, + const dictionary& dict +) +: + Function1<Type>(io, dict) +{ + readDict(dict); } @@ -73,7 +86,7 @@ void Foam::Function1Types::LimitRange<Type>::writeEntries(Ostream& os) const template<class Type> -void Foam::Function1Types::LimitRange<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::LimitRange<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os << token::END_STATEMENT << nl; @@ -81,6 +94,8 @@ void Foam::Function1Types::LimitRange<Type>::writeData(Ostream& os) const os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); os.endBlock(); + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.H b/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.H index e167ebba3cb..0eaa4e5a67d 100644 --- a/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.H +++ b/src/OpenFOAM/primitives/functions/Function1/LimitRange/LimitRange.H @@ -118,7 +118,7 @@ class LimitRange // Private Member Functions //- Read the coefficients from the given dictionary - void read(const dictionary& coeffs); + void readDict(const dictionary& coeffs); public: @@ -138,6 +138,9 @@ public: //- Construct from entry name and dictionary LimitRange(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + LimitRange(const IOobject& io, const dictionary& dict); + //- Copy construct explicit LimitRange(const LimitRange<Type>& rhs); @@ -155,7 +158,7 @@ public: virtual inline Type integrate(const scalar x1, const scalar x2) const; //- Write in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; //- Write coefficient entries in dictionary format void writeEntries(Ostream& os) const; diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C index f95259c4464..6dc19d05703 100644 --- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C +++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.C @@ -47,6 +47,17 @@ Foam::Function1Types::OneConstant<Type>::OneConstant {} +template<class Type> +Foam::Function1Types::OneConstant<Type>::OneConstant +( + const IOobject& io, + const dictionary& dict +) +: + Function1<Type>(io, dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> @@ -71,11 +82,12 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::OneConstant<Type>::integrate template<class Type> -void Foam::Function1Types::OneConstant<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::OneConstant<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); + os.endEntry(); - os << token::END_STATEMENT << nl; + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H index a072e0432d1..33aa864502c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H +++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H @@ -81,6 +81,9 @@ public: //- Construct from entry name and dictionary OneConstant(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + OneConstant(const IOobject& io, const dictionary& dict); + //- Construct and return a clone virtual tmp<Function1<Type>> clone() const { @@ -111,7 +114,7 @@ public: ) const; //- Write as primitive (inline) format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.C b/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.C index b5b2cc6cfed..a92a97ef53c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.C +++ b/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.C @@ -100,6 +100,45 @@ Foam::Function1Types::Polynomial<Type>::Polynomial } +template<class Type> +Foam::Function1Types::Polynomial<Type>::Polynomial +( + const IOobject& io, + const dictionary& dict +) +: + Function1<Type>(io.name(), dict), + coeffs_(), + canIntegrate_(true) +{ + const entry* eptr = dict.findEntry(io.name(), keyType::LITERAL); + + if (eptr && eptr->isStream()) + { + // Primitive (inline) format. Eg, + // key polynomial ((0 0) (10 1)); + + ITstream& is = eptr->stream(); + if (is.peek().isWord()) + { + is.skip(); // Discard leading 'polynomial' + } + is >> this->coeffs_; + dict.checkITstream(is, io.name()); + } + else + { + // Dictionary format - "values" lookup. Eg, + // + // key { type polynomial; coeffs ((0 0) (10 1)); } + + dict.readEntry("coeffs", this->coeffs_); + } + + this->checkCoefficients(); +} + + template<class Type> Foam::Function1Types::Polynomial<Type>::Polynomial ( @@ -197,11 +236,13 @@ Type Foam::Function1Types::Polynomial<Type>::integrate template<class Type> -void Foam::Function1Types::Polynomial<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::Polynomial<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os << nl << indent << coeffs_ << token::END_STATEMENT << nl; + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H b/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H index 6fc5cf92497..969a7569dab 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H +++ b/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H @@ -111,6 +111,9 @@ public: //- Construct from entry name and dictionary Polynomial(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + Polynomial(const IOobject& io, const dictionary& dict); + //- Construct from components Polynomial ( @@ -144,7 +147,7 @@ public: virtual Type integrate(const scalar x1, const scalar x2) const; //- Write as primitive (inline) format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C index 76bb810eeed..028bad7bd6c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C @@ -31,7 +31,7 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Type> -void Foam::Function1Types::Scale<Type>::read(const dictionary& coeffs) +void Foam::Function1Types::Scale<Type>::readDict(const dictionary& coeffs) { scale_ = Function1<scalar>::New("scale", coeffs); value_ = Function1<Type>::New("value", coeffs); @@ -47,7 +47,20 @@ Foam::Function1Types::Scale<Type>::Scale : Function1<Type>(entryName) { - read(dict); + readDict(dict); +} + + +template<class Type> +Foam::Function1Types::Scale<Type>::Scale +( + const IOobject& io, + const dictionary& dict +) +: + Function1<Type>(io, dict) +{ + readDict(dict); } @@ -71,7 +84,7 @@ void Foam::Function1Types::Scale<Type>::writeEntries(Ostream& os) const template<class Type> -void Foam::Function1Types::Scale<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::Scale<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os << token::END_STATEMENT << nl; @@ -79,6 +92,8 @@ void Foam::Function1Types::Scale<Type>::writeData(Ostream& os) const os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); os.endBlock(); + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H index 7077203b59c..7c741fe64a2 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H @@ -105,7 +105,7 @@ class Scale // Private Member Functions //- Read the coefficients from the given dictionary - void read(const dictionary& coeffs); + void readDict(const dictionary& coeffs); public: @@ -129,6 +129,13 @@ public: const dictionary& dict ); + //- Construct from IOobject and dictionary + Scale + ( + const IOobject& io, + const dictionary& dict + ); + //- Copy construct explicit Scale(const Scale<Type>& rhs); @@ -143,7 +150,7 @@ public: virtual inline Type value(const scalar t) const; //- Write in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; //- Write coefficient entries in dictionary format void writeEntries(Ostream& os) const; diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C index bfcafed6db8..0d89a033254 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C +++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C @@ -52,6 +52,28 @@ Foam::Function1Types::Sine<Type>::Sine } +template<class Type> +Foam::Function1Types::Sine<Type>::Sine +( + const IOobject& io, + const dictionary& dict +) +: + Function1<Type>(io, dict), + t0_(dict.getOrDefault<scalar>("t0", 0)), + amplitude_(Function1<scalar>::NewIfPresent("amplitude", dict)), + period_(Function1<scalar>::NewIfPresent("period", dict)), + frequency_(nullptr), + scale_(Function1<Type>::New("scale", dict)), + level_(Function1<Type>::New("level", dict)) +{ + if (!period_) + { + frequency_ = Function1<scalar>::New("frequency", dict); + } +} + + template<class Type> Foam::Function1Types::Sine<Type>::Sine(const Sine<Type>& rhs) : @@ -96,7 +118,7 @@ void Foam::Function1Types::Sine<Type>::writeEntries(Ostream& os) const template<class Type> -void Foam::Function1Types::Sine<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::Sine<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os.endEntry(); @@ -104,6 +126,8 @@ void Foam::Function1Types::Sine<Type>::writeData(Ostream& os) const os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); os.endBlock(); + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H index 64096352e7c..475c4a753c0 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H +++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H @@ -184,6 +184,9 @@ public: //- Construct from entry name and dictionary Sine(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + Sine(const IOobject& io, const dictionary& dict); + //- Copy construct explicit Sine(const Sine<Type>& rhs); @@ -204,7 +207,7 @@ public: } //- Write in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; //- Write coefficient entries in dictionary format void writeEntries(Ostream& os) const; diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.C b/src/OpenFOAM/primitives/functions/Function1/Square/Square.C index adc4d91f358..12167d8f4e8 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.C +++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.C @@ -43,6 +43,19 @@ Foam::Function1Types::Square<Type>::Square {} +template<class Type> +Foam::Function1Types::Square<Type>::Square +( + const IOobject& io, + const dictionary& dict +) +: + Sine<Type>(io, dict), + mark_(dict.getOrDefaultCompat<scalar>("mark", {{"markSpace", 2006}}, 1)), + space_(dict.getOrDefault<scalar>("space", 1)) +{} + + template<class Type> Foam::Function1Types::Square<Type>::Square(const Square<Type>& rhs) : @@ -64,7 +77,7 @@ void Foam::Function1Types::Square<Type>::writeEntries(Ostream& os) const template<class Type> -void Foam::Function1Types::Square<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::Square<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os.endEntry(); @@ -72,6 +85,8 @@ void Foam::Function1Types::Square<Type>::writeData(Ostream& os) const os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); os.endBlock(); + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H index c79f6e12f3d..a5e4dbf3d2f 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H +++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H @@ -147,6 +147,9 @@ public: //- Construct from entry name and dictionary Square(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + Square(const IOobject& io, const dictionary& dict); + //- Copy construct explicit Square(const Square<Type>& rhs); @@ -164,7 +167,7 @@ public: } //- Write in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; //- Write coefficient entries in dictionary format void writeEntries(Ostream& os) const; diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/Table.C b/src/OpenFOAM/primitives/functions/Function1/Table/Table.C index cb57b875023..1709940a6e2 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/Table.C +++ b/src/OpenFOAM/primitives/functions/Function1/Table/Table.C @@ -88,6 +88,64 @@ Foam::Function1Types::Table<Type>::Table } +template<class Type> +Foam::Function1Types::Table<Type>::Table +( + const IOobject& io, + const dictionary& dict +) +: + TableBase<Type>(io, dict), + fName_() +{ + const entry* eptr = dict.findEntry(io.name(), keyType::LITERAL); + + if (eptr && eptr->isStream()) + { + // Primitive (inline) format. Eg, + // key table ((0 0) (10 1)); + + ITstream& is = eptr->stream(); + if (is.peek().isWord()) + { + is.skip(); // Discard leading 'table' + } + is >> this->table_; + dict.checkITstream(is, io.name()); + } + else if (dict.readIfPresent("file", fName_)) + { + // Dictionary format - "file" lookup. Eg, + // key { type table; file "name"; } + + fileName expandedFile(fName_); + expandedFile.expand(); + + autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile)); + if (isPtr && isPtr->good()) + { + *isPtr >> this->table_; + } + else + { + FatalIOErrorInFunction(dict) + << "Cannot open file: " << expandedFile << nl + << exit(FatalIOError); + } + } + else + { + // Dictionary format - "values" lookup. Eg, + // + // key { type table; values ((0 0) (10 1)); } + + dict.readEntry("values", this->table_); + } + + TableBase<Type>::check(); +} + + template<class Type> Foam::Function1Types::Table<Type>::Table(const Table<Type>& tbl) : @@ -99,7 +157,7 @@ Foam::Function1Types::Table<Type>::Table(const Table<Type>& tbl) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -void Foam::Function1Types::Table<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::Table<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os.endEntry(); @@ -120,6 +178,8 @@ void Foam::Function1Types::Table<Type>::writeData(Ostream& os) const } os.endBlock(); + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H index 154e18c8e2c..eafaced95fc 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H +++ b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H @@ -122,6 +122,9 @@ public: //- Construct from entry name and dictionary. Table(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + Table(const IOobject& io, const dictionary& dict); + //- Copy construct explicit Table(const Table<Type>& tbl); @@ -139,7 +142,7 @@ public: // Member Functions //- Write coefficients in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C index 497e4b4cd6c..1710d7b63d7 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C +++ b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.C @@ -91,6 +91,39 @@ Foam::Function1Types::TableBase<Type>::TableBase {} +template<class Type> +Foam::Function1Types::TableBase<Type>::TableBase +( + const IOobject& io, + const dictionary& dict +) +: + Function1<Type>(io, dict), + bounding_ + ( + bounds::repeatableBoundingNames.getOrDefault + ( + "outOfBounds", + dict, + bounds::repeatableBounding::CLAMP, + true // Failsafe behaviour + ) + ), + interpolationScheme_ + ( + dict.getOrDefault<word> + ( + "interpolationScheme", + "linear", + keyType::LITERAL + ) + ), + table_(), + tableSamplesPtr_(nullptr), + interpolatorPtr_(nullptr) +{} + + template<class Type> Foam::Function1Types::TableBase<Type>::TableBase(const TableBase<Type>& tbl) : @@ -372,11 +405,12 @@ void Foam::Function1Types::TableBase<Type>::writeEntries(Ostream& os) const template<class Type> -void Foam::Function1Types::TableBase<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::TableBase<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os << nl << indent << table_ << token::END_STATEMENT << nl; writeEntries(os); + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H index 57b05c7f2ba..b25542bb697 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H +++ b/src/OpenFOAM/primitives/functions/Function1/Table/TableBase.H @@ -103,6 +103,9 @@ public: //- Construct from dictionary - note table is not populated TableBase(const word& name, const dictionary& dict); + //- Construct from IOobject and dictionary + TableBase(const IOobject& io, const dictionary& dict); + //- Copy constructor. Note: steals interpolator, tableSamples explicit TableBase(const TableBase<Type>& tbl); @@ -138,7 +141,7 @@ public: virtual tmp<Field<Type>> y() const; //- Write all table data in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; //- Write keywords only in dictionary format. // Used for non-inline table types diff --git a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.C b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.C index 0f06734ee97..dbde2b0bb97 100644 --- a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.C +++ b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.C @@ -60,6 +60,36 @@ Foam::Function1Types::TableFile<Type>::TableFile } +template<class Type> +Foam::Function1Types::TableFile<Type>::TableFile +( + const IOobject& io, + const dictionary& dict +) +: + TableBase<Type>(io, dict), + fName_() +{ + dict.readEntry("file", fName_); + + fileName expandedFile(fName_); + + autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile.expand())); + ISstream& is = *isPtr; + + if (!is.good()) + { + FatalIOErrorInFunction(is) + << "Cannot open file." << nl + << exit(FatalIOError); + } + + is >> this->table_; + + TableBase<Type>::check(); +} + + template<class Type> Foam::Function1Types::TableFile<Type>::TableFile(const TableFile<Type>& tbl) : @@ -71,7 +101,7 @@ Foam::Function1Types::TableFile<Type>::TableFile(const TableFile<Type>& tbl) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -void Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); os.endEntry(); @@ -85,6 +115,8 @@ void Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const os.writeEntry("file", fName_); os.endBlock(); + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H index cabe6e2d9fc..fc604562fd9 100644 --- a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H +++ b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H @@ -103,6 +103,9 @@ public: //- Construct from entry name and "file" found in dictionary TableFile(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + TableFile(const IOobject& io, const dictionary& dict); + //- Copy construct explicit TableFile(const TableFile<Type>& tbl); @@ -120,7 +123,7 @@ public: // Member Functions //- Write in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.C b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.C index fa48a8b6591..cd4af3a12e6 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.C +++ b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.C @@ -40,4 +40,15 @@ Foam::Function1Types::Uniform<Type>::Uniform {} +template<class Type> +Foam::Function1Types::Uniform<Type>::Uniform +( + const IOobject& io, + const dictionary& dict +) +: + Constant<Type>(io, dict) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H index 805480f504b..5d05c16ef43 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H +++ b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H @@ -83,6 +83,9 @@ public: //- Construct from entry name and dictionary Uniform(const word& entryName, const dictionary& dict); + + //- Construct from IOobject and dictionary + Uniform(const IOobject& io, const dictionary& dict); }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C index 591e430f624..e8c3bb83756 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C +++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.C @@ -48,14 +48,26 @@ Foam::Function1Types::ZeroConstant<Type>::ZeroConstant {} +template<class Type> +Foam::Function1Types::ZeroConstant<Type>::ZeroConstant +( + const IOobject& io, + const dictionary& dict +) +: + Function1<Type>(io, dict) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -void Foam::Function1Types::ZeroConstant<Type>::writeData(Ostream& os) const +bool Foam::Function1Types::ZeroConstant<Type>::writeData(Ostream& os) const { Function1<Type>::writeData(os); + os.endEntry(); - os << token::END_STATEMENT << nl; + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H index 8563f6663d8..d4a16c2628c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H +++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H @@ -90,6 +90,9 @@ public: //- Construct from entry name and dictionary ZeroConstant(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + ZeroConstant(const IOobject& io, const dictionary& dict); + //- Destructor virtual ~ZeroConstant() = default; @@ -104,7 +107,7 @@ public: virtual inline Type integrate(const scalar x1, const scalar x2) const; //- Write as primitive (inline) format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; }; diff --git a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C index c41dee31559..e206e56e528 100644 --- a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C +++ b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C @@ -50,4 +50,14 @@ Foam::Function1Types::halfCosineRamp::halfCosineRamp {} +Foam::Function1Types::halfCosineRamp::halfCosineRamp +( + const IOobject& io, + const dictionary& dict +) +: + ramp(io, dict) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H index 7d536988e8c..526f13d4dec 100644 --- a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H +++ b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H @@ -70,6 +70,9 @@ public: //- Construct from entry name and dictionary halfCosineRamp(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + halfCosineRamp(const IOobject& io, const dictionary& dict); + //- Destructor virtual ~halfCosineRamp() = default; diff --git a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.C b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.C index de2aca2812f..1657da829be 100644 --- a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.C +++ b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.C @@ -50,4 +50,14 @@ Foam::Function1Types::linearRamp::linearRamp {} +Foam::Function1Types::linearRamp::linearRamp +( + const IOobject& io, + const dictionary& dict +) +: + ramp(io, dict) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H index d22271c839c..0016464c9ab 100644 --- a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H +++ b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H @@ -70,6 +70,9 @@ public: //- Construct from entry name and dictionary linearRamp(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + linearRamp(const IOobject& io, const dictionary& dict); + //- Destructor virtual ~linearRamp() = default; diff --git a/src/OpenFOAM/primitives/functions/Function1/makeFunction1s.C b/src/OpenFOAM/primitives/functions/Function1/makeFunction1s.C index 680c49149c8..5feeb651ccf 100644 --- a/src/OpenFOAM/primitives/functions/Function1/makeFunction1s.C +++ b/src/OpenFOAM/primitives/functions/Function1/makeFunction1s.C @@ -81,4 +81,46 @@ namespace Foam } +// Construct from IOobject + +#define makeIOobjectFunction1s(Type) \ + defineTemplateRunTimeSelectionTable \ + ( \ + Function1<Type>, \ + IOobject \ + ); \ + makeIOobjectFunction1Type(Constant, Type); \ + makeIOobjectFunction1Type(Uniform, Type); \ + makeIOobjectFunction1Type(ZeroConstant, Type); \ + makeIOobjectFunction1Type(OneConstant, Type); \ + makeIOobjectFunction1Type(Polynomial, Type); \ + makeIOobjectFunction1Type(Cosine, Type); \ + makeIOobjectFunction1Type(Sine, Type); \ + makeIOobjectFunction1Type(Square, Type); \ + makeIOobjectFunction1Type(CSV, Type); \ + makeIOobjectFunction1Type(Table, Type); \ + makeIOobjectFunction1Type(TableFile, Type); \ + makeIOobjectFunction1Type(Scale, Type); \ + makeIOobjectFunction1Type(LimitRange, Type); + + +namespace Foam +{ + // Add IOobject selection table for label. To be populated. + defineTemplateRunTimeSelectionTable + ( + Function1<label>, + IOobject + ); + + makeIOobjectFunction1s(scalar); + makeIOobjectFunction1s(vector); + makeIOobjectFunction1s(sphericalTensor); + makeIOobjectFunction1s(symmTensor); + makeIOobjectFunction1s(tensor); + + // Tbd: makeIOobjectFieldFunction1s +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.C b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.C index ad1ba81e522..df056c7c2be 100644 --- a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.C +++ b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.C @@ -50,4 +50,14 @@ Foam::Function1Types::quadraticRamp::quadraticRamp {} +Foam::Function1Types::quadraticRamp::quadraticRamp +( + const IOobject& io, + const dictionary& dict +) +: + ramp(io, dict) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H index fcdfaeacb1e..03e8adc8d9e 100644 --- a/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H +++ b/src/OpenFOAM/primitives/functions/Function1/quadraticRamp/quadraticRamp.H @@ -70,6 +70,9 @@ public: //- Construct from entry name and dictionary quadraticRamp(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + quadraticRamp(const IOobject& io, const dictionary& dict); + //- Destructor virtual ~quadraticRamp() = default; diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C index c3b0b2085ee..94e6d68867c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C +++ b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C @@ -50,4 +50,14 @@ Foam::Function1Types::quarterCosineRamp::quarterCosineRamp {} +Foam::Function1Types::quarterCosineRamp::quarterCosineRamp +( + const IOobject& io, + const dictionary& dict +) +: + ramp(io, dict) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.H b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.H index 275d316e476..cc766f6c6c1 100644 --- a/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.H +++ b/src/OpenFOAM/primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.H @@ -70,6 +70,9 @@ public: //- Construct from entry name and dictionary quarterCosineRamp(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + quarterCosineRamp(const IOobject& io, const dictionary& dict); + //- Destructor virtual ~quarterCosineRamp() = default; diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C index 287c5dfd132..9ef0acd7e3f 100644 --- a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C +++ b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C @@ -50,4 +50,14 @@ Foam::Function1Types::quarterSineRamp::quarterSineRamp {} +Foam::Function1Types::quarterSineRamp::quarterSineRamp +( + const IOobject& io, + const dictionary& dict +) +: + ramp(io, dict) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.H b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.H index 37aec55d7e4..b06339961b7 100644 --- a/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.H +++ b/src/OpenFOAM/primitives/functions/Function1/quarterSineRamp/quarterSineRamp.H @@ -69,6 +69,9 @@ public: //- Construct from entry name and dictionary quarterSineRamp(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + quarterSineRamp(const IOobject& io, const dictionary& dict); + //- Destructor virtual ~quarterSineRamp() = default; diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C index 53fb63ccc07..131f6077a63 100644 --- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.C @@ -30,7 +30,7 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -void Foam::Function1Types::ramp::read(const dictionary& coeffs) +void Foam::Function1Types::ramp::readDict(const dictionary& coeffs) { start_ = coeffs.getOrDefault<scalar>("start", 0); coeffs.readEntry("duration", duration_); @@ -45,7 +45,19 @@ Foam::Function1Types::ramp::ramp : Function1<scalar>(entryName, dict) { - read(dict); + readDict(dict); +} + + +Foam::Function1Types::ramp::ramp +( + const IOobject& io, + const dictionary& dict +) +: + Function1<scalar>(io, dict) +{ + readDict(dict); } @@ -65,7 +77,7 @@ void Foam::Function1Types::ramp::convertTimeBase(const Time& t) } -void Foam::Function1Types::ramp::writeData(Ostream& os) const +bool Foam::Function1Types::ramp::writeData(Ostream& os) const { Function1<scalar>::writeData(os); os << token::END_STATEMENT << nl; @@ -73,6 +85,8 @@ void Foam::Function1Types::ramp::writeData(Ostream& os) const os.beginBlock(word(this->name() + "Coeffs")); writeEntries(os); os.endBlock(); + + return os.good(); } diff --git a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H index df7ed6c00b1..6631722a5f4 100644 --- a/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H +++ b/src/OpenFOAM/primitives/functions/Function1/ramp/ramp.H @@ -109,7 +109,7 @@ private: // Private Member Functions //- Read the coefficients from the given dictionary - void read(const dictionary& coeffs); + void readDict(const dictionary& coeffs); //- No copy assignment void operator=(const ramp&) = delete; @@ -126,6 +126,13 @@ public: const dictionary& dict ); + //- Construct from IOobject and dictionary + ramp + ( + const IOobject& io, + const dictionary& dict + ); + //- Destructor virtual ~ramp() = default; @@ -140,7 +147,7 @@ public: virtual scalar value(const scalar t) const = 0; //- Write in dictionary format - virtual void writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; //- Write coefficient entries in dictionary format void writeEntries(Ostream& os) const; diff --git a/src/OpenFOAM/primitives/functions/Function1/step/stepFunction.C b/src/OpenFOAM/primitives/functions/Function1/step/stepFunction.C index 4ab76010f4e..a15c0511f12 100644 --- a/src/OpenFOAM/primitives/functions/Function1/step/stepFunction.C +++ b/src/OpenFOAM/primitives/functions/Function1/step/stepFunction.C @@ -34,6 +34,9 @@ namespace Foam namespace Function1Types { makeScalarFunction1(stepFunction); + + // IOobject version + makeConcreteIOobjectFunction1(stepFunction, scalar); } } @@ -50,4 +53,14 @@ Foam::Function1Types::stepFunction::stepFunction {} +Foam::Function1Types::stepFunction::stepFunction +( + const IOobject& io, + const dictionary& dict +) +: + ramp(io, dict) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/step/stepFunction.H b/src/OpenFOAM/primitives/functions/Function1/step/stepFunction.H index e6a6daa638a..84e9aa19744 100644 --- a/src/OpenFOAM/primitives/functions/Function1/step/stepFunction.H +++ b/src/OpenFOAM/primitives/functions/Function1/step/stepFunction.H @@ -69,6 +69,13 @@ public: //- Construct from entry name and dictionary stepFunction(const word& entryName, const dictionary& dict); + //- Construct from IOobject and dictionary + stepFunction + ( + const IOobject& io, + const dictionary& dict + ); + //- Destructor virtual ~stepFunction() = default; diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/surfactantProperties.H b/src/dynamicFaMesh/interfaceTrackingFvMesh/surfactantProperties.H index 3806a61d20e..47e997fec79 100644 --- a/src/dynamicFaMesh/interfaceTrackingFvMesh/surfactantProperties.H +++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/surfactantProperties.H @@ -183,7 +183,7 @@ public: IOobject ( "dSigma", - surfactConc.mesh().mesh().time().timeName(), + surfactConc.mesh().time().timeName(), surfactConc.mesh().mesh(), IOobject::NO_READ, IOobject::NO_WRITE diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.H index c0be971d0be..5c9dad8103e 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.H @@ -260,6 +260,15 @@ public: // If global number of visible cells > 0 becomes active explicit refinementHistory(const IOobject&, Istream&); + //- Copy construct + explicit refinementHistory(const refinementHistory&) = default; + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + // Member Functions diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H index bbfd2219507..6b0351e452b 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H @@ -101,6 +101,13 @@ public: // Uses read-option READ_IF_PRESENT explicit polyTopoChanger(polyMesh& mesh); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~polyTopoChanger() = default; diff --git a/src/finiteArea/edgeMesh/edgeFaMesh.H b/src/finiteArea/edgeMesh/edgeFaMesh.H index e726f628810..351f24a3cd0 100644 --- a/src/finiteArea/edgeMesh/edgeFaMesh.H +++ b/src/finiteArea/edgeMesh/edgeFaMesh.H @@ -65,6 +65,7 @@ public: GeoMesh<faMesh>(mesh) {} + // Member Functions //- Return size. Number of internal edges diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H index b39d19aeffa..368364311a7 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H @@ -115,6 +115,13 @@ public: const label size ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor ~faBoundaryMesh() = default; diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H index 229bbfc2c52..267c0d5e91d 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.H @@ -213,6 +213,13 @@ public: const word& cellZoneName = word::null ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~porosityModel() = default; diff --git a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.H b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.H index 14c06b7de27..b6602d78706 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.H +++ b/src/finiteVolume/cfdTools/general/solutionControl/solutionControl/solutionControl.H @@ -199,6 +199,13 @@ public: //- Construct from mesh solutionControl(fvMesh& mesh, const word& algorithmName); + //- Return a clone. Not applicable for singleton + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~solutionControl() = default; diff --git a/src/finiteVolume/expressions/base/fvExprDriverWriter.H b/src/finiteVolume/expressions/base/fvExprDriverWriter.H index 7553251c316..104e88d2a2a 100644 --- a/src/finiteVolume/expressions/base/fvExprDriverWriter.H +++ b/src/finiteVolume/expressions/base/fvExprDriverWriter.H @@ -85,6 +85,13 @@ public: //- Construct for named driver fvExprDriverWriter(const word& name, fvExprDriver& driver); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~fvExprDriverWriter() = default; diff --git a/src/finiteVolume/fields/surfaceFields/surfaceFields.C b/src/finiteVolume/fields/surfaceFields/surfaceFields.C index fd24f7d060c..22f80cfef86 100644 --- a/src/finiteVolume/fields/surfaceFields/surfaceFields.C +++ b/src/finiteVolume/fields/surfaceFields/surfaceFields.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,14 +27,13 @@ License \*---------------------------------------------------------------------------*/ #include "surfaceFields.H" +#include "addToRunTimeSelectionTable.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - defineTemplate2TypeNameAndDebug ( surfaceScalarField::Internal, @@ -67,8 +67,15 @@ defineTemplateTypeNameAndDebug(surfaceSphericalTensorField, 0); defineTemplateTypeNameAndDebug(surfaceSymmTensorField, 0); defineTemplateTypeNameAndDebug(surfaceTensorField, 0); +addToRunTimeSelectionTable(regIOobject, surfaceScalarField, IOobject); +addToRunTimeSelectionTable(regIOobject, surfaceVectorField, IOobject); +addToRunTimeSelectionTable(regIOobject, surfaceSphericalTensorField, IOobject); +addToRunTimeSelectionTable(regIOobject, surfaceSymmTensorField, IOobject); +addToRunTimeSelectionTable(regIOobject, surfaceTensorField, IOobject); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/volFields/volFields.C b/src/finiteVolume/fields/volFields/volFields.C index 768fe459141..f1358ae819f 100644 --- a/src/finiteVolume/fields/volFields/volFields.C +++ b/src/finiteVolume/fields/volFields/volFields.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,6 +27,7 @@ License \*---------------------------------------------------------------------------*/ #include "volFields.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -52,6 +53,12 @@ namespace Foam defineTemplateTypeNameAndDebug(volSymmTensorField, 0); defineTemplateTypeNameAndDebug(volTensorField, 0); + addToRunTimeSelectionTable(regIOobject, volScalarField, IOobject); + addToRunTimeSelectionTable(regIOobject, volVectorField, IOobject); + addToRunTimeSelectionTable(regIOobject, volSphericalTensorField, IOobject); + addToRunTimeSelectionTable(regIOobject, volSymmTensorField, IOobject); + addToRunTimeSelectionTable(regIOobject, volTensorField, IOobject); + } // End namespace Foam diff --git a/src/finiteVolume/lduPrimitiveMeshAssembly/lduPrimitiveMeshAssembly.H b/src/finiteVolume/lduPrimitiveMeshAssembly/lduPrimitiveMeshAssembly.H index 5a1edb35541..44790a5d3ba 100644 --- a/src/finiteVolume/lduPrimitiveMeshAssembly/lduPrimitiveMeshAssembly.H +++ b/src/finiteVolume/lduPrimitiveMeshAssembly/lduPrimitiveMeshAssembly.H @@ -122,6 +122,13 @@ public: const lduMesh& ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~lduPrimitiveMeshAssembly() = default; diff --git a/src/finiteVolume/surfaceMesh/surfaceMesh.H b/src/finiteVolume/surfaceMesh/surfaceMesh.H index b82d2ac9822..e4757c01e9c 100644 --- a/src/finiteVolume/surfaceMesh/surfaceMesh.H +++ b/src/finiteVolume/surfaceMesh/surfaceMesh.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -81,6 +82,18 @@ public: { return mesh_.Cf(); } + + //- Return mesh given objectRegistry. Reverse of thisDb. Returns + // null if objectRegistry does not hold Mesh + static refPtr<fvMesh> mesh(const objectRegistry& db) + { + const auto* meshPtr = isA<fvMesh>(db); + if (meshPtr) + { + return *meshPtr; + } + return nullptr; + } }; diff --git a/src/finiteVolume/volMesh/volMesh.H b/src/finiteVolume/volMesh/volMesh.H index cde07521f37..2751d892651 100644 --- a/src/finiteVolume/volMesh/volMesh.H +++ b/src/finiteVolume/volMesh/volMesh.H @@ -83,6 +83,18 @@ public: { return mesh_.C(); } + + //- Return mesh given objectRegistry. Reverse of thisDb. Returns + // null if objectRegistry does not hold Mesh + static refPtr<fvMesh> mesh(const objectRegistry& db) + { + const auto* meshPtr = isA<fvMesh>(db); + if (meshPtr) + { + return *meshPtr; + } + return nullptr; + } }; diff --git a/src/lagrangian/basic/IOPosition/IOPosition.H b/src/lagrangian/basic/IOPosition/IOPosition.H index 74e62d7876d..1b3d7eb8403 100644 --- a/src/lagrangian/basic/IOPosition/IOPosition.H +++ b/src/lagrangian/basic/IOPosition/IOPosition.H @@ -83,6 +83,13 @@ public: cloud::geometryType geomType = cloud::geometryType::COORDINATES ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + // Member functions diff --git a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Basic/Basic.H b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Basic/Basic.H index fc037a5fa66..ff00c77b23e 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Basic/Basic.H +++ b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Basic/Basic.H @@ -120,6 +120,12 @@ public: ); } + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~Basic(); diff --git a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H index 0f7c7b0fdc4..cba3c60a23a 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H +++ b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H @@ -134,6 +134,12 @@ public: ); } + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~Dual() = default; diff --git a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Moment/Moment.H b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Moment/Moment.H index c78a2583d97..485bf27f3b1 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Moment/Moment.H +++ b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Moment/Moment.H @@ -133,6 +133,12 @@ public: ); } + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~Moment(); diff --git a/src/lumpedPointMotion/movement/lumpedPointIOMovement.H b/src/lumpedPointMotion/movement/lumpedPointIOMovement.H index 7945b591f31..de24631314e 100644 --- a/src/lumpedPointMotion/movement/lumpedPointIOMovement.H +++ b/src/lumpedPointMotion/movement/lumpedPointIOMovement.H @@ -92,6 +92,13 @@ public: //- Construct from IOobject, optionally with some owner information explicit lumpedPointIOMovement(const IOobject& io, label ownerId = -1); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~lumpedPointIOMovement() = default; diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C index f4cecf62750..e35103afd35 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPointPatch/cyclicAMIPointPatch.C @@ -113,7 +113,7 @@ bool Foam::cyclicAMIPointPatch::coupled() const { return Pstream::parRun() - || !this->boundaryMesh().mesh().mesh().time().processorCase(); + || !this->boundaryMesh().mesh().time().processorCase(); } diff --git a/src/meshTools/PatchFunction1/MappedFile/rawIOField.H b/src/meshTools/PatchFunction1/MappedFile/rawIOField.H index 57bd0ec1742..53bc90af74a 100644 --- a/src/meshTools/PatchFunction1/MappedFile/rawIOField.H +++ b/src/meshTools/PatchFunction1/MappedFile/rawIOField.H @@ -74,6 +74,12 @@ public: //- Construct from IOobject explicit rawIOField(const IOobject& io, const bool readAverage); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~rawIOField() = default; diff --git a/src/meshTools/coordinate/systems/coordinateSystems.H b/src/meshTools/coordinate/systems/coordinateSystems.H index eb81ff231bf..dbebfb2aeda 100644 --- a/src/meshTools/coordinate/systems/coordinateSystems.H +++ b/src/meshTools/coordinate/systems/coordinateSystems.H @@ -123,6 +123,13 @@ public: PtrList<coordinateSystem>&& content ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + // Selectors diff --git a/src/meshTools/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.H b/src/meshTools/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.H index 26190e2f1a8..3ddba1feddf 100644 --- a/src/meshTools/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.H +++ b/src/meshTools/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.H @@ -123,6 +123,13 @@ public: const labelList& regionEdges ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~extendedFeatureEdgeMesh() = default; diff --git a/src/meshTools/edgeMesh/featureEdgeMesh/featureEdgeMesh.H b/src/meshTools/edgeMesh/featureEdgeMesh/featureEdgeMesh.H index d89db6b362f..bf92498dfed 100644 --- a/src/meshTools/edgeMesh/featureEdgeMesh/featureEdgeMesh.H +++ b/src/meshTools/edgeMesh/featureEdgeMesh/featureEdgeMesh.H @@ -75,9 +75,18 @@ public: const edgeList& edges ); + //- Construct as copy + explicit featureEdgeMesh(const featureEdgeMesh&) = default; + //- Construct as copy featureEdgeMesh(const IOobject& io, const edgeMesh& em); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + // IO diff --git a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.H b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.H index c8579e51ed6..99dac6f95bb 100644 --- a/src/meshTools/searchableSurfaces/searchableBox/searchableBox.H +++ b/src/meshTools/searchableSurfaces/searchableBox/searchableBox.H @@ -123,6 +123,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchableBox() = default; diff --git a/src/meshTools/searchableSurfaces/searchableCone/searchableCone.H b/src/meshTools/searchableSurfaces/searchableCone/searchableCone.H index 77c7dea6681..81e302d51e5 100644 --- a/src/meshTools/searchableSurfaces/searchableCone/searchableCone.H +++ b/src/meshTools/searchableSurfaces/searchableCone/searchableCone.H @@ -175,6 +175,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchableCone() = default; diff --git a/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.H b/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.H index 9035af15f07..a087273849f 100644 --- a/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.H +++ b/src/meshTools/searchableSurfaces/searchableCylinder/searchableCylinder.H @@ -146,6 +146,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchableCylinder() = default; diff --git a/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.H b/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.H index 7dec54089f8..c97e3ec7e1b 100644 --- a/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.H +++ b/src/meshTools/searchableSurfaces/searchableDisk/searchableDisk.H @@ -132,6 +132,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchableDisk() = default; diff --git a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.H b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.H index 1231adfc071..0085564cb86 100644 --- a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.H +++ b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.H @@ -113,6 +113,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchableExtrudedCircle(); diff --git a/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.H b/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.H index db9ae54b6b9..124c1a24f79 100644 --- a/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.H +++ b/src/meshTools/searchableSurfaces/searchablePlane/searchablePlane.H @@ -115,6 +115,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchablePlane() = default; diff --git a/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.H b/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.H index f04371e1f48..e3c932e574f 100644 --- a/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.H +++ b/src/meshTools/searchableSurfaces/searchablePlate/searchablePlate.H @@ -140,6 +140,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchablePlate() = default; diff --git a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.H b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.H index 8709528eece..c2f8c487309 100644 --- a/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.H +++ b/src/meshTools/searchableSurfaces/searchableRotatedBox/searchableRotatedBox.H @@ -125,6 +125,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchableRotatedBox() = default; diff --git a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H index febf3c4dd23..0269bf28a89 100644 --- a/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H +++ b/src/meshTools/searchableSurfaces/searchableSphere/searchableSphere.H @@ -200,6 +200,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchableSphere() = default; diff --git a/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H b/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H index 38d00526684..ebd74bfbf21 100644 --- a/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H +++ b/src/meshTools/searchableSurfaces/searchableSurface/searchableSurface.H @@ -138,8 +138,15 @@ public: searchableSurface(const IOobject& io); - //- Clone - virtual autoPtr<searchableSurface> clone() const + ////- Clone + //virtual autoPtr<searchableSurface> clone() const + //{ + // NotImplemented; + // return nullptr; + //} + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const { NotImplemented; return nullptr; diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.H b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.H index 3cbf15f86ac..9737e7a6f97 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.H +++ b/src/meshTools/searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.H @@ -145,6 +145,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~searchableSurfaceCollection(); diff --git a/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.H b/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.H index 6b2ad80cc99..ace88f45aa1 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.H +++ b/src/meshTools/searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.H @@ -142,6 +142,14 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + + //- Destructor virtual ~searchableSurfaceWithGaps() = default; diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H index e5fe8825ad3..6abb87eb0f7 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/triSurfaceMesh.H @@ -182,6 +182,14 @@ public: ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + + //- Destructor virtual ~triSurfaceMesh(); diff --git a/src/meshTools/sets/cellSources/fieldToCell/fieldDictionary.H b/src/meshTools/sets/cellSources/fieldToCell/fieldDictionary.H index 999f5a8862c..323ed409dc1 100644 --- a/src/meshTools/sets/cellSources/fieldToCell/fieldDictionary.H +++ b/src/meshTools/sets/cellSources/fieldToCell/fieldDictionary.H @@ -72,6 +72,15 @@ public: close(); } + //- Construct as copy + explicit fieldDictionary(const fieldDictionary&) = default; + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + // Member Functions diff --git a/src/meshTools/sets/topoSets/cellSet.H b/src/meshTools/sets/topoSets/cellSet.H index 3f03edb070b..a9b90790ea9 100644 --- a/src/meshTools/sets/topoSets/cellSet.H +++ b/src/meshTools/sets/topoSets/cellSet.H @@ -155,6 +155,14 @@ public: ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + + //- Destructor virtual ~cellSet() = default; diff --git a/src/meshTools/sets/topoSets/faceSet.H b/src/meshTools/sets/topoSets/faceSet.H index 5965ed75fb9..21c6ef939e5 100644 --- a/src/meshTools/sets/topoSets/faceSet.H +++ b/src/meshTools/sets/topoSets/faceSet.H @@ -118,6 +118,13 @@ public: writeOption w=NO_WRITE ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~faceSet() = default; diff --git a/src/meshTools/sets/topoSets/pointSet.H b/src/meshTools/sets/topoSets/pointSet.H index 3a0d0124c97..241bfe0aa57 100644 --- a/src/meshTools/sets/topoSets/pointSet.H +++ b/src/meshTools/sets/topoSets/pointSet.H @@ -118,6 +118,13 @@ public: writeOption w=NO_WRITE ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~pointSet() = default; diff --git a/src/meshTools/sets/topoSets/topoBitSet.H b/src/meshTools/sets/topoSets/topoBitSet.H index 6fdc551b77c..364cdce91b5 100644 --- a/src/meshTools/sets/topoSets/topoBitSet.H +++ b/src/meshTools/sets/topoSets/topoBitSet.H @@ -103,6 +103,14 @@ protected: public: + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + + //- Destructor virtual ~topoBitSet() = default; diff --git a/src/meshTools/sets/topoSets/topoBoolSet.H b/src/meshTools/sets/topoSets/topoBoolSet.H index 39b11652871..e14bd7f55b5 100644 --- a/src/meshTools/sets/topoSets/topoBoolSet.H +++ b/src/meshTools/sets/topoSets/topoBoolSet.H @@ -103,6 +103,14 @@ protected: public: + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + + //- Destructor virtual ~topoBoolSet() = default; diff --git a/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.H b/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.H index d80c75b12eb..3bbffd51023 100644 --- a/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.H +++ b/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.H @@ -148,6 +148,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~ATCModel() = default; diff --git a/src/optimisation/adjointOptimisation/adjoint/objectiveManager/objectiveManager/objectiveManager.H b/src/optimisation/adjointOptimisation/adjoint/objectiveManager/objectiveManager/objectiveManager.H index 0aeacc6b484..4905fc3727c 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectiveManager/objectiveManager/objectiveManager.H +++ b/src/optimisation/adjointOptimisation/adjoint/objectiveManager/objectiveManager/objectiveManager.H @@ -121,6 +121,13 @@ public: const word& primalSolverName ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~objectiveManager() = default; diff --git a/src/optimisation/adjointOptimisation/adjoint/solvers/adjointSolverManager/adjointSolverManager.H b/src/optimisation/adjointOptimisation/adjoint/solvers/adjointSolverManager/adjointSolverManager.H index 9f91025dad3..0782fa118c7 100644 --- a/src/optimisation/adjointOptimisation/adjoint/solvers/adjointSolverManager/adjointSolverManager.H +++ b/src/optimisation/adjointOptimisation/adjoint/solvers/adjointSolverManager/adjointSolverManager.H @@ -103,6 +103,13 @@ public: const dictionary& dict ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~adjointSolverManager() = default; diff --git a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.H b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.H index 6abd7931441..5ec35b3b78f 100644 --- a/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.H +++ b/src/optimisation/adjointOptimisation/adjoint/turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.H @@ -203,6 +203,13 @@ public: adjointTurbulenceModel::typeName ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~adjointRASModel() = default; diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/porousModels/porousModel/porousModel.H b/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/porousModels/porousModel/porousModel.H index 3fb3aa332df..68369e76eda 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/porousModels/porousModel/porousModel.H +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/porousModels/porousModel/porousModel.H @@ -93,6 +93,13 @@ public: const fvMesh& mesh ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~porousModel() = default; diff --git a/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.H b/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.H index d577ad27ddd..7f4ab511b6f 100644 --- a/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.H +++ b/src/phaseSystemModels/multiphaseInter/phasesSystem/interfaceModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.H @@ -95,6 +95,13 @@ public: const bool registerObject ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~surfaceTensionModel() = default; diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.H b/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.H index b09508e987b..2cf720edd3f 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.H +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/BlendedInterfacialModel/BlendedInterfacialModel.H @@ -157,6 +157,13 @@ public: const bool correctFixedFluxBCs = true ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor ~BlendedInterfacialModel(); diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialCompositionModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.H b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialCompositionModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.H index af8284cfcf6..eb25fdf4779 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialCompositionModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.H +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialCompositionModels/surfaceTensionModels/surfaceTensionModel/surfaceTensionModel.H @@ -102,6 +102,13 @@ public: const bool registerObject ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~surfaceTensionModel() = default; diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/dragModels/dragModel/dragModel.H b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/dragModels/dragModel/dragModel.H index 660662e2ef2..71c822bbc19 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/dragModels/dragModel/dragModel.H +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/dragModels/dragModel/dragModel.H @@ -114,6 +114,13 @@ public: const bool registerObject ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~dragModel(); diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/virtualMassModels/virtualMassModel/virtualMassModel.H b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/virtualMassModels/virtualMassModel/virtualMassModel.H index 10ad757b1ca..d255ababc30 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/virtualMassModels/virtualMassModel/virtualMassModel.H +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/interfacialModels/virtualMassModels/virtualMassModel/virtualMassModel.H @@ -103,6 +103,13 @@ public: const bool registerObject ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~virtualMassModel() = default; diff --git a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.H b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.H index 91e31fed5bc..e8ae3e97e34 100644 --- a/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.H +++ b/src/phaseSystemModels/reactingEuler/multiphaseSystem/populationBalanceModel/populationBalanceModel/populationBalanceModel.H @@ -384,6 +384,13 @@ public: } }; + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~populationBalanceModel(); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/dragModels/dragModel/dragModel.H b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/dragModels/dragModel/dragModel.H index 2663b42430b..e6e294944e1 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/dragModels/dragModel/dragModel.H +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/dragModels/dragModel/dragModel.H @@ -114,6 +114,13 @@ public: const bool registerObject ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~dragModel(); diff --git a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/virtualMassModel/virtualMassModel.H b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/virtualMassModel/virtualMassModel.H index 91b5656fe07..e8c8d6ec7b1 100644 --- a/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/virtualMassModel/virtualMassModel.H +++ b/src/phaseSystemModels/twoPhaseEuler/twoPhaseSystem/interfacialModels/virtualMassModels/virtualMassModel/virtualMassModel.H @@ -103,6 +103,13 @@ public: const bool registerObject ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~virtualMassModel() = default; diff --git a/src/surfMesh/surfZone/surfZoneIOList.H b/src/surfMesh/surfZone/surfZoneIOList.H index 10681a89290..2f9d1a4da9a 100644 --- a/src/surfMesh/surfZone/surfZoneIOList.H +++ b/src/surfMesh/surfZone/surfZoneIOList.H @@ -73,6 +73,15 @@ public: //- Construct from IOobject and transferring surfZoneList content surfZoneIOList(const IOobject& io, surfZoneList&& content); + //- Construct as copy + explicit surfZoneIOList(const surfZoneIOList&) = default; + + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + return regIOobject::DeepClone(*this); + } + //- Destructor virtual ~surfZoneIOList() = default; diff --git a/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.H b/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.H index 4db7724d0c1..8f6d1b6c917 100644 --- a/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.H +++ b/src/thermophysicalModels/SLGThermo/SLGThermo/SLGThermo.H @@ -91,6 +91,13 @@ public: //- Construct from mesh SLGThermo(const fvMesh& mesh, fluidThermo& thermo); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~SLGThermo(); diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.H b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.H index df9b62a6ce8..d2bfb0b2b20 100644 --- a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.H +++ b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.H @@ -89,6 +89,13 @@ public: const fvMesh& mesh ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~constant(); diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.H b/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.H index cd2ecb264e1..fc9287f86cc 100644 --- a/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.H +++ b/src/transportModels/interfaceProperties/surfaceTensionModels/temperatureDependent/temperatureDependentSurfaceTension.H @@ -104,6 +104,13 @@ public: const fvMesh& mesh ); + //- Return a clone + virtual refPtr<regIOobject> deepClone() const + { + NotImplemented; + return nullptr; + } + //- Destructor virtual ~temperatureDependent(); -- GitLab