Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
sergio
2018-12-17 08:21:04 -08:00
138 changed files with 1745 additions and 877 deletions

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) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,11 +38,13 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noBanner(); argList::noBanner();
argList::noParallel(); argList::noCheckProcessorDirectories(); // parallel OK, but without checks
// argList::noFunctionObjects(); // argList::noFunctionObjects();
argList::addOption("label", "value", "Test parsing of label"); argList::addOption("label", "value", "Test parsing of label");
argList::addOption("scalar", "value", "Test parsing of scalar"); argList::addOption("scalar", "value", "Test parsing of scalar");
argList::addOption("string", "value", "Test string lookup"); argList::addOption("string", "value", "Test string lookup");
argList::addOption("relative", "PATH", "Test relativePath");
// These are actually lies (never had -parseLabel, -parseScalar etc), // These are actually lies (never had -parseLabel, -parseScalar etc),
// but good for testing... // but good for testing...
@ -70,20 +72,27 @@ int main(int argc, char *argv[])
argList::addArgument("label"); argList::addArgument("label");
argList::noMandatoryArgs(); argList::noMandatoryArgs();
argList args(argc, argv); #include "setRootCase.H"
Info<< "command-line (" Pout<< "command-line ("
<< args.options().size() << " options, " << args.options().size() << " options, "
<< args.args().size() << " args)" << nl << args.args().size() << " args)" << nl
<< " " << args.commandLine().c_str() << nl << nl; << " " << args.commandLine().c_str() << nl << nl;
Info<< "rootPath: " << args.rootPath() << nl Pout<< "rootPath: " << args.rootPath() << nl
<< "globalCase: " << args.globalCaseName() << nl << "globalCase: " << args.globalCaseName() << nl
<< "globalPath: " << args.globalPath() << nl << "globalPath: " << args.globalPath() << nl
<< nl; << nl;
Info<<"have: " if (args.found("relative"))
<<args.count({"label", "scalar"}) << " options" << nl; {
Pout<< "input path: " << args["relative"] << nl
<< "relative : " << args.relativePath(args["relative"], true) << nl
<< nl;
}
Info<< "have: "
<< args.count({"label", "scalar"}) << " options" << nl;
label ival; label ival;
scalar sval; scalar sval;

View File

@ -27,7 +27,7 @@ Description
#include "argList.H" #include "argList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "TimePaths.H" #include "Time.H"
#include "timeSelector.H" #include "timeSelector.H"
using namespace Foam; using namespace Foam;
@ -58,13 +58,31 @@ bool print(const instantList& instants)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::addNote("Test timeSelector"); argList::addNote("Test timeSelector and TimePaths");
timeSelector::addOptions(true, true); timeSelector::addOptions(true, true);
argList::noLibs(); argList::noLibs();
argList::noFunctionObjects(); argList::noFunctionObjects();
argList::addOption("relative", "PATH", "Test relativePath");
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H"
Pout<< "Time" << nl
<< "rootPath: " << runTime.rootPath() << nl
<< "path: " << runTime.path() << nl
<< "globalCase: " << runTime.globalCaseName() << nl
<< "globalPath: " << runTime.globalPath() << nl
<< nl;
if (args.found("relative"))
{
Pout<< "input path: " << args["relative"] << nl
<< "relative : " << runTime.relativePath(args["relative"], true)
<< nl
<< nl;
}
autoPtr<TimePaths> timePaths; autoPtr<TimePaths> timePaths;

View File

@ -82,7 +82,8 @@ int main(int argc, char *argv[])
"Collapse faces that are in the supplied face set" "Collapse faces that are in the supplied face set"
); );
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative collapseDict");
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
argList::noFunctionObjects(); // Never use function objects argList::noFunctionObjects(); // Never use function objects

View File

@ -342,7 +342,7 @@ int main(int argc, char *argv[])
"For example, moving points, splitting/collapsing edges etc." "For example, moving points, splitting/collapsing edges etc."
); );
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative modifyMeshDict");
argList::noFunctionObjects(); // Never use function objects argList::noFunctionObjects(); // Never use function objects

View File

@ -1469,7 +1469,12 @@ int main(int argc, char *argv[])
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addDictOption.H"
argList::addOption
(
"dict", "file", "Use alternative extrudeToRegionMeshDict"
);
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "createNamedMesh.H" #include "createNamedMesh.H"

View File

@ -684,6 +684,7 @@ int main(int argc, char *argv[])
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addProfilingOption.H"
argList::addBoolOption argList::addBoolOption
( (
"checkGeometry", "checkGeometry",
@ -707,8 +708,7 @@ int main(int argc, char *argv[])
"file", "file",
"Name of the file to save the simplified surface to" "Name of the file to save the simplified surface to"
); );
#include "addProfilingOption.H" argList::addOption("dict", "file", "Use alternative snappyHexMeshDict");
#include "addDictOption.H"
argList::noFunctionObjects(); // Never use function objects argList::noFunctionObjects(); // Never use function objects

View File

@ -441,9 +441,8 @@ int main(int argc, char *argv[])
"Does not duplicate points." "Does not duplicate points."
); );
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative createBafflesDict");
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addDictOption.H"
#include "addRegionOption.H" #include "addRegionOption.H"
argList::noFunctionObjects(); // Never use function objects argList::noFunctionObjects(); // Never use function objects

View File

@ -518,7 +518,7 @@ int main(int argc, char *argv[])
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative createPatchDict");
argList::addBoolOption argList::addBoolOption
( (
"writeObj", "writeObj",

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-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,24 +31,37 @@ License
Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io) Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
: :
fvMesh(io), mirrorFvMesh
mirrorMeshDict_
( (
IOobject io,
IOdictionary
( (
"mirrorMeshDict", IOobject
time().system(), (
*this, "mirrorMeshDict",
IOobject::MUST_READ_IF_MODIFIED, io.time().system(),
IOobject::NO_WRITE io.time(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
) )
) )
{}
Foam::mirrorFvMesh::mirrorFvMesh
(
const IOobject& io,
const IOdictionary& mirrorDict
)
:
fvMesh(io)
{ {
plane mirrorPlane(mirrorMeshDict_); plane mirrorPlane(mirrorDict);
const scalar planeTolerance const scalar planeTolerance
( (
mirrorMeshDict_.get<scalar>("planeTolerance") mirrorDict.get<scalar>("planeTolerance")
); );
const pointField& oldPoints = points(); const pointField& oldPoints = points();
@ -57,6 +70,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
const label nOldInternalFaces = nInternalFaces(); const label nOldInternalFaces = nInternalFaces();
const polyPatchList& oldPatches = boundaryMesh(); const polyPatchList& oldPatches = boundaryMesh();
Info<< "Mirroring mesh at origin:" << mirrorPlane.origin()
<< " normal:" << mirrorPlane.normal() << nl;
// Mirror the points // Mirror the points
Info<< "Mirroring points. Old points: " << oldPoints.size(); Info<< "Mirroring points. Old points: " << oldPoints.size();
@ -66,15 +82,15 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
labelList mirrorPointLookup(oldPoints.size(), -1); labelList mirrorPointLookup(oldPoints.size(), -1);
// Grab the old points // Grab the old points
forAll(oldPoints, pointi) for (const point& pt : oldPoints)
{ {
newPoints[nNewPoints] = oldPoints[pointi]; newPoints[nNewPoints] = pt;
nNewPoints++; ++nNewPoints;
} }
forAll(oldPoints, pointi) forAll(oldPoints, pointi)
{ {
scalar alpha = const scalar alpha =
mirrorPlane.normalIntersect mirrorPlane.normalIntersect
( (
oldPoints[pointi], oldPoints[pointi],
@ -121,7 +137,6 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
} }
Info<< "Mirroring faces. Old faces: " << oldFaces.size(); Info<< "Mirroring faces. Old faces: " << oldFaces.size();
// Algorithm: // Algorithm:
@ -325,7 +340,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
Info<< "Mirroring patches. Old patches: " << boundary().size() Info<< "Mirroring patches. Old patches: " << boundary().size()
<< " New patches: " << boundary().size() << endl; << " New patches: " << boundary().size() << endl;
Info<< "Mirroring cells. Old cells: " << oldCells.size() Info<< "Mirroring cells. Old cells: " << oldCells.size()
<< " New cells: " << 2*oldCells.size() << endl; << " New cells: " << 2*oldCells.size() << endl;
cellList newCells(2*oldCells.size()); cellList newCells(2*oldCells.size());

View File

@ -51,9 +51,6 @@ class mirrorFvMesh
{ {
// Private data // Private data
//- Mirror dictionary
IOdictionary mirrorMeshDict_;
//- Mirrored mesh //- Mirrored mesh
autoPtr<fvMesh> mirrorMeshPtr_; autoPtr<fvMesh> mirrorMeshPtr_;
@ -77,8 +74,11 @@ public:
// Constructors // Constructors
//- Construct from IOobject //- Construct from IOobject, using system mirrorMeshDict
mirrorFvMesh(const IOobject& io); explicit mirrorFvMesh(const IOobject& io);
//- Construct from IOobject and specified mirrorMeshDict
mirrorFvMesh(const IOobject& io, const IOdictionary& mirrorDict);
//- Destructor //- Destructor

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-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -49,12 +49,23 @@ int main(int argc, char *argv[])
"Mirrors a mesh around a given plane." "Mirrors a mesh around a given plane."
); );
argList::addOption("dict", "file", "Use alternative mirrorMeshDict");
argList::setAdvanced("decomposeParDict");
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const bool overwrite = args.found("overwrite"); const bool overwrite = args.found("overwrite");
const word dictName("mirrorMeshDict");
#include "setSystemRunTimeDictionaryIO.H"
Info<< "Reading " << dictName << "\n" << endl;
const IOdictionary mirrorDict(dictIO);
mirrorFvMesh mesh mirrorFvMesh mesh
( (
IOobject IOobject
@ -62,7 +73,8 @@ int main(int argc, char *argv[])
mirrorFvMesh::defaultRegion, mirrorFvMesh::defaultRegion,
runTime.constant(), runTime.constant(),
runTime runTime
) ),
mirrorDict
); );
hexRef8Data refData hexRef8Data refData

View File

@ -162,7 +162,8 @@ int main(int argc, char *argv[])
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addDictOption.H"
argList::addOption("dict", "file", "Use alternative refineMeshDict");
argList::addBoolOption argList::addBoolOption
( (

View File

@ -617,7 +617,8 @@ int main(int argc, char *argv[])
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addTimeOptions.H" #include "addTimeOptions.H"
#include "addDictOption.H"
argList::addOption("dict", "file", "Use alternative renumberMeshDict");
argList::addBoolOption argList::addBoolOption
( (

View File

@ -115,7 +115,8 @@ int main(int argc, char *argv[])
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addDictOption.H"
argList::addOption("dict", "file", "Use alternative stitchMeshDict");
argList::addBoolOption argList::addBoolOption
( (

View File

@ -207,7 +207,9 @@ int main(int argc, char *argv[])
); );
timeSelector::addOptions(true, false); // constant(true), zero(false) timeSelector::addOptions(true, false); // constant(true), zero(false)
#include "addDictOption.H"
argList::addOption("dict", "file", "Use alternative topoSetDict");
#include "addRegionOption.H" #include "addRegionOption.H"
argList::addBoolOption argList::addBoolOption
( (

View File

@ -94,7 +94,7 @@ if (doLagrangian)
); );
Info<< " Lagrangian: " Info<< " Lagrangian: "
<< writer.output().relative(runTime.globalPath()) << nl; << runTime.relativePath(writer.output()) << nl;
writer.writeTimeValue(mesh.time().value()); writer.writeTimeValue(mesh.time().value());
writer.writeGeometry(); writer.writeGeometry();

View File

@ -107,7 +107,7 @@ Description
); );
Info<< " Surface : " Info<< " Surface : "
<< writer.output().relative(runTime.globalPath()) << nl; << runTime.relativePath(writer.output()) << nl;
writer.writeTimeValue(timeValue); writer.writeTimeValue(timeValue);
@ -211,7 +211,7 @@ Description
); );
Info<< " FaceZone : " Info<< " FaceZone : "
<< writer.output().relative(runTime.globalPath()) << nl; << runTime.relativePath(writer.output()) << nl;
writer.beginFile(fz.name()); writer.beginFile(fz.name());

View File

@ -42,7 +42,7 @@ if (faceSetName.size())
); );
Info<< " faceSet : " Info<< " faceSet : "
<< outputName.relative(runTime.globalPath()) << nl; << runTime.relativePath(outputName) << nl;
vtk::writeFaceSet vtk::writeFaceSet
( (
@ -70,7 +70,7 @@ if (pointSetName.size())
); );
Info<< " pointSet : " Info<< " pointSet : "
<< outputName.relative(runTime.globalPath()) << nl; << runTime.relativePath(outputName) << nl;
vtk::writePointSet vtk::writePointSet
( (

View File

@ -113,7 +113,7 @@ Description
); );
Info<< " Internal : " Info<< " Internal : "
<< internalWriter->output().relative(runTime.globalPath()) << nl; << runTime.relativePath(internalWriter->output()) << nl;
internalWriter->writeTimeValue(mesh.time().value()); internalWriter->writeTimeValue(mesh.time().value());
internalWriter->writeGeometry(); internalWriter->writeGeometry();
@ -163,7 +163,7 @@ Description
); );
Info<< " Boundaries: " Info<< " Boundaries: "
<< writer->output().relative(runTime.globalPath()) << nl; << runTime.relativePath(writer->output()) << nl;
writer->writeTimeValue(timeValue); writer->writeTimeValue(timeValue);
writer->writeGeometry(); writer->writeGeometry();
@ -229,7 +229,7 @@ Description
); );
Info<< " Boundary : " Info<< " Boundary : "
<< writer->output().relative(runTime.globalPath()) << nl; << runTime.relativePath(writer->output()) << nl;
writer->writeTimeValue(timeValue); writer->writeTimeValue(timeValue);
writer->writeGeometry(); writer->writeGeometry();

View File

@ -650,7 +650,7 @@ int main(int argc, char *argv[])
if (args.found("overwrite") && isDir(regionDir)) if (args.found("overwrite") && isDir(regionDir))
{ {
Info<< "Removing old directory " Info<< "Removing old directory "
<< regionDir.relative(runTime.globalPath()) << runTime.relativePath(regionDir)
<< nl << endl; << nl << endl;
rmDir(regionDir); rmDir(regionDir);
} }

View File

@ -109,7 +109,8 @@ int main(int argc, char *argv[])
argList::noCheckProcessorDirectories(); argList::noCheckProcessorDirectories();
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative noiseDict");
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"

View File

@ -396,7 +396,8 @@ int main(int argc, char *argv[])
" (such as the patch type for fields and polyMesh/boundary files)." " (such as the patch type for fields and polyMesh/boundary files)."
); );
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative changeDictionaryDict");
argList::addOption argList::addOption
( (
"subDict", "subDict",

View File

@ -81,7 +81,7 @@ int main(int argc, char *argv[])
( (
"commsDir", "commsDir",
"dir", "dir",
"Specify alternate communications directory (default is 'comms')" "Specify communications directory (default is 'comms')"
); );
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"

View File

@ -59,8 +59,9 @@ int main(int argc, char *argv[])
" algorithm. Writes a map of fine to coarse grid." " algorithm. Writes a map of fine to coarse grid."
); );
argList::addOption("dict", "file", "Use alternative viewFactorsDict");
#include "addRegionOption.H" #include "addRegionOption.H"
#include "addDictOption.H"
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "createNamedMesh.H" #include "createNamedMesh.H"

View File

@ -401,7 +401,8 @@ int main(int argc, char *argv[])
"Set values on a selected set of cells/patch-faces via a dictionary" "Set values on a selected set of cells/patch-faces via a dictionary"
); );
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative setFieldsDict");
#include "addRegionOption.H" #include "addRegionOption.H"
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"

View File

@ -693,8 +693,7 @@ int main(int argc, char *argv[])
vtkWriter->writeGeometry(); vtkWriter->writeGeometry();
Info<< "Writing VTK to " Info<< "Writing VTK to "
<< ((vtkOutputDir/outputName).ext(vtkWriter->ext())) << runTime.relativePath(vtkWriter->output()) << nl;
.relative(runTime.globalPath()) << nl;
} }
} }
else else

View File

@ -274,8 +274,7 @@ int main(int argc, char *argv[])
); );
argList::noParallel(); argList::noParallel();
argList::addArgument("hookTolerance", "The point merge tolerance"); argList::addArgument("hookTolerance", "The point merge tolerance");
argList::addOption("dict", "file", "Use alternative surfaceHookUpDict");
#include "addDictOption.H"
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"

View File

@ -100,7 +100,8 @@ int main(int argc, char *argv[])
"factor", "factor",
"Geometry scaling factor on output" "Geometry scaling factor on output"
); );
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative coordinateSystems");
argList::addOption argList::addOption
( (
"from", "from",

View File

@ -107,7 +107,8 @@ int main(int argc, char *argv[])
"factor", "factor",
"Geometry scaling factor on output - default is 1" "Geometry scaling factor on output - default is 1"
); );
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative coordinateSystems");
argList::addOption argList::addOption
( (
"from", "from",

View File

@ -49,7 +49,7 @@ Usage
Specify a scaling factor when writing files. Specify a scaling factor when writing files.
- \par -dict \<dictionary\> - \par -dict \<dictionary\>
Specify an alternative dictionary for constant/coordinateSystems. Use alternative dictionary for constant/coordinateSystems.
- \par -from \<coordinateSystem\> - \par -from \<coordinateSystem\>
Specify a coordinate system when reading files. Specify a coordinate system when reading files.
@ -107,7 +107,8 @@ int main(int argc, char *argv[])
"factor", "factor",
"Geometry scaling factor on output - default is 1" "Geometry scaling factor on output - default is 1"
); );
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative coordinateSystems");
argList::addOption argList::addOption
( (
"from", "from",

View File

@ -28,16 +28,15 @@ Group
grpSurfaceUtilities grpSurfaceUtilities
Description Description
Extracts surface from a polyMesh. Depending on output surface format Extract patch or faceZone surfaces from a polyMesh.
triangulates faces. Depending on output surface format triangulates faces.
Region numbers on faces cannot be guaranteed to be the same as the patch Region numbers on faces no guaranteed to be the same as the patch indices.
indices.
Optionally only triangulates named patches. Optionally only extracts named patches.
If run in parallel the processor patches get filtered out by default and If run in parallel, processor patches get filtered out by default and
the mesh gets merged (based on topology). the mesh is merged (based on topology).
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -62,7 +61,9 @@ int main(int argc, char *argv[])
{ {
argList::addNote argList::addNote
( (
"Extract surface from a polyMesh" "Extract patch or faceZone surfaces from a polyMesh."
" The name is historical, it only triangulates faces"
" when the output format requires it."
); );
timeSelector::addOptions(); timeSelector::addOptions();
@ -77,14 +78,16 @@ int main(int argc, char *argv[])
argList::addOption argList::addOption
( (
"patches", "patches",
"(patch0 .. patchN)", "wordRes"
"Only triangulate selected patches (wildcards supported)" "Specify single patch or multiple patches to extract.\n"
"Eg, 'top' or '( front \".*back\" )'"
); );
argList::addOption argList::addOption
( (
"faceZones", "faceZones",
"(fz0 .. fzN)", "wordRes",
"Triangulate selected faceZones (wildcards supported)" "Specify single or multiple faceZones to extract\n"
"Eg, 'cells' or '( slice \"mfp-.*\" )'"
); );
#include "setRootCase.H" #include "setRootCase.H"
@ -99,8 +102,7 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
Info<< "Extracting surface from boundaryMesh ..." Info<< "Extracting surface from boundaryMesh ..." << nl << nl;
<< endl << endl;
const bool includeProcPatches = const bool includeProcPatches =
!( !(
@ -134,7 +136,6 @@ int main(int argc, char *argv[])
if (timeDirs.size() == 1) if (timeDirs.size() == 1)
{ {
outFileName = userOutFileName; outFileName = userOutFileName;
Info<< nl;
} }
else else
{ {
@ -144,15 +145,11 @@ int main(int argc, char *argv[])
Info<<" ... no mesh change." << nl; Info<<" ... no mesh change." << nl;
continue; continue;
} }
else
{
Info<< nl;
}
// The filename based on the original, but with additional // The filename based on the original, but with additional
// time information. The extension was previously checked that // time information. The extension was previously checked that
// it exists // it exists
std::string::size_type dot = userOutFileName.rfind('.'); const auto dot = userOutFileName.rfind('.');
outFileName = outFileName =
userOutFileName.substr(0, dot) + "_" userOutFileName.substr(0, dot) + "_"
@ -160,6 +157,8 @@ int main(int argc, char *argv[])
+ userOutFileName.ext(); + userOutFileName.ext();
} }
Info<< nl;
// Create local surface from: // Create local surface from:
// - explicitly named patches only (-patches (at your option) // - explicitly named patches only (-patches (at your option)
// - all patches (default in sequential mode) // - all patches (default in sequential mode)
@ -170,37 +169,39 @@ int main(int argc, char *argv[])
// Construct table of patches to include. // Construct table of patches to include.
const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
labelHashSet includePatches(bMesh.size()); labelList includePatches;
if (args.found("patches")) if (args.found("patches"))
{ {
includePatches = bMesh.patchSet(args.getList<wordRe>("patches")); includePatches =
bMesh.patchSet(args.getList<wordRe>("patches")).sortedToc();
}
else if (includeProcPatches)
{
includePatches = identity(bMesh.size());
} }
else else
{ {
forAll(bMesh, patchi) includePatches = identity(bMesh.nNonProcessor());
{
const polyPatch& patch = bMesh[patchi];
if (includeProcPatches || !isA<processorPolyPatch>(patch))
{
includePatches.insert(patchi);
}
}
} }
labelList includeFaceZones;
const faceZoneMesh& fzm = mesh.faceZones(); const faceZoneMesh& fzm = mesh.faceZones();
labelHashSet includeFaceZones(fzm.size());
if (args.found("faceZones")) if (args.found("faceZones"))
{ {
wordReList zoneNames(args.getList<wordRe>("faceZones"));
const wordList allZoneNames(fzm.names()); const wordList allZoneNames(fzm.names());
const wordRes zoneNames(args.getList<wordRe>("faceZones"));
labelHashSet hashed(2*fzm.size());
for (const wordRe& zoneName : zoneNames) for (const wordRe& zoneName : zoneNames)
{ {
labelList zoneIDs = findStrings(zoneName, allZoneNames); labelList zoneIDs = findStrings(zoneName, allZoneNames);
includeFaceZones.insert(zoneIDs); hashed.insert(zoneIDs);
if (zoneIDs.empty()) if (zoneIDs.empty())
{ {
@ -209,17 +210,15 @@ int main(int argc, char *argv[])
<< zoneName << endl; << zoneName << endl;
} }
} }
Info<< "Additionally triangulating faceZones "
<< UIndirectList<word> includeFaceZones = hashed.sortedToc();
(
allZoneNames, Info<< "Additionally extracting faceZones "
includeFaceZones.sortedToc() << UIndirectList<word>(allZoneNames, includeFaceZones)
)
<< endl; << endl;
} }
// From (name of) patch to compact 'zone' index // From (name of) patch to compact 'zone' index
HashTable<label> compactZoneID(1024); HashTable<label> compactZoneID(1024);
// Mesh face and compact zone indx // Mesh face and compact zone indx
@ -252,18 +251,14 @@ int main(int argc, char *argv[])
// Allocate compact numbering for all patches/faceZones // Allocate compact numbering for all patches/faceZones
forAllConstIter(HashTable<label>, patchSize, iter) forAllConstIters(patchSize, iter)
{ {
label sz = compactZoneID.size(); compactZoneID.insert(iter.key(), compactZoneID.size());
compactZoneID.insert(iter.key(), sz);
} }
forAllConstIter(HashTable<label>, zoneSize, iter) forAllConstIters(zoneSize, iter)
{ {
label sz = compactZoneID.size(); compactZoneID.insert(iter.key(), compactZoneID.size());
//Info<< "For faceZone " << iter.key() << " allocating zoneID "
// << sz << endl;
compactZoneID.insert(iter.key(), sz);
} }
@ -273,7 +268,7 @@ int main(int argc, char *argv[])
// Rework HashTable into labelList just for speed of conversion // Rework HashTable into labelList just for speed of conversion
labelList patchToCompactZone(bMesh.size(), -1); labelList patchToCompactZone(bMesh.size(), -1);
labelList faceZoneToCompactZone(bMesh.size(), -1); labelList faceZoneToCompactZone(bMesh.size(), -1);
forAllConstIter(HashTable<label>, compactZoneID, iter) forAllConstIters(compactZoneID, iter)
{ {
label patchi = bMesh.findPatchID(iter.key()); label patchi = bMesh.findPatchID(iter.key());
if (patchi != -1) if (patchi != -1)
@ -348,10 +343,10 @@ int main(int argc, char *argv[])
forAll(gatheredFaces[Pstream::myProcNo()], i) forAll(gatheredFaces[Pstream::myProcNo()], i)
{ {
inplaceRenumber inplaceRenumber
( (
pointToGlobal, pointToGlobal,
gatheredFaces[Pstream::myProcNo()][i] gatheredFaces[Pstream::myProcNo()][i]
); );
} }
Pstream::gatherList(gatheredFaces); Pstream::gatherList(gatheredFaces);

View File

@ -57,7 +57,7 @@ int main(int argc, char *argv[])
"Add patches (regions) to a surface with a user-selectable method" "Add patches (regions) to a surface with a user-selectable method"
); );
argList::noParallel(); argList::noParallel();
#include "addDictOption.H" argList::addOption("dict", "file", "Use alternative surfacePatchDict");
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"

View File

@ -25,6 +25,9 @@
# For USERMPI, the user is responsible for supplying an appropriate # For USERMPI, the user is responsible for supplying an appropriate
# wmake/rules/General/mplibUSERMPI file and managing all settings # wmake/rules/General/mplibUSERMPI file and managing all settings
# #
# For INTELMPI, note that the (I_MPI_CC, I_MPI_CCX) environment variables
# define the underlying compiler to be used
#
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unsetenv MPI_ARCH_PATH MPI_HOME unsetenv MPI_ARCH_PATH MPI_HOME
setenv FOAM_MPI dummy # Fallback value setenv FOAM_MPI dummy # Fallback value

View File

@ -138,7 +138,7 @@ _of_complete_cache_[mergeOrSplitBaffles]="-case -decomposeParDict -dict -fileHan
_of_complete_cache_[mergeSurfacePatches]="-case -fileHandler -output -patchIdRange -patchIds -patchNames | -keep -noFunctionObjects -doc -doc-source -help" _of_complete_cache_[mergeSurfacePatches]="-case -fileHandler -output -patchIdRange -patchIds -patchNames | -keep -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[meshToFPMA]="-case -decomposeParDict -fileHandler | -noFunctionObjects -parallel -doc -doc-source -help" _of_complete_cache_[meshToFPMA]="-case -decomposeParDict -fileHandler | -noFunctionObjects -parallel -doc -doc-source -help"
_of_complete_cache_[mhdFoam]="-case -decomposeParDict -fileHandler | -dry-run -dry-run-write -listFunctionObjects -listRegisteredSwitches -listScalarBCs -listSwitches -listUnsetSwitches -listVectorBCs -noFunctionObjects -parallel -postProcess -doc -doc-source -help" _of_complete_cache_[mhdFoam]="-case -decomposeParDict -fileHandler | -dry-run -dry-run-write -listFunctionObjects -listRegisteredSwitches -listScalarBCs -listSwitches -listUnsetSwitches -listVectorBCs -noFunctionObjects -parallel -postProcess -doc -doc-source -help"
_of_complete_cache_[mirrorMesh]="-case -decomposeParDict -fileHandler | -noFunctionObjects -overwrite -parallel -doc -doc-source -help" _of_complete_cache_[mirrorMesh]="-case -dict -decomposeParDict -fileHandler | -noFunctionObjects -overwrite -parallel -doc -doc-source -help"
_of_complete_cache_[mixtureAdiabaticFlameT]="-case -fileHandler | -doc -doc-source -help" _of_complete_cache_[mixtureAdiabaticFlameT]="-case -fileHandler | -doc -doc-source -help"
_of_complete_cache_[modifyMesh]="-case -decomposeParDict -dict -fileHandler | -overwrite -parallel -doc -doc-source -help" _of_complete_cache_[modifyMesh]="-case -decomposeParDict -dict -fileHandler | -overwrite -parallel -doc -doc-source -help"
_of_complete_cache_[moveDynamicMesh]="-case -decomposeParDict -fileHandler -region | -checkAMI -noFunctionObjects -parallel -doc -doc-source -help" _of_complete_cache_[moveDynamicMesh]="-case -decomposeParDict -fileHandler -region | -checkAMI -noFunctionObjects -parallel -doc -doc-source -help"

View File

@ -25,6 +25,9 @@
# For USERMPI, the user is responsible for supplying an appropriate # For USERMPI, the user is responsible for supplying an appropriate
# wmake/rules/General/mplibUSERMPI file and managing all settings # wmake/rules/General/mplibUSERMPI file and managing all settings
# #
# For INTELMPI, note that the (I_MPI_CC, I_MPI_CCX) environment variables
# define the underlying compiler to be used
#
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unset MPI_ARCH_PATH MPI_HOME unset MPI_ARCH_PATH MPI_HOME
export FOAM_MPI=dummy # Fallback value export FOAM_MPI=dummy # Fallback value

View File

@ -35,11 +35,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<IOobject>& ip)
os << "IOobject: " os << "IOobject: "
<< io.type() << token::SPACE << io.type() << token::SPACE
<< io.name() << token::SPACE << io.name()
<< "readOpt:" << token::SPACE << io.readOpt() << token::SPACE << " local: " << io.local()
<< "writeOpt:" << token::SPACE << io.writeOpt() << token::SPACE << " readOpt: " << io.readOpt()
<< "globalObject:" << token::SPACE << io.globalObject() << token::SPACE << " writeOpt: " << io.writeOpt()
<< io.path() << endl; << " globalObject: " << io.globalObject()
<< token::SPACE << io.path() << endl;
return os; return os;
} }

View File

@ -133,28 +133,6 @@ Foam::TimePaths::TimePaths
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::TimePaths::caseSystem() const
{
if (processorCase_)
{
return ".."/system();
}
return system();
}
Foam::fileName Foam::TimePaths::caseConstant() const
{
if (processorCase_)
{
return ".."/constant();
}
return constant();
}
Foam::instantList Foam::TimePaths::findTimes Foam::instantList Foam::TimePaths::findTimes
( (
const fileName& directory, const fileName& directory,

View File

@ -108,86 +108,64 @@ public:
// Member Functions // Member Functions
//- True if case running with parallel distributed directories
//- (ie. not NFS mounted)
inline bool distributed() const;
//- Return true if this is a processor case //- Return true if this is a processor case
bool processorCase() const inline bool processorCase() const;
{
return processorCase_;
}
//- Return root path //- Return root path
const fileName& rootPath() const inline const fileName& rootPath() const;
{
return rootPath_;
}
//- Return global case name //- Return global case name
const fileName& globalCaseName() const inline const fileName& globalCaseName() const;
{
return globalCaseName_;
}
//- Return case name //- Return case name
const fileName& caseName() const inline const fileName& caseName() const;
{
return case_;
}
//- Return case name //- The case name for modification (use with caution)
fileName& caseName() inline fileName& caseName();
{
return case_;
}
//- Return system name //- Return path for the case
const word& system() const inline fileName path() const;
{
return system_; //- Return global path for the case
} inline fileName globalPath() const;
//- Return the input relative to the globalPath by stripping off
//- a leading value of the globalPath
//
// \param input the directory or filename to make case-relative
// \param caseTag replace globalPath with \<case\> for later
// use with expand(), or prefix \<case\> if the file name was
// not an absolute location
inline fileName relativePath
(
const fileName& input,
const bool caseTag = false
) const;
//- Return the system name for the case, which is
//- \c ../system() for parallel runs.
fileName caseSystem() const;
//- Return constant name //- Return constant name
const word& constant() const inline const word& constant() const;
{
return constant_;
}
//- Is case running with parallel distributed directories //- Return system name
// (i.e. not NFS mounted) inline const word& system() const;
bool distributed() const
{
return distributed_;
}
//- Return the constant name for the case, which is //- Return the constant name for the case, which is
//- \c ../constant() for parallel runs. //- \c ../constant() for parallel runs.
fileName caseConstant() const; inline fileName caseConstant() const;
//- Return path for the case //- Return the system name for the case, which is
fileName path() const //- \c ../system() for parallel runs.
{ inline fileName caseSystem() const;
return rootPath()/caseName();
}
//- Return global path for the case
fileName globalPath() const
{
return rootPath()/globalCaseName();
}
//- Return system path
fileName systemPath() const
{
return path()/system();
}
//- Return constant path //- Return constant path
fileName constantPath() const inline fileName constantPath() const;
{
return path()/constant(); //- Return system path
} inline fileName systemPath() const;
// Searching // Searching
@ -223,6 +201,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "TimePathsI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,132 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::TimePaths::distributed() const
{
return distributed_;
}
inline bool Foam::TimePaths::processorCase() const
{
return processorCase_;
}
inline const Foam::fileName& Foam::TimePaths::rootPath() const
{
return rootPath_;
}
inline const Foam::fileName& Foam::TimePaths::globalCaseName() const
{
return globalCaseName_;
}
inline const Foam::fileName& Foam::TimePaths::caseName() const
{
return case_;
}
inline Foam::fileName& Foam::TimePaths::caseName()
{
return case_;
}
inline Foam::fileName Foam::TimePaths::path() const
{
return rootPath()/caseName();
}
inline Foam::fileName Foam::TimePaths::globalPath() const
{
return rootPath()/globalCaseName();
}
inline Foam::fileName Foam::TimePaths::relativePath
(
const fileName& input,
const bool caseTag
) const
{
return input.relative(globalPath(), caseTag);
}
inline const Foam::word& Foam::TimePaths::constant() const
{
return constant_;
}
inline const Foam::word& Foam::TimePaths::system() const
{
return system_;
}
inline Foam::fileName Foam::TimePaths::caseConstant() const
{
if (processorCase_)
{
return ".."/constant();
}
return constant();
}
inline Foam::fileName Foam::TimePaths::caseSystem() const
{
if (processorCase_)
{
return ".."/system();
}
return system();
}
inline Foam::fileName Foam::TimePaths::constantPath() const
{
return path()/constant();
}
inline Foam::fileName Foam::TimePaths::systemPath() const
{
return path()/system();
}
// ************************************************************************* //

View File

@ -25,7 +25,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::TimeState::timeOutputValue() const inline Foam::scalar Foam::TimeState::timeOutputValue() const
{ {
return timeToUserTime(value()); return timeToUserTime(value());

View File

@ -142,7 +142,7 @@ void Foam::timeSelector::addOptions
( (
"time", "time",
"ranges", "ranges",
"Comma-separated time ranges - eg, ':10,20,40:70,1000:'" "List of ranges. Eg, ':10,20 40:70 1000:', 'none', etc"
); );
} }

View File

@ -25,6 +25,7 @@ License
#include "dynamicCode.H" #include "dynamicCode.H"
#include "dynamicCodeContext.H" #include "dynamicCodeContext.H"
#include "argList.H"
#include "stringOps.H" #include "stringOps.H"
#include "Fstream.H" #include "Fstream.H"
#include "IOstreams.H" #include "IOstreams.H"
@ -64,10 +65,10 @@ void Foam::dynamicCode::checkSecurity
if (isAdministrator()) if (isAdministrator())
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "This code should not be executed by someone with administrator" << "This code should not be executed by someone"
<< " rights due to security reasons." << nl << " with administrator rights for security reasons." << nl
<< "(it writes a shared library which then gets loaded " << "It generates a shared library which is loaded using dlopen"
<< "using dlopen)" << nl << endl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -292,8 +293,8 @@ bool Foam::dynamicCode::writeDigest(const std::string& sha1) const
Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName) Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName)
: :
codeRoot_(stringOps::expand("<case>")/topDirName), codeRoot_(argList::envGlobalPath()/topDirName),
libSubDir_(stringOps::expand("platforms/$WM_OPTIONS/lib")), libSubDir_(stringOps::expand("platforms/${WM_OPTIONS}/lib")),
codeName_(codeName), codeName_(codeName),
codeDirName_(codeDirName) codeDirName_(codeDirName)
{ {

View File

@ -40,6 +40,7 @@ bool Foam::functionObject::postProcess(false);
Foam::word Foam::functionObject::outputPrefix("postProcessing"); Foam::word Foam::functionObject::outputPrefix("postProcessing");
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::word Foam::functionObject::scopedName(const word& name) const Foam::word Foam::functionObject::scopedName(const word& name) const
@ -68,10 +69,9 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
{ {
const word functionType(dict.get<word>("type")); const word functionType(dict.get<word>("type"));
if (debug) DebugInfo
{ << "Selecting function " << functionType << endl;
Info<< "Selecting function " << functionType << endl;
}
// Load any additional libraries // Load any additional libraries
{ {
@ -122,12 +122,6 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObject::~functionObject()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::functionObject::name() const const Foam::word& Foam::functionObject::name() const
@ -179,4 +173,48 @@ void Foam::functionObject::movePoints(const polyMesh&)
{} {}
// * * * * * * * * * * * * unavailableFunctionObject * * * * * * * * * * * * //
Foam::functionObject::unavailableFunctionObject::unavailableFunctionObject
(
const word& name
)
:
functionObject(name)
{}
void Foam::functionObject::unavailableFunctionObject::carp
(
std::string message
) const
{
FatalError
<< "####" << nl
<< " " << type() << " not available" << nl
<< "####" << nl;
if (message.size())
{
FatalError
<< message.c_str() << nl;
}
FatalError
<< exit(FatalError);
}
bool Foam::functionObject::unavailableFunctionObject::execute()
{
return true;
}
bool Foam::functionObject::unavailableFunctionObject::write()
{
return true;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -127,7 +127,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes // Forward declarations
class Time; class Time;
class polyMesh; class polyMesh;
class mapPolyMesh; class mapPolyMesh;
@ -144,15 +144,6 @@ class functionObject
const word name_; const word name_;
// Private Member Functions
//- No copy construct
functionObject(const functionObject&) = delete;
//- No copy assignment
void operator=(const functionObject&) = delete;
protected: protected:
// Protected Member Functions // Protected Member Functions
@ -163,6 +154,9 @@ protected:
public: public:
// Forward declarations
class unavailableFunctionObject;
//- Runtime type information //- Runtime type information
virtual const word& type() const = 0; virtual const word& type() const = 0;
@ -209,13 +203,13 @@ public:
static autoPtr<functionObject> New static autoPtr<functionObject> New
( (
const word& name, const word& name,
const Time&, const Time& runTime,
const dictionary& const dictionary& dict
); );
//- Destructor //- Destructor
virtual ~functionObject(); virtual ~functionObject() = default;
// Member Functions // Member Functions
@ -243,7 +237,7 @@ public:
virtual bool write() = 0; virtual bool write() = 0;
//- Called when Time::run() determines that the time-loop exits. //- Called when Time::run() determines that the time-loop exits.
// By default it simply calls execute(). // The base implementation is a no-op.
virtual bool end(); virtual bool end();
//- Called at the end of Time::adjustDeltaT() if adjustTime is true //- Called at the end of Time::adjustDeltaT() if adjustTime is true
@ -262,6 +256,37 @@ public:
}; };
/*---------------------------------------------------------------------------*\
Class functionObject::unavailableFunctionObject Declaration
\*---------------------------------------------------------------------------*/
//- Abstract functionObject to report when a real version is unavailable.
class functionObject::unavailableFunctionObject
:
public functionObject
{
protected:
//- Construct with name
unavailableFunctionObject(const word& name);
//- Report it is unavailable, emitting a FatalError for try/catch
//- in the caller
void carp(std::string message = "") const;
public:
// Member Functions
//- No nothing
virtual bool execute();
//- No nothing
virtual bool write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -463,6 +463,14 @@ bool Foam::argList::postProcess(int argc, char *argv[])
} }
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::fileName Foam::argList::envGlobalPath()
{
return Foam::getEnv("FOAM_CASE");
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::word Foam::argList::optionCompat(const word& optName) Foam::word Foam::argList::optionCompat(const word& optName)

View File

@ -272,6 +272,18 @@ public:
// Member Functions // Member Functions
// Environment
//- Global case (directory) from environment variable
//
// Returns the contents of the \c FOAM_CASE variable,
// which has previously been set by argList or by Time.
//
// This will normally be identical to the value of globalPath(),
// but obtained via the environment.
static fileName envGlobalPath();
// Low-level // Low-level
//- Scan for -help, -doc options etc prior to checking the validity //- Scan for -help, -doc options etc prior to checking the validity
@ -304,6 +316,19 @@ public:
// \note This is guaranteed to be an absolute path // \note This is guaranteed to be an absolute path
inline fileName globalPath() const; inline fileName globalPath() const;
//- Return the input relative to the globalPath by stripping off
//- a leading value of the globalPath
//
// \param input the directory or filename to make case-relative
// \param caseTag replace globalPath with \<case\> for later
// use with expand(), or prefix \<case\> if the file name was
// not an absolute location
inline fileName relativePath
(
const fileName& input,
const bool caseTag = false
) const;
//- Return distributed flag //- Return distributed flag
//- (i.e. are rootPaths different on different machines) //- (i.e. are rootPaths different on different machines)
inline bool distributed() const; inline bool distributed() const;

View File

@ -87,6 +87,16 @@ inline Foam::fileName Foam::argList::globalPath() const
} }
inline Foam::fileName Foam::argList::relativePath
(
const fileName& input,
const bool caseTag
) const
{
return input.relative(globalPath(), caseTag);
}
inline bool Foam::argList::distributed() const inline bool Foam::argList::distributed() const
{ {
return parRunControl_.distributed(); return parRunControl_.distributed();

View File

@ -96,7 +96,7 @@ namespace Foam
//- OpenFOAM version (name or stringified number) as a std::string //- OpenFOAM version (name or stringified number) as a std::string
extern const std::string version; extern const std::string version;
//- Test if the patch string appeared to be in use, //- Test if the patch string appears to be in use,
//- which is when it is defined (non-zero). //- which is when it is defined (non-zero).
bool patched(); bool patched();

View File

@ -498,17 +498,8 @@ whichPoint
const label gp const label gp
) const ) const
{ {
Map<label>::const_iterator fnd = meshPointMap().find(gp); // The point found, or -1 if not found
return meshPointMap().lookup(gp, -1);
if (fnd != meshPointMap().end())
{
return fnd();
}
else
{
// Not found
return -1;
}
} }

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-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -152,8 +152,8 @@ private:
//- Labels of mesh points //- Labels of mesh points
mutable labelList* meshPointsPtr_; mutable labelList* meshPointsPtr_;
//- Mesh point map. Given the global point index find its //- Mesh point map. Given the global point index find its
//location in the patch //- location in the patch
mutable Map<label>* meshPointMapPtr_; mutable Map<label>* meshPointMapPtr_;
//- Outside edge loops //- Outside edge loops
@ -301,7 +301,7 @@ public:
} }
// Access functions for demand driven data // Access functions for demand-driven data
// Topological data; no mesh required. // Topological data; no mesh required.
@ -329,8 +329,7 @@ public:
return edgei < nInternalEdges(); return edgei < nInternalEdges();
} }
//- Return list of boundary points, //- Return list of boundary points, address into LOCAL point list
// address into LOCAL point list
const labelList& boundaryPoints() const; const labelList& boundaryPoints() const;
//- Return face-face addressing //- Return face-face addressing
@ -354,13 +353,13 @@ public:
// Addressing into mesh // Addressing into mesh
//- Return labelList of mesh points in patch. They are constructed //- Return labelList of mesh points in patch.
// walking through the faces in incremental order and not sorted // They are constructed by walking through the faces in
// anymore. // incremental order and not sorted anymore.
const labelList& meshPoints() const; const labelList& meshPoints() const;
//- Mesh point map. Given the global point index find its //- Mesh point map.
// location in the patch // Given the global point index find its location in the patch
const Map<label>& meshPointMap() const; const Map<label>& meshPointMap() const;
//- Return pointField of points in patch //- Return pointField of points in patch
@ -374,11 +373,11 @@ public:
label whichPoint(const label gp) const; label whichPoint(const label gp) const;
//- Given an edge in local point labels, return its //- Given an edge in local point labels, return its
// index in the edge list. If the edge is not found, return -1 //- index in the edge list. If the edge is not found, return -1
label whichEdge(const edge&) const; label whichEdge(const edge&) const;
//- Return labels of patch edges in the global edge list using //- Return labels of patch edges in the global edge list using
// cell addressing //- cell addressing
labelList meshEdges labelList meshEdges
( (
const edgeList& allEdges, const edgeList& allEdges,
@ -387,7 +386,7 @@ public:
) const; ) const;
//- Return labels of patch edges in the global edge list using //- Return labels of patch edges in the global edge list using
// basic edge addressing. //- basic edge addressing.
labelList meshEdges labelList meshEdges
( (
const edgeList& allEdges, const edgeList& allEdges,
@ -410,6 +409,14 @@ public:
const Field<PointType>& pointNormals() const; const Field<PointType>& pointNormals() const;
// Storage Management
inline bool hasFaceAreas() const { return faceAreasPtr_; }
inline bool hasFaceCentres() const { return faceCentresPtr_; }
inline bool hasFaceNormals() const { return faceNormalsPtr_; }
inline bool hasPointNormals() const { return pointNormalsPtr_; }
// Other patch operations // Other patch operations
//- Project vertices of patch onto another patch //- Project vertices of patch onto another patch
@ -475,7 +482,7 @@ public:
virtual void movePoints(const Field<PointType>&); virtual void movePoints(const Field<PointType>&);
// Member operators // Member Operators
//- Assignment //- Assignment
void operator= void operator=

View File

@ -60,8 +60,7 @@ calcAddressing() const
if (edgesPtr_ || faceFacesPtr_ || edgeFacesPtr_ || faceEdgesPtr_) if (edgesPtr_ || faceFacesPtr_ || edgeFacesPtr_ || faceEdgesPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "addressing already calculated" << "addressing already calculated"
<< abort(FatalError); << abort(FatalError);

View File

@ -46,10 +46,9 @@ calcBdryPoints() const
if (boundaryPointsPtr_) if (boundaryPointsPtr_)
{ {
// it is considered an error to attempt to recalculate // Error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "edge types already calculated" << "boundaryPoints already calculated"
<< abort(FatalError); << abort(FatalError);
} }

View File

@ -50,8 +50,7 @@ calcEdgeLoops() const
if (edgeLoopsPtr_) if (edgeLoopsPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "edge loops already calculated" << "edge loops already calculated"
<< abort(FatalError); << abort(FatalError);

View File

@ -56,8 +56,7 @@ calcLocalPointOrder() const
if (localPointOrderPtr_) if (localPointOrderPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "local point order already calculated" << "local point order already calculated"
<< abort(FatalError); << abort(FatalError);

View File

@ -47,10 +47,9 @@ calcMeshData() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate meshPoints
// if they have already been calculated.
if (meshPointsPtr_ || localFacesPtr_) if (meshPointsPtr_ || localFacesPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "meshPointsPtr_ or localFacesPtr_ already allocated" << "meshPointsPtr_ or localFacesPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
@ -157,10 +156,9 @@ calcMeshPointMap() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate meshPoints
// if they have already been calculated.
if (meshPointMapPtr_) if (meshPointMapPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "meshPointMapPtr_ already allocated" << "meshPointMapPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
@ -205,10 +203,9 @@ calcLocalPoints() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate localPoints
// if they have already been calculated.
if (localPointsPtr_) if (localPointsPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "localPointsPtr_ already allocated" << "localPointsPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
@ -254,10 +251,9 @@ calcPointNormals() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate pointNormals
// if they have already been calculated.
if (pointNormalsPtr_) if (pointNormalsPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "pointNormalsPtr_ already allocated" << "pointNormalsPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
@ -318,10 +314,9 @@ calcFaceCentres() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate faceCentres
// if they have already been calculated.
if (faceCentresPtr_) if (faceCentresPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "faceCentresPtr_ already allocated" << "faceCentresPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
@ -365,9 +360,9 @@ calcMagFaceAreas() const
<< endl; << endl;
} }
// It is an error to calculate these more than once.
if (magFaceAreasPtr_) if (magFaceAreasPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "magFaceAreasPtr_ already allocated" << "magFaceAreasPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
@ -410,10 +405,9 @@ calcFaceAreas() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate faceNormals
// if they have already been calculated.
if (faceAreasPtr_) if (faceAreasPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "faceAreasPtr_ already allocated" << "faceAreasPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);
@ -457,10 +451,9 @@ calcFaceNormals() const
<< endl; << endl;
} }
// It is considered an error to attempt to recalculate faceNormals
// if they have already been calculated.
if (faceNormalsPtr_) if (faceNormalsPtr_)
{ {
// An error to recalculate if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "faceNormalsPtr_ already allocated" << "faceNormalsPtr_ already allocated"
<< abort(FatalError); << abort(FatalError);

View File

@ -51,8 +51,7 @@ calcPointEdges() const
if (pointEdgesPtr_) if (pointEdgesPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "pointEdges already calculated" << "pointEdges already calculated"
<< abort(FatalError); << abort(FatalError);
@ -89,8 +88,7 @@ calcPointFaces() const
if (pointFacesPtr_) if (pointFacesPtr_)
{ {
// it is considered an error to attempt to recalculate // An error to recalculate if already allocated
// if already allocated
FatalErrorInFunction FatalErrorInFunction
<< "pointFaces already calculated" << "pointFaces already calculated"
<< abort(FatalError); << abort(FatalError);

View File

@ -32,6 +32,9 @@ Description
Note Note
This class is still subject to larger changes (2018-11) as it matures. This class is still subject to larger changes (2018-11) as it matures.
SeeAlso
Foam::scalarRange, Foam::scalarRanges
SourceFiles SourceFiles
scalarPredicates.C scalarPredicates.C
scalarPredicatesI.H scalarPredicatesI.H
@ -233,7 +236,10 @@ public:
using List<unary>::List; using List<unary>::List;
//- Construct from an initializer list of (opName opValue) tuples //- Construct from an initializer list of (opName opValue) tuples
explicit scalars(std::initializer_list<std::pair<word, scalar>> entries); explicit scalars
(
std::initializer_list<std::pair<word, scalar>> entries
);
//- Copy construct from a list of (opName opValue) tuples //- Copy construct from a list of (opName opValue) tuples
explicit scalars(const UList<Tuple2<word, scalar>>& entries); explicit scalars(const UList<Tuple2<word, scalar>>& entries);

View File

@ -37,6 +37,14 @@ bool Foam::scalarRange::parse(const std::string& str, scalarRange& range)
if (colon == std::string::npos) if (colon == std::string::npos)
{ {
// No colon
if (str == "none")
{
// "none" is an empty (inverse) range
return true;
}
// "VALUE" // "VALUE"
scalar val; scalar val;
if (readScalar(str, val)) if (readScalar(str, val))
@ -119,11 +127,11 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const scalarRange& range)
break; break;
case scalarRange::GE_LE: case scalarRange::GE_LE:
os << range.min_ << ":" << range.max_; os << range.min_ << ':' << range.max_;
break; break;
default: default:
os << "false"; os << "none";
break; break;
} }

View File

@ -30,6 +30,12 @@ Description
The bound can be specified as an "MIN:MAX" range, as a "MIN:" or ":MAX" The bound can be specified as an "MIN:MAX" range, as a "MIN:" or ":MAX"
bound or simply as a single "VALUE". bound or simply as a single "VALUE".
When defined via the parse() method, the special string "none" can be
used to define an empty (inverse) range.
SeeAlso
Foam::predicates::scalars
SourceFiles SourceFiles
scalarRange.C scalarRange.C
@ -103,6 +109,10 @@ public:
//- Construct by parsing string content. //- Construct by parsing string content.
// A colon (:) is used as a range marker or when specifying // A colon (:) is used as a range marker or when specifying
// greater-than or less-than bounds. // greater-than or less-than bounds.
//
// \note The special string "none" can be used define an empty
// (inverse) range
//
// \return True if no parse problems were encountered. // \return True if no parse problems were encountered.
static bool parse(const std::string& str, scalarRange& range); static bool parse(const std::string& str, scalarRange& range);
@ -150,10 +160,13 @@ public:
// For GE, LE bounds it is the min/max value, respectively. // For GE, LE bounds it is the min/max value, respectively.
inline scalar value() const; inline scalar value() const;
//- True if the value matches the condition.
inline bool match(const scalar& value) const;
// Member Operators // Member Operators
//- Unary predicate to test if the value is within the bounds //- Identical to match(), for use as a predicate.
inline bool operator()(const scalar& value) const; inline bool operator()(const scalar& value) const;
inline bool operator==(const scalarRange& rhs) const; inline bool operator==(const scalarRange& rhs) const;

View File

@ -152,23 +152,29 @@ inline Foam::scalar Foam::scalarRange::value() const
} }
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline bool Foam::scalarRange::match(const scalar& value) const
inline bool Foam::scalarRange::operator()(const scalar& value) const
{ {
switch (type_) switch (type_)
{ {
case EQ: return equal(value, min_); case EQ: return equal(value, min_);
case GE: return value >= min_; case GE: return (value >= min_);
case GT: return value > min_; case GT: return (value > min_);
case LE: return value <= max_; case LE: return (value <= max_);
case LT: return value < max_; case LT: return (value < max_);
case GE_LE: return value >= min_ && value <= max_; case GE_LE: return (value >= min_ && value <= max_);
default: return false; default: return false;
} }
} }
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::scalarRange::operator()(const scalar& value) const
{
return match(value);
}
inline bool Foam::scalarRange::operator==(const scalarRange& rhs) const inline bool Foam::scalarRange::operator==(const scalarRange& rhs) const
{ {
return (type_ == rhs.type_ && min_ == rhs.min_ && max_ == rhs.max_); return (type_ == rhs.type_ && min_ == rhs.min_ && max_ == rhs.max_);

View File

@ -26,33 +26,39 @@ License
#include "scalarRanges.H" #include "scalarRanges.H"
#include "stringOps.H" #include "stringOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::scalarRanges::scalarRanges(const std::string& str) Foam::scalarRanges Foam::scalarRanges::parse
: (
List<scalarRange>() const std::string& str,
bool verbose
)
{ {
const SubStrings<std::string> items = stringOps::splitAny(str, " ,;"); const SubStrings<std::string> items = stringOps::splitAny(str, " ,;");
setSize(items.size()); scalarRanges ranges(items.size());
label nItems = 0; label n = 0;
for (const auto& item : items) for (const auto& item : items)
{ {
const std::string s = item.str(); const std::string s = item.str();
if (scalarRange::parse(s, operator[](nItems))) scalarRange& range = ranges[n];
if (scalarRange::parse(s, range))
{ {
++nItems; ++n;
} }
else else if (verbose)
{ {
Info<< "Bad scalar-range while parsing: " << s << endl; Info<< "Bad scalar-range while parsing: " << s << endl;
} }
} }
setSize(nItems); ranges.resize(n);
return ranges;
} }

View File

@ -27,6 +27,9 @@ Class
Description Description
A collection of scalar bounds to be used as a unary predicate. A collection of scalar bounds to be used as a unary predicate.
SeeAlso
Foam::predicates::scalars
SourceFiles SourceFiles
scalarRanges.C scalarRanges.C
@ -55,17 +58,35 @@ public:
// Constructors // Constructors
//- Inherit constructors from List of scalarRange
using List<scalarRange>::List;
//- Construct null //- Construct null
inline scalarRanges(); inline scalarRanges();
//- Construct by parsing a string for scalar ranges //- Construct by parsing string for scalar ranges
// The individual items are space, comma or semicolon delimited. // The individual items are space, comma or semicolon delimited.
scalarRanges(const std::string& str); // Optionally report when any range failed to parse
inline scalarRanges(const std::string& str, bool verbose = true);
// Static Constructors
//- Construct by parsing string for scalar ranges
// The individual items are space, comma or semicolon delimited.
static scalarRanges parse(const std::string& str, bool verbose = true);
// Member Functions
//- Match any condition in the list.
// \return True if the value matches any condition in the list.
inline bool match(const scalar& value) const;
// Member Operators // Member Operators
//- Unary predicate to test if the value is within any of the ranges //- Identical to match(), for use as a predicate.
inline bool operator()(const scalar& value) const; inline bool operator()(const scalar& value) const;
}; };

View File

@ -31,9 +31,15 @@ inline Foam::scalarRanges::scalarRanges()
{} {}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline Foam::scalarRanges::scalarRanges(const std::string& str, bool verbose)
:
List<scalarRange>(scalarRanges::parse(str, verbose))
{}
inline bool Foam::scalarRanges::operator()(const scalar& value) const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::scalarRanges::match(const scalar& value) const
{ {
for (const scalarRange& range : *this) for (const scalarRange& range : *this)
{ {
@ -47,4 +53,12 @@ inline bool Foam::scalarRanges::operator()(const scalar& value) const
} }
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::scalarRanges::operator()(const scalar& value) const
{
return match(value);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -367,7 +367,7 @@ std::string Foam::fileName::nameLessExt(const std::string& str)
Foam::fileName Foam::fileName::relative Foam::fileName Foam::fileName::relative
( (
const fileName& parent, const fileName& parent,
const bool caseRelative const bool caseTag
) const ) const
{ {
const auto top = parent.size(); const auto top = parent.size();
@ -383,7 +383,7 @@ Foam::fileName Foam::fileName::relative
&& f.startsWith(parent) && f.startsWith(parent)
) )
{ {
if (caseRelative) if (caseTag)
{ {
return "<case>"/f.substr(top+1); return "<case>"/f.substr(top+1);
} }
@ -392,7 +392,7 @@ Foam::fileName Foam::fileName::relative
return f.substr(top+1); return f.substr(top+1);
} }
} }
else if (caseRelative && f.size() && !f.isAbsolute()) else if (caseTag && f.size() && !f.isAbsolute())
{ {
return "<case>"/f; return "<case>"/f;
} }

View File

@ -294,13 +294,13 @@ public:
//- where possible. //- where possible.
// //
// \param parent the parent directory // \param parent the parent directory
// \param caseRelative replace the parent with \<case\> for later // \param caseTag replace the parent with \<case\> for later
// use with expand(), or prefix \<case\> if the file name was // use with expand(), or prefix \<case\> if the file name was
// not an absolute location // not an absolute location
fileName relative fileName relative
( (
const fileName& parent, const fileName& parent,
const bool caseRelative = false const bool caseTag = false
) const; ) const;
//- Return file name without extension (part before last .) //- Return file name without extension (part before last .)

View File

@ -65,11 +65,11 @@ template<class PatchType>
vtkSmartPointer<vtkCellArray> vtkSmartPointer<vtkCellArray>
Foam::vtk::Tools::Patch::faces(const PatchType& p) Foam::vtk::Tools::Patch::faces(const PatchType& p)
{ {
// Faces as polygons // List of faces or triFaces
const faceList& fcs = p.localFaces(); const auto& fcs = p.localFaces();
label nAlloc = fcs.size(); label nAlloc = fcs.size();
for (const face& f : fcs) for (const auto& f : fcs)
{ {
nAlloc += f.size(); nAlloc += f.size();
} }
@ -81,7 +81,7 @@ Foam::vtk::Tools::Patch::faces(const PatchType& p)
// Cell connectivity for polygons // Cell connectivity for polygons
// [size, verts..., size, verts... ] // [size, verts..., size, verts... ]
auto iter = list.begin(); auto iter = list.begin();
for (const face& f : fcs) for (const auto& f : fcs)
{ {
*(iter++) = f.size(); *(iter++) = f.size();
@ -118,15 +118,24 @@ Foam::vtk::Tools::Patch::faceNormals(const PatchType& p)
array->SetNumberOfTuples(p.size()); array->SetNumberOfTuples(p.size());
// Unit normals for patch faces. // Unit normals for patch faces.
// If not already cached, could be more memory efficient to loop over // Cached values if available or loop over faces (avoid triggering cache)
// the individual faces instead.
const vectorField& norms = p.faceNormals();
vtkIdType faceId = 0; vtkIdType faceId = 0;
for (const vector& n : norms)
if (p.hasFaceNormals())
{ {
array->SetTuple(faceId++, n.v_); for (const vector& n : p.faceNormals())
{
array->SetTuple(faceId++, n.v_);
}
}
else
{
for (const auto& f : p)
{
const vector n(f.unitNormal(p.points()));
array->SetTuple(faceId++, n.v_);
}
} }
return array; return array;

View File

@ -786,7 +786,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
propsDict.add propsDict.add
( (
"file", "file",
scalarVtkFile.relative(time_.globalPath(), true) time_.relativePath(scalarVtkFile, true)
); );
setProperty(fieldName, propsDict); setProperty(fieldName, propsDict);
} }
@ -798,7 +798,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
propsDict.add propsDict.add
( (
"file", "file",
vectorVtkFile.relative(time_.globalPath(), true) time_.relativePath(vectorVtkFile, true)
); );
setProperty(fieldName, propsDict); setProperty(fieldName, propsDict);
} }

View File

@ -2,10 +2,12 @@
cd ${0%/*} || exit 1 # Run from this directory cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Source wmake functions . $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions # Source wmake functions
# Cleanup library # This cleanup handles both cmake runTimePostProcessing and the dummy version
# Cleanup library files with .so version endings
rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null
# Cleanup generated files - remove entire top-level # Cleanup generated files - remove entire top-level
removeObjectDir $PWD removeObjectDir "$PWD"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -6,9 +6,9 @@ cd ${0%/*} || exit 1 # Run from this directory
echo "======================================================================" echo "======================================================================"
echo "${PWD##*/} : $PWD" echo "${PWD##*/} : $PWD"
echo
unset depend unset depend
if [ -d "$VTK_DIR" ] if [ -d "$VTK_DIR" ]
then then
depend="VTK_DIR=$VTK_DIR" depend="VTK_DIR=$VTK_DIR"
@ -17,25 +17,36 @@ then
depend="ParaView_DIR=$ParaView_DIR" depend="ParaView_DIR=$ParaView_DIR"
fi fi
if [ -n "$depend" ] # Or force use of dummy only
# unset depend
if [ "$targetType" = objects ]
then then
if [ "$targetType" != objects ] depend=ignore
elif [ -n "$depend" ]
then
if command -v cmake > /dev/null 2>&1
then then
if command -v cmake > /dev/null 2>&1 cmakeVersioned "$depend" $PWD || {
then echo
cmakeVersioned "$depend" $PWD || { echo " WARNING: incomplete build of VTK-based post-processing"
echo echo
echo " WARNING: incomplete build of VTK-based post-processing" depend="dummy"
echo }
} else
else echo "==> skip runTimePostProcessing (needs cmake)"
echo "WARNING: skipped - needs cmake" depend="dummy"
fi
fi fi
else else
echo "WARNING: skipped - needs a VTK or a ParaView installation" echo "WARNING: skip runTimePostProcessing (no VTK or ParaView)"
echo " - For ParaView : export the 'ParaView_DIR' variable" echo " - ParaView : export the 'ParaView_DIR' variable"
echo " - For VTK : export the 'VTK_DIR' variable" echo " - VTK : export the 'VTK_DIR' variable"
fi
if [ "${depend:-dummy}" = dummy ]
then
echo "==> dummy runTimePostProcessing"
wmakeVersioned "vtk=dummy" $PWD dummy
fi fi
echo "======================================================================" echo "======================================================================"

View File

@ -0,0 +1,3 @@
runTimePostProcessingDummy.C
LIB = $(FOAM_LIBBIN)/librunTimePostProcessing

View File

@ -0,0 +1,2 @@
/* EXE_INC = */
/* LIB_LIBS = */

View File

@ -0,0 +1,67 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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 "runTimePostProcessingDummy.H"
#include "dictionary.H"
#include "Time.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(runTimePostProcessingDummy, 0);
addToRunTimeSelectionTable
(
functionObject,
runTimePostProcessingDummy,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostProcessingDummy::runTimePostProcessingDummy
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
functionObject::unavailableFunctionObject(name)
{
carp
(
"VTK libraries were not available at compilation time"
);
}
// ************************************************************************* //

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ 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/>.
Class
Foam::functionObjects::runTimePostProcessingDummy
Group
grpGraphicsFunctionObjects
Description
Dummy implementation of Foam::functionObjects::runTimePostProcessing
to report when the real version is unavailable.
SourceFiles
runTimePostProcessingDummy.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_runTimePostProcessingDummy_H
#define functionObjects_runTimePostProcessingDummy_H
#include "functionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class runTimePostProcessingDummy Declaration
\*---------------------------------------------------------------------------*/
class runTimePostProcessingDummy
:
public functionObject::unavailableFunctionObject
{
public:
//- Runtime type information
TypeName("runTimePostProcessing");
// Constructors
//- Construct from dictionary
runTimePostProcessingDummy
(
const word& name,
const Time& runTime,
const dictionary& dict
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -49,9 +49,11 @@ License
const Foam::Enum const Foam::Enum
< <
Foam::functionObjects::fieldVisualisationBase::colourByType Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
colourByType
> >
Foam::functionObjects::fieldVisualisationBase::colourByTypeNames Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
colourByTypeNames
({ ({
{ colourByType::cbColour, "colour" }, { colourByType::cbColour, "colour" },
{ colourByType::cbField, "field" }, { colourByType::cbField, "field" },
@ -59,9 +61,11 @@ Foam::functionObjects::fieldVisualisationBase::colourByTypeNames
const Foam::Enum const Foam::Enum
< <
Foam::functionObjects::fieldVisualisationBase::colourMapType Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
colourMapType
> >
Foam::functionObjects::fieldVisualisationBase::colourMapTypeNames Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
colourMapTypeNames
({ ({
{ colourMapType::cmRainbow, "rainbow" }, { colourMapType::cmRainbow, "rainbow" },
{ colourMapType::cmBlueWhiteRed, "blueWhiteRed" }, { colourMapType::cmBlueWhiteRed, "blueWhiteRed" },
@ -72,7 +76,8 @@ Foam::functionObjects::fieldVisualisationBase::colourMapTypeNames
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::functionObjects::fieldVisualisationBase::setColourMap void Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
setColourMap
( (
vtkLookupTable* lut vtkLookupTable* lut
) const ) const
@ -130,7 +135,8 @@ void Foam::functionObjects::fieldVisualisationBase::setColourMap
} }
void Foam::functionObjects::fieldVisualisationBase::addScalarBar void Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
addScalarBar
( (
const scalar position, const scalar position,
vtkRenderer* renderer, vtkRenderer* renderer,
@ -239,7 +245,8 @@ void Foam::functionObjects::fieldVisualisationBase::addScalarBar
} }
void Foam::functionObjects::fieldVisualisationBase::setField void Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
setField
( (
const scalar position, const scalar position,
const word& colourFieldName, const word& colourFieldName,
@ -272,11 +279,11 @@ void Foam::functionObjects::fieldVisualisationBase::setField
// Note: if both point and cell data exists, preferentially // Note: if both point and cell data exists, preferentially
// choosing point data. This is often the case when using // choosing point data. This is often the case when using
// glyphs // glyphs
if (pData->GetPointData()->HasArray(fieldName) == 1) if (pData->GetPointData()->HasArray(fieldName))
{ {
mapper->SetScalarModeToUsePointFieldData(); mapper->SetScalarModeToUsePointFieldData();
} }
else if (pData->GetCellData()->HasArray(fieldName) == 1) else if (pData->GetCellData()->HasArray(fieldName))
{ {
mapper->SetScalarModeToUseCellFieldData(); mapper->SetScalarModeToUseCellFieldData();
} }
@ -302,8 +309,8 @@ void Foam::functionObjects::fieldVisualisationBase::setField
} }
void Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
void Foam::functionObjects::fieldVisualisationBase::addGlyphs addGlyphs
( (
const scalar position, const scalar position,
const word& scaleFieldName, const word& scaleFieldName,
@ -320,20 +327,49 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
glyph->SetInputData(data); glyph->SetInputData(data);
glyph->ScalingOn(); glyph->ScalingOn();
bool ok = true;
bool needPointData = false;
// Determine whether we have scalar or vector data // Determine whether we have scalar or vector data
// and if we need to convert CellData -> PointData
label nComponents = -1; label nComponents = -1;
const char* scaleFieldNameChar = scaleFieldName.c_str(); const char* scaleFieldNameChar = scaleFieldName.c_str();
if (data->GetPointData()->HasArray(scaleFieldNameChar) == 1) if (data->GetPointData()->HasArray(scaleFieldNameChar))
{ {
nComponents = nComponents =
data->GetPointData()->GetArray(scaleFieldNameChar) data->GetPointData()->GetArray(scaleFieldNameChar)
->GetNumberOfComponents(); ->GetNumberOfComponents();
} }
else if (data->GetCellData()->HasArray(scaleFieldNameChar) == 1) else if (data->GetCellData()->HasArray(scaleFieldNameChar))
{
// Need to convert CellData to PointData
needPointData = true;
nComponents =
data->GetCellData()->GetArray(scaleFieldNameChar)
->GetNumberOfComponents();
}
else
{
WarningInFunction
<< "Cannot add glyphs. No such cell or point field: "
<< scaleFieldName << endl;
return;
}
const bool ok = (nComponents == 1 || nComponents == 3);
if (!ok)
{
WarningInFunction
<< "Glyphs can only be added to scalar or vector data. "
<< "Unable to process field " << scaleFieldName << endl;
return;
}
else if (needPointData)
{ {
// Need to convert cell data to point data
auto cellToPoint = vtkSmartPointer<vtkCellDataToPointData>::New(); auto cellToPoint = vtkSmartPointer<vtkCellDataToPointData>::New();
cellToPoint->SetInputData(data); cellToPoint->SetInputData(data);
cellToPoint->Update(); cellToPoint->Update();
@ -342,16 +378,8 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
// Store in main vtkPolyData // Store in main vtkPolyData
data->GetPointData()->AddArray(pData); data->GetPointData()->AddArray(pData);
}
nComponents = pData->GetNumberOfComponents();
}
else
{
WarningInFunction
<< "Glyphs can only be added to scalar or vector data. "
<< "Unable to process field " << scaleFieldName << endl;
return;
}
if (nComponents == 1) if (nComponents == 1)
{ {
@ -367,18 +395,16 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
if (maxGlyphLength > 0) if (maxGlyphLength > 0)
{ {
double range[2]; // Can get range from point data:
// Can use values to find range // double range[2];
// vtkDataArray* values = // vtkDataArray* values =
// data->GetPointData()->GetScalars(scaleFieldNameChar); // data->GetPointData()->GetScalars(scaleFieldNameChar);
// values->GetRange(range); // values->GetRange(range);
// Set range according to user-supplied limits // Set range according to user-supplied limits
range[0] = range_.first();
range[1] = range_.second();
glyph->ClampingOn(); glyph->ClampingOn();
glyph->SetRange(range); glyph->SetRange(range_.first(), range_.second());
// If range[0] != min(value), maxGlyphLength behaviour will not // If range[0] != min(value), maxGlyphLength behaviour will not
// be correct... // be correct...
@ -450,15 +476,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
scaleFieldNameChar scaleFieldNameChar
); );
} }
else
{
WarningInFunction
<< "Glyphs can only be added to scalar and vector fields."
<< " Field " << scaleFieldName << " has " << nComponents
<< " components" << endl;
ok = false;
}
if (ok) if (ok)
{ {
@ -477,10 +495,11 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
fieldVisualisationBase
( (
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
colours_(colours), colours_(colours),
@ -504,16 +523,17 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
colourMapTypeNames.readIfPresent("colourMap", dict, colourMap_); colourMapTypeNames.readIfPresent("colourMap", dict, colourMap_);
const dictionary& sbarDict = dict.subDict("scalarBar"); const dictionary& sbDict = dict.subDict("scalarBar");
sbarDict.readEntry("visible", scalarBar_.visible_); sbDict.readEntry("visible", scalarBar_.visible_);
if (scalarBar_.visible_) if (scalarBar_.visible_)
{ {
sbarDict.readEntry("vertical", scalarBar_.vertical_); sbDict.readEntry("vertical", scalarBar_.vertical_);
sbarDict.readEntry("position", scalarBar_.position_); sbDict.readEntry("position", scalarBar_.position_);
sbarDict.readEntry("title", scalarBar_.title_); sbDict.readEntry("title", scalarBar_.title_);
sbarDict.readEntry("fontSize", scalarBar_.fontSize_); sbDict.readEntry("fontSize", scalarBar_.fontSize_);
sbarDict.readEntry("labelFormat", scalarBar_.labelFormat_); sbDict.readEntry("labelFormat", scalarBar_.labelFormat_);
sbarDict.readEntry("numberOfLabels", scalarBar_.numberOfLabels_); sbDict.readEntry("numberOfLabels", scalarBar_.numberOfLabels_);
} }
break; break;
} }
@ -523,21 +543,23 @@ Foam::functionObjects::fieldVisualisationBase::fieldVisualisationBase
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::fieldVisualisationBase::~fieldVisualisationBase() Foam::functionObjects::runTimePostPro::fieldVisualisationBase::
~fieldVisualisationBase()
{} {}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::HashPtrTable<Foam::Function1<Foam::vector>, Foam::word>& const Foam::HashPtrTable<Foam::Function1<Foam::vector>, Foam::word>&
Foam::functionObjects::fieldVisualisationBase::colours() const Foam::functionObjects::runTimePostPro::fieldVisualisationBase::colours() const
{ {
return colours_; return colours_;
} }
const Foam::word& const Foam::word&
Foam::functionObjects::fieldVisualisationBase::fieldName() const Foam::functionObjects::runTimePostPro::fieldVisualisationBase::fieldName()
const
{ {
return fieldName_; return fieldName_;
} }

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::functionObjects::fieldVisualisationBase Foam::functionObjects::runTimePostPro::fieldVisualisationBase
Description Description
Base class for scene objects Base class for scene objects
@ -42,26 +42,29 @@ SourceFiles
#include "HashPtrTable.H" #include "HashPtrTable.H"
#include "Function1.H" #include "Function1.H"
// VTK includes
#include "vtkSmartPointer.h" #include "vtkSmartPointer.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkActor; class vtkActor;
class vtkLookupTable; class vtkLookupTable;
class vtkMapper;
class vtkPolyData; class vtkPolyData;
class vtkPolyDataMapper; class vtkPolyDataMapper;
class vtkRenderer; class vtkRenderer;
class vtkMapper;
namespace Foam namespace Foam
{ {
namespace functionObjects namespace functionObjects
{ {
// Forward declarations
class runTimePostProcessing; class runTimePostProcessing;
namespace runTimePostPro
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class fieldVisualisationBase Declaration Class fieldVisualisationBase Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -91,20 +94,9 @@ public:
static const Enum<colourMapType> colourMapTypeNames; static const Enum<colourMapType> colourMapTypeNames;
private:
// Private Member Functions
//- No copy construct
fieldVisualisationBase(const fieldVisualisationBase&) = delete;
//- No copy assignment
void operator=(const fieldVisualisationBase&) = delete;
protected: protected:
// Protected data // Protected Data
struct scalarBar struct scalarBar
{ {
@ -118,7 +110,7 @@ protected:
}; };
//- Colours //- Colours
const HashPtrTable<Function1<vector>, word>& colours_; const HashPtrTable<Function1<vector>>& colours_;
//- Field name //- Field name
word fieldName_; word fieldName_;
@ -171,6 +163,12 @@ protected:
vtkRenderer* renderer vtkRenderer* renderer
) const; ) const;
//- No copy construct
fieldVisualisationBase(const fieldVisualisationBase&) = delete;
//- No copy assignment
void operator=(const fieldVisualisationBase&) = delete;
public: public:
@ -180,7 +178,7 @@ public:
fieldVisualisationBase fieldVisualisationBase
( (
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );
@ -190,18 +188,19 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Return the colours //- Return the colours
const HashPtrTable<Function1<vector>, word>& colours() const; const HashPtrTable<Function1<vector>>& colours() const;
//- Return the field name //- Return the field name
const word& fieldName() const; const word& fieldName() const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace runTimePostPro
} // End namespace functionObjects } // End namespace functionObjects
} // End namespace Foam } // End namespace Foam

View File

@ -79,7 +79,7 @@ Foam::functionObjects::runTimePostPro::functionObjectBase::functionObjectBase
( (
const stateFunctionObject& state, const stateFunctionObject& state,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
fieldVisualisationBase(dict, colours), fieldVisualisationBase(dict, colours),

View File

@ -109,13 +109,13 @@ protected:
// \note does not change the stateFunctionObject // \note does not change the stateFunctionObject
bool removeFile(const word& keyword, const word& subDictName); bool removeFile(const word& keyword, const word& subDictName);
//- No copy construct //- No copy construct
functionObjectBase(const functionObjectBase&) = delete; functionObjectBase(const functionObjectBase&) = delete;
//- No copy assignment //- No copy assignment
void operator=(const functionObjectBase&) = delete; void operator=(const functionObjectBase&) = delete;
public: public:
//- Run-time type information //- Run-time type information
@ -129,7 +129,7 @@ public:
( (
const stateFunctionObject& state, const stateFunctionObject& state,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );

View File

@ -35,10 +35,12 @@ License
#include "vtkSmartPointer.h" #include "vtkSmartPointer.h"
#include "vtkPolyData.h" #include "vtkPolyData.h"
#include "vtkPolyDataMapper.h" #include "vtkPolyDataMapper.h"
#include "vtkXMLPolyDataReader.h"
#include "vtkPolyDataReader.h"
#include "vtkProperty.h" #include "vtkProperty.h"
// VTK Readers
#include "vtkPolyDataReader.h"
#include "vtkXMLPolyDataReader.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -60,7 +62,7 @@ Foam::functionObjects::runTimePostPro::functionObjectCloud::functionObjectCloud
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
pointData(parent, dict, colours), pointData(parent, dict, colours),
@ -101,7 +103,6 @@ addGeometryToScene
// containing all fields. // containing all fields.
inputFileName_ = getFileName("file", cloudName_); inputFileName_ = getFileName("file", cloudName_);
inputFileName_.expand();
if (inputFileName_.empty()) if (inputFileName_.empty())
{ {
@ -113,6 +114,7 @@ addGeometryToScene
return; return;
} }
vtkSmartPointer<vtkPolyData> dataset; vtkSmartPointer<vtkPolyData> dataset;
if (inputFileName_.hasExt("vtp")) if (inputFileName_.hasExt("vtp"))
@ -128,9 +130,17 @@ addGeometryToScene
// Invalid name - ignore. // Invalid name - ignore.
// Don't support VTK legacy format at all - it is too wasteful // Don't support VTK legacy format at all - it is too wasteful
// and cumbersome. // and cumbersome.
WarningInFunction
<< "Could not read "<< inputFileName_ << nl
<< "Only VTK (.vtp) files are supported"
<< ". Cloud will not be processed"
<< endl;
inputFileName_.clear(); inputFileName_.clear();
} }
if (dataset) if (dataset)
{ {
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();

View File

@ -56,20 +56,9 @@ class functionObjectCloud
public pointData, public pointData,
public functionObjectBase public functionObjectBase
{ {
private:
// Private Member Functions
//- No copy construct
functionObjectCloud(const functionObjectCloud&) = delete;
//- No copy assignment
void operator=(const functionObjectCloud&) = delete;
protected: protected:
// Protected data // Protected Data
//- Name of functionObjectCloud //- Name of functionObjectCloud
word cloudName_; word cloudName_;
@ -83,6 +72,16 @@ protected:
//- Actor //- Actor
vtkSmartPointer<vtkActor> actor_; vtkSmartPointer<vtkActor> actor_;
// Protected Member Functions
//- No copy construct
functionObjectCloud(const functionObjectCloud&) = delete;
//- No copy assignment
void operator=(const functionObjectCloud&) = delete;
public: public:
//- Run-time type information //- Run-time type information
@ -96,7 +95,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,11 +30,15 @@ License
// VTK includes // VTK includes
#include "vtkActor.h" #include "vtkActor.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRenderer.h" #include "vtkRenderer.h"
#include "vtkSmartPointer.h" #include "vtkSmartPointer.h"
#include "vtkPolyDataMapper.h"
// VTK Readers
#include "vtkPolyDataReader.h" #include "vtkPolyDataReader.h"
#include "vtkProperty.h" #include "vtkXMLPolyDataReader.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -51,13 +55,51 @@ namespace runTimePostPro
} }
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
{
static vtkSmartPointer<vtkPolyData> getPolyDataFile(const Foam::fileName& fName)
{
// Not extremely elegant...
vtkSmartPointer<vtkPolyData> dataset;
if (fName.ext() == "vtk")
{
auto reader = vtkSmartPointer<vtkPolyDataReader>::New();
reader->SetFileName(fName.c_str());
reader->Update();
dataset = reader->GetOutput();
return dataset;
}
if (fName.ext() == "vtp")
{
auto reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName(fName.c_str());
reader->Update();
dataset = reader->GetOutput();
return dataset;
}
return dataset;
}
} // End anonymous namespace
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostPro::functionObjectLine::functionObjectLine Foam::functionObjects::runTimePostPro::functionObjectLine::functionObjectLine
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
pathline(parent, dict, colours), pathline(parent, dict, colours),
@ -99,21 +141,28 @@ addGeometryToScene
return; return;
} }
if (fName.hasExt("vtk"))
auto polyData = getPolyDataFile(fName);
if (!polyData || polyData->GetNumberOfPoints() == 0)
{ {
auto lines = vtkSmartPointer<vtkPolyDataReader>::New(); WarningInFunction
lines->SetFileName(fName.c_str()); << "Could not read "<< fName << nl
lines->Update(); << "Only VTK (.vtp, .vtk) files are supported"
<< endl;
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); return;
setField(position, fieldName_, mapper, renderer, lines->GetOutput());
actor_->SetMapper(mapper);
addLines(position, actor_, lines->GetOutput());
renderer->AddActor(actor_);
} }
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
setField(position, fieldName_, mapper, renderer, polyData);
actor_->SetMapper(mapper);
addLines(position, actor_, polyData);
renderer->AddActor(actor_);
} }
@ -126,6 +175,7 @@ void Foam::functionObjects::runTimePostPro::functionObjectLine::updateActors
actor_->GetProperty()->SetOpacity(opacity(position)); actor_->GetProperty()->SetOpacity(opacity(position));
} }
bool Foam::functionObjects::runTimePostPro::functionObjectLine::clear() bool Foam::functionObjects::runTimePostPro::functionObjectLine::clear()
{ {
if (functionObjectBase::clear()) if (functionObjectBase::clear())

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -56,9 +56,15 @@ class functionObjectLine
public pathline, public pathline,
public functionObjectBase public functionObjectBase
{ {
private: protected:
// Private Member Functions // Protected Data
//- Actor
vtkSmartPointer<vtkActor> actor_;
// Protected Member Functions
//- No copy construct //- No copy construct
functionObjectLine(const functionObjectLine&) = delete; functionObjectLine(const functionObjectLine&) = delete;
@ -67,14 +73,6 @@ private:
void operator=(const functionObjectLine&) = delete; void operator=(const functionObjectLine&) = delete;
protected:
// Protected data
//- Actor
vtkSmartPointer<vtkActor> actor_;
public: public:
//- Run-time type information //- Run-time type information
@ -88,7 +86,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );

View File

@ -30,12 +30,16 @@ License
// VTK includes // VTK includes
#include "vtkActor.h" #include "vtkActor.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h" #include "vtkPolyDataMapper.h"
#include "vtkPolyDataReader.h"
#include "vtkProperty.h" #include "vtkProperty.h"
#include "vtkRenderer.h" #include "vtkRenderer.h"
#include "vtkSmartPointer.h" #include "vtkSmartPointer.h"
// VTK Readers
#include "vtkPolyDataReader.h"
#include "vtkXMLPolyDataReader.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -51,6 +55,44 @@ namespace runTimePostPro
} }
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
{
static vtkSmartPointer<vtkPolyData> getPolyDataFile(const Foam::fileName& fName)
{
// Not extremely elegant...
vtkSmartPointer<vtkPolyData> dataset;
if (fName.ext() == "vtk")
{
auto reader = vtkSmartPointer<vtkPolyDataReader>::New();
reader->SetFileName(fName.c_str());
reader->Update();
dataset = reader->GetOutput();
return dataset;
}
if (fName.ext() == "vtp")
{
auto reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName(fName.c_str());
reader->Update();
dataset = reader->GetOutput();
return dataset;
}
return dataset;
}
} // End anonymous namespace
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostPro::functionObjectSurface:: Foam::functionObjects::runTimePostPro::functionObjectSurface::
@ -58,7 +100,7 @@ functionObjectSurface
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
geometrySurface(parent, dict, colours, List<fileName>()), geometrySurface(parent, dict, colours, List<fileName>()),
@ -99,37 +141,38 @@ addGeometryToScene
} }
auto polyData = getPolyDataFile(fName);
if (!polyData || polyData->GetNumberOfPoints() == 0)
{
WarningInFunction
<< "Could not read "<< fName << nl
<< "Only VTK (.vtp, .vtk) files are supported"
<< endl;
return;
}
if (representation_ == rtGlyph) if (representation_ == rtGlyph)
{ {
auto surf = vtkSmartPointer<vtkPolyDataReader>::New();
surf->SetFileName(fName.c_str());
surf->Update();
addGlyphs addGlyphs
( (
position, position,
fieldName_, fieldName_,
fieldName_, fieldName_,
maxGlyphLength_, maxGlyphLength_,
surf->GetOutput(), polyData,
surfaceActor_, surfaceActor_,
renderer renderer
); );
return;
} }
else
if (fName.hasExt("vtk"))
{ {
auto surf = vtkSmartPointer<vtkPolyDataReader>::New(); addFeatureEdges(renderer, polyData);
surf->SetFileName(fName.c_str());
surf->Update();
addFeatureEdges(renderer, surf->GetOutput());
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(surf->GetOutputPort()); mapper->SetInputData(polyData);
setField(position, fieldName_, mapper, renderer, surf->GetOutput()); setField(position, fieldName_, mapper, renderer, polyData);
surfaceActor_->SetMapper(mapper); surfaceActor_->SetMapper(mapper);
@ -137,12 +180,6 @@ addGeometryToScene
renderer->AddActor(surfaceActor_); renderer->AddActor(surfaceActor_);
} }
else
{
WarningInFunction
<< "Only VTK file types are supported"
<< endl;
}
} }

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -56,10 +56,9 @@ class functionObjectSurface
public geometrySurface, public geometrySurface,
public functionObjectBase public functionObjectBase
{ {
protected:
private: // Protected Member Functions
// Private Member Functions
//- No copy construct //- No copy construct
functionObjectSurface(const functionObjectSurface&) = delete; functionObjectSurface(const functionObjectSurface&) = delete;
@ -81,7 +80,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,6 +27,7 @@ License
#include "runTimePostProcessing.H" #include "runTimePostProcessing.H"
#include "Constant.H" #include "Constant.H"
// VTK includes
#include "vtkActor.h" #include "vtkActor.h"
#include "vtkProperty.h" #include "vtkProperty.h"
@ -81,7 +82,7 @@ Foam::functionObjects::runTimePostPro::geometryBase::geometryBase
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
parent_(parent), parent_(parent),
@ -96,7 +97,7 @@ Foam::functionObjects::runTimePostPro::geometryBase::geometryBase
{ {
if (dict.found("opacity")) if (dict.found("opacity"))
{ {
opacity_.reset(Function1<scalar>::New("opacity", dict).ptr()); opacity_.reset(Function1<scalar>::New("opacity", dict));
} }
else else
{ {

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,7 +25,15 @@ Class
Foam::functionObjects::runTimePostPro::geometryBase Foam::functionObjects::runTimePostPro::geometryBase
Description Description
Base class for surface handling Base class for surface, text handling
Dictionary controls
\table
Property | Description | Required | Default
visible | Display the object | yes |
renderMode | Shading (flat/gouraud/phong) | no | gouraud
opacity | Object opacity | no | 1.0
\endtable
SourceFiles SourceFiles
geometryBase.C geometryBase.C
@ -43,6 +51,7 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkRenderer; class vtkRenderer;
class vtkActor; class vtkActor;
@ -51,6 +60,7 @@ namespace Foam
namespace functionObjects namespace functionObjects
{ {
// Forward declarations
class runTimePostProcessing; class runTimePostProcessing;
namespace runTimePostPro namespace runTimePostPro
@ -78,17 +88,6 @@ public:
static const Enum<renderModeType> renderModeTypeNames; static const Enum<renderModeType> renderModeTypeNames;
private:
// Private Member Functions
//- No copy construct
geometryBase(const geometryBase&) = delete;
//- No copy assignment
void operator=(const geometryBase&) = delete;
protected: protected:
// Protected data // Protected data
@ -109,7 +108,7 @@ protected:
autoPtr<Function1<scalar>> opacity_; autoPtr<Function1<scalar>> opacity_;
//- Reference to the colours //- Reference to the colours
const HashPtrTable<Function1<vector>, word>& colours_; const HashPtrTable<Function1<vector>>& colours_;
// Protected functions // Protected functions
@ -117,6 +116,12 @@ protected:
//- Initialise actor //- Initialise actor
void initialiseActor(vtkActor* actor) const; void initialiseActor(vtkActor* actor) const;
//- No copy construct
geometryBase(const geometryBase&) = delete;
//- No copy assignment
void operator=(const geometryBase&) = delete;
public: public:
@ -127,7 +132,7 @@ public:
( (
const runTimePostProcessing& parent_, const runTimePostProcessing& parent_,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );
@ -137,24 +142,26 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Return the reference to the parent function object //- Return the reference to the parent function object
const runTimePostProcessing& parent() const; const runTimePostProcessing& parent() const;
//- Return the name //- Return the name
const word& name() const; const word& name() const;
//- Return the visible flag //- Return the visible flag
bool visible() const; bool visible() const;
//- Return the opacity //- Return the opacity
scalar opacity(const scalar position) const; scalar opacity(const scalar position) const;
//- Return reference to the colours //- Return reference to the colours
const HashPtrTable<Function1<vector>, word>& colours() const; const HashPtrTable<Function1<vector>>& colours() const;
// Scene interaction
//- Add geometry to scene //- Add geometry to scene
virtual void addGeometryToScene virtual void addGeometryToScene
( (

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,7 +26,8 @@ License
// OpenFOAM includes // OpenFOAM includes
#include "geometrySurface.H" #include "geometrySurface.H"
#include "stringOps.H" #include "stringOps.H"
#include "triSurface.H" #include "foamVtkTools.H"
#include "MeshedSurfaces.H"
#include "runTimePostProcessing.H" #include "runTimePostProcessing.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -42,7 +43,12 @@ License
#include "vtkProperty.h" #include "vtkProperty.h"
#include "vtkRenderer.h" #include "vtkRenderer.h"
#include "vtkSmartPointer.h" #include "vtkSmartPointer.h"
#include "vtkTriangle.h"
// VTK Readers
#include "vtkOBJReader.h"
#include "vtkSTLReader.h"
#include "vtkPolyDataReader.h"
#include "vtkXMLPolyDataReader.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -58,6 +64,78 @@ namespace runTimePostPro
} }
} }
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
{
static vtkSmartPointer<vtkPolyData> getPolyDataFile(const Foam::fileName& fName)
{
// Not extremely elegant...
vtkSmartPointer<vtkPolyData> dataset;
if (fName.ext() == "vtk")
{
auto reader = vtkSmartPointer<vtkPolyDataReader>::New();
reader->SetFileName(fName.c_str());
reader->Update();
dataset = reader->GetOutput();
return dataset;
}
if (fName.ext() == "vtp")
{
auto reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName(fName.c_str());
reader->Update();
dataset = reader->GetOutput();
return dataset;
}
if (fName.ext() == "obj")
{
auto reader = vtkSmartPointer<vtkOBJReader>::New();
reader->SetFileName(fName.c_str());
reader->Update();
dataset = reader->GetOutput();
return dataset;
}
if (fName.ext() == "stl" || fName.ext() == "stlb")
{
auto reader = vtkSmartPointer<vtkSTLReader>::New();
reader->SetFileName(fName.c_str());
reader->Update();
dataset = reader->GetOutput();
return dataset;
}
// Fallback to using OpenFOAM to read the surface and convert afterwards
Foam::meshedSurface surf(fName);
dataset = Foam::vtk::Tools::Patch::mesh(surf);
dataset->GetCellData()->SetNormals
(
Foam::vtk::Tools::Patch::faceNormals(surf)
);
return dataset;
}
} // End anonymous namespace
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
@ -74,53 +152,22 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
<< " object" << exit(FatalError); << " object" << exit(FatalError);
} }
triSurface surf(fName); auto surf = getPolyDataFile(fName);
const Field<point>& surfPoints = surf.points(); if (!surf || surf->GetNumberOfPoints() == 0)
const Field<vector>& surfFaceNormals = surf.faceNormals();
auto points = vtkSmartPointer<vtkPoints>::New();
auto triangles = vtkSmartPointer<vtkCellArray>::New();
auto faceNormals = vtkSmartPointer<vtkDoubleArray>::New();
faceNormals->SetNumberOfComponents(3);
forAll(surfPoints, i)
{ {
const point& pt = surfPoints[i]; FatalErrorInFunction
points->InsertNextPoint(pt.x(), pt.y(), pt.z()); << "Could not read "<< fName << nl
<< exit(FatalError);
} }
forAll(surf, i)
{
const Foam::face& f = surf[i];
auto triangle = vtkSmartPointer<vtkTriangle>::New();
triangle->GetPointIds()->SetId(0, f[0]);
triangle->GetPointIds()->SetId(1, f[1]);
triangle->GetPointIds()->SetId(2, f[2]);
triangles->InsertNextCell(triangle);
double n[3];
n[0] = surfFaceNormals[i].x();
n[1] = surfFaceNormals[i].y();
n[2] = surfFaceNormals[i].z();
faceNormals->InsertNextTuple(n);
}
surf.clearOut();
auto polyData = vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(points);
polyData->SetPolys(triangles);
polyData->GetCellData()->SetNormals(faceNormals);
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New(); auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->ScalarVisibilityOff();
mapper->SetInputData(polyData);
addFeatureEdges(renderer, polyData); mapper->ScalarVisibilityOff();
mapper->SetInputData(surf);
addFeatureEdges(renderer, surf);
surfaceActor_->SetMapper(mapper); surfaceActor_->SetMapper(mapper);
@ -136,7 +183,7 @@ Foam::functionObjects::runTimePostPro::geometrySurface::geometrySurface
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
surface(parent, dict, colours), surface(parent, dict, colours),
@ -150,7 +197,7 @@ Foam::functionObjects::runTimePostPro::geometrySurface::geometrySurface
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours, const HashPtrTable<Function1<vector>>& colours,
const List<fileName>& fileNames const List<fileName>& fileNames
) )
: :
@ -159,12 +206,6 @@ Foam::functionObjects::runTimePostPro::geometrySurface::geometrySurface
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostPro::geometrySurface::~geometrySurface()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
@ -178,10 +219,10 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene
return; return;
} }
forAll(fileNames_, i) for (fileName f : fileNames_) // Use a copy
{ {
fileName fName = fileNames_[i].expand(); f.expand();
addGeometryToScene(position, renderer, fName); addGeometryToScene(position, renderer, f);
} }
} }
@ -210,8 +251,8 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::updateActors
bool Foam::functionObjects::runTimePostPro::geometrySurface::clear() bool Foam::functionObjects::runTimePostPro::geometrySurface::clear()
{ {
// Note: not removing geometry files // Note: do not remove geometry files
// - these are usually static files that are used e.g. for meshing // - often static files used for other purposes as well (eg meshing)
return true; return true;
} }

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::geometrySurface Foam::functionObjects::runTimePostPro::geometrySurface
Description Description
Visualisation of surface geometry data Visualisation of surface geometry data
@ -39,6 +39,7 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkPolyData; class vtkPolyData;
namespace Foam namespace Foam
@ -56,17 +57,6 @@ class geometrySurface
: :
public surface public surface
{ {
private:
// Private Member Functions
//- No copy construct
geometrySurface(const geometrySurface&) = delete;
//- No copy assignment
void operator=(const geometrySurface&) = delete;
protected: protected:
// Protected data // Protected data
@ -85,6 +75,12 @@ protected:
const fileName& fName const fileName& fName
) const; ) const;
//- No copy construct
geometrySurface(const geometrySurface&) = delete;
//- No copy assignment
void operator=(const geometrySurface&) = delete;
public: public:
@ -99,7 +95,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );
//- Construct from components //- Construct from components
@ -107,18 +103,18 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours, const HashPtrTable<Function1<vector>>& colours,
const List<fileName>& fileNames const List<fileName>& fileNames
); );
//- Destructor //- Destructor
virtual ~geometrySurface(); virtual ~geometrySurface() = default;
// Member Functions // Member Functions
//- Add surface(s) to scene //- Add geometry surface(s) to scene
virtual void addGeometryToScene virtual void addGeometryToScene
( (
const scalar position, const scalar position,

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -78,7 +78,7 @@ void Foam::functionObjects::runTimePostPro::pathline::addLines
actor->GetProperty()->SetColor(colour[0], colour[1], colour[2]); actor->GetProperty()->SetColor(colour[0], colour[1], colour[2]);
vtkPolyDataMapper* mapper = vtkPolyDataMapper* mapper =
vtkPolyDataMapper::SafeDownCast(actor->GetMapper()); vtkPolyDataMapper::SafeDownCast(actor->GetMapper());
switch (representation_) switch (representation_)
{ {
@ -123,7 +123,7 @@ Foam::functionObjects::runTimePostPro::pathline::pathline
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
geometryBase(parent, dict, colours), geometryBase(parent, dict, colours),
@ -136,7 +136,7 @@ Foam::functionObjects::runTimePostPro::pathline::pathline
{ {
if (dict.found("lineColour")) if (dict.found("lineColour"))
{ {
lineColour_.reset(Function1<vector>::New("lineColour", dict).ptr()); lineColour_.reset(Function1<vector>::New("lineColour", dict));
} }
else else
{ {
@ -174,7 +174,7 @@ Foam::functionObjects::runTimePostPro::pathline::New
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours, const HashPtrTable<Function1<vector>>& colours,
const word& pathlineType const word& pathlineType
) )
{ {

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -22,9 +22,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::pathline Foam::functionObjects::runTimePostPro::pathline
Description Description
Visualisation of line data (eg, streamlines)
SourceFiles SourceFiles
pathline.C pathline.C
@ -40,6 +41,7 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkActor; class vtkActor;
class vtkPolyData; class vtkPolyData;
class vtkPolyDataMapper; class vtkPolyDataMapper;
@ -74,17 +76,6 @@ public:
static const Enum<representationType> representationTypeNames; static const Enum<representationType> representationTypeNames;
private:
// Private Member Functions
//- No copy construct
pathline(const pathline&) = delete;
//- No copy assignment
void operator=(const pathline&) = delete;
protected: protected:
// Protected data // Protected data
@ -109,6 +100,12 @@ protected:
vtkPolyData* data vtkPolyData* data
) const; ) const;
//- No copy construct
pathline(const pathline&) = delete;
//- No copy assignment
void operator=(const pathline&) = delete;
public: public:
@ -126,7 +123,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
), ),
(parent, dict, colours) (parent, dict, colours)
); );
@ -139,7 +136,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );
@ -150,7 +147,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours, const HashPtrTable<Function1<vector>>& colours,
const word& pathlineName const word& pathlineName
); );

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -93,7 +93,7 @@ Foam::functionObjects::runTimePostPro::pointData::pointData
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
geometryBase(parent, dict, colours), geometryBase(parent, dict, colours),
@ -106,7 +106,7 @@ Foam::functionObjects::runTimePostPro::pointData::pointData
{ {
if (dict.found("pointColour")) if (dict.found("pointColour"))
{ {
pointColour_.reset(Function1<vector>::New("pointColour", dict).ptr()); pointColour_.reset(Function1<vector>::New("pointColour", dict));
} }
else else
{ {
@ -135,7 +135,7 @@ Foam::functionObjects::runTimePostPro::pointData::New
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours, const HashPtrTable<Function1<vector>>& colours,
const word& pointDataType const word& pointDataType
) )
{ {

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,6 +25,7 @@ Class
Foam::functionObjects::runTimePostPro::pointData Foam::functionObjects::runTimePostPro::pointData
Description Description
Visualisation of point data
SourceFiles SourceFiles
pointData.C pointData.C
@ -40,6 +41,7 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkActor; class vtkActor;
class vtkPolyData; class vtkPolyData;
class vtkPolyDataMapper; class vtkPolyDataMapper;
@ -72,17 +74,6 @@ public:
static const Enum<representationType> representationTypeNames; static const Enum<representationType> representationTypeNames;
private:
// Private Member Functions
//- No copy construct
pointData(const pointData&) = delete;
//- No copy assignment
void operator=(const pointData&) = delete;
protected: protected:
// Protected data // Protected data
@ -108,6 +99,12 @@ protected:
vtkPolyData* data vtkPolyData* data
) const; ) const;
//- No copy construct
pointData(const pointData&) = delete;
//- No copy assignment
void operator=(const pointData&) = delete;
public: public:
@ -125,7 +122,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
), ),
(parent, dict, colours) (parent, dict, colours)
); );
@ -138,7 +135,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );
@ -149,7 +146,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours, const HashPtrTable<Function1<vector>>& colours,
const word& pointDataName const word& pointDataName
); );

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -39,7 +39,6 @@ License
#include "vtkRenderer.h" #include "vtkRenderer.h"
#include "vtkRenderWindow.h" #include "vtkRenderWindow.h"
#include "vtkSmartPointer.h" #include "vtkSmartPointer.h"
#include "vtkLight.h" #include "vtkLight.h"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -60,6 +59,48 @@ namespace functionObjects
} }
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
static void addGeometryToScene
(
PtrList<Type>& objects,
const scalar position,
vtkRenderer* renderer
)
{
for (Type& obj : objects)
{
obj.addGeometryToScene(position, renderer);
}
}
template<class Type>
static void updateActors(PtrList<Type>& objects, const scalar position)
{
for (Type& obj : objects)
{
obj.updateActors(position);
}
}
template<class Type>
static void cleanup(PtrList<Type>& objects)
{
for (Type& obj : objects)
{
obj.clear();
}
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostProcessing::runTimePostProcessing Foam::functionObjects::runTimePostProcessing::runTimePostProcessing
@ -80,12 +121,6 @@ Foam::functionObjects::runTimePostProcessing::runTimePostProcessing
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostProcessing::~runTimePostProcessing()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict) bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
@ -101,7 +136,6 @@ bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
outputDict.readEntry("width", output_.width_); outputDict.readEntry("width", output_.width_);
outputDict.readEntry("height", output_.height_); outputDict.readEntry("height", output_.height_);
readObjects(dict.subOrEmptyDict("points"), points_); readObjects(dict.subOrEmptyDict("points"), points_);
readObjects(dict.subOrEmptyDict("lines"), lines_); readObjects(dict.subOrEmptyDict("lines"), lines_);
readObjects(dict.subOrEmptyDict("surfaces"), surfaces_); readObjects(dict.subOrEmptyDict("surfaces"), surfaces_);
@ -113,16 +147,19 @@ bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
if (!dEntry.isDict()) if (!dEntry.isDict())
{ {
FatalIOErrorInFunction(textDict) FatalIOErrorInFunction(textDict)
<< textDict.dictName()
<< "text must be specified in dictionary format" << "text must be specified in dictionary format"
<< exit(FatalIOError); << exit(FatalIOError);
} }
const dictionary& objectDict = dEntry.dict();
text_.append text_.append
( (
new runTimePostPro::text new runTimePostPro::text
( (
*this, *this,
dEntry.dict(), objectDict,
scene_.colours() scene_.colours()
) )
); );
@ -173,76 +210,27 @@ bool Foam::functionObjects::runTimePostProcessing::write()
renderWindow->AddRenderer(renderer); renderWindow->AddRenderer(renderer);
// Add the points
forAll(points_, i)
{
points_[i].addGeometryToScene(0, renderer);
}
// Add the lines addGeometryToScene(points_, 0, renderer);
forAll(lines_, i) addGeometryToScene(lines_, 0, renderer);
{ addGeometryToScene(surfaces_, 0, renderer);
lines_[i].addGeometryToScene(0, renderer); addGeometryToScene(text_, 0, renderer);
}
// Add the surfaces
forAll(surfaces_, i)
{
surfaces_[i].addGeometryToScene(0, renderer);
}
// Add the text
forAll(text_, i)
{
text_[i].addGeometryToScene(0, renderer);
}
while (scene_.loop(renderer)) while (scene_.loop(renderer))
{ {
scalar position = scene_.position(); const scalar position = scene_.position();
// Update the text updateActors(text_, position);
forAll(text_, i) updateActors(points_, position);
{ updateActors(lines_, position);
text_[i].updateActors(position); updateActors(surfaces_, position);
}
// Update the points
forAll(points_, i)
{
points_[i].updateActors(position);
}
// Update the lines
forAll(lines_, i)
{
lines_[i].updateActors(position);
}
// Update the surfaces
forAll(surfaces_, i)
{
surfaces_[i].updateActors(position);
}
} }
// Clean up // Cleanup
forAll(text_, i) cleanup(text_);
{ cleanup(points_);
text_[i].clear(); cleanup(lines_);
} cleanup(surfaces_);
forAll(points_, i)
{
points_[i].clear();
}
forAll(lines_, i)
{
lines_[i].clear();
}
forAll(surfaces_, i)
{
surfaces_[i].clear();
}
// Instead of relying on the destructor, manually restore the previous // Instead of relying on the destructor, manually restore the previous

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -21,8 +21,15 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Namespace
Foam::functionObjects::runTimePostPro
Description
Classes and objects used in the implementation of
Foam::functionObjects::runTimePostProcessing
Class Class
Foam::functionObjects::runTimePostPro::runTimePostProcessing Foam::functionObjects::runTimePostProcessing
Group Group
grpGraphicsFunctionObjects grpGraphicsFunctionObjects
@ -34,9 +41,9 @@ Description
which provide a broad set of functionality for scene composition and which provide a broad set of functionality for scene composition and
manipulation. manipulation.
Images are generated using a combination of function object output, and Images are generated using a combination of function object output
additional data e.gg triangulated surfaces and text. Current capabilities and additional data - eg, surfaces and text.
include support for: Current capabilities include support for:
- Camera - Camera
- Objects - Objects
- Points - Points
@ -45,6 +52,8 @@ Description
- Scalar bars - Scalar bars
- Annotations - Annotations
- Selection of colour maps - Selection of colour maps
.
Scene configuration is performed using standard OpenFOAM dictionaries, using Scene configuration is performed using standard OpenFOAM dictionaries, using
the main headings of: output=, camera, colours, points, lines, the main headings of: output=, camera, colours, points, lines,
surfaces and text. surfaces and text.
@ -65,6 +74,7 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkRenderer; class vtkRenderer;
class vtkRenderWindow; class vtkRenderWindow;
@ -74,10 +84,11 @@ namespace functionObjects
{ {
namespace runTimePostPro namespace runTimePostPro
{ {
class pointData; // Forward declarations
class pathline; class pointData;
class surface; class pathline;
class text; class surface;
class text;
} }
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -119,15 +130,11 @@ private:
PtrList<runTimePostPro::text> text_; PtrList<runTimePostPro::text> text_;
// Private Member Functions // Private Member Functions
//- Helper function to read scene objects //- Helper function to read scene objects
template<class Type> template<class Type>
void readObjects void readObjects(const dictionary& dict, PtrList<Type>& objects) const;
(
const dictionary& dict,
PtrList<Type>& objects
) const;
public: public:
@ -143,12 +150,12 @@ public:
( (
const word& name, const word& name,
const Time& runTime, const Time& runTime,
const dictionary&dict const dictionary& dict
); );
//- Destructor //- Destructor
virtual ~runTimePostProcessing(); virtual ~runTimePostProcessing() = default;
// Member Functions // Member Functions
@ -158,8 +165,8 @@ public:
return mesh_; return mesh_;
} }
//- Read the field min/max data //- Read the post-processing controls
virtual bool read(const dictionary&); virtual bool read(const dictionary& dict);
//- Execute, currently does nothing //- Execute, currently does nothing
virtual bool execute(); virtual bool execute();

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.

View File

@ -38,7 +38,6 @@ License
#include "vtkRenderWindow.h" #include "vtkRenderWindow.h"
#include "vtkWindowToImageFilter.h" #include "vtkWindowToImageFilter.h"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::functionObjects::runTimePostPro::scene::readCamera void Foam::functionObjects::runTimePostPro::scene::readCamera

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -70,6 +70,7 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkActor; class vtkActor;
class vtkRenderer; class vtkRenderer;
class vtkRenderWindow; class vtkRenderWindow;
@ -123,7 +124,7 @@ protected:
// Protected data // Protected data
//- Colours //- Colours
HashPtrTable<Function1<vector>, word> colours_; HashPtrTable<Function1<vector>> colours_;
// Camera settings // Camera settings
@ -197,26 +198,27 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Return the colours //- Return the colours
const HashPtrTable<Function1<vector>, word>& colours() const; const HashPtrTable<Function1<vector>>& colours() const;
//- Return the current frame index //- Return the current frame index
label frameIndex() const; label frameIndex() const;
//- Return the current position (in range 0-1) //- Return the current position (in range 0-1)
scalar position() const; scalar position() const;
void read(const dictionary& dict);
void initialise(vtkRenderer* renderer, const word& outputName); void read(const dictionary& dict);
//- Main control loop void initialise(vtkRenderer* renderer, const word& outputName);
bool loop(vtkRenderer* renderer);
//- Save image to file //- Main control loop
void saveImage(vtkRenderWindow* renderWindow) const; bool loop(vtkRenderer* renderer);
//- Save image to file
void saveImage(vtkRenderWindow* renderWindow) const;
}; };

View File

@ -83,7 +83,7 @@ void Foam::functionObjects::runTimePostPro::surface::setRepresentation
} }
case rtWireframe: case rtWireframe:
{ {
// note: colour is set using general SetColour, not setEdgeColor // note: colour is set using general SetColor, not SetEdgeColor
actor->GetProperty()->SetRepresentationToWireframe(); actor->GetProperty()->SetRepresentationToWireframe();
break; break;
} }
@ -143,7 +143,7 @@ Foam::functionObjects::runTimePostPro::surface::surface
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
geometryBase(parent, dict, colours), geometryBase(parent, dict, colours),
@ -163,10 +163,7 @@ Foam::functionObjects::runTimePostPro::surface::surface
if (dict.found("surfaceColour")) if (dict.found("surfaceColour"))
{ {
surfaceColour_.reset surfaceColour_.reset(Function1<vector>::New("surfaceColour", dict));
(
Function1<vector>::New("surfaceColour", dict).ptr()
);
} }
else else
{ {
@ -175,7 +172,7 @@ Foam::functionObjects::runTimePostPro::surface::surface
if (dict.found("edgeColour")) if (dict.found("edgeColour"))
{ {
edgeColour_.reset(Function1<vector>::New("edgeColour", dict).ptr()); edgeColour_.reset(Function1<vector>::New("edgeColour", dict));
} }
else else
{ {
@ -200,7 +197,7 @@ Foam::functionObjects::runTimePostPro::surface::New
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours, const HashPtrTable<Function1<vector>>& colours,
const word& surfaceType const word& surfaceType
) )
{ {

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,6 +25,7 @@ Class
Foam::functionObjects::runTimePostPro::surface Foam::functionObjects::runTimePostPro::surface
Description Description
Visualisation of surface data
SourceFiles SourceFiles
surface.C surface.C
@ -37,11 +38,11 @@ SourceFiles
#include "geometryBase.H" #include "geometryBase.H"
#include "Enum.H" #include "Enum.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "vtkSmartPointer.h" #include "vtkSmartPointer.h"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkActor; class vtkActor;
class vtkRenderer; class vtkRenderer;
class vtkPolyData; class vtkPolyData;
@ -77,17 +78,6 @@ public:
static const Enum<representationType> representationTypeNames; static const Enum<representationType> representationTypeNames;
private:
// Private Member Functions
//- No copy construct
surface(const surface&) = delete;
//- No copy assignment
void operator=(const surface&) = delete;
protected: protected:
// Protected data // Protected data
@ -126,6 +116,12 @@ protected:
vtkPolyData* data vtkPolyData* data
) const; ) const;
//- No copy construct
surface(const surface&) = delete;
//- No copy assignment
void operator=(const surface&) = delete;
public: public:
@ -143,7 +139,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
), ),
(parent, dict, colours) (parent, dict, colours)
); );
@ -156,7 +152,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );
@ -167,7 +163,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours, const HashPtrTable<Function1<vector>>& colours,
const word& surfaceName const word& surfaceName
); );

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,13 +34,28 @@ License
#include "vtkTextActor.h" #include "vtkTextActor.h"
#include "vtkTextProperty.h" #include "vtkTextProperty.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
const Foam::Enum
<
Foam::functionObjects::runTimePostPro::text::halignType
>
Foam::functionObjects::runTimePostPro::text::halignTypeNames
({
{ halignType::LEFT, "left" },
{ halignType::CENTER, "center" },
{ halignType::CENTER, "centre" },
{ halignType::RIGHT, "right" },
});
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::runTimePostPro::text::text Foam::functionObjects::runTimePostPro::text::text
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
) )
: :
geometryBase(parent, dict, colours), geometryBase(parent, dict, colours),
@ -48,14 +63,20 @@ Foam::functionObjects::runTimePostPro::text::text
position_(), position_(),
size_(dict.get<scalar>("size")), size_(dict.get<scalar>("size")),
colour_(nullptr), colour_(nullptr),
halign_
(
halignTypeNames.lookupOrDefault("halign", dict, halignType::LEFT)
),
bold_(dict.get<bool>("bold")), bold_(dict.get<bool>("bold")),
italic_(dict.lookupOrDefault("italic", false)),
shadow_(dict.lookupOrDefault("shadow", false)),
timeStamp_(dict.lookupOrDefault("timeStamp", false)) timeStamp_(dict.lookupOrDefault("timeStamp", false))
{ {
dict.readEntry("position", position_); dict.readEntry("position", position_);
if (dict.found("colour")) if (dict.found("colour"))
{ {
colour_.reset(Function1<vector>::New("colour", dict).ptr()); colour_.reset(Function1<vector>::New("colour", dict));
} }
else else
{ {
@ -86,21 +107,28 @@ void Foam::functionObjects::runTimePostPro::text::addGeometryToScene
auto actor = vtkSmartPointer<vtkTextActor>::New(); auto actor = vtkSmartPointer<vtkTextActor>::New();
// Concatenate string with timeStamp if true // Concatenate string with timeStamp if true
string textAndTime = string_; string str = string_;
if (timeStamp_) if (timeStamp_)
{ {
textAndTime = str += " " + geometryBase::parent_.mesh().time().timeName();
textAndTime + " " + geometryBase::parent_.mesh().time().timeName();
} }
actor->SetInput(textAndTime.c_str()); actor->SetInput(str.c_str());
actor->GetTextProperty()->SetFontFamilyToArial();
actor->GetTextProperty()->SetFontSize(size_); vtkTextProperty* prop = actor->GetTextProperty();
actor->GetTextProperty()->SetJustificationToLeft();
actor->GetTextProperty()->SetVerticalJustificationToBottom(); prop->SetFontFamilyToArial();
actor->GetTextProperty()->SetBold(bold_); prop->SetFontSize(size_);
prop->SetJustification(int(halign_));
prop->SetVerticalJustificationToBottom();
prop->SetBold(bold_);
prop->SetItalic(italic_);
prop->SetShadow(shadow_);
const vector colour = colour_->value(position); const vector colour = colour_->value(position);
actor->GetTextProperty()->SetColor(colour[0], colour[1], colour[2]);
prop->SetColor(colour[0], colour[1], colour[2]);
prop->SetOpacity(opacity(position));
actor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); actor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
actor->GetPositionCoordinate()->SetValue actor->GetPositionCoordinate()->SetValue
( (

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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,6 +25,8 @@ Class
Foam::functionObjects::runTimePostPro::text Foam::functionObjects::runTimePostPro::text
Description Description
Define text element for runTimePostProcessing
Example of text object specification: Example of text object specification:
\verbatim \verbatim
text1 text1
@ -32,17 +34,42 @@ Description
string "text to display"; string "text to display";
position (0.1 0.05); position (0.1 0.05);
size 18; size 18;
// halign left; // (left | centre | right)
bold yes; bold yes;
// Optional entry
shadow false;
visible yes; visible yes;
// Optionally override default colour // Optionally override default colour
// colour (0 1 1); // colour (0 1 1);
// Optional entry // Optional entry
timeStamp yes; //Append solution time to string timeStamp yes; // Append solution time to string
} }
\endverbatim \endverbatim
Dictionary controls
\table
Property | Description | Required | Default
string | Text to display | yes |
position | The (x y) viewport position | yes |
size | The font size in points | yes |
halign | Text justification (left/centre/ right) | no | left
bold | Use bold font | yes |
italic | Use italic font | no | false
shadow | Add text shadow | no | false
colour | Override default text colour | no |
timeStamp | Append solution timeName to string | no | false
\endtable
Inherited controls
\table
Property | Description | Required | Default
visible | Display the object | yes |
opacity | Object opacity | no | 1.0
\endtable
SourceFiles SourceFiles
text.C text.C
@ -56,6 +83,7 @@ SourceFiles
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declarations
class vtkRenderer; class vtkRenderer;
namespace Foam namespace Foam
@ -73,20 +101,25 @@ class text
: :
public geometryBase public geometryBase
{ {
private: public:
// Private Member Functions // Public enumerations
//- No copy construct //- Horizontal alignment type
text(const text&) = delete; enum halignType
{
LEFT = 0, //!< Left-justified text - default ("left")
CENTER = 1, //!< Centred text ("center", "centre")
RIGHT = 2 //!< Right-justified text ("right")
};
//- No copy assignment //- Horizontal alignment names (includes "center" and "centre")
void operator=(const text&) = delete; static const Enum<halignType> halignTypeNames;
protected: protected:
// Protected data // Protected Data
//- Text //- Text
string string_; string string_;
@ -100,13 +133,31 @@ protected:
//- Colour //- Colour
autoPtr<Function1<vector>> colour_; autoPtr<Function1<vector>> colour_;
//- Horizontal alignment
halignType halign_;
//- Bold flag //- Bold flag
bool bold_; bool bold_;
//- Italic flag
bool italic_;
//- Shadow flag
bool shadow_;
//- Time stamp flag //- Time stamp flag
bool timeStamp_; bool timeStamp_;
// Protected Member Functions
//- No copy construct
text(const text&) = delete;
//- No copy assignment
void operator=(const text&) = delete;
public: public:
// Constructors // Constructors
@ -116,7 +167,7 @@ public:
( (
const runTimePostProcessing& parent, const runTimePostProcessing& parent,
const dictionary& dict, const dictionary& dict,
const HashPtrTable<Function1<vector>, word>& colours const HashPtrTable<Function1<vector>>& colours
); );

Some files were not shown because too many files have changed in this diff Show More