From 987dbe45897dba1da7a5297de8f756b3a9e954c4 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 8 Jan 2024 11:30:58 +0100 Subject: [PATCH] ENH: use factory Clone method for handling member clone() methods - reduces code clutter, simplifies modification for new types. Handled classes: Function1, PatchFunction1, coordinateRotation, coordinateSystem, particle, liquidProperties, solidProperties --- .../laserDTRM/DTRMParticle/DTRMParticle.H | 10 +++++-- .../redistributePar/passivePositionParticle.H | 6 ++-- .../dynamicCode/codedFunction1Template.H | 9 ++---- .../dynamicCode/codedPatchFunction1Template.H | 28 ++++++++----------- .../Function1/Function1Expression.H | 10 +++---- .../rotation/EulerCoordinateRotation.H | 6 ++-- .../rotation/STARCDCoordinateRotation.H | 6 ++-- .../coordinate/rotation/axesRotation.H | 6 ++-- .../coordinate/rotation/axisAngleRotation.H | 6 ++-- .../coordinate/rotation/coordinateRotation.H | 13 +++++++-- .../coordinate/rotation/cylindricalRotation.H | 6 ++-- .../coordinate/rotation/identityRotation.H | 6 ++-- .../coordinate/rotation/specifiedRotation.H | 6 ++-- .../coordinate/systems/cartesianCS.H | 4 +-- .../coordinate/systems/coordinateSystem.H | 23 +++++++++++++-- .../coordinate/systems/cylindricalCS.H | 4 +-- .../coordinate/systems/indirectCS.H | 4 +-- .../primitives/functions/Function1/CSV/CSV.H | 6 ++-- .../Function1/Coded/CodedFunction1.H | 10 +++---- .../functions/Function1/Constant/Constant.H | 10 +++---- .../functions/Function1/Cosine/Cosine.H | 10 +++---- .../functions/Function1/Function1/Function1.C | 11 -------- .../functions/Function1/Function1/Function1.H | 20 +++++++++---- .../Function1/Function1/Function1Fwd.H | 4 +-- .../FunctionObjectTrigger.H | 11 ++++---- .../FunctionObjectValue/FunctionObjectValue.H | 10 +++---- .../InputValueMapper/InputValueMapper.H | 10 +++---- .../functions/Function1/None/NoneFunction1.H | 6 ++-- .../functions/Function1/One/OneConstant.H | 10 +++---- .../Function1/Polynomial/PolynomialEntry.H | 10 +++---- .../functions/Function1/Scale/Scale.H | 10 +++---- .../functions/Function1/Sine/Sine.H | 10 +++---- .../functions/Function1/Square/Square.H | 10 +++---- .../functions/Function1/Table/Table.H | 10 +++---- .../functions/Function1/TableFile/TableFile.H | 10 +++---- .../functions/Function1/Uniform/Uniform.H | 10 +++---- .../functions/Function1/Zero/ZeroConstant.H | 10 +++---- .../PatchFunction1/PatchFunction1Expression.C | 16 +++++------ .../PatchFunction1/PatchFunction1Expression.H | 22 ++++++--------- .../derived/mappedField/Sampled/Sampled.C | 20 ++++++------- .../derived/mappedField/Sampled/Sampled.H | 22 ++++++--------- .../field/nearWallFields/findCellParticle.H | 11 ++++---- .../field/streamLine/streamLineParticle.H | 8 +++--- .../wallBoundedParticle.H | 12 ++++---- .../wallBoundedStreamLineParticle.H | 10 +++---- .../parcels/Templates/DSMCParcel/DSMCParcel.H | 10 +++---- .../basic/indexedParticle/indexedParticle.H | 10 +++---- .../basic/injectedParticle/injectedParticle.H | 17 ++++------- src/lagrangian/basic/particle/particle.C | 18 +++--------- src/lagrangian/basic/particle/particle.H | 25 ++++++++++++++--- .../basic/passiveParticle/passiveParticle.H | 7 ++--- .../CollidingParcel/CollidingParcel.H | 13 ++++----- .../KinematicParcel/KinematicParcel.H | 14 ++++------ .../Templates/MPPICParcel/MPPICParcel.H | 13 ++++----- .../ReactingHeterogeneousParcel.H | 16 ++++------- .../ReactingMultiphaseParcel.H | 13 ++++----- .../Templates/ReactingParcel/ReactingParcel.H | 16 ++++------- .../Templates/ThermoParcel/ThermoParcel.H | 13 ++++----- .../molecule/molecule/molecule.H | 12 ++++---- src/lagrangian/solidParticle/solidParticle.H | 7 ++--- .../Templates/SprayParcel/SprayParcel.H | 16 ++++------- .../trackedParticle/trackedParticle.H | 12 ++++---- .../PatchFunction1/CodedField/CodedField.C | 16 +++++------ .../PatchFunction1/CodedField/CodedField.H | 22 ++++++--------- .../ConstantField/ConstantField.C | 20 ++++++------- .../ConstantField/ConstantField.H | 19 ++++++------- .../PatchFunction1/MappedFile/MappedFile.C | 20 ++++++------- .../PatchFunction1/MappedFile/MappedFile.H | 22 ++++++--------- .../PatchFunction1/PatchFunction1.C | 14 +++++----- .../PatchFunction1/PatchFunction1.H | 27 ++++++++++++++---- .../UniformValueField/UniformValueField.C | 20 ++++++------- .../UniformValueField/UniformValueField.H | 26 +++++++---------- .../reconstruct/passivePositionParticle.H | 11 ++++---- .../Function1/Sample/SampleFunction1.H | 10 +++---- .../liquidProperties/Ar/Ar.H | 4 +-- .../liquidProperties/C10H22/C10H22.H | 4 +-- .../liquidProperties/C12H26/C12H26.H | 4 +-- .../liquidProperties/C13H28/C13H28.H | 4 +-- .../liquidProperties/C14H30/C14H30.H | 4 +-- .../liquidProperties/C16H34/C16H34.H | 4 +-- .../liquidProperties/C2H5OH/C2H5OH.H | 4 +-- .../liquidProperties/C2H6/C2H6.H | 4 +-- .../liquidProperties/C2H6O/C2H6O.H | 4 +-- .../liquidProperties/C3H6O/C3H6O.H | 4 +-- .../liquidProperties/C3H8/C3H8.H | 4 +-- .../liquidProperties/C4H10O/C4H10O.H | 4 +-- .../liquidProperties/C6H14/C6H14.H | 4 +-- .../liquidProperties/C6H6/C6H6.H | 4 +-- .../liquidProperties/C7H16/C7H16.H | 4 +-- .../liquidProperties/C7H8/C7H8.H | 4 +-- .../liquidProperties/C8H10/C8H10.H | 4 +-- .../liquidProperties/C8H18/C8H18.H | 4 +-- .../liquidProperties/C9H20/C9H20.H | 4 +-- .../liquidProperties/CH3OH/CH3OH.H | 4 +-- .../liquidProperties/CH4N2O/CH4N2O.H | 4 +-- .../liquidProperties/H2O/H2O.H | 4 +-- .../liquidProperties/IC8H18/IC8H18.H | 4 +-- .../liquidProperties/IDEA/IDEA.H | 4 +-- .../liquidProperties/MB/MB.H | 4 +-- .../liquidProperties/N2/N2.H | 4 +-- .../liquidProperties/aC10H7CH3/aC10H7CH3.H | 4 +-- .../liquidProperties/bC10H7CH3/bC10H7CH3.H | 4 +-- .../liquidProperties/iC3H8O/iC3H8O.H | 4 +-- .../liquidProperties/liquid/liquid.H | 8 +++--- .../liquidProperties/liquidProperties.H | 15 +++++++--- .../liquidProperties/nC3H8O/nC3H8O.H | 4 +-- .../solidProperties/C/C.H | 4 +-- .../solidProperties/CaCO3/CaCO3.H | 4 +-- .../solidProperties/ash/ash.H | 4 +-- .../solidProperties/solidProperties.H | 15 +++++++--- 110 files changed, 537 insertions(+), 564 deletions(-) diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/DTRMParticle/DTRMParticle.H b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/DTRMParticle/DTRMParticle.H index 5ad00275d59..47c381aa8ca 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<particle> 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 394f64e4909..89821165c37 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<particle> clone() const { - return autoPtr<particle>(new passivePositionParticle(*this)); + return particle::Clone(*this); } diff --git a/etc/codeTemplates/dynamicCode/codedFunction1Template.H b/etc/codeTemplates/dynamicCode/codedFunction1Template.H index 3b2de974a93..d54e4a350cc 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<Function1<${TemplateType}>> clone() const { - return tmp<Function1<${TemplateType}>> - ( - 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 c67d1600127..16b38abecc9 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<PatchFunction1<${TemplateType}>> clone() const { - return tmp<PatchFunction1<${TemplateType}>> - ( - 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<PatchFunction1<${TemplateType}>> clone ( const polyPatch& pp ) const { - return tmp<PatchFunction1<${TemplateType}>> - ( - 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 69ecf324246..25917790883 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Function1Expression<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/EulerCoordinateRotation.H index f5053531540..5dfaf1e9df1 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<coordinateRotation> clone() const { - return - autoPtr<coordinateRotation>::NewFrom - <coordinateRotations::euler>(*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/STARCDCoordinateRotation.H index 057c6f699b1..d6f4bed516d 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<coordinateRotation> clone() const { - return - autoPtr<coordinateRotation>::NewFrom - <coordinateRotations::starcd>(*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/axesRotation.H index cd693981a78..775f9bb0068 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<coordinateRotation> clone() const { - return - autoPtr<coordinateRotation>::NewFrom - <coordinateRotations::axes>(*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/axisAngleRotation.H index 0914d4b1c23..5ff65b483ee 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<coordinateRotation> clone() const { - return - autoPtr<coordinateRotation>::NewFrom - <coordinateRotations::axisAngle>(*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/coordinateRotation.H index 32c5e81493a..6a2ccd37241 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<coordinateRotation> clone() const = 0; - // Selectors + // Factory Methods + + //- Clone a coordinate rotation + template<class Derived> + static autoPtr<coordinateRotation> Clone(const Derived& crot) + { + return autoPtr<coordinateRotation>(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 59a1acd0fb2..ca9c1d987b6 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<coordinateRotation> clone() const { - return - autoPtr<coordinateRotation>::NewFrom - <coordinateRotations::cylindrical>(*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/identityRotation.H index 80fe1efec67..ede44c3c287 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<coordinateRotation> clone() const { - return - autoPtr<coordinateRotation>::NewFrom - <coordinateRotations::identity>(*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H b/src/OpenFOAM/primitives/coordinate/rotation/specifiedRotation.H index 6d41c8ce554..f2f0971f0c0 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<coordinateRotation> clone() const { - return - autoPtr<coordinateRotation>::NewFrom - <coordinateRotations::specified>(*this); + return coordinateRotation::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/systems/cartesianCS.H b/src/OpenFOAM/primitives/coordinate/systems/cartesianCS.H index 111db8100e0..4b8c95429aa 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<coordinateSystem> clone() const { - return autoPtr<coordinateSystem>::NewFrom<cartesian>(*this); + return coordinateSystem::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H b/src/OpenFOAM/primitives/coordinate/systems/coordinateSystem.H index 7703525b1a5..d835ddeaad5 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<class Derived> + static autoPtr<coordinateSystem> Clone(const Derived& csys) + { + return autoPtr<coordinateSystem>(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<coordinateSystem> 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 47d39e5fa58..a6a08e7a19d 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<coordinateSystem> clone() const { - return autoPtr<coordinateSystem>::NewFrom<cylindrical>(*this); + return coordinateSystem::Clone(*this); } diff --git a/src/OpenFOAM/primitives/coordinate/systems/indirectCS.H b/src/OpenFOAM/primitives/coordinate/systems/indirectCS.H index 26565d46f23..bf40e9a6a28 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<coordinateSystem> clone() const { - return autoPtr<coordinateSystem>::NewFrom<indirect>(*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 486744c04f3..bb7341047cf 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<Type>& csv); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new CSV<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H index ed8dbfe01e4..3884d5caa59 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new CodedFunction1<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H index 3ddc1ed6709..84072468b22 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Constant<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H b/src/OpenFOAM/primitives/functions/Function1/Cosine/Cosine.H index 5c00ed1a2ca..6342c5066a8 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<Type>(rhs) {} - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Cosine<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C index cfcde228014..27fc4e66049 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<Function1Type>::FieldFunction1 {} -template<class Function1Type> -Foam::tmp<Foam::Function1<typename Function1Type::returnType>> -Foam::FieldFunction1<Function1Type>::clone() const -{ - return tmp<Function1<Type>> - ( - new FieldFunction1<Function1Type>(*this) - ); -} - - template<class Function1Type> Foam::tmp<Foam::Field<typename Function1Type::returnType>> Foam::FieldFunction1<Function1Type>::integrate diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H index fa64f4f0cd9..107a857b0b8 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const = 0; - // Selectors + // Factory Methods + + //- Clone a Function1 + template<class Derived> + static tmp<Function1<Type>> Clone(const Derived& fun) + { + return tmp<Function1<Type>>(new Derived(fun)); + } //- Selector, with fallback redirection static autoPtr<Function1<Type>> New @@ -321,8 +328,11 @@ public: const objectRegistry* obrPtr = nullptr ); - //- Construct and return a clone - virtual tmp<Function1<Type>> clone() const; + //- Return a clone + virtual tmp<Function1<Type>> clone() const + { + return Function1<Type>::Clone(*this); + } //- Destructor diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1Fwd.H index b3ac5b73373..c8f0053ec5e 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 9e2d876bf5f..4bc989a8402 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<Type> { - // Private Data //- Trigger indices when it is considered active @@ -124,10 +123,10 @@ public: //- Copy construct explicit FunctionObjectTrigger(const FunctionObjectTrigger<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new FunctionObjectTrigger<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/FunctionObjectValue/FunctionObjectValue.H b/src/OpenFOAM/primitives/functions/Function1/FunctionObjectValue/FunctionObjectValue.H index 03f00ade901..c2e7f7919c9 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new FunctionObjectValue<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/InputValueMapper/InputValueMapper.H b/src/OpenFOAM/primitives/functions/Function1/InputValueMapper/InputValueMapper.H index c7edfc49fe7..a59a89ae638 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new InputValueMapper<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/None/NoneFunction1.H b/src/OpenFOAM/primitives/functions/Function1/None/NoneFunction1.H index 2faa535cfb6..c3b67156fbc 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<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new None<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H index 84d496afb23..8dc2bff57b6 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<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new OneConstant<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H b/src/OpenFOAM/primitives/functions/Function1/Polynomial/PolynomialEntry.H index bf165ed22d2..61a5ba4daa5 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<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Polynomial<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H index fe3c7ff0a68..7df092c4ba3 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Scale<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H index 58f255cba37..db86c65986e 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Sine<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H index 0aa61cf6c51..01d1aa4a04b 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<Type>& rhs); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Square<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H index c9832de5c0b..cdb2b4f5ca5 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<Type>& tbl); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Table<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H b/src/OpenFOAM/primitives/functions/Function1/TableFile/TableFile.H index 9cd1319d6d3..c622c8653cc 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<Type>& tbl); - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new TableFile<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H index 1b17a7a355f..22919c77ff1 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<Type>(entryName, dict, obrPtr) {} - //- Construct and return a clone + //- Return a clone virtual tmp<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Uniform<Type>(*this)); + return Function1<Type>::Clone(*this); } }; diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H index 3437ffc4a1a..b457844b1bd 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<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new ZeroConstant<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C index a342dc4b57c..554e74e8a38 100644 --- a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C +++ b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.C @@ -65,24 +65,24 @@ Foam::PatchFunction1Types::PatchExprField<Type>::PatchExprField template<class Type> Foam::PatchFunction1Types::PatchExprField<Type>::PatchExprField ( - const PatchExprField<Type>& rhs + const PatchExprField<Type>& rhs, + const polyPatch& pp ) : - PatchExprField<Type>(rhs, rhs.patch()) + PatchFunction1<Type>(rhs, pp), + dict_(rhs.dict_), // Deep copy + valueExpr_(rhs.valueExpr_), + driver_(fvPatch::lookupPatch(this->patch()), rhs.driver_, dict_) {} template<class Type> Foam::PatchFunction1Types::PatchExprField<Type>::PatchExprField ( - const PatchExprField<Type>& rhs, - const polyPatch& pp + const PatchExprField<Type>& rhs ) : - PatchFunction1<Type>(rhs, pp), - dict_(rhs.dict_), // Deep copy - valueExpr_(rhs.valueExpr_), - driver_(fvPatch::lookupPatch(this->patch()), rhs.driver_, dict_) + PatchExprField<Type>(rhs, rhs.patch()) {} diff --git a/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H b/src/finiteVolume/expressions/PatchFunction1/PatchFunction1Expression.H index 4a66dbc6698..ac3620918c3 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<Type>& 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<Type>& rhs); + + //- Return a clone virtual tmp<PatchFunction1<Type>> clone() const { - return tmp<PatchFunction1<Type>> - ( - new PatchExprField<Type>(*this) - ); + return PatchFunction1<Type>::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const { - return tmp<PatchFunction1<Type>> - ( - new PatchExprField<Type>(*this, pp) - ); + return PatchFunction1<Type>::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 45601fe2365..7cc3c3048de 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<Type>::Sampled } -template<class Type> -Foam::PatchFunction1Types::Sampled<Type>::Sampled -( - const Sampled<Type>& rhs -) -: - Sampled<Type>(rhs, rhs.patch()) -{} - - template<class Type> Foam::PatchFunction1Types::Sampled<Type>::Sampled ( @@ -99,6 +89,16 @@ Foam::PatchFunction1Types::Sampled<Type>::Sampled {} +template<class Type> +Foam::PatchFunction1Types::Sampled<Type>::Sampled +( + const Sampled<Type>& rhs +) +: + Sampled<Type>(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H index a92ae7fd7a5..7a64493489a 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<Type>& 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<Type>& rhs); + + //- Return a clone virtual tmp<PatchFunction1<Type>> clone() const { - return tmp<PatchFunction1<Type>> - ( - new Sampled<Type>(*this) - ); + return PatchFunction1<Type>::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const { - return tmp<PatchFunction1<Type>> - ( - new Sampled<Type>(*this, pp) - ); + return PatchFunction1<Type>::Clone(*this, pp); } diff --git a/src/functionObjects/field/nearWallFields/findCellParticle.H b/src/functionObjects/field/nearWallFields/findCellParticle.H index c4238a66bae..3c120921356 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<particle> clone() const + //- Return a clone + virtual autoPtr<particle> clone() const { - return autoPtr<particle>(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 9f8045f00bf..53cec863832 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<particle> clone() const + //- Return a clone + virtual autoPtr<particle> clone() const { - return autoPtr<particle>(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 9a49d00b16a..451b83a0ba0 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<particle> clone() const + //- Return a clone + virtual autoPtr<particle> clone() const { - return autoPtr<particle>(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 a40535ee15c..d2f4548448f 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<particle> clone() const { - return autoPtr<particle>(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 d2946bc2adf..a4982401490 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<particle> clone() const { - return autoPtr<particle>(new DSMCParcel<ParcelType>(*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 e08f525de66..66103eea8f9 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<particle> clone() const { - return autoPtr<particle>(new indexedParticle(*this)); + return particle::Clone(*this); } diff --git a/src/lagrangian/basic/injectedParticle/injectedParticle.H b/src/lagrangian/basic/injectedParticle/injectedParticle.H index 294108a7f34..124fcf67f67 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<particle> clone() const { - return autoPtr<particle>(new injectedParticle(*this)); + return particle::Clone(*this); } //- Construct and return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle>(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<injectedParticle> operator()(Istream& is) const { - return autoPtr<injectedParticle> - ( - new injectedParticle(mesh_, is, true) - ); + return autoPtr<injectedParticle>::New(mesh_, is, true); } }; diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index 2ddea84408d..2939c3a6f39 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -599,9 +599,9 @@ Foam::particle::particle } -Foam::particle::particle(const particle& p) +Foam::particle::particle(const particle& p, const polyMesh& mesh) : - mesh_(p.mesh_), + mesh_(mesh), coordinates_(p.coordinates_), celli_(p.celli_), tetFacei_(p.tetFacei_), @@ -615,19 +615,9 @@ Foam::particle::particle(const particle& p) {} -Foam::particle::particle(const particle& p, const polyMesh& mesh) +Foam::particle::particle(const particle& p) : - mesh_(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_) + particle(p, p.mesh()) {} diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 10e282e12ae..97702a4ee62 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<particle> clone() const { return autoPtr<particle>::New(*this); } + + // Factory Methods + + //- Clone a particle + template<class Derived> + static autoPtr<particle> Clone(const Derived& p) + { + return autoPtr<particle>(new Derived(p)); + } + + //- Clone a particle with a mesh reference + template<class Derived> + static autoPtr<particle> Clone(const Derived& p, const polyMesh& mesh) + { + return autoPtr<particle>(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 46593237ece..13c1f180245 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<particle> clone() const { - return autoPtr<particle>(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 7741b6195f7..ee46e5e4e5b 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<particle> clone() const { - return autoPtr<particle>(new CollidingParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle>(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 14efa73daf2..d8362c1ba0e 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<particle> clone() const { - return autoPtr<particle>(new KinematicParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle>(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 59cc4044fce..e62261d6d2c 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<particle> clone() const { - return autoPtr<particle>(new MPPICParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle>(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 120cfcd4abb..fc589fac933 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<particle> clone() const { - return autoPtr<particle>(new ReactingHeterogeneousParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle> - ( - 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 757dc1bc5db..a2dd7c434e0 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<particle> clone() const { - return autoPtr<particle>(new ReactingMultiphaseParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle>(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 4491c506cc0..a2975634172 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<particle> clone() const { - return autoPtr<particle>(new ReactingParcel<ParcelType>(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle> - ( - new ReactingParcel<ParcelType>(*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 dbbf70ffad0..d22c06958aa 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<particle> clone() const { - return autoPtr<particle>(new ThermoParcel(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle>(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 e11827c5c03..26dd41c15b4 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<particle> clone() const + //- Return a clone + virtual autoPtr<particle> clone() const { - return autoPtr<particle>(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 b82f7bc7e02..4f9375b91f3 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<particle> clone() const { - return autoPtr<particle>(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 f77c4b2955a..eb47be3b227 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<particle> clone() const { - return autoPtr<particle>(new SprayParcel<ParcelType>(*this)); + return particle::Clone(*this); } - //- Construct and return a (basic particle) clone + //- Return a (basic particle) clone virtual autoPtr<particle> clone(const polyMesh& mesh) const { - return autoPtr<particle> - ( - new SprayParcel<ParcelType>(*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 a4ae212678a..ce831e5238a 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<particle> clone() const + //- Return a clone + virtual autoPtr<particle> clone() const { - return autoPtr<particle>::NewFrom<trackedParticle>(*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 8cea612466b..d4a39fa793c 100644 --- a/src/meshTools/PatchFunction1/CodedField/CodedField.C +++ b/src/meshTools/PatchFunction1/CodedField/CodedField.C @@ -168,24 +168,24 @@ Foam::PatchFunction1Types::CodedField<Type>::CodedField template<class Type> Foam::PatchFunction1Types::CodedField<Type>::CodedField ( - const CodedField<Type>& rhs + const CodedField<Type>& rhs, + const polyPatch& pp ) : - CodedField<Type>(rhs, rhs.patch()) + PatchFunction1<Type>(rhs, pp), + codedBase(), + dict_(rhs.dict_), + redirectName_(rhs.redirectName_) {} template<class Type> Foam::PatchFunction1Types::CodedField<Type>::CodedField ( - const CodedField<Type>& rhs, - const polyPatch& pp + const CodedField<Type>& rhs ) : - PatchFunction1<Type>(rhs, pp), - codedBase(), - dict_(rhs.dict_), - redirectName_(rhs.redirectName_) + CodedField<Type>(rhs, rhs.patch()) {} diff --git a/src/meshTools/PatchFunction1/CodedField/CodedField.H b/src/meshTools/PatchFunction1/CodedField/CodedField.H index 54cf23076e1..ba3228d5711 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<Type>& 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<Type>& rhs); + + //- Return a clone virtual tmp<PatchFunction1<Type>> clone() const { - return tmp<PatchFunction1<Type>> - ( - new CodedField<Type>(*this) - ); + return PatchFunction1<Type>::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const { - return tmp<PatchFunction1<Type>> - ( - new CodedField<Type>(*this, pp) - ); + return PatchFunction1<Type>::Clone(*this, pp); } diff --git a/src/meshTools/PatchFunction1/ConstantField/ConstantField.C b/src/meshTools/PatchFunction1/ConstantField/ConstantField.C index 262fb5d7bf8..abf183487ac 100644 --- a/src/meshTools/PatchFunction1/ConstantField/ConstantField.C +++ b/src/meshTools/PatchFunction1/ConstantField/ConstantField.C @@ -248,16 +248,6 @@ Foam::PatchFunction1Types::ConstantField<Type>::ConstantField {} -template<class Type> -Foam::PatchFunction1Types::ConstantField<Type>::ConstantField -( - const ConstantField<Type>& rhs -) -: - ConstantField<Type>(rhs, rhs.patch()) -{} - - template<class Type> Foam::PatchFunction1Types::ConstantField<Type>::ConstantField ( @@ -280,6 +270,16 @@ Foam::PatchFunction1Types::ConstantField<Type>::ConstantField } +template<class Type> +Foam::PatchFunction1Types::ConstantField<Type>::ConstantField +( + const ConstantField<Type>& rhs +) +: + ConstantField<Type>(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/meshTools/PatchFunction1/ConstantField/ConstantField.H b/src/meshTools/PatchFunction1/ConstantField/ConstantField.H index 26789759306..9d66bd343c4 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<Type>& 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<Type>& rhs); + + //- Return a clone virtual tmp<PatchFunction1<Type>> clone() const { - return tmp<PatchFunction1<Type>>(new ConstantField<Type>(*this)); + return PatchFunction1<Type>::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const { - return tmp<PatchFunction1<Type>> - ( - new ConstantField<Type>(*this, pp) - ); + return PatchFunction1<Type>::Clone(*this, pp); } diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C index 6d6138017aa..98f54c33342 100644 --- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C +++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C @@ -167,16 +167,6 @@ Foam::PatchFunction1Types::MappedFile<Type>::MappedFile {} -template<class Type> -Foam::PatchFunction1Types::MappedFile<Type>::MappedFile -( - const MappedFile<Type>& rhs -) -: - MappedFile<Type>(rhs, rhs.patch()) -{} - - template<class Type> Foam::PatchFunction1Types::MappedFile<Type>::MappedFile ( @@ -214,6 +204,16 @@ Foam::PatchFunction1Types::MappedFile<Type>::MappedFile } +template<class Type> +Foam::PatchFunction1Types::MappedFile<Type>::MappedFile +( + const MappedFile<Type>& rhs +) +: + MappedFile<Type>(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H index 7a871843404..3116b04abab 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<Type>& 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<Type>& rhs); + + //- Return a clone virtual tmp<PatchFunction1<Type>> clone() const { - return tmp<PatchFunction1<Type>> - ( - new MappedFile<Type>(*this) - ); + return PatchFunction1<Type>::Clone(*this, this->patch()); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const { - return tmp<PatchFunction1<Type>> - ( - new MappedFile<Type>(*this, pp) - ); + return PatchFunction1<Type>::Clone(*this, pp); } diff --git a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.C b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.C index 2e6c728f588..f5ce15c8cdb 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.C +++ b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.C @@ -58,13 +58,6 @@ Foam::PatchFunction1<Type>::PatchFunction1 {} -template<class Type> -Foam::PatchFunction1<Type>::PatchFunction1(const PatchFunction1<Type>& rhs) -: - PatchFunction1<Type>(rhs, rhs.patch()) -{} - - template<class Type> Foam::PatchFunction1<Type>::PatchFunction1 ( @@ -77,6 +70,13 @@ Foam::PatchFunction1<Type>::PatchFunction1 {} +template<class Type> +Foam::PatchFunction1<Type>::PatchFunction1(const PatchFunction1<Type>& rhs) +: + PatchFunction1<Type>(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.H b/src/meshTools/PatchFunction1/PatchFunction1/PatchFunction1.H index b8e075e5f59..3c975467433 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<Type>& rhs); - //- Copy construct setting patch explicit PatchFunction1 ( @@ -157,6 +154,9 @@ public: const polyPatch& pp ); + //- Copy construct + explicit PatchFunction1(const PatchFunction1<Type>& rhs); + //- Return a clone virtual tmp<PatchFunction1<Type>> clone() const = 0; @@ -164,7 +164,24 @@ public: virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const = 0; - // Selectors + // Factory Methods + + //- Clone a PatchFunction1 + template<class Derived> + static tmp<PatchFunction1<Type>> + Clone(const Derived& fun) + { + return tmp<PatchFunction1<Type>>(new Derived(fun)); + } + + //- Clone a PatchFunction1 with a patch + template<class Derived> + static tmp<PatchFunction1<Type>> + Clone(const Derived& fun, const polyPatch& pp) + { + return tmp<PatchFunction1<Type>>(new Derived(fun, pp)); + } + //- Selector static autoPtr<PatchFunction1<Type>> New diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C index aafc6abdc2e..7204c9ed67b 100644 --- a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C +++ b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.C @@ -54,16 +54,6 @@ Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField {} -template<class Type> -Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField -( - const UniformValueField<Type>& rhs -) -: - UniformValueField<Type>(rhs, rhs.patch()) -{} - - template<class Type> Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField ( @@ -81,6 +71,16 @@ Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField } +template<class Type> +Foam::PatchFunction1Types::UniformValueField<Type>::UniformValueField +( + const UniformValueField<Type>& rhs +) +: + UniformValueField<Type>(rhs, rhs.patch()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H index 789aa3d70da..01a107c0852 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<Type>& 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<Type>& rhs); + + //- Return a clone virtual tmp<PatchFunction1<Type>> clone() const { - return tmp<PatchFunction1<Type>> - ( - new UniformValueField<Type>(*this) - ); + return PatchFunction1<Type>::Clone(*this); } - //- Construct and return a clone setting patch + //- Return a clone, setting the patch virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const { - return tmp<PatchFunction1<Type>> - ( - new UniformValueField<Type>(*this, pp) - ); + return PatchFunction1<Type>::Clone(*this, pp); } diff --git a/src/parallel/reconstruct/reconstruct/passivePositionParticle.H b/src/parallel/reconstruct/reconstruct/passivePositionParticle.H index b7cb6bab060..392b109d432 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<particle> clone() const { - return autoPtr<particle>(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 5500abab7df..513c847352d 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<Function1<Type>> clone() const { - return tmp<Function1<Type>>(new Sample<Type>(*this)); + return Function1<Type>::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/Ar/Ar.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/Ar/Ar.H index de9273f6256..3d71c0b79fb 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<Ar>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C10H22/C10H22.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C10H22/C10H22.H index 164da673a03..0f544d11549 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C10H22>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C12H26/C12H26.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C12H26/C12H26.H index 45346e3feeb..3d91dd881fb 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C12H26>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C13H28/C13H28.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C13H28/C13H28.H index b45b57d0192..4b0fab59ef8 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C13H28>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C14H30/C14H30.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C14H30/C14H30.H index a1ad7431a7a..0eeb8cc1a18 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C14H30>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C16H34/C16H34.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C16H34/C16H34.H index 47a1a5e3eab..a8f4bb6a735 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C16H34>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H5OH/C2H5OH.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H5OH/C2H5OH.H index dc6a2f2477e..8d184291608 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C2H5OH>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6/C2H6.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6/C2H6.H index 656656cac38..204160cf66f 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C2H6>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6O/C2H6O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C2H6O/C2H6O.H index 9c608556aef..538f4c2c92f 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C2H6O>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H6O/C3H6O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H6O/C3H6O.H index 61e482f73e0..1efc92fd242 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C3H6O>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H8/C3H8.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C3H8/C3H8.H index 4222ea2d98d..ef9d85e3b57 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C3H8>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C4H10O/C4H10O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C4H10O/C4H10O.H index 83d8fe1d06d..ed5e1326da7 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C4H10O>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H14/C6H14.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H14/C6H14.H index 83b49d09a81..ebe60044dd4 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C6H14>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H6/C6H6.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C6H6/C6H6.H index e67f2e5e081..81be1a18dde 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C6H6>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H16/C7H16.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H16/C7H16.H index 5f713fda2ec..27b3485714f 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C7H16>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H8/C7H8.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C7H8/C7H8.H index 51a66c69b51..6dfabef59ec 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C7H8>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H10/C8H10.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H10/C8H10.H index 2b337d0a9df..66f26229043 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C8H10>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H18/C8H18.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C8H18/C8H18.H index a2300872696..6b0446c4ec2 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C8H18>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C9H20/C9H20.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/C9H20/C9H20.H index 6206617bd8a..dc38c2d753f 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<C9H20>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH3OH/CH3OH.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH3OH/CH3OH.H index d9e034f4297..c2a8001939e 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<CH3OH>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH4N2O/CH4N2O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/CH4N2O/CH4N2O.H index 628c9845226..b6992f52660 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<CH4N2O>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/H2O/H2O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/H2O/H2O.H index d96d82ff9de..764316c5795 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<H2O>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IC8H18/IC8H18.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IC8H18/IC8H18.H index d1689a8bfa6..e6d492faf3f 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<IC8H18>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IDEA/IDEA.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/IDEA/IDEA.H index c9a5e6b7bff..1f7a6c9de12 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<IDEA>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/MB/MB.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/MB/MB.H index fbb7fb049a3..3ed033af167 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<MB>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/N2/N2.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/N2/N2.H index d57624c57cf..72015b13e55 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<N2>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/aC10H7CH3/aC10H7CH3.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/aC10H7CH3/aC10H7CH3.H index 6d07dacbe6a..fb6c4bed313 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<aC10H7CH3>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/bC10H7CH3/bC10H7CH3.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/bC10H7CH3/bC10H7CH3.H index 93e4c0db6a7..a8a45ecd650 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<bC10H7CH3>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/iC3H8O/iC3H8O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/iC3H8O/iC3H8O.H index ffbea567359..6144243c726 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<iC3H8O>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquid/liquid.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/liquid/liquid.H index 21b152c36aa..fc6f69ea2c3 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>(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 220f962f753..589865f2922 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<liquidProperties> clone() const = 0; - // Selectors + // Factory Methods + + //- Clone liquidProperties + template<class Derived> + static autoPtr<liquidProperties> Clone(const Derived& prop) + { + return autoPtr<liquidProperties>(new Derived(prop)); + } //- Return a pointer to a new liquidProperties created from name static autoPtr<liquidProperties> New(const word& name); diff --git a/src/thermophysicalModels/thermophysicalProperties/liquidProperties/nC3H8O/nC3H8O.H b/src/thermophysicalModels/thermophysicalProperties/liquidProperties/nC3H8O/nC3H8O.H index b5729a0ffa0..388375dc725 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<liquidProperties> clone() const { - return autoPtr<liquidProperties>::NewFrom<nC3H8O>(*this); + return liquidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/C/C.H index 471498121fc..5ff8dda5ea0 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<solidProperties> clone() const { - return autoPtr<solidProperties>::NewFrom<C>(*this); + return solidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/CaCO3/CaCO3.H index fce234a3f0a..b8baf048a39 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<solidProperties> clone() const { - return autoPtr<solidProperties>::NewFrom<CaCO3>(*this); + return solidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/ash/ash.H index 7297af2785b..34e759813dc 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<solidProperties> clone() const { - return autoPtr<solidProperties>::NewFrom<ash>(*this); + return solidProperties::Clone(*this); } diff --git a/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H b/src/thermophysicalModels/thermophysicalProperties/solidProperties/solidProperties/solidProperties.H index 3d8729acc36..313f3c37ab1 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<class Derived> + static autoPtr<solidProperties> Clone(const Derived& prop) + { + return autoPtr<solidProperties>(new Derived(prop)); + } //- Return a pointer to a new solidProperties created from name static autoPtr<solidProperties> New(const word& name); -- GitLab