GIT: Initial state after latest Foundation merge

This commit is contained in:
Andrew Heather
2016-09-20 14:49:08 +01:00
4571 changed files with 115696 additions and 74609 deletions

View File

@ -103,8 +103,8 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
label& startSeedI
)
{
label srcCellI = srcSeedI;
label tgtCellI = tgtSeedI;
label srcCelli = srcSeedI;
label tgtCelli = tgtSeedI;
List<DynamicList<label>> srcToTgtAddr(src_.nCells());
List<DynamicList<scalar>> srcToTgtWght(src_.nCells());
@ -115,12 +115,12 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
// list of tgt cell neighbour cells
DynamicList<label> nbrTgtCells(10);
// list of tgt cells currently visited for srcCellI to avoid multiple hits
// 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;
seedCells[srcCelli] = tgtCelli;
const scalarField& srcVol = src_.cellVolumes();
@ -130,27 +130,27 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
visitedTgtCells.clear();
// append initial target cell and neighbours
nbrTgtCells.append(tgtCellI);
appendNbrCells(tgtCellI, tgt_, visitedTgtCells, nbrTgtCells);
nbrTgtCells.append(tgtCelli);
appendNbrCells(tgtCelli, tgt_, visitedTgtCells, nbrTgtCells);
do
{
tgtCellI = nbrTgtCells.remove();
visitedTgtCells.append(tgtCellI);
tgtCelli = nbrTgtCells.remove();
visitedTgtCells.append(tgtCelli);
scalar vol = interVol(srcCellI, tgtCellI);
scalar vol = interVol(srcCelli, tgtCelli);
// accumulate addressing and weights for valid intersection
if (vol/srcVol[srcCellI] > tolerance_)
if (vol/srcVol[srcCelli] > tolerance_)
{
// store src/tgt cell pair
srcToTgtAddr[srcCellI].append(tgtCellI);
srcToTgtWght[srcCellI].append(vol);
srcToTgtAddr[srcCelli].append(tgtCelli);
srcToTgtWght[srcCelli].append(vol);
tgtToSrcAddr[tgtCellI].append(srcCellI);
tgtToSrcWght[tgtCellI].append(vol);
tgtToSrcAddr[tgtCelli].append(srcCelli);
tgtToSrcWght[tgtCelli].append(vol);
appendNbrCells(tgtCellI, tgt_, visitedTgtCells, nbrTgtCells);
appendNbrCells(tgtCelli, tgt_, visitedTgtCells, nbrTgtCells);
// accumulate intersection volume
V_ += vol;
@ -158,21 +158,21 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
}
while (!nbrTgtCells.empty());
mapFlag[srcCellI] = false;
mapFlag[srcCelli] = false;
// find new source seed cell
setNextCells
(
startSeedI,
srcCellI,
tgtCellI,
srcCelli,
tgtCelli,
srcCellIDs,
mapFlag,
visitedTgtCells,
seedCells
);
}
while (srcCellI != -1);
while (srcCelli != -1);
// transfer addressing into persistent storage
forAll(srcToTgtCellAddr, i)
@ -230,15 +230,15 @@ void Foam::cellVolumeWeightMethod::calculateAddressing
void Foam::cellVolumeWeightMethod::setNextCells
(
label& startSeedI,
label& srcCellI,
label& tgtCellI,
label& srcCelli,
label& tgtCelli,
const labelList& srcCellIDs,
const boolList& mapFlag,
const DynamicList<label>& visitedCells,
labelList& seedCells
) const
{
const labelList& srcNbrCells = src_.cellCells()[srcCellI];
const labelList& srcNbrCells = src_.cellCells()[srcCelli];
// set possible seeds for later use by querying all src cell neighbours
// with all visited target cells
@ -259,8 +259,8 @@ void Foam::cellVolumeWeightMethod::setNextCells
if (!valuesSet)
{
srcCellI = cellS;
tgtCellI = cellT;
srcCelli = cellS;
tgtCelli = cellT;
valuesSet = true;
}
}
@ -291,8 +291,8 @@ void Foam::cellVolumeWeightMethod::setNextCells
if (seedCells[cellS] != -1)
{
srcCellI = cellS;
tgtCellI = seedCells[cellS];
srcCelli = cellS;
tgtCelli = seedCells[cellS];
return;
}
@ -312,8 +312,8 @@ void Foam::cellVolumeWeightMethod::setNextCells
srcCellIDs,
mapFlag,
startSeedI,
srcCellI,
tgtCellI
srcCelli,
tgtCelli
);
if (restart)
@ -324,8 +324,8 @@ void Foam::cellVolumeWeightMethod::setNextCells
}
// if we have got to here, there are no more src/tgt cell intersections
srcCellI = -1;
tgtCellI = -1;
srcCelli = -1;
tgtCelli = -1;
}

View File

@ -85,8 +85,8 @@ protected:
void setNextCells
(
label& startSeedI,
label& srcCellI,
label& tgtCellI,
label& srcCelli,
label& tgtCelli,
const labelList& srcCellIDs,
const boolList& mapFlag,
const DynamicList<label>& visitedCells,

View File

@ -40,14 +40,14 @@ namespace Foam
bool Foam::directMethod::intersect
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const
{
return tgt_.pointInCell
(
src_.cellCentres()[srcCellI],
tgtCellI,
src_.cellCentres()[srcCelli],
tgtCelli,
polyMesh::FACE_PLANES
);
}
@ -118,20 +118,20 @@ void Foam::directMethod::calculateAddressing
const scalarField& srcVc = src_.cellVolumes();
const scalarField& tgtVc = tgt_.cellVolumes();
label srcCellI = srcSeedI;
label tgtCellI = tgtSeedI;
label srcCelli = srcSeedI;
label tgtCelli = tgtSeedI;
do
{
// store src/tgt cell pair
srcToTgt[srcCellI].append(tgtCellI);
tgtToSrc[tgtCellI].append(srcCellI);
srcToTgt[srcCelli].append(tgtCelli);
tgtToSrc[tgtCelli].append(srcCelli);
// mark source cell srcSeedI as matched
mapFlag[srcCellI] = false;
mapFlag[srcCelli] = false;
// accumulate intersection volume
V_ += srcVc[srcCellI];
V_ += srcVc[srcCelli];
// find new source seed cell
appendToDirectSeeds
@ -139,11 +139,11 @@ void Foam::directMethod::calculateAddressing
mapFlag,
srcTgtSeed,
srcSeeds,
srcCellI,
tgtCellI
srcCelli,
tgtCelli
);
}
while (srcCellI >= 0);
while (srcCelli >= 0);
// transfer addressing into persistent storage
forAll(srcToTgtCellAddr, i)

View File

@ -59,8 +59,8 @@ protected:
//- Return the true if cells intersect
virtual bool intersect
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const;
//- Find indices of overlapping cells in src and tgt meshes - returns

View File

@ -109,35 +109,35 @@ void Foam::mapNearestMethod::calculateAddressing
const scalarField& tgtVc = tgt_.cellVolumes();
{
label srcCellI = srcSeedI;
label tgtCellI = tgtSeedI;
label srcCelli = srcSeedI;
label tgtCelli = tgtSeedI;
do
{
// find nearest tgt cell
findNearestCell(src_, tgt_, srcCellI, tgtCellI);
findNearestCell(src_, tgt_, srcCelli, tgtCelli);
// store src/tgt cell pair
srcToTgt[srcCellI].append(tgtCellI);
tgtToSrc[tgtCellI].append(srcCellI);
srcToTgt[srcCelli].append(tgtCelli);
tgtToSrc[tgtCelli].append(srcCelli);
// mark source cell srcCellI and tgtCellI as matched
mapFlag[srcCellI] = false;
// mark source cell srcCelli and tgtCelli as matched
mapFlag[srcCelli] = false;
// accumulate intersection volume
V_ += srcVc[srcCellI];
V_ += srcVc[srcCelli];
// find new source cell
setNextNearestCells
(
startSeedI,
srcCellI,
tgtCellI,
srcCelli,
tgtCelli,
mapFlag,
srcCellIDs
);
}
while (srcCellI >= 0);
while (srcCelli >= 0);
}
// for the case of multiple source cells per target cell, select the
@ -145,16 +145,16 @@ void Foam::mapNearestMethod::calculateAddressing
const vectorField& srcCc = src_.cellCentres();
const vectorField& tgtCc = tgt_.cellCentres();
forAll(tgtToSrc, targetCellI)
forAll(tgtToSrc, targetCelli)
{
if (tgtToSrc[targetCellI].size() > 1)
if (tgtToSrc[targetCelli].size() > 1)
{
const vector& tgtC = tgtCc[targetCellI];
const vector& tgtC = tgtCc[targetCelli];
DynamicList<label>& srcCells = tgtToSrc[targetCellI];
DynamicList<label>& srcCells = tgtToSrc[targetCelli];
label srcCellI = srcCells[0];
scalar d = magSqr(tgtC - srcCc[srcCellI]);
label srcCelli = srcCells[0];
scalar d = magSqr(tgtC - srcCc[srcCelli]);
for (label i = 1; i < srcCells.size(); i++)
{
@ -163,26 +163,26 @@ void Foam::mapNearestMethod::calculateAddressing
if (dNew < d)
{
d = dNew;
srcCellI = srcI;
srcCelli = srcI;
}
}
srcCells.clear();
srcCells.append(srcCellI);
srcCells.append(srcCelli);
}
}
// If there are more target cells than source cells, some target cells
// might not yet be mapped
forAll(tgtToSrc, tgtCellI)
forAll(tgtToSrc, tgtCelli)
{
if (tgtToSrc[tgtCellI].empty())
if (tgtToSrc[tgtCelli].empty())
{
label srcCellI = findMappedSrcCell(tgtCellI, tgtToSrc);
label srcCelli = findMappedSrcCell(tgtCelli, tgtToSrc);
findNearestCell(tgt_, src_, tgtCellI, srcCellI);
findNearestCell(tgt_, src_, tgtCelli, srcCelli);
tgtToSrc[tgtCellI].append(srcCellI);
tgtToSrc[tgtCelli].append(srcCelli);
}
}
@ -241,29 +241,29 @@ void Foam::mapNearestMethod::findNearestCell
void Foam::mapNearestMethod::setNextNearestCells
(
label& startSeedI,
label& srcCellI,
label& tgtCellI,
label& srcCelli,
label& tgtCelli,
boolList& mapFlag,
const labelList& srcCellIDs
) const
{
const labelList& srcNbr = src_.cellCells()[srcCellI];
const labelList& srcNbr = src_.cellCells()[srcCelli];
srcCellI = -1;
srcCelli = -1;
forAll(srcNbr, i)
{
label cellI = srcNbr[i];
if (mapFlag[cellI])
label celli = srcNbr[i];
if (mapFlag[celli])
{
srcCellI = cellI;
srcCelli = celli;
return;
}
}
for (label i = startSeedI; i < srcCellIDs.size(); i++)
{
label cellI = srcCellIDs[i];
if (mapFlag[cellI])
label celli = srcCellIDs[i];
if (mapFlag[celli])
{
startSeedI = i;
break;
@ -275,26 +275,26 @@ void Foam::mapNearestMethod::setNextNearestCells
srcCellIDs,
mapFlag,
startSeedI,
srcCellI,
tgtCellI
srcCelli,
tgtCelli
);
}
Foam::label Foam::mapNearestMethod::findMappedSrcCell
(
const label tgtCellI,
const label tgtCelli,
const List<DynamicList<label>>& tgtToSrc
) const
{
DynamicList<label> testCells(10);
DynamicList<label> visitedCells(10);
testCells.append(tgtCellI);
testCells.append(tgtCelli);
do
{
// search target tgtCellI neighbours for match with source cell
// search target tgtCelli neighbours for match with source cell
label tgtI = testCells.remove();
if (findIndex(visitedCells, tgtI) == -1)

View File

@ -98,16 +98,16 @@ protected:
virtual void setNextNearestCells
(
label& startSeedI,
label& srcCellI,
label& tgtCellI,
label& srcCelli,
label& tgtCelli,
boolList& mapFlag,
const labelList& srcCellIDs
) const;
//- Find a source cell mapped to target cell tgtCellI
//- Find a source cell mapped to target cell tgtCelli
virtual label findMappedSrcCell
(
const label tgtCellI,
const label tgtCelli,
const List<DynamicList<label>>& tgtToSrc
) const;

View File

@ -76,22 +76,22 @@ Foam::labelList Foam::meshToMeshMethod::maskCells() const
bool Foam::meshToMeshMethod::intersect
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const
{
scalar threshold = tolerance_*src_.cellVolumes()[srcCellI];
scalar threshold = tolerance_*src_.cellVolumes()[srcCelli];
tetOverlapVolume overlapEngine;
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCellI]);
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCelli]);
return overlapEngine.cellCellOverlapMinDecomp
(
src_,
srcCellI,
srcCelli,
tgt_,
tgtCellI,
tgtCelli,
bbTgtCell,
threshold
);
@ -100,20 +100,20 @@ bool Foam::meshToMeshMethod::intersect
Foam::scalar Foam::meshToMeshMethod::interVol
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const
{
tetOverlapVolume overlapEngine;
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCellI]);
treeBoundBox bbTgtCell(tgt_.points(), tgt_.cellPoints()[tgtCelli]);
scalar vol = overlapEngine.cellCellOverlapVolumeMinDecomp
(
src_,
srcCellI,
srcCelli,
tgt_,
tgtCellI,
tgtCelli,
bbTgtCell
);
@ -159,26 +159,26 @@ Foam::meshToMeshMethod::interVolAndCentroid
void Foam::meshToMeshMethod::appendNbrCells
(
const label cellI,
const label celli,
const polyMesh& mesh,
const DynamicList<label>& visitedCells,
DynamicList<label>& nbrCellIDs
) const
{
const labelList& nbrCells = mesh.cellCells()[cellI];
const labelList& nbrCells = mesh.cellCells()[celli];
// filter out cells already visited from cell neighbours
forAll(nbrCells, i)
{
label nbrCellI = nbrCells[i];
label nbrCelli = nbrCells[i];
if
(
(findIndex(visitedCells, nbrCellI) == -1)
&& (findIndex(nbrCellIDs, nbrCellI) == -1)
(findIndex(visitedCells, nbrCelli) == -1)
&& (findIndex(nbrCellIDs, nbrCelli) == -1)
)
{
nbrCellIDs.append(nbrCellI);
nbrCellIDs.append(nbrCelli);
}
}
}
@ -273,10 +273,10 @@ void Foam::meshToMeshMethod::writeConnectivity
const labelList& addr = mesh1ToMesh2Addr[i];
forAll(addr, j)
{
label cellI = addr[j];
label celli = addr[j];
const vector& c0 = mesh1.cellCentres()[i];
const cell& c = mesh2.cells()[cellI];
const cell& c = mesh2.cells()[celli];
const pointField pts(c.points(mesh2.faces(), mesh2.points()));
forAll(pts, j)
{

View File

@ -74,15 +74,15 @@ protected:
//- Return the true if cells intersect
virtual bool intersect
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const;
//- Return the intersection volume between two cells
virtual scalar interVol
(
const label srcCellI,
const label tgtCellI
const label srcCelli,
const label tgtCelli
) const;
//- Return the intersection volume and centroid between two cells
@ -95,7 +95,7 @@ protected:
//- Append target cell neihgbour cells to cellIDs list
virtual void appendNbrCells
(
const label tgtCellI,
const label tgtCelli,
const polyMesh& mesh,
const DynamicList<label>& visitedTgtCells,
DynamicList<label>& nbrTgtCellIDs

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -85,13 +85,13 @@ public:
}
}
if ((singlePatchProc_ == -1) != (distMapPtr_ != NULL))
if ((singlePatchProc_ == -1) != (distMapPtr_ != nullptr))
{
FatalErrorInFunction
<< "Supply a mapDistributeBase if and only if "
<< "singlePatchProc is -1"
<< " singlePatchProc_:" << singlePatchProc_
<< " distMapPtr_:" << (distMapPtr_ != NULL)
<< " distMapPtr_:" << (distMapPtr_ != nullptr)
<< exit(FatalError);
}
}

View File

@ -368,9 +368,9 @@ void Foam::meshToMesh::normaliseWeights
if (nCell > 0)
{
forAll(wght, cellI)
forAll(wght, celli)
{
scalarList& w = wght[cellI];
scalarList& w = wght[celli];
scalar s = sum(w);
forAll(w, i)
@ -663,11 +663,11 @@ void Foam::meshToMesh::calculatePatchAMIs(const word& AMIMethodName)
forAll(srcPatchID_, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchI];
const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchI];
const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchi];
const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchi];
Info<< "Creating AMI between source patch " << srcPP.name()
<< " and target patch " << tgtPP.name()
@ -710,9 +710,9 @@ void Foam::meshToMesh::constructNoCuttingPatches
DynamicList<label> srcPatchID(srcBM.size());
DynamicList<label> tgtPatchID(tgtBM.size());
forAll(srcBM, patchI)
forAll(srcBM, patchi)
{
const polyPatch& pp = srcBM[patchI];
const polyPatch& pp = srcBM[patchi];
// We want to map all the global patches, including constraint
// patches (since they might have mappable properties, e.g.
@ -721,11 +721,11 @@ void Foam::meshToMesh::constructNoCuttingPatches
{
srcPatchID.append(pp.index());
label tgtPatchI = tgtBM.findPatchID(pp.name());
label tgtPatchi = tgtBM.findPatchID(pp.name());
if (tgtPatchI != -1)
if (tgtPatchi != -1)
{
tgtPatchID.append(tgtPatchI);
tgtPatchID.append(tgtPatchi);
}
else
{
@ -823,8 +823,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellVec_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
srcMapPtr_(nullptr),
tgtMapPtr_(nullptr)
{
constructNoCuttingPatches
(
@ -861,8 +861,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellVec_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
srcMapPtr_(nullptr),
tgtMapPtr_(nullptr)
{
constructNoCuttingPatches(methodName, AMIMethodName, interpAllPatches);
}
@ -889,8 +889,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellWght_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
srcMapPtr_(nullptr),
tgtMapPtr_(nullptr)
{
constructFromCuttingPatches
(
@ -927,8 +927,8 @@ Foam::meshToMesh::meshToMesh
tgtToSrcCellWght_(),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
srcMapPtr_(nullptr),
tgtMapPtr_(nullptr)
{
constructFromCuttingPatches
(

View File

@ -40,7 +40,7 @@ Foam::label Foam::meshToMesh::calcDistribution
const polyMesh& tgt
) const
{
label procI = 0;
label proci = 0;
if (Pstream::parRun())
{
@ -61,7 +61,7 @@ Foam::label Foam::meshToMesh::calcDistribution
if (nHaveCells > 1)
{
procI = -1;
proci = -1;
if (debug)
{
InfoInFunction
@ -70,16 +70,16 @@ Foam::label Foam::meshToMesh::calcDistribution
}
else if (nHaveCells == 1)
{
procI = findIndex(cellsPresentOnProc, 1);
proci = findIndex(cellsPresentOnProc, 1);
if (debug)
{
InfoInFunction
<< "Meshes local to processor" << procI << endl;
<< "Meshes local to processor" << proci << endl;
}
}
}
return procI;
return proci;
}
@ -94,15 +94,15 @@ Foam::label Foam::meshToMesh::calcOverlappingProcs
label nOverlaps = 0;
forAll(procBb, procI)
forAll(procBb, proci)
{
const treeBoundBoxList& bbp = procBb[procI];
const treeBoundBoxList& bbp = procBb[proci];
forAll(bbp, bbI)
forAll(bbp, bbi)
{
if (bbp[bbI].overlaps(bb))
if (bbp[bbi].overlaps(bb))
{
overlaps[procI] = true;
overlaps[proci] = true;
nOverlaps++;
break;
}
@ -146,9 +146,9 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
InfoInFunction
<< "Determining extent of src mesh per processor:" << nl
<< "\tproc\tbb" << endl;
forAll(procBb, procI)
forAll(procBb, proci)
{
Info<< '\t' << procI << '\t' << procBb[procI] << endl;
Info<< '\t' << proci << '\t' << procBb[proci] << endl;
}
}
@ -165,22 +165,22 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
List<DynamicList<label>> dynSendMap(Pstream::nProcs());
label iniSize = floor(tgt.nCells()/Pstream::nProcs());
forAll(dynSendMap, procI)
forAll(dynSendMap, proci)
{
dynSendMap[procI].setCapacity(iniSize);
dynSendMap[proci].setCapacity(iniSize);
}
// work array - whether src processor bb overlaps the tgt cell bounds
boolList procBbOverlaps(Pstream::nProcs());
forAll(cells, cellI)
forAll(cells, celli)
{
const cell& c = cells[cellI];
const cell& c = cells[celli];
// determine bounding box of tgt cell
boundBox cellBb(point::max, point::min);
forAll(c, faceI)
forAll(c, facei)
{
const face& f = faces[c[faceI]];
const face& f = faces[c[facei]];
forAll(f, fp)
{
cellBb.min() = min(cellBb.min(), points[f[fp]]);
@ -191,20 +191,20 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
// find the overlapping tgt cells on each src processor
(void)calcOverlappingProcs(procBb, cellBb, procBbOverlaps);
forAll(procBbOverlaps, procI)
forAll(procBbOverlaps, proci)
{
if (procBbOverlaps[procI])
if (procBbOverlaps[proci])
{
dynSendMap[procI].append(cellI);
dynSendMap[proci].append(celli);
}
}
}
// convert dynamicList to labelList
sendMap.setSize(Pstream::nProcs());
forAll(sendMap, procI)
forAll(sendMap, proci)
{
sendMap[procI].transfer(dynSendMap[procI]);
sendMap[proci].transfer(dynSendMap[proci]);
}
}
@ -213,9 +213,9 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
{
Pout<< "Of my " << cells.size() << " target cells I need to send to:"
<< nl << "\tproc\tcells" << endl;
forAll(sendMap, procI)
forAll(sendMap, proci)
{
Pout<< '\t' << procI << '\t' << sendMap[procI].size() << endl;
Pout<< '\t' << proci << '\t' << sendMap[proci].size() << endl;
}
}
@ -223,9 +223,9 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
// send over how many tgt cells I need to receive from each processor
labelListList sendSizes(Pstream::nProcs());
sendSizes[Pstream::myProcNo()].setSize(Pstream::nProcs());
forAll(sendMap, procI)
forAll(sendMap, proci)
{
sendSizes[Pstream::myProcNo()][procI] = sendMap[procI].size();
sendSizes[Pstream::myProcNo()][proci] = sendMap[proci].size();
}
Pstream::gatherList(sendSizes);
Pstream::scatterList(sendSizes);
@ -235,15 +235,15 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
labelListList constructMap(Pstream::nProcs());
label segmentI = 0;
forAll(constructMap, procI)
forAll(constructMap, proci)
{
// what I need to receive is what other processor is sending to me
label nRecv = sendSizes[procI][Pstream::myProcNo()];
constructMap[procI].setSize(nRecv);
label nRecv = sendSizes[proci][Pstream::myProcNo()];
constructMap[proci].setSize(nRecv);
for (label i = 0; i < nRecv; i++)
{
constructMap[procI][i] = segmentI++;
constructMap[proci][i] = segmentI++;
}
}
@ -297,9 +297,9 @@ void Foam::meshToMesh::distributeCells
{
// reverse cell map
labelList reverseCellMap(tgtMesh.nCells(), -1);
forAll(sendElems, subCellI)
forAll(sendElems, subCelli)
{
reverseCellMap[sendElems[subCellI]] = subCellI;
reverseCellMap[sendElems[subCelli]] = subCelli;
}
DynamicList<face> subFaces(tgtMesh.nFaces());
@ -312,10 +312,10 @@ void Foam::meshToMesh::distributeCells
label nInternal = 0;
// internal faces
forAll(tgtMesh.faceNeighbour(), faceI)
forAll(tgtMesh.faceNeighbour(), facei)
{
label own = tgtMesh.faceOwner()[faceI];
label nbr = tgtMesh.faceNeighbour()[faceI];
label own = tgtMesh.faceOwner()[facei];
label nbr = tgtMesh.faceNeighbour()[facei];
label subOwn = reverseCellMap[own];
label subNbr = reverseCellMap[nbr];
@ -325,7 +325,7 @@ void Foam::meshToMesh::distributeCells
if (subOwn < subNbr)
{
subFaces.append(tgtMesh.faces()[faceI]);
subFaces.append(tgtMesh.faces()[facei]);
subFaceOwner.append(subOwn);
subFaceNeighbour.append(subNbr);
subNbrProcIDs.append(-1);
@ -333,7 +333,7 @@ void Foam::meshToMesh::distributeCells
}
else
{
subFaces.append(tgtMesh.faces()[faceI].reverseFace());
subFaces.append(tgtMesh.faces()[facei].reverseFace());
subFaceOwner.append(subNbr);
subFaceNeighbour.append(subOwn);
subNbrProcIDs.append(-1);
@ -343,16 +343,16 @@ void Foam::meshToMesh::distributeCells
}
// boundary faces for new region
forAll(tgtMesh.faceNeighbour(), faceI)
forAll(tgtMesh.faceNeighbour(), facei)
{
label own = tgtMesh.faceOwner()[faceI];
label nbr = tgtMesh.faceNeighbour()[faceI];
label own = tgtMesh.faceOwner()[facei];
label nbr = tgtMesh.faceNeighbour()[facei];
label subOwn = reverseCellMap[own];
label subNbr = reverseCellMap[nbr];
if (subOwn != -1 && subNbr == -1)
{
subFaces.append(tgtMesh.faces()[faceI]);
subFaces.append(tgtMesh.faces()[facei]);
subFaceOwner.append(subOwn);
subFaceNeighbour.append(subNbr);
subNbrProcIDs.append(-1);
@ -360,7 +360,7 @@ void Foam::meshToMesh::distributeCells
}
else if (subOwn == -1 && subNbr != -1)
{
subFaces.append(tgtMesh.faces()[faceI].reverseFace());
subFaces.append(tgtMesh.faces()[facei].reverseFace());
subFaceOwner.append(subNbr);
subFaceNeighbour.append(subOwn);
subNbrProcIDs.append(-1);
@ -369,11 +369,11 @@ void Foam::meshToMesh::distributeCells
}
// boundary faces of existing region
forAll(tgtMesh.boundaryMesh(), patchI)
forAll(tgtMesh.boundaryMesh(), patchi)
{
const polyPatch& pp = tgtMesh.boundaryMesh()[patchI];
const polyPatch& pp = tgtMesh.boundaryMesh()[patchi];
label nbrProcI = -1;
label nbrProci = -1;
// store info for faces on processor patches
if (isA<processorPolyPatch>(pp))
@ -381,20 +381,20 @@ void Foam::meshToMesh::distributeCells
const processorPolyPatch& ppp =
dynamic_cast<const processorPolyPatch&>(pp);
nbrProcI = ppp.neighbProcNo();
nbrProci = ppp.neighbProcNo();
}
forAll(pp, i)
{
label faceI = pp.start() + i;
label own = tgtMesh.faceOwner()[faceI];
label facei = pp.start() + i;
label own = tgtMesh.faceOwner()[facei];
if (reverseCellMap[own] != -1)
{
subFaces.append(tgtMesh.faces()[faceI]);
subFaces.append(tgtMesh.faces()[facei]);
subFaceOwner.append(reverseCellMap[own]);
subFaceNeighbour.append(-1);
subNbrProcIDs.append(nbrProcI);
subNbrProcIDs.append(nbrProci);
subProcLocalFaceIDs.append(i);
}
}
@ -403,19 +403,19 @@ void Foam::meshToMesh::distributeCells
// reverse point map
labelList reversePointMap(tgtMesh.nPoints(), -1);
DynamicList<point> subPoints(tgtMesh.nPoints());
forAll(subFaces, subFaceI)
forAll(subFaces, subFacei)
{
face& f = subFaces[subFaceI];
face& f = subFaces[subFacei];
forAll(f, fp)
{
label pointI = f[fp];
if (reversePointMap[pointI] == -1)
label pointi = f[fp];
if (reversePointMap[pointi] == -1)
{
reversePointMap[pointI] = subPoints.size();
subPoints.append(tgtMesh.points()[pointI]);
reversePointMap[pointi] = subPoints.size();
subPoints.append(tgtMesh.points()[pointi]);
}
f[fp] = reversePointMap[pointI];
f[fp] = reversePointMap[pointi];
}
}
@ -568,19 +568,19 @@ void Foam::meshToMesh::distributeAndMergeCells
// Starting offset for points
label nPoints = 0;
labelList pointOffset(Pstream::nProcs(), 0);
forAll(allPoints, procI)
forAll(allPoints, proci)
{
pointOffset[procI] = nPoints;
nPoints += allPoints[procI].size();
pointOffset[proci] = nPoints;
nPoints += allPoints[proci].size();
}
// Starting offset for cells
label nCells = 0;
labelList cellOffset(Pstream::nProcs(), 0);
forAll(allTgtCellIDs, procI)
forAll(allTgtCellIDs, proci)
{
cellOffset[procI] = nCells;
nCells += allTgtCellIDs[procI].size();
cellOffset[proci] = nCells;
nCells += allTgtCellIDs[proci].size();
}
// Count any coupled faces
@ -588,19 +588,19 @@ void Foam::meshToMesh::distributeAndMergeCells
typedef HashTable<label, label3, label3::Hash<>> procCoupleInfo;
procCoupleInfo procFaceToGlobalCell;
forAll(allNbrProcIDs, procI)
forAll(allNbrProcIDs, proci)
{
const labelList& nbrProcI = allNbrProcIDs[procI];
const labelList& localFaceI = allProcLocalFaceIDs[procI];
const labelList& nbrProci = allNbrProcIDs[proci];
const labelList& localFacei = allProcLocalFaceIDs[proci];
forAll(nbrProcI, i)
forAll(nbrProci, i)
{
if (nbrProcI[i] != -1 && localFaceI[i] != -1)
if (nbrProci[i] != -1 && localFacei[i] != -1)
{
label3 key;
key[0] = min(procI, nbrProcI[i]);
key[1] = max(procI, nbrProcI[i]);
key[2] = localFaceI[i];
key[0] = min(proci, nbrProci[i]);
key[1] = max(proci, nbrProci[i]);
key[2] = localFacei[i];
procCoupleInfo::const_iterator fnd =
procFaceToGlobalCell.find(key);
@ -618,7 +618,7 @@ void Foam::meshToMesh::distributeAndMergeCells
<< " across local face " << key[2] << endl;
}
allNIntCoupledFaces[procI]++;
allNIntCoupledFaces[proci]++;
}
}
}
@ -629,14 +629,14 @@ void Foam::meshToMesh::distributeAndMergeCells
label nIntFaces = 0;
label nFacesTotal = 0;
labelList internalFaceOffset(Pstream::nProcs(), 0);
forAll(allNIntCoupledFaces, procI)
forAll(allNIntCoupledFaces, proci)
{
label nCoupledFaces =
allNIntCoupledFaces[procI] - allNInternalFaces[procI];
allNIntCoupledFaces[proci] - allNInternalFaces[proci];
internalFaceOffset[procI] = nIntFaces;
nIntFaces += allNIntCoupledFaces[procI];
nFacesTotal += allFaceOwners[procI].size() - nCoupledFaces;
internalFaceOffset[proci] = nIntFaces;
nIntFaces += allNIntCoupledFaces[proci];
nFacesTotal += allFaceOwners[proci].size() - nCoupledFaces;
}
tgtPoints.setSize(nPoints);
@ -646,99 +646,99 @@ void Foam::meshToMesh::distributeAndMergeCells
tgtCellIDs.setSize(nCells);
// Insert points
forAll(allPoints, procI)
forAll(allPoints, proci)
{
const pointField& pts = allPoints[procI];
SubList<point>(tgtPoints, pts.size(), pointOffset[procI]) = pts;
const pointField& pts = allPoints[proci];
SubList<point>(tgtPoints, pts.size(), pointOffset[proci]) = pts;
}
// Insert cellIDs
forAll(allTgtCellIDs, procI)
forAll(allTgtCellIDs, proci)
{
const labelList& cellIDs = allTgtCellIDs[procI];
SubList<label>(tgtCellIDs, cellIDs.size(), cellOffset[procI]) = cellIDs;
const labelList& cellIDs = allTgtCellIDs[proci];
SubList<label>(tgtCellIDs, cellIDs.size(), cellOffset[proci]) = cellIDs;
}
// Insert internal faces (from internal faces)
forAll(allFaces, procI)
forAll(allFaces, proci)
{
const faceList& fcs = allFaces[procI];
const labelList& faceOs = allFaceOwners[procI];
const labelList& faceNs = allFaceNeighbours[procI];
const faceList& fcs = allFaces[proci];
const labelList& faceOs = allFaceOwners[proci];
const labelList& faceNs = allFaceNeighbours[proci];
SubList<face> slice
(
tgtFaces,
allNInternalFaces[procI],
internalFaceOffset[procI]
allNInternalFaces[proci],
internalFaceOffset[proci]
);
slice = SubList<face>(fcs, allNInternalFaces[procI]);
slice = SubList<face>(fcs, allNInternalFaces[proci]);
forAll(slice, i)
{
add(slice[i], pointOffset[procI]);
add(slice[i], pointOffset[proci]);
}
SubField<label> ownSlice
(
tgtFaceOwners,
allNInternalFaces[procI],
internalFaceOffset[procI]
allNInternalFaces[proci],
internalFaceOffset[proci]
);
ownSlice = SubField<label>(faceOs, allNInternalFaces[procI]);
add(ownSlice, cellOffset[procI]);
ownSlice = SubField<label>(faceOs, allNInternalFaces[proci]);
add(ownSlice, cellOffset[proci]);
SubField<label> nbrSlice
(
tgtFaceNeighbours,
allNInternalFaces[procI],
internalFaceOffset[procI]
allNInternalFaces[proci],
internalFaceOffset[proci]
);
nbrSlice = SubField<label>(faceNs, allNInternalFaces[procI]);
add(nbrSlice, cellOffset[procI]);
nbrSlice = SubField<label>(faceNs, allNInternalFaces[proci]);
add(nbrSlice, cellOffset[proci]);
internalFaceOffset[procI] += allNInternalFaces[procI];
internalFaceOffset[proci] += allNInternalFaces[proci];
}
// Insert internal faces (from coupled face-pairs)
forAll(allNbrProcIDs, procI)
forAll(allNbrProcIDs, proci)
{
const labelList& nbrProcI = allNbrProcIDs[procI];
const labelList& localFaceI = allProcLocalFaceIDs[procI];
const labelList& faceOs = allFaceOwners[procI];
const faceList& fcs = allFaces[procI];
const labelList& nbrProci = allNbrProcIDs[proci];
const labelList& localFacei = allProcLocalFaceIDs[proci];
const labelList& faceOs = allFaceOwners[proci];
const faceList& fcs = allFaces[proci];
forAll(nbrProcI, i)
forAll(nbrProci, i)
{
if (nbrProcI[i] != -1 && localFaceI[i] != -1)
if (nbrProci[i] != -1 && localFacei[i] != -1)
{
label3 key;
key[0] = min(procI, nbrProcI[i]);
key[1] = max(procI, nbrProcI[i]);
key[2] = localFaceI[i];
key[0] = min(proci, nbrProci[i]);
key[1] = max(proci, nbrProci[i]);
key[2] = localFacei[i];
procCoupleInfo::iterator fnd = procFaceToGlobalCell.find(key);
if (fnd != procFaceToGlobalCell.end())
{
label tgtFaceI = fnd();
if (tgtFaceI == -1)
label tgtFacei = fnd();
if (tgtFacei == -1)
{
// on first visit store the new cell on this side
fnd() = cellOffset[procI] + faceOs[i];
fnd() = cellOffset[proci] + faceOs[i];
}
else
{
// get owner and neighbour in new cell numbering
label newOwn = cellOffset[procI] + faceOs[i];
label newOwn = cellOffset[proci] + faceOs[i];
label newNbr = fnd();
label tgtFaceI = internalFaceOffset[procI]++;
label tgtFacei = internalFaceOffset[proci]++;
if (debug > 1)
{
Pout<< " proc " << procI
<< "\tinserting face:" << tgtFaceI
Pout<< " proc " << proci
<< "\tinserting face:" << tgtFacei
<< " connection between owner " << newOwn
<< " and neighbour " << newNbr
<< endl;
@ -747,19 +747,19 @@ void Foam::meshToMesh::distributeAndMergeCells
if (newOwn < newNbr)
{
// we have correct orientation
tgtFaces[tgtFaceI] = fcs[i];
tgtFaceOwners[tgtFaceI] = newOwn;
tgtFaceNeighbours[tgtFaceI] = newNbr;
tgtFaces[tgtFacei] = fcs[i];
tgtFaceOwners[tgtFacei] = newOwn;
tgtFaceNeighbours[tgtFacei] = newNbr;
}
else
{
// reverse orientation
tgtFaces[tgtFaceI] = fcs[i].reverseFace();
tgtFaceOwners[tgtFaceI] = newNbr;
tgtFaceNeighbours[tgtFaceI] = newOwn;
tgtFaces[tgtFacei] = fcs[i].reverseFace();
tgtFaceOwners[tgtFacei] = newNbr;
tgtFaceNeighbours[tgtFacei] = newOwn;
}
add(tgtFaces[tgtFaceI], pointOffset[procI]);
add(tgtFaces[tgtFacei], pointOffset[proci]);
// mark with unique value
fnd() = -2;
@ -770,50 +770,50 @@ void Foam::meshToMesh::distributeAndMergeCells
}
forAll(allNbrProcIDs, procI)
forAll(allNbrProcIDs, proci)
{
const labelList& nbrProcI = allNbrProcIDs[procI];
const labelList& localFaceI = allProcLocalFaceIDs[procI];
const labelList& faceOs = allFaceOwners[procI];
const labelList& faceNs = allFaceNeighbours[procI];
const faceList& fcs = allFaces[procI];
const labelList& nbrProci = allNbrProcIDs[proci];
const labelList& localFacei = allProcLocalFaceIDs[proci];
const labelList& faceOs = allFaceOwners[proci];
const labelList& faceNs = allFaceNeighbours[proci];
const faceList& fcs = allFaces[proci];
forAll(nbrProcI, i)
forAll(nbrProci, i)
{
// coupled boundary face
if (nbrProcI[i] != -1 && localFaceI[i] != -1)
if (nbrProci[i] != -1 && localFacei[i] != -1)
{
label3 key;
key[0] = min(procI, nbrProcI[i]);
key[1] = max(procI, nbrProcI[i]);
key[2] = localFaceI[i];
key[0] = min(proci, nbrProci[i]);
key[1] = max(proci, nbrProci[i]);
key[2] = localFacei[i];
label tgtFaceI = procFaceToGlobalCell[key];
label tgtFacei = procFaceToGlobalCell[key];
if (tgtFaceI == -1)
if (tgtFacei == -1)
{
FatalErrorInFunction
<< "Unvisited " << key
<< abort(FatalError);
}
else if (tgtFaceI != -2)
else if (tgtFacei != -2)
{
label newOwn = cellOffset[procI] + faceOs[i];
label tgtFaceI = nIntFaces++;
label newOwn = cellOffset[proci] + faceOs[i];
label tgtFacei = nIntFaces++;
if (debug > 1)
{
Pout<< " proc " << procI
<< "\tinserting boundary face:" << tgtFaceI
Pout<< " proc " << proci
<< "\tinserting boundary face:" << tgtFacei
<< " from coupled face " << key
<< endl;
}
tgtFaces[tgtFaceI] = fcs[i];
add(tgtFaces[tgtFaceI], pointOffset[procI]);
tgtFaces[tgtFacei] = fcs[i];
add(tgtFaces[tgtFacei], pointOffset[proci]);
tgtFaceOwners[tgtFaceI] = newOwn;
tgtFaceNeighbours[tgtFaceI] = -1;
tgtFaceOwners[tgtFacei] = newOwn;
tgtFaceNeighbours[tgtFacei] = -1;
}
}
// normal boundary face
@ -823,14 +823,14 @@ void Foam::meshToMesh::distributeAndMergeCells
label nbr = faceNs[i];
if ((own != -1) && (nbr == -1))
{
label newOwn = cellOffset[procI] + faceOs[i];
label tgtFaceI = nIntFaces++;
label newOwn = cellOffset[proci] + faceOs[i];
label tgtFacei = nIntFaces++;
tgtFaces[tgtFaceI] = fcs[i];
add(tgtFaces[tgtFaceI], pointOffset[procI]);
tgtFaces[tgtFacei] = fcs[i];
add(tgtFaces[tgtFacei], pointOffset[proci]);
tgtFaceOwners[tgtFaceI] = newOwn;
tgtFaceNeighbours[tgtFaceI] = -1;
tgtFaceOwners[tgtFacei] = newOwn;
tgtFaceNeighbours[tgtFacei] = -1;
}
}
}

View File

@ -105,40 +105,40 @@ void Foam::meshToMesh::mapSrcToTgt
List<Type> work(srcField);
map.distribute(work);
forAll(result, cellI)
forAll(result, celli)
{
const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
const labelList& srcAddress = tgtToSrcCellAddr_[celli];
const scalarList& srcWeight = tgtToSrcCellWght_[celli];
if (srcAddress.size())
{
// result[cellI] = Zero;
result[cellI] *= (1.0 - sum(srcWeight));
// result[celli] = Zero;
result[celli] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i)
{
label srcI = srcAddress[i];
scalar w = srcWeight[i];
cbop(result[cellI], cellI, work[srcI], w);
cbop(result[celli], celli, work[srcI], w);
}
}
}
}
else
{
forAll(result, cellI)
forAll(result, celli)
{
const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
const labelList& srcAddress = tgtToSrcCellAddr_[celli];
const scalarList& srcWeight = tgtToSrcCellWght_[celli];
if (srcAddress.size())
{
// result[cellI] = Zero;
result[cellI] *= (1.0 - sum(srcWeight));
// result[celli] = Zero;
result[celli] *= (1.0 - sum(srcWeight));
forAll(srcAddress, i)
{
label srcI = srcAddress[i];
scalar w = srcWeight[i];
cbop(result[cellI], cellI, srcField[srcI], w);
cbop(result[celli], celli, srcField[srcI], w);
}
}
}
@ -320,38 +320,38 @@ void Foam::meshToMesh::mapTgtToSrc
List<Type> work(tgtField);
map.distribute(work);
forAll(result, cellI)
forAll(result, celli)
{
const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
const labelList& tgtAddress = srcToTgtCellAddr_[celli];
const scalarList& tgtWeight = srcToTgtCellWght_[celli];
if (tgtAddress.size())
{
result[cellI] *= (1.0 - sum(tgtWeight));
result[celli] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i)
{
label tgtI = tgtAddress[i];
scalar w = tgtWeight[i];
cbop(result[cellI], cellI, work[tgtI], w);
cbop(result[celli], celli, work[tgtI], w);
}
}
}
}
else
{
forAll(result, cellI)
forAll(result, celli)
{
const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
const labelList& tgtAddress = srcToTgtCellAddr_[celli];
const scalarList& tgtWeight = srcToTgtCellWght_[celli];
if (tgtAddress.size())
{
result[cellI] *= (1.0 - sum(tgtWeight));
result[celli] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i)
{
label tgtI = tgtAddress[i];
scalar w = tgtWeight[i];
cbop(result[cellI], cellI, tgtField[tgtI], w);
cbop(result[celli], celli, tgtField[tgtI], w);
}
}
}
@ -512,14 +512,14 @@ void Foam::meshToMesh::mapInternalSrcToTgt
mapSrcToTgt
(
field,
fvc::grad(field)().internalField(),
fvc::grad(field)().primitiveField(),
cop,
result.internalField()
result.primitiveFieldRef()
);
}
else
{
mapSrcToTgt(field, cop, result.internalField());
mapSrcToTgt(field, cop, result.primitiveFieldRef());
}
}
@ -554,19 +554,20 @@ void Foam::meshToMesh::mapSrcToTgt
const bool secondOrder
) const
{
mapInternalSrcToTgt(field, cop, result, secondOrder);
mapInternalSrcToTgt(field, cop, result.primitiveFieldRef(), secondOrder);
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
typename GeometricField<Type, fvPatchField, volMesh>::
Boundary& resultBf = result.boundaryFieldRef();
forAll(AMIList, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
const fvPatchField<Type>& srcField = field.boundaryField()[srcPatchI];
fvPatchField<Type>& tgtField = result.boundaryField()[tgtPatchI];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
const fvPatchField<Type>& srcField = field.boundaryField()[srcPatchi];
fvPatchField<Type>& tgtField = resultBf[tgtPatchi];
// Clone and map (since rmap does not do general mapping)
tmp<fvPatchField<Type>> tnewTgt
@ -575,14 +576,14 @@ void Foam::meshToMesh::mapSrcToTgt
(
srcField,
tgtField.patch(),
result.dimensionedInternalField(),
result(),
distributedWeightedFvPatchFieldMapper
(
AMIList[i].singlePatchProc(),
(
AMIList[i].singlePatchProc() == -1
? &AMIList[i].srcMap()
: NULL
: nullptr
),
AMIList[i].tgtAddress(),
AMIList[i].tgtWeights()
@ -591,7 +592,7 @@ void Foam::meshToMesh::mapSrcToTgt
);
// Transfer all mapped quantities (value and e.g. gradient) onto
// tgtField
// tgtField. Value will get overwritten below.
tgtField.rmap(tnewTgt(), identity(tgtField.size()));
// Override value to account for CombineOp (note: is dummy template
@ -601,8 +602,8 @@ void Foam::meshToMesh::mapSrcToTgt
forAll(cuttingPatches_, i)
{
label patchI = cuttingPatches_[i];
fvPatchField<Type>& pf = result.boundaryField()[patchI];
label patchi = cuttingPatches_[i];
fvPatchField<Type>& pf = resultBf[patchi];
pf == pf.patchInternalField();
}
}
@ -622,32 +623,32 @@ Foam::meshToMesh::mapSrcToTgt
const fvMesh& tgtMesh = static_cast<const fvMesh&>(tgtRegion_);
const fvBoundaryMesh& tgtBm = tgtMesh.boundary();
const typename fieldType::GeometricBoundaryField& srcBfld =
const typename fieldType::Boundary& srcBfld =
field.boundaryField();
PtrList<fvPatchField<Type>> tgtPatchFields(tgtBm.size());
// constuct tgt boundary patch types as copy of 'field' boundary types
// construct tgt boundary patch types as copy of 'field' boundary types
// note: this will provide place holders for fields with additional
// entries, but these values will need to be reset
forAll(tgtPatchID_, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
if (!tgtPatchFields.set(tgtPatchI))
if (!tgtPatchFields.set(tgtPatchi))
{
tgtPatchFields.set
(
tgtPatchI,
tgtPatchi,
fvPatchField<Type>::New
(
srcBfld[srcPatchI],
tgtMesh.boundary()[tgtPatchI],
srcBfld[srcPatchi],
tgtMesh.boundary()[tgtPatchi],
DimensionedField<Type, volMesh>::null(),
directFvPatchFieldMapper
(
labelList(tgtMesh.boundary()[tgtPatchI].size(), -1)
labelList(tgtMesh.boundary()[tgtPatchi].size(), -1)
)
)
);
@ -655,19 +656,19 @@ Foam::meshToMesh::mapSrcToTgt
}
// Any unset tgtPatchFields become calculated
forAll(tgtPatchFields, tgtPatchI)
forAll(tgtPatchFields, tgtPatchi)
{
if (!tgtPatchFields.set(tgtPatchI))
if (!tgtPatchFields.set(tgtPatchi))
{
// Note: use factory New method instead of direct generation of
// calculated so we keep constraints
tgtPatchFields.set
(
tgtPatchI,
tgtPatchi,
fvPatchField<Type>::New
(
calculatedFvPatchField<Type>::typeName,
tgtMesh.boundary()[tgtPatchI],
tgtMesh.boundary()[tgtPatchi],
DimensionedField<Type, volMesh>::null()
)
);
@ -783,6 +784,27 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapAndOpTgtToSrc
(
const AMIPatchToPatchInterpolation& AMI,
Field<Type>& srcField,
const Field<Type>& tgtField,
const CombineOp& cop
) const
{
srcField = pTraits<Type>::zero;
AMI.interpolateToSource
(
tgtField,
multiplyWeightedOp<Type, CombineOp>(cop),
srcField,
UList<Type>::null()
);
}
template<class Type, class CombineOp>
void Foam::meshToMesh::mapTgtToSrc
(
@ -792,18 +814,18 @@ void Foam::meshToMesh::mapTgtToSrc
const bool secondOrder
) const
{
mapInternalTgtToSrc(field, cop, result, secondOrder);
mapInternalTgtToSrc(field, cop, result.primitiveFieldRef(), secondOrder);
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
forAll(AMIList, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
fvPatchField<Type>& srcField = result.boundaryFieldRef()[srcPatchi];
const fvPatchField<Type>& tgtField = field.boundaryField()[tgtPatchi];
fvPatchField<Type>& srcField = result.boundaryField()[srcPatchI];
const fvPatchField<Type>& tgtField = field.boundaryField()[tgtPatchI];
// Clone and map (since rmap does not do general mapping)
tmp<fvPatchField<Type>> tnewSrc
@ -812,23 +834,22 @@ void Foam::meshToMesh::mapTgtToSrc
(
tgtField,
srcField.patch(),
result.dimensionedInternalField(),
result(),
distributedWeightedFvPatchFieldMapper
(
AMIList[i].singlePatchProc(),
(
AMIList[i].singlePatchProc() == -1
? &AMIList[i].tgtMap()
: NULL
: nullptr
),
AMIList[i].srcAddress(),
AMIList[i].srcWeights()
)
)
);
// Transfer all mapped quantities (value and e.g. gradient) onto
// tgtField
// srcField. Value will get overwritten below
srcField.rmap(tnewSrc(), identity(srcField.size()));
// Override value to account for CombineOp (could be dummy for
@ -838,8 +859,8 @@ void Foam::meshToMesh::mapTgtToSrc
forAll(cuttingPatches_, i)
{
label patchI = cuttingPatches_[i];
fvPatchField<Type>& pf = result.boundaryField()[patchI];
label patchi = cuttingPatches_[i];
fvPatchField<Type>& pf = result.boundaryFieldRef()[patchi];
pf == pf.patchInternalField();
}
}
@ -859,7 +880,7 @@ Foam::meshToMesh::mapTgtToSrc
const fvMesh& srcMesh = static_cast<const fvMesh&>(srcRegion_);
const fvBoundaryMesh& srcBm = srcMesh.boundary();
const typename fieldType::GeometricBoundaryField& tgtBfld =
const typename fieldType::Boundary& tgtBfld =
field.boundaryField();
PtrList<fvPatchField<Type>> srcPatchFields(srcBm.size());
@ -869,22 +890,22 @@ Foam::meshToMesh::mapTgtToSrc
// entries, but these values will need to be reset
forAll(srcPatchID_, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
if (!srcPatchFields.set(tgtPatchI))
if (!srcPatchFields.set(tgtPatchi))
{
srcPatchFields.set
(
srcPatchI,
srcPatchi,
fvPatchField<Type>::New
(
tgtBfld[srcPatchI],
srcMesh.boundary()[tgtPatchI],
tgtBfld[srcPatchi],
srcMesh.boundary()[tgtPatchi],
DimensionedField<Type, volMesh>::null(),
directFvPatchFieldMapper
(
labelList(srcMesh.boundary()[srcPatchI].size(), -1)
labelList(srcMesh.boundary()[srcPatchi].size(), -1)
)
)
);
@ -892,19 +913,19 @@ Foam::meshToMesh::mapTgtToSrc
}
// Any unset srcPatchFields become calculated
forAll(srcPatchFields, srcPatchI)
forAll(srcPatchFields, srcPatchi)
{
if (!srcPatchFields.set(srcPatchI))
if (!srcPatchFields.set(srcPatchi))
{
// Note: use factory New method instead of direct generation of
// calculated so we keep constraints
srcPatchFields.set
(
srcPatchI,
srcPatchi,
fvPatchField<Type>::New
(
calculatedFvPatchField<Type>::typeName,
srcMesh.boundary()[srcPatchI],
srcMesh.boundary()[srcPatchi],
DimensionedField<Type, volMesh>::null()
)
);