diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/DTRMParticle/DTRMParticle.H b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/DTRMParticle/DTRMParticle.H index 5ad00275d5..47c381aa8c 100644 --- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/DTRMParticle/DTRMParticle.H +++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/DTRMParticle/DTRMParticle.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2019 OpenCFD Ltd + Copyright (C) 2017-2024 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -206,9 +206,13 @@ public: //- Construct as copy DTRMParticle(const DTRMParticle& p); + //- Return a clone + virtual autoPtr clone() const + { + return particle::Clone(*this); + } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H index 394f64e490..89821165c3 100644 --- a/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H +++ b/applications/utilities/parallelProcessing/redistributePar/passivePositionParticle.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -100,10 +100,10 @@ public: cachedPosition_(p.cachedPosition_) {} - //- Construct and return a clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr(new passivePositionParticle(*this)); + return particle::Clone(*this); } diff --git a/etc/codeTemplates/dynamicCode/codedFunction1Template.H b/etc/codeTemplates/dynamicCode/codedFunction1Template.H index 3b2de974a9..d54e4a350c 100644 --- a/etc/codeTemplates/dynamicCode/codedFunction1Template.H +++ b/etc/codeTemplates/dynamicCode/codedFunction1Template.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -86,13 +86,10 @@ public: const ${typeName}Function1_${TemplateType}& rhs ) = default; - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp> - ( - new ${typeName}Function1_${TemplateType}(*this) - ); + return Function1<${TemplateType}>::Clone(*this); } diff --git a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H index c67d160012..16b38abecc 100644 --- a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H +++ b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,12 +85,6 @@ public: const bool faceValues = true ); - //- Copy construct - ${typeName}PatchFunction1${FieldType} - ( - const ${typeName}PatchFunction1${FieldType}& rhs - ) = default; - //- Copy construct, resetting patch ${typeName}PatchFunction1${FieldType} ( @@ -98,25 +92,25 @@ public: const polyPatch& pp ); - //- Construct and return a clone + //- Copy construct + ${typeName}PatchFunction1${FieldType} + ( + const ${typeName}PatchFunction1${FieldType}& rhs + ) = default; + + //- Return a clone virtual tmp> clone() const { - return tmp> - ( - new ${typeName}PatchFunction1${FieldType}(*this) - ); + return PatchFunction1<${TemplateType}>::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp> clone ( const polyPatch& pp ) const { - return tmp> - ( - new ${typeName}PatchFunction1${FieldType}(*this, pp) - ); + return PatchFunction1<${TemplateType}>::Clone(*this, pp); } diff --git a/src/OpenFOAM/expressions/Function1/Function1Expression.H b/src/OpenFOAM/expressions/Function1/Function1Expression.H index 69ecf32424..2591779088 100644 --- a/src/OpenFOAM/expressions/Function1/Function1Expression.H +++ b/src/OpenFOAM/expressions/Function1/Function1Expression.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,8 +65,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_expression_H -#define Function1Types_expression_H +#ifndef Foam_Function1Types_expression_H +#define Foam_Function1Types_expression_H #include "Function1.H" #include "fieldExprDriver.H" @@ -124,10 +124,10 @@ public: //- Copy construct explicit Function1Expression(const Function1Expression& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Function1Expression(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H index f505353154..5dfaf1e9df 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -133,9 +133,7 @@ public: //- Return clone autoPtr clone() const { - return - autoPtr::NewFrom - (*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H index 057c6f699b..d6f4bed516 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -115,9 +115,7 @@ public: //- Return clone autoPtr clone() const { - return - autoPtr::NewFrom - (*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H index cd693981a7..775f9bb006 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -144,9 +144,7 @@ public: //- Return clone autoPtr clone() const { - return - autoPtr::NewFrom - (*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H index 0914d4b1c2..5ff65b483e 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -120,9 +120,7 @@ public: //- Return clone autoPtr clone() const { - return - autoPtr::NewFrom - (*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H index 32c5e81493..6a2ccd3724 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -109,11 +109,18 @@ public: // Uses all default constructors - //- Construct and return a clone + //- Return a clone virtual autoPtr clone() const = 0; - // Selectors + // Factory Methods + + //- Clone a coordinate rotation + template + static autoPtr Clone(const Derived& crot) + { + return autoPtr(new Derived(crot)); + } //- Select construct the specified coordinate rotation type // diff --git a/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.H index 59a1acd0fb..ca9c1d987b 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/cylindricalRotation.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -89,9 +89,7 @@ public: //- Return clone autoPtr clone() const { - return - autoPtr::NewFrom - (*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H index 80fe1efec6..ede44c3c28 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -93,9 +93,7 @@ public: //- Return clone autoPtr clone() const { - return - autoPtr::NewFrom - (*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H index 6d41c8ce55..f2f0971f0c 100644 --- a/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H +++ b/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -89,9 +89,7 @@ public: //- Return clone autoPtr clone() const { - return - autoPtr::NewFrom - (*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/systems/cartesianCS.H b/src/OpenFOAM/primitives/coordinate/systems/cartesianCS.H index 111db8100e..4b8c95429a 100644 --- a/src/OpenFOAM/primitives/coordinate/systems/cartesianCS.H +++ b/src/OpenFOAM/primitives/coordinate/systems/cartesianCS.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -149,7 +149,7 @@ public: //- Return clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return coordinateSystem::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H index 7703525b1a..d835ddeaad 100644 --- a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H +++ b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -453,7 +453,26 @@ public: ); - // Selectors + // Factory Methods + + //- Clone a coordinate system + template + static autoPtr Clone(const Derived& csys) + { + return autoPtr(new Derived(csys)); + } + + //- Select construct the specified coordinate system type + //- with reference to objectRegistry for indirect entries. + // + // An empty modelType will be treated as "cartesian" + static autoPtr Clone + ( + const word& modelType, + const objectRegistry& obr, + const dictionary& dict, + IOobjectOption::readOption readOrigin = IOobjectOption::MUST_READ + ); //- Select construct the specified coordinate system type //- with reference to objectRegistry for indirect entries. diff --git a/src/OpenFOAM/primitives/coordinate/systems/cylindricalCS.H b/src/OpenFOAM/primitives/coordinate/systems/cylindricalCS.H index 47d39e5fa5..a6a08e7a19 100644 --- a/src/OpenFOAM/primitives/coordinate/systems/cylindricalCS.H +++ b/src/OpenFOAM/primitives/coordinate/systems/cylindricalCS.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -191,7 +191,7 @@ public: //- Return clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return coordinateSystem::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/systems/indirectCS.H b/src/OpenFOAM/primitives/coordinate/systems/indirectCS.H index 26565d46f2..bf40e9a6a2 100644 --- a/src/OpenFOAM/primitives/coordinate/systems/indirectCS.H +++ b/src/OpenFOAM/primitives/coordinate/systems/indirectCS.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -149,7 +149,7 @@ public: //- Return clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return coordinateSystem::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H index 486744c04f..bb7341047c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H +++ b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -140,10 +140,10 @@ public: //- Copy construct explicit CSV(const CSV& csv); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new CSV(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H index ed8dbfe01e..3884d5caa5 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -84,8 +84,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_CodedFunction1_H -#define Function1Types_CodedFunction1_H +#ifndef Foam_Function1Types_CodedFunction1_H +#define Foam_Function1Types_CodedFunction1_H #include "Function1.H" #include "codedBase.H" @@ -184,10 +184,10 @@ public: //- Copy construct explicit CodedFunction1(const CodedFunction1& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new CodedFunction1(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H index 3ddc1ed670..84072468b2 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H +++ b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -53,8 +53,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Constant_H -#define Function1Types_Constant_H +#ifndef Foam_Function1Types_Constant_H +#define Foam_Function1Types_Constant_H #include "Function1.H" @@ -118,10 +118,10 @@ public: //- Copy constructor explicit Constant(const Constant& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Constant(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H b/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H index 5c00ed1a2c..6342c5066a 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H +++ b/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -96,8 +96,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Cosine_H -#define Function1Types_Cosine_H +#ifndef Foam_Function1Types_Cosine_H +#define Foam_Function1Types_Cosine_H #include "Sine.H" @@ -148,10 +148,10 @@ public: Sine(rhs) {} - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Cosine(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C index cfcde22801..27fc4e6604 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C @@ -134,17 +134,6 @@ Foam::FieldFunction1::FieldFunction1 {} -template -Foam::tmp> -Foam::FieldFunction1::clone() const -{ - return tmp> - ( - new FieldFunction1(*this) - ); -} - - template Foam::tmp> Foam::FieldFunction1::integrate diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H index fa64f4f0cd..107a857b0b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -164,11 +164,18 @@ public: //- Copy construct explicit Function1(const Function1& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const = 0; - // Selectors + // Factory Methods + + //- Clone a Function1 + template + static tmp> Clone(const Derived& fun) + { + return tmp>(new Derived(fun)); + } //- Selector, with fallback redirection static autoPtr> New @@ -321,8 +328,11 @@ public: const objectRegistry* obrPtr = nullptr ); - //- Construct and return a clone - virtual tmp> clone() const; + //- Return a clone + virtual tmp> clone() const + { + return Function1::Clone(*this); + } //- Destructor diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H index b3ac5b7337..c8f0053ec5 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H @@ -25,8 +25,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef Function1Fwd_H -#define Function1Fwd_H +#ifndef Foam_Function1Fwd_H +#define Foam_Function1Fwd_H #include "Function1.H" #include "vector.H" diff --git a/src/OpenFOAM/primitives/functions/Function1/FunctionObjectTrigger/FunctionObjectTrigger.H b/src/OpenFOAM/primitives/functions/Function1/FunctionObjectTrigger/FunctionObjectTrigger.H index 9e2d876bf5..4bc989a840 100644 --- a/src/OpenFOAM/primitives/functions/Function1/FunctionObjectTrigger/FunctionObjectTrigger.H +++ b/src/OpenFOAM/primitives/functions/Function1/FunctionObjectTrigger/FunctionObjectTrigger.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,8 +58,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_FunctionObjectTrigger_H -#define Function1Types_FunctionObjectTrigger_H +#ifndef Foam_Function1Types_FunctionObjectTrigger_H +#define Foam_Function1Types_FunctionObjectTrigger_H #include "Function1.H" #include "labelList.H" @@ -80,7 +80,6 @@ class FunctionObjectTrigger : public Function1 { - // Private Data //- Trigger indices when it is considered active @@ -124,10 +123,10 @@ public: //- Copy construct explicit FunctionObjectTrigger(const FunctionObjectTrigger& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new FunctionObjectTrigger(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/FunctionObjectValue/FunctionObjectValue.H b/src/OpenFOAM/primitives/functions/Function1/FunctionObjectValue/FunctionObjectValue.H index 03f00ade90..c2e7f7919c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/FunctionObjectValue/FunctionObjectValue.H +++ b/src/OpenFOAM/primitives/functions/Function1/FunctionObjectValue/FunctionObjectValue.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,8 +49,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_FunctionObjectValue_H -#define Function1Types_FunctionObjectValue_H +#ifndef Foam_Function1Types_FunctionObjectValue_H +#define Foam_Function1Types_FunctionObjectValue_H #include "Function1.H" @@ -116,10 +116,10 @@ public: //- Copy construct explicit FunctionObjectValue(const FunctionObjectValue& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new FunctionObjectValue(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/InputValueMapper/InputValueMapper.H b/src/OpenFOAM/primitives/functions/Function1/InputValueMapper/InputValueMapper.H index c7edfc49fe..a59a89ae63 100644 --- a/src/OpenFOAM/primitives/functions/Function1/InputValueMapper/InputValueMapper.H +++ b/src/OpenFOAM/primitives/functions/Function1/InputValueMapper/InputValueMapper.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,8 +104,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_InputValueMapper_H -#define Function1Types_InputValueMapper_H +#ifndef Foam_Function1Types_InputValueMapper_H +#define Foam_Function1Types_InputValueMapper_H #include "Function1.H" #include "Enum.H" @@ -201,10 +201,10 @@ public: //- Copy construct explicit InputValueMapper(const InputValueMapper& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new InputValueMapper(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/None/NoneFunction1.H b/src/OpenFOAM/primitives/functions/Function1/None/NoneFunction1.H index 2faa535cfb..c3b67156fb 100644 --- a/src/OpenFOAM/primitives/functions/Function1/None/NoneFunction1.H +++ b/src/OpenFOAM/primitives/functions/Function1/None/NoneFunction1.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -86,10 +86,10 @@ public: const objectRegistry* obrPtr = nullptr ); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new None(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H index 84d496afb2..8dc2bff57b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H +++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,8 +40,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_OneConstant_H -#define Function1Types_OneConstant_H +#ifndef Foam_Function1Types_OneConstant_H +#define Foam_Function1Types_OneConstant_H #include "Function1.H" @@ -93,10 +93,10 @@ public: const objectRegistry* obrPtr = nullptr ); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new OneConstant(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H b/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H index bf165ed22d..61a5ba4daa 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H +++ b/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,8 +59,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Polynomial_H -#define Function1Types_Polynomial_H +#ifndef Foam_Function1Types_Polynomial_H +#define Foam_Function1Types_Polynomial_H #include "Function1.H" #include "Tuple2.H" @@ -127,10 +127,10 @@ public: //- Copy constructor explicit Polynomial(const Polynomial& poly); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Polynomial(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H index fe3c7ff0a6..7df092c4ba 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,8 +72,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Scale_H -#define Function1Types_Scale_H +#ifndef Foam_Function1Types_Scale_H +#define Foam_Function1Types_Scale_H #include "Function1.H" @@ -133,10 +133,10 @@ public: //- Copy construct explicit Scale(const Scale& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Scale(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H index 58f255cba3..db86c65986 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H +++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -98,8 +98,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Sine_H -#define Function1Types_Sine_H +#ifndef Foam_Function1Types_Sine_H +#define Foam_Function1Types_Sine_H #include "Function1.H" @@ -192,10 +192,10 @@ public: //- Copy construct explicit Sine(const Sine& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Sine(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H index 0aa61cf6c5..01d1aa4a04 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H +++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -101,8 +101,8 @@ Note \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Square_H -#define Function1Types_Square_H +#ifndef Foam_Function1Types_Square_H +#define Foam_Function1Types_Square_H #include "Sine.H" @@ -155,10 +155,10 @@ public: //- Copy construct explicit Square(const Square& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Square(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H index c9832de5c0..cdb2b4f5ca 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H +++ b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -79,8 +79,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Table_H -#define Function1Types_Table_H +#ifndef Foam_Function1Types_Table_H +#define Foam_Function1Types_Table_H #include "TableBase.H" @@ -130,10 +130,10 @@ public: //- Copy construct explicit Table(const Table& tbl); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Table(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H index 9cd1319d6d..c622c8653c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H +++ b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,8 +59,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_TableFile_H -#define Function1Types_TableFile_H +#ifndef Foam_Function1Types_TableFile_H +#define Foam_Function1Types_TableFile_H #include "TableBase.H" @@ -111,10 +111,10 @@ public: //- Copy construct explicit TableFile(const TableFile& tbl); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new TableFile(*this)); + return Function1::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H index 1b17a7a355..22919c77ff 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H +++ b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,8 +40,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Uniform_H -#define Function1Types_Uniform_H +#ifndef Foam_Function1Types_Uniform_H +#define Foam_Function1Types_Uniform_H #include "Constant.H" @@ -89,10 +89,10 @@ public: Constant(entryName, dict, obrPtr) {} - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Uniform(*this)); + return Function1::Clone(*this); } }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H index 3437ffc4a1..b457844b1b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H +++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,8 +49,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_ZeroConstant_H -#define Function1Types_ZeroConstant_H +#ifndef Foam_Function1Types_ZeroConstant_H +#define Foam_Function1Types_ZeroConstant_H #include "Function1.H" @@ -102,10 +102,10 @@ public: const objectRegistry* obrPtr = nullptr ); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new ZeroConstant(*this)); + return Function1::Clone(*this); } diff --git a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C index a342dc4b57..554e74e8a3 100644 --- a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C +++ b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C @@ -62,16 +62,6 @@ Foam::PatchFunction1Types::PatchExprField::PatchExprField } -template -Foam::PatchFunction1Types::PatchExprField::PatchExprField -( - const PatchExprField& rhs -) -: - PatchExprField(rhs, rhs.patch()) -{} - - template Foam::PatchFunction1Types::PatchExprField::PatchExprField ( @@ -86,6 +76,16 @@ Foam::PatchFunction1Types::PatchExprField::PatchExprField {} +template +Foam::PatchFunction1Types::PatchExprField::PatchExprField +( + const PatchExprField& rhs +) +: + PatchExprField(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H index 4a66dbc669..ac3620918c 100644 --- a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H +++ b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -122,9 +122,6 @@ public: const bool faceValues = true ); - //- Copy construct - explicit PatchExprField(const PatchExprField& rhs); - //- Copy construct setting patch explicit PatchExprField ( @@ -132,22 +129,19 @@ public: const polyPatch& pp ); - //- Construct and return a clone + //- Copy construct + explicit PatchExprField(const PatchExprField& rhs); + + //- Return a clone virtual tmp> clone() const { - return tmp> - ( - new PatchExprField(*this) - ); + return PatchFunction1::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp> clone(const polyPatch& pp) const { - return tmp> - ( - new PatchExprField(*this, pp) - ); + return PatchFunction1::Clone(*this, pp); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.C index 45601fe236..7cc3c3048d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.C @@ -73,16 +73,6 @@ Foam::PatchFunction1Types::Sampled::Sampled } -template -Foam::PatchFunction1Types::Sampled::Sampled -( - const Sampled& rhs -) -: - Sampled(rhs, rhs.patch()) -{} - - template Foam::PatchFunction1Types::Sampled::Sampled ( @@ -99,6 +89,16 @@ Foam::PatchFunction1Types::Sampled::Sampled {} +template +Foam::PatchFunction1Types::Sampled::Sampled +( + const Sampled& rhs +) +: + Sampled(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H index a92ae7fd7a..7a64493489 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -149,9 +149,6 @@ public: const bool faceValues = true ); - //- Copy construct - explicit Sampled(const Sampled& rhs); - //- Copy construct setting patch explicit Sampled ( @@ -159,22 +156,19 @@ public: const polyPatch& pp ); - //- Construct and return a clone + //- Copy construct + explicit Sampled(const Sampled& rhs); + + //- Return a clone virtual tmp> clone() const { - return tmp> - ( - new Sampled(*this) - ); + return PatchFunction1::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp> clone(const polyPatch& pp) const { - return tmp> - ( - new Sampled(*this, pp) - ); + return PatchFunction1::Clone(*this, pp); } diff --git a/src/functionObjects/field/nearWallFields/findCellParticle.H b/src/functionObjects/field/nearWallFields/findCellParticle.H index c4238a66ba..3c12092135 100644 --- a/src/functionObjects/field/nearWallFields/findCellParticle.H +++ b/src/functionObjects/field/nearWallFields/findCellParticle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -144,14 +144,13 @@ public: bool newFormat = true ); - //- Construct and return a clone - autoPtr clone() const + //- Return a clone + virtual autoPtr clone() const { - return autoPtr(new findCellParticle(*this)); + return particle::Clone(*this); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/functionObjects/field/streamLine/streamLineParticle.H b/src/functionObjects/field/streamLine/streamLineParticle.H index 9f8045f00b..53cec86383 100644 --- a/src/functionObjects/field/streamLine/streamLineParticle.H +++ b/src/functionObjects/field/streamLine/streamLineParticle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -170,10 +170,10 @@ public: //- Construct copy streamLineParticle(const streamLineParticle& p); - //- Construct and return a clone - autoPtr clone() const + //- Return a clone + virtual autoPtr clone() const { - return autoPtr(new streamLineParticle(*this)); + return particle::Clone(*this); } //- Factory class to read-construct particles used for parallel transfer diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.H b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.H index 9a49d00b16..451b83a0ba 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.H +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +41,6 @@ SourceFiles #define Foam_wallBoundedParticle_H #include "particle.H" -#include "autoPtr.H" #include "InfoProxy.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -176,14 +175,13 @@ public: //- Construct copy wallBoundedParticle(const wallBoundedParticle& p); - //- Construct and return a clone - autoPtr clone() const + //- Return a clone + virtual autoPtr clone() const { - return autoPtr(new wallBoundedParticle(*this)); + return particle::Clone(*this); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.H b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.H index a40535ee15..d2f4548448 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.H +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,7 +40,6 @@ SourceFiles #define Foam_wallBoundedStreamLineParticle_H #include "wallBoundedParticle.H" -#include "autoPtr.H" #include "interpolation.H" #include "vectorList.H" #include "InfoProxy.H" @@ -181,14 +180,13 @@ public: //- Construct copy wallBoundedStreamLineParticle(const wallBoundedStreamLineParticle& p); - //- Construct and return a clone + //- Return a clone autoPtr clone() const { - return autoPtr(new wallBoundedStreamLineParticle(*this)); + return particle::Clone(*this); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H index d2946bc2ad..a498240149 100644 --- a/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H +++ b/src/lagrangian/DSMC/parcels/Templates/DSMCParcel/DSMCParcel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,7 +42,6 @@ SourceFiles #include "particle.H" #include "IOstream.H" -#include "autoPtr.H" #include "contiguous.H" #include "DSMCCloud.H" @@ -193,14 +192,13 @@ public: bool newFormat = true ); - //- Construct and return a clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr(new DSMCParcel(*this)); + return particle::Clone(*this); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/basic/indexedParticle/indexedParticle.H b/src/lagrangian/basic/indexedParticle/indexedParticle.H index e08f525de6..66103eea8f 100644 --- a/src/lagrangian/basic/indexedParticle/indexedParticle.H +++ b/src/lagrangian/basic/indexedParticle/indexedParticle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,7 +40,6 @@ SourceFiles #include "particle.H" #include "IOstream.H" -#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -109,13 +108,14 @@ public: //- Construct as a copy indexedParticle(const indexedParticle& p) : - particle(p) + particle(p), + index_(p.index_) {} - //- Construct and return a clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr(new indexedParticle(*this)); + return particle::Clone(*this); } diff --git a/src/lagrangian/basic/injectedParticle/injectedParticle.H b/src/lagrangian/basic/injectedParticle/injectedParticle.H index 294108a7f3..124fcf67f6 100644 --- a/src/lagrangian/basic/injectedParticle/injectedParticle.H +++ b/src/lagrangian/basic/injectedParticle/injectedParticle.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,7 +46,6 @@ SeeAlso #include "particle.H" #include "IOstream.H" -#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -147,20 +146,19 @@ public: //- Construct as a copy injectedParticle(const injectedParticle& p, const polyMesh& mesh); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new injectedParticle(*this)); + return particle::Clone(*this); } //- Construct and return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr(new injectedParticle(*this, mesh)); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; @@ -174,10 +172,7 @@ public: autoPtr operator()(Istream& is) const { - return autoPtr - ( - new injectedParticle(mesh_, is, true) - ); + return autoPtr::New(mesh_, is, true); } }; diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index 2ddea84408..2939c3a6f3 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -599,22 +599,6 @@ Foam::particle::particle } -Foam::particle::particle(const particle& p) -: - mesh_(p.mesh_), - coordinates_(p.coordinates_), - celli_(p.celli_), - tetFacei_(p.tetFacei_), - tetPti_(p.tetPti_), - facei_(p.facei_), - stepFraction_(p.stepFraction_), - behind_(p.behind_), - nBehind_(p.nBehind_), - origProc_(p.origProc_), - origId_(p.origId_) -{} - - Foam::particle::particle(const particle& p, const polyMesh& mesh) : mesh_(mesh), @@ -631,6 +615,12 @@ Foam::particle::particle(const particle& p, const polyMesh& mesh) {} +Foam::particle::particle(const particle& p) +: + particle(p, p.mesh()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::particle::track diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 10e282e12a..97702a4ee6 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -417,18 +417,35 @@ public: const bool doLocate = true ); - //- Construct as a copy - particle(const particle& p); - - //- Construct as a copy with reference to a new mesh + //- Construct as a copy with reference to a mesh particle(const particle& p, const polyMesh& mesh); + //- Copy construct + particle(const particle& p); + //- Construct a clone virtual autoPtr clone() const { return autoPtr::New(*this); } + + // Factory Methods + + //- Clone a particle + template + static autoPtr Clone(const Derived& p) + { + return autoPtr(new Derived(p)); + } + + //- Clone a particle with a mesh reference + template + static autoPtr Clone(const Derived& p, const polyMesh& mesh) + { + return autoPtr(new Derived(p, mesh)); + } + //- Factory class to read-construct particles (for parallel transfer) class iNew { diff --git a/src/lagrangian/basic/passiveParticle/passiveParticle.H b/src/lagrangian/basic/passiveParticle/passiveParticle.H index 46593237ec..13c1f18024 100644 --- a/src/lagrangian/basic/passiveParticle/passiveParticle.H +++ b/src/lagrangian/basic/passiveParticle/passiveParticle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,7 +40,6 @@ SourceFiles #include "particle.H" #include "IOstream.H" -#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -106,10 +105,10 @@ public: {} - //- Construct and return a clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr(new passiveParticle(*this)); + return particle::Clone(*this); } diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H index 7741b6195f..ee46e5e4e5 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -226,20 +226,19 @@ public: //- Construct as a copy CollidingParcel(const CollidingParcel& p, const polyMesh& mesh); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new CollidingParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr(new CollidingParcel(*this, mesh)); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H index 14efa73daf..d8362c1ba0 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,7 +52,6 @@ SourceFiles #include "particle.H" #include "IOstream.H" -#include "autoPtr.H" #include "interpolation.H" #include "demandDrivenEntry.H" #include "labelFieldIOField.H" @@ -433,20 +432,19 @@ public: //- Construct as a copy KinematicParcel(const KinematicParcel& p, const polyMesh& mesh); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new KinematicParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr(new KinematicParcel(*this, mesh)); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H index 59cc4044fc..e62261d6d2 100644 --- a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -238,20 +238,19 @@ public: //- Construct as a copy MPPICParcel(const MPPICParcel& p, const polyMesh& mesh); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new MPPICParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr(new MPPICParcel(*this, mesh)); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingHeterogeneousParcel/ReactingHeterogeneousParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingHeterogeneousParcel/ReactingHeterogeneousParcel.H index 120cfcd4ab..fc589fac93 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingHeterogeneousParcel/ReactingHeterogeneousParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingHeterogeneousParcel/ReactingHeterogeneousParcel.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -280,23 +280,19 @@ public: const polyMesh& mesh ); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new ReactingHeterogeneousParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr - ( - new ReactingHeterogeneousParcel(*this, mesh) - ); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H index 757dc1bc5d..a2dd7c434e 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -357,20 +357,19 @@ public: const polyMesh& mesh ); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new ReactingMultiphaseParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr(new ReactingMultiphaseParcel(*this, mesh)); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H index 4491c506cc..a297563417 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -327,23 +327,19 @@ public: //- Construct as a copy ReactingParcel(const ReactingParcel& p); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new ReactingParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr - ( - new ReactingParcel(*this, mesh) - ); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H index dbbf70ffad..d22c06958a 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -348,20 +348,19 @@ public: //- Construct as a copy ThermoParcel(const ThermoParcel& p, const polyMesh& mesh); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new ThermoParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr(new ThermoParcel(*this, mesh)); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H index e11827c5c0..26dd41c15b 100644 --- a/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H +++ b/src/lagrangian/molecularDynamics/molecule/molecule/molecule.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,7 +42,6 @@ SourceFiles #include "particle.H" #include "IOstream.H" -#include "autoPtr.H" #include "diagTensor.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -283,14 +282,13 @@ public: bool newFormat = true ); - //- Construct and return a clone - autoPtr clone() const + //- Return a clone + virtual autoPtr clone() const { - return autoPtr(new molecule(*this)); + return particle::Clone(*this); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/lagrangian/solidParticle/solidParticle.H b/src/lagrangian/solidParticle/solidParticle.H index b82f7bc7e0..4f9375b91f 100644 --- a/src/lagrangian/solidParticle/solidParticle.H +++ b/src/lagrangian/solidParticle/solidParticle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,7 +43,6 @@ SourceFiles #include "particle.H" #include "IOstream.H" -#include "autoPtr.H" #include "interpolationCellPoint.H" #include "contiguous.H" @@ -185,10 +184,10 @@ public: bool newFormat = true ); - //- Construct and return a clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr(new solidParticle(*this)); + return particle::Clone(*this); } //- Factory class to read-construct particles (for parallel transfer) diff --git a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H index f77c4b2955..eb47be3b22 100644 --- a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H +++ b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -275,23 +275,19 @@ public: //- Construct as a copy SprayParcel(const SprayParcel& p); - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone() const { - return autoPtr(new SprayParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr clone(const polyMesh& mesh) const { - return autoPtr - ( - new SprayParcel(*this, mesh) - ); + return particle::Clone(*this, mesh); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.H b/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.H index a4ae212678..ce831e5238 100644 --- a/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.H +++ b/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +41,6 @@ SourceFiles #include "bitSet.H" #include "particle.H" -#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -164,14 +163,13 @@ public: bool newFormat = true ); - //- Construct and return a clone - autoPtr clone() const + //- Return a clone + virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return particle::Clone(*this); } - //- Factory class to read-construct particles used for - // parallel transfer + //- Factory class to read-construct particles (for parallel transfer) class iNew { const polyMesh& mesh_; diff --git a/src/meshTools/PatchFunction1/CodedField/CodedField.C b/src/meshTools/PatchFunction1/CodedField/CodedField.C index 8cea612466..d4a39fa793 100644 --- a/src/meshTools/PatchFunction1/CodedField/CodedField.C +++ b/src/meshTools/PatchFunction1/CodedField/CodedField.C @@ -165,16 +165,6 @@ Foam::PatchFunction1Types::CodedField::CodedField } -template -Foam::PatchFunction1Types::CodedField::CodedField -( - const CodedField& rhs -) -: - CodedField(rhs, rhs.patch()) -{} - - template Foam::PatchFunction1Types::CodedField::CodedField ( @@ -189,6 +179,16 @@ Foam::PatchFunction1Types::CodedField::CodedField {} +template +Foam::PatchFunction1Types::CodedField::CodedField +( + const CodedField& rhs +) +: + CodedField(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/meshTools/PatchFunction1/CodedField/CodedField.H b/src/meshTools/PatchFunction1/CodedField/CodedField.H index 54cf23076e..ba3228d571 100644 --- a/src/meshTools/PatchFunction1/CodedField/CodedField.H +++ b/src/meshTools/PatchFunction1/CodedField/CodedField.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -181,9 +181,6 @@ public: const bool faceValues = true ); - //- Copy construct - explicit CodedField(const CodedField& rhs); - //- Copy construct, setting patch explicit CodedField ( @@ -191,22 +188,19 @@ public: const polyPatch& pp ); - //- Construct and return a clone + //- Copy construct + explicit CodedField(const CodedField& rhs); + + //- Return a clone virtual tmp> clone() const { - return tmp> - ( - new CodedField(*this) - ); + return PatchFunction1::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp> clone(const polyPatch& pp) const { - return tmp> - ( - new CodedField(*this, pp) - ); + return PatchFunction1::Clone(*this, pp); } diff --git a/src/meshTools/PatchFunction1/ConstantField/ConstantField.C b/src/meshTools/PatchFunction1/ConstantField/ConstantField.C index 262fb5d7bf..abf183487a 100644 --- a/src/meshTools/PatchFunction1/ConstantField/ConstantField.C +++ b/src/meshTools/PatchFunction1/ConstantField/ConstantField.C @@ -248,16 +248,6 @@ Foam::PatchFunction1Types::ConstantField::ConstantField {} -template -Foam::PatchFunction1Types::ConstantField::ConstantField -( - const ConstantField& rhs -) -: - ConstantField(rhs, rhs.patch()) -{} - - template Foam::PatchFunction1Types::ConstantField::ConstantField ( @@ -280,6 +270,16 @@ Foam::PatchFunction1Types::ConstantField::ConstantField } +template +Foam::PatchFunction1Types::ConstantField::ConstantField +( + const ConstantField& rhs +) +: + ConstantField(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/meshTools/PatchFunction1/ConstantField/ConstantField.H b/src/meshTools/PatchFunction1/ConstantField/ConstantField.H index 2678975930..9d66bd343c 100644 --- a/src/meshTools/PatchFunction1/ConstantField/ConstantField.H +++ b/src/meshTools/PatchFunction1/ConstantField/ConstantField.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -147,9 +147,6 @@ public: const bool faceValues = true ); - //- Copy construct - explicit ConstantField(const ConstantField& rhs); - //- Copy construct setting patch explicit ConstantField ( @@ -157,19 +154,19 @@ public: const polyPatch& pp ); - //- Construct and return a clone + //- Copy construct + explicit ConstantField(const ConstantField& rhs); + + //- Return a clone virtual tmp> clone() const { - return tmp>(new ConstantField(*this)); + return PatchFunction1::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp> clone(const polyPatch& pp) const { - return tmp> - ( - new ConstantField(*this, pp) - ); + return PatchFunction1::Clone(*this, pp); } diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C index 6d6138017a..98f54c3334 100644 --- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C +++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C @@ -167,16 +167,6 @@ Foam::PatchFunction1Types::MappedFile::MappedFile {} -template -Foam::PatchFunction1Types::MappedFile::MappedFile -( - const MappedFile& rhs -) -: - MappedFile(rhs, rhs.patch()) -{} - - template Foam::PatchFunction1Types::MappedFile::MappedFile ( @@ -214,6 +204,16 @@ Foam::PatchFunction1Types::MappedFile::MappedFile } +template +Foam::PatchFunction1Types::MappedFile::MappedFile +( + const MappedFile& rhs +) +: + MappedFile(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H index 7a87184340..3116b04aba 100644 --- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H +++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -219,9 +219,6 @@ public: const bool faceValues = true ); - //- Copy construct - explicit MappedFile(const MappedFile& rhs); - //- Copy construct setting patch explicit MappedFile ( @@ -229,22 +226,19 @@ public: const polyPatch& pp ); - //- Construct and return a clone + //- Copy construct + explicit MappedFile(const MappedFile& rhs); + + //- Return a clone virtual tmp> clone() const { - return tmp> - ( - new MappedFile(*this) - ); + return PatchFunction1::Clone(*this, this->patch()); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp> clone(const polyPatch& pp) const { - return tmp> - ( - new MappedFile(*this, pp) - ); + return PatchFunction1::Clone(*this, pp); } diff --git a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.C b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.C index 2e6c728f58..f5ce15c8cd 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.C +++ b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.C @@ -58,13 +58,6 @@ Foam::PatchFunction1::PatchFunction1 {} -template -Foam::PatchFunction1::PatchFunction1(const PatchFunction1& rhs) -: - PatchFunction1(rhs, rhs.patch()) -{} - - template Foam::PatchFunction1::PatchFunction1 ( @@ -77,6 +70,13 @@ Foam::PatchFunction1::PatchFunction1 {} +template +Foam::PatchFunction1::PatchFunction1(const PatchFunction1& rhs) +: + PatchFunction1(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.H b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.H index b8e075e5f5..3c97546743 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.H +++ b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -147,9 +147,6 @@ public: const bool faceValues = true ); - //- Copy construct - explicit PatchFunction1(const PatchFunction1& rhs); - //- Copy construct setting patch explicit PatchFunction1 ( @@ -157,6 +154,9 @@ public: const polyPatch& pp ); + //- Copy construct + explicit PatchFunction1(const PatchFunction1& rhs); + //- Return a clone virtual tmp> clone() const = 0; @@ -164,7 +164,24 @@ public: virtual tmp> clone(const polyPatch& pp) const = 0; - // Selectors + // Factory Methods + + //- Clone a PatchFunction1 + template + static tmp> + Clone(const Derived& fun) + { + return tmp>(new Derived(fun)); + } + + //- Clone a PatchFunction1 with a patch + template + static tmp> + Clone(const Derived& fun, const polyPatch& pp) + { + return tmp>(new Derived(fun, pp)); + } + //- Selector static autoPtr> New diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C index aafc6abdc2..7204c9ed67 100644 --- a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C +++ b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C @@ -54,16 +54,6 @@ Foam::PatchFunction1Types::UniformValueField::UniformValueField {} -template -Foam::PatchFunction1Types::UniformValueField::UniformValueField -( - const UniformValueField& rhs -) -: - UniformValueField(rhs, rhs.patch()) -{} - - template Foam::PatchFunction1Types::UniformValueField::UniformValueField ( @@ -81,6 +71,16 @@ Foam::PatchFunction1Types::UniformValueField::UniformValueField } +template +Foam::PatchFunction1Types::UniformValueField::UniformValueField +( + const UniformValueField& rhs +) +: + UniformValueField(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H index 789aa3d70d..01a107c085 100644 --- a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H +++ b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,8 +40,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef PatchFunction1Types_UniformValueField_H -#define PatchFunction1Types_UniformValueField_H +#ifndef Foam_PatchFunction1Types_UniformValueField_H +#define Foam_PatchFunction1Types_UniformValueField_H #include "PatchFunction1.H" #include "Function1.H" @@ -92,9 +92,6 @@ public: const bool faceValues = true ); - //- Copy construct - explicit UniformValueField(const UniformValueField& rhs); - //- Copy construct setting patch explicit UniformValueField ( @@ -102,22 +99,19 @@ public: const polyPatch& pp ); - //- Construct and return a clone + //- Copy construct + explicit UniformValueField(const UniformValueField& rhs); + + //- Return a clone virtual tmp> clone() const { - return tmp> - ( - new UniformValueField(*this) - ); + return PatchFunction1::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp> clone(const polyPatch& pp) const { - return tmp> - ( - new UniformValueField(*this, pp) - ); + return PatchFunction1::Clone(*this, pp); } diff --git a/src/parallel/reconstruct/reconstruct/passivePositionParticle.H b/src/parallel/reconstruct/reconstruct/passivePositionParticle.H index b7cb6bab06..392b109d43 100644 --- a/src/parallel/reconstruct/reconstruct/passivePositionParticle.H +++ b/src/parallel/reconstruct/reconstruct/passivePositionParticle.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,7 +43,6 @@ SourceFiles #include "particle.H" #include "IOstream.H" -#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -131,17 +130,17 @@ public: //- Construct as copy passivePositionParticle(const passivePositionParticle& p) : - particle(p) + particle(p), + location_(p.location_) {} - //- Construct and return a clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr(new passivePositionParticle(*this)); + return particle::Clone(*this); } - //- Factory class to read-construct particles (for parallel transfer) class iNew { diff --git a/src/sampling/functions/Function1/Sample/SampleFunction1.H b/src/sampling/functions/Function1/Sample/SampleFunction1.H index 5500abab7d..513c847352 100644 --- a/src/sampling/functions/Function1/Sample/SampleFunction1.H +++ b/src/sampling/functions/Function1/Sample/SampleFunction1.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,8 +45,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef Function1Types_Sample_H -#define Function1Types_Sample_H +#ifndef Foam_Function1Types_Sample_H +#define Foam_Function1Types_Sample_H #include "Function1.H" #include "point.H" @@ -121,10 +121,10 @@ public: //- Copy constructor explicit Sample(const Sample& poly); - //- Construct and return a clone + //- Return a clone virtual tmp> clone() const { - return tmp>(new Sample(*this)); + return Function1::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/Ar/Ar.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/Ar/Ar.H index de9273f625..3d71c0b79f 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/Ar/Ar.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/Ar/Ar.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary Ar(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C10H22/C10H22.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C10H22/C10H22.H index 164da673a0..0f544d1154 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C10H22/C10H22.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C10H22/C10H22.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C10H22(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C12H26/C12H26.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C12H26/C12H26.H index 45346e3fee..3d91dd881f 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C12H26/C12H26.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C12H26/C12H26.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C12H26(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C13H28/C13H28.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C13H28/C13H28.H index b45b57d019..4b0fab59ef 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C13H28/C13H28.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C13H28/C13H28.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C13H28(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C14H30/C14H30.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C14H30/C14H30.H index a1ad7431a7..0eeb8cc1a1 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C14H30/C14H30.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C14H30/C14H30.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C14H30(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C16H34/C16H34.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C16H34/C16H34.H index 47a1a5e3ea..a8f4bb6a73 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C16H34/C16H34.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C16H34/C16H34.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C16H34(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H5OH/C2H5OH.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H5OH/C2H5OH.H index dc6a2f2477..8d18429160 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H5OH/C2H5OH.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H5OH/C2H5OH.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C2H5OH(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6/C2H6.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6/C2H6.H index 656656cac3..204160cf66 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6/C2H6.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6/C2H6.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C2H6(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6O/C2H6O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6O/C2H6O.H index 9c608556ae..538f4c2c92 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6O/C2H6O.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6O/C2H6O.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C2H6O(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H6O/C3H6O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H6O/C3H6O.H index 61e482f73e..1efc92fd24 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H6O/C3H6O.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H6O/C3H6O.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C3H6O(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H8/C3H8.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H8/C3H8.H index 4222ea2d98..ef9d85e3b5 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H8/C3H8.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H8/C3H8.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C3H8(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C4H10O/C4H10O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C4H10O/C4H10O.H index 83d8fe1d06..ed5e1326da 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C4H10O/C4H10O.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C4H10O/C4H10O.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C4H10O(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H14/C6H14.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H14/C6H14.H index 83b49d09a8..ebe60044dd 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H14/C6H14.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H14/C6H14.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C6H14(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H6/C6H6.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H6/C6H6.H index e67f2e5e08..81be1a18dd 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H6/C6H6.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H6/C6H6.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C6H6(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H16/C7H16.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H16/C7H16.H index 5f713fda2e..27b3485714 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H16/C7H16.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H16/C7H16.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C7H16(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H8/C7H8.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H8/C7H8.H index 51a66c69b5..6dfabef59e 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H8/C7H8.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H8/C7H8.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C7H8(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H10/C8H10.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H10/C8H10.H index 2b337d0a9d..66f2622904 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H10/C8H10.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H10/C8H10.H @@ -113,10 +113,10 @@ public: //- Construct from dictionary C8H10(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H18/C8H18.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H18/C8H18.H index a230087269..6b0446c4ec 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H18/C8H18.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H18/C8H18.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C8H18(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C9H20/C9H20.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C9H20/C9H20.H index 6206617bd8..dc38c2d753 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C9H20/C9H20.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C9H20/C9H20.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary C9H20(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH3OH/CH3OH.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH3OH/CH3OH.H index d9e034f429..c2a8001939 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH3OH/CH3OH.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH3OH/CH3OH.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary CH3OH(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH4N2O/CH4N2O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH4N2O/CH4N2O.H index 628c984522..b6992f5266 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH4N2O/CH4N2O.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH4N2O/CH4N2O.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary CH4N2O(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/H2O/H2O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/H2O/H2O.H index d96d82ff9d..764316c579 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/H2O/H2O.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/H2O/H2O.H @@ -113,10 +113,10 @@ public: //- Construct from dictionary H2O(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IC8H18/IC8H18.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IC8H18/IC8H18.H index d1689a8bfa..e6d492faf3 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IC8H18/IC8H18.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IC8H18/IC8H18.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary IC8H18(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IDEA/IDEA.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IDEA/IDEA.H index c9a5e6b7bf..1f7a6c9de1 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IDEA/IDEA.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IDEA/IDEA.H @@ -136,10 +136,10 @@ public: //- Construct from dictionary IDEA(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/MB/MB.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/MB/MB.H index fbb7fb049a..3ed033af16 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/MB/MB.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/MB/MB.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary MB(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/N2/N2.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/N2/N2.H index d57624c57c..72015b13e5 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/N2/N2.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/N2/N2.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary N2(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/aC10H7CH3/aC10H7CH3.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/aC10H7CH3/aC10H7CH3.H index 6d07dacbe6..fb6c4bed31 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/aC10H7CH3/aC10H7CH3.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/aC10H7CH3/aC10H7CH3.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary aC10H7CH3(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/bC10H7CH3/bC10H7CH3.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/bC10H7CH3/bC10H7CH3.H index 93e4c0db6a..a8a45ecd65 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/bC10H7CH3/bC10H7CH3.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/bC10H7CH3/bC10H7CH3.H @@ -114,10 +114,10 @@ public: //- Construct from dictionary bC10H7CH3(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/iC3H8O/iC3H8O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/iC3H8O/iC3H8O.H index ffbea56735..6144243c72 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/iC3H8O/iC3H8O.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/iC3H8O/iC3H8O.H @@ -112,10 +112,10 @@ public: //- Construct from dictionary iC3H8O(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquid/liquid.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquid/liquid.H index 21b152c36a..fc6f69ea2c 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquid/liquid.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquid/liquid.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef liquid_H -#define liquid_H +#ifndef Foam_liquid_H +#define Foam_liquid_H #include "liquidProperties.H" #include "Function1.H" @@ -90,10 +90,10 @@ public: liquid(const liquid& rhs); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr(new liquid(*this)); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.H index 220f962f75..589865f292 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquidProperties/liquidProperties.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef liquidProperties_H -#define liquidProperties_H +#ifndef Foam_liquidProperties_H +#define Foam_liquidProperties_H #include "thermophysicalProperties.H" @@ -137,7 +137,14 @@ public: virtual autoPtr clone() const = 0; - // Selectors + // Factory Methods + + //- Clone liquidProperties + template + static autoPtr Clone(const Derived& prop) + { + return autoPtr(new Derived(prop)); + } //- Return a pointer to a new liquidProperties created from name static autoPtr New(const word& name); diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/nC3H8O/nC3H8O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/nC3H8O/nC3H8O.H index b5729a0ffa..388375dc72 100644 --- a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/nC3H8O/nC3H8O.H +++ b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/nC3H8O/nC3H8O.H @@ -112,10 +112,10 @@ public: //- Construct from dictionary nC3H8O(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H index 471498121f..5ff8dda5ea 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H @@ -67,10 +67,10 @@ public: //- Construct from dictionary C(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return solidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H index fce234a3f0..b8baf048a3 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H @@ -67,10 +67,10 @@ public: //- Construct from dictionary CaCO3(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return solidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H index 7297af2785..34e759813d 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H @@ -67,10 +67,10 @@ public: //- Construct from dictionary ash(const dictionary& dict); - //- Construct and return clone + //- Return a clone virtual autoPtr clone() const { - return autoPtr::NewFrom(*this); + return solidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H index 3d8729acc3..313f3c37ab 100644 --- a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H +++ b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef solidProperties_H -#define solidProperties_H +#ifndef Foam_solidProperties_H +#define Foam_solidProperties_H #include "typeInfo.H" #include "autoPtr.H" @@ -133,7 +133,14 @@ public: } - // Selectors + // Factory Methods + + //- Clone solidProperties + template + static autoPtr Clone(const Derived& prop) + { + return autoPtr(new Derived(prop)); + } //- Return a pointer to a new solidProperties created from name static autoPtr New(const word& name);