-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add snapshot frequency to Euler Forward driver and print disable flag.
Add snapshot frequency for euler forward and printer disable flag for CSV printer
- Loading branch information
Showing
8 changed files
with
107 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ namespace marco::runtime | |
|
||
std::vector<int64_t> derOrders; | ||
|
||
|
||
private: | ||
Printer* printer; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,79 @@ | ||
#include "marco/Runtime/Drivers/EulerForward/Driver.h" | ||
#include "marco/Runtime/Drivers/EulerForward/CLI.h" | ||
#include "marco/Runtime/Solvers/EulerForward/Options.h" | ||
#include "marco/Runtime/Solvers/EulerForward/Profiler.h" | ||
#include "marco/Runtime/Simulation/Options.h" | ||
#include "marco/Runtime/Simulation/Profiler.h" | ||
#include "marco/Runtime/Simulation/Runtime.h" | ||
#include "marco/Runtime/Solvers/EulerForward/Options.h" | ||
#include "marco/Runtime/Solvers/EulerForward/Profiler.h" | ||
#include <iostream> | ||
|
||
namespace marco::runtime | ||
{ | ||
EulerForward::EulerForward(Simulation* simulation) | ||
: Driver(simulation) | ||
{ | ||
} | ||
namespace marco::runtime { | ||
EulerForward::EulerForward(Simulation *simulation) : Driver(simulation) {} | ||
|
||
#ifdef CLI_ENABLE | ||
std::unique_ptr<cli::Category> EulerForward::getCLIOptions() | ||
{ | ||
return std::make_unique<eulerforward::CommandLineOptions>(); | ||
} | ||
std::unique_ptr<cli::Category> EulerForward::getCLIOptions() { | ||
return std::make_unique<eulerforward::CommandLineOptions>(); | ||
} | ||
#endif // CLI_ENABLE | ||
|
||
int EulerForward::run() | ||
{ | ||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Starting simulation" << std::endl; | ||
} | ||
|
||
double time; | ||
int EulerForward::run() { | ||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Starting simulation" << std::endl; | ||
} | ||
|
||
do { | ||
// Compute the next values of the state variables. | ||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Updating state variables" << std::endl; | ||
} | ||
double time; | ||
std::size_t iterationStep = 0; | ||
|
||
EULER_FORWARD_PROFILER_STATEVAR_START; | ||
updateStateVariables(eulerforward::getOptions().timeStep); | ||
EULER_FORWARD_PROFILER_STATEVAR_STOP; | ||
do { | ||
iterationStep++; | ||
|
||
// Move to the next step. | ||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Updating time and non-state variables" << std::endl; | ||
} | ||
// Compute the next values of the state variables. | ||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Updating state variables" << std::endl; | ||
} | ||
|
||
EULER_FORWARD_PROFILER_NONSTATEVAR_START; | ||
time = getTime() + eulerforward::getOptions().timeStep; | ||
setTime(time); | ||
EULER_FORWARD_PROFILER_STATEVAR_START; | ||
updateStateVariables(eulerforward::getOptions().timeStep); | ||
EULER_FORWARD_PROFILER_STATEVAR_STOP; | ||
|
||
updateNonStateVariables(); | ||
EULER_FORWARD_PROFILER_NONSTATEVAR_STOP; | ||
// Move to the next step. | ||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Updating time and non-state variables" | ||
<< std::endl; | ||
} | ||
|
||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Printing values" << std::endl; | ||
} | ||
EULER_FORWARD_PROFILER_NONSTATEVAR_START; | ||
time = getTime() + eulerforward::getOptions().timeStep; | ||
setTime(time); | ||
|
||
// Print the values. | ||
getSimulation()->getPrinter()->printValues(); | ||
} while (std::abs(simulation::getOptions().endTime - time) >= | ||
eulerforward::getOptions().timeStep); | ||
updateNonStateVariables(); | ||
EULER_FORWARD_PROFILER_NONSTATEVAR_STOP; | ||
|
||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Simulation finished" << std::endl; | ||
std::cerr << "[Euler Forward] Printing values" << std::endl; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
// Print the values at a specified frequency. | ||
if (iterationStep % eulerforward::getOptions().snapshotSteps == 0) { | ||
getSimulation()->getPrinter()->printValues(); | ||
} | ||
|
||
} while (std::abs(simulation::getOptions().endTime - time) >= | ||
eulerforward::getOptions().timeStep); | ||
|
||
iterationStep++; | ||
getSimulation()->getPrinter()->printValues(); | ||
|
||
if (marco::runtime::simulation::getOptions().debug) { | ||
std::cerr << "[Euler Forward] Simulation finished" << std::endl; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
} // namespace marco::runtime | ||
|
||
namespace marco::runtime | ||
{ | ||
std::unique_ptr<Driver> getDriver(Simulation* simulation) | ||
{ | ||
return std::make_unique<EulerForward>(simulation); | ||
} | ||
namespace marco::runtime { | ||
std::unique_ptr<Driver> getDriver(Simulation *simulation) { | ||
return std::make_unique<EulerForward>(simulation); | ||
} | ||
} // namespace marco::runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters