diff --git a/src/functionObjects/field/streamLine/streamLineBase.C b/src/functionObjects/field/streamLine/streamLineBase.C index 2b0665df23d3f11d79469fd3769e3297300e537f..8806a14ee726fa33f9bbf9129948ac3929cb650b 100644 --- a/src/functionObjects/field/streamLine/streamLineBase.C +++ b/src/functionObjects/field/streamLine/streamLineBase.C @@ -783,7 +783,11 @@ bool Foam::functionObjects::streamLineBase::writeToFile() for (const word& fieldName : scalarNames_) { dictionary propsDict; - propsDict.add("file", scalarVtkFile); + propsDict.add + ( + "file", + scalarVtkFile.relative(time_.globalPath(), true) + ); setProperty(fieldName, propsDict); } @@ -791,7 +795,11 @@ bool Foam::functionObjects::streamLineBase::writeToFile() for (const word& fieldName : vectorNames_) { dictionary propsDict; - propsDict.add("file", vectorVtkFile); + propsDict.add + ( + "file", + vectorVtkFile.relative(time_.globalPath(), true) + ); setProperty(fieldName, propsDict); } diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C index 004b3914426c987ab7edefccd53555c4b3d76c04..11475a3b2a8ad284a11bda0fd288856cb1b6cd8a 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C +++ b/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,37 +41,35 @@ namespace runTimePostPro // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -bool Foam::functionObjects::runTimePostPro::functionObjectBase::removeFile +Foam::fileName +Foam::functionObjects::runTimePostPro::functionObjectBase::getFileName ( const word& keyword, const word& subDictName -) +) const { dictionary dict; state_.getObjectDict(functionObjectName_, subDictName, dict); - fileName fName; - if (dict.readIfPresent(keyword, fName)) + fileName f; + if (dict.readIfPresent<fileName>(keyword, f)) { - Foam::rm(fName); - return true; + f.expand(); } - return false; + return f; } -Foam::fileName -Foam::functionObjects::runTimePostPro::functionObjectBase::getFileName +bool Foam::functionObjects::runTimePostPro::functionObjectBase::removeFile ( const word& keyword, const word& subDictName -) const +) { - dictionary dict; - state_.getObjectDict(functionObjectName_, subDictName, dict); + // Foam::rm() ignores empty names etc. - return dict.lookupOrDefault<fileName>(keyword, fileName::null); + return Foam::rm(getFileName(keyword, subDictName)); } @@ -91,12 +89,6 @@ Foam::functionObjects::runTimePostPro::functionObjectBase::functionObjectBase {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::runTimePostPro::functionObjectBase::~functionObjectBase() -{} - - // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // bool Foam::functionObjects::runTimePostPro::functionObjectBase::clear() diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.H b/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.H index 042873e40a45687a0458b1fcde707dd772937504..7515024521f4315041ee613f42858c07c1011ead 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.H +++ b/src/functionObjects/graphics/runTimePostProcessing/functionObjectBase.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,17 +62,6 @@ class functionObjectBase : public fieldVisualisationBase { -private: - - // Private Member Functions - - //- No copy construct - functionObjectBase(const functionObjectBase&) = delete; - - //- No copy assignment - void operator=(const functionObjectBase&) = delete; - - protected: // Protected data @@ -100,11 +89,11 @@ protected: // \verbatim // T // { - // file "path/T_object.vtk"; + // file "<case>/relpath/T_object.vtk"; // } // defaultCloud // { - // file "path/cloud_0001.vtp"; + // file "<case>/relpath/cloud_0001.vtp"; // fields (T U); // } // \endverbatim @@ -121,6 +110,12 @@ protected: bool removeFile(const word& keyword, const word& subDictName); + //- No copy construct + functionObjectBase(const functionObjectBase&) = delete; + + //- No copy assignment + void operator=(const functionObjectBase&) = delete; + public: //- Run-time type information @@ -139,7 +134,7 @@ public: //- Destructor - virtual ~functionObjectBase(); + virtual ~functionObjectBase() = default; // Member Functions diff --git a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C index b5fd758a7c03b13d5758ccb203bb5da2f0b0f1f6..6bec0a8aa40ba32086325e0b33bb7377a29936de 100644 --- a/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C +++ b/src/functionObjects/lagrangian/vtkCloud/vtkCloud.C @@ -318,20 +318,14 @@ bool Foam::functionObjects::vtkCloud::writeCloud // } // } + // Shorten file name to be case-local and use "<case>" shortcut + // to make the content relocatable dictionary propsDict; - - // Use case-local filename and "<case>" shortcut for readable output - // and for possibly relocation of files - - fileName fName(file.relative(time_.globalPath())); - if (fName.isAbsolute()) - { - propsDict.add("file", fName); - } - else - { - propsDict.add("file", "<case>"/fName); - } + propsDict.add + ( + "file", + file.relative(time_.globalPath(), true) + ); propsDict.add("fields", written); setObjectProperty(name(), cloudName, propsDict); diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 6c6078bbbdc2e2b169d4f17d6858344cc8f6cec0..9fef162add63c237abafb5248fa0579ef8172872 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -338,10 +338,18 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields) Pstream::scatter(sampleFile); if (sampleFile.size()) { + // Shorten file name to be case-local and use "<case>" shortcut + // to make the content relocatable + forAll(masterFields, fieldi) { dictionary propsDict; - propsDict.add("file", sampleFile); + propsDict.add + ( + "file", + sampleFile.relative(time_.globalPath(), true) + ); + const word& fieldName = masterFields[fieldi].name(); setProperty(fieldName, propsDict); } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index 19ccc258a663dacdc46d1b100f24f389a0c7bb0d..3976bde6f73c90b43fcd0b5caed77d2f7a7268e3 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -95,8 +95,15 @@ void Foam::sampledSurfaces::writeSurface Pstream::scatter(sampleFile); if (sampleFile.size()) { + // Shorten file name to be case-local and use "<case>" shortcut + // to make the content relocatable + dictionary propsDict; - propsDict.add("file", sampleFile); + propsDict.add + ( + "file", + sampleFile.relative(time_.globalPath(), true) + ); setProperty(fieldName, propsDict); } } @@ -116,8 +123,15 @@ void Foam::sampledSurfaces::writeSurface s.interpolate() ); + // Case-local filename and "<case>" shortcut for readable output + // and for possibly relocation of files + dictionary propsDict; - propsDict.add("file", fName); + propsDict.add + ( + "file", + fName.relative(time_.globalPath(), true) + ); setProperty(fieldName, propsDict); } }