Skip to content
Snippets Groups Projects
Commit 3e75a373 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

STYLE: remove file series handling from foamVtkOutput

- now handled by the vtk::seriesWriter, and with its static methods.
parent 03eec4a5
Branches
Tags
No related merge requests found
......@@ -89,101 +89,6 @@ Foam::vtk::newFormatter
}
void Foam::vtk::seriesInfo
(
Ostream& os,
const fileName& base,
const UList<instant>& series,
const char sep
)
{
// Split the base into (stem, ext) components
//
// base = "path/file.vtm"
//
// stem = "file"
// ext = ".vtm"
const word stem = base.nameLessExt();
const word ext = "." + base.ext();
// Begin file-series (JSON)
os << "{\n \"file-series-version\" : \"1.0\",\n \"files\" : [\n";
// Track how many entries are remaining
// - trailing commas on all but the final entry (JSON requirement)
label nremain = series.size();
// Each entry
// { "name" : "<stem><sep>name<ext>", "time" : value }
for (const instant& inst : series)
{
os << " { \"name\" : \""
<< stem << sep << inst.name() << ext
<< "\", \"time\" : " << inst.value() << " }";
if (--nremain)
{
os << ',';
}
os << nl;
}
os << " ]\n}\n";
}
void Foam::vtk::seriesWrite
(
const fileName& base,
const UList<instant>& series,
const char sep
)
{
mkDir(base.path());
autoPtr<OFstream> osPtr =
(
base.hasExt("series")
? autoPtr<OFstream>::New(base)
: autoPtr<OFstream>::New(base + ".series")
);
seriesInfo(*osPtr, base, series, sep);
}
Foam::fileName Foam::vtk::seriesBase
(
const fileName& outputName,
const char sep
)
{
const auto dash = outputName.rfind(sep);
// No separator? Or separator in path() instead of name()?
if
(
std::string::npos == dash
|| std::string::npos != outputName.find('/', dash)
)
{
// Warn?
return outputName;
}
const auto dot = outputName.find('.', dash);
if (std::string::npos == dot)
{
return outputName.substr(0, dash);
}
return outputName.substr(0, dash) + outputName.substr(dot);
}
void Foam::vtk::writeList
(
vtk::formatter& fmt,
......
......@@ -84,40 +84,6 @@ namespace vtk
);
//- Print file series (JSON format) for specified time instances
//
// \param os The output stream
// \param base The name for the series (eg, "path/file.vtm")
// \param series The list of suffix/value entries
// \param sep The separator used between file stem and suffix.
void seriesInfo
(
Ostream& os,
const fileName& base,
const UList<instant>& series,
const char sep = '_'
);
//- Write file series (JSON format) to disk, for specified time instances
//
// \param base The name for the series (eg, "path/file.vtm")
// \param series The list of suffix/value entries
// \param sep The separator used between file stem and suffix.
void seriesWrite
(
const fileName& base,
const UList<instant>& series,
const char sep = '_'
);
//- Extract the base name for a file series
//
// \param outputName The name of the data output file
// Eg, "somefile_0001.vtm" would extract to "somefile.vtm"
// \param sep The separator used between file stem and suffix.
fileName seriesBase(const fileName& outputName, const char sep = '_');
//- Write a list of uint8_t values.
// The output does not include the payload size.
void writeList
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment