Dune::Copasi
Loading...
Searching...
No Matches
model_multi_compartment.hh
Go to the documentation of this file.
1#ifndef DUNE_COPASI_MODEL_DIFFUSION_REACTION_MULTI_COMPARTMENT_HH
2#define DUNE_COPASI_MODEL_DIFFUSION_REACTION_MULTI_COMPARTMENT_HH
3
4// file: diffusion reaction for multi compartment models
5
11
12#include <dune/pdelab/basis/merging_strategy.hh>
13#include <dune/pdelab/basis/prebasis/composite.hh>
14#include <dune/pdelab/basis/prebasis/leaf.hh>
15#include <dune/pdelab/finiteelementmap/pkfem.hh>
16
17#include <dune/grid/concepts/grid.hh>
18#include <dune/grid/concepts/gridview.hh>
19
21
22template<class Traits>
24 : public Model<typename Traits::Grid,
25 typename Traits::CompartmentEntitySet,
26 typename Traits::RangeQuatinty,
27 typename Traits::TimeQuantity>
28{
29 using Base = Model<typename Traits::Grid,
30 typename Traits::CompartmentEntitySet,
31 typename Traits::RangeQuatinty,
32 typename Traits::TimeQuantity>;
33
34public:
35 using State = typename Base::State;
36 using Grid = typename Traits::Grid;
37 using TimeQuantity = typename Traits::TimeQuantity;
38 using ScalarQuantity = typename Traits::RangeQuatinty;
39 using CompartmentEntitySet = typename Traits::CompartmentEntitySet;
40 using MultiCompartmentEntitySet = typename Traits::MultiCompartmentEntitySet;
41
42 using ScalarFiniteElementMap = typename Traits::ScalarFiniteElementMap;
43
44 using ScalarMergingStrategy = typename Traits::ScalarMergingStrategy;
45 using CompartmentMergingStrategy = typename Traits::CompartmentMergingStrategy;
46 using MultiCompartmentMergingStrategy = typename Traits::MultiCompartmentMergingStrategy;
47
49 PDELab::PreBasis<ScalarMergingStrategy, ScalarFiniteElementMap, Constraints<CompartmentEntitySet>>;
50 using CompartmentPreBasis = PDELab::PreBasisVector<CompartmentMergingStrategy, ScalarPreBasis>;
52 PDELab::PreBasisVector<MultiCompartmentMergingStrategy, CompartmentPreBasis>;
53
55
57
61 : _functor_factory{ std::move(functor_factory) }
62 , _cell_data{ std::move(cell_data) }
63 {
64 assert(_functor_factory);
65 }
66
67 std::unique_ptr<State> make_state(const std::shared_ptr<const Grid>&,
68 const ParameterTree&) const override;
69
70 void interpolate(State&, const std::unordered_map<std::string, GridFunction>&) const override;
71
72 std::unordered_map<std::string, GridFunction> make_initial(const Grid&,
73 const ParameterTree&) const override;
74
75 GridFunction make_compartment_function(const std::shared_ptr<const State>&,
76 std::string_view) const override;
77
78 std::unique_ptr<PDELab::OneStep<State>> make_step_operator(const State&,
79 const ParameterTree&) const override;
80
81 void write_vtk(const State&, const std::filesystem::path&, bool) const override;
82
83 std::map<std::string, double> reduce(const State&, const ParameterTree&) const override;
84
85private:
86 static MultiCompartmentPreBasis make_multi_compartment_pre_basis(const Grid&,
87 const ParameterTree&,
88 std::shared_ptr<const FunctorFactory<Grid::dimensionworld>>);
89
90 static void setup_coefficient_vector(State&);
91 static CompartmentEntitySet get_entity_set(const Grid&, std::size_t);
92
93 mutable std::unordered_map<std::string, std::vector<double>> _writer_timesteps;
94 std::shared_ptr<const FunctorFactory<Grid::dimensionworld>> _functor_factory;
95 std::shared_ptr<const CellData<typename Grid::LeafGridView, ScalarQuantity>> _cell_data;
96};
97
98} // namespace Dune::Copasi::DiffusionReaction
99
100#ifndef DUNE_COPASI_PRECOMPILED_MODE
102#endif
103
104#endif // DUNE_COPASI_MODEL_DIFFUSION_REACTION_MULTI_COMPARTMENT_HH
Container for cell data of a grid view.
Definition cell_data.hh:25
Definition model_multi_compartment.hh:28
PDELab::PreBasisVector< CompartmentMergingStrategy, ScalarPreBasis > CompartmentPreBasis
Definition model_multi_compartment.hh:50
void write_vtk(const State &, const std::filesystem::path &, bool) const override
Definition model_multi_compartment.impl.hh:220
ModelMultiCompartment(std::shared_ptr< const FunctorFactory< Grid::dimensionworld > > functor_factory, std::shared_ptr< const CellData< typename Grid::LeafGridView, ScalarQuantity > > cell_data=nullptr)
Definition model_multi_compartment.hh:58
GridFunction make_compartment_function(const std::shared_ptr< const State > &, std::string_view) const override
Definition model_multi_compartment.impl.hh:126
ScalarQuantity ResidualQuantity
Definition model_multi_compartment.hh:54
typename Base::State State
Definition model_multi_compartment.hh:35
void interpolate(State &, const std::unordered_map< std::string, GridFunction > &) const override
Definition model_multi_compartment.impl.hh:33
typename Traits::ScalarFiniteElementMap ScalarFiniteElementMap
Definition model_multi_compartment.hh:42
typename Traits::CompartmentMergingStrategy CompartmentMergingStrategy
Definition model_multi_compartment.hh:45
typename Traits::RangeQuatinty ScalarQuantity
Definition model_multi_compartment.hh:38
PDELab::PreBasisVector< MultiCompartmentMergingStrategy, CompartmentPreBasis > MultiCompartmentPreBasis
Definition model_multi_compartment.hh:51
std::unordered_map< std::string, GridFunction > make_initial(const Grid &, const ParameterTree &) const override
Definition model_multi_compartment.impl.hh:155
typename Traits::MultiCompartmentEntitySet MultiCompartmentEntitySet
Definition model_multi_compartment.hh:40
typename Traits::Grid Grid
Definition model_multi_compartment.hh:36
typename Traits::CompartmentEntitySet CompartmentEntitySet
Definition model_multi_compartment.hh:39
typename Traits::ScalarMergingStrategy ScalarMergingStrategy
Definition model_multi_compartment.hh:44
typename Base::GridFunction GridFunction
Definition model_multi_compartment.hh:56
typename Traits::TimeQuantity TimeQuantity
Definition model_multi_compartment.hh:37
std::unique_ptr< State > make_state(const std::shared_ptr< const Grid > &, const ParameterTree &) const override
Definition model_multi_compartment.impl.hh:111
std::unique_ptr< PDELab::OneStep< State > > make_step_operator(const State &, const ParameterTree &) const override
Definition model_multi_compartment.impl.hh:181
PDELab::PreBasis< ScalarMergingStrategy, ScalarFiniteElementMap, Constraints< CompartmentEntitySet > > ScalarPreBasis
Definition model_multi_compartment.hh:48
std::map< std::string, double > reduce(const State &, const ParameterTree &) const override
Definition model_multi_compartment.impl.hh:164
typename Traits::MultiCompartmentMergingStrategy MultiCompartmentMergingStrategy
Definition model_multi_compartment.hh:46
Definition functor_factory.hh:24
Definition factory.hh:28
constexpr bool is_bitflags_v
Alias for Bitflag indicator.
Definition bit_flags.hh:24
Definition model.hh:37
Definition model.hh:29
Dune::Functions::GridViewFunction< RangeQuatinty(typename GridView::template Codim< 0 >::Geometry::GlobalCoordinate), GridView > GridFunction
Definition model.hh:44