Commit d2b8b58b authored by Andrew Heather's avatar Andrew Heather
Browse files
parents 23ffbab4 60508888
......@@ -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"
......
......@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
// Test:print shared points
// Test:print (collocated) shared points
{
const labelListList& globalPointSlaves =
globalData.globalPointSlaves();
......@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
// Test: point to faces addressing
// Test: (collocated) point to faces addressing
{
const labelListList& globalPointBoundaryFaces =
globalData.globalPointBoundaryFaces();
......@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
// Test:point to cells addressing
// Test:(collocated) point to cells addressing
{
const labelList& boundaryCells = globalData.boundaryCells();
const labelListList& globalPointBoundaryCells =
......@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
// Test:print shared edges
// Test:print (collocated) shared edges
{
const labelListList& globalEdgeSlaves =
globalData.globalEdgeSlaves();
......
......@@ -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();
......
......@@ -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
(
IOobject
// 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
(
this->polyMesh::name(), // region name of undecomposed mesh
pointsInstance(),
processorDb
),
xferMove(procPoints),
xferMove(procFaces),
xferMove(procCells)
);
facesInstancePointsPtr_(),
curPointLabels
);
procMeshPtr.reset
(
new polyMesh
(
IOobject
(
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];
// Create processor boundary patches
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,14 +383,13 @@ bool Foam::domainDecomposition::writeDecomposition()
);
// Map existing patches
procPatches[nPatches] =
meshPatches[curBoundaryAddressing[patchi]].clone
(
procMesh.boundaryMesh(),
nPatches,
patchMapper.directAddressing(),
curPatchStarts[patchi]
).ptr();
procPatches[nPatches] = meshPatch.clone
(
procMesh.boundaryMesh(),
nPatches,
patchMapper.directAddressing(),
curPatchStarts[patchi]
).ptr();
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();
}
......
......@@ -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();
......
......@@ -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
......
// ignore special fields or fields that we don't handle
//
bool variableGood = true;
for (label n1=startTime; n1<endTime && variableGood; ++n1)
for (label n1=0; n1<Times.size() && variableGood; ++n1)
{
// ignore _0 fields
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
......
......@@ -19,7 +19,7 @@ if (Pstream::master())
Info<< "Correcting time values. Adding " << Tcorr << endl;
}
for (int n=startTime; n<endTime; n++)
forAll(Times, n)
{
ensightCaseFile << setw(12) << Times[n].value() + Tcorr << " ";
......
......@@ -185,7 +185,6 @@ void writeAllFaceData
const labelList& prims,
const label nPrims,
const Field<Type>& pf,
const labelList& patchProcessors,
OFstream& ensightFile
)
{
......@@ -199,16 +198,12 @@ void writeAllFaceData
{
writeData(map(pf, prims, cmpt), ensightFile);
forAll(patchProcessors, i)
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
if (patchProcessors[i] != 0)
{
label slave = patchProcessors[i];
IPstream fromSlave(Pstream::scheduled, slave);
scalarField pf(fromSlave);
IPstream fromSlave(Pstream::scheduled, slave);
scalarField pf(fromSlave);
writeData(pf, ensightFile);
}
writeData(pf, ensightFile);
}
}
}
......@@ -231,7 +226,6 @@ void writeAllFaceDataBinary
const labelList& prims,
const label nPrims,
const Field<Type>& pf,
const labelList& patchProcessors,
std::ofstream& ensightFile
)
{
......@@ -245,16 +239,12 @@ void writeAllFaceDataBinary
{
writeEnsDataBinary(map(pf, prims, cmpt), ensightFile);
forAll(patchProcessors, i)
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
if (patchProcessors[i] != 0)
{
label slave = patchProcessors[i];
IPstream fromSlave(Pstream::scheduled, slave);
scalarField pf(fromSlave);
IPstream fromSlave(Pstream::scheduled, slave);
scalarField pf(fromSlave);
writeEnsDataBinary(pf, ensightFile);
}
writeEnsDataBinary(pf, ensightFile);
}
}
}
......@@ -278,7 +268,6 @@ bool writePatchField
const Foam::label ensightPatchI,
const Foam::faceSets& boundaryFaceSet,
const Foam::ensightMesh::nFacePrimitives& nfp,
const Foam::labelList& patchProcessors,
Foam::OFstream& ensightFile
)
{
......@@ -297,7 +286,6 @@ bool writePatchField
boundaryFaceSet.tris,
nfp.nTris,
pf,
patchProcessors,
ensightFile
);
......@@ -307,7 +295,6 @@ bool writePatchField
boundaryFaceSet.quads,
nfp.nQuads,
pf,
patchProcessors,
ensightFile
);
......@@ -317,7 +304,6 @@ bool writePatchField
boundaryFaceSet.polys,
nfp.nPolys,
pf,
patchProcessors,
ensightFile
);
......@@ -338,7 +324,6 @@ bool writePatchFieldBinary
const Foam::label ensightPatchI,
const Foam::faceSets& boundaryFaceSet,
const Foam::ensightMesh::nFacePrimitives& nfp,
const Foam::labelList& patchProcessors,
std::ofstream& ensightFile
)
{
......@@ -356,7 +341,6 @@ bool writePatchFieldBinary
boundaryFaceSet.tris,
nfp.nTris,
pf,
patchProcessors,
ensightFile
);
......@@ -366,7 +350,6 @@ bool writePatchFieldBinary
boundaryFaceSet.quads,
nfp.nQuads,
pf,
patchProcessors,
ensightFile
);
......@@ -376,7 +359,6 @@ bool writePatchFieldBinary
boundaryFaceSet.polys,
nfp.nPolys,
pf,
patchProcessors,
ensightFile
);
......@@ -406,7 +388,6 @@ void writePatchField
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
const wordList& allPatchNames = eMesh.allPatchNames();
const List<labelList>& allPatchProcs = eMesh.allPatchProcs();
const HashTable<ensightMesh::nFacePrimitives>&
nPatchPrims = eMesh.nPatchPrims();
......@@ -425,8 +406,6 @@ void writePatchField
}
const labelList& patchProcessors = allPatchProcs[patchi];
word pfName = patchName + '.' + fieldName;
word timeFile = prepend + itoa(timeIndex);
......@@ -473,7 +452,6 @@ void writePatchField
ensightPatchI,
boundaryFaceSets[patchi],
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
);
}
......@@ -488,7 +466,6 @@ void writePatchField
ensightPatchI,
nullFaceSets,
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
);
}
......@@ -521,7 +498,6 @@ void ensightFieldAscii
const cellSets& meshCellSets = eMesh.meshCellSets();
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
const wordList& allPatchNames = eMesh.allPatchNames();
const List<labelList>& allPatchProcs = eMesh.allPatchProcs();
const wordHashSet& patchNames = eMesh.patchNames();
const HashTable<ensightMesh::nFacePrimitives>&
nPatchPrims = eMesh.nPatchPrims();
......@@ -619,50 +595,23 @@ void ensightFieldAscii
forAll(allPatchNames, patchi)
{
const word& patchName = allPatchNames[patchi];
const labelList& patchProcessors = allPatchProcs[patchi];
if (patchNames.empty() || patchNames.found(patchName))
{
if (mesh.boundary()[patchi].size())
{
if
if
(
writePatchField
(
writePatchField
(
vf.boundaryField()[patchi],
patchi,
ensightPatchI,
boundaryFaceSets[patchi],
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
)
vf.boundaryField()[patchi],
patchi,
ensightPatchI,