Commit 39538cda authored by Lukas Riedel's avatar Lukas Riedel

Add logger as optional constructor argument of H5File and CalcController

The argument will default to retrieving the base logger
parent e5d57af2
......@@ -19,8 +19,10 @@ class H5File
{
private:
//! Type of the logger for brevity
using Logger = std::shared_ptr<spdlog::logger>;
//! The logger of this instance
const std::shared_ptr<spdlog::logger> _log;
const Logger _log;
//! ID of the H5 file
hid_t _file_id;
//! ID of the currently opened group
......@@ -30,9 +32,12 @@ public:
/// Open the H5 file and its base group.
/**
* \param file_path Path to the H5 file
* \param log The logger to use for this instance,
* defaults to retrieving the base logger.
*/
explicit H5File(const std::string& file_path):
_log(get_logger(log_base)),
explicit H5File(const std::string& file_path,
const Logger log=get_logger(log_base)):
_log(log),
_file_id(-1),
_group_id(-1)
{
......
......@@ -16,6 +16,8 @@ template<typename R, typename TSC>
class CalculationController
{
private:
//! Typedef of logger for brevity
using Logger = std::shared_ptr<spdlog::logger>;
R time; //!< current time
R dt; //!< current time step
......@@ -23,7 +25,7 @@ private:
bool use_dt_suggestion; //!< flag for suggested dt
int it; //!< current number of allowed iterations for Newton solver
//! logger of this instance
const std::shared_ptr<spdlog::logger> _log;
const Logger _log;
const R dtmax, dtmin; //!< time step limits
const R eps; //!< error margin
const R dtinc, dtdec; //!< time step mutliplicators
......@@ -38,13 +40,17 @@ public:
/// Read relevant time values, check for consistency and adapt time step to BC change, if necessary
/** \param tsc_ Class with public function getNextTimeStamp(time)
* \param log The logger to use for this instance,
* defaults to retrieving the base logger.
*/
CalculationController(const ParameterTree& config, const TSC& tsc_, const Dune::MPIHelper& helper)
CalculationController(const ParameterTree& config,
const TSC& tsc_,
const Logger log=get_logger(log_base))
: time(config.get<R>("time.start"))
, dt(config.get<R>("time.startTimestep"))
, suggested_dt(dt)
, use_dt_suggestion(false)
, _log(Dorie::get_logger(log_base))
, _log(log)
, dtmax(config.get<R>("time.maxTimestep"))
, dtmin(config.get<R>("time.minTimestep"))
, eps(dtmin/10.0)
......
......@@ -48,8 +48,9 @@ constexpr R estimate_mbe_entries (const int dim, const Dune::GeometryType::Basic
else if (geo==Dune::GeometryType::BasicType::simplex){
return dim + 2;
}
std::cerr << "Cannot provide MBE entry estimation for given dimension and/or GeometryType!" << std::endl;
return 1;
throw std::runtime_error("Cannot provide matrix backend entry estimate "
"for given geometry type!");
}
/// Provide types and construction of the GFS for the linear solver
......@@ -243,4 +244,4 @@ struct BaseTraits
}
}
#endif // DUNE_DORIE_UTIL_HH
\ No newline at end of file
#endif // DUNE_DORIE_UTIL_HH
......@@ -56,7 +56,8 @@ RichardsSimulation<Traits>::RichardsSimulation (
#endif // EXPERIMENTAL_DG_FEATURES
tlop = std::make_unique<TLOP>(inifile, *fparam, gv);
controller = std::make_unique<CalculationController>(inifile,*fboundary,helper);
controller = std::make_unique<CalculationController>(
inifile, *fboundary, this->_log);
// --- Solution Vectors and Initial Condition ---
u = std::make_shared<U>(*gfs,.0);
......
Markdown is supported
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