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),
directFieldMapper(static_cast<const labelList&>(*this))
forwardFieldMapper(static_cast<const labelList&>(*this))
{}

View File

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

View File

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

View File

@ -38,7 +38,7 @@ SourceFiles
#include "pointMesh.H"
#include "pointFields.H"
#include "generalFieldMapper.H"
#include "forwardFieldMapper.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -61,51 +61,31 @@ public:
//- Point patch field decomposer class
class patchFieldDecomposer
:
public generalFieldMapper
public labelList,
public forwardFieldMapper
{
// Private Data
// Private Member Functions
//- ...
labelList directAddressing_;
//- Does map contain any unmapped values?
bool hasUnmapped_;
//- Generate the addressing
static labelList addressing
(
const pointPatch& completePatch,
const pointPatch& procPatch,
const labelList& pointProcAddressing
);
public:
// Constructors
//- Construct given addressing
//- Construct given patches and addressing
patchFieldDecomposer
(
const pointPatch& completeMeshPatch,
const pointPatch& procMeshPatch,
const labelList& directAddr
const pointPatch& completePatch,
const pointPatch& procPatch,
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 "HashTable.H"
#include "generalFieldMapper.H"
#include "scalarList.H"
#include "className.H"
@ -176,54 +175,6 @@ public:
~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
// Access

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

View File

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

View File

@ -23,12 +23,12 @@ License
\*---------------------------------------------------------------------------*/
#include "directFieldMapper.H"
#include "forwardFieldMapper.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::directFieldMapper::map
void Foam::forwardFieldMapper::map
(
Field<Type>& f,
const Field<Type>& mapF
@ -46,7 +46,7 @@ void Foam::directFieldMapper::map
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::directFieldMapper::map
Foam::tmp<Foam::Field<Type>> Foam::forwardFieldMapper::map
(
const Field<Type>& mapF
) const
@ -59,10 +59,10 @@ Foam::tmp<Foam::Field<Type>> Foam::directFieldMapper::map
// * * * * * * * * * * * * * * * 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/>.
Class
Foam::directFieldMapper
Foam::forwardFieldMapper
Description
Direct field mapper
Forward field mapper
\*---------------------------------------------------------------------------*/
#ifndef directFieldMapper_H
#define directFieldMapper_H
#ifndef forwardFieldMapper_H
#define forwardFieldMapper_H
#include "fieldMapper.H"
@ -40,10 +40,10 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class directFieldMapper Declaration
Class forwardFieldMapper Declaration
\*---------------------------------------------------------------------------*/
class directFieldMapper
class forwardFieldMapper
:
public fieldMapper
{
@ -52,7 +52,7 @@ class directFieldMapper
//- Addressing from new back to old
const labelUList& addressing_;
//- Does map contain any unmapped values
//- Does map contain any unmapped values?
bool hasUnmapped_;
@ -72,7 +72,7 @@ public:
// Constructors
//- Construct given addressing
directFieldMapper(const labelUList& addressing)
forwardFieldMapper(const labelUList& addressing)
:
addressing_(addressing),
hasUnmapped_(false)
@ -85,7 +85,7 @@ public:
//- Destructor
virtual ~directFieldMapper()
virtual ~forwardFieldMapper()
{}

View File

@ -26,7 +26,7 @@ License
#include "volFields.H"
#include "surfaceFields.H"
#include "pointFields.H"
#include "directFieldMapper.H"
#include "forwardFieldMapper.H"
#include "reverseFieldMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -156,7 +156,7 @@ void Foam::fvMeshAdder::MapVolField
bfld[newPatchi], // old field
mesh.boundary()[newPatchi], // new fvPatch
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
mesh.boundary()[newPatchi], // new fvPatch
fld(), // new int. field
directFieldMapper(newToAdded) // mapper
forwardFieldMapper(newToAdded) // mapper
)
);
}
@ -447,7 +447,7 @@ void Foam::fvMeshAdder::MapSurfaceField
bfld[newPatchi], // old field
mesh.boundary()[newPatchi], // new fvPatch
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
mesh.boundary()[newPatchi], // new fvPatch
fld(), // new int. field
directFieldMapper(newToAdded) // mapper
forwardFieldMapper(newToAdded) // mapper
)
);
}
@ -734,7 +734,7 @@ void Foam::fvMeshAdder::MapPointField
bfld[newPatchi], // old field
mesh.boundary()[newPatchi], // new pointPatch
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
mesh.boundary()[newPatchi], // new pointPatch
fld(), // new int. field
directFieldMapper(newToAdded) // mapper
forwardFieldMapper(newToAdded) // mapper
)
);
}

View File

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

View File

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

View File

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