3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
multidomain/fvgridgeometry.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_FVGRIDGEOMETRY_HH
25#define DUMUX_MULTIDOMAIN_FVGRIDGEOMETRY_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 static constexpr std::size_t numSubDomains = MDTraits::numSubDomains;
45
46public:
48 template<std::size_t i>
49 using Type = typename MDTraits::template SubDomain<i>::GridGeometry;
50
52 template<std::size_t i>
53 using PtrType = std::shared_ptr<Type<i>>;
54
56 using TupleType = typename MDTraits::template Tuple<PtrType>;
57
62
67 template<class GridViews>
68 MultiDomainFVGridGeometry(GridViews&& gridViews)
69 {
70 using namespace Dune::Hybrid;
71 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
72 {
73 constexpr auto i = std::decay_t<decltype(id)>::value;
74 elementAt(gridGeometries_, id) = std::make_shared<Type<i>>(std::get<i>(gridViews));
75 });
76 }
77
81 void update()
82 {
83 using namespace Dune::Hybrid;
84 forEach(std::make_index_sequence<numSubDomains>{}, [&](auto&& id)
85 {
86 elementAt(gridGeometries_, id)->update();
87 });
88 }
89
91 template<std::size_t i>
92 const Type<i>& operator[] (Dune::index_constant<i> id) const
93 { return *Dune::Hybrid::elementAt(gridGeometries_, id); }
94
96 template<std::size_t i>
97 Type<i>& operator[] (Dune::index_constant<i> id)
98 { return *Dune::Hybrid::elementAt(gridGeometries_, id); }
99
101 template<std::size_t i>
102 PtrType<i> get(Dune::index_constant<i> id = Dune::index_constant<i>{})
103 { return Dune::Hybrid::elementAt(gridGeometries_, id); }
104
106 template<std::size_t i>
107 void set(PtrType<i> p, Dune::index_constant<i> id = Dune::index_constant<i>{})
108 { Dune::Hybrid::elementAt(gridGeometries_, Dune::index_constant<i>{}) = p; }
109
115 { return gridGeometries_; }
116
117private:
118
120 TupleType gridGeometries_;
121};
122
123} // end namespace Dumux
124
125#endif
Definition: adapt.hh:29
A multidomain wrapper for multiple grid geometries.
Definition: multidomain/fvgridgeometry.hh:43
TupleType getTuple()
return the grid variables tuple we are wrapping
Definition: multidomain/fvgridgeometry.hh:114
void set(PtrType< i > p, Dune::index_constant< i > id=Dune::index_constant< i >{})
set the pointer for sub domain i
Definition: multidomain/fvgridgeometry.hh:107
typename MDTraits::template SubDomain< i >::GridGeometry Type
export base types of the stored type
Definition: multidomain/fvgridgeometry.hh:49
const Type< i > & operator[](Dune::index_constant< i > id) const
return the grid geometry for domain with index i
Definition: multidomain/fvgridgeometry.hh:92
typename MDTraits::template Tuple< PtrType > TupleType
export type of tuple of pointers
Definition: multidomain/fvgridgeometry.hh:56
PtrType< i > get(Dune::index_constant< i > id=Dune::index_constant< i >{})
! return the grid geometry pointer for domain with index i
Definition: multidomain/fvgridgeometry.hh:102
MultiDomainFVGridGeometry(GridViews &&gridViews)
Contruct the problem.
Definition: multidomain/fvgridgeometry.hh:68
MultiDomainFVGridGeometry()=default
The default constructor.
void update()
Update all grid geometries (do this again after grid adaption)
Definition: multidomain/fvgridgeometry.hh:81
std::shared_ptr< Type< i > > PtrType
export pointer types the stored type
Definition: multidomain/fvgridgeometry.hh:53