Skip to content
Snippets Groups Projects
Commit 0efa5f06 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: DimensionedFields::New static constructors

parent 93dcf732
No related branches found
No related tags found
No related merge requests found
...@@ -585,6 +585,7 @@ COMPUTED_ASSIGNMENT(scalar, /=) ...@@ -585,6 +585,7 @@ COMPUTED_ASSIGNMENT(scalar, /=)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "DimensionedFieldIO.C" #include "DimensionedFieldIO.C"
#include "DimensionedFieldNew.C"
#include "DimensionedFieldFunctions.C" #include "DimensionedFieldFunctions.C"
// ************************************************************************* // // ************************************************************************* //
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components, copy initial field content
DimensionedField DimensionedField
( (
const IOobject& io, const IOobject& io,
...@@ -282,6 +282,62 @@ public: ...@@ -282,6 +282,62 @@ public:
tmp<DimensionedField<Type, GeoMesh>> clone() const; tmp<DimensionedField<Type, GeoMesh>> 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<DimensionedField<Type, GeoMesh>> New
(
const word& name,
const Mesh& mesh,
const dimensionSet& ds,
const Field<Type>& 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<DimensionedField<Type, GeoMesh>> New
(
const word& name,
const Mesh& mesh,
const dimensionSet& ds,
Field<Type>&& 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<DimensionedField<Type, GeoMesh>> New
(
const word& name,
const Mesh& mesh,
const dimensionSet& ds
);
//- Return tmp field from name, mesh, dimensioned\<Type\>.
// The field is NO_READ, NO_WRITE, unregistered and uses the
// current timeName from the mesh registry
static tmp<DimensionedField<Type, GeoMesh>> New
(
const word& name,
const Mesh& mesh,
const dimensioned<Type>& dt
);
//- Return renamed tmp field
// The field is NO_READ, NO_WRITE, unregistered and uses the
// current timeName from the mesh registry
static tmp<DimensionedField<Type, GeoMesh>> New
(
const word& newName,
const tmp<DimensionedField<Type, GeoMesh>>&
);
//- Destructor //- Destructor
virtual ~DimensionedField() = default; virtual ~DimensionedField() = default;
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type, class GeoMesh>
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
Foam::DimensionedField<Type, GeoMesh>::New
(
const word& name,
const Mesh& mesh,
const dimensionSet& ds,
const Field<Type>& iField
)
{
return tmp<DimensionedField<Type, GeoMesh>>::New
(
IOobject
(
name,
mesh.thisDb().time().timeName(),
mesh.thisDb(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
ds,
iField
);
}
template<class Type, class GeoMesh>
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
Foam::DimensionedField<Type, GeoMesh>::New
(
const word& name,
const Mesh& mesh,
const dimensionSet& ds,
Field<Type>&& iField
)
{
return tmp<DimensionedField<Type, GeoMesh>>::New
(
IOobject
(
name,
mesh.thisDb().time().timeName(),
mesh.thisDb(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
ds,
std::move(iField)
);
}
template<class Type, class GeoMesh>
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
Foam::DimensionedField<Type, GeoMesh>::New
(
const word& name,
const Mesh& mesh,
const dimensionSet& ds
)
{
return tmp<DimensionedField<Type, GeoMesh>>::New
(
IOobject
(
name,
mesh.thisDb().time().timeName(),
mesh.thisDb(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
ds,
false // checkIOFlags = true
);
}
template<class Type, class GeoMesh>
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
Foam::DimensionedField<Type, GeoMesh>::New
(
const word& name,
const Mesh& mesh,
const dimensioned<Type>& dt
)
{
return tmp<DimensionedField<Type, GeoMesh>>::New
(
IOobject
(
name,
mesh.thisDb().time().timeName(),
mesh.thisDb(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
dt,
false // checkIOFlags = true
);
}
template<class Type, class GeoMesh>
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
Foam::DimensionedField<Type, GeoMesh>::New
(
const word& newName,
const tmp<DimensionedField<Type, GeoMesh>>& tfld
)
{
return tmp<DimensionedField<Type, GeoMesh>>::New
(
IOobject
(
newName,
tfld().instance(),
tfld().local(),
tfld().db(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
tfld
);
}
// ************************************************************************* //
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment