ENH: use GeometricField type aliases in sampling and expressions

This commit is contained in:
Mark Olesen
2022-02-14 21:21:15 +01:00
parent a67f6bf7ae
commit 2a25b356b9
26 changed files with 311 additions and 433 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,9 +73,9 @@ Foam::meshToMesh::procMapMethodNames_
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>& field,
const VolumeField<sphericalTensor>& field,
const plusEqOp<sphericalTensor>& cop,
GeometricField<sphericalTensor, fvPatchField, volMesh>& result,
VolumeField<sphericalTensor>& result,
const bool secondOrder
) const
{
@ -86,9 +86,9 @@ void Foam::meshToMesh::mapInternalSrcToTgt
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>& field,
const VolumeField<sphericalTensor>& field,
const minusEqOp<sphericalTensor>& cop,
GeometricField<sphericalTensor, fvPatchField, volMesh>& result,
VolumeField<sphericalTensor>& result,
const bool secondOrder
) const
{
@ -99,9 +99,9 @@ void Foam::meshToMesh::mapInternalSrcToTgt
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<symmTensor, fvPatchField, volMesh>& field,
const VolumeField<symmTensor>& field,
const plusEqOp<symmTensor>& cop,
GeometricField<symmTensor, fvPatchField, volMesh>& result,
VolumeField<symmTensor>& result,
const bool secondOrder
) const
{
@ -112,9 +112,9 @@ void Foam::meshToMesh::mapInternalSrcToTgt
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<symmTensor, fvPatchField, volMesh>& field,
const VolumeField<symmTensor>& field,
const minusEqOp<symmTensor>& cop,
GeometricField<symmTensor, fvPatchField, volMesh>& result,
VolumeField<symmTensor>& result,
const bool secondOrder
) const
{
@ -125,9 +125,9 @@ void Foam::meshToMesh::mapInternalSrcToTgt
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<tensor, fvPatchField, volMesh>& field,
const VolumeField<tensor>& field,
const plusEqOp<tensor>& cop,
GeometricField<tensor, fvPatchField, volMesh>& result,
VolumeField<tensor>& result,
const bool secondOrder
) const
{
@ -138,9 +138,9 @@ void Foam::meshToMesh::mapInternalSrcToTgt
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<tensor, fvPatchField, volMesh>& field,
const VolumeField<tensor>& field,
const minusEqOp<tensor>& cop,
GeometricField<tensor, fvPatchField, volMesh>& result,
VolumeField<tensor>& result,
const bool secondOrder
) const
{
@ -151,9 +151,9 @@ void Foam::meshToMesh::mapInternalSrcToTgt
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>& field,
const VolumeField<sphericalTensor>& field,
const plusEqOp<sphericalTensor>& cop,
GeometricField<sphericalTensor, fvPatchField, volMesh>& result,
VolumeField<sphericalTensor>& result,
const bool secondOrder
) const
{
@ -164,9 +164,9 @@ void Foam::meshToMesh::mapInternalTgtToSrc
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>& field,
const VolumeField<sphericalTensor>& field,
const minusEqOp<sphericalTensor>& cop,
GeometricField<sphericalTensor, fvPatchField, volMesh>& result,
VolumeField<sphericalTensor>& result,
const bool secondOrder
) const
{
@ -177,9 +177,9 @@ void Foam::meshToMesh::mapInternalTgtToSrc
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<symmTensor, fvPatchField, volMesh>& field,
const VolumeField<symmTensor>& field,
const plusEqOp<symmTensor>& cop,
GeometricField<symmTensor, fvPatchField, volMesh>& result,
VolumeField<symmTensor>& result,
const bool secondOrder
) const
{
@ -190,9 +190,9 @@ void Foam::meshToMesh::mapInternalTgtToSrc
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<symmTensor, fvPatchField, volMesh>& field,
const VolumeField<symmTensor>& field,
const minusEqOp<symmTensor>& cop,
GeometricField<symmTensor, fvPatchField, volMesh>& result,
VolumeField<symmTensor>& result,
const bool secondOrder
) const
{
@ -203,9 +203,9 @@ void Foam::meshToMesh::mapInternalTgtToSrc
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<tensor, fvPatchField, volMesh>& field,
const VolumeField<tensor>& field,
const plusEqOp<tensor>& cop,
GeometricField<tensor, fvPatchField, volMesh>& result,
VolumeField<tensor>& result,
const bool secondOrder
) const
{
@ -216,9 +216,9 @@ void Foam::meshToMesh::mapInternalTgtToSrc
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<tensor, fvPatchField, volMesh>& field,
const VolumeField<tensor>& field,
const minusEqOp<tensor>& cop,
GeometricField<tensor, fvPatchField, volMesh>& result,
VolumeField<tensor>& result,
const bool secondOrder
) const
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,8 +42,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef meshToMesh_H
#define meshToMesh_H
#ifndef Foam_meshToMesh_H
#define Foam_meshToMesh_H
#include "polyMesh.H"
#include "treeBoundBox.H"
@ -159,9 +159,9 @@ private:
template<class Type, class CombineOp>
void mapInternalSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
VolumeField<Type>& result,
const bool secondOrder
) const;
@ -170,9 +170,9 @@ private:
template<class Type, class CombineOp>
void mapInternalTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
VolumeField<Type>& result,
const bool secondOrder
) const;
@ -550,18 +550,18 @@ public:
template<class Type, class CombineOp>
void mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
VolumeField<Type>& result,
const bool secondOrder = true
) const;
//- Interpolate a field with a defined operation. The initial
// values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt
tmp<VolumeField<Type>> mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
const bool secondOrder = true
) const;
@ -569,10 +569,9 @@ public:
//- Interpolate a tmp field with a defined operation. The
// initial values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt
tmp<VolumeField<Type>> mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>&
tfield,
const tmp<VolumeField<Type>>& tfield,
const CombineOp& cop,
const bool secondOrder = true
) const;
@ -580,19 +579,18 @@ public:
//- Convenience function to map a field with a default
// operation (plusEqOp)
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt
tmp<VolumeField<Type>> mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const bool secondOrder = true
) const;
//- Convenience function to map a tmp field with a default
// operation (plusEqOp)
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt
tmp<VolumeField<Type>> mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>&
tfield,
const tmp<VolumeField<Type>>& tfield,
const bool secondOrder = true
) const;
@ -606,18 +604,18 @@ public:
template<class Type, class CombineOp>
void mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
VolumeField<Type>& result,
const bool secondOrder = true
) const;
//- Interpolate a field with a defined operation. The initial
// values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc
tmp<VolumeField<Type>> mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
const bool secondOrder = true
) const;
@ -625,9 +623,9 @@ public:
//- Interpolate a tmp field with a defined operation. The
// initial values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc
tmp<VolumeField<Type>> mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>&
const tmp<VolumeField<Type>>&
tfield,
const CombineOp& cop,
const bool secondOrder = true
@ -636,19 +634,18 @@ public:
//- Convenience function to map a field with a default
// operation (plusEqOp)
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc
tmp<VolumeField<Type>> mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const bool secondOrder = true
) const;
//- Convenience function to map a tmp field with a default
// operation (plusEqOp)
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc
tmp<VolumeField<Type>> mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>&
tfield,
const tmp<VolumeField<Type>>& tfield,
const bool secondOrder = true
) const;
};
@ -661,97 +658,97 @@ public:
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const VolumeField<sphericalTensor>&,
const plusEqOp<sphericalTensor>&,
GeometricField<sphericalTensor, fvPatchField, volMesh>&,
VolumeField<sphericalTensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const VolumeField<sphericalTensor>&,
const minusEqOp<sphericalTensor>&,
GeometricField<sphericalTensor, fvPatchField, volMesh>&,
VolumeField<sphericalTensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<symmTensor, fvPatchField, volMesh>&,
const VolumeField<symmTensor>&,
const plusEqOp<symmTensor>&,
GeometricField<symmTensor, fvPatchField, volMesh>&,
VolumeField<symmTensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<symmTensor, fvPatchField, volMesh>&,
const VolumeField<symmTensor>&,
const minusEqOp<symmTensor>&,
GeometricField<symmTensor, fvPatchField, volMesh>&,
VolumeField<symmTensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<tensor, fvPatchField, volMesh>&,
const VolumeField<tensor>&,
const plusEqOp<tensor>&,
GeometricField<tensor, fvPatchField, volMesh>&,
VolumeField<tensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<tensor, fvPatchField, volMesh>&,
const VolumeField<tensor>&,
const minusEqOp<tensor>&,
GeometricField<tensor, fvPatchField, volMesh>&,
VolumeField<tensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const VolumeField<sphericalTensor>&,
const plusEqOp<sphericalTensor>&,
GeometricField<sphericalTensor, fvPatchField, volMesh>&,
VolumeField<sphericalTensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const VolumeField<sphericalTensor>&,
const minusEqOp<sphericalTensor>&,
GeometricField<sphericalTensor, fvPatchField, volMesh>&,
VolumeField<sphericalTensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<symmTensor, fvPatchField, volMesh>&,
const VolumeField<symmTensor>&,
const plusEqOp<symmTensor>&,
GeometricField<symmTensor, fvPatchField, volMesh>&,
VolumeField<symmTensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<symmTensor, fvPatchField, volMesh>&,
const VolumeField<symmTensor>&,
const minusEqOp<symmTensor>&,
GeometricField<symmTensor, fvPatchField, volMesh>&,
VolumeField<symmTensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<tensor, fvPatchField, volMesh>&,
const VolumeField<tensor>&,
const plusEqOp<tensor>&,
GeometricField<tensor, fvPatchField, volMesh>&,
VolumeField<tensor>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<tensor, fvPatchField, volMesh>&,
const VolumeField<tensor>&,
const minusEqOp<tensor>&,
GeometricField<tensor, fvPatchField, volMesh>&,
VolumeField<tensor>&,
const bool
) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2015 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -472,9 +472,9 @@ Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc
template<class Type, class CombineOp>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
VolumeField<Type>& result,
const bool secondOrder
) const
{
@ -519,9 +519,9 @@ void Foam::meshToMesh::mapAndOpSrcToTgt
template<class Type, class CombineOp>
void Foam::meshToMesh::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
VolumeField<Type>& result,
const bool secondOrder
) const
{
@ -529,8 +529,7 @@ void Foam::meshToMesh::mapSrcToTgt
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
typename GeometricField<Type, fvPatchField, volMesh>::
Boundary& resultBf = result.boundaryFieldRef();
auto& resultBf = result.boundaryFieldRef();
forAll(AMIList, i)
{
@ -581,21 +580,18 @@ void Foam::meshToMesh::mapSrcToTgt
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::tmp<Foam::VolumeField<Type>>
Foam::meshToMesh::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
const bool secondOrder
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& tgtMesh = static_cast<const fvMesh&>(tgtRegion_);
const fvBoundaryMesh& tgtBm = tgtMesh.boundary();
const typename fieldType::Boundary& srcBfld =
field.boundaryField();
const auto& srcBfld = field.boundaryField();
PtrList<fvPatchField<Type>> tgtPatchFields(tgtBm.size());
@ -646,9 +642,8 @@ Foam::meshToMesh::mapSrcToTgt
}
}
tmp<fieldType> tresult
(
new fieldType
auto tresult =
tmp<VolumeField<Type>>::New
(
IOobject
(
@ -662,8 +657,7 @@ Foam::meshToMesh::mapSrcToTgt
field.dimensions(),
Field<Type>(tgtMesh.nCells(), Zero),
tgtPatchFields
)
);
);
mapSrcToTgt(field, cop, tresult.ref(), secondOrder);
@ -672,10 +666,10 @@ Foam::meshToMesh::mapSrcToTgt
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::tmp<Foam::VolumeField<Type>>
Foam::meshToMesh::mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield,
const tmp<VolumeField<Type>>& tfield,
const CombineOp& cop,
const bool secondOrder
) const
@ -685,10 +679,10 @@ Foam::meshToMesh::mapSrcToTgt
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::tmp<Foam::VolumeField<Type>>
Foam::meshToMesh::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const bool secondOrder
) const
{
@ -697,10 +691,10 @@ Foam::meshToMesh::mapSrcToTgt
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::tmp<Foam::VolumeField<Type>>
Foam::meshToMesh::mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield,
const tmp<VolumeField<Type>>& tfield,
const bool secondOrder
) const
{
@ -711,9 +705,9 @@ Foam::meshToMesh::mapSrcToTgt
template<class Type, class CombineOp>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
VolumeField<Type>& result,
const bool secondOrder
) const
{
@ -758,9 +752,9 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
template<class Type, class CombineOp>
void Foam::meshToMesh::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
VolumeField<Type>& result,
const bool secondOrder
) const
{
@ -817,21 +811,18 @@ void Foam::meshToMesh::mapTgtToSrc
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::tmp<Foam::VolumeField<Type>>
Foam::meshToMesh::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const CombineOp& cop,
const bool secondOrder
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& srcMesh = static_cast<const fvMesh&>(srcRegion_);
const fvBoundaryMesh& srcBm = srcMesh.boundary();
const typename fieldType::Boundary& tgtBfld =
field.boundaryField();
const auto& tgtBfld = field.boundaryField();
PtrList<fvPatchField<Type>> srcPatchFields(srcBm.size());
@ -882,9 +873,8 @@ Foam::meshToMesh::mapTgtToSrc
}
}
tmp<fieldType> tresult
(
new fieldType
auto tresult =
tmp<VolumeField<Type>>::New
(
IOobject
(
@ -898,8 +888,7 @@ Foam::meshToMesh::mapTgtToSrc
field.dimensions(),
Field<Type>(srcMesh.nCells(), Zero),
srcPatchFields
)
);
);
mapTgtToSrc(field, cop, tresult.ref(), secondOrder);
@ -908,10 +897,10 @@ Foam::meshToMesh::mapTgtToSrc
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::tmp<Foam::VolumeField<Type>>
Foam::meshToMesh::mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield,
const tmp<VolumeField<Type>>& tfield,
const CombineOp& cop,
const bool secondOrder
) const
@ -921,10 +910,10 @@ Foam::meshToMesh::mapTgtToSrc
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::tmp<Foam::VolumeField<Type>>
Foam::meshToMesh::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const VolumeField<Type>& field,
const bool secondOrder
) const
{
@ -933,10 +922,10 @@ Foam::meshToMesh::mapTgtToSrc
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::tmp<Foam::VolumeField<Type>>
Foam::meshToMesh::mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield,
const tmp<VolumeField<Type>>& tfield,
const bool secondOrder
) const
{