52 [](
const scalar a,
const scalar
b)
73 dictName_(cacheFileName)
104bool Foam::ensightOutput::writerCaching::remove(
const word& fieldName)
110 return dictptr->remove(fieldName);
127Foam::label Foam::ensightOutput::writerCaching::readPreviousTimes
129 const fileName& dictFile,
130 const scalar timeValue
139 IFstream is(dictFile);
141 if (is.good() && cache_.read(is))
145 cache_.readIfPresent(
"times", times_);
151 if (cache_.readIfPresent(
"geometry", geomIndices))
154 geoms_.set(geomIndices);
169 return max(0, times_.size()-1);
174 return max(0, geoms_.find_last());
182 if (geoms_.count() <= 1)
187 if (geoms_.size() == times_.size() && geoms_.all())
203 const scalar timeValue,
204 const bool geomChanged,
205 const word& fieldName,
206 const string& fieldType,
210 const fileName dictFile(baseDir/dictName_);
212 bool stateChanged =
false;
217 ? readPreviousTimes(dictFile, timeValue)
256 cache_.set(
new primitiveEntry(
"times", std::move(toks)));
258 cache_.set(
"geometry", geoms_.sortedToc());
267 dict.set(
"type", fieldType);
268 if (!varName.empty() && varName != fieldName)
271 dict.set(
"name", varName);
277 OFstream
os(dictFile);
279 os <<
"// State file for writer output" <<
nl <<
nl;
280 cache_.write(
os,
false);
282 os <<
nl <<
"// End" <<
nl;
Various functions to operate on Lists.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
void resize(const label len)
Adjust allocated size of list.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
A simple output token stream that can be used to build token lists. Always UNCOMPRESSED.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
bool remove(const word &keyword)
Remove an entry specified by keyword.
void clear()
Clear the dictionary.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
label latestTimeIndex() const
The most current time index.
writerCaching(const word &cacheFileName)
Construct with specified cache name.
bool update(const fileName &baseDir, const scalar timeValue, const bool geomChanged, const word &fieldName, const string &fieldType, const word &varName=word::null)
Update time/geometry information and file cache. This routine should only be called from the master p...
label latestGeomIndex() const
The most current geometry index.
void clear()
Clear all values.
int geometryTimeset() const
Expected timeset for the geometry.
const dictionary & fieldsDict() const
Get or create the 'fields' information dictionary.
A class for handling file names.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
static const equalOp< scalar > equalTimes(ROOTSMALL)
static label findTimeIndex(const UList< scalar > &list, const scalar val)
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< token > tokenList
List of token, used for dictionary primitive entry (for example).
List< scalar > scalarList
List of scalar.
constexpr char nl
The newline '\n' character (0x0a).