The TS-GitLab will have to shut down towards the end of the year — please think about migrating your projects to GitLab.com or GitHub.
(This is still a very early message, meant to keep you informed. There will be more urgent ones in the future.)

Commit ad2d3d77 authored by Santiago Ospina De Los Ríos's avatar Santiago Ospina De Los Ríos
Browse files

Apply clang format to .hh files in DORiE

parent a6e1e7c2
#ifndef DUNE_DORIE_RAVIART_THOMAS_DG_FEM_HH #ifndef DUNE_DORIE_RAVIART_THOMAS_DG_FEM_HH
#define DUNE_DORIE_RAVIART_THOMAS_DG_FEM_HH #define DUNE_DORIE_RAVIART_THOMAS_DG_FEM_HH
#include <dune/pdelab/finiteelementmap/finiteelementmap.hh>
#include <dune/pdelab/finiteelement/l2orthonormal.hh> #include <dune/pdelab/finiteelement/l2orthonormal.hh>
#include <dune/pdelab/finiteelementmap/finiteelementmap.hh>
#include <dune/dorie/common/finite_element/raviart_thomas_dg/local_finite_element.hh> #include <dune/dorie/common/finite_element/raviart_thomas_dg/local_finite_element.hh>
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include <dune/dorie/common/typedefs.hh> #include <dune/dorie/common/typedefs.hh>
namespace Dune{ namespace Dune {
namespace Dorie{ namespace Dorie {
/** /**
* @brief Base class for models. * @brief Base class for models.
...@@ -24,7 +24,6 @@ namespace Dorie{ ...@@ -24,7 +24,6 @@ namespace Dorie{
class ModelBase class ModelBase
{ {
public: public:
/** /**
* @brief Constructs the ModelBase. * @brief Constructs the ModelBase.
* *
...@@ -36,26 +35,27 @@ public: ...@@ -36,26 +35,27 @@ public:
* @param[in] adapt_policy The adapt policy. * @param[in] adapt_policy The adapt policy.
* Defaults to AdaptiviyPolicy::None. * Defaults to AdaptiviyPolicy::None.
*/ */
ModelBase( ModelBase(const std::string log_name,
const std::string log_name, const std::string log_level,
const std::string log_level, const Dune::MPIHelper& helper,
const Dune::MPIHelper& helper, OutputPolicy output_policy = OutputPolicy::None,
OutputPolicy output_policy=OutputPolicy::None, AdaptivityPolicy adapt_policy = AdaptivityPolicy::None)
AdaptivityPolicy adapt_policy=AdaptivityPolicy::None
)
: _output_policy(output_policy) : _output_policy(output_policy)
, _adapt_policy(adapt_policy) , _adapt_policy(adapt_policy)
, _time(0.0) , _time(0.0)
, _log(create_logger(log_name, helper, spdlog::level::from_str(log_level))) , _log(create_logger(log_name, helper, spdlog::level::from_str(log_level)))
{ } {}
virtual ~ModelBase () = default; virtual ~ModelBase() = default;
/** /**
* @brief Sets the output policy. * @brief Sets the output policy.
* *
* @param[in] output_policy The output policy, * @param[in] output_policy The output policy,
*/ */
void set_policy(OutputPolicy output_policy) {_output_policy = output_policy;} void set_policy(OutputPolicy output_policy)
{
_output_policy = output_policy;
}
/** /**
* @brief Sets the adaptivity policy. * @brief Sets the adaptivity policy.
...@@ -72,20 +72,19 @@ public: ...@@ -72,20 +72,19 @@ public:
* *
* @return The current output policy. * @return The current output policy.
*/ */
OutputPolicy output_policy() const {return _output_policy;} OutputPolicy output_policy() const { return _output_policy; }
/** /**
* @brief Returns the current adaptivity policy. * @brief Returns the current adaptivity policy.
* *
* @return The current adaptivity policy. * @return The current adaptivity policy.
*/ */
AdaptivityPolicy adaptivity_policy() const {return _adapt_policy;} AdaptivityPolicy adaptivity_policy() const { return _adapt_policy; }
/// Set the logger for this model /// Set the logger for this model
/** @param logger The new logger /** @param logger The new logger
*/ */
void set_logger (const std::shared_ptr<spdlog::logger> logger) void set_logger(const std::shared_ptr<spdlog::logger> logger)
{ {
_log = logger; _log = logger;
} }
...@@ -119,7 +118,7 @@ public: ...@@ -119,7 +118,7 @@ public:
/** /**
* @brief Operations before adaptation of the grid * @brief Operations before adaptation of the grid
*/ */
virtual void pre_adapt_grid() {}; virtual void pre_adapt_grid(){};
/** /**
* @brief Adapt the grid together it every dependency of the grid (e.g. * @brief Adapt the grid together it every dependency of the grid (e.g.
...@@ -131,8 +130,7 @@ public: ...@@ -131,8 +130,7 @@ public:
_log->error("This model does not implement a grid adaptation " _log->error("This model does not implement a grid adaptation "
"algorithm."); "algorithm.");
DUNE_THROW(Dune::NotImplemented, "'adapt_grid' not implemented"); DUNE_THROW(Dune::NotImplemented, "'adapt_grid' not implemented");
} } else {
else {
_log->error("Calling 'adapt_grid' on a model with " _log->error("Calling 'adapt_grid' on a model with "
"AdaptivityPolicy::None. Grid adaptation refused"); "AdaptivityPolicy::None. Grid adaptation refused");
DUNE_THROW(Dune::InvalidStateException, "Invalid adaptation policy"); DUNE_THROW(Dune::InvalidStateException, "Invalid adaptation policy");
...@@ -142,7 +140,7 @@ public: ...@@ -142,7 +140,7 @@ public:
/** /**
* @brief Operations after adaptation of the grid * @brief Operations after adaptation of the grid
*/ */
virtual void post_adapt_grid() {}; virtual void post_adapt_grid(){};
/** /**
* @brief Method that provides the begin time of the model. * @brief Method that provides the begin time of the model.
...@@ -189,13 +187,11 @@ public: ...@@ -189,13 +187,11 @@ public:
if (output_policy() != OutputPolicy::None) if (output_policy() != OutputPolicy::None)
write_data(); write_data();
while( Dune::FloatCmp::lt( current_time(), end_time()) ) while (Dune::FloatCmp::lt(current_time(), end_time())) {
{
step(); step();
if (adaptivity_policy() != AdaptivityPolicy::None) if (adaptivity_policy() != AdaptivityPolicy::None)
if ( Dune::FloatCmp::lt( current_time(), end_time()) ) if (Dune::FloatCmp::lt(current_time(), end_time())) {
{
mark_grid(); mark_grid();
pre_adapt_grid(); pre_adapt_grid();
adapt_grid(); adapt_grid();
...@@ -205,8 +201,8 @@ public: ...@@ -205,8 +201,8 @@ public:
} }
private: private:
OutputPolicy _output_policy; OutputPolicy _output_policy;
AdaptivityPolicy _adapt_policy; AdaptivityPolicy _adapt_policy;
protected: protected:
/// The current time of the model /// The current time of the model
...@@ -222,28 +218,28 @@ protected: ...@@ -222,28 +218,28 @@ protected:
## Base class for models ## Base class for models
### Stepping: ### Stepping:
The method `step()` must be an abstract method that always has to be The method `step()` must be an abstract method that always has to be
implemented by the derived class. The step must succeed always, otherwise, implemented by the derived class. The step must succeed always, otherwise,
it should throw a `ModelStepException`. It means that time adaptivity it should throw a `ModelStepException`. It means that time adaptivity
must be done internally so that the time step succeeds. must be done internally so that the time step succeeds.
### Writing data: ### Writing data:
The method `step()` must be able to decide whether to write data or not. The method `step()` must be able to decide whether to write data or not.
(Say that in one case one wants that transport writes that every step and in (Say that in one case one wants that transport writes that every step and in
another case one wants that it writes at the end of the Richards step. The another case one wants that it writes at the end of the Richards step. The
first case can't be covered writing data in the `run()` method of the first case can't be covered writing data in the `run()` method of the
coupled model.) Then, enum class called `OutputPolicy` must decide coupled model.) Then, enum class called `OutputPolicy` must decide
whether to call the method `write_data()`. This policy can be set and be whether to call the method `write_data()`. This policy can be set and be
extracted by the methods `set_policy(OutputPolicy)` and `output_policy()` extracted by the methods `set_policy(OutputPolicy)` and `output_policy()`
respectively. respectively.
The method `write_data()` should be in charge of writing the data. The method `write_data()` should be in charge of writing the data.
In principle, this method should be only used following the `OutputPolicy`. In principle, this method should be only used following the `OutputPolicy`.
Usually called at the end of each step and at the beginning of the Usually called at the end of each step and at the beginning of the
model. Since the `step()` method is in charge of it, it is assumed that model. Since the `step()` method is in charge of it, it is assumed that
this method writes the *current* state of the model (e.g. intermediate this method writes the *current* state of the model (e.g. intermediate
results of the coupled model for the transport state). results of the coupled model for the transport state).
### Adaptivity: ### Adaptivity:
...@@ -270,19 +266,19 @@ protected: ...@@ -270,19 +266,19 @@ protected:
A minimal interface is only providing `begin_time()`, `end_time()` and A minimal interface is only providing `begin_time()`, `end_time()` and
`current_time()`. `current_time()`.
In order to keep solution vectors minimal at the time of adaptivity, DORiE In order to keep solution vectors minimal at the time of adaptivity, DORiE
expect the several models synchronized in time. Therefore, a good and still expect the several models synchronized in time. Therefore, a good and still
minimal interface is only suggesting the timestep to the model via minimal interface is only suggesting the timestep to the model via
`suggest_timestep(double dt)`. Such suggestion has to be taken into account `suggest_timestep(double dt)`. Such suggestion has to be taken into account
within the model, and the model must ensure that the timestep is done in within the model, and the model must ensure that the timestep is done in
`step()` is never bigger than the suggested one so that coupled models can `step()` is never bigger than the suggested one so that coupled models can
achieve synchronization. Naturally, models have to ensure that achieve synchronization. Naturally, models have to ensure that
`begin_time()` \f$=\f$ `current_time()` when they are constructed. `begin_time()` \f$=\f$ `current_time()` when they are constructed.
### Local Operator Setup: ### Local Operator Setup:
Since adaptivity can modify the complete setup of the model, and since Since adaptivity can modify the complete setup of the model, and since
the method `adapt_grid()` is not necessarily called by the model. the method `adapt_grid()` is not necessarily called by the model.
There is a need for the method `post_adapt_grid()` which is in charge of There is a need for the method `post_adapt_grid()` which is in charge of
setup everything again to the new grid. Same argument holds for setup everything again to the new grid. Same argument holds for
`pre_adapt_grid()`. `pre_adapt_grid()`.
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#endif #endif
namespace Dune{ namespace Dune {
namespace Dorie{ namespace Dorie {
/** /**
* @brief Traits for the class ModelRichardsTransportCoupling. * @brief Traits for the class ModelRichardsTransportCoupling.
...@@ -29,38 +29,42 @@ namespace Dorie{ ...@@ -29,38 +29,42 @@ namespace Dorie{
* @tparam TransportOrder Order of the polynomial degree used for the basis * @tparam TransportOrder Order of the polynomial degree used for the basis
* functions in the Transport DG/FV method. * functions in the Transport DG/FV method.
*/ */
template<class BaseTraits, unsigned int RichardsOrder, unsigned int TransportOrder> template<class BaseTraits,
unsigned int RichardsOrder,
unsigned int TransportOrder>
struct ModelRichardsTransportCouplingTraits : public BaseTraits struct ModelRichardsTransportCouplingTraits : public BaseTraits
{ {
private: private:
using ModelRichardsTraits = Dune::Dorie::ModelRichardsTraits<BaseTraits,RichardsOrder>; using ModelRichardsTraits =
Dune::Dorie::ModelRichardsTraits<BaseTraits, RichardsOrder>;
public: public:
static_assert(ModelRichardsTraits::enable_rt_engine, static_assert(ModelRichardsTraits::enable_rt_engine,
"Flux reconstruction is not available in the Richards model!"); "Flux reconstruction is not available in the Richards model!");
/// Container for the water content grid function /// Container for the water content grid function
/** \note Interpolates linearly between time steps. /** \note Interpolates linearly between time steps.
* \see GridFunctionContainerPolicy * \see GridFunctionContainerPolicy
*/ */
using GFWaterContentContainer = GridFunctionContainer< using GFWaterContentContainer =
const typename ModelRichardsTraits::GFWaterContent, GridFunctionContainer<const typename ModelRichardsTraits::GFWaterContent,
double, double,
GridFunctionContainerPolicy::LinearInterpolation GridFunctionContainerPolicy::LinearInterpolation>;
>;
/// Container for the water flux grid function /// Container for the water flux grid function
/** \note Returns the next future value /** \note Returns the next future value
* \see GridFunctionContainerPolicy * \see GridFunctionContainerPolicy
*/ */
using GFWaterFluxContainer = GridFunctionContainer<const typename ModelRichardsTraits::GFFluxReconstruction>; using GFWaterFluxContainer = GridFunctionContainer<
const typename ModelRichardsTraits::GFFluxReconstruction>;
private: private:
using ModelTransportTraits = Dune::Dorie::ModelTransportTraits< using ModelTransportTraits =
BaseTraits, Dune::Dorie::ModelTransportTraits<BaseTraits,
GFWaterFluxContainer, GFWaterFluxContainer,
GFWaterContentContainer, GFWaterContentContainer,
TransportOrder TransportOrder>;
>;
public: public:
using ModelRichards = Dune::Dorie::ModelRichards<ModelRichardsTraits>; using ModelRichards = Dune::Dorie::ModelRichards<ModelRichardsTraits>;
using ModelTransport = Dune::Dorie::ModelTransport<ModelTransportTraits>; using ModelTransport = Dune::Dorie::ModelTransport<ModelTransportTraits>;
...@@ -70,7 +74,6 @@ public: ...@@ -70,7 +74,6 @@ public:
using GridCreator = Dune::Dorie::GridCreator<typename BaseTraits::Grid>; using GridCreator = Dune::Dorie::GridCreator<typename BaseTraits::Grid>;
}; };
/** /**
* @brief Class for richards transport coupling model. * @brief Class for richards transport coupling model.
* @details For given ModelRichardsTransportCouplingTraits, this class * @details For given ModelRichardsTransportCouplingTraits, this class
...@@ -91,31 +94,31 @@ class ModelRichardsTransportCoupling : public ModelBase ...@@ -91,31 +94,31 @@ class ModelRichardsTransportCoupling : public ModelBase
{ {
public: public:
using Traits = T; using Traits = T;
private: private:
using ModelRichards = typename Traits::ModelRichards; using ModelRichards = typename Traits::ModelRichards;
using ModelTransport = typename Traits::ModelTransport; using ModelTransport = typename Traits::ModelTransport;
using ModelRichardsTraits = typename ModelRichards::Traits; using ModelRichardsTraits = typename ModelRichards::Traits;
using ModelTransportTraits = typename ModelTransport::Traits; using ModelTransportTraits = typename ModelTransport::Traits;
using GFWaterContentContainer = typename Traits::GFWaterContentContainer; using GFWaterContentContainer = typename Traits::GFWaterContentContainer;
using GFWaterFluxContainer = typename Traits::GFWaterFluxContainer; using GFWaterFluxContainer = typename Traits::GFWaterFluxContainer;
using GridCreator = typename Traits::GridCreator; using GridCreator = typename Traits::GridCreator;
using TimeField = typename Traits::TimeField; using TimeField = typename Traits::TimeField;
using RichardsState = typename ModelRichardsTraits::State; using RichardsState = typename ModelRichardsTraits::State;
std::shared_ptr<typename Traits::BaseTraits::Grid> _grid; std::shared_ptr<typename Traits::BaseTraits::Grid> _grid;
Dune::ParameterTree _inifile_richards, _inifile_transport; Dune::ParameterTree _inifile_richards, _inifile_transport;
std::unique_ptr<ModelRichards> _richards; std::unique_ptr<ModelRichards> _richards;
std::unique_ptr<ModelTransport> _transport; std::unique_ptr<ModelTransport> _transport;
RichardsState richards_state_before_step, richards_state_after_step; RichardsState richards_state_before_step, richards_state_after_step;
public: public:
/** /**
* @brief Construct Coupled model. * @brief Construct Coupled model.
* *
...@@ -126,21 +129,19 @@ public: ...@@ -126,21 +129,19 @@ public:
* *
* @todo Fix logger warning. * @todo Fix logger warning.
*/ */
ModelRichardsTransportCoupling ( ModelRichardsTransportCoupling(Dune::ParameterTree& inifile_richards,
Dune::ParameterTree& inifile_richards, Dune::ParameterTree& inifile_transport,
Dune::ParameterTree& inifile_transport, const GridCreator& _grid_creator,
const GridCreator& _grid_creator, Dune::MPIHelper& helper);
Dune::MPIHelper& helper
);
~ModelRichardsTransportCoupling() = default; ~ModelRichardsTransportCoupling() = default;
/*------------------------------------------------------------------------*//** /*------------------------------------------------------------------------*/ /**
* @brief Compute a time step. Models the time step requirement of * @brief Compute a time step. Models the time step requirement of
* ModelBase * ModelBase
* *
* @throws Dune::Exception Fatal error occurs during computation * @throws Dune::Exception Fatal error occurs during computation
*/ */
void step() override; void step() override;
/** /**
...@@ -149,30 +150,27 @@ public: ...@@ -149,30 +150,27 @@ public:
void mark_grid() override void mark_grid() override
{ {
// select model and mark the grid // select model and mark the grid
if (adaptivity_policy() == AdaptivityPolicy::WaterFlux) if (adaptivity_policy() == AdaptivityPolicy::WaterFlux) {
{
_richards->set_policy(adaptivity_policy()); _richards->set_policy(adaptivity_policy());
_richards->mark_grid(); _richards->mark_grid();
} } else if (adaptivity_policy() == AdaptivityPolicy::SoluteFlux) {
else if (adaptivity_policy() == AdaptivityPolicy::SoluteFlux)
{
_transport->set_policy(adaptivity_policy()); _transport->set_policy(adaptivity_policy());
_transport->mark_grid(); _transport->mark_grid();
} else if (adaptivity_policy() != AdaptivityPolicy::None) } else if (adaptivity_policy() != AdaptivityPolicy::None)
DUNE_THROW(Dune::NotImplemented,"Not known adaptivity policy!"); DUNE_THROW(Dune::NotImplemented, "Not known adaptivity policy!");
} }
/** /**
* @brief Operations before adaptation of the grid * @brief Operations before adaptation of the grid
*/ */
void pre_adapt_grid() override void pre_adapt_grid() override
{ {
_richards->pre_adapt_grid(); _richards->pre_adapt_grid();
_transport->pre_adapt_grid(); _transport->pre_adapt_grid();
}; };
/** /**
* @brief Adapt the grid together it every dependency of the * @brief Adapt the grid together it every dependency of the
* grid (e.g. solution vector and grid function spaces). * grid (e.g. solution vector and grid function spaces).
*/ */
void adapt_grid() override; void adapt_grid() override;
...@@ -182,44 +180,35 @@ public: ...@@ -182,44 +180,35 @@ public:
*/ */
void post_adapt_grid() override; void post_adapt_grid() override;
/*------------------------------------------------------------------------*//** /*------------------------------------------------------------------------*/ /**
* @brief Method that provides the begin time of the model. * @brief Method that provides the begin time of the model.
* *
* @return Begin time of the model. * @return Begin time of the model.
*/ */
double begin_time() const override double begin_time() const override { return _richards->begin_time(); }
{
return _richards->begin_time(); /*------------------------------------------------------------------------*/ /**
} * @brief Method that provides the end time of the model.
*
/*------------------------------------------------------------------------*//** * @return End time of the model.
* @brief Method that provides the end time of the model. */
* double end_time() const override { return _richards->end_time(); }
* @return End time of the model.
*/ /*------------------------------------------------------------------------*/ /**
double end_time() const override * @brief Suggest a time step to the model.
{ *
return _richards->end_time(); * @param[in] dt Suggestion for the internal time step of the model. The
} * new internal time step shall not be bigger than dt
*/
/*------------------------------------------------------------------------*//** void suggest_timestep(double dt) override { _richards->suggest_timestep(dt); }
* @brief Suggest a time step to the model.
* /*------------------------------------------------------------------------*/ /**
* @param[in] dt Suggestion for the internal time step of the model. The * @brief Write the data using the VTKWriter. VTKWriters is always
* new internal time step shall not be bigger than dt * cleared after used.
*/ *
void suggest_timestep(double dt) override * @param[in] time The time to print in th pvd file.
{ */
_richards->suggest_timestep(dt); void write_data() const override
}
/*------------------------------------------------------------------------*//**