Skip to content

Commit 229ed89

Browse files
authored
Merge pull request #138 from xylar/omega/critical-error-on-bad-time-stepper
Add a critical error if TimeStepper is invalid
2 parents eb5ab7a + 3bc09ca commit 229ed89

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

components/omega/src/timeStepping/TimeStepper.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ std::map<std::string, std::unique_ptr<TimeStepper>>
1717
// convert string into TimeStepperType enum
1818
TimeStepperType getTimeStepperFromStr(const std::string &InString) {
1919

20-
TimeStepperType TimeStepperChoice;
20+
// Initialize TimeStepperChoice with Invalid
21+
TimeStepperType TimeStepperChoice = TimeStepperType::Invalid;
22+
2123
if (InString == "Forward-Backward") {
2224
TimeStepperChoice = TimeStepperType::ForwardBackward;
2325
} else if (InString == "RungeKutta4") {
2426
TimeStepperChoice = TimeStepperType::RungeKutta4;
2527
} else if (InString == "RungeKutta2") {
2628
TimeStepperChoice = TimeStepperType::RungeKutta2;
29+
} else {
30+
LOG_CRITICAL("TimeStepper should be one of 'Forward-Backward', "
31+
"'RungeKutta4' or 'RungeKutta2' but got {}:",
32+
InString);
2733
}
2834

2935
return TimeStepperChoice;

components/omega/src/timeStepping/TimeStepper.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ namespace OMEGA {
2727

2828
/// An enum for every time stepper type
2929
/// needs to extended every time a new time stepper is added
30-
enum class TimeStepperType { ForwardBackward, RungeKutta4, RungeKutta2 };
30+
enum class TimeStepperType {
31+
ForwardBackward,
32+
RungeKutta4,
33+
RungeKutta2,
34+
Invalid
35+
};
3136

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

0 commit comments

Comments
 (0)