diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 5c8f4da2d7..4f1f821681 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -8,7 +8,6 @@ #include "wedgePolyPatch.H" #include "unitConversion.H" #include "polyMeshTetDecomposition.H" -#include "surfaceWriter.H" #include "checkTools.H" #include "functionObject.H" @@ -482,7 +481,7 @@ Foam::label Foam::checkGeometry ( const polyMesh& mesh, const bool allGeometry, - const autoPtr& surfWriter, + autoPtr& surfWriter, const autoPtr>& setWriter ) { @@ -542,7 +541,7 @@ Foam::label Foam::checkGeometry nonAlignedPoints.write(); if (setWriter.valid()) { - mergeAndWrite(setWriter(), nonAlignedPoints); + mergeAndWrite(*setWriter, nonAlignedPoints); } } } @@ -576,7 +575,7 @@ Foam::label Foam::checkGeometry cells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), cells); + mergeAndWrite(*surfWriter, cells); } } } @@ -592,7 +591,7 @@ Foam::label Foam::checkGeometry aspectCells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), aspectCells); + mergeAndWrite(*surfWriter, aspectCells); } } } @@ -613,7 +612,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -635,7 +634,7 @@ Foam::label Foam::checkGeometry cells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), cells); + mergeAndWrite(*surfWriter, cells); } } } @@ -658,7 +657,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -680,7 +679,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -702,7 +701,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -726,7 +725,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -759,7 +758,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -784,7 +783,7 @@ Foam::label Foam::checkGeometry points.write(); if (setWriter.valid()) { - mergeAndWrite(setWriter(), points); + mergeAndWrite(*setWriter, points); } } } @@ -807,7 +806,7 @@ Foam::label Foam::checkGeometry nearPoints.write(); if (setWriter.valid()) { - mergeAndWrite(setWriter(), nearPoints); + mergeAndWrite(*setWriter, nearPoints); } } } @@ -831,7 +830,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -854,7 +853,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -875,7 +874,7 @@ Foam::label Foam::checkGeometry cells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), cells); + mergeAndWrite(*surfWriter, cells); } } } @@ -895,7 +894,7 @@ Foam::label Foam::checkGeometry cells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), cells); + mergeAndWrite(*surfWriter, cells); } } } @@ -916,7 +915,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -937,7 +936,7 @@ Foam::label Foam::checkGeometry faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -952,14 +951,10 @@ Foam::label Foam::checkGeometry autoPtr patchWriter; if (!surfWriter.valid()) { - patchWriter.reset(new vtkSurfaceWriter()); + patchWriter.reset(new surfaceWriters::vtkWriter()); } - const surfaceWriter& wr = - ( - surfWriter.valid() - ? surfWriter() - : patchWriter() - ); + + surfaceWriter& wr = (surfWriter.valid() ? *surfWriter : *patchWriter); // Currently only do AMI checks @@ -1017,22 +1012,22 @@ Foam::label Foam::checkGeometry if (Pstream::master()) { - wr.write + const word fName ( - outputDir, - ( - "patch" + Foam::name(cpp.index()) - + "-src_" + tmName - ), - meshedSurfRef - ( - mergedPoints, - mergedFaces - ), - "weightsSum", - mergedWeights, - false + "patch" + Foam::name(cpp.index()) + + "-src_" + tmName ); + + wr.open + ( + mergedPoints, + mergedFaces, + (outputDir / fName), + false // serial - already merged + ); + + wr.write("weightsSum", mergedWeights); + wr.clear(); } if (isA(pbm[patchi])) @@ -1049,22 +1044,22 @@ Foam::label Foam::checkGeometry if (Pstream::master()) { - wr.write + const word fName ( - outputDir, - ( - "patch" + Foam::name(cpp.index()) - + "-src_" + tmName - ), - meshedSurfRef - ( - mergedPoints, - mergedFaces - ), - "mask", - mergedMask, - false + "patch" + Foam::name(cpp.index()) + + "-src_" + tmName ); + + wr.open + ( + mergedPoints, + mergedFaces, + (outputDir / fName), + false // serial - already merged + ); + + wr.write("mask", mergedMask); + wr.clear(); } } } @@ -1101,22 +1096,22 @@ Foam::label Foam::checkGeometry if (Pstream::master()) { - wr.write + const word fName ( - outputDir, - ( - "patch" + Foam::name(cpp.index()) - + "-tgt_" + tmName - ), - meshedSurfRef - ( - mergedPoints, - mergedFaces - ), - "weightsSum", - mergedWeights, - false + "patch" + Foam::name(cpp.index()) + + "-tgt_" + tmName ); + + wr.open + ( + mergedPoints, + mergedFaces, + (outputDir / fName), + false // serial - already merged + ); + + wr.write("weightsSum", mergedWeights); + wr.clear(); } if (isA(pbm[patchi])) @@ -1129,24 +1124,25 @@ Foam::label Foam::checkGeometry pp.neighbPatch().mask(), mergedMask ); + if (Pstream::master()) { - wr.write + const word fName ( - outputDir, - ( - "patch" + Foam::name(cpp.index()) - + "-tgt_" + tmName - ), - meshedSurfRef - ( - mergedPoints, - mergedFaces - ), - "mask", - mergedMask, - false + "patch" + Foam::name(cpp.index()) + + "-tgt_" + tmName ); + + wr.open + ( + mergedPoints, + mergedFaces, + (outputDir / fName), + false // serial - already merged + ); + + wr.write("mask", mergedMask); + wr.clear(); } } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H index d0111fd1e1..acd3d401be 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H @@ -27,7 +27,7 @@ namespace Foam ( const polyMesh& mesh, const bool allGeometry, - const autoPtr&, - const autoPtr>& + autoPtr& surfWriter, + const autoPtr>& setWriter ); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index 0df2a3dcd3..fcf6c145b8 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010, 2015-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2010, 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2017 OpenFOAM Foundation @@ -67,8 +67,8 @@ Usage #include "Time.H" #include "fvMesh.H" #include "globalMeshData.H" -#include "surfaceWriter.H" #include "vtkSetWriter.H" +#include "vtkSurfaceWriter.H" #include "IOdictionary.H" #include "checkTools.H" @@ -149,16 +149,19 @@ int main(int argc, char *argv[]) ); if (!writeFields && args.found("writeAllFields")) { - selectedFields.insert("nonOrthoAngle"); - selectedFields.insert("faceWeight"); - selectedFields.insert("skewness"); - selectedFields.insert("cellDeterminant"); - selectedFields.insert("aspectRatio"); - selectedFields.insert("cellShapes"); - selectedFields.insert("cellVolume"); - selectedFields.insert("cellVolumeRatio"); - selectedFields.insert("minTetVolume"); - selectedFields.insert("cellRegion"); + selectedFields.insert + ({ + "nonOrthoAngle", + "faceWeight", + "skewness", + "cellDeterminant", + "aspectRatio", + "cellShapes", + "cellVolume", + "cellVolumeRatio", + "minTetVolume", + "cellRegion" + }); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C index a6a01c7336..26dfbb6d20 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C @@ -10,7 +10,7 @@ Foam::label Foam::checkMeshQuality ( const polyMesh& mesh, const dictionary& dict, - const autoPtr& writer + autoPtr& writer ) { label noFailedChecks = 0; @@ -29,9 +29,10 @@ Foam::label Foam::checkMeshQuality << " faces in error to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) { - mergeAndWrite(writer(), faces); + mergeAndWrite(*writer, faces); } } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H index 52507986bf..0ad3f74487 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H @@ -6,8 +6,8 @@ namespace Foam label checkMeshQuality ( - const polyMesh&, - const dictionary&, - const autoPtr& + const polyMesh& mesh, + const dictionary& dict, + autoPtr& writer ); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C index 060c60b0fc..4b530ee9ef 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -209,7 +209,7 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) void Foam::mergeAndWrite ( const polyMesh& mesh, - const surfaceWriter& writer, + surfaceWriter& writer, const word& name, const indirectPrimitivePatch& setPatch, const fileName& outputDir @@ -242,37 +242,37 @@ void Foam::mergeAndWrite // Write if (Pstream::master()) { - writer.write + writer.open ( - outputDir, - name, - meshedSurfRef - ( - mergedPoints, - mergedFaces - ) + mergedPoints, + mergedFaces, + (outputDir / name), + false // serial - already merged ); + + writer.writeGeometry(); + writer.clear(); } } else { - writer.write + writer.open ( - outputDir, - name, - meshedSurfRef - ( - setPatch.localPoints(), - setPatch.localFaces() - ) + setPatch.localPoints(), + setPatch.localFaces(), + (outputDir / name), + false // serial - already merged ); + + writer.writeGeometry(); + writer.clear(); } } void Foam::mergeAndWrite ( - const surfaceWriter& writer, + surfaceWriter& writer, const faceSet& set ) { @@ -299,7 +299,7 @@ void Foam::mergeAndWrite void Foam::mergeAndWrite ( - const surfaceWriter& writer, + surfaceWriter& writer, const cellSet& set ) { diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.H b/applications/utilities/mesh/manipulation/checkMesh/checkTools.H index adb98089b5..79c68b6673 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.H @@ -5,12 +5,12 @@ namespace Foam { class polyMesh; - class surfaceWriter; class pointSet; class faceSet; class cellSet; class fileName; class polyMesh; + class surfaceWriter; void printMeshStats(const polyMesh& mesh, const bool allTopology); @@ -19,7 +19,7 @@ namespace Foam void mergeAndWrite ( const polyMesh& mesh, - const surfaceWriter& writer, + surfaceWriter& writer, const word& name, const indirectPrimitivePatch& setPatch, const fileName& outputDir @@ -27,15 +27,15 @@ namespace Foam //- Write vtk representation of (assembled) faceSet to surface file in // postProcessing/ directory - void mergeAndWrite(const surfaceWriter&, const faceSet&); + void mergeAndWrite(surfaceWriter& writer, const faceSet& set); //- Write vtk representation of (assembled) cellSet to surface file in // postProcessing/ directory - void mergeAndWrite(const surfaceWriter&, const cellSet&); + void mergeAndWrite(surfaceWriter& writer, const cellSet& set); //- Write vtk representation of (assembled) pointSet to 'set' file in // postProcessing/ directory - void mergeAndWrite(const writer&, const pointSet&); + void mergeAndWrite(const writer& writer, const pointSet& set); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index fb0d1c6ccf..25c8e43de8 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -35,7 +35,7 @@ License #include "IOmanip.H" #include "emptyPolyPatch.H" #include "processorPolyPatch.H" -#include "surfaceWriter.H" +#include "vtkSurfaceWriter.H" #include "checkTools.H" #include "treeBoundBox.H" @@ -114,7 +114,7 @@ Foam::label Foam::checkTopology const polyMesh& mesh, const bool allTopology, const bool allGeometry, - const autoPtr& surfWriter, + autoPtr& surfWriter, const autoPtr>& setWriter ) { @@ -203,7 +203,7 @@ Foam::label Foam::checkTopology cells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), cells); + mergeAndWrite(*surfWriter, cells); } } else @@ -227,7 +227,7 @@ Foam::label Foam::checkTopology points.write(); if (setWriter.valid()) { - mergeAndWrite(setWriter(), points); + mergeAndWrite(*setWriter, points); } } } @@ -249,7 +249,7 @@ Foam::label Foam::checkTopology faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -269,7 +269,7 @@ Foam::label Foam::checkTopology faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -290,7 +290,7 @@ Foam::label Foam::checkTopology cells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), cells); + mergeAndWrite(*surfWriter, cells); } } @@ -314,7 +314,7 @@ Foam::label Foam::checkTopology faces.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), faces); + mergeAndWrite(*surfWriter, faces); } } } @@ -369,7 +369,7 @@ Foam::label Foam::checkTopology oneCells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), oneCells); + mergeAndWrite(*surfWriter, oneCells); } } @@ -385,7 +385,7 @@ Foam::label Foam::checkTopology twoCells.write(); if (surfWriter.valid()) { - mergeAndWrite(surfWriter(), twoCells); + mergeAndWrite(*surfWriter, twoCells); } } } @@ -530,7 +530,7 @@ Foam::label Foam::checkTopology points.write(); if (setWriter.valid()) { - mergeAndWrite(setWriter(), points); + mergeAndWrite(*setWriter, points); } } } @@ -641,7 +641,7 @@ Foam::label Foam::checkTopology points.write(); if (setWriter.valid()) { - mergeAndWrite(setWriter(), points); + mergeAndWrite(*setWriter, points); } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H index 7320cb0e56..bd93afc3db 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H @@ -5,8 +5,8 @@ namespace Foam { class polyMesh; - class surfaceWriter; class pointSet; + class surfaceWriter; template void checkPatch @@ -19,10 +19,10 @@ namespace Foam label checkTopology ( - const polyMesh&, - const bool, - const bool, - const autoPtr&, - const autoPtr>& + const polyMesh& mesh, + const bool allTopology, + const bool allGeometry, + autoPtr& surfWriter, + const autoPtr>& setWriter ); } diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index 7564f5faf2..eab6eff932 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2011, 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011, 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -128,7 +128,7 @@ labelList countBins void writeZoning ( - const surfaceWriter& writer, + surfaceWriter& writer, const triSurface& surf, const labelList& faceZone, const word& fieldName, @@ -136,43 +136,23 @@ void writeZoning const fileName& surfFileNameBase ) { - Info<< "Writing zoning to " - << fileName - ( - surfFilePath - / fieldName - + '_' - + surfFileNameBase - + '.' - + writer.type() - ) - << " ..." << endl << endl; + // Transcribe faces + faceList faces; + surf.triFaceFaces(faces); - // Convert data - scalarField scalarFaceZone(faceZone.size()); - forAll(faceZone, i) - { - scalarFaceZone[i] = faceZone[i]; - } - faceList faces(surf.size()); - forAll(surf, i) - { - faces[i] = surf[i]; - } - - writer.write + writer.open ( - surfFilePath, - surfFileNameBase, - meshedSurfRef - ( - surf.points(), - faces - ), - fieldName, - scalarFaceZone, - false // face based data + surf.points(), + faces, + (surfFilePath / surfFileNameBase), + false // serial - already merged ); + + fileName outputName = writer.write(fieldName, labelField(faceZone)); + + writer.clear(); + + Info<< "Wrote zoning to " << outputName << nl << endl; } @@ -213,7 +193,7 @@ void writeParts fileName subName ( surfFilePath - /surfFileNameBase + "_" + name(zone) + ".obj" + / surfFileNameBase + "_" + name(zone) + ".obj" ); Info<< "writing part " << zone << " size " << subSurf.size() @@ -377,6 +357,7 @@ int main(int argc, char *argv[]) if (writeSets) { surfWriter = surfaceWriter::New(surfaceFormat); + // Option1: hard-coded format edgeFormat = "obj"; //// Option2: same type as surface format. Problem is e.g. .obj format @@ -514,38 +495,29 @@ int main(int argc, char *argv[]) ) ); - const fileName qualityName + + // Transcribe faces + faceList faces; + subSurf.triFaceFaces(faces); + + surfWriter->open ( - surfFilePath - / "illegal" - + '_' - + surfFileNameBase - + '.' - + surfWriter().type() + subSurf.points(), + faces, + (surfFilePath / surfFileNameBase), + false // serial - already merged ); - Info<< "Writing illegal triangles to " - << qualityName << " ..." << endl << endl; - // Convert data - faceList faces(subSurf.size()); - forAll(subSurf, i) - { - faces[i] = subSurf[i]; - } - - surfWriter().write + fileName outputName = surfWriter->write ( - surfFilePath, - surfFileNameBase, - meshedSurfRef - ( - subSurf.points(), - faces - ), "illegal", - scalarField(subSurf.size(), Zero), - false // face based data + scalarField(subSurf.size(), Zero) ); + + surfWriter->clear(); + + Info<< "Wrote illegal triangles to " + << outputName << nl << endl; } else if (outputThreshold > 0) { @@ -645,38 +617,24 @@ int main(int argc, char *argv[]) // Dump for subsetting if (surfWriter.valid()) { - const fileName qualityName - ( - surfFilePath - / "quality" - + '_' - + surfFileNameBase - + '.' - + surfWriter().type() - ); - Info<< "Writing triangle-quality to " - << qualityName << " ..." << endl << endl; - - // Convert data + // Transcribe faces faceList faces(surf.size()); - forAll(surf, i) - { - faces[i] = surf[i]; - } + surf.triFaceFaces(faces); - surfWriter().write + surfWriter->open ( - surfFilePath, - surfFileNameBase, - meshedSurfRef - ( - surf.points(), - faces - ), - "quality", - triQ, - false // face based data + surf.points(), + faces, + (surfFilePath / surfFileNameBase), + false // serial - already merged ); + + fileName outputName = surfWriter->write("quality", triQ); + + surfWriter->clear(); + + Info<< "Wrote triangle-quality to " + << outputName << nl << endl; } else if (outputThreshold > 0) { @@ -926,11 +884,12 @@ int main(int argc, char *argv[]) if (!surfWriter.valid()) { - surfWriter.reset(new vtkSurfaceWriter()); + surfWriter.reset(new surfaceWriters::vtkWriter()); } + writeZoning ( - surfWriter(), + *surfWriter, surf, faceZone, "zone", @@ -991,11 +950,12 @@ int main(int argc, char *argv[]) { if (!surfWriter.valid()) { - surfWriter.reset(new vtkSurfaceWriter()); + surfWriter.reset(new surfaceWriters::vtkWriter()); } + writeZoning ( - surfWriter(), + *surfWriter, surf, normalZone, "normal", diff --git a/etc/caseDicts/annotated/runTimePostProcessingDict b/etc/caseDicts/annotated/runTimePostProcessingDict new file mode 100644 index 0000000000..cbe82ec81f --- /dev/null +++ b/etc/caseDicts/annotated/runTimePostProcessingDict @@ -0,0 +1,281 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1812 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object runTimePostProcessingDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// Type of functionObject +type runTimePostProcessing; + +// Where to load it from +libs ("librunTimePostProcessing.so"); + +// Function object enabled flag +enabled true; + +// When to output the average fields +writeControl writeTime; + +//- Optionally disable parallel VTK rendering, default = true +// parallel true; + +//- The output characteristics +output +{ + //- The name stem for output images + name image; + + //- The image dimensions + width 1400; + height 1050; +} + + +//- The camera settings +camera +{ + // If camera is moving, optionally provide start and end times + // startPosition 0.2; + // endPosition 0.75; + + // Total number of frames to generate + nFrameTotal 1; + + // Parallel projection flag + parallelProjection yes; + + // clipBox is optional + + position (385 -560 650); + focalPoint (160 90 60); + up (0.06 0.7 0.7); + + position ( -41.95 -247.55 426.87 ); + focalPoint ( 146 76 40 ); + up ( 0.3646 0.6194 0.6953 ); + + zoom 1.5; + // clipBox (-10 18 0)(280 160 76); + clipBox (-30 0 0)(300 200 80); +} + + +// Default colours +// - If select to colourBy colour, these values are used unless +// they are locally overridden +colours +{ + background (0.317647 0.341176 0.431373); + background2 (0.317647 0.341176 0.431373); + text (0.75 0.75 0.75); + edge (1 0 0); + surface (0.5 0.5 0.5); + line (1 0 0); + point (0.5 0.5 0.5); +} + + +// Line data +lines +{ + streamline + { + type functionObjectLine; + functionObject streamLines; + colourMap rainbow; + representation tube; + visible true; + tubeRadius 0.5; + colourBy field; + field U; + range (0 20); + opacity 1; + scalarBar + { + visible no; + } + } +} + + +// Surface data +surfaces +{ + geom + { + type geometry; + files ("/myGeometry.vtp"); + renderMode phong; + representation surface; + edgeColour (0.5 0.5 0.5); + visible yes; + featureEdges none; + opacity 1.0; + } + + surf1 + { + type functionObjectSurface; + functionObject planes.plane0; + liveObject true; + colourMap coolToWarm; + + representation surface; + maxGlyphLength 0.1; + smooth true; + visible yes; + + featureEdges none; + colourBy field; + field U; + range (0 20); + opacity 1; + + scalarBar + { + visible no; + } + } + + patches + { + type patches; + patches ( buildings ground ); + nearCellValue true; + smooth true; + colourMap coolToWarm; + representation surface; + representation glyph; + + // maxGlyphLength 5; + maxGlyphLength 0; + visible yes; + featureEdges none; + colourBy field; + + field U; + range (0 20); + + opacity 1; + scalarBar + { + visible no; + position (0.8 0.1); + vertical yes; + fontSize 16; + titleSize 18; + title "velocity [m/s]"; + labelFormat "%6.2f"; + numberOfLabels 5; + + bold yes; + italic yes; + shadow yes; + } + } + + + cutting + { + type plane; + planeType pointAndNormal; + + pointAndNormalDict + { + point (100 100 50); + normal (1 0 0); + } + + offsets (0 100 200); + + smooth true; + colourMap coolToWarm; + representation surface; + + representation glyph; + + // maxGlyphLength 5; + maxGlyphLength 0; + visible yes; + featureEdges none; + + colourBy field; + colourField U; + field U; + range (0 20); + + opacity 1; + scalarBar + { + visible no; + } + } + + iso + { + type iso; + values (0 4 8); + + smooth true; + colourMap coolToWarm; + representation surface; + + representation glyph; + + // maxGlyphLength 5; + maxGlyphLength 0; + visible yes; + featureEdges none; + + colourBy field; + colourField U; + field U; + range (0 20); + + colourField k; + field k; + range (0 20); + + colourBy field; + colourField U; + field U; + range (0 20); + + opacity 1; + scalarBar + { + visible no; + } + } +} + +// Text data +text +{ + text1 + { + string "buildings"; + position (0.5 0.15); + halign centre; + size 18; + opacity 0.4; + bold yes; + italic yes; + shadow yes; + visible yes; + } +} + + +// ************************************************************************* // diff --git a/etc/caseDicts/postProcessing/visualization/runTimePostPro.cfg b/etc/caseDicts/postProcessing/visualization/runTimePostPro.cfg new file mode 100644 index 0000000000..cf5ab38a1c --- /dev/null +++ b/etc/caseDicts/postProcessing/visualization/runTimePostPro.cfg @@ -0,0 +1,107 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1812 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +type runTimePostProcessing; + +libs ("librunTimePostProcessing.so"); + +writeControl writeTime; + +// Output characteristics +output +{ + //- The name stem for output images + name image; + + //- The image dimensions + width 1400; + height 1050; +} + + +// Some convenient colour schemes +colourScheme +{ + black + { + background (0 0 0); + text (0.75 0.75 0.75); + edge (1 0 0); + surface (0.5 0.5 0.5); + line (1 0 0); + point (0.5 0.5 0.5); + } + + blueGradient + { + background (1 1 1); + background2 (0 0 1); + text (0 0 0); + edge (1 0 0); + surface (0.5 0.5 0.5); + line (1 0 0); + point (0.5 0.5 0.5); + } + + greyGradient + { + background (0.5 0.5 0.5); + background2 (0.7 0.7 0.7); + text (1 1 1); + edge (1 0 0); + surface (0.5 0.5 0.5); + line (1 0 0); + point (0.5 0.5 0.5); + } + + paraview + { + background (0.317647 0.341176 0.431373); + text (0.75 0.75 0.75); + edge (1 0 0); + surface (0.5 0.5 0.5); + line (1 0 0); + point (0.5 0.5 0.5); + } +} + + +// Some typical scalarBar settings +scalarBar +{ + right + { + visible true; + vertical true; + position (0.8 0.1); + size (0.1 0.75); + fontSize 16; + labelFormat "%f"; + numberOfLabels 5; + bold yes; + italic yes; + shadow yes; + } + + bottom + { + visible true; + vertical false; + position (0.2 0.1); + size (0.6 0.1); + fontSize 16; + labelFormat "%f"; + numberOfLabels 5; + bold yes; + italic yes; + shadow yes; + } +} + + +// ************************************************************************* // diff --git a/etc/controlDict b/etc/controlDict index f6a1120cfc..3d6c94dd80 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -820,6 +820,7 @@ DebugSwitches rotatedBoxToCell 0; rotatingPressureInletOutletVelocity 0; rotatingTotalPressure 0; + runTimePostPro::geometryBase 0; sampledPatch 0; sampledPlane 0; sampledSet 0; diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.H b/src/functionObjects/field/fieldAverage/fieldAverage.H index 656fddc0b1..1212f7f25e 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.H +++ b/src/functionObjects/field/fieldAverage/fieldAverage.H @@ -32,7 +32,9 @@ Group Description Calculates average quantities for a user-specified selection of volumetric and surface fields. - With the %subRegion option, also supports fields on a surfMesh. + With the %subRegion option, also supports fields on functionObject + surface output (eg, sampledSurfaces). + Fields are entered as a list of sub-dictionaries, which indicate the type of averages to perform, and can be updated during the calculation. The current @@ -104,15 +106,15 @@ Usage Where the entries comprise: \table - Property | Description | Required | Default - type | type name: fieldAverage | yes | - restartOnRestart | Restart the averaging on restart | no | no - restartOnOutput | Restart the averaging on output | no | no - periodicRestart | Periodically restart the averaging | no | no - restartPeriod | Periodic restart period | conditional | - restartTime | One-shot reset of the averaging | no | great - fields | list of fields and averaging options | yes | - subRegion | name of a sub-region such as a surface name | no | + Property | Description | Required | Default + type | Type name: fieldAverage | yes | + restartOnRestart| Restart the averaging on restart | no | no + restartOnOutput | Restart the averaging on output | no | no + periodicRestart | Periodically restart the averaging | no | no + restartPeriod | Periodic restart period | conditional | + restartTime | One-shot reset of the averaging | no | great + fields | list of fields and averaging options | yes | + subRegion | Name for alternative objectRegistry | no | "" \endtable diff --git a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C index 109ac8aefb..b9ee121ab5 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageTemplates.C @@ -28,7 +28,7 @@ License #include "fieldAverageItem.H" #include "volFields.H" #include "surfaceFields.H" -#include "surfFields.H" +#include "polySurfaceFields.H" #include "OFstream.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -99,7 +99,7 @@ void Foam::functionObjects::fieldAverage::addMeanField { typedef GeometricField VolFieldType; typedef GeometricField SurfaceFieldType; - typedef DimensionedField SurfFieldType; + typedef DimensionedField SurfFieldType; if (item.mean()) { @@ -169,7 +169,7 @@ void Foam::functionObjects::fieldAverage::restoreWindowFields { typedef GeometricField VolFieldType; typedef GeometricField SurfaceFieldType; - typedef DimensionedField SurfFieldType; + typedef DimensionedField SurfFieldType; if (item.window() > 0) { @@ -243,11 +243,11 @@ void Foam::functionObjects::fieldAverage::addPrime2MeanField { typedef GeometricField VolFieldType1; typedef GeometricField SurfaceFieldType1; - typedef DimensionedField SurfFieldType1; + typedef DimensionedField SurfFieldType1; typedef GeometricField VolFieldType2; typedef GeometricField SurfaceFieldType2; - typedef DimensionedField SurfFieldType2; + typedef DimensionedField SurfFieldType2; if (item.prime2Mean()) { @@ -312,7 +312,7 @@ void Foam::functionObjects::fieldAverage::storeWindowFields() { typedef GeometricField VolFieldType; typedef GeometricField SurfaceFieldType; - typedef DimensionedField SurfFieldType; + typedef DimensionedField SurfFieldType; for (fieldAverageItem& item : faItems_) { @@ -331,7 +331,7 @@ void Foam::functionObjects::fieldAverage::calculateMeanFields() const { typedef GeometricField VolFieldType; typedef GeometricField SurfaceFieldType; - typedef DimensionedField SurfFieldType; + typedef DimensionedField SurfFieldType; for (const fieldAverageItem& item : faItems_) { @@ -347,11 +347,11 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFields() const { typedef GeometricField VolFieldType1; typedef GeometricField SurfaceFieldType1; - typedef DimensionedField SurfFieldType1; + typedef DimensionedField SurfFieldType1; typedef GeometricField VolFieldType2; typedef GeometricField SurfaceFieldType2; - typedef DimensionedField SurfFieldType2; + typedef DimensionedField SurfFieldType2; for (const fieldAverageItem& item : faItems_) { @@ -391,11 +391,11 @@ void Foam::functionObjects::fieldAverage::addMeanSqrToPrime2Mean() const { typedef GeometricField VolFieldType1; typedef GeometricField SurfaceFieldType1; - typedef DimensionedField SurfFieldType1; + typedef DimensionedField SurfFieldType1; typedef GeometricField VolFieldType2; typedef GeometricField SurfaceFieldType2; - typedef DimensionedField SurfFieldType2; + typedef DimensionedField SurfFieldType2; for (const fieldAverageItem& item : faItems_) { @@ -431,7 +431,7 @@ void Foam::functionObjects::fieldAverage::writeFields() const { typedef GeometricField VolFieldType; typedef GeometricField SurfaceFieldType; - typedef DimensionedField SurfFieldType; + typedef DimensionedField SurfFieldType; for (const fieldAverageItem& item : faItems_) { diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index 1df74fc79d..65225a544a 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -60,7 +60,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::regionTypeNames_ ({ { regionTypes::stFaceZone, "faceZone" }, { regionTypes::stPatch, "patch" }, - { regionTypes::stSurface, "surface" }, + { regionTypes::stObject, "functionObjectSurface" }, { regionTypes::stSampled, "sampledSurface" }, }); @@ -118,9 +118,9 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::postOperationTypeNames_ const Foam::objectRegistry& Foam::functionObjects::fieldValues::surfaceFieldValue::obr() const { - if (stSurface == regionType_) + if (stObject == regionType_) { - return mesh_.lookupObject(regionName_); + return storedObjects().lookupObject(regionName_); } return mesh_; @@ -368,9 +368,9 @@ combineSurfaceGeometry pointField& points ) const { - if (stSurface == regionType_) + if (stObject == regionType_) { - const surfMesh& s = dynamicCast(obr()); + const polySurface& s = dynamicCast(obr()); if (Pstream::parRun()) { @@ -436,9 +436,9 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const { scalar totalArea = 0; - if (stSurface == regionType_) + if (stObject == regionType_) { - const surfMesh& s = dynamicCast(obr()); + const polySurface& s = dynamicCast(obr()); totalArea = gSum(s.magSf()); } @@ -505,9 +505,9 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::update() setPatchFaces(); break; } - case stSurface: + case stObject: { - const surfMesh& s = dynamicCast(obr()); + const polySurface& s = dynamicCast(obr()); nFaces_ = returnReduce(s.size(), sumOp