1#ifndef DUNE_COPASI_MODEL_FACTORY_HH
2#define DUNE_COPASI_MODEL_FACTORY_HH
16#ifndef DUNE_COPASI_1D_DIFFUSION_REACTION_FEM_ORDERS
17#define DUNE_COPASI_1D_DIFFUSION_REACTION_FEM_ORDERS 1
20#ifndef DUNE_COPASI_2D_DIFFUSION_REACTION_FEM_ORDERS
21#define DUNE_COPASI_2D_DIFFUSION_REACTION_FEM_ORDERS 1
24#ifndef DUNE_COPASI_3D_DIFFUSION_REACTION_FEM_ORDERS
25#define DUNE_COPASI_3D_DIFFUSION_REACTION_FEM_ORDERS 1
31template<
class Model, std::
size_t Order,
bool SpeciesBlocked>
39template<
class Model, std::
size_t Order,
bool SpeciesBlocked,
bool CompartmentBlocked>
41 SingleCompartmentTraits<Model, Order, SpeciesBlocked>,
51 const ParameterTree& config,
56 if (not functor_factory) {
57 functor_factory = std::make_shared<FunctorFactoryParser<Model::Grid::dimensionworld>>();
60 const auto fem_orders = []() {
61 if constexpr (Model::Grid::dimensionworld == 1) {
62 return std::index_sequence<DUNE_COPASI_1D_DIFFUSION_REACTION_FEM_ORDERS>{};
63 }
else if constexpr (Model::Grid::dimensionworld == 2) {
64 return std::index_sequence<DUNE_COPASI_2D_DIFFUSION_REACTION_FEM_ORDERS>{};
65 }
else if constexpr (Model::Grid::dimensionworld == 3) {
66 return std::index_sequence<DUNE_COPASI_3D_DIFFUSION_REACTION_FEM_ORDERS>{};
68 return std::index_sequence<1>{};
72 auto config_fem_order = config.get(
"order", std::size_t{ 1 });
74 auto field_blocked = config.get(
"blocked_layout.scalar_fields",
false);
75 auto compartments_blocked = config.get(
"blocked_layout.compartments",
false);
77 std::set<std::string> compartments;
78 for (
const auto& component : config.sub(
"scalar_field").getSubKeys()) {
79 compartments.insert(config[fmt::format(
"scalar_field.{}.compartment", component)]);
83 auto not_know_order = [config_fem_order]() {
85 IOError{},
"Polynomail degree '{}' not available for this simulation", config_fem_order);
88 std::unique_ptr<Model> model;
90 if (compartments.size() == 1) {
92 Dune::Hybrid::switchCases(
97 model = std::make_unique<
99 functor_factory, cell_data);
101 model = std::make_unique<
103 functor_factory, cell_data);
109 Dune::Hybrid::switchCases(
112 [&](
auto fem_order) {
113 if (compartments_blocked) {
Container for cell data of a grid view.
Definition: cell_data.hh:25
Definition: model_multi_compartment.hh:28
Definition: model_single_compartment.hh:26
Definition: functor_factory.hh:24
Concept for dune multidomain grids.
Definition: grid.hh:51
Concept for dune subdomain grids of multidomain grids.
Definition: grid.hh:31
Definition: factory.hh:28
std::unique_ptr< Model > make_model(const ParameterTree &config, std::shared_ptr< const FunctorFactory< Model::Grid::dimensionworld > > functor_factory=nullptr, std::shared_ptr< const CellData< typename Model::Grid::LeafGridView, typename Model::RangeQuatinty > > cell_data=nullptr)
Definition: factory.hh:50
auto format_exception(Exception &&e, fmt::format_string< Args... > format, Args &&... args)
Definition: exceptions.hh:23
Definition: model_single_compartment_traits.hh:19
Definition: model_multi_compartment_traits.hh:20
GridView_ GridView
Definition: model.hh:32
TimeQuantity_ TimeQuantity
Definition: model.hh:33
Grid_ Grid
Definition: model.hh:31
RangeQuatinty_ RangeQuatinty
Definition: model.hh:34