From 02de121ca3307c5e4c0af3d9a14175ec25b3d75b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 15 Mar 2022 14:43:20 +0100 Subject: [PATCH] added: ability to use a fixed time level in FieldFunctions --- src/Utility/FieldFunctions.C | 11 +++++++++++ src/Utility/FieldFunctions.h | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Utility/FieldFunctions.C b/src/Utility/FieldFunctions.C index 75690fcb..c94bf1ea 100644 --- a/src/Utility/FieldFunctions.C +++ b/src/Utility/FieldFunctions.C @@ -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& 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; } diff --git a/src/Utility/FieldFunctions.h b/src/Utility/FieldFunctions.h index 7700138f..28bf55f9 100644 --- a/src/Utility/FieldFunctions.h +++ b/src/Utility/FieldFunctions.h @@ -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 };