ENH: Store additional information to handle split cyclics (still not correct though)

This commit is contained in:
mattijs
2010-04-14 15:57:36 +01:00
parent d807c16732
commit bdaca3a63f
2 changed files with 451 additions and 188 deletions

View File

@ -30,6 +30,9 @@ License
#include "faceCoupleInfo.H" #include "faceCoupleInfo.H"
#include "processorFvPatchField.H" #include "processorFvPatchField.H"
#include "processorFvsPatchField.H" #include "processorFvsPatchField.H"
#include "processorCyclicPolyPatch.H"
#include "processorCyclicFvPatchField.H"
#include "processorCyclicFvsPatchField.H"
#include "polyTopoChange.H" #include "polyTopoChange.H"
#include "removeCells.H" #include "removeCells.H"
#include "polyModifyFace.H" #include "polyModifyFace.H"
@ -129,6 +132,7 @@ void Foam::fvMeshDistribute::printMeshInfo(const fvMesh& mesh)
{ {
Pout<< "Primitives:" << nl Pout<< "Primitives:" << nl
<< " points :" << mesh.nPoints() << nl << " points :" << mesh.nPoints() << nl
<< " bb :" << boundBox(mesh.points(), false) << nl
<< " internalFaces:" << mesh.nInternalFaces() << nl << " internalFaces:" << mesh.nInternalFaces() << nl
<< " faces :" << mesh.nFaces() << nl << " faces :" << mesh.nFaces() << nl
<< " cells :" << mesh.nCells() << nl; << " cells :" << mesh.nCells() << nl;
@ -188,7 +192,8 @@ void Foam::fvMeshDistribute::printCoupleInfo
const primitiveMesh& mesh, const primitiveMesh& mesh,
const labelList& sourceFace, const labelList& sourceFace,
const labelList& sourceProc, const labelList& sourceProc,
const labelList& sourceNewProc const labelList& sourcePatch,
const labelList& sourceNewNbrProc
) )
{ {
Pout<< nl Pout<< nl
@ -203,7 +208,7 @@ void Foam::fvMeshDistribute::printCoupleInfo
<< " fc:" << mesh.faceCentres()[meshFaceI] << " fc:" << mesh.faceCentres()[meshFaceI]
<< " connects to proc:" << sourceProc[bFaceI] << " connects to proc:" << sourceProc[bFaceI]
<< "/face:" << sourceFace[bFaceI] << "/face:" << sourceFace[bFaceI]
<< " which will move to proc:" << sourceNewProc[bFaceI] << " which will move to proc:" << sourceNewNbrProc[bFaceI]
<< endl; << endl;
} }
} }
@ -271,32 +276,87 @@ Foam::label Foam::fvMeshDistribute::findNonEmptyPatch() const
} }
// Appends processorPolyPatch. Returns patchID. //// Appends processorPolyPatch. Returns patchID.
Foam::label Foam::fvMeshDistribute::addProcPatch //Foam::label Foam::fvMeshDistribute::addProcPatch
( //(
const word& patchName, // const word& patchName,
const label nbrProc // const label nbrProc
) //)
//{
// // Clear local fields and e.g. polyMesh globalMeshData.
// mesh_.clearOut();
//
//
// polyBoundaryMesh& polyPatches =
// const_cast<polyBoundaryMesh&>(mesh_.boundaryMesh());
// fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh_.boundary());
//
// if (polyPatches.findPatchID(patchName) != -1)
// {
// FatalErrorIn("fvMeshDistribute::addProcPatch(const word&, const label)")
// << "Cannot create patch " << patchName << " since already exists."
// << nl
// << "Current patch names:" << polyPatches.names()
// << exit(FatalError);
// }
//
//
//
// // Add the patch
// // ~~~~~~~~~~~~~
//
// label sz = polyPatches.size();
//
// // Add polyPatch
// polyPatches.setSize(sz+1);
// polyPatches.set
// (
// sz,
// new processorPolyPatch
// (
// patchName,
// 0, // size
// mesh_.nFaces(),
// sz,
// mesh_.boundaryMesh(),
// Pstream::myProcNo(),
// nbrProc
// )
// );
// fvPatches.setSize(sz+1);
// fvPatches.set
// (
// sz,
// fvPatch::New
// (
// polyPatches[sz], // point to newly added polyPatch
// mesh_.boundary()
// )
// );
//
// return sz;
//}
// Appends polyPatch. Returns patchID.
Foam::label Foam::fvMeshDistribute::addPatch(polyPatch* patchPtr)
{ {
// Clear local fields and e.g. polyMesh globalMeshData. // Clear local fields and e.g. polyMesh globalMeshData.
mesh_.clearOut(); mesh_.clearOut();
polyBoundaryMesh& polyPatches = polyBoundaryMesh& polyPatches =
const_cast<polyBoundaryMesh&>(mesh_.boundaryMesh()); const_cast<polyBoundaryMesh&>(mesh_.boundaryMesh());
fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh_.boundary()); fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh_.boundary());
if (polyPatches.findPatchID(patchName) != -1) if (polyPatches.findPatchID(patchPtr->name()) != -1)
{ {
FatalErrorIn("fvMeshDistribute::addProcPatch(const word&, const label)") FatalErrorIn("fvMeshDistribute::addPatch(polyPatch*)")
<< "Cannot create patch " << patchName << " since already exists." << "Cannot create patch " << patchPtr->name()
<< nl << " since already exists." << nl
<< "Current patch names:" << polyPatches.names() << "Current patch names:" << polyPatches.names() << exit(FatalError);
<< exit(FatalError);
} }
// Add the patch // Add the patch
// ~~~~~~~~~~~~~ // ~~~~~~~~~~~~~
@ -304,20 +364,7 @@ Foam::label Foam::fvMeshDistribute::addProcPatch
// Add polyPatch // Add polyPatch
polyPatches.setSize(sz+1); polyPatches.setSize(sz+1);
polyPatches.set polyPatches.set(sz, patchPtr);
(
sz,
new processorPolyPatch
(
patchName,
0, // size
mesh_.nFaces(),
sz,
mesh_.boundaryMesh(),
Pstream::myProcNo(),
nbrProc
)
);
fvPatches.setSize(sz+1); fvPatches.setSize(sz+1);
fvPatches.set fvPatches.set
( (
@ -625,25 +672,27 @@ void Foam::fvMeshDistribute::getNeighbourData
const labelList& distribution, const labelList& distribution,
labelList& sourceFace, labelList& sourceFace,
labelList& sourceProc, labelList& sourceProc,
labelList& sourceNewProc labelList& sourcePatch,
labelList& sourceNewNbrProc
) const ) const
{ {
label nBnd = mesh_.nFaces() - mesh_.nInternalFaces(); label nBnd = mesh_.nFaces() - mesh_.nInternalFaces();
sourceFace.setSize(nBnd); sourceFace.setSize(nBnd);
sourceProc.setSize(nBnd); sourceProc.setSize(nBnd);
sourceNewProc.setSize(nBnd); sourcePatch.setSize(nBnd);
sourceNewNbrProc.setSize(nBnd);
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// Get neighbouring meshFace labels and new processor of coupled boundaries. // Get neighbouring meshFace labels and new processor of coupled boundaries.
labelList nbrFaces(nBnd, -1); labelList nbrFaces(nBnd, -1);
labelList nbrNewProc(nBnd, -1); labelList nbrNewNbrProc(nBnd, -1);
forAll(patches, patchI) forAll(patches, patchI)
{ {
const polyPatch& pp = patches[patchI]; const polyPatch& pp = patches[patchI];
if (isA<processorPolyPatch>(pp)) if (pp.coupled())
{ {
label offset = pp.start() - mesh_.nInternalFaces(); label offset = pp.start() - mesh_.nInternalFaces();
@ -655,7 +704,7 @@ void Foam::fvMeshDistribute::getNeighbourData
} }
// Which processor they will end up on // Which processor they will end up on
SubList<label>(nbrNewProc, pp.size(), offset).assign SubList<label>(nbrNewNbrProc, pp.size(), offset).assign
( (
UIndirectList<label>(distribution, pp.faceCells())() UIndirectList<label>(distribution, pp.faceCells())()
); );
@ -665,7 +714,7 @@ void Foam::fvMeshDistribute::getNeighbourData
// Exchange the boundary data // Exchange the boundary data
syncTools::swapBoundaryFaceList(mesh_, nbrFaces); syncTools::swapBoundaryFaceList(mesh_, nbrFaces);
syncTools::swapBoundaryFaceList(mesh_, nbrNewProc); syncTools::swapBoundaryFaceList(mesh_, nbrNewNbrProc);
forAll(patches, patchI) forAll(patches, patchI)
@ -680,7 +729,7 @@ void Foam::fvMeshDistribute::getNeighbourData
// Check which of the two faces we store. // Check which of the two faces we store.
if (Pstream::myProcNo() < procPatch.neighbProcNo()) if (procPatch.owner())
{ {
// Use my local face labels // Use my local face labels
forAll(pp, i) forAll(pp, i)
@ -688,7 +737,7 @@ void Foam::fvMeshDistribute::getNeighbourData
label bndI = offset + i; label bndI = offset + i;
sourceFace[bndI] = pp.start()+i; sourceFace[bndI] = pp.start()+i;
sourceProc[bndI] = Pstream::myProcNo(); sourceProc[bndI] = Pstream::myProcNo();
sourceNewProc[bndI] = nbrNewProc[bndI]; sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
} }
} }
else else
@ -699,7 +748,50 @@ void Foam::fvMeshDistribute::getNeighbourData
label bndI = offset + i; label bndI = offset + i;
sourceFace[bndI] = nbrFaces[bndI]; sourceFace[bndI] = nbrFaces[bndI];
sourceProc[bndI] = procPatch.neighbProcNo(); sourceProc[bndI] = procPatch.neighbProcNo();
sourceNewProc[bndI] = nbrNewProc[bndI]; sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
}
}
label patchI = -1;
if (isA<processorCyclicPolyPatch>(pp))
{
patchI = refCast<const processorCyclicPolyPatch>
(
pp
).referPatchID();
}
forAll(pp, i)
{
label bndI = offset + i;
sourcePatch[bndI] = patchI;
}
}
else if (isA<cyclicPolyPatch>(pp))
{
const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
if (cpp.owner())
{
forAll(pp, i)
{
label bndI = offset + i;
sourceFace[bndI] = pp.start()+i;
sourceProc[bndI] = Pstream::myProcNo();
sourcePatch[bndI] = patchI;
sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
}
}
else
{
forAll(pp, i)
{
label bndI = offset + i;
sourceFace[bndI] = nbrFaces[bndI];
sourceProc[bndI] = Pstream::myProcNo();
sourcePatch[bndI] = patchI;
sourceNewNbrProc[bndI] = nbrNewNbrProc[bndI];
} }
} }
} }
@ -709,9 +801,10 @@ void Foam::fvMeshDistribute::getNeighbourData
forAll(pp, i) forAll(pp, i)
{ {
label bndI = offset + i; label bndI = offset + i;
sourceFace[bndI] = patchI; sourceFace[bndI] = -1;
sourceProc[bndI] = -1; sourceProc[bndI] = -1;
sourceNewProc[bndI] = -1; sourcePatch[bndI] = patchI;
sourceNewNbrProc[bndI] = -1;
} }
} }
} }
@ -732,16 +825,19 @@ void Foam::fvMeshDistribute::subsetBoundaryData
const labelList& sourceFace, const labelList& sourceFace,
const labelList& sourceProc, const labelList& sourceProc,
const labelList& sourceNewProc, const labelList& sourcePatch,
const labelList& sourceNewNbrProc,
labelList& subFace, labelList& subFace,
labelList& subProc, labelList& subProc,
labelList& subNewProc labelList& subPatch,
labelList& subNewNbrProc
) )
{ {
subFace.setSize(mesh.nFaces() - mesh.nInternalFaces()); subFace.setSize(mesh.nFaces() - mesh.nInternalFaces());
subProc.setSize(mesh.nFaces() - mesh.nInternalFaces()); subProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
subNewProc.setSize(mesh.nFaces() - mesh.nInternalFaces()); subPatch.setSize(mesh.nFaces() - mesh.nInternalFaces());
subNewNbrProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
forAll(subFace, newBFaceI) forAll(subFace, newBFaceI)
{ {
@ -754,6 +850,7 @@ void Foam::fvMeshDistribute::subsetBoundaryData
{ {
subFace[newBFaceI] = oldFaceI; subFace[newBFaceI] = oldFaceI;
subProc[newBFaceI] = Pstream::myProcNo(); subProc[newBFaceI] = Pstream::myProcNo();
subPatch[newBFaceI] = -1;
label oldOwn = oldFaceOwner[oldFaceI]; label oldOwn = oldFaceOwner[oldFaceI];
label oldNei = oldFaceNeighbour[oldFaceI]; label oldNei = oldFaceNeighbour[oldFaceI];
@ -761,12 +858,12 @@ void Foam::fvMeshDistribute::subsetBoundaryData
if (oldOwn == cellMap[mesh.faceOwner()[newFaceI]]) if (oldOwn == cellMap[mesh.faceOwner()[newFaceI]])
{ {
// We kept the owner side. Where does the neighbour move to? // We kept the owner side. Where does the neighbour move to?
subNewProc[newBFaceI] = oldDistribution[oldNei]; subNewNbrProc[newBFaceI] = oldDistribution[oldNei];
} }
else else
{ {
// We kept the neighbour side. // We kept the neighbour side.
subNewProc[newBFaceI] = oldDistribution[oldOwn]; subNewNbrProc[newBFaceI] = oldDistribution[oldOwn];
} }
} }
else else
@ -776,7 +873,8 @@ void Foam::fvMeshDistribute::subsetBoundaryData
subFace[newBFaceI] = sourceFace[oldBFaceI]; subFace[newBFaceI] = sourceFace[oldBFaceI];
subProc[newBFaceI] = sourceProc[oldBFaceI]; subProc[newBFaceI] = sourceProc[oldBFaceI];
subNewProc[newBFaceI] = sourceNewProc[oldBFaceI]; subPatch[newBFaceI] = sourcePatch[oldBFaceI];
subNewNbrProc[newBFaceI] = sourceNewNbrProc[oldBFaceI];
} }
} }
} }
@ -789,11 +887,13 @@ void Foam::fvMeshDistribute::findCouples
const primitiveMesh& mesh, const primitiveMesh& mesh,
const labelList& sourceFace, const labelList& sourceFace,
const labelList& sourceProc, const labelList& sourceProc,
const labelList& sourcePatch,
const label domain, const label domain,
const primitiveMesh& domainMesh, const primitiveMesh& domainMesh,
const labelList& domainFace, const labelList& domainFace,
const labelList& domainProc, const labelList& domainProc,
const labelList& domainPatch,
labelList& masterCoupledFaces, labelList& masterCoupledFaces,
labelList& slaveCoupledFaces labelList& slaveCoupledFaces
@ -803,9 +903,16 @@ void Foam::fvMeshDistribute::findCouples
// with same face+proc. // with same face+proc.
HashTable<label, labelPair, labelPair::Hash<> > map(domainFace.size()); HashTable<label, labelPair, labelPair::Hash<> > map(domainFace.size());
forAll(domainFace, bFaceI) forAll(domainProc, bFaceI)
{ {
map.insert(labelPair(domainFace[bFaceI], domainProc[bFaceI]), bFaceI); if (domainProc[bFaceI] != -1 && domainPatch[bFaceI] == -1)
{
map.insert
(
labelPair(domainFace[bFaceI], domainProc[bFaceI]),
bFaceI
);
}
} }
@ -817,7 +924,7 @@ void Foam::fvMeshDistribute::findCouples
forAll(sourceFace, bFaceI) forAll(sourceFace, bFaceI)
{ {
if (sourceProc[bFaceI] != -1) if (sourceProc[bFaceI] != -1 && sourcePatch[bFaceI] == -1)
{ {
labelPair myData(sourceFace[bFaceI], sourceProc[bFaceI]); labelPair myData(sourceFace[bFaceI], sourceProc[bFaceI]);
@ -935,105 +1042,202 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::doRemoveCells
// the processor patchID. // the processor patchID.
void Foam::fvMeshDistribute::addProcPatches void Foam::fvMeshDistribute::addProcPatches
( (
const labelList& neighbourNewProc, // processor that neighbour is on const labelList& nbrProc, // processor that neighbour is now on
labelList& procPatchID const labelList& referPatchID, // patchID (or -1) I originated from
List<Map<label> >& procPatchID
) )
{ {
// Now use the neighbourFace/Proc to repatch the mesh. These two lists // Now use the neighbourFace/Proc to repatch the mesh. These lists
// contain for all current boundary faces the global patchID (for non-proc // contain for all current boundary faces the global patchID (for non-proc
// patch) or the processor. // patch) or the processor.
labelList procPatchSizes(Pstream::nProcs(), 0);
forAll(neighbourNewProc, bFaceI)
{
if (neighbourNewProc[bFaceI] != -1)
{
procPatchSizes[neighbourNewProc[bFaceI]]++;
}
}
// Per neighbour processor the label of the processor patch
procPatchID.setSize(Pstream::nProcs()); procPatchID.setSize(Pstream::nProcs());
forAll(procPatchSizes, procI) forAll(nbrProc, bFaceI)
{ {
if (procPatchSizes[procI] > 0) label procI = nbrProc[bFaceI];
if (procI != -1 && procI != Pstream::myProcNo())
{ {
const word patchName = if (!procPatchID[procI].found(referPatchID[bFaceI]))
"procBoundary" {
+ name(Pstream::myProcNo()) // No patch for neighbour yet. Is either a normal processor
+ "to" // patch or a processorCyclic patch.
+ name(procI);
if (referPatchID[bFaceI] == -1)
{
// Ordinary processor boundary
procPatchID[procI] = addProcPatch(patchName, procI); const word patchName =
addPatchFields<volScalarField> "procBoundary"
( + name(Pstream::myProcNo())
processorFvPatchField<scalar>::typeName + "to"
); + name(procI);
addPatchFields<volVectorField>
(
processorFvPatchField<vector>::typeName
);
addPatchFields<volSphericalTensorField>
(
processorFvPatchField<sphericalTensor>::typeName
);
addPatchFields<volSymmTensorField>
(
processorFvPatchField<symmTensor>::typeName
);
addPatchFields<volTensorField>
(
processorFvPatchField<tensor>::typeName
);
addPatchFields<surfaceScalarField> procPatchID[procI].insert
( (
processorFvPatchField<scalar>::typeName referPatchID[bFaceI],
); addPatch
addPatchFields<surfaceVectorField> (
( new processorPolyPatch
processorFvPatchField<vector>::typeName (
); patchName,
addPatchFields<surfaceSphericalTensorField> 0, // size
( mesh_.nFaces(),
processorFvPatchField<sphericalTensor>::typeName mesh_.boundaryMesh().size(),
); mesh_.boundaryMesh(),
addPatchFields<surfaceSymmTensorField> Pstream::myProcNo(),
( nbrProc[bFaceI]
processorFvPatchField<symmTensor>::typeName )
); )
addPatchFields<surfaceTensorField> );
(
processorFvPatchField<tensor>::typeName addPatchFields<volScalarField>
); (
} processorFvPatchField<scalar>::typeName
else );
{ addPatchFields<volVectorField>
procPatchID[procI] = -1; (
processorFvPatchField<vector>::typeName
);
addPatchFields<volSphericalTensorField>
(
processorFvPatchField<sphericalTensor>::typeName
);
addPatchFields<volSymmTensorField>
(
processorFvPatchField<symmTensor>::typeName
);
addPatchFields<volTensorField>
(
processorFvPatchField<tensor>::typeName
);
addPatchFields<surfaceScalarField>
(
processorFvPatchField<scalar>::typeName
);
addPatchFields<surfaceVectorField>
(
processorFvPatchField<vector>::typeName
);
addPatchFields<surfaceSphericalTensorField>
(
processorFvPatchField<sphericalTensor>::typeName
);
addPatchFields<surfaceSymmTensorField>
(
processorFvPatchField<symmTensor>::typeName
);
addPatchFields<surfaceTensorField>
(
processorFvPatchField<tensor>::typeName
);
}
else
{
// Processor boundary originating from cyclic
const word& cycName = mesh_.boundaryMesh()
[
referPatchID[bFaceI]
].name();
const word patchName =
"procBoundary"
+ name(Pstream::myProcNo())
+ "to"
+ name(procI)
+ "through"
+ cycName;
procPatchID[procI].insert
(
referPatchID[bFaceI],
addPatch
(
new processorCyclicPolyPatch
(
patchName,
0, // size
mesh_.nFaces(),
mesh_.boundaryMesh().size(),
mesh_.boundaryMesh(),
Pstream::myProcNo(),
nbrProc[bFaceI],
cycName
)
)
);
addPatchFields<volScalarField>
(
processorCyclicFvPatchField<scalar>::typeName
);
addPatchFields<volVectorField>
(
processorCyclicFvPatchField<vector>::typeName
);
addPatchFields<volSphericalTensorField>
(
processorCyclicFvPatchField<sphericalTensor>::typeName
);
addPatchFields<volSymmTensorField>
(
processorCyclicFvPatchField<symmTensor>::typeName
);
addPatchFields<volTensorField>
(
processorCyclicFvPatchField<tensor>::typeName
);
addPatchFields<surfaceScalarField>
(
processorCyclicFvPatchField<scalar>::typeName
);
addPatchFields<surfaceVectorField>
(
processorCyclicFvPatchField<vector>::typeName
);
addPatchFields<surfaceSphericalTensorField>
(
processorCyclicFvPatchField<sphericalTensor>::typeName
);
addPatchFields<surfaceSymmTensorField>
(
processorCyclicFvPatchField<symmTensor>::typeName
);
addPatchFields<surfaceTensorField>
(
processorCyclicFvPatchField<tensor>::typeName
);
}
}
} }
} }
} }
// Get boundary faces to be repatched. Is -1 or new patchID // Get boundary faces to be repatched. Is -1 or new patchID
Foam::labelList Foam::fvMeshDistribute::getProcBoundaryPatch Foam::labelList Foam::fvMeshDistribute::getBoundaryPatch
( (
const labelList& neighbourNewProc, // new processor per boundary face const labelList& nbrProc, // new processor per boundary face
const labelList& procPatchID // patchID const labelList& referPatchID, // patchID (or -1) I originated from
const List<Map<label> >& procPatchID // per proc the new procPatches
) )
{ {
labelList patchIDs(neighbourNewProc); labelList patchIDs(nbrProc);
forAll(neighbourNewProc, bFaceI) forAll(nbrProc, bFaceI)
{ {
if (neighbourNewProc[bFaceI] != -1) if (nbrProc[bFaceI] == Pstream::myProcNo())
{ {
label nbrProc = neighbourNewProc[bFaceI]; label origPatchI = referPatchID[bFaceI];
patchIDs[bFaceI] = origPatchI;
patchIDs[bFaceI] = procPatchID[nbrProc]; }
else if (nbrProc[bFaceI] != -1)
{
label origPatchI = referPatchID[bFaceI];
patchIDs[bFaceI] = procPatchID[nbrProc[bFaceI]][origPatchI];
} }
else else
{ {
@ -1056,7 +1260,8 @@ void Foam::fvMeshDistribute::sendMesh
const labelList& sourceFace, const labelList& sourceFace,
const labelList& sourceProc, const labelList& sourceProc,
const labelList& sourceNewProc, const labelList& sourcePatch,
const labelList& sourceNewNbrProc,
UOPstream& toDomain UOPstream& toDomain
) )
{ {
@ -1192,7 +1397,8 @@ void Foam::fvMeshDistribute::sendMesh
<< sourceFace << sourceFace
<< sourceProc << sourceProc
<< sourceNewProc; << sourcePatch
<< sourceNewNbrProc;
if (debug) if (debug)
@ -1213,7 +1419,8 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshDistribute::receiveMesh
const Time& runTime, const Time& runTime,
labelList& domainSourceFace, labelList& domainSourceFace,
labelList& domainSourceProc, labelList& domainSourceProc,
labelList& domainSourceNewProc, labelList& domainSourcePatch,
labelList& domainSourceNewNbrProc,
UIPstream& fromNbr UIPstream& fromNbr
) )
{ {
@ -1231,7 +1438,8 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshDistribute::receiveMesh
fromNbr fromNbr
>> domainSourceFace >> domainSourceFace
>> domainSourceProc >> domainSourceProc
>> domainSourceNewProc; >> domainSourcePatch
>> domainSourceNewNbrProc;
// Construct fvMesh // Construct fvMesh
autoPtr<fvMesh> domainMeshPtr autoPtr<fvMesh> domainMeshPtr
@ -1449,16 +1657,37 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// physical boundary: // physical boundary:
// sourceProc = -1 // sourceProc = -1
// sourceNewProc = -1 // sourceNewNbrProc = -1
// sourceFace = patchID // sourceFace = -1
// coupled boundary: // sourcePatch = patchID
// sourceProc = proc // processor boundary:
// sourceNewProc = distribution[cell on proc] // sourceProc = proc (on owner side)
// sourceFace = face // sourceNewNbrProc = distribution of coupled cell
// sourceFace = face (on owner side)
// sourcePatch = -1
// ?cyclic:
// ? sourceProc = proc
// ? sourceNewNbrProc = distribution of coupled cell
// ? sourceFace = face (on owner side)
// ? sourcePatch = patchID
// processor-cyclic boundary:
// sourceProc = proc (on owner side)
// sourceNewNbrProc = distribution of coupled cell
// sourceFace = face (on owner side)
// sourcePatch = patchID
labelList sourcePatch;
labelList sourceFace; labelList sourceFace;
labelList sourceProc; labelList sourceProc;
labelList sourceNewProc; labelList sourceNewNbrProc;
getNeighbourData(distribution, sourceFace, sourceProc, sourceNewProc); getNeighbourData
(
distribution,
sourceFace,
sourceProc,
sourcePatch,
sourceNewNbrProc
);
// Remove meshPhi. Since this would otherwise disappear anyway // Remove meshPhi. Since this would otherwise disappear anyway
@ -1530,7 +1759,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
inplaceReorder(bFaceMap, sourceFace); inplaceReorder(bFaceMap, sourceFace);
inplaceReorder(bFaceMap, sourceProc); inplaceReorder(bFaceMap, sourceProc);
inplaceReorder(bFaceMap, sourceNewProc); inplaceReorder(bFaceMap, sourcePatch);
inplaceReorder(bFaceMap, sourceNewNbrProc);
} }
@ -1633,7 +1863,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// Subset the boundary fields (owner/neighbour/processor) // Subset the boundary fields (owner/neighbour/processor)
labelList procSourceFace; labelList procSourceFace;
labelList procSourceProc; labelList procSourceProc;
labelList procSourceNewProc; labelList procSourcePatch;
labelList procSourceNewNbrProc;
subsetBoundaryData subsetBoundaryData
( (
@ -1648,11 +1879,13 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
sourceFace, sourceFace,
sourceProc, sourceProc,
sourceNewProc, sourcePatch,
sourceNewNbrProc,
procSourceFace, procSourceFace,
procSourceProc, procSourceProc,
procSourceNewProc procSourcePatch,
procSourceNewNbrProc
); );
@ -1669,7 +1902,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
procSourceFace, procSourceFace,
procSourceProc, procSourceProc,
procSourceNewProc, procSourcePatch,
procSourceNewNbrProc,
str str
); );
sendFields<volScalarField>(recvProc, volScalars, subsetter, str); sendFields<volScalarField>(recvProc, volScalars, subsetter, str);
@ -1772,7 +2006,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// fields // fields
labelList domainSourceFace; labelList domainSourceFace;
labelList domainSourceProc; labelList domainSourceProc;
labelList domainSourceNewProc; labelList domainSourcePatch;
labelList domainSourceNewNbrProc;
subsetBoundaryData subsetBoundaryData
( (
@ -1787,16 +2022,19 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
sourceFace, sourceFace,
sourceProc, sourceProc,
sourceNewProc, sourcePatch,
sourceNewNbrProc,
domainSourceFace, domainSourceFace,
domainSourceProc, domainSourceProc,
domainSourceNewProc domainSourcePatch,
domainSourceNewNbrProc
); );
sourceFace.transfer(domainSourceFace); sourceFace.transfer(domainSourceFace);
sourceProc.transfer(domainSourceProc); sourceProc.transfer(domainSourceProc);
sourceNewProc.transfer(domainSourceNewProc); sourcePatch.transfer(domainSourcePatch);
sourceNewNbrProc.transfer(domainSourceNewNbrProc);
} }
@ -1849,7 +2087,8 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// Receive from sendProc // Receive from sendProc
labelList domainSourceFace; labelList domainSourceFace;
labelList domainSourceProc; labelList domainSourceProc;
labelList domainSourceNewProc; labelList domainSourcePatch;
labelList domainSourceNewNbrProc;
autoPtr<fvMesh> domainMeshPtr; autoPtr<fvMesh> domainMeshPtr;
PtrList<volScalarField> vsf; PtrList<volScalarField> vsf;
@ -1875,10 +2114,14 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
const_cast<Time&>(mesh_.time()), const_cast<Time&>(mesh_.time()),
domainSourceFace, domainSourceFace,
domainSourceProc, domainSourceProc,
domainSourceNewProc, domainSourcePatch,
domainSourceNewNbrProc,
str str
); );
fvMesh& domainMesh = domainMeshPtr(); fvMesh& domainMesh = domainMeshPtr();
// Force construction of various on mesh.
//(void)domainMesh.globalData();
// Receive fields. Read as single dictionary because // Receive fields. Read as single dictionary because
// of problems reading consecutive fields from single stream. // of problems reading consecutive fields from single stream.
@ -2007,11 +2250,13 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
sourceFace, sourceFace,
sourceProc, sourceProc,
sourcePatch,
sendProc, sendProc,
domainMesh, domainMesh,
domainSourceFace, domainSourceFace,
domainSourceProc, domainSourceProc,
domainSourcePatch,
masterCoupledFaces, masterCoupledFaces,
slaveCoupledFaces slaveCoupledFaces
@ -2046,33 +2291,38 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// Update mesh data: sourceFace,sourceProc for added // Update mesh data: sourceFace,sourceProc for added
// mesh. // mesh.
sourceFace = sourceFace = mapBoundaryData
mapBoundaryData (
( mesh_,
mesh_, map(),
map(), sourceFace,
sourceFace, domainMesh.nInternalFaces(),
domainMesh.nInternalFaces(), domainSourceFace
domainSourceFace );
); sourceProc = mapBoundaryData
sourceProc = (
mapBoundaryData mesh_,
( map(),
mesh_, sourceProc,
map(), domainMesh.nInternalFaces(),
sourceProc, domainSourceProc
domainMesh.nInternalFaces(), );
domainSourceProc sourcePatch = mapBoundaryData
); (
sourceNewProc = mesh_,
mapBoundaryData map(),
( sourcePatch,
mesh_, domainMesh.nInternalFaces(),
map(), domainSourcePatch
sourceNewProc, );
domainMesh.nInternalFaces(), sourceNewNbrProc = mapBoundaryData
domainSourceNewProc (
); mesh_,
map(),
sourceNewNbrProc,
domainMesh.nInternalFaces(),
domainSourceNewNbrProc
);
// Update all addressing so xxProcAddressing points to correct item // Update all addressing so xxProcAddressing points to correct item
// in masterMesh. // in masterMesh.
@ -2142,11 +2392,13 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// Add processorPatches // Add processorPatches
// ~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~
// Per neighbour processor the patchID to it (or -1). // Per neighbour processor, per originating patch, the patchID
labelList procPatchID; // For faces resulting from internal faces or normal processor patches
// the originating patch is -1. For cyclics this is the cyclic patchID.
List<Map<label> > procPatchID;
// Add processor patches. // Add processor and processorCyclic patches.
addProcPatches(sourceNewProc, procPatchID); addProcPatches(sourceNewNbrProc, sourcePatch, procPatchID);
// Put faces into correct patch. Note that we now have proper // Put faces into correct patch. Note that we now have proper
// processorPolyPatches again so repatching will take care of coupled face // processorPolyPatches again so repatching will take care of coupled face
@ -2155,9 +2407,10 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// Get boundary faces to be repatched. Is -1 or new patchID // Get boundary faces to be repatched. Is -1 or new patchID
labelList newPatchID labelList newPatchID
( (
getProcBoundaryPatch getBoundaryPatch
( (
sourceNewProc, sourceNewNbrProc,
sourcePatch,
procPatchID procPatchID
) )
); );

View File

@ -103,8 +103,8 @@ class fvMeshDistribute
//- Find patch to put exposed faces into. //- Find patch to put exposed faces into.
label findNonEmptyPatch() const; label findNonEmptyPatch() const;
//- Appends processorPolyPatch. Returns patchID. //- Appends polyPatch. Returns patchID.
label addProcPatch(const word& patchName, const label nbrProc); label addPatch(polyPatch*);
//- Add patch field //- Add patch field
template<class GeoField> template<class GeoField>
@ -170,6 +170,7 @@ class fvMeshDistribute
const labelList& distribution, const labelList& distribution,
labelList& sourceFace, labelList& sourceFace,
labelList& sourceProc, labelList& sourceProc,
labelList& sourcePatch,
labelList& sourceNewProc labelList& sourceNewProc
) const; ) const;
@ -187,10 +188,12 @@ class fvMeshDistribute
const labelList& sourceFace, const labelList& sourceFace,
const labelList& sourceProc, const labelList& sourceProc,
const labelList& sourcePatch,
const labelList& sourceNewProc, const labelList& sourceNewProc,
labelList& subFace, labelList& subFace,
labelList& subProc, labelList& subProc,
labelList& subPatch,
labelList& subNewProc labelList& subNewProc
); );
@ -201,11 +204,13 @@ class fvMeshDistribute
const primitiveMesh&, const primitiveMesh&,
const labelList& sourceFace, const labelList& sourceFace,
const labelList& sourceProc, const labelList& sourceProc,
const labelList& sourcePatch,
const label domain, const label domain,
const primitiveMesh& domainMesh, const primitiveMesh& domainMesh,
const labelList& domainFace, const labelList& domainFace,
const labelList& domainProc, const labelList& domainProc,
const labelList& domainPatch,
labelList& masterCoupledFaces, labelList& masterCoupledFaces,
labelList& slaveCoupledFaces labelList& slaveCoupledFaces
@ -236,15 +241,17 @@ class fvMeshDistribute
// proc the processor patchID. // proc the processor patchID.
void addProcPatches void addProcPatches
( (
const labelList&, // processor that neighbour is on const labelList&, // processor that neighbour is now on
labelList& procPatchID const labelList&, // -1 or patch that face originated from
List<Map<label> >& procPatchID
); );
//- Get boundary faces to be repatched. Is -1 or new patchID //- Get boundary faces to be repatched. Is -1 or new patchID
static labelList getProcBoundaryPatch static labelList getBoundaryPatch
( (
const labelList& neighbourNewProc,// new processor per b. face const labelList& neighbourNewProc, // new processor per b. face
const labelList& procPatchID // patchID const labelList& referPatchID, // -1 or original patch
const List<Map<label> >& procPatchID// patchID
); );
//- Send mesh and coupling data. //- Send mesh and coupling data.
@ -257,6 +264,7 @@ class fvMeshDistribute
const wordList& cellZoneNames, const wordList& cellZoneNames,
const labelList& sourceFace, const labelList& sourceFace,
const labelList& sourceProc, const labelList& sourceProc,
const labelList& sourcePatch,
const labelList& sourceNewProc, const labelList& sourceNewProc,
UOPstream& toDomain UOPstream& toDomain
); );
@ -280,6 +288,7 @@ class fvMeshDistribute
const Time& runTime, const Time& runTime,
labelList& domainSourceFace, labelList& domainSourceFace,
labelList& domainSourceProc, labelList& domainSourceProc,
labelList& domainSourcePatch,
labelList& domainSourceNewProc, labelList& domainSourceNewProc,
UIPstream& fromNbr UIPstream& fromNbr
); );
@ -329,6 +338,7 @@ public:
const primitiveMesh&, const primitiveMesh&,
const labelList&, const labelList&,
const labelList&, const labelList&,
const labelList&,
const labelList& const labelList&
); );