basevanguard.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 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 2 of the License, or
9 (at your option) any later version.
10
11 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef EWOMS_BASE_VANGUARD_HH
28#define EWOMS_BASE_VANGUARD_HH
29
32
33#include <dune/common/version.hh>
34
35#if HAVE_DUNE_FEM
36#include <dune/fem/space/common/dofmanager.hh>
37#endif
38
39#include <type_traits>
40#include <memory>
41
42namespace Opm {
43
47template <class TypeTag>
49{
53 using Implementation = GetPropType<TypeTag, Properties::Vanguard>;
54
55#if HAVE_DUNE_FEM
57#endif
58
59public:
60 BaseVanguard(Simulator& simulator)
61 : simulator_(simulator)
62 {}
63
64 BaseVanguard(const BaseVanguard&) = delete;
65
69 const GridView& gridView() const
70 { return *gridView_; }
71
72#if HAVE_DUNE_FEM
76 const GridPart& gridPart() const
77 { return *gridPart_; }
78
82 GridPart& gridPart()
83 { return *gridPart_; }
84#endif
85
92 int gridSequenceNumber () const
93 {
94#if HAVE_DUNE_FEM
95 using FemDofManager = Dune::Fem::DofManager< Grid >;
96 return FemDofManager::instance( asImp_().grid() ).sequence();
97#else
98 return 0; // return the same sequence number >= 0 means the grid never changes
99#endif
100 }
101
102
108 {
109 asImp_().grid().loadBalance();
111 }
112
113protected:
114 // this method should be called after the grid has been allocated
116 {
118 }
119
121 {
122#if HAVE_DUNE_FEM
123 if constexpr (std::is_same_v<GridView,
124 typename GetPropType<TypeTag,
125 Properties::GridPart>::GridViewType>) {
126 gridPart_ = std::make_unique<GridPart>(asImp_().grid());
127 gridView_ = std::make_unique<GridView>(static_cast<GridView>(*gridPart_));
128 assert(gridView_->size(0) == asImp_().grid().leafGridView().size(0));
129 } else
130#endif
131 {
132 gridView_ = std::make_unique<GridView>(asImp_().grid().leafGridView());
133 }
134 }
135
136private:
137 Implementation& asImp_()
138 { return *static_cast<Implementation*>(this); }
139
140 const Implementation& asImp_() const
141 { return *static_cast<const Implementation*>(this); }
142
143 Simulator& simulator_;
144#if HAVE_DUNE_FEM
145 std::unique_ptr<GridPart> gridPart_;
146#endif
147 std::unique_ptr<GridView> gridView_;
148};
149
150} // namespace Opm
151
152#endif
Defines a type tags and some fundamental properties all models.
Provides the base class for most (all?) simulator vanguards.
Definition: basevanguard.hh:49
void updateGridView_()
Definition: basevanguard.hh:120
int gridSequenceNumber() const
Returns the number of times the grid has been changed since its creation.
Definition: basevanguard.hh:92
const GridView & gridView() const
Returns a reference to the grid view to be used.
Definition: basevanguard.hh:69
void finalizeInit_()
Definition: basevanguard.hh:115
BaseVanguard(Simulator &simulator)
Definition: basevanguard.hh:60
BaseVanguard(const BaseVanguard &)=delete
void loadBalance()
Distribute the grid (and attached data) over all processes.
Definition: basevanguard.hh:107
Definition: blackoilboundaryratevector.hh:37
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:235
This file provides the infrastructure to retrieve run-time parameters.