added: ability to use a fixed time level in FieldFunctions

This commit is contained in:
Arne Morten Kvarving 2022-03-15 14:43:20 +01:00
parent c5c43beca2
commit 02de121ca3
2 changed files with 17 additions and 1 deletions

View File

@ -50,6 +50,7 @@ FieldFuncHDF5::FieldFuncHDF5 (const std::string& fName)
{
lastLevel = 0;
lastTime = 0.0;
hasMultipleLevels = true;
#ifdef HAS_HDF5
pAdm = new ProcessAdm();
hdf5 = new HDF5Reader(fName,*pAdm);
@ -69,6 +70,7 @@ FieldFuncHDF5::~FieldFuncHDF5 ()
int FieldFuncHDF5::findClosestLevel (double time) const
{
if (!hasMultipleLevels) return lastLevel;
if (time == lastTime) return lastLevel;
#ifdef HAS_HDF5
double t;
@ -102,6 +104,11 @@ bool FieldFuncHDF5::load (const std::vector<std::string>& fieldNames,
{
size_t nOK = 0;
size_t nPatches = 0;
if (level & FIXED_LEVEL) {
hasMultipleLevels = false;
level = level & ~FIXED_LEVEL;
lastLevel = level;
}
#ifdef HAS_HDF5
bool mixedField = basisName.find('-') == std::string::npos;
std::stringstream str;
@ -246,6 +253,8 @@ FieldFunction::FieldFunction (const std::string& fileName,
{
if (level >= 0)
this->load({fieldName},basisName,level,true);
if (!hasMultipleLevels)
currentLevel = lastLevel;
}
@ -331,6 +340,8 @@ FieldsFuncBase::FieldsFuncBase (const std::string& fileName,
{
if (level >= 0)
this->load(fName,basisName,level);
if (!hasMultipleLevels)
currentLevel = lastLevel;
}

View File

@ -30,6 +30,9 @@ class ProcessAdm;
class FieldFuncBase
{
public:
static constexpr int FIXED_LEVEL = 1 << 24; //!< Bit flag in level for using fixed
protected:
//! \brief Default constructor.
FieldFuncBase() : pidx(0), npch(0) {}
@ -87,11 +90,13 @@ protected:
//! \brief Clears the field container.
virtual void clearField() = 0;
bool hasMultipleLevels; //!< True if we have multiple time levels
mutable int lastLevel; //!< The last time level read from
private:
HDF5Reader* hdf5; //!< The HDF5-file containing the field data
ProcessAdm* pAdm; //!< Process administrator for the HDF5-file reader
mutable int lastLevel; //!< The last time level read from
mutable double lastTime; //!< The time of \a lastLevel
};