Loading [MathJax]/extensions/tex2jax.js
3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
68 [[deprecated("Will be removed after release 3.5. Use one of the constructors instead.")]]
70
76 {
77 using namespace Dune::Hybrid;
78 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
79 {
80 constexpr auto i = std::decay_t<decltype(id)>::value;
81 std::get<i>(problems_) = std::make_shared<Type<i>>(gridGeometries.template get<i>());
82 });
83 }
84
90 : problems_(std::move(problemTuple))
91 {}
92
97 void applyInitialSolution(SolutionVector& sol) const
98 {
99 using namespace Dune::Hybrid;
100 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
101 {
102 elementAt(problems_, id)->applyInitialSolution(sol[id]);
103 });
104 }
105
107 template<std::size_t i>
108 const Type<i>& operator[] (Dune::index_constant<i> id) const
109 { return *std::get<i>(problems_); }
110
112 template<std::size_t i>
113 Type<i>& operator[] (Dune::index_constant<i> id)
114 { return *std::get<i>(problems_); }
115
117 template<std::size_t i>
118 const PtrType<i>& get(Dune::index_constant<i> id = Dune::index_constant<i>{}) const
119 { return std::get<i>(problems_); }
120
122 template<std::size_t i>
123 PtrType<i>& get(Dune::index_constant<i> id = Dune::index_constant<i>{})
124 { return std::get<i>(problems_); }
125
127 template<std::size_t i>
128 [[deprecated("Will be removed after release 3.5. Use one of the constructors instead.")]]
129 void set(PtrType<i> p, Dune::index_constant<i> id = Dune::index_constant<i>{})
130 { Dune::Hybrid::elementAt(problems_, Dune::index_constant<i>{}) = p; }
131
136 [[deprecated("Use asTuple. Will be removed after release 3.5")]]
138 { return problems_; }
139
144 { return problems_; }
145
149 const TupleType& asTuple() const
150 { return problems_; }
151
152private:
153
155 TupleType problems_;
156};
157
158} // end namespace Dumux
159
160#endif
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:123
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:118
MultiDomainFVProblem(TupleType problemTuple)
Construct wrapper from a tuple of problems.
Definition: multidomain/fvproblem.hh:89
typename MDTraits::template SubDomain< i >::Problem Type
export base types of the stored type
Definition: multidomain/fvproblem.hh:56
MultiDomainFVProblem(MultiDomainFVGridGeometry< MDTraits > gridGeometries)
Contruct the problem.
Definition: multidomain/fvproblem.hh:75
const Type< i > & operator[](Dune::index_constant< i > id) const
return the problem for domain with index i
Definition: multidomain/fvproblem.hh:108
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvproblem.hh:63
MultiDomainFVProblem()=default
The default constructor.
TupleType getTuple()
return the grid variables tuple we are wrapping
Definition: multidomain/fvproblem.hh:137
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: multidomain/fvproblem.hh:97
const TupleType & asTuple() const
Access the underlying tuple representation.
Definition: multidomain/fvproblem.hh:149
TupleType & asTuple()
Access the underlying tuple representation.
Definition: multidomain/fvproblem.hh:143
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:129
Multidomain wrapper for multiple grid geometries.