Skip to content

Commit

Permalink
Merge pull request #138 from xylar/omega/critical-error-on-bad-time-s…
Browse files Browse the repository at this point in the history
…tepper

Add a critical error if TimeStepper is invalid
xylar authored Sep 30, 2024

Verified

This commit was signed with the committer’s verified signature.
ladislas Ladislas de Toldi
2 parents eb5ab7a + 3bc09ca commit 229ed89
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion components/omega/src/timeStepping/TimeStepper.cpp
Original file line number Diff line number Diff line change
@@ -17,13 +17,19 @@ std::map<std::string, std::unique_ptr<TimeStepper>>
// convert string into TimeStepperType enum
TimeStepperType getTimeStepperFromStr(const std::string &InString) {

TimeStepperType TimeStepperChoice;
// Initialize TimeStepperChoice with Invalid
TimeStepperType TimeStepperChoice = TimeStepperType::Invalid;

if (InString == "Forward-Backward") {
TimeStepperChoice = TimeStepperType::ForwardBackward;
} else if (InString == "RungeKutta4") {
TimeStepperChoice = TimeStepperType::RungeKutta4;
} else if (InString == "RungeKutta2") {
TimeStepperChoice = TimeStepperType::RungeKutta2;
} else {
LOG_CRITICAL("TimeStepper should be one of 'Forward-Backward', "
"'RungeKutta4' or 'RungeKutta2' but got {}:",
InString);
}

return TimeStepperChoice;
7 changes: 6 additions & 1 deletion components/omega/src/timeStepping/TimeStepper.h
Original file line number Diff line number Diff line change
@@ -27,7 +27,12 @@ namespace OMEGA {

/// An enum for every time stepper type
/// needs to extended every time a new time stepper is added
enum class TimeStepperType { ForwardBackward, RungeKutta4, RungeKutta2 };
enum class TimeStepperType {
ForwardBackward,
RungeKutta4,
RungeKutta2,
Invalid
};

/// Translate string for time stepper type into enum
TimeStepperType getTimeStepperFromStr(

0 comments on commit 229ed89

Please sign in to comment.