24#ifndef DUMUX_MULTIDOMAIN_FV_GRID_VARIABLES_HH
25#define DUMUX_MULTIDOMAIN_FV_GRID_VARIABLES_HH
31#include <dune/common/hybridutilities.hh>
32#include <dune/common/indices.hh>
41template<
class MDTraits>
44 using SolutionVector =
typename MDTraits::SolutionVector;
45 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
47 template<std::
size_t i>
48 using GridGeometry =
typename MDTraits::template SubDomain<i>::GridGeometry;
49 using GridGeometries =
typename MDTraits::template TupleOfSharedPtrConst<GridGeometry>;
51 template<std::
size_t i>
52 using Problem =
typename MDTraits::template SubDomain<i>::Problem;
53 using Problems =
typename MDTraits::template TupleOfSharedPtrConst<Problem>;
57 template<std::
size_t i>
58 using Type =
typename MDTraits::template SubDomain<i>::GridVariables;
61 template<std::
size_t i>
65 using TupleType =
typename MDTraits::template Tuple<PtrType>;
79 using namespace Dune::Hybrid;
80 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
82 constexpr auto i = std::decay_t<
decltype(id)>::value;
83 elementAt(gridVars_,
id) = std::make_shared<Type<i>>( std::get<i>(problems), std::get<i>(gridGeometries));
88 void init(
const SolutionVector& sol)
90 using namespace Dune::Hybrid;
91 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
93 elementAt(gridVars_,
id)->init(sol[
id]);
98 void update(
const SolutionVector& sol,
bool forceFluxCacheUpdate =
false)
100 using namespace Dune::Hybrid;
101 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
103 elementAt(gridVars_,
id)->update(sol[
id], forceFluxCacheUpdate);
110 using namespace Dune::Hybrid;
111 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
113 elementAt(gridVars_,
id)->updateAfterGridAdaption(sol[
id]);
123 using namespace Dune::Hybrid;
124 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
126 elementAt(gridVars_,
id)->advanceTimeStep();
133 using namespace Dune::Hybrid;
134 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
136 elementAt(gridVars_,
id)->resetTimeStep(sol[
id]);
141 template<std::
size_t i>
143 {
return *Dune::Hybrid::elementAt(gridVars_,
id); }
146 template<std::
size_t i>
148 {
return *Dune::Hybrid::elementAt(gridVars_,
id); }
151 template<std::
size_t i>
153 {
return Dune::Hybrid::elementAt(gridVars_,
id); }
156 template<std::
size_t i>
157 void set(
PtrType<i> p, Dune::index_constant<i>
id = Dune::index_constant<i>{})
158 { Dune::Hybrid::elementAt(gridVars_,
id) = p; }
165 {
return gridVars_; }
A multidomain wrapper for multiple grid variables.
Definition: multidomain/fvgridvariables.hh:43
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvgridvariables.hh:65
typename MDTraits::template SubDomain< i >::GridVariables Type
export base types of the stored type
Definition: multidomain/fvgridvariables.hh:58
void set(PtrType< i > p, Dune::index_constant< i > id=Dune::index_constant< i >{})
set the pointer for sub domain i
Definition: multidomain/fvgridvariables.hh:157
void update(const SolutionVector &sol, bool forceFluxCacheUpdate=false)
update all variables
Definition: multidomain/fvgridvariables.hh:98
PtrType< i > get(Dune::index_constant< i > id=Dune::index_constant< i >{})
return the grid variables tuple we are wrapping
Definition: multidomain/fvgridvariables.hh:152
const Type< i > & operator[](Dune::index_constant< i > id) const
return the grid variables for domain with index i
Definition: multidomain/fvgridvariables.hh:142
void updateAfterGridAdaption(const SolutionVector &sol)
update all variables after grid adaption
Definition: multidomain/fvgridvariables.hh:108
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvgridvariables.hh:62
MultiDomainFVGridVariables()=default
The default constructor.
void init(const SolutionVector &sol)
initialize all variables
Definition: multidomain/fvgridvariables.hh:88
MultiDomainFVGridVariables(GridGeometries &&gridGeometries, Problems &&problems)
Contruct the grid variables.
Definition: multidomain/fvgridvariables.hh:77
void resetTimeStep(const SolutionVector &sol)
resets state to the one before time integration
Definition: multidomain/fvgridvariables.hh:131
void advanceTimeStep()
Sets the current state as the previous for next time step.
Definition: multidomain/fvgridvariables.hh:121
TupleType getTuple()
return the grid variables tuple we are wrapping
Definition: multidomain/fvgridvariables.hh:164