forwardFieldMapper: Rationalisation

The directFieldMapper has been renamed to forwardFieldMapper, and
instances where generalFieldMapper was used instead of a more simple
forward/direct type have been removed.
This commit is contained in:
Will Bainbridge
2023-11-14 10:19:00 +00:00
parent fbc3a122c5
commit 79ab17131e
13 changed files with 84 additions and 152 deletions

View File

@ -58,7 +58,7 @@ Foam::fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
) )
: :
labelList(mag(addressing) - 1), labelList(mag(addressing) - 1),
directFieldMapper(static_cast<const labelList&>(*this)) forwardFieldMapper(static_cast<const labelList&>(*this))
{} {}

View File

@ -40,7 +40,7 @@ SourceFiles
#include "IOobjectList.H" #include "IOobjectList.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "directFieldMapper.H" #include "forwardFieldMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -63,7 +63,7 @@ public:
class patchFieldDecomposer class patchFieldDecomposer
: :
public labelList, public labelList,
public directFieldMapper public forwardFieldMapper
{ {
public: public:

View File

@ -26,51 +26,59 @@ License
#include "pointFieldDecomposer.H" #include "pointFieldDecomposer.H"
#include "fvMesh.H" #include "fvMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer Foam::labelList Foam::pointFieldDecomposer::patchFieldDecomposer::addressing
( (
const pointPatch& completeMeshPatch, const pointPatch& completePatch,
const pointPatch& procMeshPatch, const pointPatch& procPatch,
const labelList& directAddr const labelList& pointProcAddressing
) )
:
generalFieldMapper(),
directAddressing_(procMeshPatch.size(), -1),
hasUnmapped_(false)
{ {
// Create the inverse-addressing of the patch point labels. const labelList& completePatchPoints = completePatch.meshPoints();
labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1); const labelList& procPatchPoints = procPatch.meshPoints();
const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints(); // Create a map from complete mesh point index to complete patch point index
labelList map(completePatch.boundaryMesh().mesh().size(), -1);
forAll(completeMeshPatchPoints, pointi) forAll(completePatchPoints, pointi)
{ {
pointMap[completeMeshPatchPoints[pointi]] = pointi; map[completePatchPoints[pointi]] = pointi;
} }
// Use the inverse point addressing to create the addressing table for this // Determine the complete patch point for every proc patch point, going via
// patch // the complete mesh point index and using the above map
const labelList& procMeshPatchPoints = procMeshPatch.meshPoints(); labelList result(procPatch.size(), -1);
forAll(procPatchPoints, pointi)
forAll(procMeshPatchPoints, pointi)
{ {
directAddressing_[pointi] = result[pointi] = map[pointProcAddressing[procPatchPoints[pointi]]];
pointMap[directAddr[procMeshPatchPoints[pointi]]];
} }
// Check that all the patch point addresses are set // Check that all the patch point addresses are set
if (directAddressing_.size() && min(directAddressing_) < 0) if (result.size() && min(result) < 0)
{ {
hasUnmapped_ = true;
FatalErrorInFunction FatalErrorInFunction
<< "Incomplete patch point addressing" << "Incomplete patch point addressing"
<< abort(FatalError); << abort(FatalError);
} }
return result;
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
(
const pointPatch& completePatch,
const pointPatch& procPatch,
const labelList& pointProcAddressing
)
:
labelList(addressing(completePatch, procPatch, pointProcAddressing)),
forwardFieldMapper(static_cast<const labelList&>(*this))
{}
Foam::pointFieldDecomposer::pointFieldDecomposer Foam::pointFieldDecomposer::pointFieldDecomposer
( (
const pointMesh& completeMesh, const pointMesh& completeMesh,

View File

@ -38,7 +38,7 @@ SourceFiles
#include "pointMesh.H" #include "pointMesh.H"
#include "pointFields.H" #include "pointFields.H"
#include "generalFieldMapper.H" #include "forwardFieldMapper.H"
#include "IOobjectList.H" #include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -61,51 +61,31 @@ public:
//- Point patch field decomposer class //- Point patch field decomposer class
class patchFieldDecomposer class patchFieldDecomposer
: :
public generalFieldMapper public labelList,
public forwardFieldMapper
{ {
// Private Data // Private Member Functions
//- ... //- Generate the addressing
labelList directAddressing_; static labelList addressing
(
//- Does map contain any unmapped values? const pointPatch& completePatch,
bool hasUnmapped_; const pointPatch& procPatch,
const labelList& pointProcAddressing
);
public: public:
// Constructors // Constructors
//- Construct given addressing //- Construct given patches and addressing
patchFieldDecomposer patchFieldDecomposer
( (
const pointPatch& completeMeshPatch, const pointPatch& completePatch,
const pointPatch& procMeshPatch, const pointPatch& procPatch,
const labelList& directAddr const labelList& pointProcAddressing
); );
// Member Functions
label size() const
{
return directAddressing_.size();
}
bool direct() const
{
return true;
}
bool hasUnmapped() const
{
return hasUnmapped_;
}
const labelUList& directAddressing() const
{
return directAddressing_;
}
}; };

View File

@ -40,7 +40,6 @@ SourceFiles
#include "fvMesh.H" #include "fvMesh.H"
#include "HashTable.H" #include "HashTable.H"
#include "generalFieldMapper.H"
#include "scalarList.H" #include "scalarList.H"
#include "className.H" #include "className.H"
@ -176,54 +175,6 @@ public:
~meshToMesh0(); ~meshToMesh0();
//- Patch-field interpolation class
class patchFieldInterpolator
:
public generalFieldMapper
{
const labelList& directAddressing_;
public:
// Constructors
//- Construct given addressing
patchFieldInterpolator(const labelList& addr)
:
directAddressing_(addr)
{}
//- Destructor
virtual ~patchFieldInterpolator()
{}
// Member Functions
label size() const
{
return directAddressing_.size();
}
bool direct() const
{
return true;
}
bool hasUnmapped() const
{
return false;
}
const labelList& directAddressing() const
{
return directAddressing_;
}
};
// Member Functions // Member Functions
// Access // Access

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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,6 +28,7 @@ License
#include "interpolationCellPoint.H" #include "interpolationCellPoint.H"
#include "SubField.H" #include "SubField.H"
#include "mixedFvPatchField.H" #include "mixedFvPatchField.H"
#include "forwardFieldMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -370,10 +371,7 @@ Foam::meshToMesh0::interpolate
fromVf.boundaryField()[patchi], fromVf.boundaryField()[patchi],
toMesh_.boundary()[patchi], toMesh_.boundary()[patchi],
DimensionedField<Type, volMesh>::null(), DimensionedField<Type, volMesh>::null(),
patchFieldInterpolator forwardFieldMapper(boundaryAddressing_[patchi])
(
boundaryAddressing_[patchi]
)
) )
); );
} }

View File

@ -627,7 +627,7 @@ fields/UniformGeometricFields/uniformGeometricFields.C
Fields = fields/Fields Fields = fields/Fields
$(Fields)/fieldMappers/directFieldMapper/directFieldMapper.C $(Fields)/fieldMappers/forwardFieldMapper/forwardFieldMapper.C
$(Fields)/fieldMappers/identityFieldMapper/identityFieldMapper.C $(Fields)/fieldMappers/identityFieldMapper/identityFieldMapper.C
$(Fields)/fieldMappers/generalFieldMapper/generalFieldMapper.C $(Fields)/fieldMappers/generalFieldMapper/generalFieldMapper.C
$(Fields)/fieldMappers/reverseFieldMapper/reverseFieldMapper.C $(Fields)/fieldMappers/reverseFieldMapper/reverseFieldMapper.C

View File

@ -23,12 +23,12 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "directFieldMapper.H" #include "forwardFieldMapper.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::directFieldMapper::map void Foam::forwardFieldMapper::map
( (
Field<Type>& f, Field<Type>& f,
const Field<Type>& mapF const Field<Type>& mapF
@ -46,7 +46,7 @@ void Foam::directFieldMapper::map
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::directFieldMapper::map Foam::tmp<Foam::Field<Type>> Foam::forwardFieldMapper::map
( (
const Field<Type>& mapF const Field<Type>& mapF
) const ) const
@ -59,10 +59,10 @@ Foam::tmp<Foam::Field<Type>> Foam::directFieldMapper::map
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
FOR_ALL_FIELD_TYPES(IMPLEMENT_FIELD_MAPPER_OPERATOR, directFieldMapper) FOR_ALL_FIELD_TYPES(IMPLEMENT_FIELD_MAPPER_OPERATOR, forwardFieldMapper)
IMPLEMENT_FIELD_MAPPER_OPERATOR(label, directFieldMapper) IMPLEMENT_FIELD_MAPPER_OPERATOR(label, forwardFieldMapper)
// ************************************************************************* // // ************************************************************************* //

View File

@ -22,15 +22,15 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::directFieldMapper Foam::forwardFieldMapper
Description Description
Direct field mapper Forward field mapper
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef directFieldMapper_H #ifndef forwardFieldMapper_H
#define directFieldMapper_H #define forwardFieldMapper_H
#include "fieldMapper.H" #include "fieldMapper.H"
@ -40,10 +40,10 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class directFieldMapper Declaration Class forwardFieldMapper Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class directFieldMapper class forwardFieldMapper
: :
public fieldMapper public fieldMapper
{ {
@ -52,7 +52,7 @@ class directFieldMapper
//- Addressing from new back to old //- Addressing from new back to old
const labelUList& addressing_; const labelUList& addressing_;
//- Does map contain any unmapped values //- Does map contain any unmapped values?
bool hasUnmapped_; bool hasUnmapped_;
@ -72,7 +72,7 @@ public:
// Constructors // Constructors
//- Construct given addressing //- Construct given addressing
directFieldMapper(const labelUList& addressing) forwardFieldMapper(const labelUList& addressing)
: :
addressing_(addressing), addressing_(addressing),
hasUnmapped_(false) hasUnmapped_(false)
@ -85,7 +85,7 @@ public:
//- Destructor //- Destructor
virtual ~directFieldMapper() virtual ~forwardFieldMapper()
{} {}

View File

@ -26,7 +26,7 @@ License
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "pointFields.H" #include "pointFields.H"
#include "directFieldMapper.H" #include "forwardFieldMapper.H"
#include "reverseFieldMapper.H" #include "reverseFieldMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -156,7 +156,7 @@ void Foam::fvMeshAdder::MapVolField
bfld[newPatchi], // old field bfld[newPatchi], // old field
mesh.boundary()[newPatchi], // new fvPatch mesh.boundary()[newPatchi], // new fvPatch
fld(), // new internal field fld(), // new internal field
directFieldMapper(newToOld) // mapper (new to old) forwardFieldMapper(newToOld) // mapper (new to old)
) )
); );
} }
@ -208,7 +208,7 @@ void Foam::fvMeshAdder::MapVolField
fldToAdd.boundaryField()[patchi], // added field fldToAdd.boundaryField()[patchi], // added field
mesh.boundary()[newPatchi], // new fvPatch mesh.boundary()[newPatchi], // new fvPatch
fld(), // new int. field fld(), // new int. field
directFieldMapper(newToAdded) // mapper forwardFieldMapper(newToAdded) // mapper
) )
); );
} }
@ -447,7 +447,7 @@ void Foam::fvMeshAdder::MapSurfaceField
bfld[newPatchi], // old field bfld[newPatchi], // old field
mesh.boundary()[newPatchi], // new fvPatch mesh.boundary()[newPatchi], // new fvPatch
fld(), // new internal field fld(), // new internal field
directFieldMapper(newToOld) // mapper (new to old) forwardFieldMapper(newToOld) // mapper (new to old)
) )
); );
} }
@ -499,7 +499,7 @@ void Foam::fvMeshAdder::MapSurfaceField
fldToAdd.boundaryField()[patchi],// added field fldToAdd.boundaryField()[patchi],// added field
mesh.boundary()[newPatchi], // new fvPatch mesh.boundary()[newPatchi], // new fvPatch
fld(), // new int. field fld(), // new int. field
directFieldMapper(newToAdded) // mapper forwardFieldMapper(newToAdded) // mapper
) )
); );
} }
@ -734,7 +734,7 @@ void Foam::fvMeshAdder::MapPointField
bfld[newPatchi], // old field bfld[newPatchi], // old field
mesh.boundary()[newPatchi], // new pointPatch mesh.boundary()[newPatchi], // new pointPatch
fld(), // new internal field fld(), // new internal field
directFieldMapper(newToOld) // mapper (new to old) forwardFieldMapper(newToOld) // mapper (new to old)
) )
); );
} }
@ -798,7 +798,7 @@ void Foam::fvMeshAdder::MapPointField
fldToAdd.boundaryField()[patchi],// added field fldToAdd.boundaryField()[patchi],// added field
mesh.boundary()[newPatchi], // new pointPatch mesh.boundary()[newPatchi], // new pointPatch
fld(), // new int. field fld(), // new int. field
directFieldMapper(newToAdded) // mapper forwardFieldMapper(newToAdded) // mapper
) )
); );
} }

View File

@ -28,7 +28,7 @@ License
#include "internalFvsPatchField.H" #include "internalFvsPatchField.H"
#include "internalPointPatchField.H" #include "internalPointPatchField.H"
#include "internalFvPatchFields.H" #include "internalFvPatchFields.H"
#include "directFieldMapper.H" #include "forwardFieldMapper.H"
#include "flipOp.H" #include "flipOp.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -143,7 +143,7 @@ Foam::fvMeshSubset::interpolate
vf.boundaryField()[patchMap[patchi]], vf.boundaryField()[patchMap[patchi]],
subPatch, subPatch,
resF(), resF(),
directFieldMapper(directAddressing) forwardFieldMapper(directAddressing)
) )
); );
} }
@ -286,7 +286,7 @@ Foam::fvMeshSubset::interpolate
sf.boundaryField()[patchMap[patchi]], sf.boundaryField()[patchMap[patchi]],
subPatch, subPatch,
resF(), resF(),
directFieldMapper(directAddressing) forwardFieldMapper(directAddressing)
) )
); );
} }
@ -475,7 +475,7 @@ Foam::fvMeshSubset::interpolate
pf.boundaryField()[patchMap[patchi]], pf.boundaryField()[patchMap[patchi]],
subPatch, subPatch,
resF(), resF(),
directFieldMapper(directAddressing) forwardFieldMapper(directAddressing)
) )
); );
} }

View File

@ -25,7 +25,7 @@ License
#include "singleCellFvMesh.H" #include "singleCellFvMesh.H"
#include "calculatedFvPatchFields.H" #include "calculatedFvPatchFields.H"
#include "directFieldMapper.H" #include "identityFieldMapper.H"
#include "Time.H" #include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -125,8 +125,6 @@ tmp<VolField<Type>> singleCellFvMesh::interpolate
{ {
forAll(vf.boundaryField(), patchi) forAll(vf.boundaryField(), patchi)
{ {
labelList map(identityMap(vf.boundaryField()[patchi].size()));
bf.set bf.set
( (
patchi, patchi,
@ -135,7 +133,7 @@ tmp<VolField<Type>> singleCellFvMesh::interpolate
vf.boundaryField()[patchi], vf.boundaryField()[patchi],
boundary()[patchi], boundary()[patchi],
resF(), resF(),
directFieldMapper(map) identityFieldMapper()
) )
); );
} }

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvMeshToFvMesh.H" #include "fvMeshToFvMesh.H"
#include "directFieldMapper.H" #include "setSizeFieldMapper.H"
#include "identityFieldMapper.H" #include "identityFieldMapper.H"
#include "patchToPatchLeftOverFieldMapper.H" #include "patchToPatchLeftOverFieldMapper.H"
#include "patchToPatchNormalisedFieldMapper.H" #include "patchToPatchNormalisedFieldMapper.H"
@ -140,10 +140,7 @@ Foam::tmp<Foam::VolField<Type>> Foam::fvMeshToFvMesh::srcToTgt
srcFld.boundaryField()[srcPatchi], srcFld.boundaryField()[srcPatchi],
tgtMesh.boundary()[tgtPatchi], tgtMesh.boundary()[tgtPatchi],
DimensionedField<Type, volMesh>::null(), DimensionedField<Type, volMesh>::null(),
directFieldMapper setSizeFieldMapper(tgtMesh.boundary()[tgtPatchi].size())
(
labelList(tgtMesh.boundary()[tgtPatchi].size(), -1)
)
) )
); );
} }