[Coupling] Allow adapt the grid depending on the policy

parent f0677269
......@@ -10,7 +10,7 @@
namespace Dune{
namespace Dorie{
template<class BaseTraits, int RichardsOrder, int TransportOrder>
template<class BaseTraits, unsigned int RichardsOrder, unsigned int TransportOrder>
struct RichardsTransportCouplingSimulationTraits : public BaseTraits
{
private:
......@@ -52,8 +52,9 @@ private:
using GridCreator = typename Traits::GridCreator;
using TimeField = typename Traits::TimeField;
using TimeInterval = typename Traits::TimeInterval;
using RichardsState = typename RichardsSimulationTraits::State;
std::shared_ptr<typename Traits::BaseTraits::Grid> _grid;
Dune::ParameterTree _inifile_richards, _inifile_transport;
TimeField _current_time;
......@@ -61,16 +62,19 @@ private:
std::unique_ptr<RichardsSimulation> _richards;
std::unique_ptr<TransportSimulation> _transport;
RichardsState richards_state_before_step, richards_state_after_step;
public:
/*-----------------------------------------------------------------------*//**
* @brief Construct Coupled simulation.
*
* @param helper The helper
* @param[in] grid The grid
* @param inifile_richards The inifile richards
* @param _inifile_transport The inifile transport
* @param inifile_richards The richards inifile.
* @param inifile_transport The transport inifile.
* @param[in] _grid_creator The grid creator.
* @param helper The mpi helper.
*
* @todo Fix logger warning.
*/
RichardsTransportCouplingSimulation (
Dune::ParameterTree& inifile_richards,
......@@ -89,7 +93,43 @@ public:
*/
void step() override;
// void adapt();
/**
* @brief Mark the grid in order to improve the current model.
*/
void mark_grid() override
{
if (adaptivity_policy() == AdaptivityPolicy::WaterFlux)
{
_richards->set_policy(adaptivity_policy());
_richards->mark_grid();
}
else if (adaptivity_policy() == AdaptivityPolicy::SoluteFlux)
{
_transport->set_policy(adaptivity_policy());
_transport->mark_grid();
} else if (adaptivity_policy() != AdaptivityPolicy::None)
DUNE_THROW(Dune::NotImplemented,"Not known adaptivity policy!");
}
/**
* @brief Operations before adaptation of the grid
*/
void pre_adapt_grid() override
{
_richards->pre_adapt_grid();
_transport->pre_adapt_grid();
};
/**
* @brief Adapt the grid together it every dependency of the
* grid (e.g. solution vector and grid function spaces).
*/
void adapt_grid() override;
/**
* @brief Operations after adaptation of the grid
*/
void post_adapt_grid() override;
/*------------------------------------------------------------------------*//**
* @brief Method that provides the begin time of the model.
......@@ -140,8 +180,10 @@ public:
*/
void write_data () const override
{
_richards->write_data();
_transport->write_data();
if (_richards->output_policy() != OutputPolicy::None)
_richards->write_data();
if (_transport->output_policy() != OutputPolicy::None)
_transport->write_data();
}
};
......
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