Merge branch 'master' into sixDofPatch

This commit is contained in:
graham
2010-02-08 13:13:44 +00:00
14 changed files with 1817 additions and 570 deletions

View File

@ -55,7 +55,7 @@ int main(int argc, char *argv[])
#include "initContinuityErrs.H"
while (runTime.run())
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
@ -81,8 +81,6 @@ int main(int argc, char *argv[])
#include "convergenceCheck.H"
}
runTime++;
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"

View File

@ -46,9 +46,6 @@ Usage
@param -fields \n
Use existing geometry decomposition and convert fields only.
@param -filterPatches \n
Remove empty patches when decomposing the geometry.
@param -force \n
Remove any existing @a processor subdirectories before decomposing the
geometry.
@ -99,11 +96,6 @@ int main(int argc, char *argv[])
"use existing geometry decomposition and convert fields only"
);
argList::addBoolOption
(
"filterPatches",
"remove empty patches when decomposing the geometry"
);
argList::addBoolOption
(
"force",
"remove existing processor*/ subdirs before decomposing the geometry"
@ -128,7 +120,6 @@ int main(int argc, char *argv[])
bool writeCellDist = args.optionFound("cellDist");
bool copyUniform = args.optionFound("copyUniform");
bool decomposeFieldsOnly = args.optionFound("fields");
bool filterPatches = args.optionFound("filterPatches");
bool forceOverwrite = args.optionFound("force");
bool ifRequiredDecomposition = args.optionFound("ifRequired");
@ -249,7 +240,7 @@ int main(int argc, char *argv[])
// Decompose the mesh
if (!decomposeFieldsOnly)
{
mesh.decomposeMesh(filterPatches);
mesh.decomposeMesh();
mesh.writeDecomposition();

View File

@ -69,6 +69,24 @@ void Foam::domainDecomposition::mark
Foam::domainDecomposition::domainDecomposition(const IOobject& io)
:
fvMesh(io),
facesInstancePointsPtr_
(
pointsInstance() != facesInstance()
? new pointIOField
(
IOobject
(
"points",
facesInstance(),
polyMesh::meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
)
: NULL
),
decompositionDict_
(
IOobject
@ -86,7 +104,6 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io)
procPointAddressing_(nProcs_),
procFaceAddressing_(nProcs_),
procCellAddressing_(nProcs_),
procBoundaryAddressing_(nProcs_),
procPatchSize_(nProcs_),
procPatchStartIndex_(nProcs_),
procNeighbourProcessors_(nProcs_),
@ -263,24 +280,67 @@ bool Foam::domainDecomposition::writeDecomposition()
"system",
"constant"
);
processorDb.setTime(time());
// create the mesh
polyMesh procMesh
// create the mesh. Two situations:
// - points and faces come from the same time ('instance'). The mesh
// will get constructed in the same instance.
// - points come from a different time (moving mesh cases).
// It will read the points belonging to the faces instance and
// construct the procMesh with it which then gets handled as above.
// (so with 'old' geometry).
// Only at writing time will it additionally write the current
// points.
autoPtr<polyMesh> procMeshPtr;
if (facesInstancePointsPtr_.valid())
{
// Construct mesh from facesInstance.
pointField facesInstancePoints
(
facesInstancePointsPtr_(),
curPointLabels
);
procMeshPtr.reset
(
new polyMesh
(
IOobject
(
this->polyMesh::name(), // region name of undecomposed mesh
pointsInstance(),
this->polyMesh::name(), // region of undecomposed mesh
facesInstance(),
processorDb
),
xferMove(facesInstancePoints),
xferMove(procFaces),
xferMove(procCells)
)
);
}
else
{
procMeshPtr.reset
(
new polyMesh
(
IOobject
(
this->polyMesh::name(), // region of undecomposed mesh
facesInstance(),
processorDb
),
xferMove(procPoints),
xferMove(procFaces),
xferMove(procCells)
)
);
}
polyMesh& procMesh = procMeshPtr();
// Create processor boundary patches
const labelList& curBoundaryAddressing = procBoundaryAddressing_[procI];
const labelList& curPatchSizes = procPatchSize_[procI];
const labelList& curPatchStarts = procPatchStartIndex_[procI];
@ -309,8 +369,7 @@ bool Foam::domainDecomposition::writeDecomposition()
{
// Get the face labels consistent with the field mapping
// (reuse the patch field mappers)
const polyPatch& meshPatch =
meshPatches[curBoundaryAddressing[patchi]];
const polyPatch& meshPatch = meshPatches[patchi];
fvFieldDecomposer::patchFieldDecomposer patchMapper
(
@ -324,8 +383,7 @@ bool Foam::domainDecomposition::writeDecomposition()
);
// Map existing patches
procPatches[nPatches] =
meshPatches[curBoundaryAddressing[patchi]].clone
procPatches[nPatches] = meshPatch.clone
(
procMesh.boundaryMesh(),
nPatches,
@ -589,6 +647,26 @@ bool Foam::domainDecomposition::writeDecomposition()
procMesh.write();
// Write points if pointsInstance differing from facesInstance
if (facesInstancePointsPtr_.valid())
{
pointIOField pointsInstancePoints
(
IOobject
(
"points",
pointsInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferMove(procPoints)
);
pointsInstancePoints.write();
}
Info<< endl
<< "Processor " << procI << nl
<< " Number of cells = " << procMesh.nCells()
@ -678,6 +756,16 @@ bool Foam::domainDecomposition::writeDecomposition()
);
cellProcAddressing.write();
// Write patch map for backwards compatibility.
// (= identity map for original patches, -1 for processor patches)
label nMeshPatches = curPatchSizes.size();
labelList procBoundaryAddressing(identity(nMeshPatches));
procBoundaryAddressing.setSize
(
nMeshPatches+curProcessorPatchSizes.size(),
-1
);
labelIOList boundaryProcAddressing
(
IOobject
@ -689,7 +777,7 @@ bool Foam::domainDecomposition::writeDecomposition()
IOobject::NO_READ,
IOobject::NO_WRITE
),
procBoundaryAddressing_[procI]
procBoundaryAddressing
);
boundaryProcAddressing.write();
}

View File

@ -55,6 +55,9 @@ class domainDecomposition
{
// Private data
//- Optional: points at the facesInstance
autoPtr<pointIOField> facesInstancePointsPtr_;
//- Mesh decomposition control dictionary
IOdictionary decompositionDict_;
@ -83,9 +86,6 @@ class domainDecomposition
//- Labels of cells for each processor
labelListList procCellAddressing_;
//- Original patch index for every processor patch
labelListList procBoundaryAddressing_;
//- Sizes for processor mesh patches
// Excludes inter-processor boundaries
labelListList procPatchSize_;
@ -149,8 +149,8 @@ public:
return distributed_;
}
//- Decompose mesh. Optionally remove zero-sized patches.
void decomposeMesh(const bool filterEmptyPatches);
//- Decompose mesh.
void decomposeMesh();
//- Write decomposition
bool writeDecomposition();

View File

@ -40,7 +40,7 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches)
void Foam::domainDecomposition::decomposeMesh()
{
// Decide which cell goes to which processor
distributeCells();
@ -598,64 +598,6 @@ void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches)
}
}
Info<< "\nCalculating processor boundary addressing" << endl;
// For every patch of processor boundary, find the index of the original
// patch. Mis-alignment is caused by the fact that patches with zero size
// are omitted. For processor patches, set index to -1.
// At the same time, filter the procPatchSize_ and procPatchStartIndex_
// lists to exclude zero-size patches
forAll(procPatchSize_, procI)
{
// Make a local copy of old lists
const labelList oldPatchSizes = procPatchSize_[procI];
const labelList oldPatchStarts = procPatchStartIndex_[procI];
labelList& curPatchSizes = procPatchSize_[procI];
labelList& curPatchStarts = procPatchStartIndex_[procI];
const labelList& curProcessorPatchSizes =
procProcessorPatchSize_[procI];
labelList& curBoundaryAddressing = procBoundaryAddressing_[procI];
curBoundaryAddressing.setSize
(
oldPatchSizes.size()
+ curProcessorPatchSizes.size()
);
label nPatches = 0;
forAll(oldPatchSizes, patchi)
{
if (!filterEmptyPatches || oldPatchSizes[patchi] > 0)
{
curBoundaryAddressing[nPatches] = patchi;
curPatchSizes[nPatches] = oldPatchSizes[patchi];
curPatchStarts[nPatches] = oldPatchStarts[patchi];
nPatches++;
}
}
// reset to the size of live patches
curPatchSizes.setSize(nPatches);
curPatchStarts.setSize(nPatches);
forAll(curProcessorPatchSizes, procPatchI)
{
curBoundaryAddressing[nPatches] = -1;
nPatches++;
}
curBoundaryAddressing.setSize(nPatches);
}
Info<< "\nDistributing points to processors" << endl;
// For every processor, loop through the list of faces for the processor.
// For every face, loop through the list of points and mark the point as

View File

@ -35,6 +35,10 @@ License
#include "IOmanip.H"
#include "itoa.H"
#include "ensightWriteBinary.H"
#include "globalIndex.H"
#include "PackedBoolList.H"
#include "mapDistribute.H"
#include <fstream>
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
@ -106,7 +110,8 @@ Foam::ensightMesh::ensightMesh
{
allPatchNames_ = wordList::subList
(
mesh_.boundaryMesh().names(), mesh_.boundary().size()
mesh_.boundaryMesh().names(),
mesh_.boundary().size()
- mesh_.globalData().processorPatches().size()
);
@ -295,6 +300,114 @@ Foam::ensightMesh::~ensightMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::globalIndex Foam::ensightMesh::mergeMeshPoints
(
labelList& pointToGlobal,
pointField& uniquePoints
) const
{
const globalMeshData& globalData = mesh_.globalData();
const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
const labelListList& globalPointSlaves =
globalData.globalPointSlaves();
const mapDistribute& globalPointSlavesMap =
globalData.globalPointSlavesMap();
// 1. Count number of masters on my processor.
label nCoupledMaster = 0;
PackedBoolList isMaster(mesh_.nPoints(), 1);
forAll(globalPointSlaves, pointI)
{
const labelList& slavePoints = globalPointSlaves[pointI];
if (slavePoints.size() > 0)
{
nCoupledMaster++;
}
else
{
isMaster[coupledPatch.meshPoints()[pointI]] = 0;
}
}
label myUniquePoints =
mesh_.nPoints()
- coupledPatch.nPoints()
+ nCoupledMaster;
//Pout<< "Points :" << nl
// << " mesh : " << mesh_.nPoints() << nl
// << " of which coupled : " << coupledPatch.nPoints() << nl
// << " of which master : " << nCoupledMaster << nl
// << endl;
// 2. Create global indexing for unique points.
globalIndex globalPoints(myUniquePoints);
// 3. Assign global point numbers. Keep slaves unset.
pointToGlobal.setSize(mesh_.nPoints());
pointToGlobal = -1;
uniquePoints.setSize(myUniquePoints);
label nMaster = 0;
forAll(isMaster, meshPointI)
{
if (isMaster[meshPointI])
{
pointToGlobal[meshPointI] = globalPoints.toGlobal(nMaster);
uniquePoints[nMaster] = mesh_.points()[meshPointI];
nMaster++;
}
}
// 4. Push global index for coupled points to slaves.
{
labelList masterToGlobal(globalPointSlavesMap.constructSize(), -1);
forAll(globalPointSlaves, pointI)
{
const labelList& slaves = globalPointSlaves[pointI];
if (slaves.size() > 0)
{
// Duplicate master globalpoint into slave slots
label meshPointI = coupledPatch.meshPoints()[pointI];
masterToGlobal[pointI] = pointToGlobal[meshPointI];
forAll(slaves, i)
{
masterToGlobal[slaves[i]] = masterToGlobal[pointI];
}
}
}
// Send back
globalPointSlavesMap.reverseDistribute
(
coupledPatch.nPoints(),
masterToGlobal
);
// On slave copy master index into overall map.
forAll(globalPointSlaves, pointI)
{
const labelList& slaves = globalPointSlaves[pointI];
if (slaves.size() == 0)
{
label meshPointI = coupledPatch.meshPoints()[pointI];
pointToGlobal[meshPointI] = masterToGlobal[pointI];
}
}
}
return globalPoints;
}
void Foam::ensightMesh::writePoints
(
const scalarField& pointsComponent,
@ -311,7 +424,8 @@ void Foam::ensightMesh::writePoints
Foam::cellShapeList Foam::ensightMesh::map
(
const cellShapeList& cellShapes,
const labelList& prims
const labelList& prims,
const labelList& pointToGlobal
) const
{
cellShapeList mcsl(prims.size());
@ -319,6 +433,7 @@ Foam::cellShapeList Foam::ensightMesh::map
forAll(prims, i)
{
mcsl[i] = cellShapes[prims[i]];
inplaceRenumber(pointToGlobal, mcsl[i]);
}
return mcsl;
@ -329,7 +444,8 @@ Foam::cellShapeList Foam::ensightMesh::map
(
const cellShapeList& cellShapes,
const labelList& hexes,
const labelList& wedges
const labelList& wedges,
const labelList& pointToGlobal
) const
{
cellShapeList mcsl(hexes.size() + wedges.size());
@ -337,6 +453,7 @@ Foam::cellShapeList Foam::ensightMesh::map
forAll(hexes, i)
{
mcsl[i] = cellShapes[hexes[i]];
inplaceRenumber(pointToGlobal, mcsl[i]);
}
label offset = hexes.size();
@ -358,6 +475,7 @@ Foam::cellShapeList Foam::ensightMesh::map
hexLabels[7] = cellPoints[5];
mcsl[i + offset] = cellShape(hex, hexLabels);
inplaceRenumber(pointToGlobal, mcsl[i + offset]);
}
return mcsl;
@ -367,19 +485,18 @@ Foam::cellShapeList Foam::ensightMesh::map
void Foam::ensightMesh::writePrims
(
const cellShapeList& cellShapes,
const label pointOffset,
OFstream& ensightGeometryFile
) const
{
label po = pointOffset + 1;
forAll(cellShapes, i)
{
const cellShape& cellPoints = cellShapes[i];
forAll(cellPoints, pointI)
{
ensightGeometryFile<< setw(10) << cellPoints[pointI] + po;
ensightGeometryFile
<< setw(10)
<< cellPoints[pointI] + 1;
}
ensightGeometryFile << nl;
}
@ -389,12 +506,9 @@ void Foam::ensightMesh::writePrims
void Foam::ensightMesh::writePrimsBinary
(
const cellShapeList& cellShapes,
const label pointOffset,
std::ofstream& ensightGeometryFile
) const
{
label po = pointOffset + 1;
// Create a temp int array
int numElem;
@ -414,7 +528,7 @@ void Foam::ensightMesh::writePrimsBinary
forAll(cellPoints, pointI)
{
temp[n] = cellPoints[pointI] + po;
temp[n] = cellPoints[pointI] + 1;
n++;
}
}
@ -469,12 +583,9 @@ void Foam::ensightMesh::writePolysPoints
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
const label pointOffset,
OFstream& ensightGeometryFile
) const
{
label po = pointOffset + 1;
forAll(polys, i)
{
const labelList& cf = cellFaces[polys[i]];
@ -485,7 +596,7 @@ void Foam::ensightMesh::writePolysPoints
forAll(f, pointI)
{
ensightGeometryFile << setw(10) << f[pointI] + po;
ensightGeometryFile << setw(10) << f[pointI] + 1;
}
ensightGeometryFile << nl;
}
@ -495,14 +606,19 @@ void Foam::ensightMesh::writePolysPoints
void Foam::ensightMesh::writeAllPolys
(
const labelList& pointOffsets,
const labelList& pointToGlobal,
OFstream& ensightGeometryFile
) const
{
if (meshCellSets_.nPolys)
{
const cellList& cellFaces = mesh_.cells();
const faceList& faces = mesh_.faces();
// Renumber faces to use global point numbers
faceList faces(mesh_.faces());
forAll(faces, i)
{
inplaceRenumber(pointToGlobal, faces[i]);
}
if (Pstream::master())
{
@ -541,6 +657,7 @@ void Foam::ensightMesh::writeAllPolys
toMaster<< meshCellSets_.polys << cellFaces;
}
// Number of points for each face of the above list
if (Pstream::master())
{
@ -584,7 +701,6 @@ void Foam::ensightMesh::writeAllPolys
meshCellSets_.polys,
cellFaces,
faces,
0,
ensightGeometryFile
);
// Slaves
@ -600,7 +716,6 @@ void Foam::ensightMesh::writeAllPolys
polys,
cellFaces,
faces,
pointOffsets[slave-1],
ensightGeometryFile
);
}
@ -661,12 +776,9 @@ void Foam::ensightMesh::writePolysPointsBinary
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
const label pointOffset,
std::ofstream& ensightGeometryFile
) const
{
label po = pointOffset + 1;
forAll(polys, i)
{
const labelList& cf = cellFaces[polys[i]];
@ -677,7 +789,7 @@ void Foam::ensightMesh::writePolysPointsBinary
forAll(f, pointI)
{
writeEnsDataBinary(f[pointI] + po,ensightGeometryFile);
writeEnsDataBinary(f[pointI] + 1,ensightGeometryFile);
}
}
}
@ -686,14 +798,19 @@ void Foam::ensightMesh::writePolysPointsBinary
void Foam::ensightMesh::writeAllPolysBinary
(
const labelList& pointOffsets,
const labelList& pointToGlobal,
std::ofstream& ensightGeometryFile
) const
{
if (meshCellSets_.nPolys)
{
const cellList& cellFaces = mesh_.cells();
const faceList& faces = mesh_.faces();
// Renumber faces to use global point numbers
faceList faces(mesh_.faces());
forAll(faces, i)
{
inplaceRenumber(pointToGlobal, faces[i]);
}
if (Pstream::master())
{
@ -775,7 +892,6 @@ void Foam::ensightMesh::writeAllPolysBinary
meshCellSets_.polys,
cellFaces,
faces,
0,
ensightGeometryFile
);
// Slaves
@ -791,7 +907,6 @@ void Foam::ensightMesh::writeAllPolysBinary
polys,
cellFaces,
faces,
pointOffsets[slave-1],
ensightGeometryFile
);
}
@ -810,7 +925,6 @@ void Foam::ensightMesh::writeAllPrims
const char* key,
const label nPrims,
const cellShapeList& cellShapes,
const labelList& pointOffsets,
OFstream& ensightGeometryFile
) const
{
@ -820,19 +934,14 @@ void Foam::ensightMesh::writeAllPrims
{
ensightGeometryFile << key << nl << setw(10) << nPrims << nl;
writePrims(cellShapes, 0, ensightGeometryFile);
writePrims(cellShapes, ensightGeometryFile);
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
cellShapeList cellShapes(fromSlave);
writePrims
(
cellShapes,
pointOffsets[slave-1],
ensightGeometryFile
);
writePrims(cellShapes, ensightGeometryFile);
}
}
else
@ -849,7 +958,6 @@ void Foam::ensightMesh::writeAllPrimsBinary
const char* key,
const label nPrims,
const cellShapeList& cellShapes,
const labelList& pointOffsets,
std::ofstream& ensightGeometryFile
) const
{
@ -860,19 +968,14 @@ void Foam::ensightMesh::writeAllPrimsBinary
writeEnsDataBinary(key,ensightGeometryFile);
writeEnsDataBinary(nPrims,ensightGeometryFile);
writePrimsBinary(cellShapes, 0, ensightGeometryFile);
writePrimsBinary(cellShapes, ensightGeometryFile);
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
cellShapeList cellShapes(fromSlave);
writePrimsBinary
(
cellShapes,
pointOffsets[slave-1],
ensightGeometryFile
);
writePrimsBinary(cellShapes, ensightGeometryFile);
}
}
else
@ -926,34 +1029,13 @@ void Foam::ensightMesh::writeFacePrimsBinary
forAll(patchFace, pointI)
{
writeEnsDataBinary
(
patchFace[pointI] + po,
ensightGeometryFile
);
writeEnsDataBinary(patchFace[pointI] + po, ensightGeometryFile);
}
}
}
}
Foam::faceList Foam::ensightMesh::map
(
const faceList& patchFaces,
const labelList& prims
) const
{
faceList ppf(prims.size());
forAll(prims, i)
{
ppf[i] = patchFaces[prims[i]];
}
return ppf;
}
void Foam::ensightMesh::writeAllFacePrims
(
const char* key,
@ -975,7 +1057,7 @@ void Foam::ensightMesh::writeAllFacePrims
{
writeFacePrims
(
map(patchFaces, prims),
UIndirectList<face>(patchFaces, prims)(),
0,
ensightGeometryFile
);
@ -1001,7 +1083,7 @@ void Foam::ensightMesh::writeAllFacePrims
else if (&prims != NULL)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims);
toMaster<< UIndirectList<face>(patchFaces, prims);
}
}
}
@ -1015,8 +1097,7 @@ void Foam::ensightMesh::writeNSidedNPointsPerFace
{
forAll(patchFaces, i)
{
ensightGeometryFile
<< setw(10) << patchFaces[i].size() << nl;
ensightGeometryFile << setw(10) << patchFaces[i].size() << nl;
}
}
@ -1028,12 +1109,7 @@ void Foam::ensightMesh::writeNSidedPoints
OFstream& ensightGeometryFile
) const
{
writeFacePrims
(
patchFaces,
pointOffset,
ensightGeometryFile
);
writeFacePrims(patchFaces, pointOffset, ensightGeometryFile);
}
@ -1062,7 +1138,7 @@ void Foam::ensightMesh::writeAllNSided
{
writeNSidedNPointsPerFace
(
map(patchFaces, prims),
UIndirectList<face>(patchFaces, prims)(),
ensightGeometryFile
);
}
@ -1086,7 +1162,7 @@ void Foam::ensightMesh::writeAllNSided
else if (&prims != NULL)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims);
toMaster<< UIndirectList<face>(patchFaces, prims);
}
// List of points id for each face
@ -1096,7 +1172,7 @@ void Foam::ensightMesh::writeAllNSided
{
writeNSidedPoints
(
map(patchFaces, prims),
UIndirectList<face>(patchFaces, prims)(),
0,
ensightGeometryFile
);
@ -1122,7 +1198,7 @@ void Foam::ensightMesh::writeAllNSided
else if (&prims != NULL)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims);
toMaster<< UIndirectList<face>(patchFaces, prims);
}
}
}
@ -1186,7 +1262,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
{
writeNSidedNPointsPerFaceBinary
(
map(patchFaces, prims),
UIndirectList<face>(patchFaces, prims)(),
ensightGeometryFile
);
}
@ -1210,7 +1286,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
else if (&prims != NULL)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims);
toMaster<< UIndirectList<face>(patchFaces, prims);
}
// List of points id for each face
@ -1220,7 +1296,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
{
writeNSidedPointsBinary
(
map(patchFaces, prims),
UIndirectList<face>(patchFaces, prims)(),
0,
ensightGeometryFile
);
@ -1246,7 +1322,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
else if (&prims != NULL)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims);
toMaster<< UIndirectList<face>(patchFaces, prims);
}
}
}
@ -1274,7 +1350,7 @@ void Foam::ensightMesh::writeAllFacePrimsBinary
{
writeFacePrimsBinary
(
map(patchFaces, prims),
UIndirectList<face>(patchFaces, prims)(),
0,
ensightGeometryFile
);
@ -1300,7 +1376,7 @@ void Foam::ensightMesh::writeAllFacePrimsBinary
else if (&prims != NULL)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims);
toMaster<< UIndirectList<face>(patchFaces, prims);
}
}
}
@ -1334,9 +1410,22 @@ void Foam::ensightMesh::writeAscii
) const
{
const Time& runTime = mesh_.time();
const pointField& points = mesh_.points();
//const pointField& points = mesh_.points();
const cellShapeList& cellShapes = mesh_.cellShapes();
// Find global point numbering
labelList pointToGlobal;
pointField uniquePoints;
globalIndex globalPoints
(
mergeMeshPoints
(
pointToGlobal,
uniquePoints
)
);
word timeFile = prepend;
if (timeIndex == 0)
@ -1382,12 +1471,9 @@ void Foam::ensightMesh::writeAscii
<< "element id assign" << nl;
}
labelList pointOffsets(Pstream::nProcs(), 0);
if (patchNames_.empty())
{
label nPoints = points.size();
Pstream::gather(nPoints, sumOp<label>());
label nPoints = globalPoints.size();
if (Pstream::master())
{
@ -1401,17 +1487,13 @@ void Foam::ensightMesh::writeAscii
for (direction d=0; d<vector::nComponents; d++)
{
writePoints(points.component(d), ensightGeometryFile);
pointOffsets[0] = points.size();
writePoints(uniquePoints.component(d), ensightGeometryFile);
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
scalarField pointsComponent(fromSlave);
writePoints(pointsComponent, ensightGeometryFile);
pointOffsets[slave] =
pointOffsets[slave-1]
+ pointsComponent.size();
}
}
}
@ -1420,16 +1502,22 @@ void Foam::ensightMesh::writeAscii
for (direction d=0; d<vector::nComponents; d++)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< points.component(d);
toMaster<< uniquePoints.component(d);
}
}
writeAllPrims
(
"hexa8",
meshCellSets_.nHexesWedges,
map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges),
pointOffsets,
map // Rewrite cellShapes to global numbering
(
cellShapes,
meshCellSets_.hexes,
meshCellSets_.wedges,
pointToGlobal
),
ensightGeometryFile
);
@ -1437,8 +1525,7 @@ void Foam::ensightMesh::writeAscii
(
"penta6",
meshCellSets_.nPrisms,
map(cellShapes, meshCellSets_.prisms),
pointOffsets,
map(cellShapes, meshCellSets_.prisms, pointToGlobal),
ensightGeometryFile
);
@ -1446,8 +1533,7 @@ void Foam::ensightMesh::writeAscii
(
"pyramid5",
meshCellSets_.nPyrs,
map(cellShapes, meshCellSets_.pyrs),
pointOffsets,
map(cellShapes, meshCellSets_.pyrs, pointToGlobal),
ensightGeometryFile
);
@ -1455,14 +1541,13 @@ void Foam::ensightMesh::writeAscii
(
"tetra4",
meshCellSets_.nTets,
map(cellShapes, meshCellSets_.tets),
pointOffsets,
map(cellShapes, meshCellSets_.tets, pointToGlobal),
ensightGeometryFile
);
writeAllPolys
(
pointOffsets,
pointToGlobal,
ensightGeometryFile
);
}
@ -1498,14 +1583,14 @@ void Foam::ensightMesh::writeAscii
patchFacesPtr = &(p.localFaces());
}
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
const labelList& tris = *trisPtr;
const labelList& quads = *quadsPtr;
const labelList& polys = *polysPtr;
const pointField& patchPoints = *patchPointsPtr;
const faceList& patchFaces = *patchFacesPtr;
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
labelList patchPointOffsets(Pstream::nProcs(), 0);
if (Pstream::master())
@ -1627,10 +1712,21 @@ void Foam::ensightMesh::writeBinary
Ostream& ensightCaseFile
) const
{
//const Time& runTime = mesh.time();
const pointField& points = mesh_.points();
const cellShapeList& cellShapes = mesh_.cellShapes();
// Find global point numbering
labelList pointToGlobal;
pointField uniquePoints;
globalIndex globalPoints
(
mergeMeshPoints
(
pointToGlobal,
uniquePoints
)
);
word timeFile = prepend;
if (timeIndex == 0)
@ -1668,12 +1764,10 @@ void Foam::ensightMesh::writeBinary
writeEnsDataBinary("element id assign", ensightGeometryFile);
}
labelList pointOffsets(Pstream::nProcs(), 0);
if (patchNames_.empty())
{
label nPoints = points.size();
Pstream::gather(nPoints, sumOp<label>());
label nPoints = globalPoints.size();
if (Pstream::master())
{
@ -1685,19 +1779,17 @@ void Foam::ensightMesh::writeBinary
for (direction d=0; d<vector::nComponents; d++)
{
//writePointsBinary(points.component(d), ensightGeometryFile);
writeEnsDataBinary(points.component(d), ensightGeometryFile);
pointOffsets[0] = points.size();
writeEnsDataBinary
(
uniquePoints.component(d),
ensightGeometryFile
);
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
scalarField pointsComponent(fromSlave);
//writePointsBinary(pointsComponent, ensightGeometryFile);
writeEnsDataBinary(pointsComponent, ensightGeometryFile);
pointOffsets[slave] =
pointOffsets[slave-1]
+ pointsComponent.size();
}
}
}
@ -1706,7 +1798,7 @@ void Foam::ensightMesh::writeBinary
for (direction d=0; d<vector::nComponents; d++)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< points.component(d);
toMaster<< uniquePoints.component(d);
}
}
@ -1714,8 +1806,13 @@ void Foam::ensightMesh::writeBinary
(
"hexa8",
meshCellSets_.nHexesWedges,
map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges),
pointOffsets,
map // Rewrite cellShapes to global numbering
(
cellShapes,
meshCellSets_.hexes,
meshCellSets_.wedges,
pointToGlobal
),
ensightGeometryFile
);
@ -1723,8 +1820,7 @@ void Foam::ensightMesh::writeBinary
(
"penta6",
meshCellSets_.nPrisms,
map(cellShapes, meshCellSets_.prisms),
pointOffsets,
map(cellShapes, meshCellSets_.prisms, pointToGlobal),
ensightGeometryFile
);
@ -1732,8 +1828,7 @@ void Foam::ensightMesh::writeBinary
(
"pyramid5",
meshCellSets_.nPyrs,
map(cellShapes, meshCellSets_.pyrs),
pointOffsets,
map(cellShapes, meshCellSets_.pyrs, pointToGlobal),
ensightGeometryFile
);
@ -1741,17 +1836,15 @@ void Foam::ensightMesh::writeBinary
(
"tetra4",
meshCellSets_.nTets,
map(cellShapes, meshCellSets_.tets),
pointOffsets,
map(cellShapes, meshCellSets_.tets, pointToGlobal),
ensightGeometryFile
);
writeAllPolysBinary
(
pointOffsets,
pointToGlobal,
ensightGeometryFile
);
}
label ensightPatchI = patchPartOffset_;
@ -1786,14 +1879,14 @@ void Foam::ensightMesh::writeBinary
patchFacesPtr = &(p.localFaces());
}
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
const labelList& tris = *trisPtr;
const labelList& quads = *quadsPtr;
const labelList& polys = *polysPtr;
const pointField& patchPoints = *patchPointsPtr;
const faceList& patchFaces = *patchFacesPtr;
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
labelList patchPointOffsets(Pstream::nProcs(), 0);
if (Pstream::master())

View File

@ -42,6 +42,7 @@ SourceFiles
#include "fvMesh.H"
#include "OFstream.H"
#include <fstream>
#include "globalIndex.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -110,6 +111,16 @@ private:
//- Disallow default bitwise assignment
void operator=(const ensightMesh&);
//- Construct map from mesh points to merged points.
// pointToGlobal : from mesh point to global point
// uniquePoints : my set of unique points
globalIndex mergeMeshPoints
(
labelList& pointToGlobal,
pointField& uniquePoints
) const;
void writePoints
(
const scalarField& pointsComponent,
@ -119,20 +130,21 @@ private:
cellShapeList map
(
const cellShapeList& cellShapes,
const labelList& prims
const labelList& prims,
const labelList& pointToGlobal
) const;
cellShapeList map
(
const cellShapeList& cellShapes,
const labelList& hexes,
const labelList& wedges
const labelList& wedges,
const labelList& pointToGlobal
) const;
void writePrims
(
const cellShapeList& cellShapes,
const label pointOffset,
OFstream& ensightGeometryFile
) const;
@ -156,13 +168,12 @@ private:
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
const label pointOffset,
OFstream& ensightGeometryFile
) const;
void writeAllPolys
(
const labelList& pointOffsets,
const labelList& pointToGlobal,
OFstream& ensightGeometryFile
) const;
@ -171,7 +182,6 @@ private:
const char* key,
const label nPrims,
const cellShapeList& cellShapes,
const labelList& pointOffsets,
OFstream& ensightGeometryFile
) const;
@ -182,12 +192,6 @@ private:
OFstream& ensightGeometryFile
) const;
faceList map
(
const faceList& patchFaces,
const labelList& prims
) const;
void writeAllFacePrims
(
const char* key,
@ -241,7 +245,6 @@ private:
void writePrimsBinary
(
const cellShapeList& cellShapes,
const label pointOffset,
std::ofstream& ensightGeometryFile
) const;
@ -250,7 +253,6 @@ private:
const char* key,
const label nPrims,
const cellShapeList& cellShapes,
const labelList& pointOffsets,
std::ofstream& ensightGeometryFile
) const;
@ -274,13 +276,12 @@ private:
const labelList& polys,
const cellList& cellFaces,
const faceList& faces,
const label pointOffset,
std::ofstream& ensightGeometryFile
) const;
void writeAllPolysBinary
(
const labelList& pointOffsets,
const labelList& pointToGlobal,
std::ofstream& ensightGeometryFile
) const;

View File

@ -676,6 +676,10 @@ Foam::Time& Foam::Time::operator++()
deltaT0_ = deltaTSave_;
deltaTSave_ = deltaT_;
// Save old time name
const word oldTimeName = dimensionedScalar::name();
setTime(value() + deltaT_, timeIndex_ + 1);
if (!subCycling_)
@ -685,7 +689,30 @@ Foam::Time& Foam::Time::operator++()
{
setTime(0.0, timeIndex_);
}
}
// Check that new time representation differs from old one
if (dimensionedScalar::name() == oldTimeName)
{
int oldPrecision = precision_;
do
{
precision_++;
setTime(value(), timeIndex());
}
while (precision_ < 100 && dimensionedScalar::name() == oldTimeName);
WarningIn("Time::operator++()")
<< "Increased the timePrecision from " << oldPrecision
<< " to " << precision_
<< " to distinguish between timeNames at time " << value()
<< endl;
}
if (!subCycling_)
{
switch (writeControl_)
{
case wcTimeStep:

View File

@ -410,33 +410,30 @@ Foam::label Foam::globalMeshData::countCoincidentFaces
}
void Foam::globalMeshData::calcGlobalPointSlaves() const
void Foam::globalMeshData::calcGlobalPointSlaves
(
const globalPoints& globalData,
autoPtr<globalIndex>& globalIndicesPtr,
autoPtr<labelListList>& globalPointSlavesPtr,
autoPtr<mapDistribute>& globalPointSlavesMapPtr
) const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalPointSlaves() :"
<< " calculating coupled master to slave point addressing."
<< endl;
}
// Calculate connected points for master points
globalPoints globalData(mesh_, coupledPatch(), true);
const Map<label>& meshToProcPoint = globalData.meshToProcPoint();
// Create global numbering for coupled points
globalPointNumberingPtr_.reset
globalIndicesPtr.reset
(
new globalIndex(globalData.globalIndices())
);
const globalIndex& globalIndices = globalPointNumberingPtr_();
const globalIndex& globalIndices = globalIndicesPtr();
// Create master to slave addressing. Empty for slave points.
globalPointSlavesPtr_.reset
globalPointSlavesPtr.reset
(
new labelListList(coupledPatch().nPoints())
);
labelListList& globalPointSlaves = globalPointSlavesPtr_();
labelListList& globalPointSlaves = globalPointSlavesPtr();
const Map<label>& meshToProcPoint = globalData.meshToProcPoint();
forAllConstIter(Map<label>, meshToProcPoint, iter)
{
@ -465,7 +462,7 @@ void Foam::globalMeshData::calcGlobalPointSlaves() const
// Changes globalPointSlaves to be indices into compact data
List<Map<label> > compactMap(Pstream::nProcs());
globalPointSlavesMapPtr_.reset
globalPointSlavesMapPtr.reset
(
new mapDistribute
(
@ -477,41 +474,50 @@ void Foam::globalMeshData::calcGlobalPointSlaves() const
if (debug)
{
Pout<< "globalMeshData::calcGlobalPointSlaves() :"
Pout<< "globalMeshData::calcGlobalPointSlaves(..) :"
<< " coupled points:" << coupledPatch().nPoints()
<< " additional remote points:"
<< globalPointSlavesMapPtr_().constructSize()
<< globalPointSlavesMapPtr().constructSize()
- coupledPatch().nPoints()
<< endl;
}
}
void Foam::globalMeshData::calcGlobalEdgeSlaves() const
void Foam::globalMeshData::calcGlobalPointSlaves() const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalEdgeSlaves() :"
<< " calculating coupled master to slave edge addressing."
Pout<< "globalMeshData::calcGlobalPointSlaves() :"
<< " calculating coupled master to collocated"
<< " slave point addressing."
<< endl;
}
const labelListList& globalPointSlaves = this->globalPointSlaves();
const mapDistribute& globalPointSlavesMap = this->globalPointSlavesMap();
// Calculate collocated connected points for master points.
globalPoints collocatedGlobalData(mesh_, coupledPatch(), true, false);
// - Send across connected edges (in global edge addressing)
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
globalEdgeNumberingPtr_.reset
calcGlobalPointSlaves
(
new globalIndex(coupledPatch().nEdges())
collocatedGlobalData,
globalPointNumberingPtr_,
globalPointSlavesPtr_,
globalPointSlavesMapPtr_
);
const globalIndex& globalIndices = globalEdgeNumberingPtr_();
}
void Foam::globalMeshData::calcGlobalEdgeSlaves
(
const labelListList& pointSlaves,
const mapDistribute& pointSlavesMap,
const globalIndex& globalEdgeIndices,
autoPtr<labelListList>& globalEdgeSlavesPtr,
autoPtr<mapDistribute>& globalEdgeSlavesMapPtr
) const
{
// Coupled point to global coupled edges.
labelListList globalPointEdges(globalPointSlavesMap.constructSize());
labelListList globalPointEdges(pointSlavesMap.constructSize());
// Create local version
const labelListList& pointEdges = coupledPatch().pointEdges();
@ -522,12 +528,12 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
globalPEdges.setSize(pEdges.size());
forAll(pEdges, i)
{
globalPEdges[i] = globalIndices.toGlobal(pEdges[i]);
globalPEdges[i] = globalEdgeIndices.toGlobal(pEdges[i]);
}
}
// Pull slave data to master
globalPointSlavesMap.distribute(globalPointEdges);
pointSlavesMap.distribute(globalPointEdges);
// Now check on master if any of my edges are also on slave.
// This assumes that if slaves have a coupled edge it is also on
@ -538,14 +544,14 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
const edgeList& edges = coupledPatch().edges();
// Create master to slave addressing. Empty for slave edges.
globalEdgeSlavesPtr_.reset(new labelListList(edges.size()));
labelListList& globalEdgeSlaves = globalEdgeSlavesPtr_();
globalEdgeSlavesPtr.reset(new labelListList(edges.size()));
labelListList& globalEdgeSlaves = globalEdgeSlavesPtr();
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
const labelList& slaves0 = globalPointSlaves[e[0]];
const labelList& slaves1 = globalPointSlaves[e[1]];
const labelList& slaves0 = pointSlaves[e[0]];
const labelList& slaves1 = pointSlaves[e[1]];
// Check for edges that are in both slaves0 and slaves1.
pointEdgeSet.clear();
@ -576,11 +582,11 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
// Construct map
List<Map<label> > compactMap(Pstream::nProcs());
globalEdgeSlavesMapPtr_.reset
globalEdgeSlavesMapPtr.reset
(
new mapDistribute
(
globalIndices,
globalEdgeIndices,
globalEdgeSlaves,
compactMap
)
@ -591,12 +597,39 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
Pout<< "globalMeshData::calcGlobalEdgeSlaves() :"
<< " coupled edge:" << edges.size()
<< " additional remote edges:"
<< globalEdgeSlavesMapPtr_().constructSize() - edges.size()
<< globalEdgeSlavesMapPtr().constructSize() - edges.size()
<< endl;
}
}
void Foam::globalMeshData::calcGlobalEdgeSlaves() const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalEdgeSlaves() :"
<< " calculating coupled master to collocated slave"
<< " edge addressing." << endl;
}
// - Send across connected edges (in global edge addressing)
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
const globalIndex& globalIndices = globalEdgeNumbering();
calcGlobalEdgeSlaves
(
globalPointSlaves(),
globalPointSlavesMap(),
globalIndices,
globalEdgeSlavesPtr_,
globalEdgeSlavesMapPtr_
);
}
// Calculate uncoupled boundary faces (without calculating
// primitiveMesh::pointFaces())
void Foam::globalMeshData::calcPointBoundaryFaces
@ -961,6 +994,55 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
}
void Foam::globalMeshData::calcGlobalPointAllSlaves() const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalPointAllSlaves() :"
<< " calculating coupled master to slave point addressing."
<< endl;
}
// Calculate collocated&non-collocated connected points for master points.
globalPoints allGlobalData(mesh_, coupledPatch(), true, true);
calcGlobalPointSlaves
(
allGlobalData,
globalPointAllNumberingPtr_,
globalPointAllSlavesPtr_,
globalPointAllSlavesMapPtr_
);
}
void Foam::globalMeshData::calcGlobalEdgeAllSlaves() const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalEdgeAllSlaves() :"
<< " calculating coupled master to slave edge addressing."
<< endl;
}
// - Send across connected edges (in global edge addressing)
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
const globalIndex& globalIndices = globalEdgeNumbering();
calcGlobalEdgeSlaves
(
globalPointAllSlaves(),
globalPointAllSlavesMap(),
globalIndices,
globalEdgeAllSlavesPtr_,
globalEdgeAllSlavesMapPtr_
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from polyMesh
@ -1057,6 +1139,17 @@ void Foam::globalMeshData::clearOut()
globalBoundaryCellNumberingPtr_.clear();
globalPointBoundaryCellsPtr_.clear();
globalPointBoundaryCellsMapPtr_.clear();
//- Non-collocated
// Point
globalPointAllNumberingPtr_.clear();
globalPointAllSlavesPtr_.clear();
globalPointAllSlavesMapPtr_.clear();
// Edge
globalEdgeAllSlavesPtr_.clear();
globalEdgeAllSlavesMapPtr_.clear();
}
@ -1212,7 +1305,7 @@ Foam::pointField Foam::globalMeshData::geometricSharedPoints() const
labelList pMap;
pointField mergedPoints;
mergePoints
Foam::mergePoints
(
sharedPoints, // coordinates to merge
tolDim, // tolerance
@ -1350,7 +1443,10 @@ const Foam::globalIndex& Foam::globalMeshData::globalEdgeNumbering() const
{
if (!globalEdgeNumberingPtr_.valid())
{
calcGlobalEdgeSlaves();
globalEdgeNumberingPtr_.reset
(
new globalIndex(coupledPatch().nEdges())
);
}
return globalEdgeNumberingPtr_();
}
@ -1452,6 +1548,293 @@ const
}
// Non-collocated coupled point/edge addressing
const Foam::globalIndex& Foam::globalMeshData::globalPointAllNumbering() const
{
if (!globalPointAllNumberingPtr_.valid())
{
calcGlobalPointAllSlaves();
}
return globalPointAllNumberingPtr_();
}
const Foam::labelListList& Foam::globalMeshData::globalPointAllSlaves() const
{
if (!globalPointAllSlavesPtr_.valid())
{
calcGlobalPointAllSlaves();
}
return globalPointAllSlavesPtr_();
}
const Foam::mapDistribute& Foam::globalMeshData::globalPointAllSlavesMap() const
{
if (!globalPointAllSlavesMapPtr_.valid())
{
calcGlobalPointAllSlaves();
}
return globalPointAllSlavesMapPtr_();
}
const Foam::labelListList& Foam::globalMeshData::globalEdgeAllSlaves() const
{
if (!globalEdgeAllSlavesPtr_.valid())
{
calcGlobalEdgeAllSlaves();
}
return globalEdgeAllSlavesPtr_();
}
const Foam::mapDistribute& Foam::globalMeshData::globalEdgeAllSlavesMap() const
{
if (!globalEdgeAllSlavesMapPtr_.valid())
{
calcGlobalEdgeAllSlaves();
}
return globalEdgeAllSlavesMapPtr_();
}
Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
(
labelList& pointToGlobal,
labelList& uniquePoints
) const
{
const indirectPrimitivePatch& cpp = coupledPatch();
const labelListList& pointSlaves = globalPointSlaves();
const mapDistribute& pointSlavesMap = globalPointSlavesMap();
// 1. Count number of masters on my processor.
label nCoupledMaster = 0;
PackedBoolList isMaster(mesh_.nPoints(), 1);
forAll(pointSlaves, pointI)
{
const labelList& slavePoints = pointSlaves[pointI];
if (slavePoints.size() > 0)
{
nCoupledMaster++;
}
else
{
isMaster[cpp.meshPoints()[pointI]] = 0;
}
}
label myUniquePoints = mesh_.nPoints() - cpp.nPoints() + nCoupledMaster;
//Pout<< "Points :" << nl
// << " mesh : " << mesh_.nPoints() << nl
// << " of which coupled : " << cpp.nPoints() << nl
// << " of which master : " << nCoupledMaster << nl
// << endl;
// 2. Create global indexing for unique points.
autoPtr<globalIndex> globalPointsPtr(new globalIndex(myUniquePoints));
// 3. Assign global point numbers. Keep slaves unset.
pointToGlobal.setSize(mesh_.nPoints());
pointToGlobal = -1;
uniquePoints.setSize(myUniquePoints);
label nMaster = 0;
forAll(isMaster, meshPointI)
{
if (isMaster[meshPointI])
{
pointToGlobal[meshPointI] = globalPointsPtr().toGlobal(nMaster);
uniquePoints[nMaster] = meshPointI;
nMaster++;
}
}
// 4. Push global index for coupled points to slaves.
{
labelList masterToGlobal(pointSlavesMap.constructSize(), -1);
forAll(pointSlaves, pointI)
{
const labelList& slaves = pointSlaves[pointI];
if (slaves.size() > 0)
{
// Duplicate master globalpoint into slave slots
label meshPointI = cpp.meshPoints()[pointI];
masterToGlobal[pointI] = pointToGlobal[meshPointI];
forAll(slaves, i)
{
masterToGlobal[slaves[i]] = masterToGlobal[pointI];
}
}
}
// Send back
pointSlavesMap.reverseDistribute(cpp.nPoints(), masterToGlobal);
// On slave copy master index into overal map.
forAll(pointSlaves, pointI)
{
const labelList& slaves = pointSlaves[pointI];
if (slaves.size() == 0)
{
label meshPointI = cpp.meshPoints()[pointI];
pointToGlobal[meshPointI] = masterToGlobal[pointI];
}
}
}
return globalPointsPtr;
}
Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
(
const labelList& meshPoints,
const Map<label>& meshPointMap,
labelList& pointToGlobal,
labelList& uniquePoints
) const
{
const indirectPrimitivePatch& cpp = coupledPatch();
const labelListList& pointSlaves = globalPointSlaves();
const mapDistribute& pointSlavesMap = globalPointSlavesMap();
// 1. Count number of masters on my processor.
label nCoupledMaster = 0;
label nCoupledSlave = 0;
PackedBoolList isMaster(meshPoints.size(), 1);
forAll(meshPoints, localPointI)
{
label meshPointI = meshPoints[localPointI];
Map<label>::const_iterator iter = cpp.meshPointMap().find(meshPointI);
if (iter != cpp.meshPointMap().end())
{
// My localPointI is a coupled point.
label coupledPointI = iter();
if (pointSlaves[coupledPointI].size() > 0)
{
nCoupledMaster++;
}
else
{
isMaster[localPointI] = 0;
nCoupledSlave++;
}
}
}
label myUniquePoints = meshPoints.size() + nCoupledMaster - nCoupledSlave;
Pout<< "Points :" << nl
<< " patch : " << meshPoints.size() << nl
<< " of which coupled : " << nCoupledMaster+nCoupledSlave << nl
<< " of which master : " << nCoupledMaster << nl
<< " of which slave : " << nCoupledSlave << nl
<< endl;
// 2. Create global indexing for unique points.
autoPtr<globalIndex> globalPointsPtr(new globalIndex(myUniquePoints));
// 3. Assign global point numbers. Keep slaves unset.
pointToGlobal.setSize(meshPoints.size());
pointToGlobal = -1;
uniquePoints.setSize(myUniquePoints);
label nMaster = 0;
forAll(isMaster, localPointI)
{
if (isMaster[localPointI])
{
pointToGlobal[localPointI] = globalPointsPtr().toGlobal(nMaster);
uniquePoints[nMaster] = localPointI;
nMaster++;
}
}
// 4. Push global index for coupled points to slaves.
{
labelList masterToGlobal(pointSlavesMap.constructSize(), -1);
forAll(meshPoints, localPointI)
{
label meshPointI = meshPoints[localPointI];
Map<label>::const_iterator iter = cpp.meshPointMap().find
(
meshPointI
);
if (iter != cpp.meshPointMap().end())
{
// My localPointI is a coupled point.
label coupledPointI = iter();
const labelList& slaves = pointSlaves[coupledPointI];
if (slaves.size() > 0)
{
// Duplicate master globalpoint into slave slots
masterToGlobal[coupledPointI] = pointToGlobal[meshPointI];
forAll(slaves, i)
{
masterToGlobal[slaves[i]] = pointToGlobal[meshPointI];
}
}
}
}
// Send back
pointSlavesMap.reverseDistribute(cpp.nPoints(), masterToGlobal);
// On slave copy master index into overal map.
forAll(meshPoints, localPointI)
{
label meshPointI = meshPoints[localPointI];
Map<label>::const_iterator iter = cpp.meshPointMap().find
(
meshPointI
);
if (iter != cpp.meshPointMap().end())
{
// My localPointI is a coupled point.
label coupledPointI = iter();
const labelList& slaves = pointSlaves[coupledPointI];
if (slaves.size() == 0)
{
pointToGlobal[meshPointI] = masterToGlobal[coupledPointI];
}
}
}
}
return globalPointsPtr;
}
void Foam::globalMeshData::movePoints(const pointField& newPoints)
{
// Topology does not change and we don't store any geometry so nothing
@ -1482,8 +1865,9 @@ void Foam::globalMeshData::updateMesh()
// Option 1. Topological
{
// Calculate all shared points. This does all the hard work.
globalPoints parallelPoints(mesh_, false);
// Calculate all shared points (excluded points that are only
// on two coupled patches). This does all the hard work.
globalPoints parallelPoints(mesh_, false, true);
// Copy data out.
nGlobalPoints_ = parallelPoints.nGlobalPoints();
@ -1505,6 +1889,16 @@ void Foam::globalMeshData::updateMesh()
// sharedEdgeAddr_ = parallelPoints.sharedEdgeAddr();
//}
if (debug)
{
Pout<< "globalMeshData : nGlobalPoints_:" << nGlobalPoints_ << nl
<< "globalMeshData : sharedPointLabels_:"
<< sharedPointLabels_.size() << nl
<< "globalMeshData : sharedPointAddr_:"
<< sharedPointAddr_.size() << endl;
}
// Total number of faces. Start off from all faces. Remove coincident
// processor faces (on highest numbered processor) before summing.
nTotalFaces_ = mesh_.nFaces();

View File

@ -31,7 +31,7 @@ Description
Requires:
- all processor patches to have correct ordering.
- all processorPatches to have their transforms set ('makeTransforms')
- all processorPatches to have their transforms set.
The shared point addressing is quite interesting. It gives on each processor
the vertices that cannot be set using a normal swap on processor patches.
@ -67,14 +67,12 @@ Description
SourceFiles
globalMeshData.C
globalMeshDataMorph.C
\*---------------------------------------------------------------------------*/
#ifndef globalMeshData_H
#define globalMeshData_H
//#include "polyMesh.H"
#include "Switch.H"
#include "processorTopology.H"
#include "labelPair.H"
@ -95,6 +93,7 @@ class globalIndex;
class polyMesh;
class mapDistribute;
template<class T> class EdgeMap;
class globalPoints;
/*---------------------------------------------------------------------------*\
Class globalMeshData Declaration
@ -201,31 +200,36 @@ class globalMeshData
// Coupled point addressing
// This is addressing from coupled point to coupled points,faces,cells
// This is addressing from coupled point to coupled points/faces/cells.
// Two variants:
// - collocated (so not physically separated)
// - also separated
// This is a full schedule so includes points only used by two
// coupled patches.
mutable autoPtr<indirectPrimitivePatch> coupledPatchPtr_;
// Coupled point to coupled points
// Collocated
// Coupled point to collocated coupled points
mutable autoPtr<globalIndex> globalPointNumberingPtr_;
mutable autoPtr<labelListList> globalPointSlavesPtr_;
mutable autoPtr<mapDistribute> globalPointSlavesMapPtr_;
// Coupled edge to coupled edges
// Coupled edge to collocated coupled edges
mutable autoPtr<globalIndex> globalEdgeNumberingPtr_;
mutable autoPtr<labelListList> globalEdgeSlavesPtr_;
mutable autoPtr<mapDistribute> globalEdgeSlavesMapPtr_;
// Coupled point to boundary faces
// Coupled point to collocated boundary faces
mutable autoPtr<globalIndex> globalBoundaryFaceNumberingPtr_;
mutable autoPtr<labelListList> globalPointBoundaryFacesPtr_;
mutable autoPtr<mapDistribute> globalPointBoundaryFacesMapPtr_;
// Coupled point to boundary cells
// Coupled point to collocated boundary cells
mutable autoPtr<labelList> boundaryCellsPtr_;
mutable autoPtr<globalIndex> globalBoundaryCellNumberingPtr_;
@ -233,6 +237,21 @@ class globalMeshData
mutable autoPtr<mapDistribute> globalPointBoundaryCellsMapPtr_;
// Non-collocated as well
// Coupled point to all coupled points
mutable autoPtr<globalIndex> globalPointAllNumberingPtr_;
mutable autoPtr<labelListList> globalPointAllSlavesPtr_;
mutable autoPtr<mapDistribute> globalPointAllSlavesMapPtr_;
// Coupled edge to all coupled edges (same numbering as
// collocated coupled edges)
mutable autoPtr<labelListList> globalEdgeAllSlavesPtr_;
mutable autoPtr<mapDistribute> globalEdgeAllSlavesMapPtr_;
// Private Member Functions
//- Set up processor patch addressing
@ -256,9 +275,28 @@ class globalMeshData
const vectorField& separationDist
);
//- Calculate global point addressing.
void calcGlobalPointSlaves
(
const globalPoints&,
autoPtr<globalIndex>&,
autoPtr<labelListList>&,
autoPtr<mapDistribute>&
) const;
//- Calculate global point addressing.
void calcGlobalPointSlaves() const;
//- Calculate global edge addressing.
void calcGlobalEdgeSlaves
(
const labelListList&,
const mapDistribute&,
const globalIndex&,
autoPtr<labelListList>&,
autoPtr<mapDistribute>&
) const;
//- Calculate global edge addressing.
void calcGlobalEdgeSlaves() const;
@ -272,6 +310,15 @@ class globalMeshData
void calcGlobalPointBoundaryCells() const;
// Non-collocated
//- Calculate global point addressing.
void calcGlobalPointAllSlaves() const;
//- Calculate global edge addressing.
void calcGlobalEdgeAllSlaves() const;
//- Disallow default bitwise copy construct
globalMeshData(const globalMeshData&);
@ -449,8 +496,8 @@ public:
//- Return patch of all coupled faces
const indirectPrimitivePatch& coupledPatch() const;
// Coupled point to coupled points. Coupled points are points on
// any coupled patch.
// Coupled point to collocated coupled points. Coupled points are
// points on any coupled patch.
//- Numbering of coupled points is according to coupledPatch.
const globalIndex& globalPointNumbering() const;
@ -484,6 +531,45 @@ public:
const mapDistribute& globalPointBoundaryCellsMap() const;
// Collocated & non-collocated
// Coupled point to all coupled points (collocated and
// non-collocated).
const globalIndex& globalPointAllNumbering()const;
const labelListList& globalPointAllSlaves() const;
const mapDistribute& globalPointAllSlavesMap() const;
// Coupled edge to all coupled edges (same numbering as
// collocated)
const labelListList& globalEdgeAllSlaves() const;
const mapDistribute& globalEdgeAllSlavesMap() const;
// Other
//- Helper for merging mesh point data. Determines
// - my unique indices
// - global numbering over all unique indices
// - the global number for all local points (so this will
// be local for my unique points)
autoPtr<globalIndex> mergePoints
(
labelList& pointToGlobal,
labelList& uniquePoints
) const;
//- Helper for merging patch point data. Takes maps from
// local points to/from mesh
autoPtr<globalIndex> mergePoints
(
const labelList& meshPoints,
const Map<label>& meshPointMap,
labelList& pointToGlobal,
labelList& uniquePoints
) const;
// Edit
//- Update for moving points.

File diff suppressed because it is too large Load Diff

View File

@ -67,8 +67,8 @@ Description
At this point one will have complete point-point connectivity for all
points on processor patches. Now
- remove point equivalences of size 2. These are just normal points
shared between two neighbouring procPatches.
- (optional)remove point equivalences of size 2. These are
just normal points shared between two neighbouring procPatches.
- collect on each processor points for which it is the master
- request number of sharedPointLabels from the Pstream::master.
@ -98,10 +98,10 @@ SourceFiles
#include "DynamicList.H"
#include "Map.H"
#include "primitivePatch.H"
#include "className.H"
#include "edgeList.H"
#include "globalIndex.H"
#include "indirectPrimitivePatch.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -112,6 +112,8 @@ namespace Foam
class polyMesh;
class polyBoundaryMesh;
class cyclicPolyPatch;
class polyPatch;
class coupledPolyPatch;
/*---------------------------------------------------------------------------*\
Class globalPoints Declaration
@ -119,7 +121,15 @@ class cyclicPolyPatch;
class globalPoints
{
// Private classes
// Static data members
//- Offset to add to points (in globalIndices) originating from
// collocated coupled points.
static const label fromCollocated;
//- Distance to check whether points/faces are collocated.
static const scalar mergeDist;
// Private data
@ -152,13 +162,53 @@ class globalPoints
// Private Member Functions
//- Is identity transform?
static bool noTransform(const tensor&, const scalar mergeDist);
//- Return per face collocated status
static PackedBoolList collocatedFaces
(
const coupledPolyPatch&,
const scalar mergeDist
);
//- Return per point collocated status
static PackedBoolList collocatedPoints
(
const coupledPolyPatch&,
const scalar mergeDist
);
// Wrappers around global point numbering to add collocated bit
//- Convert into globalIndices and add collocated bit
label toGlobal(const label, const bool isCollocated) const;
//- Is collocated bit set
bool isCollocated(const label globalI) const;
//- Remove collocated bit
label removeCollocated(const label globalI) const;
//- (remove collocated bit and) check if originates from local proc
bool isLocal(const label globalI) const;
//- (remove collocated bit and) get originating processor
label whichProcID(const label globalI) const;
//- (remove collocated bit and) convert to local number on processor
label toLocal(const label procI, const label globalI) const;
//- (remove collocated bit and) convert to local number on
// Pstream::myProcNo
label toLocal(const label globalI) const;
//- Count all points on processorPatches. Is all points for which
// information is collected.
static label countPatchPoints(const polyBoundaryMesh&);
////- Get all faces on coupled patches
//static labelListl coupledFaces(const polyBoundaryMesh&);
//- Add information about patchPointI in relative indices to send
// buffers (patchFaces, indexInFace etc.)
static void addToSend
@ -197,9 +247,17 @@ class globalPoints
bool storeInfo
(
const labelList& nbrInfo,
const label localPointI
const label localPointI,
const bool isCollocated
);
void printProcPoints
(
const labelList& patchToMeshPoint,
const labelList& pointInfo,
Ostream& os
) const;
//- Initialize procPoints_ to my patch points. allPoints = true:
// seed with all patch points, = false: only boundaryPoints().
void initOwnPoints
@ -212,6 +270,7 @@ class globalPoints
//- Send subset of procPoints to neighbours
void sendPatchPoints
(
const bool mergeSeparated,
const Map<label>&,
PstreamBuffers&,
const labelHashSet&
@ -220,6 +279,7 @@ class globalPoints
//- Receive neighbour points and merge into my procPoints.
void receivePatchPoints
(
const bool mergeSeparated,
const Map<label>&,
PstreamBuffers&,
labelHashSet&
@ -230,20 +290,31 @@ class globalPoints
void remove(const labelList& patchToMeshPoint, const Map<label>&);
//- Compact out unused elements of procPoints.
void compact();
void compact(const labelList& patchToMeshPoint);
//- Get indices of point for which I am master (lowest numbered proc)
labelList getMasterPoints(const labelList& patchToMeshPoint) const;
//- Send subset of shared points to neighbours
void sendSharedPoints(PstreamBuffers&, const labelList&) const;
void sendSharedPoints
(
const bool mergeSeparated,
PstreamBuffers&,
const DynamicList<label>&
) const;
//- Take over any local shared points
void extendSharedPoints(const Map<label>&, DynamicList<label>&);
//- Receive shared points and update subset.
void receiveSharedPoints
(
const Map<label>&,
const bool mergeSeparated,
const Map<label>& meshToPatchPoint,
const Map<label>& meshToShared,
PstreamBuffers&,
labelList&
DynamicList<label>&
);
//- Should move into cyclicPolyPatch ordering problem
@ -255,7 +326,8 @@ class globalPoints
(
const Map<label>&,
const labelList&,
const bool keepAllPoints
const bool keepAllPoints,
const bool mergeSeparated
);
//- Disallow default bitwise copy construct
@ -276,7 +348,15 @@ public:
//- Construct from mesh.
// keepAllPoints = false : filter out points that are on two
// neighbouring coupled patches (so can be swapped)
globalPoints(const polyMesh& mesh, const bool keepAllPoints);
// mergeSeparated:
// true : merge coupled points across separated patches.
// false : do not merge across coupled separated patches.
globalPoints
(
const polyMesh& mesh,
const bool keepAllPoints,
const bool mergeSeparated
);
//- Construct from mesh and patch of coupled faces. Difference with
// construct from mesh only is that this stores the meshToProcPoint,
@ -286,7 +366,8 @@ public:
(
const polyMesh& mesh,
const indirectPrimitivePatch& coupledPatch,
const bool keepAllPoints
const bool keepAllPoints,
const bool mergeSeparated
);

View File

@ -206,6 +206,15 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs)
}
else if (mag(magSf - nbrMagSf)/avSf > coupledPolyPatch::matchTol)
{
fileName nm
(
boundaryMesh().mesh().time().path()
/name()+"_faces.obj"
);
Pout<< "processorPolyPatch::order : Writing my " << size()
<< " faces to OBJ file " << nm << endl;
writeOBJ(nm, *this, points());
FatalErrorIn
(
"processorPolyPatch::calcGeometry()"

View File

@ -61,7 +61,33 @@ Foam::displacementFvMotionSolver::displacementFvMotionSolver
)
)
)
{}
{
if (points0_.size() != mesh.nPoints())
{
FatalErrorIn
(
"displacementFvMotionSolver::displacementFvMotionSolver\n"
"(\n"
" const polyMesh&,\n"
" Istream&\n"
")"
) << "Number of points in mesh " << mesh.nPoints()
<< " differs from number of points " << points0_.size()
<< " read from file "
<<
IOobject
(
"points",
mesh.time().constant(),
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
).filePath()
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //