diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C index 81b415b7c3..fad6981021 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C @@ -585,6 +585,7 @@ COMPUTED_ASSIGNMENT(scalar, /=) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "DimensionedFieldIO.C" +#include "DimensionedFieldNew.C" #include "DimensionedFieldFunctions.C" // ************************************************************************* // diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H index 52c3ffd345..f521f7b42b 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2021 OpenCFD Ltd. + Copyright (C) 2015-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,7 +129,7 @@ public: // Constructors - //- Construct from components + //- Construct from components, copy initial field content DimensionedField ( const IOobject& io, @@ -282,6 +282,62 @@ public: tmp> clone() const; + // Static Constructors + + //- Return tmp field from name, mesh, dimensions, + //- copy of internal field. + // The field is NO_READ, NO_WRITE, unregistered and uses the + // current timeName from the mesh registry + static tmp> New + ( + const word& name, + const Mesh& mesh, + const dimensionSet& ds, + const Field& iField + ); + + //- Return tmp field from name, mesh, dimensions, + //- moved internal field contents. + // The field is NO_READ, NO_WRITE, unregistered and uses the + // current timeName from the mesh registry + static tmp> New + ( + const word& name, + const Mesh& mesh, + const dimensionSet& ds, + Field&& iField + ); + + //- Return tmp field from name, mesh, dimensions. + // The field is NO_READ, NO_WRITE, unregistered and uses the + // current timeName from the mesh registry + static tmp> New + ( + const word& name, + const Mesh& mesh, + const dimensionSet& ds + ); + + //- Return tmp field from name, mesh, dimensioned\. + // The field is NO_READ, NO_WRITE, unregistered and uses the + // current timeName from the mesh registry + static tmp> New + ( + const word& name, + const Mesh& mesh, + const dimensioned& dt + ); + + //- Return renamed tmp field + // The field is NO_READ, NO_WRITE, unregistered and uses the + // current timeName from the mesh registry + static tmp> New + ( + const word& newName, + const tmp>& + ); + + //- Destructor virtual ~DimensionedField() = default; diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldNew.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldNew.C new file mode 100644 index 0000000000..dc2a0798e2 --- /dev/null +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedFieldNew.C @@ -0,0 +1,165 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +template +Foam::tmp> +Foam::DimensionedField::New +( + const word& name, + const Mesh& mesh, + const dimensionSet& ds, + const Field& iField +) +{ + return tmp>::New + ( + IOobject + ( + name, + mesh.thisDb().time().timeName(), + mesh.thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + ds, + iField + ); +} + + +template +Foam::tmp> +Foam::DimensionedField::New +( + const word& name, + const Mesh& mesh, + const dimensionSet& ds, + Field&& iField +) +{ + return tmp>::New + ( + IOobject + ( + name, + mesh.thisDb().time().timeName(), + mesh.thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + ds, + std::move(iField) + ); +} + + +template +Foam::tmp> +Foam::DimensionedField::New +( + const word& name, + const Mesh& mesh, + const dimensionSet& ds +) +{ + return tmp>::New + ( + IOobject + ( + name, + mesh.thisDb().time().timeName(), + mesh.thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + ds, + false // checkIOFlags = true + ); +} + + +template +Foam::tmp> +Foam::DimensionedField::New +( + const word& name, + const Mesh& mesh, + const dimensioned& dt +) +{ + return tmp>::New + ( + IOobject + ( + name, + mesh.thisDb().time().timeName(), + mesh.thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dt, + false // checkIOFlags = true + ); +} + + +template +Foam::tmp> +Foam::DimensionedField::New +( + const word& newName, + const tmp>& tfld +) +{ + return tmp>::New + ( + IOobject + ( + newName, + tfld().instance(), + tfld().local(), + tfld().db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + tfld + ); +} + + +// ************************************************************************* //