Code simplification: GeometricField<Type, fvPatchField, volMesh> -> VolField<Type>

Using the VolField<Type> partial specialisation of
GeometricField<Type, fvPatchField, volMesh>
simplifies the code and improves readability.
This commit is contained in:
Henry Weller
2022-12-02 22:04:45 +00:00
parent fe368d5332
commit 2f4dd4fe27
274 changed files with 1796 additions and 1802 deletions

View File

@ -129,7 +129,7 @@ void subsetVolFields
const label patchi,
const Type& exposedValue,
const word GeomVolType,
PtrList<GeometricField<Type, fvPatchField, volMesh>>& subFields
PtrList<VolField<Type>>& subFields
)
{
const fvMesh& baseMesh = subsetter.baseMesh();
@ -144,7 +144,7 @@ void subsetVolFields
Info<< "Subsetting field " << fieldName << endl;
GeometricField<Type, fvPatchField, volMesh> volField
VolField<Type> volField
(
*iter(),
baseMesh

View File

@ -52,7 +52,7 @@ void subsetVolFields
(
const fvMeshSubset& subsetter,
const wordList& fieldNames,
PtrList<GeometricField<Type, fvPatchField, volMesh>>& subFields
PtrList<VolField<Type>>& subFields
)
{
const fvMesh& baseMesh = subsetter.baseMesh();
@ -63,7 +63,7 @@ void subsetVolFields
Info<< "Subsetting field " << fieldName << endl;
GeometricField<Type, fvPatchField, volMesh> fld
VolField<Type> fld
(
IOobject
(

View File

@ -146,10 +146,10 @@ public:
//- Decompose volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
tmp<VolField<Type>>
decomposeField
(
const GeometricField<Type, fvPatchField, volMesh>& field
const VolField<Type>& field
) const;
//- Decompose surface field

View File

@ -86,7 +86,7 @@ template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::fvFieldDecomposer::decomposeField
(
const GeometricField<Type, fvPatchField, volMesh>& field
const VolField<Type>& field
) const
{
// Create dummy patch fields
@ -106,9 +106,9 @@ Foam::fvFieldDecomposer::decomposeField
}
// Create the processor field with the dummy patch fields
tmp<GeometricField<Type, fvPatchField, volMesh>> tresF
tmp<VolField<Type>> tresF
(
new GeometricField<Type, fvPatchField, volMesh>
new VolField<Type>
(
IOobject
(
@ -125,11 +125,11 @@ Foam::fvFieldDecomposer::decomposeField
patchFields
)
);
GeometricField<Type, fvPatchField, volMesh>& resF = tresF.ref();
VolField<Type>& resF = tresF.ref();
// Change the patch fields to the correct type using a mapper constructor
// (with reference to the now correct internal field)
typename GeometricField<Type, fvPatchField, volMesh>::
typename VolField<Type>::
Boundary& bf = resF.boundaryFieldRef();
forAll(bf, procPatchi)
{

View File

@ -152,16 +152,16 @@ public:
//- Reconstruct volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
tmp<VolField<Type>>
reconstructFvVolumeField
(
const IOobject& fieldIoObject,
const PtrList<GeometricField<Type, fvPatchField, volMesh>>&
const PtrList<VolField<Type>>&
) const;
//- Read and reconstruct volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
tmp<VolField<Type>>
reconstructFvVolumeField(const IOobject& fieldIoObject) const;

View File

@ -142,7 +142,7 @@ Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::fvFieldReconstructor::reconstructFvVolumeField
(
const IOobject& fieldIoObject,
const PtrList<GeometricField<Type, fvPatchField, volMesh>>& procFields
const PtrList<VolField<Type>>& procFields
) const
{
// Create the internalField
@ -153,7 +153,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
forAll(procFields, proci)
{
const GeometricField<Type, fvPatchField, volMesh>& procField =
const VolField<Type>& procField =
procFields[proci];
// Set the cell values in the reconstructed field
@ -240,9 +240,9 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
}
// Construct and return the field
return tmp<GeometricField<Type, fvPatchField, volMesh>>
return tmp<VolField<Type>>
(
new GeometricField<Type, fvPatchField, volMesh>
new VolField<Type>
(
fieldIoObject,
completeMesh_,
@ -261,7 +261,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
const IOobject& fieldIoObject
) const
{
PtrList<GeometricField<Type, fvPatchField, volMesh>>
PtrList<VolField<Type>>
procFields(procMeshes_.size());
forAll(procMeshes_, proci)
@ -269,7 +269,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
procFields.set
(
proci,
new GeometricField<Type, fvPatchField, volMesh>
new VolField<Type>
(
IOobject
(
@ -507,7 +507,7 @@ void Foam::fvFieldReconstructor::reconstructFvVolumeFields
)
{
const word& fieldClassName =
GeometricField<Type, fvPatchField, volMesh>::typeName;
VolField<Type>::typeName;
IOobjectList fields = objects.lookupClass(fieldClassName);

View File

@ -40,16 +40,16 @@ using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>>
tmp<VolField<Type>>
volField
(
const fvMeshSubset& meshSubsetter,
const GeometricField<Type, fvPatchField, volMesh>& vf
const VolField<Type>& vf
)
{
if (meshSubsetter.hasSubMesh())
{
tmp<GeometricField<Type, fvPatchField, volMesh>> tfld
tmp<VolField<Type>> tfld
(
meshSubsetter.interpolate(vf)
);
@ -300,7 +300,7 @@ void writePatchField
template<class Type>
void ensightField
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const VolField<Type>& vf,
const ensightMesh& eMesh,
const fileName& postProcPath,
const word& prepend,
@ -717,7 +717,7 @@ void ensightPointField
template<class Type>
void ensightField
(
const GeometricField<Type, fvPatchField, volMesh>& vf,
const VolField<Type>& vf,
const ensightMesh& eMesh,
const fileName& postProcPath,
const word& prepend,

View File

@ -229,7 +229,7 @@ void Foam::ensightVolField
partsList.writeField
(
os,
GeometricField<Type, fvPatchField, volMesh>
VolField<Type>
(
fieldObject,
mesh

View File

@ -123,7 +123,7 @@ public:
tmp<Field<Type>> getPatchField
(
const bool nearCellValue,
const GeometricField<Type, fvPatchField, volMesh>& vfld,
const VolField<Type>& vfld,
const label patchi
) const;

View File

@ -68,7 +68,7 @@ template<class Type>
Foam::tmp<Field<Type>> Foam::tecplotWriter::getPatchField
(
const bool nearCellValue,
const GeometricField<Type, fvPatchField, volMesh>& vfld,
const VolField<Type>& vfld,
const label patchi
) const
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -104,7 +104,7 @@ public:
void write
(
const volPointInterpolation&,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
const UPtrList<const VolField<Type>>&
);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,7 +58,7 @@ template<class Type>
void Foam::internalWriter::write
(
const volPointInterpolation& pInterp,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
const UPtrList<const VolField<Type>>& flds
)
{
forAll(flds, i)

View File

@ -114,7 +114,7 @@ public:
template<class Type>
void write
(
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
const UPtrList<const VolField<Type>>&
);
//- Write pointFields
@ -132,7 +132,7 @@ public:
void write
(
const PrimitivePatchInterpolation<primitivePatch>&,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
const UPtrList<const VolField<Type>>&
);
};

View File

@ -31,12 +31,12 @@ License
template<class Type>
void Foam::patchWriter::write
(
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
const UPtrList<const VolField<Type>>& flds
)
{
forAll(flds, fieldi)
{
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
const VolField<Type>& fld = flds[fieldi];
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
<< nFaces_ << " float" << std::endl;
@ -96,12 +96,12 @@ template<class Type>
void Foam::patchWriter::write
(
const PrimitivePatchInterpolation<primitivePatch>& pInter,
const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
const UPtrList<const VolField<Type>>& flds
)
{
forAll(flds, fieldi)
{
const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi];
const VolField<Type>& fld = flds[fieldi];
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' '
<< nPoints_ << " float" << std::endl;

View File

@ -79,7 +79,7 @@ namespace vtkWriteOps
(
std::ostream&,
const bool binary,
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
const PointField<Type>&,
const vtkMesh&
);
@ -101,7 +101,7 @@ namespace vtkWriteOps
std::ostream&,
const bool binary,
const volPointInterpolation&,
const PtrList<GeometricField<Type, fvPatchField, volMesh>>&,
const PtrList<VolField<Type>>&,
const vtkMesh&
);

View File

@ -97,7 +97,7 @@ void Foam::vtkWriteOps::write
(
std::ostream& os,
const bool binary,
const GeometricField<Type, fvPatchField, volMesh>& vvf,
const VolField<Type>& vvf,
const PointField<Type>& pvf,
const vtkMesh& vMesh
)
@ -147,7 +147,7 @@ void Foam::vtkWriteOps::write
std::ostream& os,
const bool binary,
const volPointInterpolation& pInterp,
const PtrList<GeometricField<Type, fvPatchField, volMesh>>& flds,
const PtrList<VolField<Type>>& flds,
const vtkMesh& vMesh
)
{

View File

@ -534,7 +534,7 @@ class vtkPVFoam
template<class Type>
void convertVolFieldBlock
(
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
autoPtr<PointField<Type>>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
@ -545,7 +545,7 @@ class vtkPVFoam
template<class Type>
void convertVolInternalFieldBlock
(
const typename GeometricField<Type, fvPatchField, volMesh>
const typename VolField<Type>
::Internal&,
vtkMultiBlockDataSet* output,
const arrayRange&,
@ -556,7 +556,7 @@ class vtkPVFoam
template<class Type>
void convertVolInternalField
(
const typename GeometricField<Type, fvPatchField, volMesh>
const typename VolField<Type>
::Internal&,
vtkMultiBlockDataSet* output,
const arrayRange&,
@ -579,7 +579,7 @@ class vtkPVFoam
template<class Type>
void convertSurfaceField
(
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo,
@ -652,7 +652,7 @@ class vtkPVFoam
void convertPointField
(
const PointField<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
vtkMultiBlockDataSet* output,
const arrayRange&,
const label datasetNo,

View File

@ -187,7 +187,7 @@ void Foam::vtkPVFoam::convertPointFieldBlock
convertPointField
(
ptf,
GeometricField<Type, fvPatchField, volMesh>::null(),
VolField<Type>::null(),
output,
range,
datasetNo,
@ -202,7 +202,7 @@ template<class Type>
void Foam::vtkPVFoam::convertPointField
(
const PointField<Type>& ptf,
const GeometricField<Type, fvPatchField, volMesh>& tf,
const VolField<Type>& tf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo,
@ -232,7 +232,7 @@ void Foam::vtkPVFoam::convertPointField
// Note: using the name of the original volField
// not the name generated by the interpolation "volPointInterpolate(<name>)"
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
if (&tf != &VolField<Type>::null())
{
pointData->SetName(tf.name().c_str());
}
@ -285,7 +285,7 @@ void Foam::vtkPVFoam::convertPointField
// continue insertion from here
label i = nPoints;
if (&tf != &GeometricField<Type, fvPatchField, volMesh>::null())
if (&tf != &VolField<Type>::null())
{
forAll(addPointCellLabels, apI)
{

View File

@ -45,7 +45,7 @@ InClass
template<class Type>
void Foam::vtkPVFoam::convertSurfaceField
(
const GeometricField<Type, fvPatchField, volMesh>& tf,
const VolField<Type>& tf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo,

View File

@ -59,14 +59,14 @@ void Foam::vtkPVFoam::convertVolFields
if
(
iter()->headerClassName()
!= GeometricField<Type, fvPatchField, volMesh>::typeName
!= VolField<Type>::typeName
)
{
continue;
}
// Load field
GeometricField<Type, fvPatchField, volMesh> tf
VolField<Type> tf
(
*iter(),
mesh
@ -282,14 +282,14 @@ void Foam::vtkPVFoam::convertVolInternalFields
if
(
iter()->headerClassName()
!= GeometricField<Type, fvPatchField, volMesh>::Internal::typeName
!= VolField<Type>::Internal::typeName
)
{
continue;
}
// Load field
typename GeometricField<Type, fvPatchField, volMesh>::Internal tf
typename VolField<Type>::Internal tf
(
*iter(),
mesh
@ -328,7 +328,7 @@ void Foam::vtkPVFoam::convertVolInternalFields
template<class Type>
void Foam::vtkPVFoam::convertVolFieldBlock
(
const GeometricField<Type, fvPatchField, volMesh>& tf,
const VolField<Type>& tf,
autoPtr<PointField<Type>>& ptfPtr,
vtkMultiBlockDataSet* output,
const arrayRange& range,
@ -370,7 +370,7 @@ void Foam::vtkPVFoam::convertVolFieldBlock
template<class Type>
void Foam::vtkPVFoam::convertVolInternalFieldBlock
(
const typename GeometricField<Type, fvPatchField, volMesh>::Internal& tf,
const typename VolField<Type>::Internal& tf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const List<polyDecomp>& decompLst
@ -398,7 +398,7 @@ void Foam::vtkPVFoam::convertVolInternalFieldBlock
template<class Type>
void Foam::vtkPVFoam::convertVolInternalField
(
const typename GeometricField<Type, fvPatchField, volMesh>::Internal& tf,
const typename VolField<Type>::Internal& tf,
vtkMultiBlockDataSet* output,
const arrayRange& range,
const label datasetNo,

View File

@ -267,7 +267,7 @@ public:
void interpolateField
(
Field<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
const labelList& adr,
const scalarListList& weights
) const;
@ -277,7 +277,7 @@ public:
void interpolateField
(
Field<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
const labelListList& adr,
const scalarListList& weights
) const;
@ -288,7 +288,7 @@ public:
void interpolateField
(
Field<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
const labelList& adr,
const vectorField& centres
)const;
@ -299,7 +299,7 @@ public:
void interpolateInternalField
(
Field<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
order=INTERPOLATE
) const;
@ -307,7 +307,7 @@ public:
void interpolateInternalField
(
Field<Type>&,
const tmp<GeometricField<Type, fvPatchField, volMesh>>&,
const tmp<VolField<Type>>&,
order=INTERPOLATE
) const;
@ -316,32 +316,32 @@ public:
template<class Type>
void interpolate
(
GeometricField<Type, fvPatchField, volMesh>&,
const GeometricField<Type, fvPatchField, volMesh>&,
VolField<Type>&,
const VolField<Type>&,
order=INTERPOLATE
) const;
template<class Type>
void interpolate
(
GeometricField<Type, fvPatchField, volMesh>&,
const tmp<GeometricField<Type, fvPatchField, volMesh>>&,
VolField<Type>&,
const tmp<VolField<Type>>&,
order=INTERPOLATE
) const;
//- Interpolate volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> interpolate
tmp<VolField<Type>> interpolate
(
const GeometricField<Type, fvPatchField, volMesh>&,
const VolField<Type>&,
order=INTERPOLATE
) const;
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> interpolate
tmp<VolField<Type>> interpolate
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>&,
const tmp<VolField<Type>>&,
order=INTERPOLATE
) const;
};

View File

@ -57,7 +57,7 @@ template<class Type>
void Foam::meshToMesh0::interpolateField
(
Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
const VolField<Type>& fromVf,
const labelListList& adr,
const scalarListList& weights
) const
@ -83,7 +83,7 @@ template<class Type>
void Foam::meshToMesh0::interpolateField
(
Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
const VolField<Type>& fromVf,
const labelList& adr,
const scalarListList& weights
) const
@ -117,7 +117,7 @@ template<class Type>
void Foam::meshToMesh0::interpolateField
(
Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
const VolField<Type>& fromVf,
const labelList& adr,
const vectorField& centres
) const
@ -139,7 +139,7 @@ template<class Type>
void Foam::meshToMesh0::interpolateInternalField
(
Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
const VolField<Type>& fromVf,
meshToMesh0::order ord
) const
{
@ -216,7 +216,7 @@ template<class Type>
void Foam::meshToMesh0::interpolateInternalField
(
Field<Type>& toF,
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf,
const tmp<VolField<Type>>& tfromVf,
meshToMesh0::order ord
) const
{
@ -228,14 +228,14 @@ void Foam::meshToMesh0::interpolateInternalField
template<class Type>
void Foam::meshToMesh0::interpolate
(
GeometricField<Type, fvPatchField, volMesh>& toVf,
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
VolField<Type>& toVf,
const VolField<Type>& fromVf,
meshToMesh0::order ord
) const
{
interpolateInternalField(toVf, fromVf, ord);
typename GeometricField<Type, fvPatchField, volMesh>::
typename VolField<Type>::
Boundary& toVfBf = toVf.boundaryFieldRef();
forAll(toMesh_.boundaryMesh(), patchi)
@ -322,8 +322,8 @@ void Foam::meshToMesh0::interpolate
template<class Type>
void Foam::meshToMesh0::interpolate
(
GeometricField<Type, fvPatchField, volMesh>& toVf,
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf,
VolField<Type>& toVf,
const tmp<VolField<Type>>& tfromVf,
meshToMesh0::order ord
) const
{
@ -336,7 +336,7 @@ template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh0::interpolate
(
const GeometricField<Type, fvPatchField, volMesh>& fromVf,
const VolField<Type>& fromVf,
meshToMesh0::order ord
) const
{
@ -380,9 +380,9 @@ Foam::meshToMesh0::interpolate
// Create the complete field from the pieces
tmp<GeometricField<Type, fvPatchField, volMesh>> ttoF
tmp<VolField<Type>> ttoF
(
new GeometricField<Type, fvPatchField, volMesh>
new VolField<Type>
(
IOobject
(
@ -408,11 +408,11 @@ template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh0::interpolate
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf,
const tmp<VolField<Type>>& tfromVf,
meshToMesh0::order ord
) const
{
tmp<GeometricField<Type, fvPatchField, volMesh>> tint =
tmp<VolField<Type>> tint =
interpolate(tfromVf(), ord);
tfromVf.clear();

View File

@ -36,9 +36,9 @@ namespace Foam
{
template<class Type>
void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
void evaluateConstraintTypes(VolField<Type>& fld)
{
typename GeometricField<Type, fvPatchField, volMesh>::
typename VolField<Type>::
Boundary& fldBf = fld.boundaryFieldRef();
if

View File

@ -101,7 +101,7 @@ bool setCellFieldType
}
}
typename GeometricField<Type, fvPatchField, volMesh>::
typename VolField<Type>::
Boundary& fieldBf = field.boundaryFieldRef();
forAll(field.boundaryField(), patchi)