opm-simulators
ecfvdiscretization.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 */
28 #ifndef EWOMS_ECFV_DISCRETIZATION_HH
29 #define EWOMS_ECFV_DISCRETIZATION_HH
30 
31 #include <opm/material/densead/Math.hpp>
32 
38 
40 
41 #if HAVE_DUNE_FEM
43 #include <dune/fem/space/common/functionspace.hh>
44 #include <dune/fem/space/finitevolume.hh>
45 #endif
46 
47 #include <cstddef>
48 #include <string>
49 
50 namespace Opm {
51 
52 template <class TypeTag>
53 class EcfvDiscretization;
54 
55 }
56 
57 namespace Opm::Properties {
58 
60 template<class TypeTag>
61 struct Stencil<TypeTag, TTag::EcfvDiscretization>
62 {
63 private:
66 
67 public:
69 };
70 
72 template<class TypeTag>
73 struct DofMapper<TypeTag, TTag::EcfvDiscretization>
75 
77 template<class TypeTag>
78 struct Discretization<TypeTag, TTag::EcfvDiscretization>
80 
83 template<class TypeTag>
86 
88 template<class TypeTag>
91 
92 #if HAVE_DUNE_FEM
93 template<class TypeTag>
95 struct DiscreteFunctionSpace<TypeTag, TTag::EcfvDiscretization>
96 {
97 private:
100  enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
101  using FunctionSpace = Dune::Fem::FunctionSpace<typename GridPart::GridType::ctype,
102  Scalar,
103  GridPart::GridType::dimensionworld,
104  numEq>;
105 
106 public:
107  using type = Dune::Fem::FiniteVolumeSpace< FunctionSpace, GridPart, 0 >;
108 };
109 #else
110 template <class TypeTag>
112 {
113  using DiscreteFunctionSpace = GetPropType<TypeTag, Properties::DiscreteFunctionSpace>;
114  explicit DummySpaceEcfv(const DiscreteFunctionSpace&) {}
115  explicit DummySpaceEcfv(const int&) {}
116 };
117 
118 template <class TypeTag>
120 { using type = DummySpaceEcfv<TypeTag>; };
121 #endif
122 
125 template<class TypeTag>
126 struct BorderListCreator<TypeTag, TTag::EcfvDiscretization>
127 {
128 private:
131 
132 public:
134 };
135 
139 template<class TypeTag>
141 { static constexpr bool value = true; };
142 
145 template<class TypeTag>
147 { static constexpr bool value = false; };
148 
149 } // namespace Opm::Properties
150 
151 namespace Opm {
152 
158 template<class TypeTag>
159 class EcfvDiscretization : public GetPropType<TypeTag, Properties::BaseDiscretizationType>
160 {
162  using Implementation = GetPropType<TypeTag, Properties::Model>;
168 
169 public:
170  explicit EcfvDiscretization(Simulator& simulator)
171  : ParentType(simulator)
172  {}
173 
177  static std::string discretizationName()
178  { return "ecfv"; }
179 
183  std::size_t numGridDof() const
184  { return static_cast<std::size_t>(this->gridView_.size(/*codim=*/0)); }
185 
190  const DofMapper& dofMapper() const
191  { return this->elementMapper(); }
192 
202  void syncOverlap()
203  {
204  // syncronize the solution on the ghost and overlap elements
205  using GhostSyncHandle = GridCommHandleGhostSync<PrimaryVariables,
206  SolutionVector,
207  DofMapper,
208  /*commCodim=*/0>;
209 
210  auto ghostSync = GhostSyncHandle(this->solution(/*timeIdx=*/0),
211  asImp_().dofMapper());
212  this->gridView().communicate(ghostSync,
213  Dune::InteriorBorder_All_Interface,
214  Dune::ForwardCommunication);
215  }
216 
224  template <class Restarter>
225  void serialize(Restarter& res)
226  { res.template serializeEntities</*codim=*/0>(asImp_(), this->gridView_); }
227 
235  template <class Restarter>
236  void deserialize(Restarter& res)
237  {
238  res.template deserializeEntities</*codim=*/0>(asImp_(), this->gridView_);
239  this->solution(/*timeIdx=*/1) = this->solution(/*timeIdx=*/0);
240  }
241 
242 private:
243  Implementation& asImp_()
244  { return *static_cast<Implementation*>(this); }
245 
246  const Implementation& asImp_() const
247  { return *static_cast<const Implementation*>(this); }
248 };
249 
250 } // namespace Opm
251 
252 #endif
Data handle for parallel communication which can be used to set the values values of ghost and overla...
Definition: gridcommhandles.hh:105
The class describing the stencil of the spatial discretization.
Definition: fvbaseproperties.hh:70
Implements the discretization specific parts of writing files.
Definition: ecfvbaseoutputmodule.hh:40
Definition: ecfvdiscretization.hh:111
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:233
The type of the spatial discretization used by the model.
Definition: fvbaseproperties.hh:88
Specify if elements that do not belong to the local process&#39; grid partition should be skipped...
Definition: fvbaseproperties.hh:101
The base class for the element-centered finite-volume discretization scheme.
Definition: fvbasegradientcalculator.hh:42
Represents the stencil (finite volume geometry) of a single element in the ECFV discretization.
Definition: ecfvstencil.hh:68
Represents the stencil (finite volume geometry) of a single element in the ECFV discretization.
static std::string discretizationName()
Returns a string of discretization&#39;s human-readable name.
Definition: ecfvdiscretization.hh:177
use locking to prevent race conditions when linearizing the global system of equations in multi-threa...
Definition: fvbaseproperties.hh:185
void deserialize(Restarter &res)
Deserializes the state of the model.
Definition: ecfvdiscretization.hh:236
The base class for the finite volume discretization schemes.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
The part of the VTK ouput modules which is specific to the spatial discretization.
Definition: fvbaseproperties.hh:168
The class which marks the border indices associated with the degrees of freedom on a process boundary...
Definition: basicproperties.hh:129
Uses communication on the grid to find the initial seed list of indices for methods which use element...
Definition: elementborderlistfromgrid.hh:48
The base class for the finite volume discretization schemes.
void syncOverlap()
Syncronize the values of the primary variables on the degrees of freedom that overlap with the neighb...
Definition: ecfvdiscretization.hh:202
The class describing the discrete function space when dune-fem is used, otherwise it points to the st...
Definition: fvbaseproperties.hh:74
A class which provides types for DUNE grid handles for communication.
Property to specify the type of scalar values.
Definition: basicproperties.hh:76
The class to create grid communication handles.
Definition: fvbaseproperties.hh:172
The mapper to find the global index of a degree of freedom.
Definition: fvbaseproperties.hh:223
Uses communication on the grid to find the initial seed list of indices for methods which use element...
Implements the discretization specific parts of writing files.
A class which provides types for DUNE grid handles for communication.
Definition: ecfvgridcommhandlefactory.hh:47
void serialize(Restarter &res)
Serializes the current state of the model.
Definition: ecfvdiscretization.hh:225
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:83
Definition: blackoilmodel.hh:80
const DofMapper & dofMapper() const
Mapper to convert the Dune entities of the discretization&#39;s degrees of freedoms are to indices...
Definition: ecfvdiscretization.hh:190
Declare the basic properties used by the common infrastructure of the element-centered finite volume ...
std::size_t numGridDof() const
Returns the number of global degrees of freedom (DOFs) due to the grid.
Definition: ecfvdiscretization.hh:183