From 455c8ef540ee8b45aa4bf57eb3679be55bd7833f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 15 Dec 2018 13:26:55 +0100 Subject: [PATCH 01/16] ENH: simplify use of case-relative paths - provide relativePath() for argList and for Time. These are relative to the case globalPath(). Eg, Info<< "output: " << runTime.relativePath(outputFile) << nl; --- applications/test/argList/Test-argList.C | 23 ++- .../test/timeSelector/Test-timeSelector.C | 22 ++- .../foamToVTK/convertLagrangian.H | 2 +- .../foamToVTK/convertSurfaceFields.H | 4 +- .../dataConversion/foamToVTK/convertTopoSet.H | 4 +- .../foamToVTK/convertVolumeFields.H | 6 +- .../dataConversion/foamToVTK/foamToVTK.C | 2 +- .../surfaceFeatureExtract.C | 3 +- src/OpenFOAM/db/IOobject/IOobjectIO.C | 11 +- src/OpenFOAM/db/Time/TimePaths.C | 22 --- src/OpenFOAM/db/Time/TimePaths.H | 104 ++++++-------- src/OpenFOAM/db/Time/TimePathsI.H | 132 ++++++++++++++++++ src/OpenFOAM/db/Time/TimeStateI.H | 1 - src/OpenFOAM/global/argList/argList.H | 13 ++ src/OpenFOAM/global/argList/argListI.H | 10 ++ src/OpenFOAM/include/foamVersion.H | 2 +- .../primitives/strings/fileName/fileName.C | 6 +- .../primitives/strings/fileName/fileName.H | 4 +- .../field/streamLine/streamLineBase.C | 4 +- .../lagrangian/dataCloud/dataCloud.C | 2 +- .../lagrangian/vtkCloud/vtkCloud.C | 7 +- .../utilities/vtkWrite/vtkWrite.C | 6 +- .../sampledSets/sampledSetsTemplates.C | 5 +- .../sampledSurfacesTemplates.C | 10 +- 24 files changed, 271 insertions(+), 134 deletions(-) create mode 100644 src/OpenFOAM/db/Time/TimePathsI.H diff --git a/applications/test/argList/Test-argList.C b/applications/test/argList/Test-argList.C index adb36e3835..c882b85520 100644 --- a/applications/test/argList/Test-argList.C +++ b/applications/test/argList/Test-argList.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,11 +38,13 @@ using namespace Foam; int main(int argc, char *argv[]) { argList::noBanner(); - argList::noParallel(); + argList::noCheckProcessorDirectories(); // parallel OK, but without checks + // argList::noFunctionObjects(); argList::addOption("label", "value", "Test parsing of label"); argList::addOption("scalar", "value", "Test parsing of scalar"); argList::addOption("string", "value", "Test string lookup"); + argList::addOption("relative", "PATH", "Test relativePath"); // These are actually lies (never had -parseLabel, -parseScalar etc), // but good for testing... @@ -70,20 +72,27 @@ int main(int argc, char *argv[]) argList::addArgument("label"); argList::noMandatoryArgs(); - argList args(argc, argv); + #include "setRootCase.H" - Info<< "command-line (" + Pout<< "command-line (" << args.options().size() << " options, " << args.args().size() << " args)" << nl << " " << args.commandLine().c_str() << nl << nl; - Info<< "rootPath: " << args.rootPath() << nl + Pout<< "rootPath: " << args.rootPath() << nl << "globalCase: " << args.globalCaseName() << nl << "globalPath: " << args.globalPath() << nl << nl; - Info<<"have: " - < timePaths; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertLagrangian.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertLagrangian.H index 9a2596b826..2719ccc85a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertLagrangian.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertLagrangian.H @@ -94,7 +94,7 @@ if (doLagrangian) ); Info<< " Lagrangian: " - << writer.output().relative(runTime.globalPath()) << nl; + << runTime.relativePath(writer.output()) << nl; writer.writeTimeValue(mesh.time().value()); writer.writeGeometry(); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertSurfaceFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertSurfaceFields.H index 75c7fb171e..5ab48ff99d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertSurfaceFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertSurfaceFields.H @@ -107,7 +107,7 @@ Description ); Info<< " Surface : " - << writer.output().relative(runTime.globalPath()) << nl; + << runTime.relativePath(writer.output()) << nl; writer.writeTimeValue(timeValue); @@ -211,7 +211,7 @@ Description ); Info<< " FaceZone : " - << writer.output().relative(runTime.globalPath()) << nl; + << runTime.relativePath(writer.output()) << nl; writer.beginFile(fz.name()); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertTopoSet.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertTopoSet.H index 49111ea890..e2a96e898f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertTopoSet.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertTopoSet.H @@ -42,7 +42,7 @@ if (faceSetName.size()) ); Info<< " faceSet : " - << outputName.relative(runTime.globalPath()) << nl; + << runTime.relativePath(outputName) << nl; vtk::writeFaceSet ( @@ -70,7 +70,7 @@ if (pointSetName.size()) ); Info<< " pointSet : " - << outputName.relative(runTime.globalPath()) << nl; + << runTime.relativePath(outputName) << nl; vtk::writePointSet ( diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H index ad8802f6a6..763b3fa3d9 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H @@ -113,7 +113,7 @@ Description ); Info<< " Internal : " - << internalWriter->output().relative(runTime.globalPath()) << nl; + << runTime.relativePath(internalWriter->output()) << nl; internalWriter->writeTimeValue(mesh.time().value()); internalWriter->writeGeometry(); @@ -163,7 +163,7 @@ Description ); Info<< " Boundaries: " - << writer->output().relative(runTime.globalPath()) << nl; + << runTime.relativePath(writer->output()) << nl; writer->writeTimeValue(timeValue); writer->writeGeometry(); @@ -229,7 +229,7 @@ Description ); Info<< " Boundary : " - << writer->output().relative(runTime.globalPath()) << nl; + << runTime.relativePath(writer->output()) << nl; writer->writeTimeValue(timeValue); writer->writeGeometry(); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 7c743c1619..b584822c21 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -650,7 +650,7 @@ int main(int argc, char *argv[]) if (args.found("overwrite") && isDir(regionDir)) { Info<< "Removing old directory " - << regionDir.relative(runTime.globalPath()) + << runTime.relativePath(regionDir) << nl << endl; rmDir(regionDir); } diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 0c2f9c06fb..344bd2a58d 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -693,8 +693,7 @@ int main(int argc, char *argv[]) vtkWriter->writeGeometry(); Info<< "Writing VTK to " - << ((vtkOutputDir/outputName).ext(vtkWriter->ext())) - .relative(runTime.globalPath()) << nl; + << runTime.relativePath(vtkWriter->output()) << nl; } } else diff --git a/src/OpenFOAM/db/IOobject/IOobjectIO.C b/src/OpenFOAM/db/IOobject/IOobjectIO.C index d1a51dddb5..217ca84fff 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectIO.C +++ b/src/OpenFOAM/db/IOobject/IOobjectIO.C @@ -35,11 +35,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy& ip) os << "IOobject: " << io.type() << token::SPACE - << io.name() << token::SPACE - << "readOpt:" << token::SPACE << io.readOpt() << token::SPACE - << "writeOpt:" << token::SPACE << io.writeOpt() << token::SPACE - << "globalObject:" << token::SPACE << io.globalObject() << token::SPACE - << io.path() << endl; + << io.name() + << " local: " << io.local() + << " readOpt: " << io.readOpt() + << " writeOpt: " << io.writeOpt() + << " globalObject: " << io.globalObject() + << token::SPACE << io.path() << endl; return os; } diff --git a/src/OpenFOAM/db/Time/TimePaths.C b/src/OpenFOAM/db/Time/TimePaths.C index 78378463ab..4ef6c8d448 100644 --- a/src/OpenFOAM/db/Time/TimePaths.C +++ b/src/OpenFOAM/db/Time/TimePaths.C @@ -133,28 +133,6 @@ Foam::TimePaths::TimePaths // * * * * * * * * * * * * * * * 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 ( const fileName& directory, diff --git a/src/OpenFOAM/db/Time/TimePaths.H b/src/OpenFOAM/db/Time/TimePaths.H index 55b6901d24..94036dfcc4 100644 --- a/src/OpenFOAM/db/Time/TimePaths.H +++ b/src/OpenFOAM/db/Time/TimePaths.H @@ -108,86 +108,64 @@ public: // 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 - bool processorCase() const - { - return processorCase_; - } + inline bool processorCase() const; //- Return root path - const fileName& rootPath() const - { - return rootPath_; - } + inline const fileName& rootPath() const; //- Return global case name - const fileName& globalCaseName() const - { - return globalCaseName_; - } + inline const fileName& globalCaseName() const; //- Return case name - const fileName& caseName() const - { - return case_; - } + inline const fileName& caseName() const; - //- Return case name - fileName& caseName() - { - return case_; - } + //- The case name for modification (use with caution) + inline fileName& caseName(); - //- Return system name - const word& system() const - { - return system_; - } + //- Return path for the case + inline fileName path() const; + + //- 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 \ for later + // use with expand(), or prefix \ 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 - const word& constant() const - { - return constant_; - } + inline const word& constant() const; - //- Is case running with parallel distributed directories - // (i.e. not NFS mounted) - bool distributed() const - { - return distributed_; - } + //- Return system name + inline const word& system() const; //- Return the constant name for the case, which is //- \c ../constant() for parallel runs. - fileName caseConstant() const; + inline fileName caseConstant() const; - //- Return path for the case - fileName path() 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 the system name for the case, which is + //- \c ../system() for parallel runs. + inline fileName caseSystem() const; //- Return constant path - fileName constantPath() const - { - return path()/constant(); - } + inline fileName constantPath() const; + + //- Return system path + inline fileName systemPath() const; // Searching @@ -223,6 +201,10 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "TimePathsI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/OpenFOAM/db/Time/TimePathsI.H b/src/OpenFOAM/db/Time/TimePathsI.H new file mode 100644 index 0000000000..d6f5b3f69a --- /dev/null +++ b/src/OpenFOAM/db/Time/TimePathsI.H @@ -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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * 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(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/Time/TimeStateI.H b/src/OpenFOAM/db/Time/TimeStateI.H index bb572c776a..39fb8b331a 100644 --- a/src/OpenFOAM/db/Time/TimeStateI.H +++ b/src/OpenFOAM/db/Time/TimeStateI.H @@ -25,7 +25,6 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - inline Foam::scalar Foam::TimeState::timeOutputValue() const { return timeToUserTime(value()); diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index 9c6637ee3e..379c6617d2 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -304,6 +304,19 @@ public: // \note This is guaranteed to be an absolute path 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 \ for later + // use with expand(), or prefix \ if the file name was + // not an absolute location + inline fileName relativePath + ( + const fileName& input, + const bool caseTag = false + ) const; + //- Return distributed flag //- (i.e. are rootPaths different on different machines) inline bool distributed() const; diff --git a/src/OpenFOAM/global/argList/argListI.H b/src/OpenFOAM/global/argList/argListI.H index b7e3915b47..a01e7a4413 100644 --- a/src/OpenFOAM/global/argList/argListI.H +++ b/src/OpenFOAM/global/argList/argListI.H @@ -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 { return parRunControl_.distributed(); diff --git a/src/OpenFOAM/include/foamVersion.H b/src/OpenFOAM/include/foamVersion.H index 5f521bebb0..21265e36ee 100644 --- a/src/OpenFOAM/include/foamVersion.H +++ b/src/OpenFOAM/include/foamVersion.H @@ -96,7 +96,7 @@ namespace Foam //- OpenFOAM version (name or stringified number) as a std::string 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). bool patched(); diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index 1ef148b3e7..f7154ea106 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -367,7 +367,7 @@ std::string Foam::fileName::nameLessExt(const std::string& str) Foam::fileName Foam::fileName::relative ( const fileName& parent, - const bool caseRelative + const bool caseTag ) const { const auto top = parent.size(); @@ -383,7 +383,7 @@ Foam::fileName Foam::fileName::relative && f.startsWith(parent) ) { - if (caseRelative) + if (caseTag) { return ""/f.substr(top+1); } @@ -392,7 +392,7 @@ Foam::fileName Foam::fileName::relative return f.substr(top+1); } } - else if (caseRelative && f.size() && !f.isAbsolute()) + else if (caseTag && f.size() && !f.isAbsolute()) { return ""/f; } diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index c760d1956f..f082a8bbc5 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -294,13 +294,13 @@ public: //- where possible. // // \param parent the parent directory - // \param caseRelative replace the parent with \ for later + // \param caseTag replace the parent with \ for later // use with expand(), or prefix \ if the file name was // not an absolute location fileName relative ( const fileName& parent, - const bool caseRelative = false + const bool caseTag = false ) const; //- Return file name without extension (part before last .) diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C index 8806a14ee7..470c37b787 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.C +++ b/src/functionObjects/field/streamLine/streamLineBase.C @@ -786,7 +786,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile() propsDict.add ( "file", - scalarVtkFile.relative(time_.globalPath(), true) + time_.relativePath(scalarVtkFile, true) ); setProperty(fieldName, propsDict); } @@ -798,7 +798,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile() propsDict.add ( "file", - vectorVtkFile.relative(time_.globalPath(), true) + time_.relativePath(vectorVtkFile, true) ); setProperty(fieldName, propsDict); } diff --git a/src/functionObjects/lagrangian/dataCloud/dataCloud.C b/src/functionObjects/lagrangian/dataCloud/dataCloud.C index bf303c92a3..f7327c9165 100644 --- a/src/functionObjects/lagrangian/dataCloud/dataCloud.C +++ b/src/functionObjects/lagrangian/dataCloud/dataCloud.C @@ -238,7 +238,7 @@ bool Foam::functionObjects::dataCloud::write() if (writeCloud(outputName, cloudName)) { Log << " cloud : " - << outputName.relative(time_.globalPath()) << endl; + << time_.relativePath(outputName) << endl; } } diff --git a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C index 6bec0a8aa4..40887680c3 100644 --- a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C +++ b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C @@ -318,13 +318,12 @@ bool Foam::functionObjects::vtkCloud::writeCloud // } // } - // Shorten file name to be case-local and use "" shortcut - // to make the content relocatable + // Case-local file name with "" to make relocatable dictionary propsDict; propsDict.add ( "file", - file.relative(time_.globalPath(), true) + time_.relativePath(file, true) ); propsDict.add("fields", written); @@ -503,7 +502,7 @@ bool Foam::functionObjects::vtkCloud::write() if (writeCloud(outputName, cloudName)) { Log << " cloud : " - << outputName.relative(time_.globalPath()) << endl; + << time_.relativePath(outputName) << endl; if (Pstream::master()) { diff --git a/src/functionObjects/utilities/vtkWrite/vtkWrite.C b/src/functionObjects/utilities/vtkWrite/vtkWrite.C index dfc6ad1fb0..11aed86354 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWrite.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWrite.C @@ -380,7 +380,7 @@ bool Foam::functionObjects::vtkWrite::write() ); Info<< " Internal : " - << internalWriter->output().relative(time_.globalPath()) + << time_.relativePath(internalWriter->output()) << endl; // No sub-block for internal @@ -432,7 +432,7 @@ bool Foam::functionObjects::vtkWrite::write() ); Info<< " Boundaries: " - << writer->output().relative(time_.globalPath()) << nl; + << time_.relativePath(writer->output()) << nl; writer->writeTimeValue(timeValue); @@ -497,7 +497,7 @@ bool Foam::functionObjects::vtkWrite::write() ); Info<< " Boundary : " - << writer->output().relative(time_.globalPath()) << nl; + << time_.relativePath(writer->output()) << nl; writer->writeTimeValue(timeValue); writer->writeGeometry(); diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 9fef162add..c8855bf828 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -338,8 +338,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup& fields) Pstream::scatter(sampleFile); if (sampleFile.size()) { - // Shorten file name to be case-local and use "" shortcut - // to make the content relocatable + // Case-local file name with "" to make relocatable forAll(masterFields, fieldi) { @@ -347,7 +346,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup& fields) propsDict.add ( "file", - sampleFile.relative(time_.globalPath(), true) + time_.relativePath(sampleFile, true) ); const word& fieldName = masterFields[fieldi].name(); diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index 3976bde6f7..5a028345af 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -95,14 +95,13 @@ void Foam::sampledSurfaces::writeSurface Pstream::scatter(sampleFile); if (sampleFile.size()) { - // Shorten file name to be case-local and use "" shortcut - // to make the content relocatable + // Case-local file name with "" to make relocatable dictionary propsDict; propsDict.add ( "file", - sampleFile.relative(time_.globalPath(), true) + time_.relativePath(sampleFile, true) ); setProperty(fieldName, propsDict); } @@ -123,14 +122,13 @@ void Foam::sampledSurfaces::writeSurface s.interpolate() ); - // Case-local filename and "" shortcut for readable output - // and for possibly relocation of files + // Case-local file name with "" to make relocatable dictionary propsDict; propsDict.add ( "file", - fName.relative(time_.globalPath(), true) + time_.relativePath(fName, true) ); setProperty(fieldName, propsDict); } From 9076f5b21bd78f83f496e7f829e708305b67a58d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 15 Dec 2018 14:39:12 +0100 Subject: [PATCH 02/16] ENH: provide argList::envGlobalPath() static method - this is identical to either of these solutions: * getEnv("FOAM_CASE") * stringOps::expand("") but with a closer resemblance to argList or Time globalPath(), which makes the intent clearer. Avoids using raw strings in the caller, which improves compile-time checks. Used in situations where a class has no derivation path or other access to a time registry or command args. --- .../db/dynamicLibrary/dynamicCode/dynamicCode.C | 13 +++++++------ src/OpenFOAM/global/argList/argList.C | 8 ++++++++ src/OpenFOAM/global/argList/argList.H | 12 ++++++++++++ .../utilities/systemCall/systemCall.C | 10 +++++++++- .../noise/noiseModels/noiseModel/noiseModel.C | 4 ++-- .../noise/noiseModels/pointNoise/pointNoise.C | 5 ++--- .../noise/noiseModels/surfaceNoise/surfaceNoise.C | 5 ++--- .../boundaryData/boundaryDataSurfaceWriter.C | 3 ++- .../boundaryData/boundaryDataSurfaceWriterImpl.C | 2 +- 9 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C index 422d0687a6..1a2d068749 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C @@ -25,6 +25,7 @@ License #include "dynamicCode.H" #include "dynamicCodeContext.H" +#include "argList.H" #include "stringOps.H" #include "Fstream.H" #include "IOstreams.H" @@ -64,10 +65,10 @@ void Foam::dynamicCode::checkSecurity if (isAdministrator()) { FatalIOErrorInFunction(dict) - << "This code should not be executed by someone with administrator" - << " rights due to security reasons." << nl - << "(it writes a shared library which then gets loaded " - << "using dlopen)" + << "This code should not be executed by someone" + << " with administrator rights for security reasons." << nl + << "It generates a shared library which is loaded using dlopen" + << nl << endl << exit(FatalIOError); } @@ -292,8 +293,8 @@ bool Foam::dynamicCode::writeDigest(const std::string& sha1) const Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName) : - codeRoot_(stringOps::expand("")/topDirName), - libSubDir_(stringOps::expand("platforms/$WM_OPTIONS/lib")), + codeRoot_(argList::envGlobalPath()/topDirName), + libSubDir_(stringOps::expand("platforms/${WM_OPTIONS}/lib")), codeName_(codeName), codeDirName_(codeDirName) { diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index f06b9cfc1e..f7c622e746 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -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 * * * * * * * * * * * // Foam::word Foam::argList::optionCompat(const word& optName) diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index 379c6617d2..e569e02e52 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -272,6 +272,18 @@ public: // 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 //- Scan for -help, -doc options etc prior to checking the validity diff --git a/src/functionObjects/utilities/systemCall/systemCall.C b/src/functionObjects/utilities/systemCall/systemCall.C index 0b19fda5e3..3e54b1d04f 100644 --- a/src/functionObjects/utilities/systemCall/systemCall.C +++ b/src/functionObjects/utilities/systemCall/systemCall.C @@ -114,9 +114,17 @@ bool Foam::functionObjects::systemCall::read(const dictionary& dict) if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty()) { WarningInFunction - << "no executeCalls, endCalls or writeCalls defined." + << "No executeCalls, endCalls or writeCalls defined." << endl; } + else if (isAdministrator()) + { + FatalErrorInFunction + << "System calls should not be executed by someone" + << " with administrator rights for security reasons." << nl + << nl << endl + << exit(FatalError); + } else if (!dynamicCode::allowSystemOperations) { FatalErrorInFunction diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C index 1104fabc3f..6a4272a423 100644 --- a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C @@ -25,7 +25,7 @@ License #include "noiseModel.H" #include "functionObject.H" -#include "stringOps.H" +#include "argList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -143,7 +143,7 @@ Foam::fileName Foam::noiseModel::baseFileDir(const label dataseti) const { return ( - stringOps::expand("") // ie, globalPath() + argList::envGlobalPath() / functionObject::outputPrefix / "noise" / outputPrefix_ diff --git a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C index c5474aee3b..3e0c491292 100644 --- a/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C +++ b/src/randomProcesses/noise/noiseModels/pointNoise/pointNoise.C @@ -25,7 +25,7 @@ License #include "pointNoise.H" #include "noiseFFT.H" -#include "stringOps.H" +#include "argList.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -244,8 +244,7 @@ void pointNoise::calculate() if (!fName.isAbsolute()) { - // ie, globalPath() / name - fName = stringOps::expand("")/fName; + fName = argList::envGlobalPath()/fName; } Function1Types::CSV data("pressure", dict_, fName); diff --git a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C index a60902aafb..d53c0c9b9f 100644 --- a/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C +++ b/src/randomProcesses/noise/noiseModels/surfaceNoise/surfaceNoise.C @@ -27,8 +27,8 @@ License #include "surfaceReader.H" #include "surfaceWriter.H" #include "noiseFFT.H" +#include "argList.H" #include "graph.H" -#include "stringOps.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -465,8 +465,7 @@ void surfaceNoise::calculate() if (!fName.isAbsolute()) { - // ie, globalPath() / name - fName = stringOps::expand("")/fName; + fName = argList::envGlobalPath()/fName; } initialise(fName); diff --git a/src/sampling/sampledSurface/writers/boundaryData/boundaryDataSurfaceWriter.C b/src/sampling/sampledSurface/writers/boundaryData/boundaryDataSurfaceWriter.C index 15cf1d3ee7..8456d61912 100644 --- a/src/sampling/sampledSurface/writers/boundaryData/boundaryDataSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/boundaryData/boundaryDataSurfaceWriter.C @@ -25,6 +25,7 @@ License #include "boundaryDataSurfaceWriter.H" #include "makeSurfaceWriterMethods.H" +#include "argList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -62,7 +63,7 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::write const pointField& points = surf.points(); // Dummy time to use as an objectRegistry - const fileName caseDir(getEnv("FOAM_CASE")); + const fileName caseDir(argList::envGlobalPath()); Time dummyTime ( diff --git a/src/sampling/sampledSurface/writers/boundaryData/boundaryDataSurfaceWriterImpl.C b/src/sampling/sampledSurface/writers/boundaryData/boundaryDataSurfaceWriterImpl.C index 14f1545e22..d774e7f1be 100644 --- a/src/sampling/sampledSurface/writers/boundaryData/boundaryDataSurfaceWriterImpl.C +++ b/src/sampling/sampledSurface/writers/boundaryData/boundaryDataSurfaceWriterImpl.C @@ -54,7 +54,7 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::writeTemplate const faceList& faces = surf.faces(); // Dummy time to use as an objectRegistry - const fileName caseDir(getEnv("FOAM_CASE")); + const fileName caseDir(argList::envGlobalPath()); Time dummyTime ( From dd2c7c489472e8d24fd45107535fddca4bd252c5 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 15 Dec 2018 15:49:48 +0100 Subject: [PATCH 03/16] ENH: add wmakeVersioned with tracking of ThirdParty dependencies - primarily for handling cmake replacement libraries --- wmake/scripts/cmakeFunctions | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/wmake/scripts/cmakeFunctions b/wmake/scripts/cmakeFunctions index a1b9e5e5d1..877d81f140 100644 --- a/wmake/scripts/cmakeFunctions +++ b/wmake/scripts/cmakeFunctions @@ -124,4 +124,31 @@ cmakeVersionedInstall() } +# wmake with tracking of external dependency as per cmakeVersioned +# - use sentinel file(s) to handle paraview/vtk version changes +# +# 1 - depend +# 2 - sourceDir +# 3... wmake arguments +# +wmakeVersioned() +{ + local depend="$1" + local sourceDir="$2" + shift 2 + local objectsDir sentinel + + # Where generated files are stored + objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal + + # Version changed + sentinel=$(sameDependency "$depend" "$sourceDir") || \ + rm -rf "$objectsDir" > /dev/null 2>&1 + + mkdir -p "$objectsDir" \ + && wmake "$@" \ + && echo "$depend" >| "${sentinel:-/dev/null}" +} + + #------------------------------------------------------------------------------ From d1caaa052907da3081f1b76a84a5e53688c56e74 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 15 Dec 2018 18:08:51 +0100 Subject: [PATCH 04/16] ENH: build dummy runTimePostProcessing if VTK/ParaView are not available - this allows more use of the runTimePostProcessing functionObject that will fail more gracefully if the proper version could not be built. The dummy functionObject simply emits a message that it is not available. --- .../functionObject/functionObject.C | 55 +++++++++--- .../functionObject/functionObject.H | 53 +++++++++--- .../graphics/runTimePostProcessing/Allwclean | 6 +- .../graphics/runTimePostProcessing/Allwmake | 43 ++++++---- .../runTimePostProcessing/dummy/Make/files | 3 + .../runTimePostProcessing/dummy/Make/options | 2 + .../dummy/runTimePostProcessingDummy.C | 67 +++++++++++++++ .../dummy/runTimePostProcessingDummy.H | 85 +++++++++++++++++++ .../runTimePostProcessing.C | 8 +- .../runTimePostProcessing.H | 22 ++--- .../RAS/elipsekkLOmega/system/controlDict | 4 +- 11 files changed, 284 insertions(+), 64 deletions(-) create mode 100644 src/functionObjects/graphics/runTimePostProcessing/dummy/Make/files create mode 100644 src/functionObjects/graphics/runTimePostProcessing/dummy/Make/options create mode 100644 src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.C create mode 100644 src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.H diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index a3a3b42db4..2c4c866ba5 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -40,6 +40,7 @@ bool Foam::functionObject::postProcess(false); Foam::word Foam::functionObject::outputPrefix("postProcessing"); + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // Foam::word Foam::functionObject::scopedName(const word& name) const @@ -68,10 +69,9 @@ Foam::autoPtr Foam::functionObject::New { const word functionType(dict.get("type")); - if (debug) - { - Info<< "Selecting function " << functionType << endl; - } + DebugInfo + << "Selecting function " << functionType << endl; + // Load any additional libraries { @@ -122,12 +122,6 @@ Foam::autoPtr Foam::functionObject::New } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObject::~functionObject() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::word& Foam::functionObject::name() const @@ -179,4 +173,45 @@ void Foam::functionObject::movePoints(const polyMesh&) {} +// * * * * * * * * * * * * unavailableFunctionObject * * * * * * * * * * * * // + +Foam::functionObject::unavailableFunctionObject::unavailableFunctionObject +( + const word& name +) +: + functionObject(name) +{} + + +void Foam::functionObject::unavailableFunctionObject::carp(std::string message) +{ + 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; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 6cf20b4d47..1a7b17c070 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -127,7 +127,7 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class Time; class polyMesh; class mapPolyMesh; @@ -144,15 +144,6 @@ class functionObject const word name_; - // Private Member Functions - - //- No copy construct - functionObject(const functionObject&) = delete; - - //- No copy assignment - void operator=(const functionObject&) = delete; - - protected: // Protected Member Functions @@ -163,6 +154,9 @@ protected: public: + // Forward declarations + class unavailableFunctionObject; + //- Runtime type information virtual const word& type() const = 0; @@ -209,13 +203,13 @@ public: static autoPtr New ( const word& name, - const Time&, - const dictionary& + const Time& runTime, + const dictionary& dict ); //- Destructor - virtual ~functionObject(); + virtual ~functionObject() = default; // Member Functions @@ -243,7 +237,7 @@ public: virtual bool write() = 0; //- 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(); //- 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 = ""); + + +public: + + // Member Functions + + //- No nothing + virtual bool execute(); + + //- No nothing + virtual bool write(); +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwclean b/src/functionObjects/graphics/runTimePostProcessing/Allwclean index e3340097cf..140edc4bd1 100755 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwclean +++ b/src/functionObjects/graphics/runTimePostProcessing/Allwclean @@ -2,10 +2,12 @@ cd ${0%/*} || exit 1 # Run from this directory . $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 # Cleanup generated files - remove entire top-level -removeObjectDir $PWD +removeObjectDir "$PWD" #------------------------------------------------------------------------------ diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwmake b/src/functionObjects/graphics/runTimePostProcessing/Allwmake index a0321c849b..dc55737109 100755 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwmake +++ b/src/functionObjects/graphics/runTimePostProcessing/Allwmake @@ -6,9 +6,9 @@ cd ${0%/*} || exit 1 # Run from this directory echo "======================================================================" echo "${PWD##*/} : $PWD" -echo unset depend + if [ -d "$VTK_DIR" ] then depend="VTK_DIR=$VTK_DIR" @@ -17,25 +17,36 @@ then depend="ParaView_DIR=$ParaView_DIR" fi -if [ -n "$depend" ] +# Or force use of dummy only +# unset depend + +if [ "$targetType" = objects ] then - if [ "$targetType" != objects ] + depend=ignore +elif [ -n "$depend" ] +then + if command -v cmake > /dev/null 2>&1 then - if command -v cmake > /dev/null 2>&1 - then - cmakeVersioned "$depend" $PWD || { - echo - echo " WARNING: incomplete build of VTK-based post-processing" - echo - } - else - echo "WARNING: skipped - needs cmake" - fi + cmakeVersioned "$depend" $PWD || { + echo + echo " WARNING: incomplete build of VTK-based post-processing" + echo + depend="dummy" + } + else + echo "==> skip runTimePostProcessing (needs cmake)" + depend="dummy" fi else - echo "WARNING: skipped - needs a VTK or a ParaView installation" - echo " - For ParaView : export the 'ParaView_DIR' variable" - echo " - For VTK : export the 'VTK_DIR' variable" + echo "WARNING: skip runTimePostProcessing (no VTK or ParaView)" + echo " - ParaView : export the 'ParaView_DIR' variable" + echo " - VTK : export the 'VTK_DIR' variable" +fi + +if [ "${depend:-dummy}" = dummy ] +then + echo "==> dummy runTimePostProcessing" + wmakeVersioned "vtk=dummy" $PWD dummy fi echo "======================================================================" diff --git a/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/files b/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/files new file mode 100644 index 0000000000..33685ca6e5 --- /dev/null +++ b/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/files @@ -0,0 +1,3 @@ +runTimePostProcessingDummy.C + +LIB = $(FOAM_LIBBIN)/librunTimePostProcessing diff --git a/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/options b/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/options new file mode 100644 index 0000000000..6b8588463d --- /dev/null +++ b/src/functionObjects/graphics/runTimePostProcessing/dummy/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* LIB_LIBS = */ diff --git a/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.C b/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.C new file mode 100644 index 0000000000..51f02faa8a --- /dev/null +++ b/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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" + ); +} + + +// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.H b/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.H new file mode 100644 index 0000000000..b71e771351 --- /dev/null +++ b/src/functionObjects/graphics/runTimePostProcessing/dummy/runTimePostProcessingDummy.H @@ -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 . + +Class + Foam::functionObjects::runTimePostPro::runTimePostProcessingDummy + +Group + grpGraphicsFunctionObjects + +Description + Dummy implementation of 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 + +// ************************************************************************* // diff --git a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C index 58bab58707..5aa639a049 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C +++ b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -80,12 +80,6 @@ Foam::functionObjects::runTimePostProcessing::runTimePostProcessing } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostProcessing::~runTimePostProcessing() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict) diff --git a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.H b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.H index 225ae28954..8fd76343ba 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.H +++ b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -119,15 +119,11 @@ private: PtrList text_; - // Private Member Functions + // Private Member Functions - //- Helper function to read scene objects - template - void readObjects - ( - const dictionary& dict, - PtrList& objects - ) const; + //- Helper function to read scene objects + template + void readObjects(const dictionary& dict, PtrList& objects) const; public: @@ -143,12 +139,12 @@ public: ( const word& name, const Time& runTime, - const dictionary&dict + const dictionary& dict ); //- Destructor - virtual ~runTimePostProcessing(); + virtual ~runTimePostProcessing() = default; // Member Functions @@ -158,8 +154,8 @@ public: return mesh_; } - //- Read the field min/max data - virtual bool read(const dictionary&); + //- Read the post-processing controls + virtual bool read(const dictionary& dict); //- Execute, currently does nothing virtual bool execute(); diff --git a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/controlDict b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/controlDict index 6f9d819fbc..ba2cede19c 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/controlDict +++ b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/controlDict @@ -52,8 +52,8 @@ maxCo 0.2; functions { -// #include "sampling" -// #include "runTimePostProcessing" + #include "sampling" + #include "runTimePostProcessing" } // ************************************************************************* // From dc8179f5e08d5e2b5245b8ccee700206d1bcd467 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 16 Dec 2018 14:21:45 +0100 Subject: [PATCH 05/16] ENH: add some storage queries to PrimitivePatch - for quantities such as face area/normals etc, it can be useful to calculate directly and avoid the overhead of caching all the values. STYLE: comments, use HashTable lookup() method in whichPoint() --- .../PrimitivePatch/PrimitivePatch.C | 13 +------ .../PrimitivePatch/PrimitivePatch.H | 37 +++++++++++-------- .../PrimitivePatch/PrimitivePatchAddressing.C | 3 +- .../PrimitivePatch/PrimitivePatchBdryPoints.C | 5 +-- .../PrimitivePatch/PrimitivePatchEdgeLoops.C | 3 +- .../PrimitivePatchLocalPointOrder.C | 3 +- .../PrimitivePatch/PrimitivePatchMeshData.C | 23 ++++-------- .../PrimitivePatchPointAddressing.C | 6 +-- 8 files changed, 39 insertions(+), 54 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C index 5cc8103d9c..d82ca60a81 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatch.C @@ -498,17 +498,8 @@ whichPoint const label gp ) const { - Map