3.1-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_PROBLEM_HH
25#define DUMUX_MULTIDOMAIN_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
34namespace Dumux {
35
41template<class MDTraits>
43{
44 using SolutionVector = typename MDTraits::SolutionVector;
45 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
46
47 template<std::size_t i>
48 using GridGeometry = typename MDTraits::template SubDomain<i>::GridGeometry;
49 using GridGeometries = typename MDTraits::template Tuple<GridGeometry>;
50
51public:
53 template<std::size_t i>
54 using Type = typename MDTraits::template SubDomain<i>::Problem;
55
57 template<std::size_t i>
58 using PtrType = std::shared_ptr<Type<i>>;
59
61 using TupleType = typename MDTraits::template Tuple<PtrType>;
62
67
72 MultiDomainFVProblem(GridGeometries&& gridGeometries)
73 {
74 using namespace Dune::Hybrid;
75 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
76 {
77 constexpr auto i = std::decay_t<decltype(id)>::value;
78 elementAt(problems_, id) = std::make_shared<Type<i>>(std::get<i>(gridGeometries));
79 });
80 }
81
86 void applyInitialSolution(SolutionVector& sol) const
87 {
88 using namespace Dune::Hybrid;
89 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
90 {
91 elementAt(problems_, id)->applyInitialSolution(sol[id]);
92 });
93 }
94
96 template<std::size_t i>
97 const Type<i>& operator[] (Dune::index_constant<i> id) const
98 { return *Dune::Hybrid::elementAt(problems_, id); }
99
101 template<std::size_t i>
102 Type<i>& operator[] (Dune::index_constant<i> id)
103 { return *Dune::Hybrid::elementAt(problems_, id); }
104
106 template<std::size_t i>
107 PtrType<i> get(Dune::index_constant<i> id = Dune::index_constant<i>{})
108 { return Dune::Hybrid::elementAt(problems_, id); }
109
111 template<std::size_t i>
112 void set(PtrType<i> p, Dune::index_constant<i> id = Dune::index_constant<i>{})
113 { Dune::Hybrid::elementAt(problems_, Dune::index_constant<i>{}) = p; }
114
120 { return problems_; }
121
122private:
123
125 TupleType problems_;
126};
127
128} // end namespace Dumux
129
130#endif
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
A multidomain wrapper for multiple problems.
Definition: multidomain/fvproblem.hh:43
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvproblem.hh:58
typename MDTraits::template SubDomain< i >::Problem Type
export base types of the stored type
Definition: multidomain/fvproblem.hh:54
MultiDomainFVProblem(GridGeometries &&gridGeometries)
Contruct the problem.
Definition: multidomain/fvproblem.hh:72
const Type< i > & operator[](Dune::index_constant< i > id) const
return the problem for domain with index i
Definition: multidomain/fvproblem.hh:97
PtrType< i > get(Dune::index_constant< i > id=Dune::index_constant< i >{})
return the problem for domain with index i
Definition: multidomain/fvproblem.hh:107
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvproblem.hh:61
MultiDomainFVProblem()=default
The default constructor.
TupleType getTuple()
return the grid variables tuple we are wrapping
Definition: multidomain/fvproblem.hh:119
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: multidomain/fvproblem.hh:86
void set(PtrType< i > p, Dune::index_constant< i > id=Dune::index_constant< i >{})
set the pointer for sub domain i
Definition: multidomain/fvproblem.hh:112