[Richards&Transport] Set a more clear output policy

parent 97399b66
......@@ -63,8 +63,8 @@ adding an empty line, make text **bold** or ``monospaced``.
<parameter name="policy">
<definition> Policy to write the data. </definition>
<suggestion> endOfStep </suggestion>
<values> endOfStep, none </values>
<suggestion> endOfRichardsStep </suggestion>
<values> endOfRichardsStep, none </values>
</parameter>
<parameter name="subsamplingLevel">
......
......@@ -63,8 +63,8 @@ adding an empty line, make text **bold** or ``monospaced``.
<parameter name="policy">
<definition> Policy to write the data. </definition>
<suggestion> endOfStep </suggestion>
<values> all, endOfStep, none </values>
<suggestion> endOfRichardsStep </suggestion>
<values> endOfTransportStep, endOfRichardsStep, none </values>
</parameter>
<parameter name="subsamplingLevel">
......
......@@ -31,7 +31,7 @@ public:
* @param[in] log_level The log level of the logger.
* @param[in] helper The Dune::MPIHelper instance of this process.
* @param[in] output_policy The output policy.
* Defaults to OutputPolicy::EndOfStep.
* Defaults to OutputPolicy::None.
* @param[in] adapt_policy The adapt policy.
* Defaults to AdaptiviyPolicy::None.
*/
......@@ -39,7 +39,7 @@ public:
const std::string log_name,
const std::string log_level,
const Dune::MPIHelper& helper,
OutputPolicy output_policy=OutputPolicy::EndOfStep,
OutputPolicy output_policy=OutputPolicy::None,
AdaptivityPolicy adapt_policy=AdaptivityPolicy::None
)
: _output_policy(output_policy)
......
......@@ -20,14 +20,14 @@ namespace Dune{
namespace Dorie{
/**
* @brief Enum class for output policy. It defines when a simulation class
* should produce an output
* @brief Enum class for output policy.
* @details It defines when a simulation class should produce an output.
*/
enum class OutputPolicy {None,EndOfStep,All};
enum class OutputPolicy {None,EndOfRichardsStep,EndOfTransportStep};
/**
* @brief Enum class for output policy. It defines which variable
* is the target in order to mark the grid
* @brief Enum class for output policy.
* @details It defines which variable is the target in order to mark the grid
*/
enum class AdaptivityPolicy {None,WaterFlux,SoluteFlux};
......
......@@ -26,16 +26,18 @@ RichardsSimulation<Traits>::RichardsSimulation (
enable_fluxrc(_inifile.get<bool>("fluxReconstruction.enable"))
{
// set output policy
// --- Output Policy ---
std::string output_policy_str
= inifile.get<std::string>("output.policy");
if (output_policy_str == "all" || output_policy_str == "endOfStep")
this->set_policy(OutputPolicy::EndOfStep);
else if (output_policy_str == "none")
if (output_policy_str == "endOfRichardsStep") {
this->set_policy(OutputPolicy::EndOfRichardsStep);
} else if (output_policy_str == "none") {
this->set_policy(OutputPolicy::None);
else
DUNE_THROW(NotImplemented,"not known output!");
} else {
this->_log->error("Invalid output policy '{}'", output_policy_str);
DUNE_THROW(NotImplemented,"Invalid output policy: " << output_policy_str);
}
// --- Grid Function Space ---
this->_log->trace("Setting up GridFunctionSpace");
......@@ -76,7 +78,7 @@ RichardsSimulation<Traits>::RichardsSimulation (
u = std::make_shared<U>(*gfs,.0);
Dune::PDELab::interpolate(*finitial,*gfs,*u);
// --- Utility Class Setup --- //
// --- Writer Setup --- //
if (output_policy() != OutputPolicy::None)
{
const int subsamling_lvl =
......@@ -94,6 +96,7 @@ RichardsSimulation<Traits>::RichardsSimulation (
"./");
}
// --- Adaptivity Setup --- //
if constexpr (AdaptivityHandlerFactory::enabled)
{
AdaptivityHandlerFactory adaptivity_fac(inifile,*grid);
......@@ -228,7 +231,7 @@ void RichardsSimulation<Traits>::step()
step_succeed = controller->validate(exception);
}
if (this->output_policy() != OutputPolicy::None)
if (this->output_policy() == OutputPolicy::EndOfRichardsStep)
write_data();
}
......
......@@ -18,35 +18,9 @@ RichardsTransportCouplingSimulation<Traits>::RichardsTransportCouplingSimulation
, _inifile_richards(inifile_richards)
, _inifile_transport(inifile_transport)
{
Dune::Dorie::OutputPolicy richards_op, transport_op;
std::string output_policy_str
= _inifile_richards.get<std::string>("output.policy");
if (output_policy_str == "all" || output_policy_str == "endOfStep")
richards_op = OutputPolicy::EndOfStep;
else if (output_policy_str == "none")
richards_op = OutputPolicy::None;
else
DUNE_THROW(NotImplemented,"not known output!");
output_policy_str = _inifile_transport.get<std::string>("output.policy");
if (output_policy_str == "all")
transport_op = OutputPolicy::All;
else if (output_policy_str == "endOfStep")
transport_op = OutputPolicy::EndOfStep;
else if (output_policy_str == "none")
transport_op = OutputPolicy::None;
else
DUNE_THROW(NotImplemented,"not known output!");
// create richards simulations
_richards = std::make_unique<RichardsSimulation>(_inifile_richards,grid_creator,helper);
_richards->set_policy(richards_op);
auto time_begin = _richards->begin_time();
// set initial water state into the transport simulation
......@@ -60,8 +34,9 @@ RichardsTransportCouplingSimulation<Traits>::RichardsTransportCouplingSimulation
igf_water_flux->push(gf_water_flux,time_begin);
// create transport simulations
_transport = std::make_unique<TransportSimulation>(_inifile_transport,grid_creator,helper,igf_water_flux,igf_water_content);
_transport->set_policy(transport_op);
_transport = std::make_unique<TransportSimulation>(
_inifile_transport,grid_creator,helper,
igf_water_flux,igf_water_content);
}
template<typename Traits>
......@@ -128,10 +103,12 @@ void RichardsTransportCouplingSimulation<Traits>::step()
}
_current_time = _time_richards;
// drop the old grid functions that the transport simulation have.
// drop the old grid functions in transport model.
igf_water_content->pop();
igf_water_flux->pop();
if (_transport->output_policy() == OutputPolicy::EndOfStep)
// write data in case of not autonomous management in transport
if (_transport->output_policy() == OutputPolicy::EndOfRichardsStep)
_transport->write_data();
}
......@@ -196,19 +173,25 @@ void RichardsTransportCouplingSimulation<Traits>::post_adapt_grid()
auto igf_water_flux = std::make_shared<GFWaterFluxContainer>();
// set initial state of the water content to container
auto gf_water_content_begin = _richards->get_water_content(richards_state_before_step);
igf_water_content->push(gf_water_content_begin,richards_state_before_step.time);
auto gf_water_content_begin
= _richards->get_water_content(richards_state_before_step);
igf_water_content->push(gf_water_content_begin,
richards_state_before_step.time);
// set initial state of the water flux to container
auto gf_water_flux_begin = _richards->get_water_flux_reconstructed(richards_state_before_step);
auto gf_water_flux_begin
= _richards->get_water_flux_reconstructed(richards_state_before_step);
igf_water_flux->push(gf_water_flux_begin,richards_state_before_step.time);
// set final state of the water content to container
auto gf_water_content_end = _richards->get_water_content(richards_state_after_step);
igf_water_content->push(gf_water_content_end,richards_state_after_step.time);
auto gf_water_content_end
= _richards->get_water_content(richards_state_after_step);
igf_water_content->push(gf_water_content_end,
richards_state_after_step.time);
// set final state of the water flux to container
auto gf_water_flux_end = _richards->get_water_flux_reconstructed(richards_state_after_step);
auto gf_water_flux_end
= _richards->get_water_flux_reconstructed(richards_state_after_step);
igf_water_flux->push(gf_water_flux_end,richards_state_after_step.time);
_transport->set_water_flux(igf_water_flux);
......
......@@ -22,7 +22,20 @@ TransportSimulation<Traits>::TransportSimulation(
, time_steps(0)
, enable_fluxrc(_inifile.get<bool>("fluxReconstruction.enable"))
{
Dune::Timer timer;
// --- Output Policy ---
std::string output_policy_str
= inifile.get<std::string>("output.policy");
if (output_policy_str == "endOfRichardsStep") {
this->set_policy(OutputPolicy::EndOfRichardsStep);
} else if (output_policy_str == "endOfTransportStep") {
this->set_policy(OutputPolicy::EndOfTransportStep);
} else if (output_policy_str == "none") {
this->set_policy(OutputPolicy::None);
} else {
this->_log->error("Invalid output policy '{}'", output_policy_str);
DUNE_THROW(NotImplemented,"Invalid output policy: " << output_policy_str);
}
// --- Grid Function Space ---
this->_log->trace("Setting up GridFunctionSpace");
......@@ -66,9 +79,9 @@ TransportSimulation<Traits>::TransportSimulation(
else
DUNE_THROW(Dune::NotImplemented,"Time method not supported!");
// --- Writer Setup --- //
if (output_policy() != OutputPolicy::None)
{
// // --- Utility Class Setup --- //
const int subsamling_lvl = _inifile.get<int>("output.subsamplingLevel", 0);
const auto subsamling_intervals = Dune::refinementLevels(subsamling_lvl);
auto sub_vtk = std::make_shared<Dune::SubsamplingVTKWriter<GV>>(gv,
......@@ -80,14 +93,6 @@ TransportSimulation<Traits>::TransportSimulation(
"./");
}
// --- Flux Reconstruction grid functions ---
if (enable_fluxrc and not enable_rt_engine) {
this->_log->error(
" Flux reconstruction is not available for this configuration.");
DUNE_THROW(Dune::NotImplemented,
"Flux reconstruction engine not implemented!");
}
do_operator_setup = true;
this->_log->info("Setup complete");
......@@ -212,7 +217,7 @@ void TransportSimulation<Traits>::step()
time_steps++;
if (this->output_policy() == OutputPolicy::All)
if (this->output_policy() == OutputPolicy::EndOfTransportStep)
write_data();
}
......
This diff is collapsed.
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