functionObjects/field: Simplified code using the VolField and SurfaceField partial specialisations

replacing the inconsistently named local typedefs and direct use of the more
complex GeometricField template types.
This commit is contained in:
Henry Weller
2022-12-01 22:01:54 +00:00
parent e8078ca235
commit 73c5624acf
21 changed files with 100 additions and 146 deletions

View File

@ -32,14 +32,12 @@ License
template<class Type> template<class Type>
bool Foam::functionObjects::blendingFactor::calcBF() bool Foam::functionObjects::blendingFactor::calcBF()
{ {
typedef GeometricField<Type, fvPatchField, volMesh> FieldType; if (!foundObject<VolField<Type>>(fieldName_))
if (!foundObject<FieldType>(fieldName_))
{ {
return false; return false;
} }
const FieldType& field = lookupObject<FieldType>(fieldName_); const VolField<Type>& field = lookupObject<VolField<Type>>(fieldName_);
const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')'); const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')');
ITstream& its = mesh_.schemes().div(divScheme); ITstream& its = mesh_.schemes().div(divScheme);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -52,16 +52,13 @@ bool Foam::functionObjects::components::calcFieldComponents()
template<class Type> template<class Type>
bool Foam::functionObjects::components::calcComponents() bool Foam::functionObjects::components::calcComponents()
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (foundObject<VolField<Type>>(fieldName_))
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (foundObject<VolFieldType>(fieldName_))
{ {
return calcFieldComponents<VolFieldType>(); return calcFieldComponents<VolField<Type>>();
} }
else if (foundObject<SurfaceFieldType>(fieldName_)) else if (foundObject<SurfaceField<Type>>(fieldName_))
{ {
return calcFieldComponents<SurfaceFieldType>(); return calcFieldComponents<SurfaceField<Type>>();
} }
else else
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2017-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,14 +30,12 @@ License
template<class Type> template<class Type>
bool Foam::functionObjects::ddt::calcDdt() bool Foam::functionObjects::ddt::calcDdt()
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (foundObject<VolField<Type>>(fieldName_))
if (foundObject<VolFieldType>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
fvc::ddt(lookupObject<VolFieldType>(fieldName_)) fvc::ddt(lookupObject<VolField<Type>>(fieldName_))
); );
} }
else else

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,7 +36,7 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transformField
const FieldType& field const FieldType& field
) )
{ {
word transFieldName(transformFieldName(field.name())); const word transFieldName(transformFieldName(field.name()));
store store
( (
@ -52,25 +52,22 @@ void Foam::functionObjects::fieldCoordinateSystemTransform::transform
const word& fieldName const word& fieldName
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (mesh_.foundObject<VolField<Type>>(fieldName))
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (mesh_.foundObject<VolFieldType>(fieldName))
{ {
DebugInfo << type() << ": Field " << fieldName << endl; DebugInfo << type() << ": Field " << fieldName << endl;
transformField<VolFieldType> transformField<VolField<Type>>
( (
mesh_.lookupObject<VolFieldType>(fieldName) mesh_.lookupObject<VolField<Type>>(fieldName)
); );
} }
else if (mesh_.foundObject<SurfaceFieldType>(fieldName)) else if (mesh_.foundObject<SurfaceField<Type>>(fieldName))
{ {
DebugInfo << type() << ": Field " << fieldName << endl; DebugInfo << type() << ": Field " << fieldName << endl;
transformField<SurfaceFieldType> transformField<SurfaceField<Type>>
( (
mesh_.lookupObject<SurfaceFieldType>(fieldName) mesh_.lookupObject<SurfaceField<Type>>(fieldName)
); );
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -84,9 +84,6 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::processFields
bool& found bool& found
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> vf;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
const wordList fields1 = region1Ptr_->fields(); const wordList fields1 = region1Ptr_->fields();
const dictionary& results1 = region1Ptr_->resultDict(); const dictionary& results1 = region1Ptr_->resultDict();
@ -101,7 +98,10 @@ void Foam::functionObjects::fieldValues::fieldValueDelta::processFields
if if
( (
(obr_.foundObject<vf>(fieldName) || obr_.foundObject<sf>(fieldName)) (
obr_.foundObject<VolField<Type>>(fieldName)
|| obr_.foundObject<SurfaceField<Type>>(fieldName)
)
&& results2.found(fieldName) && results2.found(fieldName)
) )
{ {

View File

@ -474,14 +474,14 @@ public:
template<class Type> template<class Type>
tmp<Field<Type>> filterField tmp<Field<Type>> filterField
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& field const SurfaceField<Type>& field
) const; ) const;
//- Filter a volume field according to faceIds //- Filter a volume field according to faceIds
template<class Type> template<class Type>
tmp<Field<Type>> filterField tmp<Field<Type>> filterField
( (
const GeometricField<Type, fvPatchField, volMesh>& field const VolField<Type>& field
) const; ) const;
//- Read from dictionary //- Read from dictionary

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,18 +38,15 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::validField
const word& fieldName const word& fieldName
) const ) const
{ {
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
typedef GeometricField<Type, fvPatchField, volMesh> vf;
if if
( (
regionType_ != regionTypes::sampledSurface regionType_ != regionTypes::sampledSurface
&& obr_.foundObject<sf>(fieldName) && obr_.foundObject<SurfaceField<Type>>(fieldName)
) )
{ {
return true; return true;
} }
else if (obr_.foundObject<vf>(fieldName)) else if (obr_.foundObject<VolField<Type>>(fieldName))
{ {
return true; return true;
} }
@ -65,14 +62,12 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
const word& fieldName const word& fieldName
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> vf;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
if (regionType_ == regionTypes::sampledSurface) if (regionType_ == regionTypes::sampledSurface)
{ {
if (obr_.foundObject<vf>(fieldName)) if (obr_.foundObject<VolField<Type>>(fieldName))
{ {
const vf& fld = obr_.lookupObject<vf>(fieldName); const VolField<Type>& fld =
obr_.lookupObject<VolField<Type>>(fieldName);
if (surfacePtr_().interpolate()) if (surfacePtr_().interpolate())
{ {
@ -102,7 +97,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
return surfacePtr_().sample(fld); return surfacePtr_().sample(fld);
} }
} }
else if (obr_.foundObject<sf>(fieldName)) else if (obr_.foundObject<SurfaceField<Type>>(fieldName))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Surface field " << fieldName << "Surface field " << fieldName
@ -113,14 +108,16 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues
} }
else else
{ {
if (obr_.foundObject<vf>(fieldName)) if (obr_.foundObject<VolField<Type>>(fieldName))
{ {
const vf& fld = obr_.lookupObject<vf>(fieldName); const VolField<Type>& fld =
obr_.lookupObject<VolField<Type>>(fieldName);
return filterField(fld); return filterField(fld);
} }
else if (obr_.foundObject<sf>(fieldName)) else if (obr_.foundObject<SurfaceField<Type>>(fieldName))
{ {
const sf& fld = obr_.lookupObject<sf>(fieldName); const SurfaceField<Type>& fld =
obr_.lookupObject<SurfaceField<Type>>(fieldName);
return filterField(fld); return filterField(fld);
} }
} }
@ -408,7 +405,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
( (
const GeometricField<Type, fvPatchField, volMesh>& field const VolField<Type>& field
) const ) const
{ {
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size())); tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));
@ -442,7 +439,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::surfaceFieldValue::filterField Foam::functionObjects::fieldValues::surfaceFieldValue::filterField
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& field const SurfaceField<Type>& field
) const ) const
{ {
tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size())); tmp<Field<Type>> tvalues(new Field<Type>(faceId_.size()));

View File

@ -34,9 +34,7 @@ bool Foam::functionObjects::fieldValues::volFieldValue::validField
const word& fieldName const word& fieldName
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> vf; if (obr_.foundObject<VolField<Type>>(fieldName))
if (obr_.foundObject<vf>(fieldName))
{ {
return true; return true;
} }
@ -52,11 +50,9 @@ Foam::functionObjects::fieldValues::volFieldValue::getFieldValues
const word& fieldName const word& fieldName
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> vf; if (obr_.foundObject<VolField<Type>>(fieldName))
if (obr_.foundObject<vf>(fieldName))
{ {
return filterField(obr_.lookupObject<vf>(fieldName)); return filterField(obr_.lookupObject<VolField<Type>>(fieldName));
} }
FatalErrorInFunction FatalErrorInFunction

View File

@ -30,24 +30,21 @@ License
template<class Type> template<class Type>
bool Foam::functionObjects::grad::calcGrad() bool Foam::functionObjects::grad::calcGrad()
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (foundObject<VolField<Type>>(fieldName_))
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (foundObject<VolFieldType>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
fvc::grad(lookupObject<VolFieldType>(fieldName_)), fvc::grad(lookupObject<VolField<Type>>(fieldName_)),
mesh_.changing() && mesh_.solution().cache(resultName_) mesh_.changing() && mesh_.solution().cache(resultName_)
); );
} }
else if (foundObject<SurfaceFieldType>(fieldName_)) else if (foundObject<SurfaceField<Type>>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
fvc::grad(lookupObject<SurfaceFieldType>(fieldName_)), fvc::grad(lookupObject<SurfaceField<Type>>(fieldName_)),
mesh_.changing() && mesh_.solution().cache(resultName_) mesh_.changing() && mesh_.solution().cache(resultName_)
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,23 +31,20 @@ License
template<class Type> template<class Type>
bool Foam::functionObjects::mag::calcMag() bool Foam::functionObjects::mag::calcMag()
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (foundObject<VolField<Type>>(fieldName_))
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (foundObject<VolFieldType>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
Foam::mag(lookupObject<VolFieldType>(fieldName_)) Foam::mag(lookupObject<VolField<Type>>(fieldName_))
); );
} }
else if (foundObject<SurfaceFieldType>(fieldName_)) else if (foundObject<SurfaceField<Type>>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
Foam::mag(lookupObject<SurfaceFieldType>(fieldName_)) Foam::mag(lookupObject<SurfaceField<Type>>(fieldName_))
); );
} }
else else

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,23 +31,20 @@ License
template<class Type> template<class Type>
bool Foam::functionObjects::magSqr::calcMagSqr() bool Foam::functionObjects::magSqr::calcMagSqr()
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (foundObject<VolField<Type>>(fieldName_))
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (foundObject<VolFieldType>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
Foam::magSqr(lookupObject<VolFieldType>(fieldName_)) Foam::magSqr(lookupObject<VolField<Type>>(fieldName_))
); );
} }
else if (foundObject<SurfaceFieldType>(fieldName_)) else if (foundObject<SurfaceField<Type>>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
Foam::magSqr(lookupObject<SurfaceFieldType>(fieldName_)) Foam::magSqr(lookupObject<SurfaceField<Type>>(fieldName_))
); );
} }
else else

View File

@ -147,7 +147,7 @@ protected:
template<class Type> template<class Type>
void createFields void createFields
( (
PtrList<GeometricField<Type, fvPatchField, volMesh>>& PtrList<VolField<Type>>&
) const; ) const;
//- Override boundary fields with sampled values //- Override boundary fields with sampled values
@ -155,13 +155,13 @@ protected:
void sampleBoundaryField void sampleBoundaryField
( (
const interpolationCellPoint<Type>& interpolator, const interpolationCellPoint<Type>& interpolator,
GeometricField<Type, fvPatchField, volMesh>& fld VolField<Type>& fld
) const; ) const;
template<class Type> template<class Type>
void sampleFields void sampleFields
( (
PtrList<GeometricField<Type, fvPatchField, volMesh>>& PtrList<VolField<Type>>&
) const; ) const;

View File

@ -30,16 +30,14 @@ License
template<class Type> template<class Type>
void Foam::functionObjects::nearWallFields::createFields void Foam::functionObjects::nearWallFields::createFields
( (
PtrList<GeometricField<Type, fvPatchField, volMesh>>& sflds PtrList<VolField<Type>>& sflds
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; HashTable<const VolField<Type>*> flds(obr_.lookupClass<VolField<Type>>());
HashTable<const VolFieldType*> flds(obr_.lookupClass<VolFieldType>()); forAllConstIter(typename HashTable<const VolField<Type>*>, flds, iter)
forAllConstIter(typename HashTable<const VolFieldType*>, flds, iter)
{ {
const VolFieldType& fld = *iter(); const VolField<Type>& fld = *iter();
if (fieldMap_.found(fld.name())) if (fieldMap_.found(fld.name()))
{ {
@ -59,7 +57,7 @@ void Foam::functionObjects::nearWallFields::createFields
sflds.set sflds.set
( (
sz, sz,
new VolFieldType new VolField<Type>
( (
IOobject IOobject
( (
@ -84,7 +82,7 @@ template<class Type>
void Foam::functionObjects::nearWallFields::sampleBoundaryField void Foam::functionObjects::nearWallFields::sampleBoundaryField
( (
const interpolationCellPoint<Type>& interpolator, const interpolationCellPoint<Type>& interpolator,
GeometricField<Type, fvPatchField, volMesh>& fld VolField<Type>& fld
) const ) const
{ {
// Construct flat fields for all patch faces to be sampled // Construct flat fields for all patch faces to be sampled
@ -108,7 +106,7 @@ void Foam::functionObjects::nearWallFields::sampleBoundaryField
sampledValues sampledValues
); );
typename GeometricField<Type, fvPatchField, volMesh>:: typename VolField<Type>::
Boundary& fldBf = fld.boundaryFieldRef(); Boundary& fldBf = fld.boundaryFieldRef();
// Pick up data // Pick up data
@ -133,15 +131,13 @@ void Foam::functionObjects::nearWallFields::sampleBoundaryField
template<class Type> template<class Type>
void Foam::functionObjects::nearWallFields::sampleFields void Foam::functionObjects::nearWallFields::sampleFields
( (
PtrList<GeometricField<Type, fvPatchField, volMesh>>& sflds PtrList<VolField<Type>>& sflds
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
forAll(sflds, i) forAll(sflds, i)
{ {
const word& fldName = reverseFieldMap_[sflds[i].name()]; const word& fldName = reverseFieldMap_[sflds[i].name()];
const VolFieldType& fld = obr_.lookupObject<VolFieldType>(fldName); const VolField<Type>& fld = obr_.lookupObject<VolField<Type>>(fldName);
// Take over internal and boundary values // Take over internal and boundary values
sflds[i] == fld; sflds[i] == fld;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,14 +31,12 @@ License
template<class Type> template<class Type>
bool Foam::functionObjects::randomise::calcRandomised() bool Foam::functionObjects::randomise::calcRandomised()
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (foundObject<VolField<Type>>(fieldName_))
if (foundObject<VolFieldType>(fieldName_))
{ {
const VolFieldType& field = lookupObject<VolFieldType>(fieldName_); const VolField<Type>& field = lookupObject<VolField<Type>>(fieldName_);
tmp<VolFieldType> rfieldt(new VolFieldType(field)); tmp<VolField<Type>> rfieldt(new VolField<Type>(field));
VolFieldType& rfield = rfieldt.ref(); VolField<Type>& rfield = rfieldt.ref();
Random rand(1234567); Random rand(1234567);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -107,8 +107,8 @@ protected:
void loadField void loadField
( (
const word&, const word&,
PtrList<GeometricField<Type, fvPatchField, volMesh>>&, PtrList<VolField<Type>>&,
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& PtrList<SurfaceField<Type>>&
) const; ) const;

View File

@ -34,20 +34,17 @@ template<class Type>
void Foam::functionObjects::readFields::loadField void Foam::functionObjects::readFields::loadField
( (
const word& fieldName, const word& fieldName,
PtrList<GeometricField<Type, fvPatchField, volMesh>>& vflds, PtrList<VolField<Type>>& vflds,
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds PtrList<SurfaceField<Type>>& sflds
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (obr_.foundObject<VolField<Type>>(fieldName))
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (obr_.foundObject<VolFieldType>(fieldName))
{ {
DebugInfo DebugInfo
<< "readFields : Field " << fieldName << " already in database" << "readFields : Field " << fieldName << " already in database"
<< endl; << endl;
} }
else if (obr_.foundObject<SurfaceFieldType>(fieldName)) else if (obr_.foundObject<SurfaceField<Type>>(fieldName))
{ {
DebugInfo DebugInfo
<< "readFields : Field " << fieldName << "readFields : Field " << fieldName
@ -67,7 +64,7 @@ void Foam::functionObjects::readFields::loadField
if if
( (
fieldHeader.headerOk() fieldHeader.headerOk()
&& fieldHeader.headerClassName() == VolFieldType::typeName && fieldHeader.headerClassName() == VolField<Type>::typeName
) )
{ {
// Store field locally // Store field locally
@ -75,12 +72,12 @@ void Foam::functionObjects::readFields::loadField
label sz = vflds.size(); label sz = vflds.size();
vflds.setSize(sz+1); vflds.setSize(sz+1);
vflds.set(sz, new VolFieldType(fieldHeader, mesh_)); vflds.set(sz, new VolField<Type>(fieldHeader, mesh_));
} }
else if else if
( (
fieldHeader.headerOk() fieldHeader.headerOk()
&& fieldHeader.headerClassName() == SurfaceFieldType::typeName && fieldHeader.headerClassName() == SurfaceField<Type>::typeName
) )
{ {
// Store field locally // Store field locally
@ -88,7 +85,7 @@ void Foam::functionObjects::readFields::loadField
label sz = sflds.size(); label sz = sflds.size();
sflds.setSize(sz+1); sflds.setSize(sz+1);
sflds.set(sz, new SurfaceFieldType(fieldHeader, mesh_)); sflds.set(sz, new SurfaceField<Type>(fieldHeader, mesh_));
} }
} }
} }

View File

@ -44,14 +44,12 @@ namespace functionObjects
template<class Type> template<class Type>
bool Foam::functionObjects::reconstruct::calcReconstruction() bool Foam::functionObjects::reconstruct::calcReconstruction()
{ {
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType; if (foundObject<SurfaceField<Type>>(fieldName_))
if (foundObject<SurfaceFieldType>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
fvc::reconstruct(lookupObject<SurfaceFieldType>(fieldName_)), fvc::reconstruct(lookupObject<SurfaceField<Type>>(fieldName_)),
mesh_.changing() && mesh_.solution().cache(resultName_) mesh_.changing() && mesh_.solution().cache(resultName_)
); );
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,23 +31,20 @@ License
template<class Type> template<class Type>
bool Foam::functionObjects::scale::calcScale() bool Foam::functionObjects::scale::calcScale()
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; if (foundObject<VolField<Type>>(fieldName_))
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
if (foundObject<VolFieldType>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
scale_*lookupObject<VolFieldType>(fieldName_) scale_*lookupObject<VolField<Type>>(fieldName_)
); );
} }
else if (foundObject<SurfaceFieldType>(fieldName_)) else if (foundObject<SurfaceField<Type>>(fieldName_))
{ {
return store return store
( (
resultName_, resultName_,
scale_*lookupObject<SurfaceFieldType>(fieldName_) scale_*lookupObject<SurfaceField<Type>>(fieldName_)
); );
} }
else else

View File

@ -158,7 +158,7 @@ protected:
void processField void processField
( (
const word& fieldName, const word& fieldName,
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tvalue const tmp<VolField<Type>>& tvalue
); );

View File

@ -31,19 +31,17 @@ template<class Type>
void Foam::functionObjects::turbulenceFields::processField void Foam::functionObjects::turbulenceFields::processField
( (
const word& fieldName, const word& fieldName,
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tvalue const tmp<VolField<Type>>& tvalue
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
const word scopedName const word scopedName
( (
IOobject::groupName(prefix_ + fieldName, phaseName_) IOobject::groupName(prefix_ + fieldName, phaseName_)
); );
if (obr_.foundObject<FieldType>(scopedName)) if (obr_.foundObject<VolField<Type>>(scopedName))
{ {
obr_.lookupObjectRef<FieldType>(scopedName) == tvalue(); obr_.lookupObjectRef<VolField<Type>>(scopedName) == tvalue();
} }
else if (obr_.found(scopedName)) else if (obr_.found(scopedName))
{ {
@ -56,7 +54,7 @@ void Foam::functionObjects::turbulenceFields::processField
{ {
obr_.store obr_.store
( (
new FieldType new VolField<Type>
( (
IOobject IOobject
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,9 +33,7 @@ License
template<class Type> template<class Type>
void Foam::functionObjects::residuals::writeFileHeader(const word& fieldName) void Foam::functionObjects::residuals::writeFileHeader(const word& fieldName)
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; if (obr_.foundObject<VolField<Type>>(fieldName))
if (obr_.foundObject<fieldType>(fieldName))
{ {
typename pTraits<Type>::labelType validComponents typename pTraits<Type>::labelType validComponents
( (
@ -60,9 +58,7 @@ void Foam::functionObjects::residuals::writeFileHeader(const word& fieldName)
template<class Type> template<class Type>
void Foam::functionObjects::residuals::writeResidual(const word& fieldName) void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; if (obr_.foundObject<VolField<Type>>(fieldName))
if (obr_.foundObject<fieldType>(fieldName))
{ {
if (Residuals<Type>::found(mesh_, fieldName)) if (Residuals<Type>::found(mesh_, fieldName))
{ {