ENH: parallel: overhaul of parallel mapping

- redistributePar to have almost (complete) functionality of decomposePar+reconstructPar
- low-level distributed Field mapping
- support for mapping surfaceFields (including flipping faces)
- support for decomposing/reconstructing refinement data
This commit is contained in:
mattijs
2015-11-17 15:05:05 +00:00
parent 09dec5263b
commit 916dcb8685
205 changed files with 21665 additions and 4196 deletions

View File

@ -62,6 +62,7 @@ meshToMeshMethods = meshToMesh/calcMethod
$(meshToMeshMethods)/meshToMeshMethod/meshToMeshMethod.C
$(meshToMeshMethods)/meshToMeshMethod/meshToMeshMethodNew.C
$(meshToMeshMethods)/cellVolumeWeight/cellVolumeWeightMethod.C
$(meshToMeshMethods)/correctedCellVolumeWeight/correctedCellVolumeWeightMethod.C
$(meshToMeshMethods)/direct/directMethod.C
$(meshToMeshMethods)/mapNearest/mapNearestMethod.C

View File

@ -4,6 +4,7 @@ EXE_INC = \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
@ -14,4 +15,5 @@ LIB_LIBS = \
-lfileFormats \
-ltriSurface \
-llagrangian \
-ldynamicMesh \
-lconversion

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -186,6 +186,44 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
tgtToSrcCellAddr[i].transfer(tgtToSrcAddr[i]);
tgtToSrcCellWght[i].transfer(tgtToSrcWght[i]);
}
if (debug%2)
{
// At this point the overlaps are still in volume so we could
// get out the relative error
forAll(srcToTgtCellAddr, cellI)
{
scalar srcVol = src_.cellVolumes()[cellI];
scalar tgtVol = sum(srcToTgtCellWght[cellI]);
if (mag(srcVol) > ROOTVSMALL && mag((tgtVol-srcVol)/srcVol) > 1e-6)
{
WarningIn("cellVolumeWeightMethod::calculateAddressing(..)")
<< "At cell " << cellI << " cc:"
<< src_.cellCentres()[cellI]
<< " vol:" << srcVol
<< " total overlap volume:" << tgtVol
<< endl;
}
}
forAll(tgtToSrcCellAddr, cellI)
{
scalar tgtVol = tgt_.cellVolumes()[cellI];
scalar srcVol = sum(tgtToSrcCellWght[cellI]);
if (mag(tgtVol) > ROOTVSMALL && mag((srcVol-tgtVol)/tgtVol) > 1e-6)
{
WarningIn("cellVolumeWeightMethod::calculateAddressing(..)")
<< "At cell " << cellI << " cc:"
<< tgt_.cellCentres()[cellI]
<< " vol:" << tgtVol
<< " total overlap volume:" << srcVol
<< endl;
}
}
}
}
@ -315,8 +353,10 @@ void Foam::cellVolumeWeightMethod::calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
)
{
bool ok = initialise

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -116,13 +116,15 @@ public:
// Evaluate
//- Calculate addressing and weights
//- Calculate addressing and weights and optionally offset vectors
virtual void calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
labelListList& tgtToTgtAddr,
scalarListList& tgtToTgtWght
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
);
};

View File

@ -0,0 +1,296 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
\*---------------------------------------------------------------------------*/
#include "correctedCellVolumeWeightMethod.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(correctedCellVolumeWeightMethod, 0);
addToRunTimeSelectionTable
(
meshToMeshMethod,
correctedCellVolumeWeightMethod,
components
);
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::correctedCellVolumeWeightMethod::calculateAddressing
(
labelListList& srcToTgtCellAddr,
scalarListList& srcToTgtCellWght,
pointListList& srcToTgtCellVec,
labelListList& tgtToSrcCellAddr,
scalarListList& tgtToSrcCellWght,
pointListList& tgtToSrcCellVec,
const label srcSeedI,
const label tgtSeedI,
const labelList& srcCellIDs,
boolList& mapFlag,
label& startSeedI
)
{
label srcCellI = srcSeedI;
label tgtCellI = tgtSeedI;
List<DynamicList<label> > srcToTgtAddr(src_.nCells());
List<DynamicList<scalar> > srcToTgtWght(src_.nCells());
List<DynamicList<point> > srcToTgtVec(src_.nCells());
List<DynamicList<label> > tgtToSrcAddr(tgt_.nCells());
List<DynamicList<scalar> > tgtToSrcWght(tgt_.nCells());
List<DynamicList<point> > tgtToSrcVec(tgt_.nCells());
// list of tgt cell neighbour cells
DynamicList<label> nbrTgtCells(10);
// list of tgt cells currently visited for srcCellI to avoid multiple hits
DynamicList<label> visitedTgtCells(10);
// list to keep track of tgt cells used to seed src cells
labelList seedCells(src_.nCells(), -1);
seedCells[srcCellI] = tgtCellI;
const scalarField& srcVol = src_.cellVolumes();
const pointField& srcCc = src_.cellCentres();
const pointField& tgtCc = tgt_.cellCentres();
do
{
nbrTgtCells.clear();
visitedTgtCells.clear();
// append initial target cell and neighbours
nbrTgtCells.append(tgtCellI);
appendNbrCells(tgtCellI, tgt_, visitedTgtCells, nbrTgtCells);
do
{
tgtCellI = nbrTgtCells.remove();
visitedTgtCells.append(tgtCellI);
Tuple2<scalar, point> vol = interVolAndCentroid
(
srcCellI,
tgtCellI
);
// accumulate addressing and weights for valid intersection
if (vol.first()/srcVol[srcCellI] > tolerance_)
{
// store src/tgt cell pair
srcToTgtAddr[srcCellI].append(tgtCellI);
srcToTgtWght[srcCellI].append(vol.first());
srcToTgtVec[srcCellI].append(vol.second()-tgtCc[tgtCellI]);
tgtToSrcAddr[tgtCellI].append(srcCellI);
tgtToSrcWght[tgtCellI].append(vol.first());
tgtToSrcVec[tgtCellI].append(vol.second()-srcCc[srcCellI]);
appendNbrCells(tgtCellI, tgt_, visitedTgtCells, nbrTgtCells);
// accumulate intersection volume
V_ += vol.first();
}
}
while (!nbrTgtCells.empty());
mapFlag[srcCellI] = false;
// find new source seed cell
setNextCells
(
startSeedI,
srcCellI,
tgtCellI,
srcCellIDs,
mapFlag,
visitedTgtCells,
seedCells
);
}
while (srcCellI != -1);
// transfer addressing into persistent storage
forAll(srcToTgtCellAddr, i)
{
srcToTgtCellAddr[i].transfer(srcToTgtAddr[i]);
srcToTgtCellWght[i].transfer(srcToTgtWght[i]);
srcToTgtCellVec[i].transfer(srcToTgtVec[i]);
}
forAll(tgtToSrcCellAddr, i)
{
tgtToSrcCellAddr[i].transfer(tgtToSrcAddr[i]);
tgtToSrcCellWght[i].transfer(tgtToSrcWght[i]);
tgtToSrcCellVec[i].transfer(tgtToSrcVec[i]);
}
if (debug%2)
{
// At this point the overlaps are still in volume so we could
// get out the relative error
forAll(srcToTgtCellAddr, cellI)
{
scalar srcVol = src_.cellVolumes()[cellI];
scalar tgtVol = sum(srcToTgtCellWght[cellI]);
if (mag(srcVol) > ROOTVSMALL && mag((tgtVol-srcVol)/srcVol) > 1e-6)
{
WarningIn
(
"correctedCellVolumeWeightMethod::calculateAddressing(..)"
) << "At cell " << cellI << " cc:"
<< src_.cellCentres()[cellI]
<< " vol:" << srcVol
<< " total overlap volume:" << tgtVol
<< endl;
}
}
forAll(tgtToSrcCellAddr, cellI)
{
scalar tgtVol = tgt_.cellVolumes()[cellI];
scalar srcVol = sum(tgtToSrcCellWght[cellI]);
if (mag(tgtVol) > ROOTVSMALL && mag((srcVol-tgtVol)/tgtVol) > 1e-6)
{
WarningIn
(
"correctedCellVolumeWeightMethod::calculateAddressing(..)"
) << "At cell " << cellI << " cc:"
<< tgt_.cellCentres()[cellI]
<< " vol:" << tgtVol
<< " total overlap volume:" << srcVol
<< endl;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::correctedCellVolumeWeightMethod::correctedCellVolumeWeightMethod
(
const polyMesh& src,
const polyMesh& tgt
)
:
cellVolumeWeightMethod(src, tgt)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::correctedCellVolumeWeightMethod::~correctedCellVolumeWeightMethod()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::correctedCellVolumeWeightMethod::calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
)
{
bool ok = initialise
(
srcToTgtAddr,
srcToTgtWght,
tgtToSrcAddr,
tgtToSrcWght
);
if (!ok)
{
return;
}
srcToTgtVec.setSize(srcToTgtAddr.size());
tgtToSrcVec.setSize(tgtToSrcAddr.size());
// (potentially) participating source mesh cells
const labelList srcCellIDs(maskCells());
// list to keep track of whether src cell can be mapped
boolList mapFlag(src_.nCells(), false);
UIndirectList<bool>(mapFlag, srcCellIDs) = true;
// find initial point in tgt mesh
label srcSeedI = -1;
label tgtSeedI = -1;
label startSeedI = 0;
bool startWalk =
findInitialSeeds
(
srcCellIDs,
mapFlag,
startSeedI,
srcSeedI,
tgtSeedI
);
if (startWalk)
{
calculateAddressing
(
srcToTgtAddr,
srcToTgtWght,
srcToTgtVec,
tgtToSrcAddr,
tgtToSrcWght,
tgtToSrcVec,
srcSeedI,
tgtSeedI,
srcCellIDs,
mapFlag,
startSeedI
);
}
else
{
// if meshes are collocated, after inflating the source mesh bounding
// box tgt mesh cells may be transferred, but may still not overlap
// with the source mesh
return;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,119 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Class
Foam::correctedCellVolumeWeightMethod
Description
Cell-volume-weighted mesh-to-mesh interpolation class
Volume conservative with calculated offset vectors
SourceFiles
correctedCellVolumeWeightMethod.C
\*---------------------------------------------------------------------------*/
#ifndef correctedCellVolumeWeightMethod_H
#define correctedCellVolumeWeightMethod_H
#include "cellVolumeWeightMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class correctedCellVolumeWeightMethod Declaration
\*---------------------------------------------------------------------------*/
class correctedCellVolumeWeightMethod
:
public cellVolumeWeightMethod
{
protected:
// Protected Member Functions
//- Calculate the mesh-to-mesh addressing and weights
void calculateAddressing
(
labelListList& srcToTgtCellAddr,
scalarListList& srcToTgtCellWght,
pointListList& srcToTgtCellVec,
labelListList& tgtToSrcCellAddr,
scalarListList& tgtToSrcCellWght,
pointListList& tgtToSrcCellVec,
const label srcSeedI,
const label tgtSeedI,
const labelList& srcCellIDs,
boolList& mapFlag,
label& startSeedI
);
//- Disallow default bitwise copy construct
correctedCellVolumeWeightMethod(const correctedCellVolumeWeightMethod&);
//- Disallow default bitwise assignment
void operator=(const correctedCellVolumeWeightMethod&);
public:
//- Run-time type information
TypeName("correctedCellVolumeWeight");
//- Construct from source and target meshes
correctedCellVolumeWeightMethod(const polyMesh& src, const polyMesh& tgt);
//- Destructor
virtual ~correctedCellVolumeWeightMethod();
// Member Functions
// Evaluate
//- Calculate addressing and weights and optionally offset vectors
virtual void calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -72,21 +72,15 @@ bool Foam::directMethod::findInitialSeeds
if (mapFlag[srcI])
{
const pointField
pts(srcCells[srcI].points(srcFaces, srcPts).xfer());
const point srcCtr(srcCells[srcI].centre(srcPts, srcFaces));
label tgtI = tgt_.cellTree().findInside(srcCtr);
forAll(pts, ptI)
if (tgtI != -1 && intersect(srcI, tgtI))
{
const point& pt = pts[ptI];
label tgtI = tgt_.cellTree().findInside(pt);
srcSeedI = srcI;
tgtSeedI = tgtI;
if (tgtI != -1 && intersect(srcI, tgtI))
{
srcSeedI = srcI;
tgtSeedI = tgtI;
return true;
}
return true;
}
}
}
@ -178,8 +172,6 @@ void Foam::directMethod::appendToDirectSeeds
const labelList& srcNbr = src_.cellCells()[srcSeedI];
const labelList& tgtNbr = tgt_.cellCells()[tgtSeedI];
const vectorField& srcCentre = src_.cellCentres();
forAll(srcNbr, i)
{
label srcI = srcNbr[i];
@ -194,15 +186,7 @@ void Foam::directMethod::appendToDirectSeeds
{
label tgtI = tgtNbr[j];
if
(
tgt_.pointInCell
(
srcCentre[srcI],
tgtI,
polyMesh::FACE_PLANES
)
)
if (intersect(srcI, tgtI))
{
// new match - append to lists
found = true;
@ -251,14 +235,17 @@ Foam::directMethod::directMethod
Foam::directMethod::~directMethod()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::directMethod::calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
)
{
bool ok = initialise

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -121,13 +121,15 @@ public:
// Evaluate
//- Calculate addressing and weights
//- Calculate addressing and weights and optionally offset vectors
virtual void calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
labelListList& tgtToTgtAddr,
scalarListList& tgtToTgtWght
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
);
};

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -359,8 +359,10 @@ void Foam::mapNearestMethod::calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
)
{
bool ok = initialise

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -134,13 +134,15 @@ public:
// Evaluate
//- Calculate addressing and weights
//- Calculate addressing and weights and optionally offset vectors
virtual void calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
labelListList& tgtToTgtAddr,
scalarListList& tgtToTgtWght
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
);
};

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -121,6 +121,42 @@ Foam::scalar Foam::meshToMeshMethod::interVol
}
Foam::Tuple2<Foam::scalar, Foam::point>
Foam::meshToMeshMethod::interVolAndCentroid
(
const label srcCellI,
const label tgtCellI
)
{
tetOverlapVolume overlapEngine;
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCellI]);
Tuple2<scalar, point> volAndInertia =
overlapEngine.cellCellOverlapMomentMinDecomp
(
src_,
srcCellI,
tgt_,
tgtCellI,
bbTgtCell
);
// Convert from inertia to centroid
if (volAndInertia.first() <= ROOTVSMALL)
{
volAndInertia.first() = 0.0;
volAndInertia.second() = vector::zero;
}
else
{
volAndInertia.second() /= volAndInertia.first();
}
return volAndInertia;
}
void Foam::meshToMeshMethod::appendNbrCells
(
const label cellI,

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,8 +36,8 @@ SourceFiles
#define meshToMeshMethod_H
#include "polyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointList.H"
#include "Tuple2.H"
namespace Foam
{
@ -85,6 +85,13 @@ protected:
const label tgtCellI
) const;
//- Return the intersection volume and centroid between two cells
virtual Tuple2<scalar, point> interVolAndCentroid
(
const label srcCellI,
const label tgtCellI
);
//- Append target cell neihgbour cells to cellIDs list
virtual void appendNbrCells
(
@ -147,13 +154,15 @@ public:
// Evaluate
//- Calculate addressing and weights
//- Calculate addressing and weights and optionally offset vectors
virtual void calculate
(
labelListList& srcToTgtAddr,
scalarListList& srcToTgtWght,
labelListList& tgtToTgtAddr,
scalarListList& tgtToTgtWght
pointListList& srcToTgtVec,
labelListList& tgtToSrcAddr,
scalarListList& tgtToSrcWght,
pointListList& tgtToSrcVec
) = 0;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -22,17 +22,18 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::weightedFvPatchFieldMapper
Foam::distributedWeightedFvPatchFieldMapper
Description
FieldMapper with weighted mapping.
FieldMapper with weighted mapping from (optionally remote) quantities.
\*---------------------------------------------------------------------------*/
#ifndef weightedFvPatchFieldMapper_H
#define weightedFvPatchFieldMapper_H
#ifndef distributedWeightedFvPatchFieldMapper_H
#define distributedWeightedFvPatchFieldMapper_H
#include "fvPatchFieldMapper.H"
#include "mapDistributeBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -40,13 +41,17 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class weightedFvPatchFieldMapper Declaration
Class distributedWeightedFvPatchFieldMapper Declaration
\*---------------------------------------------------------------------------*/
class weightedFvPatchFieldMapper
class distributedWeightedFvPatchFieldMapper
:
public fvPatchFieldMapper
{
const label singlePatchProc_;
const mapDistributeBase* distMapPtr_;
const labelListList& addressing_;
const scalarListList& weights_;
@ -58,12 +63,16 @@ public:
// Constructors
//- Construct given addressing
weightedFvPatchFieldMapper
distributedWeightedFvPatchFieldMapper
(
const label singlePatchProc,
const mapDistributeBase* distMapPtr,
const labelListList& addressing,
const scalarListList& weights
)
:
singlePatchProc_(singlePatchProc),
distMapPtr_(distMapPtr),
addressing_(addressing),
weights_(weights),
hasUnmapped_(false)
@ -75,10 +84,23 @@ public:
hasUnmapped_ = true;
}
}
if ((singlePatchProc_ == -1) != (distMapPtr_ != NULL))
{
FatalErrorIn
(
"distributedWeightedFvPatchFieldMapper::"
"distributedWeightedFvPatchFieldMapper(..)"
) << "Supply a mapDistributeBase if and only if "
<< "singlePatchProc is -1"
<< " singlePatchProc_:" << singlePatchProc_
<< " distMapPtr_:" << (distMapPtr_ != NULL)
<< exit(FatalError);
}
}
//- Destructor
virtual ~weightedFvPatchFieldMapper()
virtual ~distributedWeightedFvPatchFieldMapper()
{}
@ -86,7 +108,14 @@ public:
virtual label size() const
{
return addressing().size();
if (distributed())
{
return distributeMap().constructSize();
}
else
{
return addressing().size();
}
}
virtual bool direct() const
@ -94,6 +123,25 @@ public:
return false;
}
virtual bool distributed() const
{
return singlePatchProc_ == -1;
}
virtual const mapDistributeBase& distributeMap() const
{
if (!distMapPtr_)
{
FatalErrorIn
(
"distributedWeightedFvPatchFieldMapper::"
"distributeMap()"
) << "Cannot ask for distributeMap on a non-distributed"
<< " mapper" << exit(FatalError);
}
return *distMapPtr_;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,21 +38,288 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::meshToMesh::interpolationMethod,
3
4
>::names[] =
{
"direct",
"mapNearest",
"cellVolumeWeight"
"cellVolumeWeight",
"correctedCellVolumeWeight"
};
const NamedEnum<meshToMesh::interpolationMethod, 3>
const NamedEnum<meshToMesh::interpolationMethod, 4>
meshToMesh::interpolationMethodNames_;
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>& field,
const plusEqOp<sphericalTensor>& cop,
GeometricField<sphericalTensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>& field,
const minusEqOp<sphericalTensor>& cop,
GeometricField<sphericalTensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<symmTensor, fvPatchField, volMesh>& field,
const plusEqOp<symmTensor>& cop,
GeometricField<symmTensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<symmTensor, fvPatchField, volMesh>& field,
const minusEqOp<symmTensor>& cop,
GeometricField<symmTensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<tensor, fvPatchField, volMesh>& field,
const plusEqOp<tensor>& cop,
GeometricField<tensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<tensor, fvPatchField, volMesh>& field,
const minusEqOp<tensor>& cop,
GeometricField<tensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>& field,
const plusEqOp<sphericalTensor>& cop,
GeometricField<sphericalTensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>& field,
const minusEqOp<sphericalTensor>& cop,
GeometricField<sphericalTensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<symmTensor, fvPatchField, volMesh>& field,
const plusEqOp<symmTensor>& cop,
GeometricField<symmTensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<symmTensor, fvPatchField, volMesh>& field,
const minusEqOp<symmTensor>& cop,
GeometricField<symmTensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<tensor, fvPatchField, volMesh>& field,
const plusEqOp<tensor>& cop,
GeometricField<tensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<tensor, fvPatchField, volMesh>& field,
const minusEqOp<tensor>& cop,
GeometricField<tensor, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
}
template<>
void Foam::meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<scalar>& srcField,
Field<scalar>& tgtField,
const plusEqOp<scalar>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<vector>& srcField,
Field<vector>& tgtField,
const plusEqOp<vector>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<sphericalTensor>& srcField,
Field<sphericalTensor>& tgtField,
const plusEqOp<sphericalTensor>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<symmTensor>& srcField,
Field<symmTensor>& tgtField,
const plusEqOp<symmTensor>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<tensor>& srcField,
Field<tensor>& tgtField,
const plusEqOp<tensor>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<scalar>& srcField,
const Field<scalar>& tgtField,
const plusEqOp<scalar>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<vector>& srcField,
const Field<vector>& tgtField,
const plusEqOp<vector>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<sphericalTensor>& srcField,
const Field<sphericalTensor>& tgtField,
const plusEqOp<sphericalTensor>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<symmTensor>& srcField,
const Field<symmTensor>& tgtField,
const plusEqOp<symmTensor>& cop
) const
{}
template<>
void Foam::meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<tensor>& srcField,
const Field<tensor>& tgtField,
const plusEqOp<tensor>& cop
) const
{}
Foam::labelList Foam::meshToMesh::maskCells
(
const polyMesh& src,
@ -138,8 +405,10 @@ void Foam::meshToMesh::calcAddressing
(
srcToTgtCellAddr_,
srcToTgtCellWght_,
srcToTgtCellVec_,
tgtToSrcCellAddr_,
tgtToSrcCellWght_
tgtToSrcCellWght_,
tgtToSrcCellVec_
);
V_ = methodPtr->V();
@ -265,28 +534,34 @@ void Foam::meshToMesh::calculate(const word& methodName)
}
// set up as a reverse distribute
mapDistribute::distribute
mapDistributeBase::distribute
(
Pstream::nonBlocking,
List<labelPair>(),
tgtRegion_.nCells(),
map.constructMap(),
false,
map.subMap(),
false,
tgtToSrcCellAddr_,
ListPlusEqOp<label>(),
flipOp(),
labelList()
);
// set up as a reverse distribute
mapDistribute::distribute
mapDistributeBase::distribute
(
Pstream::nonBlocking,
List<labelPair>(),
tgtRegion_.nCells(),
map.constructMap(),
false,
map.subMap(),
false,
tgtToSrcCellWght_,
ListPlusEqOp<scalar>(),
flipOp(),
scalarList()
);
@ -358,6 +633,7 @@ Foam::meshToMesh::interpolationMethodAMI(const interpolationMethod method)
break;
}
case imCellVolumeWeight:
case imCorrectedCellVolumeWeight:
{
return AMIPatchToPatchInterpolation::imFaceAreaWeight;
break;
@ -493,23 +769,28 @@ void Foam::meshToMesh::constructFromCuttingPatches
const wordList& cuttingPatches
)
{
srcPatchID_.setSize(patchMap.size());
tgtPatchID_.setSize(patchMap.size());
DynamicList<label> srcIDs(patchMap.size());
DynamicList<label> tgtIDs(patchMap.size());
label i = 0;
forAllConstIter(HashTable<word>, patchMap, iter)
{
const word& tgtPatchName = iter.key();
const word& srcPatchName = iter();
const polyPatch& srcPatch = srcRegion_.boundaryMesh()[srcPatchName];
const polyPatch& tgtPatch = tgtRegion_.boundaryMesh()[tgtPatchName];
srcPatchID_[i] = srcPatch.index();
tgtPatchID_[i] = tgtPatch.index();
i++;
if (!polyPatch::constraintType(srcPatch.type()))
{
const polyPatch& tgtPatch = tgtRegion_.boundaryMesh()[tgtPatchName];
srcIDs.append(srcPatch.index());
tgtIDs.append(tgtPatch.index());
}
}
srcPatchID_.transfer(srcIDs);
tgtPatchID_.transfer(tgtIDs);
// calculate volume addressing and weights
calculate(methodName);
@ -546,6 +827,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellAddr_(),
srcToTgtCellWght_(),
tgtToSrcCellWght_(),
srcToTgtCellVec_(),
tgtToSrcCellVec_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
@ -582,6 +865,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellAddr_(),
srcToTgtCellWght_(),
tgtToSrcCellWght_(),
srcToTgtCellVec_(),
tgtToSrcCellVec_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,11 +43,12 @@ SourceFiles
#define meshToMesh_H
#include "polyMesh.H"
#include "boundBox.H"
#include "treeBoundBox.H"
#include "mapDistribute.H"
#include "volFieldsFwd.H"
#include "NamedEnum.H"
#include "AMIPatchToPatchInterpolation.H"
#include "pointList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,10 +70,11 @@ public:
{
imDirect,
imMapNearest,
imCellVolumeWeight
imCellVolumeWeight,
imCorrectedCellVolumeWeight
};
static const NamedEnum<interpolationMethod, 3>
static const NamedEnum<interpolationMethod, 4>
interpolationMethodNames_;
private:
@ -109,6 +111,15 @@ private:
//- Target to source cell interpolation weights
scalarListList tgtToSrcCellWght_;
// Vectors from cell centre to overlap volume for 2nd order correction
// (only set for corrected methods)
//- Source to target cell offset vectors
pointListList srcToTgtCellVec_;
//- Target to source cell offset vectors
pointListList tgtToSrcCellVec_;
//- Cell total volume in overlap region [m3]
scalar V_;
@ -129,6 +140,50 @@ private:
template<class Type>
void add(UList<Type>& fld, const label offset) const;
//- Helper function to interpolate internal field. Optionally uses
// gradient. Template specialisations for tensor types below
template<class Type, class CombineOp>
void mapInternalSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
const bool secondOrder
) const;
//- Helper function to interpolate internal field. Optionally uses
// gradient. Template specialisations for tensor types below
template<class Type, class CombineOp>
void mapInternalTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
const bool secondOrder
) const;
//- Helper function to interpolate patch field. Template
// specialisations below
template<class Type, class CombineOp>
void mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<Type>& srcField,
Field<Type>& tgtField,
const CombineOp& cop
) const;
//- Helper function to interpolate patch field. Template
// specialisations below
template<class Type, class CombineOp>
void mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<Type>& srcField,
const Field<Type>& tgtField,
const CombineOp& cop
) const;
//- Return src cell IDs for the overlap region
labelList maskCells(const polyMesh& src, const polyMesh& tgt) const;
@ -172,11 +227,6 @@ private:
const wordList& cuttingPatches
);
//- Return the list of AMIs between source and target patches
inline const PtrList<AMIPatchToPatchInterpolation>&
patchAMIs() const;
// Parallel operations
//- Determine whether the meshes are split across multiple pocessors
@ -189,7 +239,7 @@ private:
//- Determine which processor bounding-boxes overlap
label calcOverlappingProcs
(
const List<boundBox>& procBb,
const List<treeBoundBoxList>& procBb,
const boundBox& bb,
boolList& overlaps
) const;
@ -312,6 +362,12 @@ public:
//- Return const access to the target to source cell weights
inline const scalarListList& tgtToSrcCellWght() const;
//- Return const access to the source to target offset vectors
inline const pointListList& srcToTgtCellVec() const;
//- Return const access to the target to source offset vectors
inline const pointListList& tgtToSrcCellVec() const;
//- Return const access to the overlap volume
inline scalar V() const;
@ -322,12 +378,16 @@ public:
const interpolationMethod method
);
//- Return the list of AMIs between source and target patches
inline const PtrList<AMIPatchToPatchInterpolation>&
patchAMIs() const;
// Evaluation
// Source-to-target field mapping
//- 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
// return value
template<class Type, class CombineOp>
@ -338,8 +398,23 @@ public:
List<Type>& result
) const;
//- Map extrapolated field (using gradient) from src to tgt
// mesh with defined operation. Falls back to non-extrapolated
// mapping (above) if not constructed with method that supports
// getting offset vectors. Extrapolation only for internal
// values. Values passed in via 'result' are used to
// initialise the return value.
template<class Type, class CombineOp>
void mapSrcToTgt
(
const UList<Type>& srcField,
const UList<typename outerProduct<vector, Type>::type>&,
const CombineOp& cop,
List<Type>& result
) const;
//- 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
(
@ -386,8 +461,23 @@ public:
List<Type>& result
) const;
//- Map extrapolated field (using gradient) from tgt to src
// mesh with defined operation. Falls back to non-extrapolated
// mapping (above) if not constructed with method that supports
// getting offset vectors. Extrapolation only for internal
// values. Values passed in via 'result' are used to
// initialise the return value
template<class Type, class CombineOp>
void mapTgtToSrc
(
const UList<Type>& srcField,
const UList<typename outerProduct<vector, Type>::type>&,
const CombineOp& cop,
List<Type>& result
) const;
//- 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
(
@ -425,13 +515,15 @@ public:
//- Interpolate a field with a defined operation. Values
// passed in via 'result' are used to initialise the return
// value
// value. Optionallly uses gradient correction (internal
// field only) if interpolationMethod supports it
template<class Type, class CombineOp>
void mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result
GeometricField<Type, fvPatchField, volMesh>& result,
const bool secondOrder = true
) const;
//- Interpolate a field with a defined operation. The initial
@ -440,7 +532,8 @@ public:
tmp<GeometricField<Type, fvPatchField, volMesh> > mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop
const CombineOp& cop,
const bool secondOrder = true
) const;
//- Interpolate a tmp field with a defined operation. The
@ -450,7 +543,8 @@ public:
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >&
tfield,
const CombineOp& cop
const CombineOp& cop,
const bool secondOrder = true
) const;
//- Convenience function to map a field with a default
@ -458,7 +552,8 @@ public:
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field
const GeometricField<Type, fvPatchField, volMesh>& field,
const bool secondOrder = true
) const;
//- Convenience function to map a tmp field with a default
@ -467,7 +562,8 @@ public:
tmp<GeometricField<Type, fvPatchField, volMesh> > mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >&
tfield
tfield,
const bool secondOrder = true
) const;
@ -475,13 +571,15 @@ public:
//- Interpolate a field with a defined operation. Values
// passed in via 'result' are used to initialise the return
// value
// value. Optionallly uses gradient correction (internal
// field only) if interpolationMethod supports it
template<class Type, class CombineOp>
void mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result
GeometricField<Type, fvPatchField, volMesh>& result,
const bool secondOrder = true
) const;
//- Interpolate a field with a defined operation. The initial
@ -490,7 +588,8 @@ public:
tmp<GeometricField<Type, fvPatchField, volMesh> > mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop
const CombineOp& cop,
const bool secondOrder = true
) const;
//- Interpolate a tmp field with a defined operation. The
@ -500,7 +599,8 @@ public:
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >&
tfield,
const CombineOp& cop
const CombineOp& cop,
const bool secondOrder = true
) const;
//- Convenience function to map a field with a default
@ -508,7 +608,8 @@ public:
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field
const GeometricField<Type, fvPatchField, volMesh>& field,
const bool secondOrder = true
) const;
//- Convenience function to map a tmp field with a default
@ -517,13 +618,200 @@ public:
tmp<GeometricField<Type, fvPatchField, volMesh> > mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >&
tfield
tfield,
const bool secondOrder = true
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Disable gradient 2nd order correction for tensor types
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const plusEqOp<sphericalTensor>&,
GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const minusEqOp<sphericalTensor>&,
GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<symmTensor, fvPatchField, volMesh>&,
const plusEqOp<symmTensor>&,
GeometricField<symmTensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<symmTensor, fvPatchField, volMesh>&,
const minusEqOp<symmTensor>&,
GeometricField<symmTensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<tensor, fvPatchField, volMesh>&,
const plusEqOp<tensor>&,
GeometricField<tensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalSrcToTgt
(
const GeometricField<tensor, fvPatchField, volMesh>&,
const minusEqOp<tensor>&,
GeometricField<tensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const plusEqOp<sphericalTensor>&,
GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const minusEqOp<sphericalTensor>&,
GeometricField<sphericalTensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<symmTensor, fvPatchField, volMesh>&,
const plusEqOp<symmTensor>&,
GeometricField<symmTensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<symmTensor, fvPatchField, volMesh>&,
const minusEqOp<symmTensor>&,
GeometricField<symmTensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<tensor, fvPatchField, volMesh>&,
const plusEqOp<tensor>&,
GeometricField<tensor, fvPatchField, volMesh>&,
const bool
) const;
template<>
void meshToMesh::mapInternalTgtToSrc
(
const GeometricField<tensor, fvPatchField, volMesh>&,
const minusEqOp<tensor>&,
GeometricField<tensor, fvPatchField, volMesh>&,
const bool
) const;
// Disable fvPatchField value override after rmap
template<>
void meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<scalar>& srcField,
Field<scalar>& tgtField,
const plusEqOp<scalar>& cop
) const;
template<>
void meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<vector>& srcField,
Field<vector>& tgtField,
const plusEqOp<vector>& cop
) const;
template<>
void meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<sphericalTensor>& srcField,
Field<sphericalTensor>& tgtField,
const plusEqOp<sphericalTensor>& cop
) const;
template<>
void meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<symmTensor>& srcField,
Field<symmTensor>& tgtField,
const plusEqOp<symmTensor>& cop
) const;
template<>
void meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<tensor>& srcField,
Field<tensor>& tgtField,
const plusEqOp<tensor>& cop
) const;
template<>
void meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<scalar>& srcField,
const Field<scalar>& tgtField,
const plusEqOp<scalar>& cop
) const;
template<>
void meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<vector>& srcField,
const Field<vector>& tgtField,
const plusEqOp<vector>& cop
) const;
template<>
void meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<sphericalTensor>& srcField,
const Field<sphericalTensor>& tgtField,
const plusEqOp<sphericalTensor>& cop
) const;
template<>
void meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<symmTensor>& srcField,
const Field<symmTensor>& tgtField,
const plusEqOp<symmTensor>& cop
) const;
template<>
void meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<tensor>& srcField,
const Field<tensor>& tgtField,
const plusEqOp<tensor>& cop
) const;
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,34 +39,42 @@ inline const Foam::polyMesh& Foam::meshToMesh::tgtRegion() const
}
inline const Foam::labelListList&
Foam::meshToMesh::srcToTgtCellAddr() const
inline const Foam::labelListList& Foam::meshToMesh::srcToTgtCellAddr() const
{
return srcToTgtCellAddr_;
}
inline const Foam::labelListList&
Foam::meshToMesh::tgtToSrcCellAddr() const
inline const Foam::labelListList& Foam::meshToMesh::tgtToSrcCellAddr() const
{
return tgtToSrcCellAddr_;
}
inline const Foam::scalarListList&
Foam::meshToMesh::srcToTgtCellWght() const
inline const Foam::scalarListList& Foam::meshToMesh::srcToTgtCellWght() const
{
return srcToTgtCellWght_;
}
inline const Foam::scalarListList&
Foam::meshToMesh::tgtToSrcCellWght() const
inline const Foam::scalarListList& Foam::meshToMesh::tgtToSrcCellWght() const
{
return tgtToSrcCellWght_;
}
inline const Foam::pointListList& Foam::meshToMesh::srcToTgtCellVec() const
{
return srcToTgtCellVec_;
}
inline const Foam::pointListList& Foam::meshToMesh::tgtToSrcCellVec() const
{
return tgtToSrcCellVec_;
}
inline Foam::scalar Foam::meshToMesh::V() const
{
return V_;

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,6 +30,7 @@ License
#include "mergePoints.H"
#include "processorPolyPatch.H"
#include "SubField.H"
#include "AABBTree.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -84,7 +85,7 @@ Foam::label Foam::meshToMesh::calcDistribution
Foam::label Foam::meshToMesh::calcOverlappingProcs
(
const List<boundBox>& procBb,
const List<treeBoundBoxList>& procBb,
const boundBox& bb,
boolList& overlaps
) const
@ -95,12 +96,16 @@ Foam::label Foam::meshToMesh::calcOverlappingProcs
forAll(procBb, procI)
{
const boundBox& bbp = procBb[procI];
const treeBoundBoxList& bbp = procBb[procI];
if (bbp.overlaps(bb))
forAll(bbp, bbI)
{
overlaps[procI] = true;
nOverlaps++;
if (bbp[bbI].overlaps(bb))
{
overlaps[procI] = true;
nOverlaps++;
break;
}
}
}
@ -115,20 +120,20 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
) const
{
// get decomposition of cells on src mesh
List<boundBox> procBb(Pstream::nProcs());
List<treeBoundBoxList> procBb(Pstream::nProcs());
if (src.nCells() > 0)
{
// bounding box for my mesh - do not parallel reduce
procBb[Pstream::myProcNo()] = boundBox(src.points(), false);
// slightly increase size of bounding boxes to allow for cases where
// bounding boxes are perfectly alligned
procBb[Pstream::myProcNo()].inflate(0.01);
procBb[Pstream::myProcNo()] = AABBTree<labelList>
(
src.cellPoints(),
src.points(),
false
).boundBoxes();
}
else
{
procBb[Pstream::myProcNo()] = boundBox();
procBb[Pstream::myProcNo()] = treeBoundBoxList();
}
@ -417,7 +422,7 @@ void Foam::meshToMesh::distributeCells
labelList globalElems(sendElems.size());
forAll(sendElems, i)
{
if (debug)
if (debug > 1)
{
Pout<< "tgtProc:" << Pstream::myProcNo()
<< " sending tgt cell " << sendElems[i]
@ -605,7 +610,7 @@ void Foam::meshToMesh::distributeAndMergeCells
}
else
{
if (debug)
if (debug > 1)
{
Pout<< "Additional internal face between procs:"
<< key[0] << " and " << key[1]
@ -732,7 +737,7 @@ void Foam::meshToMesh::distributeAndMergeCells
label newNbr = fnd();
label tgtFaceI = internalFaceOffset[procI]++;
if (debug)
if (debug > 1)
{
Pout<< " proc " << procI
<< "\tinserting face:" << tgtFaceI
@ -812,7 +817,7 @@ void Foam::meshToMesh::distributeAndMergeCells
label newOwn = cellOffset[procI] + faceOs[i];
label tgtFaceI = nIntFaces++;
if (debug)
if (debug > 1)
{
Pout<< " proc " << procI
<< "\tinserting boundary face:" << tgtFaceI

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,7 +27,8 @@ License
#include "volFields.H"
#include "directFvPatchFieldMapper.H"
#include "calculatedFvPatchField.H"
#include "weightedFvPatchFieldMapper.H"
#include "fvcGrad.H"
#include "distributedWeightedFvPatchFieldMapper.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -118,7 +119,6 @@ void Foam::meshToMesh::mapSrcToTgt
if (srcAddress.size())
{
// result[cellI] = pTraits<Type>::zero;
result[cellI] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i)
{
@ -138,7 +138,6 @@ void Foam::meshToMesh::mapSrcToTgt
if (srcAddress.size())
{
// result[cellI] = pTraits<Type>::zero;
result[cellI] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i)
{
@ -152,6 +151,108 @@ void Foam::meshToMesh::mapSrcToTgt
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapSrcToTgt
(
const UList<Type>& srcField,
const UList<typename outerProduct<vector, Type>::type>& srcGradField,
const CombineOp& cop,
List<Type>& result
) const
{
if (result.size() != tgtToSrcCellAddr_.size())
{
FatalErrorIn
(
"void Foam::meshToMesh::mapSrcToTgt"
"("
"const UList<Type>&, "
"const UList<typename outerProduct<vector, Type>::type>&, "
"const CombineOp&, "
"List<Type>&"
") const"
) << "Supplied field size is not equal to target mesh size" << nl
<< " source mesh = " << srcToTgtCellAddr_.size() << nl
<< " target mesh = " << tgtToSrcCellAddr_.size() << nl
<< " supplied field = " << result.size()
<< abort(FatalError);
}
multiplyWeightedOp<Type, CombineOp> cbop(cop);
if (singleMeshProc_ == -1)
{
if (returnReduce(tgtToSrcCellVec_.size(), sumOp<label>()) == 0)
{
// No correction vectors calculated. Fall back to first order.
mapSrcToTgt(srcField, cop, result);
return;
}
const mapDistribute& map = srcMapPtr_();
List<Type> work(srcField);
map.distribute(work);
List<typename outerProduct<vector, Type>::type> workGrad
(
srcGradField
);
map.distribute(workGrad);
forAll(result, cellI)
{
const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
const pointList& srcVec = tgtToSrcCellVec_[cellI];
if (srcAddress.size())
{
result[cellI] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i)
{
label srcI = srcAddress[i];
scalar w = srcWeight[i];
const vector& v = srcVec[i];
const Type srcVal = work[srcI]+(workGrad[srcI]&v);
cbop(result[cellI], cellI, srcVal, w);
}
}
}
}
else
{
if (tgtToSrcCellVec_.empty())
{
// No correction vectors calculated. Fall back to first order.
mapSrcToTgt(srcField, cop, result);
return;
}
forAll(result, cellI)
{
const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
const pointList& srcVec = tgtToSrcCellVec_[cellI];
if (srcAddress.size())
{
// Do non-conservative interpolation
result[cellI] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i)
{
label srcI = srcAddress[i];
scalar w = srcWeight[i];
const vector& v = srcVec[i];
const Type srcVal = srcField[srcI]+(srcGradField[srcI]&v);
cbop(result[cellI], cellI, srcVal, w);
}
}
}
}
}
template<class Type, class CombineOp>
Foam::tmp<Foam::Field<Type> > Foam::meshToMesh::mapSrcToTgt
(
@ -278,6 +379,100 @@ void Foam::meshToMesh::mapTgtToSrc
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapTgtToSrc
(
const UList<Type>& tgtField,
const UList<typename outerProduct<vector, Type>::type>& tgtGradField,
const CombineOp& cop,
List<Type>& result
) const
{
if (result.size() != srcToTgtCellAddr_.size())
{
FatalErrorIn
(
"void Foam::meshToMesh::mapTgtToSrc"
"("
"const UList<Type>&, "
"const UList<typename outerProduct<vector, Type>::type>&, "
"const CombineOp&, "
"List<Type>&"
") const"
) << "Supplied field size is not equal to source mesh size" << nl
<< " source mesh = " << srcToTgtCellAddr_.size() << nl
<< " target mesh = " << tgtToSrcCellAddr_.size() << nl
<< " supplied field = " << result.size()
<< abort(FatalError);
}
multiplyWeightedOp<Type, CombineOp> cbop(cop);
if (singleMeshProc_ == -1)
{
if (returnReduce(srcToTgtCellVec_.size(), sumOp<label>()) == 0)
{
// No correction vectors calculated. Fall back to first order.
mapTgtToSrc(tgtField, cop, result);
return;
}
const mapDistribute& map = tgtMapPtr_();
List<Type> work(tgtField);
map.distribute(work);
List<typename outerProduct<vector, Type>::type> workGrad
(
tgtGradField
);
map.distribute(workGrad);
forAll(result, cellI)
{
const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
const pointList& tgtVec = srcToTgtCellVec_[cellI];
if (tgtAddress.size())
{
result[cellI] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i)
{
label tgtI = tgtAddress[i];
scalar w = tgtWeight[i];
const vector& v = tgtVec[i];
const Type tgtVal = work[tgtI]+(workGrad[tgtI]&v);
cbop(result[cellI], cellI, tgtVal, w);
}
}
}
}
else
{
forAll(result, cellI)
{
const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
const pointList& tgtVec = srcToTgtCellVec_[cellI];
if (tgtAddress.size())
{
result[cellI] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i)
{
label tgtI = tgtAddress[i];
scalar w = tgtWeight[i];
const vector& v = tgtVec[i];
const Type tgtVal = tgtField[tgtI]+(tgtGradField[tgtI]&v);
cbop(result[cellI], cellI, tgtVal, w);
}
}
}
}
}
template<class Type, class CombineOp>
Foam::tmp<Foam::Field<Type> > Foam::meshToMesh::mapTgtToSrc
(
@ -331,15 +526,64 @@ Foam::tmp<Foam::Field<Type> > Foam::meshToMesh::mapTgtToSrc
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapInternalSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
if (secondOrder && returnReduce(tgtToSrcCellVec_.size(), sumOp<label>()))
{
mapSrcToTgt
(
field,
fvc::grad(field)().internalField(),
cop,
result.internalField()
);
}
else
{
mapSrcToTgt(field, cop, result.internalField());
}
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapAndOpSrcToTgt
(
const AMIPatchToPatchInterpolation& AMI,
const Field<Type>& srcField,
Field<Type>& tgtField,
const CombineOp& cop
) const
{
tgtField = pTraits<Type>::zero;
AMI.interpolateToTarget
(
srcField,
multiplyWeightedOp<Type, CombineOp>(cop),
tgtField,
UList<Type>::null()
);
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result
GeometricField<Type, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.internalField());
mapInternalSrcToTgt(field, cop, result, secondOrder);
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
@ -351,40 +595,37 @@ void Foam::meshToMesh::mapSrcToTgt
const fvPatchField<Type>& srcField = field.boundaryField()[srcPatchI];
fvPatchField<Type>& tgtField = result.boundaryField()[tgtPatchI];
// 2.3 does not do distributed mapping yet so only do if
// running on single processor
if (AMIList[i].singlePatchProc() != -1)
{
// Clone and map (since rmap does not do general mapping)
tmp<fvPatchField<Type> > tnewTgt
(
fvPatchField<Type>::New
(
srcField,
tgtField.patch(),
result.dimensionedInternalField(),
weightedFvPatchFieldMapper
(
AMIList[i].tgtAddress(),
AMIList[i].tgtWeights()
)
)
);
// Transfer all mapped quantities (value and e.g. gradient) onto
// tgtField. Value will get overwritten below.
tgtField.rmap(tnewTgt(), identity(tgtField.size()));
}
tgtField == pTraits<Type>::zero;
AMIList[i].interpolateToTarget
// Clone and map (since rmap does not do general mapping)
tmp<fvPatchField<Type> > tnewTgt
(
srcField,
multiplyWeightedOp<Type, CombineOp>(cop),
tgtField,
UList<Type>::null()
fvPatchField<Type>::New
(
srcField,
tgtField.patch(),
result.dimensionedInternalField(),
distributedWeightedFvPatchFieldMapper
(
AMIList[i].singlePatchProc(),
(
AMIList[i].singlePatchProc() == -1
? &AMIList[i].srcMap()
: NULL
),
AMIList[i].tgtAddress(),
AMIList[i].tgtWeights()
)
)
);
// Transfer all mapped quantities (value and e.g. gradient) onto
// tgtField
tgtField.rmap(tnewTgt(), identity(tgtField.size()));
// Override value to account for CombineOp (note: is dummy template
// specialisation for plusEqOp)
mapAndOpSrcToTgt(AMIList[i], srcField, tgtField, cop);
}
forAll(cuttingPatches_, i)
@ -401,7 +642,8 @@ Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop
const CombineOp& cop,
const bool secondOrder
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
@ -480,7 +722,7 @@ Foam::meshToMesh::mapSrcToTgt
)
);
mapSrcToTgt(field, cop, tresult());
mapSrcToTgt(field, cop, tresult(), secondOrder);
return tresult;
}
@ -491,32 +733,82 @@ Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield,
const CombineOp& cop,
const bool secondOrder
) const
{
return mapSrcToTgt(tfield(), cop, secondOrder);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const bool secondOrder
) const
{
return mapSrcToTgt(field, plusEqOp<Type>(), secondOrder);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield,
const bool secondOrder
) const
{
return mapSrcToTgt(tfield(), plusEqOp<Type>(), secondOrder);
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapInternalTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
if (secondOrder && returnReduce(srcToTgtCellVec_.size(), sumOp<label>()))
{
mapTgtToSrc
(
field,
fvc::grad(field)().internalField(),
cop,
result.internalField()
);
}
else
{
mapTgtToSrc(field, cop, result.internalField());
}
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<Type>& srcField,
const Field<Type>& tgtField,
const CombineOp& cop
) const
{
return mapSrcToTgt(tfield(), cop);
}
srcField = pTraits<Type>::zero;
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>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield
) const
{
return mapSrcToTgt(tfield(), plusEqOp<Type>());
AMI.interpolateToSource
(
tgtField,
multiplyWeightedOp<Type, CombineOp>(cop),
srcField,
UList<Type>::null()
);
}
@ -525,10 +817,12 @@ void Foam::meshToMesh::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result
GeometricField<Type, fvPatchField, volMesh>& result,
const bool secondOrder
) const
{
mapTgtToSrc(field, cop, result.internalField());
mapInternalTgtToSrc(field, cop, result, secondOrder);
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
@ -540,40 +834,37 @@ void Foam::meshToMesh::mapTgtToSrc
fvPatchField<Type>& srcField = result.boundaryField()[srcPatchI];
const fvPatchField<Type>& tgtField = field.boundaryField()[tgtPatchI];
// 2.3 does not do distributed mapping yet so only do if
// running on single processor
if (AMIList[i].singlePatchProc() != -1)
{
// Clone and map (since rmap does not do general mapping)
tmp<fvPatchField<Type> > tnewSrc
(
fvPatchField<Type>::New
(
tgtField,
srcField.patch(),
result.dimensionedInternalField(),
weightedFvPatchFieldMapper
(
AMIList[i].srcAddress(),
AMIList[i].srcWeights()
)
)
);
// Transfer all mapped quantities (value and e.g. gradient) onto
// srcField. Value will get overwritten below
srcField.rmap(tnewSrc(), identity(srcField.size()));
}
srcField == pTraits<Type>::zero;
AMIList[i].interpolateToSource
// Clone and map (since rmap does not do general mapping)
tmp<fvPatchField<Type> > tnewSrc
(
tgtField,
multiplyWeightedOp<Type, CombineOp>(cop),
srcField,
UList<Type>::null()
fvPatchField<Type>::New
(
tgtField,
srcField.patch(),
result.dimensionedInternalField(),
distributedWeightedFvPatchFieldMapper
(
AMIList[i].singlePatchProc(),
(
AMIList[i].singlePatchProc() == -1
? &AMIList[i].tgtMap()
: NULL
),
AMIList[i].srcAddress(),
AMIList[i].srcWeights()
)
)
);
// Transfer all mapped quantities (value and e.g. gradient) onto
// tgtField
srcField.rmap(tnewSrc(), identity(srcField.size()));
// Override value to account for CombineOp (could be dummy for
// plusEqOp)
mapAndOpTgtToSrc(AMIList[i], srcField, tgtField, cop);
}
forAll(cuttingPatches_, i)
@ -590,7 +881,8 @@ Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop
const CombineOp& cop,
const bool secondOrder
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
@ -669,7 +961,7 @@ Foam::meshToMesh::mapTgtToSrc
)
);
mapTgtToSrc(field, cop, tresult());
mapTgtToSrc(field, cop, tresult(), secondOrder);
return tresult;
}
@ -680,10 +972,11 @@ Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield,
const CombineOp& cop
const CombineOp& cop,
const bool secondOrder
) const
{
return mapTgtToSrc(tfield(), cop);
return mapTgtToSrc(tfield(), cop, secondOrder);
}
@ -691,10 +984,11 @@ template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field
const GeometricField<Type, fvPatchField, volMesh>& field,
const bool secondOrder
) const
{
return mapTgtToSrc(field, plusEqOp<Type>());
return mapTgtToSrc(field, plusEqOp<Type>(), secondOrder);
}
@ -702,10 +996,11 @@ template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMesh::mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield,
const bool secondOrder
) const
{
return mapTgtToSrc(tfield(), plusEqOp<Type>());
return mapTgtToSrc(tfield(), plusEqOp<Type>(), secondOrder);
}