diff --git a/src/petsc4Foam/utils/petscCacheManager.C b/src/petsc4Foam/utils/petscCacheManager.C index 234e916b9652188b34c20fca0f38c6a1ab3e7cee..8d83ea4e19839a68c725777d9f385a1d5a21c6f7 100644 --- a/src/petsc4Foam/utils/petscCacheManager.C +++ b/src/petsc4Foam/utils/petscCacheManager.C @@ -32,15 +32,15 @@ License const Foam::Enum < - Foam::PetscUtils::Caching::cachingTypes + Foam::PetscUtils::Caching::updateTypes > -Foam::PetscUtils::Caching::cachingTypeNames_ +Foam::PetscUtils::Caching::updateTypeNames_ { - { Caching::None, "none" }, - { Caching::None, "never" }, // Alias - { Caching::Always, "always" }, - { Caching::Periodic, "periodic" }, - { Caching::Adaptive, "adaptive" }, + { updateTypes::Always, "always" }, + { updateTypes::Periodic, "periodic" }, + { updateTypes::Adaptive, "adaptive" }, + { updateTypes::Never, "never" }, + { updateTypes::Never, "none" }, // Alias }; diff --git a/src/petsc4Foam/utils/petscCacheManager.H b/src/petsc4Foam/utils/petscCacheManager.H index 8cff30dc025210d48b8a7528a82d9d712d710246..5cacb9fbd51516cef46106fc521122b6afe5d311 100644 --- a/src/petsc4Foam/utils/petscCacheManager.H +++ b/src/petsc4Foam/utils/petscCacheManager.H @@ -83,23 +83,24 @@ struct Caching { // Public Data Types - //- Supported caching types - enum cachingTypes + //- Caching update types + enum updateTypes { - None, - Always, - Periodic, - Adaptive + Always, //!< "always" update every time-step + Periodic, //!< "periodic" update at given period + Adaptive, //!< "adaptive" update scheme + Never, //!< "never" update + None = Never, //!< "none" is an alias for "never" }; //- Names for selectable caching types - static const Enum<cachingTypes> cachingTypeNames_; + static const Enum<updateTypes> updateTypeNames_; // Member Data - cachingTypes updateType_; + updateTypes updateType_; int updateFreq_; @@ -118,10 +119,10 @@ struct Caching // Constructors - //- Default construct. No caching + //- Default construct. Always update (no caching). Caching() : - updateType_{cachingTypes::None}, + updateType_{updateTypes::Always}, updateFreq_{1}, timeIter{0}, time0{0}, @@ -133,17 +134,18 @@ struct Caching { dictionary cacheDict = dict.subOrEmptyDict(key); updateType_ = - cachingTypeNames_.getOrDefault + updateTypeNames_.getOrDefault ( "update", cacheDict, - cachingTypes::None + updateTypes::Always, + false // non-failsafe - Fatal on bad enumeration ); - if (updateType_ == cachingTypes::Periodic) + if (updateType_ == updateTypes::Periodic) { - dictionary coeffsDict = cacheDict.subOrEmptyDict("periodicCoeffs"); - updateFreq_ = coeffsDict.getOrDefault<int>("frequency", 1); + dictionary coeffs(cacheDict.subOrEmptyDict("periodicCoeffs")); + updateFreq_ = coeffs.getOrDefault<int>("frequency", 1); } } }; @@ -243,7 +245,7 @@ private: { switch (caching.updateType_) { - case PetscUtils::Caching::None: + case PetscUtils::Caching::Never: { return false; break; @@ -293,7 +295,7 @@ private: } } - // Default + // Default: Never return false; } };