version 3.10-dev
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_MULTIDOMAIN_FV_PROBLEM_HH
13#define DUMUX_MULTIDOMAIN_FV_PROBLEM_HH
14
15#include <tuple>
16#include <memory>
17#include <utility>
18
19#include <dune/common/hybridutilities.hh>
20#include <dune/common/indices.hh>
21
23
24namespace Dumux {
25
31template<class MDTraits>
33{
34 using SolutionVector = typename MDTraits::SolutionVector;
35 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
36
37 template<std::size_t i>
38 using GridGeometry = typename MDTraits::template SubDomain<i>::GridGeometry;
39 using GridGeometries = typename MDTraits::template Tuple<GridGeometry>;
40
41public:
43 template<std::size_t i>
44 using Type = typename MDTraits::template SubDomain<i>::Problem;
45
47 template<std::size_t i>
48 using PtrType = std::shared_ptr<Type<i>>;
49
51 using TupleType = typename MDTraits::template Tuple<PtrType>;
52
58 {
59 using namespace Dune::Hybrid;
60 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
61 {
62 constexpr auto i = std::decay_t<decltype(id)>::value;
63 std::get<i>(problems_) = std::make_shared<Type<i>>(gridGeometries.template get<i>());
64 });
65 }
66
72 : problems_(std::move(problemTuple))
73 {}
74
79 void applyInitialSolution(SolutionVector& sol) const
80 {
81 using namespace Dune::Hybrid;
82 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
83 {
84 elementAt(problems_, id)->applyInitialSolution(sol[id]);
85 });
86 }
87
89 template<std::size_t i>
90 const Type<i>& operator[] (Dune::index_constant<i> id) const
91 { return *std::get<i>(problems_); }
92
94 template<std::size_t i>
95 Type<i>& operator[] (Dune::index_constant<i> id)
96 { return *std::get<i>(problems_); }
97
99 template<std::size_t i>
100 const PtrType<i>& get(Dune::index_constant<i> id = Dune::index_constant<i>{}) const
101 { return std::get<i>(problems_); }
102
104 template<std::size_t i>
105 PtrType<i>& get(Dune::index_constant<i> id = Dune::index_constant<i>{})
106 { return std::get<i>(problems_); }
107
112 { return problems_; }
113
117 const TupleType& asTuple() const
118 { return problems_; }
119
120private:
121
123 TupleType problems_;
124};
125
126} // end namespace Dumux
127
128#endif
A multidomain wrapper for multiple grid geometries.
Definition: multidomain/fvgridgeometry.hh:46
A multidomain wrapper for multiple problems.
Definition: multidomain/fvproblem.hh:33
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvproblem.hh:48
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:105
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:100
MultiDomainFVProblem(TupleType problemTuple)
Construct wrapper from a tuple of problems.
Definition: multidomain/fvproblem.hh:71
typename MDTraits::template SubDomain< i >::Problem Type
export base types of the stored type
Definition: multidomain/fvproblem.hh:44
MultiDomainFVProblem(MultiDomainFVGridGeometry< MDTraits > gridGeometries)
Construct the problem.
Definition: multidomain/fvproblem.hh:57
const Type< i > & operator[](Dune::index_constant< i > id) const
return the problem for domain with index i
Definition: multidomain/fvproblem.hh:90
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvproblem.hh:51
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: multidomain/fvproblem.hh:79
const TupleType & asTuple() const
Access the underlying tuple representation.
Definition: multidomain/fvproblem.hh:117
TupleType & asTuple()
Access the underlying tuple representation.
Definition: multidomain/fvproblem.hh:111
Multidomain wrapper for multiple grid geometries.
Definition: adapt.hh:17