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

ENH: increase precision for ensight field cache (#2999)

- attempt to minimize rounding in the cached time values
  since these are also used to re-populate the case files

STYLE: remove ancient handling of "meshes" entry

- was superseded by "geometry" entry in OpenFOAM-1912 and later.
  Now remove the transitional shim, which was in place for
  restart migration from 1906.
parent 769dcffe
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -27,6 +27,7 @@ License ...@@ -27,6 +27,7 @@ License
#include "ensightWriterCaching.H" #include "ensightWriterCaching.H"
#include "ListOps.H" #include "ListOps.H"
#include "OTstream.H"
#include "Fstream.H" #include "Fstream.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
...@@ -129,15 +130,9 @@ Foam::label Foam::ensightOutput::writerCaching::readPreviousTimes ...@@ -129,15 +130,9 @@ Foam::label Foam::ensightOutput::writerCaching::readPreviousTimes
const scalar timeValue const scalar timeValue
) )
{ {
// In 1906 and earlier, the fieldsDict contained "meshes" and "times" // Track the used geometry intervals as a bitSet
// entries, each with their own time values.
// This makes it more difficult to define the exact correspondence
// between geometry intervals and times.
//
// Now track the used geometry intervals as a bitSet.
// Note: only called from master
// Only called from master
label timeIndex = 0; label timeIndex = 0;
cache_.clear(); cache_.clear();
...@@ -158,21 +153,6 @@ Foam::label Foam::ensightOutput::writerCaching::readPreviousTimes ...@@ -158,21 +153,6 @@ Foam::label Foam::ensightOutput::writerCaching::readPreviousTimes
// Convert indices to bitSet entries // Convert indices to bitSet entries
geoms_.set(geomIndices); geoms_.set(geomIndices);
} }
else if (cache_.readIfPresent("meshes", meshTimes))
{
WarningInFunction
<< nl
<< "Setting geometry timeset information from time values"
<< " (cache from an older OpenFOAM version)." << nl
<< "This may not be fully reliable." << nl
<< nl;
for (const scalar meshTime : meshTimes)
{
const label geomIndex = findTimeIndex(times_, meshTime);
geoms_.set(geomIndex);
}
}
// Make length consistent with time information. // Make length consistent with time information.
// We read/write the indices instead of simply dumping the bitSet. // We read/write the indices instead of simply dumping the bitSet.
...@@ -263,17 +243,19 @@ bool Foam::ensightOutput::writerCaching::update ...@@ -263,17 +243,19 @@ bool Foam::ensightOutput::writerCaching::update
geoms_.set(timeIndex); geoms_.set(timeIndex);
} }
// Update time/geometry information in dictionary // Update time/geometry information in dictionary
cache_.set("times", times_);
cache_.set("geometry", geoms_.sortedToc());
// Debugging, or if needed for older versions: // Note: to avoid inadvertent loss of precision,
//// cache_.set // generate output tokens for the list of times directly
//// ( {
//// "meshes", // Same as: cache_.set("times", times_);
//// IndirectList<scalar>(times_, geoms_.sortedToc()) OTstream os;
//// ); os << times_;
tokenList toks(std::move(os.tokens()));
cache_.set(new primitiveEntry("times", std::move(toks)));
}
cache_.set("geometry", geoms_.sortedToc());
// Add field information to dictionary // Add field information to dictionary
dictionary& dict = fieldDict(fieldName); dictionary& dict = fieldDict(fieldName);
...@@ -293,6 +275,7 @@ bool Foam::ensightOutput::writerCaching::update ...@@ -293,6 +275,7 @@ bool Foam::ensightOutput::writerCaching::update
if (stateChanged) if (stateChanged)
{ {
OFstream os(dictFile); OFstream os(dictFile);
os.precision(16); // increased precision to avoid rounding
os << "// State file for writer output" << nl << nl; os << "// State file for writer output" << nl << nl;
cache_.write(os, false); cache_.write(os, false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment