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>
44template<
class MDTraits>
47 using SolutionVector =
typename MDTraits::SolutionVector;
48 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
50 template<std::
size_t i>
51 using GridGeometry =
typename MDTraits::template SubDomain<i>::GridGeometry;
52 using GridGeometries =
typename MDTraits::template TupleOfSharedPtrConst<GridGeometry>;
54 template<std::
size_t i>
55 using Problem =
typename MDTraits::template SubDomain<i>::Problem;
56 using Problems =
typename MDTraits::template TupleOfSharedPtrConst<Problem>;
60 template<std::
size_t i>
61 using Type =
typename MDTraits::template SubDomain<i>::GridVariables;
64 template<std::
size_t i>
68 using TupleType =
typename MDTraits::template Tuple<PtrType>;
73 [[deprecated(
"Will be removed after release 3.5. Use one of the constructors instead.")]]
83 using namespace Dune::Hybrid;
84 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
86 constexpr auto i = std::decay_t<
decltype(id)>::value;
87 std::get<i>(gridVars_) = std::make_shared<Type<i>>(
88 problems.template get<i>(), gridGeometries.template get<i>()
98 : gridVars_(std::move(ggTuple))
102 void init(
const SolutionVector& sol)
104 using namespace Dune::Hybrid;
105 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
107 elementAt(gridVars_,
id)->init(sol[
id]);
112 void update(
const SolutionVector& sol,
bool forceFluxCacheUpdate =
false)
114 using namespace Dune::Hybrid;
115 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
117 elementAt(gridVars_,
id)->update(sol[
id], forceFluxCacheUpdate);
124 using namespace Dune::Hybrid;
125 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
127 elementAt(gridVars_,
id)->updateAfterGridAdaption(sol[
id]);
137 using namespace Dune::Hybrid;
138 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
140 elementAt(gridVars_,
id)->advanceTimeStep();
147 using namespace Dune::Hybrid;
148 forEach(std::make_index_sequence<numSubDomains>{}, [&](
auto&& id)
150 elementAt(gridVars_,
id)->resetTimeStep(sol[
id]);
155 template<std::
size_t i>
157 {
return *std::get<i>(gridVars_); }
160 template<std::
size_t i>
162 {
return *std::get<i>(gridVars_); }
165 template<std::
size_t i>
166 const PtrType<i>&
get(Dune::index_constant<i>
id = Dune::index_constant<i>{})
const
167 {
return std::get<i>(gridVars_); }
170 template<std::
size_t i>
172 {
return std::get<i>(gridVars_); }
175 template<std::
size_t i>
176 [[deprecated(
"Will be removed after release 3.5. Use one of the constructors instead.")]]
177 void set(
PtrType<i> p, Dune::index_constant<i>
id = Dune::index_constant<i>{})
178 { Dune::Hybrid::elementAt(gridVars_,
id) = p; }
184 [[deprecated(
"Use asTuple. Will be removed after release 3.5")]]
186 {
return gridVars_; }
192 {
return gridVars_; }
198 {
return gridVars_; }
A multidomain wrapper for multiple grid geometries.
Definition: multidomain/fvgridgeometry.hh:58
A multidomain wrapper for multiple grid variables.
Definition: multidomain/fvgridvariables.hh:46
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvgridvariables.hh:68
MultiDomainFVGridVariables(TupleType ggTuple)
Construct wrapper from a tuple of grid variables.
Definition: multidomain/fvgridvariables.hh:97
typename MDTraits::template SubDomain< i >::GridVariables Type
export base types of the stored type
Definition: multidomain/fvgridvariables.hh:61
const TupleType & asTuple() const
Access the underlying tuple representation.
Definition: multidomain/fvgridvariables.hh:197
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:177
void update(const SolutionVector &sol, bool forceFluxCacheUpdate=false)
update all variables
Definition: multidomain/fvgridvariables.hh:112
MultiDomainFVGridVariables(MultiDomainFVGridGeometry< MDTraits > gridGeometries, MultiDomainFVProblem< MDTraits > problems)
Contruct the grid variables.
Definition: multidomain/fvgridvariables.hh:81
const Type< i > & operator[](Dune::index_constant< i > id) const
return the grid variables for domain with index i
Definition: multidomain/fvgridvariables.hh:156
void updateAfterGridAdaption(const SolutionVector &sol)
update all variables after grid adaption
Definition: multidomain/fvgridvariables.hh:122
const PtrType< i > & get(Dune::index_constant< i > id=Dune::index_constant< i >{}) const
access the ith grid variables pointer we are wrapping
Definition: multidomain/fvgridvariables.hh:166
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvgridvariables.hh:65
MultiDomainFVGridVariables()=default
The default constructor.
void init(const SolutionVector &sol)
initialize all variables
Definition: multidomain/fvgridvariables.hh:102
void resetTimeStep(const SolutionVector &sol)
resets state to the one before time integration
Definition: multidomain/fvgridvariables.hh:145
PtrType< i > & get(Dune::index_constant< i > id=Dune::index_constant< i >{})
access the ith grid variables pointer we are wrapping
Definition: multidomain/fvgridvariables.hh:171
void advanceTimeStep()
Sets the current state as the previous for next time step.
Definition: multidomain/fvgridvariables.hh:135
TupleType & asTuple()
Access the underlying tuple representation.
Definition: multidomain/fvgridvariables.hh:191
TupleType getTuple()
return the grid variables tuple we are wrapping
Definition: multidomain/fvgridvariables.hh:185
A multidomain wrapper for multiple problems.
Definition: multidomain/fvproblem.hh:45
Multidomain wrapper for multiple problems.
Multidomain wrapper for multiple grid geometries.