Merge branch 'feature-checkMesh' into 'develop'

ENH: checkMesh: have -writeSets option

- checkMesh has option to write faceSets or (outside of) cellSets as
sampledSurface format. It automatically reconstructs the set on the master
and writes it to the postProcessing folder (as any sampledSurface). E.g.

    mpirun -np 6 checkMesh -allTopology -allGeometry -writeSets vtk -parallel

- fixed order writing of symmTensor in Ensight writers

See merge request !8
This commit is contained in:
Andrew Heather
2015-11-24 11:12:20 +00:00
26 changed files with 976 additions and 253 deletions

View File

@ -1,4 +1,4 @@
printMeshStats.C checkTools.C
checkTopology.C checkTopology.C
checkGeometry.C checkGeometry.C
checkMeshQuality.C checkMeshQuality.C

View File

@ -1,8 +1,12 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude -I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-lsampling \
-lsurfMesh \
-ldynamicMesh -ldynamicMesh

View File

@ -7,6 +7,8 @@
#include "wedgePolyPatch.H" #include "wedgePolyPatch.H"
#include "unitConversion.H" #include "unitConversion.H"
#include "polyMeshTetDecomposition.H" #include "polyMeshTetDecomposition.H"
#include "surfaceWriter.H"
#include "checkTools.H"
// Find wedge with opposite orientation. Note: does not actually check that // Find wedge with opposite orientation. Note: does not actually check that
@ -477,7 +479,12 @@ bool Foam::checkCoupledPoints
} }
Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) Foam::label Foam::checkGeometry
(
const polyMesh& mesh,
const bool allGeometry,
const autoPtr<surfaceWriter>& writer
)
{ {
label noFailedChecks = 0; label noFailedChecks = 0;
@ -563,6 +570,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< " non closed cells to set " << cells.name() << endl; << " non closed cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (writer.valid())
{
mergeAndWrite(writer(), cells);
}
} }
} }
@ -575,6 +586,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< aspectCells.name() << endl; << aspectCells.name() << endl;
aspectCells.instance() = mesh.pointsInstance(); aspectCells.instance() = mesh.pointsInstance();
aspectCells.write(); aspectCells.write();
if (writer.valid())
{
mergeAndWrite(writer(), aspectCells);
}
} }
} }
@ -592,6 +607,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< " zero area faces to set " << faces.name() << endl; << " zero area faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
} }
@ -610,6 +629,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< " zero volume cells to set " << cells.name() << endl; << " zero volume cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (writer.valid())
{
mergeAndWrite(writer(), cells);
}
} }
} }
} }
@ -629,6 +652,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< " non-orthogonal faces to set " << faces.name() << endl; << " non-orthogonal faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
@ -647,6 +674,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
} }
@ -665,6 +696,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< " skew faces to set " << faces.name() << endl; << " skew faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
} }
@ -685,6 +720,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
} }
@ -714,6 +753,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< "decomposition tets to set " << faces.name() << endl; << "decomposition tets to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
} }
@ -774,6 +817,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< endl; << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
} }
@ -793,6 +840,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< " warped faces to set " << faces.name() << endl; << " warped faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
} }
@ -810,6 +861,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< " under-determined cells to set " << cells.name() << endl; << " under-determined cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (writer.valid())
{
mergeAndWrite(writer(), cells);
}
} }
} }
@ -826,6 +881,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< " concave cells to set " << cells.name() << endl; << " concave cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (writer.valid())
{
mergeAndWrite(writer(), cells);
}
} }
} }
@ -843,6 +902,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
@ -860,6 +923,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }

View File

@ -6,6 +6,7 @@ namespace Foam
{ {
class polyMesh; class polyMesh;
class wedgePolyPatch; class wedgePolyPatch;
class surfaceWriter;
label findOppositeWedge(const polyMesh&, const wedgePolyPatch&); label findOppositeWedge(const polyMesh&, const wedgePolyPatch&);
@ -21,5 +22,10 @@ namespace Foam
//- Check 0th vertex on coupled faces //- Check 0th vertex on coupled faces
bool checkCoupledPoints(const polyMesh&, const bool report, labelHashSet*); bool checkCoupledPoints(const polyMesh&, const bool report, labelHashSet*);
label checkGeometry(const polyMesh& mesh, const bool allGeometry); label checkGeometry
(
const polyMesh& mesh,
const bool allGeometry,
const autoPtr<surfaceWriter>&
);
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -42,16 +42,20 @@ Usage
\param -region \<name\> \n \param -region \<name\> \n
Specify an alternative mesh region. Specify an alternative mesh region.
\param -writeSets \<surfaceFormat\> \n
Reconstruct all cellSets and faceSets geometry and write to postProcessing/
directory according to surfaceFormat (e.g. vtk or ensight)
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
#include "timeSelector.H" #include "timeSelector.H"
#include "Time.H" #include "Time.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "globalMeshData.H" #include "globalMeshData.H"
#include "vtkSurfaceWriter.H"
#include "printMeshStats.H" #include "checkTools.H"
#include "checkTopology.H" #include "checkTopology.H"
#include "checkGeometry.H" #include "checkGeometry.H"
#include "checkMeshQuality.H" #include "checkMeshQuality.H"
@ -84,6 +88,12 @@ int main(int argc, char *argv[])
"meshQuality", "meshQuality",
"read user-defined mesh quality criterions from system/meshQualityDict" "read user-defined mesh quality criterions from system/meshQualityDict"
); );
argList::addOption
(
"writeSets",
"surfaceFormat"
"reconstruct and write all faceSets and cellSets in selected format"
);
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
@ -95,6 +105,9 @@ int main(int argc, char *argv[])
const bool allTopology = args.optionFound("allTopology"); const bool allTopology = args.optionFound("allTopology");
const bool meshQuality = args.optionFound("meshQuality"); const bool meshQuality = args.optionFound("meshQuality");
word surfaceFormat;
const bool writeSets = args.optionReadIfPresent("writeSets", surfaceFormat);
if (noTopology) if (noTopology)
{ {
Info<< "Disabling all topology checks." << nl << endl; Info<< "Disabling all topology checks." << nl << endl;
@ -112,6 +125,12 @@ int main(int argc, char *argv[])
{ {
Info<< "Enabling user-defined geometry checks." << nl << endl; Info<< "Enabling user-defined geometry checks." << nl << endl;
} }
if (writeSets)
{
Info<< "Reconstructing and writing " << surfaceFormat
<< " representation"
<< " of all faceSets and cellSets." << nl << endl;
}
autoPtr<IOdictionary> qualDict; autoPtr<IOdictionary> qualDict;
@ -134,6 +153,13 @@ int main(int argc, char *argv[])
} }
autoPtr<surfaceWriter> writer;
if (writeSets)
{
writer = surfaceWriter::New(surfaceFormat);
}
forAll(timeDirs, timeI) forAll(timeDirs, timeI)
{ {
runTime.setTime(timeDirs[timeI], timeI); runTime.setTime(timeDirs[timeI], timeI);
@ -161,14 +187,20 @@ int main(int argc, char *argv[])
if (!noTopology) if (!noTopology)
{ {
nFailedChecks += checkTopology(mesh, allTopology, allGeometry); nFailedChecks += checkTopology
(
mesh,
allTopology,
allGeometry,
writer
);
} }
nFailedChecks += checkGeometry(mesh, allGeometry); nFailedChecks += checkGeometry(mesh, allGeometry, writer);
if (meshQuality) if (meshQuality)
{ {
nFailedChecks += checkMeshQuality(mesh, qualDict()); nFailedChecks += checkMeshQuality(mesh, qualDict(), writer);
} }
@ -189,11 +221,11 @@ int main(int argc, char *argv[])
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
label nFailedChecks = checkGeometry(mesh, allGeometry); label nFailedChecks = checkGeometry(mesh, allGeometry, writer);
if (meshQuality) if (meshQuality)
{ {
nFailedChecks += checkMeshQuality(mesh, qualDict()); nFailedChecks += checkMeshQuality(mesh, qualDict(), writer);
} }

View File

@ -3,12 +3,14 @@
#include "cellSet.H" #include "cellSet.H"
#include "faceSet.H" #include "faceSet.H"
#include "motionSmoother.H" #include "motionSmoother.H"
#include "surfaceWriter.H"
#include "checkTools.H"
Foam::label Foam::checkMeshQuality Foam::label Foam::checkMeshQuality
( (
const polyMesh& mesh, const polyMesh& mesh,
const dictionary& dict const dictionary& dict,
const autoPtr<surfaceWriter>& writer
) )
{ {
label noFailedChecks = 0; label noFailedChecks = 0;
@ -27,6 +29,10 @@ Foam::label Foam::checkMeshQuality
<< " faces in error to set " << faces.name() << endl; << " faces in error to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }

View File

@ -2,5 +2,12 @@
namespace Foam namespace Foam
{ {
label checkMeshQuality(const polyMesh& mesh, const dictionary&); class surfaceWriter;
label checkMeshQuality
(
const polyMesh&,
const dictionary&,
const autoPtr<surfaceWriter>&
);
} }

View File

@ -0,0 +1,397 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "checkTools.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "hexMatcher.H"
#include "wedgeMatcher.H"
#include "prismMatcher.H"
#include "pyrMatcher.H"
#include "tetWedgeMatcher.H"
#include "tetMatcher.H"
#include "IOmanip.H"
#include "faceSet.H"
#include "cellSet.H"
#include "PatchTools.H"
#include "Time.H"
#include "surfaceWriter.H"
#include "sampledSurfaces.H"
#include "syncTools.H"
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
{
Info<< "Mesh stats" << nl
<< " points: "
<< returnReduce(mesh.points().size(), sumOp<label>()) << nl;
label nInternalPoints = returnReduce
(
mesh.nInternalPoints(),
sumOp<label>()
);
if (nInternalPoints != -Pstream::nProcs())
{
Info<< " internal points: " << nInternalPoints << nl;
if (returnReduce(mesh.nInternalPoints(), minOp<label>()) == -1)
{
WarningIn("Foam::printMeshStats(const polyMesh&, const bool)")
<< "Some processors have their points sorted into internal"
<< " and external and some do not." << endl
<< "This can cause problems later on." << endl;
}
}
if (allTopology && nInternalPoints != -Pstream::nProcs())
{
label nEdges = returnReduce(mesh.nEdges(), sumOp<label>());
label nInternalEdges = returnReduce
(
mesh.nInternalEdges(),
sumOp<label>()
);
label nInternal1Edges = returnReduce
(
mesh.nInternal1Edges(),
sumOp<label>()
);
label nInternal0Edges = returnReduce
(
mesh.nInternal0Edges(),
sumOp<label>()
);
Info<< " edges: " << nEdges << nl
<< " internal edges: " << nInternalEdges << nl
<< " internal edges using one boundary point: "
<< nInternal1Edges-nInternal0Edges << nl
<< " internal edges using two boundary points: "
<< nInternalEdges-nInternal1Edges << nl;
}
label nFaces = returnReduce(mesh.faces().size(), sumOp<label>());
label nIntFaces = returnReduce(mesh.faceNeighbour().size(), sumOp<label>());
label nCells = returnReduce(mesh.cells().size(), sumOp<label>());
Info<< " faces: " << nFaces << nl
<< " internal faces: " << nIntFaces << nl
<< " cells: " << nCells << nl
<< " faces per cell: "
<< scalar(nFaces + nIntFaces)/max(1, nCells) << nl
<< " boundary patches: " << mesh.boundaryMesh().size() << nl
<< " point zones: " << mesh.pointZones().size() << nl
<< " face zones: " << mesh.faceZones().size() << nl
<< " cell zones: " << mesh.cellZones().size() << nl
<< endl;
// Construct shape recognizers
hexMatcher hex;
prismMatcher prism;
wedgeMatcher wedge;
pyrMatcher pyr;
tetWedgeMatcher tetWedge;
tetMatcher tet;
// Counters for different cell types
label nHex = 0;
label nWedge = 0;
label nPrism = 0;
label nPyr = 0;
label nTet = 0;
label nTetWedge = 0;
label nUnknown = 0;
Map<label> polyhedralFaces;
for (label cellI = 0; cellI < mesh.nCells(); cellI++)
{
if (hex.isA(mesh, cellI))
{
nHex++;
}
else if (tet.isA(mesh, cellI))
{
nTet++;
}
else if (pyr.isA(mesh, cellI))
{
nPyr++;
}
else if (prism.isA(mesh, cellI))
{
nPrism++;
}
else if (wedge.isA(mesh, cellI))
{
nWedge++;
}
else if (tetWedge.isA(mesh, cellI))
{
nTetWedge++;
}
else
{
nUnknown++;
polyhedralFaces(mesh.cells()[cellI].size())++;
}
}
reduce(nHex,sumOp<label>());
reduce(nPrism,sumOp<label>());
reduce(nWedge,sumOp<label>());
reduce(nPyr,sumOp<label>());
reduce(nTetWedge,sumOp<label>());
reduce(nTet,sumOp<label>());
reduce(nUnknown,sumOp<label>());
Info<< "Overall number of cells of each type:" << nl
<< " hexahedra: " << nHex << nl
<< " prisms: " << nPrism << nl
<< " wedges: " << nWedge << nl
<< " pyramids: " << nPyr << nl
<< " tet wedges: " << nTetWedge << nl
<< " tetrahedra: " << nTet << nl
<< " polyhedra: " << nUnknown
<< endl;
if (nUnknown > 0)
{
Pstream::mapCombineGather(polyhedralFaces, plusEqOp<label>());
Info<< " Breakdown of polyhedra by number of faces:" << nl
<< " faces" << " number of cells" << endl;
const labelList sortedKeys = polyhedralFaces.sortedToc();
forAll(sortedKeys, keyI)
{
const label nFaces = sortedKeys[keyI];
Info<< setf(std::ios::right) << setw(13)
<< nFaces << " " << polyhedralFaces[nFaces] << nl;
}
}
Info<< endl;
}
void Foam::mergeAndWrite
(
const surfaceWriter& writer,
const faceSet& set
)
{
const polyMesh& mesh = refCast<const polyMesh>(set.db());
const indirectPrimitivePatch setPatch
(
IndirectList<face>(mesh.faces(), set.sortedToc()),
mesh.points()
);
const fileName outputDir
(
set.time().path()
/ (Pstream::parRun() ? ".." : "")
/ "postProcessing"
/ mesh.pointsInstance()
/ set.name()
);
if (Pstream::parRun())
{
// Use tolerance from sampling (since we're doing exactly the same
// when parallel merging)
const scalar tol = sampledSurfaces::mergeTol();
// dimension as fraction of mesh bounding box
scalar mergeDim = tol * mesh.bounds().mag();
pointField mergedPoints;
faceList mergedFaces;
labelList pointMergeMap;
PatchTools::gatherAndMerge
(
mergeDim,
setPatch,
mergedPoints,
mergedFaces,
pointMergeMap
);
writer.write
(
outputDir,
set.name(),
mergedPoints,
mergedFaces
);
}
else
{
writer.write
(
outputDir,
set.name(),
setPatch.localPoints(),
setPatch.localFaces()
);
}
}
void Foam::mergeAndWrite
(
const surfaceWriter& writer,
const cellSet& set
)
{
const polyMesh& mesh = refCast<const polyMesh>(set.db());
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
// Determine faces on outside of cellSet
PackedBoolList isInSet(mesh.nCells());
forAllConstIter(cellSet, set, iter)
{
isInSet[iter.key()] = true;
}
boolList bndInSet(mesh.nFaces()-mesh.nInternalFaces());
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
const labelList& fc = pp.faceCells();
forAll(fc, i)
{
bndInSet[pp.start()+i-mesh.nInternalFaces()] = isInSet[fc[i]];
}
}
syncTools::swapBoundaryFaceList(mesh, bndInSet);
DynamicList<label> outsideFaces(3*set.size());
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
{
bool ownVal = isInSet[mesh.faceOwner()[faceI]];
bool neiVal = isInSet[mesh.faceNeighbour()[faceI]];
if (ownVal != neiVal)
{
outsideFaces.append(faceI);
}
}
forAll(pbm, patchI)
{
const polyPatch& pp = pbm[patchI];
const labelList& fc = pp.faceCells();
if (pp.coupled())
{
forAll(fc, i)
{
label faceI = pp.start()+i;
bool neiVal = bndInSet[faceI-mesh.nInternalFaces()];
if (isInSet[fc[i]] && !neiVal)
{
outsideFaces.append(faceI);
}
}
}
else
{
forAll(fc, i)
{
if (isInSet[fc[i]])
{
outsideFaces.append(pp.start()+i);
}
}
}
}
const indirectPrimitivePatch setPatch
(
IndirectList<face>(mesh.faces(), outsideFaces),
mesh.points()
);
const fileName outputDir
(
set.time().path()
/ (Pstream::parRun() ? ".." : "")
/ "postProcessing"
/ mesh.pointsInstance()
/ set.name()
);
if (Pstream::parRun())
{
// Use tolerance from sampling (since we're doing exactly the same
// when parallel merging)
const scalar tol = sampledSurfaces::mergeTol();
// dimension as fraction of mesh bounding box
scalar mergeDim = tol * mesh.bounds().mag();
pointField mergedPoints;
faceList mergedFaces;
labelList pointMergeMap;
PatchTools::gatherAndMerge
(
mergeDim,
setPatch,
mergedPoints,
mergedFaces,
pointMergeMap
);
writer.write
(
outputDir,
set.name(),
mergedPoints,
mergedFaces
);
}
else
{
writer.write
(
outputDir,
set.name(),
setPatch.localPoints(),
setPatch.localFaces()
);
}
}

View File

@ -0,0 +1,19 @@
#include "scalar.H"
namespace Foam
{
class polyMesh;
class surfaceWriter;
class faceSet;
class cellSet;
void printMeshStats(const polyMesh& mesh, const bool allTopology);
//- Write vtk representation of (assembled) faceSet to vtk file in
// postProcessing/ directory
void mergeAndWrite(const surfaceWriter&, const faceSet&);
//- Write vtk representation of (assembled) cellSet to vtk file in
// postProcessing/ directory
void mergeAndWrite(const surfaceWriter&, const cellSet&);
}

View File

@ -33,6 +33,8 @@ License
#include "IOmanip.H" #include "IOmanip.H"
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "surfaceWriter.H"
#include "checkTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -40,7 +42,8 @@ Foam::label Foam::checkTopology
( (
const polyMesh& mesh, const polyMesh& mesh,
const bool allTopology, const bool allTopology,
const bool allGeometry const bool allGeometry,
const autoPtr<surfaceWriter>& writer
) )
{ {
label noFailedChecks = 0; label noFailedChecks = 0;
@ -126,6 +129,11 @@ Foam::label Foam::checkTopology
<< " illegal cells to set " << cells.name() << endl; << " illegal cells to set " << cells.name() << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (writer.valid())
{
mergeAndWrite(writer(), cells);
}
} }
else else
{ {
@ -164,6 +172,10 @@ Foam::label Foam::checkTopology
<< " unordered faces to set " << faces.name() << endl; << " unordered faces to set " << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
@ -180,6 +192,10 @@ Foam::label Foam::checkTopology
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
@ -197,6 +213,11 @@ Foam::label Foam::checkTopology
<< endl; << endl;
cells.instance() = mesh.pointsInstance(); cells.instance() = mesh.pointsInstance();
cells.write(); cells.write();
if (writer.valid())
{
mergeAndWrite(writer(), cells);
}
} }
} }
@ -216,6 +237,10 @@ Foam::label Foam::checkTopology
<< faces.name() << endl; << faces.name() << endl;
faces.instance() = mesh.pointsInstance(); faces.instance() = mesh.pointsInstance();
faces.write(); faces.write();
if (writer.valid())
{
mergeAndWrite(writer(), faces);
}
} }
} }
@ -267,6 +292,10 @@ Foam::label Foam::checkTopology
<< endl; << endl;
oneCells.instance() = mesh.pointsInstance(); oneCells.instance() = mesh.pointsInstance();
oneCells.write(); oneCells.write();
if (writer.valid())
{
mergeAndWrite(writer(), oneCells);
}
} }
label nTwoCells = returnReduce(twoCells.size(), sumOp<label>()); label nTwoCells = returnReduce(twoCells.size(), sumOp<label>());
@ -279,6 +308,10 @@ Foam::label Foam::checkTopology
<< endl; << endl;
twoCells.instance() = mesh.pointsInstance(); twoCells.instance() = mesh.pointsInstance();
twoCells.write(); twoCells.write();
if (writer.valid())
{
mergeAndWrite(writer(), twoCells);
}
} }
} }
@ -316,6 +349,53 @@ Foam::label Foam::checkTopology
ctr.write(); ctr.write();
// Is region disconnected
boolList regionDisconnected(rs.nRegions(), true);
if (allTopology)
{
// -1 : not assigned
// -2 : multiple regions
// >= 0 : single region
labelList pointToRegion(mesh.nPoints(), -1);
for
(
label faceI = mesh.nInternalFaces();
faceI < mesh.nFaces();
faceI++
)
{
label regionI = rs[mesh.faceOwner()[faceI]];
const face& f = mesh.faces()[faceI];
forAll(f, fp)
{
label& pRegion = pointToRegion[f[fp]];
if (pRegion == -1)
{
pRegion = regionI;
}
else if (pRegion == -2)
{
// Already marked
regionDisconnected[regionI] = false;
}
else if (pRegion != regionI)
{
// Multiple regions
regionDisconnected[regionI] = false;
regionDisconnected[pRegion] = false;
pRegion = -2;
}
}
}
Pstream::listCombineGather(regionDisconnected, andEqOp<bool>());
Pstream::listCombineScatter(regionDisconnected);
}
// write cellSet for each region // write cellSet for each region
PtrList<cellSet> cellRegions(rs.nRegions()); PtrList<cellSet> cellRegions(rs.nRegions());
for (label i = 0; i < rs.nRegions(); i++) for (label i = 0; i < rs.nRegions(); i++)
@ -339,7 +419,19 @@ Foam::label Foam::checkTopology
for (label i = 0; i < rs.nRegions(); i++) for (label i = 0; i < rs.nRegions(); i++)
{ {
Info<< " <<Writing region " << i << " with " Info<< " <<Writing region " << i;
if (allTopology)
{
if (regionDisconnected[i])
{
Info<< " (fully disconnected)";
}
else
{
Info<< " (point connected)";
}
}
Info<< " with "
<< returnReduce(cellRegions[i].size(), sumOp<scalar>()) << returnReduce(cellRegions[i].size(), sumOp<scalar>())
<< " cells to cellSet " << cellRegions[i].name() << endl; << " cells to cellSet " << cellRegions[i].name() << endl;

View File

@ -1,9 +1,16 @@
#include "label.H" #include "label.H"
#include "wordList.H" #include "autoPtr.H"
namespace Foam namespace Foam
{ {
class polyMesh; class polyMesh;
class surfaceWriter;
label checkTopology(const polyMesh&, const bool, const bool); label checkTopology
(
const polyMesh&,
const bool,
const bool,
const autoPtr<surfaceWriter>&
);
} }

View File

@ -1,170 +0,0 @@
#include "printMeshStats.H"
#include "polyMesh.H"
#include "globalMeshData.H"
#include "hexMatcher.H"
#include "wedgeMatcher.H"
#include "prismMatcher.H"
#include "pyrMatcher.H"
#include "tetWedgeMatcher.H"
#include "tetMatcher.H"
#include "IOmanip.H"
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
{
Info<< "Mesh stats" << nl
<< " points: "
<< returnReduce(mesh.points().size(), sumOp<label>()) << nl;
label nInternalPoints = returnReduce
(
mesh.nInternalPoints(),
sumOp<label>()
);
if (nInternalPoints != -Pstream::nProcs())
{
Info<< " internal points: " << nInternalPoints << nl;
if (returnReduce(mesh.nInternalPoints(), minOp<label>()) == -1)
{
WarningIn("Foam::printMeshStats(const polyMesh&, const bool)")
<< "Some processors have their points sorted into internal"
<< " and external and some do not." << endl
<< "This can cause problems later on." << endl;
}
}
if (allTopology && nInternalPoints != -Pstream::nProcs())
{
label nEdges = returnReduce(mesh.nEdges(), sumOp<label>());
label nInternalEdges = returnReduce
(
mesh.nInternalEdges(),
sumOp<label>()
);
label nInternal1Edges = returnReduce
(
mesh.nInternal1Edges(),
sumOp<label>()
);
label nInternal0Edges = returnReduce
(
mesh.nInternal0Edges(),
sumOp<label>()
);
Info<< " edges: " << nEdges << nl
<< " internal edges: " << nInternalEdges << nl
<< " internal edges using one boundary point: "
<< nInternal1Edges-nInternal0Edges << nl
<< " internal edges using two boundary points: "
<< nInternalEdges-nInternal1Edges << nl;
}
label nFaces = returnReduce(mesh.faces().size(), sumOp<label>());
label nIntFaces = returnReduce(mesh.faceNeighbour().size(), sumOp<label>());
label nCells = returnReduce(mesh.cells().size(), sumOp<label>());
Info<< " faces: " << nFaces << nl
<< " internal faces: " << nIntFaces << nl
<< " cells: " << nCells << nl
<< " faces per cell: "
<< scalar(nFaces + nIntFaces)/max(1, nCells) << nl
<< " boundary patches: " << mesh.boundaryMesh().size() << nl
<< " point zones: " << mesh.pointZones().size() << nl
<< " face zones: " << mesh.faceZones().size() << nl
<< " cell zones: " << mesh.cellZones().size() << nl
<< endl;
// Construct shape recognizers
hexMatcher hex;
prismMatcher prism;
wedgeMatcher wedge;
pyrMatcher pyr;
tetWedgeMatcher tetWedge;
tetMatcher tet;
// Counters for different cell types
label nHex = 0;
label nWedge = 0;
label nPrism = 0;
label nPyr = 0;
label nTet = 0;
label nTetWedge = 0;
label nUnknown = 0;
Map<label> polyhedralFaces;
for (label cellI = 0; cellI < mesh.nCells(); cellI++)
{
if (hex.isA(mesh, cellI))
{
nHex++;
}
else if (tet.isA(mesh, cellI))
{
nTet++;
}
else if (pyr.isA(mesh, cellI))
{
nPyr++;
}
else if (prism.isA(mesh, cellI))
{
nPrism++;
}
else if (wedge.isA(mesh, cellI))
{
nWedge++;
}
else if (tetWedge.isA(mesh, cellI))
{
nTetWedge++;
}
else
{
nUnknown++;
polyhedralFaces(mesh.cells()[cellI].size())++;
}
}
reduce(nHex,sumOp<label>());
reduce(nPrism,sumOp<label>());
reduce(nWedge,sumOp<label>());
reduce(nPyr,sumOp<label>());
reduce(nTetWedge,sumOp<label>());
reduce(nTet,sumOp<label>());
reduce(nUnknown,sumOp<label>());
Info<< "Overall number of cells of each type:" << nl
<< " hexahedra: " << nHex << nl
<< " prisms: " << nPrism << nl
<< " wedges: " << nWedge << nl
<< " pyramids: " << nPyr << nl
<< " tet wedges: " << nTetWedge << nl
<< " tetrahedra: " << nTet << nl
<< " polyhedra: " << nUnknown
<< endl;
if (nUnknown > 0)
{
Pstream::mapCombineGather(polyhedralFaces, plusEqOp<label>());
Info<< " Breakdown of polyhedra by number of faces:" << nl
<< " faces" << " number of cells" << endl;
const labelList sortedKeys = polyhedralFaces.sortedToc();
forAll(sortedKeys, keyI)
{
const label nFaces = sortedKeys[keyI];
Info<< setf(std::ios::right) << setw(13)
<< nFaces << " " << polyhedralFaces[nFaces] << nl;
}
}
Info<< endl;
}

View File

@ -1,6 +0,0 @@
namespace Foam
{
class polyMesh;
void printMeshStats(const polyMesh& mesh, const bool allTopology);
}

View File

@ -1,15 +1,16 @@
EXE_INC = \ EXE_INC = \
/* -DFULLDEBUG -g -O0 */ \ /* -DFULLDEBUG -g -O0 */ \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude -I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-ldynamicMesh \
-lmeshTools \ -lmeshTools \
-lfileFormats \
-lsampling \ -lsampling \
-lgenericPatchFields \ -lgenericPatchFields \
-llagrangian -llagrangian

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,6 +28,7 @@ License
#include "IOField.H" #include "IOField.H"
#include "OFstream.H" #include "OFstream.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "ensightPTraits.H"
using namespace Foam; using namespace Foam;
@ -105,8 +106,10 @@ void ensightCloudField
v = pTraits<Type>::zero; v = pTraits<Type>::zero;
} }
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction i=0; i < pTraits<Type>::nComponents; ++i)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[i];
ensightFile << setw(12) << component(v, cmpt); ensightFile << setw(12) << component(v, cmpt);
if (++count % 6 == 0) if (++count % 6 == 0)
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,6 +34,7 @@ License
#include "ensightAsciiStream.H" #include "ensightAsciiStream.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "ensightPTraits.H" #include "ensightPTraits.H"
#include "zeroGradientFvPatchField.H"
using namespace Foam; using namespace Foam;
@ -64,6 +65,85 @@ volField
} }
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> >
volField
(
const fvMeshSubset& meshSubsetter,
const typename GeometricField
<
Type,
fvPatchField,
volMesh
>::DimensionedInternalField& df
)
{
// Construct volField (with zeroGradient) from dimensioned field
IOobject io(df);
io.readOpt() = IOobject::NO_READ;
tmp<GeometricField<Type, fvPatchField, volMesh> > tvf
(
new GeometricField<Type, fvPatchField, volMesh>
(
io,
df.mesh(),
df.dimensions(),
zeroGradientFvPatchField<scalar>::typeName
)
);
tvf().internalField() = df;
tvf().correctBoundaryConditions();
const GeometricField<Type, fvPatchField, volMesh>& vf = tvf();
if (meshSubsetter.hasSubMesh())
{
tmp<GeometricField<Type, fvPatchField, volMesh> > tfld
(
meshSubsetter.interpolate(vf)
);
tfld().checkOut();
tfld().rename(vf.name());
return tfld;
}
else
{
return tvf;
}
}
//template<class Container>
//void readAndConvertField
//(
// const fvMeshSubset& meshSubsetter,
// const IOobject& io,
// const fvMesh& mesh,
// const ensightMesh& eMesh,
// const fileName& postProcPath,
// const word& prepend,
// const label timeIndex,
// const bool binary,
// const bool nodeValues,
// Ostream& ensightCaseFile
//)
//{
// Container fld(io, mesh);
// ensightField<typename Container::value_type>
// (
// volField<typename Container::value_type>(meshSubsetter, fld),
// eMesh,
// postProcPath,
// prepend,
// timeIndex,
// binary,
// nodeValues,
// ensightCaseFile
// );
//}
template<class Type> template<class Type>
Field<Type> map Field<Type> map
( (
@ -104,8 +184,10 @@ void writeField
{ {
ensightFile.write(key); ensightFile.write(key);
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction i=0; i < pTraits<Type>::nComponents; ++i)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[i];
ensightFile.write(vf.component(cmpt)); ensightFile.write(vf.component(cmpt));
for (int slave=1; slave<Pstream::nProcs(); slave++) for (int slave=1; slave<Pstream::nProcs(); slave++)
@ -118,8 +200,10 @@ void writeField
} }
else else
{ {
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction i=0; i < pTraits<Type>::nComponents; ++i)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[i];
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< vf.component(cmpt); toMaster<< vf.component(cmpt);
} }

View File

@ -49,6 +49,21 @@ volField
); );
//- Wrapper to convert dimensionedInternalField to volField
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
volField
(
const Foam::fvMeshSubset&,
const typename Foam::GeometricField
<
Type,
Foam::fvPatchField,
Foam::volMesh
>::DimensionedInternalField& df
);
template<class Type> template<class Type>
void ensightField void ensightField
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -50,10 +50,12 @@ void Foam::ensightMesh::correct()
meshCellSets_.setSize(mesh_.nCells()); meshCellSets_.setSize(mesh_.nCells());
boundaryFaceSets_.setSize(mesh_.boundary().size()); boundaryFaceSets_.setSize(mesh_.boundary().size());
boundaryFaceSets_ = faceSets(); // if number of patches changes
allPatchNames_.clear(); allPatchNames_.clear();
patchNames_.clear(); patchNames_.clear();
nPatchPrims_ = 0; nPatchPrims_ = 0;
faceZoneFaceSets_.setSize(mesh_.faceZones().size()); faceZoneFaceSets_.setSize(mesh_.faceZones().size());
faceZoneFaceSets_ = faceSets(); // if number of patches changes
faceZoneNames_.clear(); faceZoneNames_.clear();
nFaceZonePrims_ = 0; nFaceZonePrims_ = 0;
boundaryFaceToBeIncluded_.clear(); boundaryFaceToBeIncluded_.clear();

View File

@ -167,14 +167,20 @@ int main(int argc, char *argv[])
regionPrefix = regionName; regionPrefix = regionName;
} }
const label nVolFieldTypes = 5; const label nVolFieldTypes = 10;
const word volFieldTypes[] = const word volFieldTypes[] =
{ {
volScalarField::typeName, volScalarField::typeName,
volVectorField::typeName, volVectorField::typeName,
volSphericalTensorField::typeName, volSphericalTensorField::typeName,
volSymmTensorField::typeName, volSymmTensorField::typeName,
volTensorField::typeName volTensorField::typeName,
volScalarField::DimensionedInternalField::typeName,
volVectorField::DimensionedInternalField::typeName,
volSphericalTensorField::DimensionedInternalField::typeName,
volSymmTensorField::DimensionedInternalField::typeName,
volTensorField::DimensionedInternalField::typeName
}; };
// Path to EnSight directory at case level only // Path to EnSight directory at case level only
@ -543,6 +549,122 @@ int main(int argc, char *argv[])
ensightCaseFile ensightCaseFile
); );
} }
// DimensionedFields
else if
(
volFieldTypes[i]
== volScalarField::DimensionedInternalField::typeName
)
{
volScalarField::DimensionedInternalField df
(
fieldObject,
mesh
);
ensightField<scalar>
(
volField<scalar>(meshSubsetter, df),
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
nodeValues,
ensightCaseFile
);
}
else if
(
volFieldTypes[i]
== volVectorField::DimensionedInternalField::typeName
)
{
volVectorField::DimensionedInternalField df
(
fieldObject,
mesh
);
ensightField<vector>
(
volField<vector>(meshSubsetter, df),
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
nodeValues,
ensightCaseFile
);
}
else if
(
volFieldTypes[i]
== volSphericalTensorField::DimensionedInternalField::typeName
)
{
volSphericalTensorField::DimensionedInternalField df
(
fieldObject,
mesh
);
ensightField<sphericalTensor>
(
volField<sphericalTensor>(meshSubsetter, df),
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
nodeValues,
ensightCaseFile
);
}
else if
(
volFieldTypes[i]
== volSymmTensorField::DimensionedInternalField::typeName
)
{
volSymmTensorField::DimensionedInternalField df
(
fieldObject,
mesh
);
ensightField<symmTensor>
(
volField<symmTensor>(meshSubsetter, df),
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
nodeValues,
ensightCaseFile
);
}
else if
(
volFieldTypes[i]
== volTensorField::DimensionedInternalField::typeName
)
{
volTensorField::DimensionedInternalField df
(
fieldObject,
mesh
);
ensightField<tensor>
(
volField<tensor>(meshSubsetter, df),
eMesh,
ensightDir,
prepend,
timeIndex,
binary,
nodeValues,
ensightCaseFile
);
}
} }
} }

View File

@ -1,6 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude -I$(LIB_SRC)/conversion/lnInclude
@ -8,5 +9,6 @@ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-llagrangian \ -llagrangian \
-lmeshTools \ -lmeshTools \
-lfileFormats \
-lgenericPatchFields \ -lgenericPatchFields \
-lconversion -lconversion

View File

@ -8,6 +8,7 @@ setWriters = sampledSetWriters
$(setWriters)/writers.C $(setWriters)/writers.C
$(setWriters)/ensight/ensightSetWriterRunTime.C $(setWriters)/ensight/ensightSetWriterRunTime.C
$(setWriters)/ensight/ensightPTraits.C
$(setWriters)/gnuplot/gnuplotSetWriterRunTime.C $(setWriters)/gnuplot/gnuplotSetWriterRunTime.C
$(setWriters)/jplot/jplotSetWriterRunTime.C $(setWriters)/jplot/jplotSetWriterRunTime.C
$(setWriters)/raw/rawSetWriterRunTime.C $(setWriters)/raw/rawSetWriterRunTime.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,20 +27,57 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const Foam::ensightPTraits<Foam::scalar>::typeName = const char* const Foam::ensightPTraits<Foam::scalar>::typeName =
Foam::pTraits<Foam::scalar>::typeName; Foam::pTraits<Foam::scalar>::typeName;
template<>
const Foam::direction
Foam::ensightPTraits<Foam::scalar>::componentOrder[] = {0};
template<>
const char* const Foam::ensightPTraits<Foam::vector>::typeName = const char* const Foam::ensightPTraits<Foam::vector>::typeName =
Foam::pTraits<Foam::vector>::typeName; Foam::pTraits<Foam::vector>::typeName;
template<>
const Foam::direction
Foam::ensightPTraits<Foam::vector>::componentOrder[] = {0, 1, 2};
template<>
const char* const Foam::ensightPTraits<Foam::sphericalTensor>::typeName = const char* const Foam::ensightPTraits<Foam::sphericalTensor>::typeName =
Foam::pTraits<Foam::scalar>::typeName; Foam::pTraits<Foam::scalar>::typeName;
template<>
const Foam::direction
Foam::ensightPTraits<Foam::sphericalTensor>::componentOrder[] = {0};
template<>
const char* const Foam::ensightPTraits<Foam::symmTensor>::typeName = const char* const Foam::ensightPTraits<Foam::symmTensor>::typeName =
"tensor symm"; "tensor symm";
template<>
const Foam::direction
Foam::ensightPTraits<Foam::symmTensor>::componentOrder[] = {0, 3, 5, 1, 2, 4};
template<>
const char* const Foam::ensightPTraits<Foam::tensor>::typeName = const char* const Foam::ensightPTraits<Foam::tensor>::typeName =
"tensor asym"; "tensor asym";
template<>
const Foam::direction
Foam::ensightPTraits<Foam::tensor>::componentOrder[] =
{
0,
1,
2,
3,
4,
5,
6,
7,
8
};
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,6 +34,7 @@ Description
#include "pTraits.H" #include "pTraits.H"
#include "fieldTypes.H" #include "fieldTypes.H"
#include "direction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -53,48 +54,41 @@ public:
static const char* const typeName; static const char* const typeName;
}; //- Ordering table: return OpenFOAM component given Ensight component
// This is used for the symmTensor ordering: Ensight requires
// xx yy zz xy xz yz
template<> static const direction componentOrder[];
class ensightPTraits<scalar>
{
public:
static const char* const typeName;
}; };
template<> template<>
class ensightPTraits<vector> const char* const ensightPTraits<scalar>::typeName;
{
public:
static const char* const typeName;
};
template<> template<>
class ensightPTraits<sphericalTensor> const direction ensightPTraits<scalar>::componentOrder[];
{
public:
static const char* const typeName;
};
template<> template<>
class ensightPTraits<symmTensor> const char* const ensightPTraits<vector>::typeName;
{
public:
static const char* const typeName;
};
template<> template<>
class ensightPTraits<tensor> const direction ensightPTraits<vector>::componentOrder[];
{
public:
static const char* const typeName; template<>
}; const char* const ensightPTraits<sphericalTensor>::typeName;
template<>
const direction ensightPTraits<sphericalTensor>::componentOrder[];
template<>
const char* const ensightPTraits<symmTensor>::typeName;
template<>
const direction ensightPTraits<symmTensor>::componentOrder[];
template<>
const char* const ensightPTraits<tensor>::typeName;
template<>
const direction ensightPTraits<tensor>::componentOrder[];
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,6 +29,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "foamVersion.H" #include "foamVersion.H"
#include "ensightPTraits.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -57,7 +58,7 @@ Foam::fileName Foam::ensightSetWriter<Type>::getFileName
return return
this->getBaseName(points, valueSetNames) this->getBaseName(points, valueSetNames)
//+ '_' //+ '_'
//+ pTraits<Type>::typeName //+ ensightPTraits<Type>::typeName
+ ".case"; + ".case";
} }
@ -88,7 +89,7 @@ void Foam::ensightSetWriter<Type>::write
fileName dataFile(base + ".***." + valueSetNames[setI]); fileName dataFile(base + ".***." + valueSetNames[setI]);
os.setf(ios_base::left); os.setf(ios_base::left);
os << pTraits<Type>::typeName os << ensightPTraits<Type>::typeName
<< " per node: 1 " << " per node: 1 "
<< setw(15) << valueSetNames[setI] << setw(15) << valueSetNames[setI]
<< " " << dataFile.name().c_str() << " " << dataFile.name().c_str()
@ -151,12 +152,15 @@ void Foam::ensightSetWriter<Type>::write
os.setf(ios_base::scientific, ios_base::floatfield); os.setf(ios_base::scientific, ios_base::floatfield);
os.precision(5); os.precision(5);
{ {
os << pTraits<Type>::typeName << nl os << ensightPTraits<Type>::typeName << nl
<< "part" << nl << "part" << nl
<< setw(10) << 1 << nl << setw(10) << 1 << nl
<< "coordinates" << nl; << "coordinates" << nl;
for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[i];
const scalarField fld(valueSets[setI]->component(cmpt)); const scalarField fld(valueSets[setI]->component(cmpt));
forAll(fld, i) forAll(fld, i)
{ {
@ -202,7 +206,7 @@ void Foam::ensightSetWriter<Type>::write
fileName dataFile(base + ".***." + valueSetNames[setI]); fileName dataFile(base + ".***." + valueSetNames[setI]);
os.setf(ios_base::left); os.setf(ios_base::left);
os << pTraits<Type>::typeName os << ensightPTraits<Type>::typeName
<< " per node: 1 " << " per node: 1 "
<< setw(15) << valueSetNames[setI] << setw(15) << valueSetNames[setI]
<< " " << dataFile.name().c_str() << " " << dataFile.name().c_str()
@ -277,7 +281,7 @@ void Foam::ensightSetWriter<Type>::write
os.setf(ios_base::scientific, ios_base::floatfield); os.setf(ios_base::scientific, ios_base::floatfield);
os.precision(5); os.precision(5);
{ {
os << pTraits<Type>::typeName << nl; os << ensightPTraits<Type>::typeName << nl;
const List<Field<Type> >& fieldVals = valueSets[setI]; const List<Field<Type> >& fieldVals = valueSets[setI];
forAll(fieldVals, trackI) forAll(fieldVals, trackI)
@ -286,13 +290,10 @@ void Foam::ensightSetWriter<Type>::write
<< setw(10) << trackI+1 << nl << setw(10) << trackI+1 << nl
<< "coordinates" << nl; << "coordinates" << nl;
for for (direction i=0; i < pTraits<Type>::nComponents; ++i)
(
direction cmpt = 0;
cmpt < pTraits<Type>::nComponents;
cmpt++
)
{ {
label cmpt = ensightPTraits<Type>::componentOrder[i];
const scalarField fld(fieldVals[trackI].component(cmpt)); const scalarField fld(fieldVals[trackI].component(cmpt));
forAll(fld, i) forAll(fld, i)
{ {

View File

@ -43,7 +43,6 @@ surfWriters = sampledSurface/writers
$(surfWriters)/surfaceWriter.C $(surfWriters)/surfaceWriter.C
$(surfWriters)/dx/dxSurfaceWriter.C $(surfWriters)/dx/dxSurfaceWriter.C
$(surfWriters)/ensight/ensightSurfaceWriter.C $(surfWriters)/ensight/ensightSurfaceWriter.C
$(surfWriters)/ensight/ensightPTraits.C
$(surfWriters)/foamFile/foamFileSurfaceWriter.C $(surfWriters)/foamFile/foamFileSurfaceWriter.C
$(surfWriters)/nastran/nastranSurfaceWriter.C $(surfWriters)/nastran/nastranSurfaceWriter.C
$(surfWriters)/proxy/proxySurfaceWriter.C $(surfWriters)/proxy/proxySurfaceWriter.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,6 +45,7 @@ Description
interpolate false; interpolate false;
} }
); );
}
- write using this writer. - write using this writer.
- move postProcessing/surfaces/outlet to constant/boundaryData/outlet - move postProcessing/surfaces/outlet to constant/boundaryData/outlet