3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
multidomain/fvproblem.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_MULTIDOMAIN_FV_PROBLEM_HH
25#define DUMUX_MULTIDOMAIN_FV_PROBLEM_HH
26
27#include <tuple>
28#include <memory>
29#include <utility>
30
31#include <dune/common/hybridutilities.hh>
32#include <dune/common/indices.hh>
33
35
36namespace Dumux {
37
43template<class MDTraits>
45{
46 using SolutionVector = typename MDTraits::SolutionVector;
47 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
48
49 template<std::size_t i>
50 using GridGeometry = typename MDTraits::template SubDomain<i>::GridGeometry;
51 using GridGeometries = typename MDTraits::template Tuple<GridGeometry>;
52
53public:
55 template<std::size_t i>
56 using Type = typename MDTraits::template SubDomain<i>::Problem;
57
59 template<std::size_t i>
60 using PtrType = std::shared_ptr<Type<i>>;
61
63 using TupleType = typename MDTraits::template Tuple<PtrType>;
64
70 {
71 using namespace Dune::Hybrid;
72 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
73 {
74 constexpr auto i = std::decay_t<decltype(id)>::value;
75 std::get<i>(problems_) = std::make_shared<Type<i>>(gridGeometries.template get<i>());
76 });
77 }
78
84 : problems_(std::move(problemTuple))
85 {}
86
91 void applyInitialSolution(SolutionVector& sol) const
92 {
93 using namespace Dune::Hybrid;
94 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
95 {
96 elementAt(problems_, id)->applyInitialSolution(sol[id]);
97 });
98 }
99
101 template<std::size_t i>
102 const Type<i>& operator[] (Dune::index_constant<i> id) const
103 { return *std::get<i>(problems_); }
104
106 template<std::size_t i>
107 Type<i>& operator[] (Dune::index_constant<i> id)
108 { return *std::get<i>(problems_); }
109
111 template<std::size_t i>
112 const PtrType<i>& get(Dune::index_constant<i> id = Dune::index_constant<i>{}) const
113 { return std::get<i>(problems_); }
114
116 template<std::size_t i>
117 PtrType<i>& get(Dune::index_constant<i> id = Dune::index_constant<i>{})
118 { return std::get<i>(problems_); }
119
124 { return problems_; }
125
129 const TupleType& asTuple() const
130 { return problems_; }
131
132private:
133
135 TupleType problems_;
136};
137
138} // end namespace Dumux
139
140#endif
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
A multidomain wrapper for multiple grid geometries.
Definition: multidomain/fvgridgeometry.hh:58
A multidomain wrapper for multiple problems.
Definition: multidomain/fvproblem.hh:45
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvproblem.hh:60
PtrType< i > & get(Dune::index_constant< i > id=Dune::index_constant< i >{})
access the problem ptr for domain with index i
Definition: multidomain/fvproblem.hh:117
const PtrType< i > & get(Dune::index_constant< i > id=Dune::index_constant< i >{}) const
access the problem ptr for domain with index i
Definition: multidomain/fvproblem.hh:112
MultiDomainFVProblem(TupleType problemTuple)
Construct wrapper from a tuple of problems.
Definition: multidomain/fvproblem.hh:83
typename MDTraits::template SubDomain< i >::Problem Type
export base types of the stored type
Definition: multidomain/fvproblem.hh:56
MultiDomainFVProblem(MultiDomainFVGridGeometry< MDTraits > gridGeometries)
Construct the problem.
Definition: multidomain/fvproblem.hh:69
const Type< i > & operator[](Dune::index_constant< i > id) const
return the problem for domain with index i
Definition: multidomain/fvproblem.hh:102
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvproblem.hh:63
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: multidomain/fvproblem.hh:91
const TupleType & asTuple() const
Access the underlying tuple representation.
Definition: multidomain/fvproblem.hh:129
TupleType & asTuple()
Access the underlying tuple representation.
Definition: multidomain/fvproblem.hh:123
Multidomain wrapper for multiple grid geometries.