ENH: make "file" property in functionObjects a relative path (issue #1125)

- partial solution for issue #1091

  This generates file properties that are case-relative,
  Eg,

      plane0
      {
          p
          {
              file "<case>/postProcessing/plane0/1/p_plane0.vtk";
          }
          U
          {
              file "<case>/postProcessing/plane0/1/U_plane0.vtk";
          }
      }

   This allows the case to be moved elsewhere and still find its files.

   This functionality was previously added for vtkCloud, but now also
   applies to streamLine, sampledSets and sampledSurfaces
This commit is contained in:
Mark Olesen
2018-12-14 18:03:12 +01:00
parent 2617c326d8
commit 2f9c511be5
6 changed files with 72 additions and 61 deletions

View File

@ -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);
}

View File

@ -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);
}
}