mapFields, mapFieldsPar: Removed the subtract option and supporting complexity in meshToMesh0 and meshToMesh

The subtract option in mapFieldsPar was not implemented correctly and the
significant complexity in meshToMesh required to support it creates an
unwarranted maintenance overhead.  The equivalent functionality is now provided
by the more flexible, convenient and simpler subtract functionObject.
This commit is contained in:
Henry Weller
2022-03-15 23:21:32 +00:00
parent e9608d8f0f
commit 08b7a94452
18 changed files with 468 additions and 766 deletions

View File

@ -1,4 +1,5 @@
mapLagrangian.C mapLagrangian.C
mapMeshes.C
mapFields.C mapFields.C
EXE = $(FOAM_APPBIN)/mapFields EXE = $(FOAM_APPBIN)/mapFields

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
@ -35,13 +35,12 @@ License
namespace Foam namespace Foam
{ {
template<class Type, class CombineOp> template<class Type>
void MapConsistentVolFields void MapConsistentVolFields
( (
const IOobjectList& objects, const IOobjectList& objects,
const meshToMesh0& meshToMesh0Interp, const meshToMesh0& meshToMesh0Interp,
const meshToMesh0::order& mapOrder, const meshToMesh0::order& mapOrder
const CombineOp& cop
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
@ -78,12 +77,11 @@ void MapConsistentVolFields
); );
// Interpolate field // Interpolate field
meshToMesh0Interp.interpolate meshToMesh0Interp.interpolate<Type>
( (
fieldTarget, fieldTarget,
fieldSource, fieldSource,
mapOrder, mapOrder
cop
); );
// Write field // Write field
@ -100,8 +98,7 @@ void MapConsistentVolFields
meshToMesh0Interp.interpolate meshToMesh0Interp.interpolate
( (
fieldSource, fieldSource,
mapOrder, mapOrder
cop
) )
); );

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
@ -35,13 +35,12 @@ License
namespace Foam namespace Foam
{ {
template<class Type, class CombineOp> template<class Type>
void MapVolFields void MapVolFields
( (
const IOobjectList& objects, const IOobjectList& objects,
const meshToMesh0& meshToMesh0Interp, const meshToMesh0& meshToMesh0Interp,
const meshToMesh0::order& mapOrder, const meshToMesh0::order& mapOrder
const CombineOp& cop
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
@ -81,8 +80,7 @@ void MapVolFields
( (
fieldTarget, fieldTarget,
fieldSource, fieldSource,
mapOrder, mapOrder
cop
); );
// Write field // Write field

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
@ -33,148 +33,11 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
#include "fvMesh.H" #include "mapMeshes.H"
#include "surfaceMesh.H"
#include "decompositionMethod.H" #include "decompositionMethod.H"
#include "meshToMesh0.H"
#include "processorFvPatch.H"
#include "MapMeshes.H"
using namespace Foam; using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const meshToMesh0::order& mapOrder,
const bool subtract
)
{
if (subtract)
{
MapConsistentMesh<minusEqOp>
(
meshSource,
meshTarget,
mapOrder
);
}
else
{
MapConsistentMesh<eqOp>
(
meshSource,
meshTarget,
mapOrder
);
}
}
void mapSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches,
const meshToMesh0::order& mapOrder,
const bool subtract
)
{
if (subtract)
{
MapSubMesh<minusEqOp>
(
meshSource,
meshTarget,
patchMap,
cuttingPatches,
mapOrder
);
}
else
{
MapSubMesh<eqOp>
(
meshSource,
meshTarget,
patchMap,
cuttingPatches,
mapOrder
);
}
}
void mapConsistentSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const meshToMesh0::order& mapOrder,
const bool subtract
)
{
if (subtract)
{
MapConsistentSubMesh<minusEqOp>
(
meshSource,
meshTarget,
mapOrder
);
}
else
{
MapConsistentSubMesh<eqOp>
(
meshSource,
meshTarget,
mapOrder
);
}
}
wordList addProcessorPatches
(
const fvMesh& meshTarget,
const wordList& cuttingPatches
)
{
// Add the processor patches to the cutting list
HashTable<label> cuttingPatchTable;
forAll(cuttingPatches, i)
{
cuttingPatchTable.insert(cuttingPatches[i], i);
}
forAll(meshTarget.boundary(), patchi)
{
if (isA<processorFvPatch>(meshTarget.boundary()[patchi]))
{
if
(
!cuttingPatchTable.found
(
meshTarget.boundaryMesh()[patchi].name()
)
)
{
cuttingPatchTable.insert
(
meshTarget.boundaryMesh()[patchi].name(),
-1
);
}
}
}
return cuttingPatchTable.toc();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -225,11 +88,6 @@ int main(int argc, char *argv[])
"word", "word",
"specify the mapping method" "specify the mapping method"
); );
argList::addBoolOption
(
"subtract",
"subtract mapped source from target"
);
argList args(argc, argv); argList args(argc, argv);
@ -292,12 +150,6 @@ int main(int argc, char *argv[])
Info<< "Mapping method: " << mapMethod << endl; Info<< "Mapping method: " << mapMethod << endl;
} }
const bool subtract = args.optionFound("subtract");
if (subtract)
{
Info<< "Subtracting mapped source field from target" << endl;
}
#include "createTimes.H" #include "createTimes.H"
@ -380,8 +232,7 @@ int main(int argc, char *argv[])
( (
meshSource, meshSource,
meshTarget, meshTarget,
mapOrder, mapOrder
subtract
); );
} }
else else
@ -392,8 +243,7 @@ int main(int argc, char *argv[])
meshTarget, meshTarget,
patchMap, patchMap,
cuttingPatches, cuttingPatches,
mapOrder, mapOrder
subtract
); );
} }
} }
@ -455,8 +305,7 @@ int main(int argc, char *argv[])
( (
meshSource, meshSource,
meshTarget, meshTarget,
mapOrder, mapOrder
subtract
); );
} }
else else
@ -467,8 +316,7 @@ int main(int argc, char *argv[])
meshTarget, meshTarget,
patchMap, patchMap,
addProcessorPatches(meshTarget, cuttingPatches), addProcessorPatches(meshTarget, cuttingPatches),
mapOrder, mapOrder
subtract
); );
} }
} }
@ -567,8 +415,7 @@ int main(int argc, char *argv[])
( (
meshSource, meshSource,
meshTarget, meshTarget,
mapOrder, mapOrder
subtract
); );
} }
else else
@ -579,8 +426,7 @@ int main(int argc, char *argv[])
meshTarget, meshTarget,
patchMap, patchMap,
addProcessorPatches(meshTarget, cuttingPatches), addProcessorPatches(meshTarget, cuttingPatches),
mapOrder, mapOrder
subtract
); );
} }
} }
@ -621,7 +467,7 @@ int main(int argc, char *argv[])
if (consistent) if (consistent)
{ {
mapConsistentMesh(meshSource, meshTarget, mapOrder, subtract); mapConsistentMesh(meshSource, meshTarget, mapOrder);
} }
else else
{ {
@ -631,8 +477,7 @@ int main(int argc, char *argv[])
meshTarget, meshTarget,
patchMap, patchMap,
cuttingPatches, cuttingPatches,
mapOrder, mapOrder
subtract
); );
} }
} }

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-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,21 +23,17 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef MapMeshes_H #include "mapMeshes.H"
#define MapMeshes_H #include "surfaceMesh.H"
#include "processorFvPatch.H"
#include "mapLagrangian.H"
#include "MapVolFields.H" #include "MapVolFields.H"
#include "MapConsistentVolFields.H" #include "MapConsistentVolFields.H"
#include "mapLagrangian.H"
#include "UnMapped.H" #include "UnMapped.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam void Foam::mapConsistentMesh
{
template<template<class> class CombineOp>
void MapConsistentMesh
( (
const fvMesh& meshSource, const fvMesh& meshSource,
const fvMesh& meshTarget, const fvMesh& meshTarget,
@ -61,36 +57,31 @@ void MapConsistentMesh
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<scalar>()
); );
MapConsistentVolFields<vector> MapConsistentVolFields<vector>
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<vector>()
); );
MapConsistentVolFields<sphericalTensor> MapConsistentVolFields<sphericalTensor>
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<sphericalTensor>()
); );
MapConsistentVolFields<symmTensor> MapConsistentVolFields<symmTensor>
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<symmTensor>()
); );
MapConsistentVolFields<tensor> MapConsistentVolFields<tensor>
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<tensor>()
); );
} }
@ -119,8 +110,7 @@ void MapConsistentMesh
} }
template<template<class> class CombineOp> void Foam::mapSubMesh
void MapSubMesh
( (
const fvMesh& meshSource, const fvMesh& meshSource,
const fvMesh& meshTarget, const fvMesh& meshTarget,
@ -152,36 +142,31 @@ void MapSubMesh
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<scalar>()
); );
MapVolFields<vector> MapVolFields<vector>
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<vector>()
); );
MapVolFields<sphericalTensor> MapVolFields<sphericalTensor>
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<sphericalTensor>()
); );
MapVolFields<symmTensor> MapVolFields<symmTensor>
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<symmTensor>()
); );
MapVolFields<tensor> MapVolFields<tensor>
( (
objects, objects,
meshToMesh0Interp, meshToMesh0Interp,
mapOrder, mapOrder
CombineOp<tensor>()
); );
} }
@ -210,8 +195,7 @@ void MapSubMesh
} }
template<template<class> class CombineOp> void Foam::mapConsistentSubMesh
void MapConsistentSubMesh
( (
const fvMesh& meshSource, const fvMesh& meshSource,
const fvMesh& meshTarget, const fvMesh& meshTarget,
@ -241,7 +225,7 @@ void MapConsistentSubMesh
} }
} }
MapSubMesh<CombineOp> mapSubMesh
( (
meshSource, meshSource,
meshTarget, meshTarget,
@ -252,12 +236,42 @@ void MapConsistentSubMesh
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Foam::wordList Foam::addProcessorPatches
(
const fvMesh& meshTarget,
const wordList& cuttingPatches
)
{
// Add the processor patches to the cutting list
HashTable<label> cuttingPatchTable;
forAll(cuttingPatches, i)
{
cuttingPatchTable.insert(cuttingPatches[i], i);
}
} // End namespace Foam forAll(meshTarget.boundary(), patchi)
{
if (isA<processorFvPatch>(meshTarget.boundary()[patchi]))
{
if
(
!cuttingPatchTable.found
(
meshTarget.boundaryMesh()[patchi].name()
)
)
{
cuttingPatchTable.insert
(
meshTarget.boundaryMesh()[patchi].name(),
-1
);
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // return cuttingPatchTable.toc();
}
#endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,78 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef mapMeshes_H
#define mapMeshes_H
#include "meshToMesh0.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const meshToMesh0::order& mapOrder
);
void mapSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches,
const meshToMesh0::order& mapOrder
);
void mapConsistentSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const meshToMesh0::order& mapOrder
);
wordList addProcessorPatches
(
const fvMesh& meshTarget,
const wordList& cuttingPatches
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,3 +1,4 @@
mapMeshes.C
mapLagrangian.C mapLagrangian.C
mapFieldsPar.C mapFieldsPar.C

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
@ -117,13 +117,12 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
} }
template<class Type, class CombineOp> template<class Type>
void MapVolFields void MapVolFields
( (
const IOobjectList& objects, const IOobjectList& objects,
const HashSet<word>& selectedFields, const HashSet<word>& selectedFields,
const meshToMesh& interp, const meshToMesh& interp
const CombineOp& cop
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
@ -155,7 +154,7 @@ void MapVolFields
<< fieldName << endl; << fieldName << endl;
fieldType fieldTarget(targetIO, meshTarget); fieldType fieldTarget(targetIO, meshTarget);
interp.mapSrcToTgt(fieldSource, cop, fieldTarget); interp.mapSrcToTgt(fieldSource, fieldTarget);
evaluateConstraintTypes(fieldTarget); evaluateConstraintTypes(fieldTarget);
@ -168,8 +167,7 @@ void MapVolFields
targetIO.readOpt() = IOobject::NO_READ; targetIO.readOpt() = IOobject::NO_READ;
tmp<fieldType> tmp<fieldType> tfieldTarget(interp.mapSrcToTgt(fieldSource));
tfieldTarget(interp.mapSrcToTgt(fieldSource, cop));
fieldType fieldTarget(targetIO, tfieldTarget); fieldType fieldTarget(targetIO, tfieldTarget);

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
@ -30,122 +30,11 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H" #include "argList.H"
#include "meshToMesh.H" #include "mapMeshes.H"
#include "cellVolumeWeightMethod.H" #include "cellVolumeWeightMethod.H"
#include "processorPolyPatch.H"
#include "MapMeshes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const word& mapMethod,
const bool subtract,
const HashSet<word>& selectedFields,
const bool noLagrangian
)
{
Info<< nl << "Consistently creating and mapping fields for time "
<< meshSource.time().timeName() << nl << endl;
meshToMesh interp(meshSource, meshTarget, mapMethod);
if (subtract)
{
MapMesh<minusEqOp>
(
interp,
selectedFields,
noLagrangian
);
}
else
{
MapMesh<plusEqOp>
(
interp,
selectedFields,
noLagrangian
);
}
}
void mapSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches,
const word& mapMethod,
const bool subtract,
const HashSet<word>& selectedFields,
const bool noLagrangian
)
{
Info<< nl << "Creating and mapping fields for time "
<< meshSource.time().timeName() << nl << endl;
meshToMesh interp
(
meshSource,
meshTarget,
mapMethod,
patchMap,
cuttingPatches
);
if (subtract)
{
MapMesh<minusEqOp>
(
interp,
selectedFields,
noLagrangian
);
}
else
{
MapMesh<plusEqOp>
(
interp,
selectedFields,
noLagrangian
);
}
}
wordList addProcessorPatches
(
const fvMesh& meshTarget,
const wordList& cuttingPatches
)
{
// Add the processor patches to the cutting list
HashSet<word> cuttingPatchTable;
forAll(cuttingPatches, i)
{
cuttingPatchTable.insert(cuttingPatches[i]);
}
const polyBoundaryMesh& pbm = meshTarget.boundaryMesh();
forAll(pbm, patchi)
{
if (isA<processorPolyPatch>(pbm[patchi]))
{
const word& patchName = pbm[patchi].name();
cuttingPatchTable.insert(patchName);
}
}
return cuttingPatchTable.toc();
}
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -187,11 +76,6 @@ int main(int argc, char *argv[])
"word", "word",
"specify the mapping method" "specify the mapping method"
); );
argList::addBoolOption
(
"subtract",
"subtract mapped source from target"
);
argList::addOption argList::addOption
( (
"fields", "fields",
@ -242,12 +126,6 @@ int main(int argc, char *argv[])
); );
Info<< "Mapping method: " << mapMethod << endl; Info<< "Mapping method: " << mapMethod << endl;
const bool subtract = args.optionFound("subtract");
if (subtract)
{
Info<< "Subtracting mapped source field from target" << endl;
}
HashSet<word> selectedFields; HashSet<word> selectedFields;
if (args.optionFound("fields")) if (args.optionFound("fields"))
{ {
@ -316,7 +194,6 @@ int main(int argc, char *argv[])
meshSource, meshSource,
meshTarget, meshTarget,
mapMethod, mapMethod,
subtract,
selectedFields, selectedFields,
noLagrangian noLagrangian
); );
@ -330,7 +207,6 @@ int main(int argc, char *argv[])
patchMap, patchMap,
cuttingPatches, cuttingPatches,
mapMethod, mapMethod,
subtract,
selectedFields, selectedFields,
noLagrangian noLagrangian
); );

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-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,21 +23,16 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef MapMeshes_H #include "mapMeshes.H"
#define MapMeshes_H #include "surfaceMesh.H"
#include "MapVolFields.H"
#include "mapLagrangian.H"
#include "UnMapped.H"
#include "pointMesh.H" #include "pointMesh.H"
#include "mapLagrangian.H"
#include "MapVolFields.H"
#include "UnMapped.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam void Foam::mapMesh
{
template<template<class> class CombineOp>
void MapMesh
( (
const meshToMesh& interp, const meshToMesh& interp,
const HashSet<word>& selectedFields, const HashSet<word>& selectedFields,
@ -56,37 +51,32 @@ void MapMesh
( (
objects, objects,
selectedFields, selectedFields,
interp, interp
CombineOp<scalar>()
); );
MapVolFields<vector> MapVolFields<vector>
( (
objects, objects,
selectedFields, selectedFields,
interp, interp
CombineOp<vector>()
); );
MapVolFields<sphericalTensor> MapVolFields<sphericalTensor>
( (
objects, objects,
selectedFields, selectedFields,
interp, interp
CombineOp<sphericalTensor>()
); );
MapVolFields<symmTensor> MapVolFields<symmTensor>
( (
objects, objects,
selectedFields, selectedFields,
interp, interp
CombineOp<symmTensor>()
); );
MapVolFields<tensor> MapVolFields<tensor>
( (
objects, objects,
selectedFields, selectedFields,
interp, interp
CombineOp<tensor>()
); );
} }
@ -120,12 +110,87 @@ void MapMesh
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // void Foam::mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const word& mapMethod,
const HashSet<word>& selectedFields,
const bool noLagrangian
)
{
Info<< nl << "Consistently creating and mapping fields for time "
<< meshSource.time().timeName() << nl << endl;
} // End namespace Foam meshToMesh interp(meshSource, meshTarget, mapMethod);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // mapMesh
(
interp,
selectedFields,
noLagrangian
);
}
void Foam::mapSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches,
const word& mapMethod,
const HashSet<word>& selectedFields,
const bool noLagrangian
)
{
Info<< nl << "Creating and mapping fields for time "
<< meshSource.time().timeName() << nl << endl;
meshToMesh interp
(
meshSource,
meshTarget,
mapMethod,
patchMap,
cuttingPatches
);
mapMesh
(
interp,
selectedFields,
noLagrangian
);
}
Foam::wordList Foam::addProcessorPatches
(
const fvMesh& meshTarget,
const wordList& cuttingPatches
)
{
// Add the processor patches to the cutting list
HashSet<word> cuttingPatchTable;
forAll(cuttingPatches, i)
{
cuttingPatchTable.insert(cuttingPatches[i]);
}
const polyBoundaryMesh& pbm = meshTarget.boundaryMesh();
forAll(pbm, patchi)
{
if (isA<processorPolyPatch>(pbm[patchi]))
{
const word& patchName = pbm[patchi].name();
cuttingPatchTable.insert(patchName);
}
}
return cuttingPatchTable.toc();
}
#endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef mapMeshes_H
#define mapMeshes_H
#include "meshToMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void mapMesh
(
const meshToMesh& interp,
const HashSet<word>& selectedFields,
const bool noLagrangian
);
void mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const word& mapMethod,
const HashSet<word>& selectedFields,
const bool noLagrangian
);
void mapSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches,
const word& mapMethod,
const HashSet<word>& selectedFields,
const bool noLagrangian
);
wordList addProcessorPatches
(
const fvMesh& meshTarget,
const wordList& cuttingPatches
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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
@ -81,12 +81,7 @@ Foam::fv::interRegionExplicitPorositySource::interRegionExplicitPorositySource
const fvMesh& nbrMesh = mesh.time().lookupObject<fvMesh>(nbrRegionName()); const fvMesh& nbrMesh = mesh.time().lookupObject<fvMesh>(nbrRegionName());
meshInterp().mapTgtToSrc meshInterp().mapTgtToSrc(scalarField(nbrMesh.nCells(), 1), filter_);
(
scalarField(nbrMesh.nCells(), 1),
plusEqOp<scalar>(),
filter_
);
const word zoneName(name + ":porous"); const word zoneName(name + ":porous");

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
@ -67,11 +67,11 @@ void Foam::fv::interRegionModel::interpolate
{ {
if (master()) if (master())
{ {
meshInterp().mapTgtToSrc(field, plusEqOp<scalar>(), result); meshInterp().mapTgtToSrc(field, result);
} }
else else
{ {
nbrModel.meshInterp().mapSrcToTgt(field, plusEqOp<scalar>(), result); nbrModel.meshInterp().mapSrcToTgt(field, result);
} }
} }

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
@ -43,8 +43,7 @@ void Foam::meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<scalar>& srcField, const Field<scalar>& srcField,
Field<scalar>& tgtField, Field<scalar>& tgtField
const plusEqOp<scalar>& cop
) const ) const
{} {}
@ -54,8 +53,7 @@ void Foam::meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<vector>& srcField, const Field<vector>& srcField,
Field<vector>& tgtField, Field<vector>& tgtField
const plusEqOp<vector>& cop
) const ) const
{} {}
@ -65,8 +63,7 @@ void Foam::meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<sphericalTensor>& srcField, const Field<sphericalTensor>& srcField,
Field<sphericalTensor>& tgtField, Field<sphericalTensor>& tgtField
const plusEqOp<sphericalTensor>& cop
) const ) const
{} {}
@ -76,8 +73,7 @@ void Foam::meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<symmTensor>& srcField, const Field<symmTensor>& srcField,
Field<symmTensor>& tgtField, Field<symmTensor>& tgtField
const plusEqOp<symmTensor>& cop
) const ) const
{} {}
@ -87,8 +83,7 @@ void Foam::meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<tensor>& srcField, const Field<tensor>& srcField,
Field<tensor>& tgtField, Field<tensor>& tgtField
const plusEqOp<tensor>& cop
) const ) const
{} {}
@ -98,8 +93,7 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<scalar>& srcField, Field<scalar>& srcField,
const Field<scalar>& tgtField, const Field<scalar>& tgtField
const plusEqOp<scalar>& cop
) const ) const
{} {}
@ -109,8 +103,7 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<vector>& srcField, Field<vector>& srcField,
const Field<vector>& tgtField, const Field<vector>& tgtField
const plusEqOp<vector>& cop
) const ) const
{} {}
@ -120,8 +113,7 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<sphericalTensor>& srcField, Field<sphericalTensor>& srcField,
const Field<sphericalTensor>& tgtField, const Field<sphericalTensor>& tgtField
const plusEqOp<sphericalTensor>& cop
) const ) const
{} {}
@ -131,8 +123,7 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<symmTensor>& srcField, Field<symmTensor>& srcField,
const Field<symmTensor>& tgtField, const Field<symmTensor>& tgtField
const plusEqOp<symmTensor>& cop
) const ) const
{} {}
@ -142,8 +133,7 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<tensor>& srcField, Field<tensor>& srcField,
const Field<tensor>& tgtField, const Field<tensor>& tgtField
const plusEqOp<tensor>& cop
) const ) const
{} {}

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
@ -114,24 +114,22 @@ class meshToMesh
//- Helper function to interpolate patch field. Template //- Helper function to interpolate patch field. Template
// specialisations below // specialisations below
template<class Type, class CombineOp> template<class Type>
void mapAndOpSrcToTgt void mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<Type>& srcField, const Field<Type>& srcField,
Field<Type>& tgtField, Field<Type>& tgtField
const CombineOp& cop
) const; ) const;
//- Helper function to interpolate patch field. Template //- Helper function to interpolate patch field. Template
// specialisations below // specialisations below
template<class Type, class CombineOp> template<class Type>
void mapAndOpTgtToSrc void mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<Type>& srcField, Field<Type>& srcField,
const Field<Type>& tgtField, const Field<Type>& tgtField
const CombineOp& cop
) const; ) const;
//- Return src cell IDs for the overlap region //- Return src cell IDs for the overlap region
@ -302,34 +300,15 @@ public:
//- Map field from src to tgt mesh with defined operation //- Map field from src to tgt mesh with defined operation
// Values passed in via 'result' are used to initialise the // Values passed in via 'result' are used to initialise the
// return value // return value
template<class Type, class CombineOp> template<class Type>
void mapSrcToTgt void mapSrcToTgt
( (
const UList<Type>& srcFld, const UList<Type>& srcFld,
const CombineOp& cop,
List<Type>& result List<Type>& result
) const; ) const;
//- Return the src field mapped to the tgt mesh with a defined //- Return the src field mapped to the tgt mesh with a defined
// operation. Initial values of the result are set to zero // operation. Initial values of the result are set to zero
template<class Type, class CombineOp>
tmp<Field<Type>> mapSrcToTgt
(
const Field<Type>& srcFld,
const CombineOp& cop
) const;
//- Convenience function to map a tmp field to the tgt mesh
// with a defined operation
template<class Type, class CombineOp>
tmp<Field<Type>> mapSrcToTgt
(
const tmp<Field<Type>>& tsrcFld,
const CombineOp& cop
) const;
//- Convenience function to map a field to the tgt mesh with a
// default operation (plusEqOp)
template<class Type> template<class Type>
tmp<Field<Type>> mapSrcToTgt tmp<Field<Type>> mapSrcToTgt
( (
@ -337,7 +316,7 @@ public:
) const; ) const;
//- Convenience function to map a tmp field to the tgt mesh //- Convenience function to map a tmp field to the tgt mesh
// with a default operation (plusEqOp) // with a defined operation
template<class Type> template<class Type>
tmp<Field<Type>> mapSrcToTgt tmp<Field<Type>> mapSrcToTgt
( (
@ -350,34 +329,15 @@ public:
//- Map field from tgt to src mesh with defined operation //- Map field from tgt to src mesh with defined operation
// Values passed in via 'result' are used to initialise the // Values passed in via 'result' are used to initialise the
// return value // return value
template<class Type, class CombineOp> template<class Type>
void mapTgtToSrc void mapTgtToSrc
( (
const UList<Type>& tgtFld, const UList<Type>& tgtFld,
const CombineOp& cop,
List<Type>& result List<Type>& result
) const; ) const;
//- Return the tgt field mapped to the src mesh with a defined //- Return the tgt field mapped to the src mesh with a defined
// operation. Initial values of the result are set to zero // operation. Initial values of the result are set to zero
template<class Type, class CombineOp>
tmp<Field<Type>> mapTgtToSrc
(
const Field<Type>& tgtFld,
const CombineOp& cop
) const;
//- Convenience function to map a tmp field to the src mesh
// with a defined operation
template<class Type, class CombineOp>
tmp<Field<Type>> mapTgtToSrc
(
const tmp<Field<Type>>& ttgtFld,
const CombineOp& cop
) const;
//- Convenience function to map a field to the src mesh with a
// default operation (plusEqOp)
template<class Type> template<class Type>
tmp<Field<Type>> mapTgtToSrc tmp<Field<Type>> mapTgtToSrc
( (
@ -385,7 +345,7 @@ public:
) const; ) const;
//- Convenience function to map a tmp field to the src mesh //- Convenience function to map a tmp field to the src mesh
// with a default operation (plusEqOp) // with a defined operation
template<class Type> template<class Type>
tmp<Field<Type>> mapTgtToSrc tmp<Field<Type>> mapTgtToSrc
( (
@ -398,43 +358,23 @@ public:
//- Interpolate a field with a defined operation. Values //- Interpolate a field with a defined operation. Values
// passed in via 'result' are used to initialise the return // passed in via 'result' are used to initialise the return
// value // value
template<class Type, class CombineOp> template<class Type>
void mapSrcToTgt void mapSrcToTgt
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result GeometricField<Type, fvPatchField, volMesh>& result
) const; ) const;
//- Interpolate a field with a defined operation. The initial //- Interpolate a field with a defined operation. The initial
// values of the result are set to zero // values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop
) const;
//- 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
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>&
tfield,
const CombineOp& cop
) const;
//- Convenience function to map a field with a default
// operation (plusEqOp)
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt
( (
const GeometricField<Type, fvPatchField, volMesh>& field const GeometricField<Type, fvPatchField, volMesh>& field
) const; ) const;
//- Convenience function to map a tmp field with a default //- Interpolate a tmp field with a defined operation. The
// operation (plusEqOp) // initial values of the result are set to zero
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt tmp<GeometricField<Type, fvPatchField, volMesh>> mapSrcToTgt
( (
@ -448,43 +388,23 @@ public:
//- Interpolate a field with a defined operation. Values //- Interpolate a field with a defined operation. Values
// passed in via 'result' are used to initialise the return // passed in via 'result' are used to initialise the return
// value // value
template<class Type, class CombineOp> template<class Type>
void mapTgtToSrc void mapTgtToSrc
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result GeometricField<Type, fvPatchField, volMesh>& result
) const; ) const;
//- Interpolate a field with a defined operation. The initial //- Interpolate a field with a defined operation. The initial
// values of the result are set to zero // values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop
) const;
//- 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
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>&
tfield,
const CombineOp& cop
) const;
//- Convenience function to map a field with a default
// operation (plusEqOp)
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc
( (
const GeometricField<Type, fvPatchField, volMesh>& field const GeometricField<Type, fvPatchField, volMesh>& field
) const; ) const;
//- Convenience function to map a tmp field with a default //- Interpolate a tmp field with a defined operation. The
// operation (plusEqOp) // initial values of the result are set to zero
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc tmp<GeometricField<Type, fvPatchField, volMesh>> mapTgtToSrc
( (
@ -509,40 +429,35 @@ void meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<scalar>& srcField, const Field<scalar>& srcField,
Field<scalar>& tgtField, Field<scalar>& tgtField
const plusEqOp<scalar>& cop
) const; ) const;
template<> template<>
void meshToMesh::mapAndOpSrcToTgt void meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<vector>& srcField, const Field<vector>& srcField,
Field<vector>& tgtField, Field<vector>& tgtField
const plusEqOp<vector>& cop
) const; ) const;
template<> template<>
void meshToMesh::mapAndOpSrcToTgt void meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<sphericalTensor>& srcField, const Field<sphericalTensor>& srcField,
Field<sphericalTensor>& tgtField, Field<sphericalTensor>& tgtField
const plusEqOp<sphericalTensor>& cop
) const; ) const;
template<> template<>
void meshToMesh::mapAndOpSrcToTgt void meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<symmTensor>& srcField, const Field<symmTensor>& srcField,
Field<symmTensor>& tgtField, Field<symmTensor>& tgtField
const plusEqOp<symmTensor>& cop
) const; ) const;
template<> template<>
void meshToMesh::mapAndOpSrcToTgt void meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<tensor>& srcField, const Field<tensor>& srcField,
Field<tensor>& tgtField, Field<tensor>& tgtField
const plusEqOp<tensor>& cop
) const; ) const;
@ -551,40 +466,35 @@ void meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<scalar>& srcField, Field<scalar>& srcField,
const Field<scalar>& tgtField, const Field<scalar>& tgtField
const plusEqOp<scalar>& cop
) const; ) const;
template<> template<>
void meshToMesh::mapAndOpTgtToSrc void meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<vector>& srcField, Field<vector>& srcField,
const Field<vector>& tgtField, const Field<vector>& tgtField
const plusEqOp<vector>& cop
) const; ) const;
template<> template<>
void meshToMesh::mapAndOpTgtToSrc void meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<sphericalTensor>& srcField, Field<sphericalTensor>& srcField,
const Field<sphericalTensor>& tgtField, const Field<sphericalTensor>& tgtField
const plusEqOp<sphericalTensor>& cop
) const; ) const;
template<> template<>
void meshToMesh::mapAndOpTgtToSrc void meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<symmTensor>& srcField, Field<symmTensor>& srcField,
const Field<symmTensor>& tgtField, const Field<symmTensor>& tgtField
const plusEqOp<symmTensor>& cop
) const; ) const;
template<> template<>
void meshToMesh::mapAndOpTgtToSrc void meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<tensor>& srcField, Field<tensor>& srcField,
const Field<tensor>& tgtField, const Field<tensor>& tgtField
const plusEqOp<tensor>& cop
) const; ) const;
} // End namespace Foam } // End namespace Foam

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
@ -77,11 +77,10 @@ void Foam::meshToMesh::add
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh::mapSrcToTgt void Foam::meshToMesh::mapSrcToTgt
( (
const UList<Type>& srcField, const UList<Type>& srcField,
const CombineOp& cop,
List<Type>& result List<Type>& result
) const ) const
{ {
@ -95,8 +94,6 @@ void Foam::meshToMesh::mapSrcToTgt
<< abort(FatalError); << abort(FatalError);
} }
multiplyWeightedOp<Type, CombineOp> cbop(cop);
if (singleMeshProc_ == -1) if (singleMeshProc_ == -1)
{ {
const mapDistribute& map = srcMapPtr_(); const mapDistribute& map = srcMapPtr_();
@ -111,13 +108,10 @@ void Foam::meshToMesh::mapSrcToTgt
if (srcAddress.size()) if (srcAddress.size())
{ {
// result[celli] = Zero;
result[celli] *= (1.0 - sum(srcWeight)); result[celli] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i) forAll(srcAddress, i)
{ {
label srcI = srcAddress[i]; result[celli] += srcWeight[i]*work[srcAddress[i]];
scalar w = srcWeight[i];
cbop(result[celli], celli, work[srcI], w);
} }
} }
} }
@ -131,13 +125,10 @@ void Foam::meshToMesh::mapSrcToTgt
if (srcAddress.size()) if (srcAddress.size())
{ {
// result[celli] = Zero;
result[celli] *= (1.0 - sum(srcWeight)); result[celli] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i) forAll(srcAddress, i)
{ {
label srcI = srcAddress[i]; result[celli] += srcWeight[i]*srcField[srcAddress[i]];
scalar w = srcWeight[i];
cbop(result[celli], celli, srcField[srcI], w);
} }
} }
} }
@ -145,11 +136,10 @@ void Foam::meshToMesh::mapSrcToTgt
} }
template<class Type, class CombineOp> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt
( (
const Field<Type>& srcField, const Field<Type>& srcField
const CombineOp& cop
) const ) const
{ {
tmp<Field<Type>> tresult tmp<Field<Type>> tresult
@ -161,33 +151,12 @@ Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt
) )
); );
mapSrcToTgt(srcField, cop, tresult.ref()); mapSrcToTgt(srcField, tresult.ref());
return tresult; return tresult;
} }
template<class Type, class CombineOp>
Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt
(
const tmp<Field<Type>>& tsrcField,
const CombineOp& cop
) const
{
return mapSrcToTgt(tsrcField(), cop);
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt
(
const Field<Type>& srcField
) const
{
return mapSrcToTgt(srcField, plusEqOp<Type>());
}
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt
( (
@ -198,11 +167,10 @@ Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh::mapTgtToSrc void Foam::meshToMesh::mapTgtToSrc
( (
const UList<Type>& tgtField, const UList<Type>& tgtField,
const CombineOp& cop,
List<Type>& result List<Type>& result
) const ) const
{ {
@ -216,8 +184,6 @@ void Foam::meshToMesh::mapTgtToSrc
<< abort(FatalError); << abort(FatalError);
} }
multiplyWeightedOp<Type, CombineOp> cbop(cop);
if (singleMeshProc_ == -1) if (singleMeshProc_ == -1)
{ {
const mapDistribute& map = tgtMapPtr_(); const mapDistribute& map = tgtMapPtr_();
@ -235,9 +201,7 @@ void Foam::meshToMesh::mapTgtToSrc
result[celli] *= (1.0 - sum(tgtWeight)); result[celli] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i) forAll(tgtAddress, i)
{ {
label tgtI = tgtAddress[i]; result[celli] += tgtWeight[i]*work[tgtAddress[i]];
scalar w = tgtWeight[i];
cbop(result[celli], celli, work[tgtI], w);
} }
} }
} }
@ -254,9 +218,7 @@ void Foam::meshToMesh::mapTgtToSrc
result[celli] *= (1.0 - sum(tgtWeight)); result[celli] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i) forAll(tgtAddress, i)
{ {
label tgtI = tgtAddress[i]; result[celli] += tgtWeight[i]*tgtField[tgtAddress[i]];
scalar w = tgtWeight[i];
cbop(result[celli], celli, tgtField[tgtI], w);
} }
} }
} }
@ -264,11 +226,10 @@ void Foam::meshToMesh::mapTgtToSrc
} }
template<class Type, class CombineOp> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc
( (
const Field<Type>& tgtField, const Field<Type>& tgtField
const CombineOp& cop
) const ) const
{ {
tmp<Field<Type>> tresult tmp<Field<Type>> tresult
@ -280,50 +241,28 @@ Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc
) )
); );
mapTgtToSrc(tgtField, cop, tresult.ref()); mapTgtToSrc(tgtField, tresult.ref());
return tresult; return tresult;
} }
template<class Type, class CombineOp>
Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc
(
const tmp<Field<Type>>& ttgtField,
const CombineOp& cop
) const
{
return mapTgtToSrc(ttgtField(), cop);
}
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc
(
const Field<Type>& tgtField
) const
{
return mapTgtToSrc(tgtField, plusEqOp<Type>());
}
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc
( (
const tmp<Field<Type>>& ttgtField const tmp<Field<Type>>& ttgtField
) const ) const
{ {
return mapTgtToSrc(ttgtField(), plusEqOp<Type>()); return mapTgtToSrc(ttgtField());
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh::mapAndOpSrcToTgt void Foam::meshToMesh::mapAndOpSrcToTgt
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
const Field<Type>& srcField, const Field<Type>& srcField,
Field<Type>& tgtField, Field<Type>& tgtField
const CombineOp& cop
) const ) const
{ {
tgtField = pTraits<Type>::zero; tgtField = pTraits<Type>::zero;
@ -331,22 +270,20 @@ void Foam::meshToMesh::mapAndOpSrcToTgt
AMI.interpolateToTarget AMI.interpolateToTarget
( (
srcField, srcField,
multiplyWeightedOp<Type, CombineOp>(cop),
tgtField, tgtField,
UList<Type>::null() UList<Type>::null()
); );
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh::mapSrcToTgt void Foam::meshToMesh::mapSrcToTgt
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result GeometricField<Type, fvPatchField, volMesh>& result
) const ) const
{ {
mapSrcToTgt(field, cop, result.primitiveFieldRef()); mapSrcToTgt(field, result.primitiveFieldRef());
const PtrList<AMIInterpolation>& AMIList = patchAMIs(); const PtrList<AMIInterpolation>& AMIList = patchAMIs();
@ -389,7 +326,7 @@ void Foam::meshToMesh::mapSrcToTgt
// Override value to account for CombineOp (note: is dummy template // Override value to account for CombineOp (note: is dummy template
// specialisation for plusEqOp) // specialisation for plusEqOp)
mapAndOpSrcToTgt(AMIList[i], srcField, tgtField, cop); mapAndOpSrcToTgt(AMIList[i], srcField, tgtField);
} }
forAll(cuttingPatches_, i) forAll(cuttingPatches_, i)
@ -401,12 +338,11 @@ void Foam::meshToMesh::mapSrcToTgt
} }
template<class Type, class CombineOp> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>> Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh::mapSrcToTgt Foam::meshToMesh::mapSrcToTgt
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field
const CombineOp& cop
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
@ -485,35 +421,12 @@ Foam::meshToMesh::mapSrcToTgt
) )
); );
mapSrcToTgt(field, cop, tresult.ref()); mapSrcToTgt(field, tresult.ref());
return tresult; return tresult;
} }
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh::mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield,
const CombineOp& cop
) const
{
return mapSrcToTgt(tfield(), cop);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field
) const
{
return mapSrcToTgt(field, plusEqOp<Type>());
}
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>> Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh::mapSrcToTgt Foam::meshToMesh::mapSrcToTgt
@ -521,17 +434,16 @@ Foam::meshToMesh::mapSrcToTgt
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield
) const ) const
{ {
return mapSrcToTgt(tfield(), plusEqOp<Type>()); return mapSrcToTgt(tfield());
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh::mapAndOpTgtToSrc void Foam::meshToMesh::mapAndOpTgtToSrc
( (
const AMIInterpolation& AMI, const AMIInterpolation& AMI,
Field<Type>& srcField, Field<Type>& srcField,
const Field<Type>& tgtField, const Field<Type>& tgtField
const CombineOp& cop
) const ) const
{ {
srcField = pTraits<Type>::zero; srcField = pTraits<Type>::zero;
@ -539,22 +451,20 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
AMI.interpolateToSource AMI.interpolateToSource
( (
tgtField, tgtField,
multiplyWeightedOp<Type, CombineOp>(cop),
srcField, srcField,
UList<Type>::null() UList<Type>::null()
); );
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh::mapTgtToSrc void Foam::meshToMesh::mapTgtToSrc
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result GeometricField<Type, fvPatchField, volMesh>& result
) const ) const
{ {
mapTgtToSrc(field, cop, result.primitiveFieldRef()); mapTgtToSrc(field, result.primitiveFieldRef());
const PtrList<AMIInterpolation>& AMIList = patchAMIs(); const PtrList<AMIInterpolation>& AMIList = patchAMIs();
@ -596,7 +506,7 @@ void Foam::meshToMesh::mapTgtToSrc
// Override value to account for CombineOp (could be dummy for // Override value to account for CombineOp (could be dummy for
// plusEqOp) // plusEqOp)
mapAndOpTgtToSrc(AMIList[i], srcField, tgtField, cop); mapAndOpTgtToSrc(AMIList[i], srcField, tgtField);
} }
forAll(cuttingPatches_, i) forAll(cuttingPatches_, i)
@ -608,12 +518,11 @@ void Foam::meshToMesh::mapTgtToSrc
} }
template<class Type, class CombineOp> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>> Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh::mapTgtToSrc Foam::meshToMesh::mapTgtToSrc
( (
const GeometricField<Type, fvPatchField, volMesh>& field, const GeometricField<Type, fvPatchField, volMesh>& field
const CombineOp& cop
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
@ -692,35 +601,12 @@ Foam::meshToMesh::mapTgtToSrc
) )
); );
mapTgtToSrc(field, cop, tresult.ref()); mapTgtToSrc(field, tresult.ref());
return tresult; return tresult;
} }
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh::mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield,
const CombineOp& cop
) const
{
return mapTgtToSrc(tfield(), cop);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field
) const
{
return mapTgtToSrc(field, plusEqOp<Type>());
}
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>> Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh::mapTgtToSrc Foam::meshToMesh::mapTgtToSrc
@ -728,7 +614,7 @@ Foam::meshToMesh::mapTgtToSrc
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfield
) const ) const
{ {
return mapTgtToSrc(tfield(), plusEqOp<Type>()); return mapTgtToSrc(tfield());
} }

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-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -254,105 +254,95 @@ public:
// Interpolation // Interpolation
//- Map field //- Map field
template<class Type, class CombineOp> template<class Type>
void mapField void mapField
( (
Field<Type>&, Field<Type>&,
const Field<Type>&, const Field<Type>&,
const labelList& adr, const labelList& adr
const CombineOp& cop
) const; ) const;
//- Interpolate field using inverse-distance weights //- Interpolate field using inverse-distance weights
template<class Type, class CombineOp> template<class Type>
void interpolateField void interpolateField
( (
Field<Type>&, Field<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&, const GeometricField<Type, fvPatchField, volMesh>&,
const labelList& adr, const labelList& adr,
const scalarListList& weights, const scalarListList& weights
const CombineOp& cop
) const; ) const;
//- Interpolate field using inverse-volume weights //- Interpolate field using inverse-volume weights
template<class Type, class CombineOp> template<class Type>
void interpolateField void interpolateField
( (
Field<Type>&, Field<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&, const GeometricField<Type, fvPatchField, volMesh>&,
const labelListList& adr, const labelListList& adr,
const scalarListList& weights, const scalarListList& weights
const CombineOp& cop
) const; ) const;
//- Interpolate field using cell-point interpolation //- Interpolate field using cell-point interpolation
template<class Type, class CombineOp> template<class Type>
void interpolateField void interpolateField
( (
Field<Type>&, Field<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&, const GeometricField<Type, fvPatchField, volMesh>&,
const labelList& adr, const labelList& adr,
const vectorField& centres, const vectorField& centres
const CombineOp& cop
)const; )const;
//- Interpolate internal volume field //- Interpolate internal volume field
template<class Type, class CombineOp> template<class Type>
void interpolateInternalField void interpolateInternalField
( (
Field<Type>&, Field<Type>&,
const GeometricField<Type, fvPatchField, volMesh>&, const GeometricField<Type, fvPatchField, volMesh>&,
order=INTERPOLATE, order=INTERPOLATE
const CombineOp& cop = eqOp<Type>()
) const; ) const;
template<class Type, class CombineOp> template<class Type>
void interpolateInternalField void interpolateInternalField
( (
Field<Type>&, Field<Type>&,
const tmp<GeometricField<Type, fvPatchField, volMesh>>&, const tmp<GeometricField<Type, fvPatchField, volMesh>>&,
order=INTERPOLATE, order=INTERPOLATE
const CombineOp& cop = eqOp<Type>()
) const; ) const;
//- Interpolate volume field //- Interpolate volume field
template<class Type, class CombineOp> template<class Type>
void interpolate void interpolate
( (
GeometricField<Type, fvPatchField, volMesh>&, GeometricField<Type, fvPatchField, volMesh>&,
const GeometricField<Type, fvPatchField, volMesh>&, const GeometricField<Type, fvPatchField, volMesh>&,
order=INTERPOLATE, order=INTERPOLATE
const CombineOp& cop = eqOp<Type>()
) const; ) const;
template<class Type, class CombineOp> template<class Type>
void interpolate void interpolate
( (
GeometricField<Type, fvPatchField, volMesh>&, GeometricField<Type, fvPatchField, volMesh>&,
const tmp<GeometricField<Type, fvPatchField, volMesh>>&, const tmp<GeometricField<Type, fvPatchField, volMesh>>&,
order=INTERPOLATE, order=INTERPOLATE
const CombineOp& cop = eqOp<Type>()
) const; ) const;
//- Interpolate volume field //- Interpolate volume field
template<class Type, class CombineOp> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> interpolate tmp<GeometricField<Type, fvPatchField, volMesh>> interpolate
( (
const GeometricField<Type, fvPatchField, volMesh>&, const GeometricField<Type, fvPatchField, volMesh>&,
order=INTERPOLATE, order=INTERPOLATE
const CombineOp& cop = eqOp<Type>()
) const; ) const;
template<class Type, class CombineOp> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> interpolate tmp<GeometricField<Type, fvPatchField, volMesh>> interpolate
( (
const tmp<GeometricField<Type, fvPatchField, volMesh>>&, const tmp<GeometricField<Type, fvPatchField, volMesh>>&,
order=INTERPOLATE, order=INTERPOLATE
const CombineOp& cop = eqOp<Type>()
) const; ) const;
}; };

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-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -31,13 +31,12 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh0::mapField void Foam::meshToMesh0::mapField
( (
Field<Type>& toF, Field<Type>& toF,
const Field<Type>& fromVf, const Field<Type>& fromVf,
const labelList& adr, const labelList& adr
const CombineOp& cop
) const ) const
{ {
// Direct mapping of nearest-cell values // Direct mapping of nearest-cell values
@ -46,7 +45,7 @@ void Foam::meshToMesh0::mapField
{ {
if (adr[celli] != -1) if (adr[celli] != -1)
{ {
cop(toF[celli], fromVf[adr[celli]]); toF[celli] = fromVf[adr[celli]];
} }
} }
@ -54,14 +53,13 @@ void Foam::meshToMesh0::mapField
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh0::interpolateField void Foam::meshToMesh0::interpolateField
( (
Field<Type>& toF, Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
const labelListList& adr, const labelListList& adr,
const scalarListList& weights, const scalarListList& weights
const CombineOp& cop
) const ) const
{ {
// Inverse volume weighted interpolation // Inverse volume weighted interpolation
@ -75,20 +73,19 @@ void Foam::meshToMesh0::interpolateField
{ {
label fromCelli = overlapCells[i]; label fromCelli = overlapCells[i];
f += fromVf[fromCelli]*w[i]; f += fromVf[fromCelli]*w[i];
cop(toF[celli], f); toF[celli] = f;
} }
} }
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh0::interpolateField void Foam::meshToMesh0::interpolateField
( (
Field<Type>& toF, Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
const labelList& adr, const labelList& adr,
const scalarListList& weights, const scalarListList& weights
const CombineOp& cop
) const ) const
{ {
// Inverse distance weighted interpolation // Inverse distance weighted interpolation
@ -110,20 +107,19 @@ void Foam::meshToMesh0::interpolateField
f += fromVf[neighbours[ni - 1]]*w[ni]; f += fromVf[neighbours[ni - 1]]*w[ni];
} }
cop(toF[celli], f); toF[celli] = f;
} }
} }
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh0::interpolateField void Foam::meshToMesh0::interpolateField
( (
Field<Type>& toF, Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
const labelList& adr, const labelList& adr,
const vectorField& centres, const vectorField& centres
const CombineOp& cop
) const ) const
{ {
// Cell-Point interpolation // Cell-Point interpolation
@ -133,27 +129,18 @@ void Foam::meshToMesh0::interpolateField
{ {
if (adr[celli] != -1) if (adr[celli] != -1)
{ {
cop toF[celli] = interpolator.interpolate(centres[celli], adr[celli]);
(
toF[celli],
interpolator.interpolate
(
centres[celli],
adr[celli]
)
);
} }
} }
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh0::interpolateInternalField void Foam::meshToMesh0::interpolateInternalField
( (
Field<Type>& toF, Field<Type>& toF,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
meshToMesh0::order ord, meshToMesh0::order ord
const CombineOp& cop
) const ) const
{ {
if (fromVf.mesh() != fromMesh_) if (fromVf.mesh() != fromMesh_)
@ -177,7 +164,7 @@ void Foam::meshToMesh0::interpolateInternalField
switch(ord) switch(ord)
{ {
case MAP: case MAP:
mapField(toF, fromVf, cellAddressing_, cop); mapField(toF, fromVf, cellAddressing_);
break; break;
case INTERPOLATE: case INTERPOLATE:
@ -187,8 +174,7 @@ void Foam::meshToMesh0::interpolateInternalField
toF, toF,
fromVf, fromVf,
cellAddressing_, cellAddressing_,
inverseDistanceWeights(), inverseDistanceWeights()
cop
); );
break; break;
} }
@ -199,8 +185,7 @@ void Foam::meshToMesh0::interpolateInternalField
toF, toF,
fromVf, fromVf,
cellAddressing_, cellAddressing_,
toMesh_.cellCentres(), toMesh_.cellCentres()
cop
); );
break; break;
@ -215,8 +200,7 @@ void Foam::meshToMesh0::interpolateInternalField
toF, toF,
fromVf, fromVf,
cellToCell, cellToCell,
invVolWeights, invVolWeights
cop
); );
break; break;
} }
@ -228,30 +212,28 @@ void Foam::meshToMesh0::interpolateInternalField
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh0::interpolateInternalField void Foam::meshToMesh0::interpolateInternalField
( (
Field<Type>& toF, Field<Type>& toF,
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf, const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf,
meshToMesh0::order ord, meshToMesh0::order ord
const CombineOp& cop
) const ) const
{ {
interpolateInternalField(toF, tfromVf(), ord, cop); interpolateInternalField(toF, tfromVf(), ord);
tfromVf.clear(); tfromVf.clear();
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh0::interpolate void Foam::meshToMesh0::interpolate
( (
GeometricField<Type, fvPatchField, volMesh>& toVf, GeometricField<Type, fvPatchField, volMesh>& toVf,
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
meshToMesh0::order ord, meshToMesh0::order ord
const CombineOp& cop
) const ) const
{ {
interpolateInternalField(toVf, fromVf, ord, cop); interpolateInternalField(toVf, fromVf, ord);
typename GeometricField<Type, fvPatchField, volMesh>:: typename GeometricField<Type, fvPatchField, volMesh>::
Boundary& toVfBf = toVf.boundaryFieldRef(); Boundary& toVfBf = toVf.boundaryFieldRef();
@ -270,8 +252,7 @@ void Foam::meshToMesh0::interpolate
( (
toVfBf[patchi], toVfBf[patchi],
fromVf, fromVf,
boundaryAddressing_[patchi], boundaryAddressing_[patchi]
cop
); );
break; break;
} }
@ -283,8 +264,7 @@ void Foam::meshToMesh0::interpolate
toVfBf[patchi], toVfBf[patchi],
fromVf, fromVf,
boundaryAddressing_[patchi], boundaryAddressing_[patchi],
toPatch.Cf(), toPatch.Cf()
cop
); );
break; break;
} }
@ -296,8 +276,7 @@ void Foam::meshToMesh0::interpolate
toVfBf[patchi], toVfBf[patchi],
fromVf, fromVf,
boundaryAddressing_[patchi], boundaryAddressing_[patchi],
toPatch.Cf(), toPatch.Cf()
cop
); );
break; break;
} }
@ -333,40 +312,37 @@ void Foam::meshToMesh0::interpolate
[ [
fromMeshPatches_.find(patchMap_.find(toPatch.name())())() fromMeshPatches_.find(patchMap_.find(toPatch.name())())()
], ],
boundaryAddressing_[patchi], boundaryAddressing_[patchi]
cop
); );
} }
} }
} }
template<class Type, class CombineOp> template<class Type>
void Foam::meshToMesh0::interpolate void Foam::meshToMesh0::interpolate
( (
GeometricField<Type, fvPatchField, volMesh>& toVf, GeometricField<Type, fvPatchField, volMesh>& toVf,
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf, const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf,
meshToMesh0::order ord, meshToMesh0::order ord
const CombineOp& cop
) const ) const
{ {
interpolate(toVf, tfromVf(), ord, cop); interpolate(toVf, tfromVf(), ord);
tfromVf.clear(); tfromVf.clear();
} }
template<class Type, class CombineOp> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>> Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh0::interpolate Foam::meshToMesh0::interpolate
( (
const GeometricField<Type, fvPatchField, volMesh>& fromVf, const GeometricField<Type, fvPatchField, volMesh>& fromVf,
meshToMesh0::order ord, meshToMesh0::order ord
const CombineOp& cop
) const ) const
{ {
// Create and map the internal-field values // Create and map the internal-field values
Field<Type> internalField(toMesh_.nCells()); Field<Type> internalField(toMesh_.nCells());
interpolateInternalField(internalField, fromVf, ord, cop); interpolateInternalField(internalField, fromVf, ord);
// check whether both meshes have got the same number // check whether both meshes have got the same number
// of boundary patches // of boundary patches
@ -428,17 +404,16 @@ Foam::meshToMesh0::interpolate
} }
template<class Type, class CombineOp> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>> Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
Foam::meshToMesh0::interpolate Foam::meshToMesh0::interpolate
( (
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf, const tmp<GeometricField<Type, fvPatchField, volMesh>>& tfromVf,
meshToMesh0::order ord, meshToMesh0::order ord
const CombineOp& cop
) const ) const
{ {
tmp<GeometricField<Type, fvPatchField, volMesh>> tint = tmp<GeometricField<Type, fvPatchField, volMesh>> tint =
interpolate(tfromVf(), ord, cop); interpolate(tfromVf(), ord);
tfromVf.clear(); tfromVf.clear();
return tint; return tint;