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
#define DUNE_DORIE_RAVIART_THOMAS_DG_FEM_HH
#include <dune/pdelab/finiteelementmap/finiteelementmap.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>
......
......@@ -9,8 +9,8 @@
#include <dune/dorie/common/typedefs.hh>
namespace Dune{
namespace Dorie{
namespace Dune {
namespace Dorie {
/**
* @brief Base class for models.
......@@ -24,7 +24,6 @@ namespace Dorie{
class ModelBase
{
public:
/**
* @brief Constructs the ModelBase.
*
......@@ -36,26 +35,27 @@ public:
* @param[in] adapt_policy The adapt policy.
* Defaults to AdaptiviyPolicy::None.
*/
ModelBase(
const std::string log_name,
ModelBase(const std::string log_name,
const std::string log_level,
const Dune::MPIHelper& helper,
OutputPolicy output_policy=OutputPolicy::None,
AdaptivityPolicy adapt_policy=AdaptivityPolicy::None
)
OutputPolicy output_policy = OutputPolicy::None,
AdaptivityPolicy adapt_policy = AdaptivityPolicy::None)
: _output_policy(output_policy)
, _adapt_policy(adapt_policy)
, _time(0.0)
, _log(create_logger(log_name, helper, spdlog::level::from_str(log_level)))
{ }
{}
virtual ~ModelBase () = default;
virtual ~ModelBase() = default;
/**
* @brief Sets 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.
......@@ -72,20 +72,19 @@ public:
*
* @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.
*
* @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
/** @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;
}
......@@ -119,7 +118,7 @@ public:
/**
* @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.
......@@ -131,8 +130,7 @@ public:
_log->error("This model does not implement a grid adaptation "
"algorithm.");
DUNE_THROW(Dune::NotImplemented, "'adapt_grid' not implemented");
}
else {
} else {
_log->error("Calling 'adapt_grid' on a model with "
"AdaptivityPolicy::None. Grid adaptation refused");
DUNE_THROW(Dune::InvalidStateException, "Invalid adaptation policy");
......@@ -142,7 +140,7 @@ public:
/**
* @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.
......@@ -189,13 +187,11 @@ public:
if (output_policy() != OutputPolicy::None)
write_data();
while( Dune::FloatCmp::lt( current_time(), end_time()) )
{
while (Dune::FloatCmp::lt(current_time(), end_time())) {
step();
if (adaptivity_policy() != AdaptivityPolicy::None)
if ( Dune::FloatCmp::lt( current_time(), end_time()) )
{
if (Dune::FloatCmp::lt(current_time(), end_time())) {
mark_grid();
pre_adapt_grid();
adapt_grid();
......
......@@ -10,8 +10,8 @@
#include <gtest/gtest.h>
#endif
namespace Dune{
namespace Dorie{
namespace Dune {
namespace Dorie {
/**
* @brief Traits for the class ModelRichardsTransportCoupling.
......@@ -29,11 +29,15 @@ namespace Dorie{
* @tparam TransportOrder Order of the polynomial degree used for the basis
* 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
{
private:
using ModelRichardsTraits = Dune::Dorie::ModelRichardsTraits<BaseTraits,RichardsOrder>;
using ModelRichardsTraits =
Dune::Dorie::ModelRichardsTraits<BaseTraits, RichardsOrder>;
public:
static_assert(ModelRichardsTraits::enable_rt_engine,
"Flux reconstruction is not available in the Richards model!");
......@@ -42,25 +46,25 @@ public:
/** \note Interpolates linearly between time steps.
* \see GridFunctionContainerPolicy
*/
using GFWaterContentContainer = GridFunctionContainer<
const typename ModelRichardsTraits::GFWaterContent,
using GFWaterContentContainer =
GridFunctionContainer<const typename ModelRichardsTraits::GFWaterContent,
double,
GridFunctionContainerPolicy::LinearInterpolation
>;
GridFunctionContainerPolicy::LinearInterpolation>;
/// Container for the water flux grid function
/** \note Returns the next future value
* \see GridFunctionContainerPolicy
*/
using GFWaterFluxContainer = GridFunctionContainer<const typename ModelRichardsTraits::GFFluxReconstruction>;
using GFWaterFluxContainer = GridFunctionContainer<
const typename ModelRichardsTraits::GFFluxReconstruction>;
private:
using ModelTransportTraits = Dune::Dorie::ModelTransportTraits<
BaseTraits,
using ModelTransportTraits =
Dune::Dorie::ModelTransportTraits<BaseTraits,
GFWaterFluxContainer,
GFWaterContentContainer,
TransportOrder
>;
TransportOrder>;
public:
using ModelRichards = Dune::Dorie::ModelRichards<ModelRichardsTraits>;
using ModelTransport = Dune::Dorie::ModelTransport<ModelTransportTraits>;
......@@ -70,7 +74,6 @@ public:
using GridCreator = Dune::Dorie::GridCreator<typename BaseTraits::Grid>;
};
/**
* @brief Class for richards transport coupling model.
* @details For given ModelRichardsTransportCouplingTraits, this class
......@@ -91,6 +94,7 @@ class ModelRichardsTransportCoupling : public ModelBase
{
public:
using Traits = T;
private:
using ModelRichards = typename Traits::ModelRichards;
using ModelTransport = typename Traits::ModelTransport;
......@@ -115,7 +119,6 @@ private:
RichardsState richards_state_before_step, richards_state_after_step;
public:
/**
* @brief Construct Coupled model.
*
......@@ -126,16 +129,14 @@ public:
*
* @todo Fix logger warning.
*/
ModelRichardsTransportCoupling (
Dune::ParameterTree& inifile_richards,
ModelRichardsTransportCoupling(Dune::ParameterTree& inifile_richards,
Dune::ParameterTree& inifile_transport,
const GridCreator& _grid_creator,
Dune::MPIHelper& helper
);
Dune::MPIHelper& helper);
~ModelRichardsTransportCoupling() = default;
/*------------------------------------------------------------------------*//**
/*------------------------------------------------------------------------*/ /**
* @brief Compute a time step. Models the time step requirement of
* ModelBase
*
......@@ -149,17 +150,14 @@ public:
void mark_grid() override
{
// select model and mark the grid
if (adaptivity_policy() == AdaptivityPolicy::WaterFlux)
{
if (adaptivity_policy() == AdaptivityPolicy::WaterFlux) {
_richards->set_policy(adaptivity_policy());
_richards->mark_grid();
}
else if (adaptivity_policy() == AdaptivityPolicy::SoluteFlux)
{
} 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!");
DUNE_THROW(Dune::NotImplemented, "Not known adaptivity policy!");
}
/**
......@@ -182,44 +180,35 @@ public:
*/
void post_adapt_grid() override;
/*------------------------------------------------------------------------*//**
/*------------------------------------------------------------------------*/ /**
* @brief Method that provides the begin time of the model.
*
* @return Begin time of the model.
*/
double begin_time() const override
{
return _richards->begin_time();
}
double begin_time() const override { return _richards->begin_time(); }
/*------------------------------------------------------------------------*//**
/*------------------------------------------------------------------------*/ /**
* @brief Method that provides the end time of the model.
*
* @return End time of the model.
*/
double end_time() const override
{
return _richards->end_time();
}
double end_time() const override { return _richards->end_time(); }
/*------------------------------------------------------------------------*//**
/*------------------------------------------------------------------------*/ /**
* @brief Suggest a time step to the model.
*
* @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);
}
void suggest_timestep(double dt) override { _richards->suggest_timestep(dt); }
/*------------------------------------------------------------------------*//**
/*------------------------------------------------------------------------*/ /**
* @brief Write the data using the VTKWriter. VTKWriters is always
* cleared after used.
*
* @param[in] time The time to print in th pvd file.
*/
void write_data () const override
void write_data() const override
{
if (_richards->output_policy() != OutputPolicy::None)
_richards->write_data();
......@@ -228,13 +217,11 @@ public:
}
private:
#ifdef GTEST
FRIEND_TEST(ModelCoupling, TimeSteps);
#endif
};
} // namespace Dorie
} // namespace Dune
......
#ifndef DUNE_DORIE_MODEL_FACTORY_HH
#define DUNE_DORIE_MODEL_FACTORY_HH
#ifndef DORIE_DIM
#error DORIE_DIM macro must be defined for factory builds
#else
static_assert(DORIE_DIM == 2 or DORIE_DIM == 3,
static_assert(DORIE_DIM == 2 or DORIE_DIM == 3,
"DORiE can only be built in 2D or 3D");
#endif
#include <memory>
#include <utility>
#include <dune/common/parametertree.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/parametertree.hh>
#include <dune/geometry/type.hh>
#include <dune/grid/uggrid.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/dorie/common/setup.hh>
#include <dune/dorie/common/logging.hh>
#include <dune/dorie/common/utility.hh>
#include <dune/dorie/common/grid_creator.hh>
#include <dune/dorie/common/logging.hh>
#include <dune/dorie/common/setup.hh>
#include <dune/dorie/common/utility.hh>
#include <dune/dorie/model/base.hh>
......@@ -51,21 +49,17 @@ protected:
using StructuredGrid = Dune::YaspGrid<dim>;
template<class Grid>
using BaseTraitsSimplex
= BaseTraits<Grid,
Dune::GeometryType::BasicType::simplex>;
using BaseTraitsSimplex =
BaseTraits<Grid, Dune::GeometryType::BasicType::simplex>;
template<class Grid>
using BaseTraitsCube
= BaseTraits<Grid,
Dune::GeometryType::BasicType::cube>;
using BaseTraitsCube = BaseTraits<Grid, Dune::GeometryType::BasicType::cube>;
/// Return the grid settings
/** \return Pair: Grid type/mode setting, bool if adaptivity is enabled
*/
static std::pair<GridMode, bool> get_grid_config (
const Dune::ParameterTree& config
)
static std::pair<GridMode, bool> get_grid_config(
const Dune::ParameterTree& config)
{
const auto log = get_logger(log_base);
......@@ -78,37 +72,29 @@ protected:
const auto grid_type = config.get<std::string>("grid.gridType");
if (grid_type == "gmsh") {
grid_mode = GridMode::gmsh;
}
else if (grid_type == "rectangular") {
} else if (grid_type == "rectangular") {
grid_mode = GridMode::rectangular;
}
else {
log->error("Unknown grid type: {}",
grid_type);
} else {
log->error("Unknown grid type: {}", grid_type);
DUNE_THROW(IOError, "Unknown grid type");
}
return {grid_mode, adaptivity_enbaled};
return { grid_mode, adaptivity_enbaled };
}
/// Return the adaptivity policy read from a config tree
static AdaptivityPolicy get_adaptivity_policy (
const Dune::ParameterTree& config
)
static AdaptivityPolicy get_adaptivity_policy(
const Dune::ParameterTree& config)
{
std::string adapt_policy_str
= config.get<std::string>("adaptivity.policy");
std::string adapt_policy_str = config.get<std::string>("adaptivity.policy");
if (adapt_policy_str == "waterFlux") {
return AdaptivityPolicy::WaterFlux;
}
else if (adapt_policy_str == "soluteFlux") {
} else if (adapt_policy_str == "soluteFlux") {
return AdaptivityPolicy::SoluteFlux;
}
else if (is_none(adapt_policy_str)) {
} else if (is_none(adapt_policy_str)) {
return AdaptivityPolicy::None;
}
else {
} else {
const auto log = get_logger(log_base);
log->error("Unknown adaptivity policy: {}", adapt_policy_str);
DUNE_THROW(IOError, "Unknown adaptivity policy");
......@@ -116,7 +102,7 @@ protected:
}
/// Raise an error that the FV solver does not support unstructured grids
static void raise_error_fv_grid ()
static void raise_error_fv_grid()
{
const auto log = get_logger(log_base);
log->error("The FV solver does not support unstructured grids. "
......
......@@ -8,9 +8,9 @@
#ifndef DORIE_RORDER
#error DORIE_RORDER macro must be defined for Richards factory builds
#else
static_assert(DORIE_RORDER >= 0,
static_assert(DORIE_RORDER >= 0,
"Negative polynomial orders do not make sense");
static_assert(DORIE_RORDER <= 6,
static_assert(DORIE_RORDER <= 6,
"DORiE only supports polynomial orders up to 6");
#endif
......@@ -50,17 +50,15 @@ private:
using ModRichards = ModelRichards<Traits>;
template<class Grid, int order>
using ModRichardsSimplex
= ModRichards<ModelRichardsTraits<BaseTraitsSimplex<Grid>,
order>>;
using ModRichardsSimplex =
ModRichards<ModelRichardsTraits<BaseTraitsSimplex<Grid>, order>>;
template<class Grid, int order>
using ModRichardsCube
= ModRichards<ModelRichardsTraits<BaseTraitsCube<Grid>,
order>>;
using ModRichardsCube =
ModRichards<ModelRichardsTraits<BaseTraitsCube<Grid>, order>>;
/// Verify that the run-time config matches the compile-time settings
static void check_settings (const Dune::ParameterTree& config)
static void check_settings(const Dune::ParameterTree& config)
{
const auto dim = config.get<int>("grid.dimensions");
const auto fem_order = config.get<int>("richards.numerics.FEorder");
......@@ -68,20 +66,18 @@ private:
const auto log = get_logger(log_base);
if (dim != DORIE_DIM or fem_order != DORIE_RORDER) {
log->error("Config settings do not match compile-time settings:");
log->error(" DORIE_DIM: {}, grid.dimensions: {}",
DORIE_DIM, dim);
log->error(" DORIE_DIM: {}, grid.dimensions: {}", DORIE_DIM, dim);
log->error(" DORIE_RORDER: {}, richards.numerics.FEorder: {}",
DORIE_RORDER, fem_order);
DORIE_RORDER,
fem_order);
DUNE_THROW(IOError, "Config settings not supported");
}
}
public:
/// Create a Richards Model from input parameters
static std::shared_ptr<ModelBase> create (
const Dune::ParameterTree& config,
Dune::MPIHelper& helper
)
static std::shared_ptr<ModelBase> create(const Dune::ParameterTree& config,
Dune::MPIHelper& helper)
{
check_settings(config);
std::shared_ptr<ModelBase> mod;
......@@ -90,32 +86,28 @@ public:
const auto [grid_mode, grid_adaptive] = get_grid_config(config);
auto config_richards = Setup::prep_ini_for_richards(config);
if (grid_mode == GridMode::gmsh)
{
if (grid_mode == GridMode::gmsh) {
using GridType = UnstructuredGrid<dim>;
GridCreator<GridType> grid_creator(config, helper);
#if (DORIE_RORDER > 0)
#if (DORIE_RORDER > 0)
mod = std::make_shared<ModRichardsSimplex<GridType, DORIE_RORDER>>(
config_richards, grid_creator, helper
);
#else
config_richards, grid_creator, helper);
#else
raise_error_fv_grid();
#endif
}
else // GridMode::rectangular
#endif
} else // GridMode::rectangular
{
if (grid_adaptive) {
using GridType = UnstructuredGrid<dim>;
GridCreator<GridType> grid_creator(config, helper);
#if (DORIE_RORDER > 0)
#if (DORIE_RORDER > 0)
mod = std::make_shared<ModRichardsCube<GridType, DORIE_RORDER>>(
config_richards, grid_creator, helper
);
#else
config_richards, grid_creator, helper);
#else
raise_error_fv_grid();
#endif
#endif
}
// grid not adaptive
else {
......@@ -123,8 +115,7 @@ public:
GridCreator<GridType> grid_creator(config, helper);
mod = std::make_shared<ModRichardsCube<GridType, DORIE_RORDER>>(
config_richards, grid_creator, helper
);
config_richards, grid_creator, helper);
}
}
......@@ -134,7 +125,6 @@ public:
return mod;
}
};
} // namespace Dorie
......
......@@ -3,16 +3,16 @@
#include <dune/dorie/model/factory.hh>
#include <dune/dorie/model/richards/richards.hh>
#include <dune/dorie/model/coupling/richards_coupling.hh>
#include <dune/dorie/model/richards/richards.hh>
// Checks for custom setup
#ifndef DORIE_TORDER
#error DORIE_TORDER macro must be defined for Transport factory builds
#else
static_assert(DORIE_TORDER >= 0,
static_assert(DORIE_TORDER >= 0,
"Negative polynomial orders do not make sense");
static_assert(DORIE_TORDER <= 6,
static_assert(DORIE_TORDER <= 6,
"DORiE only supports polynomial orders up to 6");
#endif
......@@ -23,7 +23,7 @@
#if DORIE_RORDER == 0
#define DORIE_RT_ORDER 0
#else
#define DORIE_RT_ORDER DORIE_RORDER-1
#define DORIE_RT_ORDER DORIE_RORDER - 1
#endif
namespace Dune {
......@@ -63,48 +63,42 @@ private:
/// Convenience typedef for a shorter name
template<class BaseTraits, int order_richards, int order_transport>
using TransportTraits
= ModelRichardsTransportCouplingTraits<BaseTraits,
using TransportTraits = ModelRichardsTransportCouplingTraits<BaseTraits,
order_richards,
order_transport>;
template<class Grid, int order_richards, int order_transport>
using ModTransportSimplex
= ModTransport<TransportTraits<BaseTraitsSimplex<Grid>,
order_richards,
order_transport>>;
using ModTransportSimplex = ModTransport<
TransportTraits<BaseTraitsSimplex<Grid>, order_richards, order_transport>>;