Page MenuHomec4science

runner.hpp
No OneTemporary

File Metadata

Created
Mon, Aug 5, 10:04

runner.hpp

#ifndef SPECMICP_REACTMICP_SOLVER_RUNNER_HPP
#define SPECMICP_REACTMICP_SOLVER_RUNNER_HPP
#include "reactive_transport_solver.hpp"
#include "timestepper.hpp"
#include <string>
#include <functional>
namespace specmicp {
namespace reactmicp {
namespace solver {
//! \struct SimulationInformation
//! \brief Information about the simulation
struct SimulationInformation
{
std::string name; //!< Name of the simulation
std::string output_prefix; //!< prefix for the output files
bool print_iter_info{true}; //!< If true, print the iteration informations
scalar_t output_step; //!< output step
SimulationInformation(std::string name_simul, scalar_t outputstep):
name(name_simul),
output_prefix(name_simul+"_"),
output_step(output_step)
{}
std::string complete_filepath(std::string name, std::string suffix) const {
return output_prefix+name+"."+suffix;
}
};
using output_f = std::function<void (scalar_t time, VariablesBasePtr variables)>;
inline void dummy_output(scalar_t _, VariablesBasePtr __) {}
class ReactiveTransportRunner
{
public:
ReactiveTransportRunner(ReactiveTransportSolver& solver,
scalar_t lower_dt_bound,
scalar_t upper_dt_bound,
const SimulationInformation info):
m_solver(solver),
m_timestepper(lower_dt_bound, upper_dt_bound, 0, 2.0),
m_simulinfo(info)
{
}
void run_until(scalar_t target, VariablesBasePtr variables);
void set_output_policy(output_f output_policy) {
m_output_function = output_policy;
}
ReactiveTransportOptions& get_options() {
return m_solver.get_options();
}
TimestepperOptions& get_timestepper_options() {
return m_timestepper.get_options();
}
ReactiveTransportPerformance& get_perfs() {
return m_solver.get_perfs();
}
ReactiveTransportTimer& get_timer() {
return m_solver.get_timer();
}
private:
index_t m_cnt{0};
ReactiveTransportSolver& m_solver;
Timestepper m_timestepper;
const SimulationInformation& m_simulinfo;
output_f m_output_function{dummy_output};
scalar_t m_output_target;
};
} // end namespace solver
} // end namespace reactmicp
} // end namespace specmicp
#endif // SPECMICP_REACTMICP_SOLVER_RUNNER_HPP

Event Timeline