Commit 60508888 authored by mattijs's avatar mattijs
Browse files

ENH: point merging of internal and patches.

Uses globalMeshData::mergePoints to topologically merge mesh points.
Also now require all patches on all processors so cleaned up all code for
handling zero-sized patches.
parent 4e3efc9d
// 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,
boundaryFaceSets[patchi],
nPatchPrims.find(patchName)(),
ensightFile
)
{
ensightPatchI++;
}
}
else if (Pstream::master())
)
{
faceSets nullFaceSet;
if
(
writePatchField
(
Field<Type>(),
-1,
ensightPatchI,
nullFaceSet,
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
)
)
{
ensightPatchI++;
}
ensightPatchI++;
}
}
}
......@@ -695,7 +644,6 @@ void ensightFieldBinary
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();
......@@ -819,50 +767,23 @@ void ensightFieldBinary
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
(
writePatchFieldBinary
(
writePatchFieldBinary
(
vf.boundaryField()[patchi],
patchi,
ensightPatchI,
boundaryFaceSets[patchi],
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
)
vf.boundaryField()[patchi],
patchi,
ensightPatchI,
boundaryFaceSets[patchi],
nPatchPrims.find(patchName)(),
ensightFile
)
{
ensightPatchI++;
}
}
else if (Pstream::master())
)
{
faceSets nullFaceSet;
if
(
writePatchFieldBinary
(
Field<Type>(),
-1,
ensightPatchI,
nullFaceSet,
nPatchPrims.find(patchName)(),
patchProcessors,
ensightFile
)
)
{
ensightPatchI++;
}
ensightPatchI++;
}
}
}
......
......@@ -63,14 +63,12 @@ public:
{
public:
label nPoints;
label nTris;
label nQuads;
label nPolys;
nFacePrimitives()
:
nPoints(0),
nTris(0),
nQuads(0),
nPolys(0)
......@@ -96,8 +94,6 @@ private:
wordList allPatchNames_;
List<labelList> allPatchProcs_;
wordHashSet patchNames_;
HashTable<nFacePrimitives> nPatchPrims_;
......@@ -111,16 +107,6 @@ 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,
......@@ -188,7 +174,6 @@ private:
void writeFacePrims
(
const faceList& patchFaces,
const label pointOffset,
OFstream& ensightGeometryFile
) const;
......@@ -198,8 +183,6 @@ private:
const labelList& prims,
const label nPrims,
const faceList& patchFaces,
const labelList& pointOffsets,
const labelList& patchProcessors,
OFstream& ensightGeometryFile
) const;
......@@ -212,7 +195,6 @@ private:
void writeNSidedPoints
(
const faceList& patchFaces,
const label pointOffset,
OFstream& ensightGeometryFile
) const;
......@@ -221,8 +203,6 @@ private:
const labelList& prims,
const label nPrims,
const faceList& patchFaces,
const labelList& pointOffsets,
const labelList& patchProcessors,
OFstream& ensightGeometryFile
) const;
......@@ -231,7 +211,10 @@ private:
const fileName& postProcPath,
const word& prepend,
const label timeIndex,
Ostream& ensightCaseFile
Ostream& ensightCaseFile,
const labelList& pointToGlobal,
const pointField& uniquePoints,
const globalIndex& globalPoints
) const;
void writeBinary
......@@ -239,7 +222,10 @@ private:
const fileName& postProcPath,
const word& prepend,
const label timeIndex,
Ostream& ensightCaseFile
Ostream& ensightCaseFile,
const labelList& pointToGlobal,
const pointField& uniquePoints,
const globalIndex& globalPoints
) const;
void writePrimsBinary
......@@ -291,22 +277,18 @@ private:
const labelList& prims,
const label nPrims,
const faceList& patchFaces,
const labelList& pointOffsets,
const labelList& patchProcessors,
std::ofstream& ensightGeometryFile
) const;
void writeFacePrimsBinary
(
const faceList& patchFaces,
const label pointOffset,
std::ofstream& ensightGeometryFile
) const;
void writeNSidedPointsBinary
(
const faceList& patchFaces,
const label pointOffset,
std::ofstream& ensightGeometryFile
) const;
......@@ -321,8 +303,6 @@ private:
const labelList& prims,
const label nPrims,
const faceList& patchFaces,
const labelList& pointOffsets,
const labelList& patchProcessors,
std::ofstream& ensightGeometryFile
) const;
......@@ -362,11 +342,6 @@ public:
return allPatchNames_;
}
const List<labelList>& allPatchProcs() const
{
return allPatchProcs_;
}
const wordHashSet& patchNames() const
{
return patchNames_;
......
......@@ -93,6 +93,9 @@ bool inFileNameList
int main(int argc, char *argv[])
{
timeSelector::addOptions();
# include "addRegionOption.H"
argList::addBoolOption
(
"ascii",
......@@ -111,7 +114,6 @@ int main(int argc, char *argv[])
"An empty list suppresses writing the internalMesh."
);
# include "addTimeOptions.H"
# include "setRootCase.H"
// Check options
......@@ -119,12 +121,7 @@ int main(int argc, char *argv[])
# include "createTime.H"
// get the available time-steps
instantList Times = runTime.times();
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
instantList Times = timeSelector::select0(runTime, args);
# include "createNamedMesh.H"
......@@ -214,9 +211,9 @@ int main(int argc, char *argv[])
// Identify if lagrangian data exists at each time, and add clouds
// to the 'allCloudNames' hash set
for (label n=startTime; n<endTime; n++)
forAll(Times, timeI)
{
runTime.setTime(Times[n], n);
runTime.setTime(Times[timeI], timeI);
fileNameList cloudDirs = readDir
(
......@@ -267,9 +264,9 @@ int main(int argc, char *argv[])
// Loop over all times to build list of fields and field types
// for each cloud
for (label n=startTime; n<endTime; n++)
forAll(Times, timeI)
{
runTime.setTime(Times[n], n);
runTime.setTime(Times[timeI], timeI);
IOobjectList cloudObjs
(
......@@ -296,20 +293,19 @@ int main(int argc, char *argv[])
}
label nTimeSteps = 0;
for (label n=startTime; n<endTime; n++)
forAll(Times, timeIndex)
{
nTimeSteps++;
runTime.setTime(Times[n], n);
label timeIndex = n - startTime;
runTime.setTime(Times[timeIndex], timeIndex);
word timeName = itoa(timeIndex);
word timeFile = prepend + timeName;
Info<< "Translating time = " << runTime.timeName() << nl;
# include "moveMesh.H"
polyMesh::readUpdateState meshState = mesh.readUpdate();
if (timeIndex == 0 || mesh.moving())
if (timeIndex == 0 || (meshState != polyMesh::UNCHANGED))
{
eMesh.write
(
......
{
IOobject ioPoints
(
"points",
runTime.timeName(),
polyMesh::meshSubDir,
mesh
);
if (ioPoints.headerOk())
{
// Reading new points
pointIOField newPoints
(
IOobject
(
"points",
mesh.time().timeName(),
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
mesh.movePoints(newPoints);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment