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

BUG: incorrect default caching type (fixes #10)

- change very misleading enum from `cachingTypes` to `updateTypes`
  and fix enumeration order.

- default constructed cache was "None" (meant to be no caching)
  but should have been "Always" (ie, always update).
parent fcb1ec2a
No related merge requests found
......@@ -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
};
......
......@@ -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;
}
};
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment