All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
33 #include "ecfvproperties.hh"
34 #include "ecfvstencil.hh"
36 #include "ecfvbaseoutputmodule.hh"
37 
40 
41 #if HAVE_DUNE_FEM
42 #include <dune/fem/space/common/functionspace.hh>
43 #include <dune/fem/space/finitevolume.hh>
44 #endif
45 
46 namespace Ewoms {
47 template <class TypeTag>
48 class EcfvDiscretization;
49 }
50 
51 namespace Ewoms {
52 namespace Properties {
54 SET_PROP(EcfvDiscretization, Stencil)
55 {
56 private:
57  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
58  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
59 
60 public:
61  typedef Ewoms::EcfvStencil<Scalar, GridView> type;
62 };
63 
65 SET_TYPE_PROP(EcfvDiscretization, DofMapper, typename GET_PROP_TYPE(TypeTag, ElementMapper));
66 
68 SET_TYPE_PROP(EcfvDiscretization, Discretization, Ewoms::EcfvDiscretization<TypeTag>);
69 
72 SET_TYPE_PROP(EcfvDiscretization, DiscBaseOutputModule,
73  Ewoms::EcfvBaseOutputModule<TypeTag>);
74 
76 SET_TYPE_PROP(EcfvDiscretization, GridCommHandleFactory,
77  Ewoms::EcfvGridCommHandleFactory<TypeTag>);
78 
79 #if HAVE_DUNE_FEM
80 SET_PROP(EcfvDiscretization, DiscreteFunctionSpace)
82 {
83 private:
84  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
85  typedef typename GET_PROP_TYPE(TypeTag, GridPart) GridPart;
86  enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
87  typedef Dune::Fem::FunctionSpace<typename GridPart::GridType::ctype,
88  Scalar,
89  GridPart::GridType::dimensionworld,
90  numEq> FunctionSpace;
91 public:
92  typedef Dune::Fem::FiniteVolumeSpace< FunctionSpace, GridPart, 0 > type;
93 };
94 #endif
95 
98 SET_PROP(EcfvDiscretization, BorderListCreator)
99 { private:
100  typedef typename GET_PROP_TYPE(TypeTag, ElementMapper) ElementMapper;
101  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
102 public:
103  typedef Ewoms::Linear::ElementBorderListFromGrid<GridView, ElementMapper> type;
104 };
105 
109 SET_BOOL_PROP(EcfvDiscretization, LinearizeNonLocalElements, true);
110 
113 SET_BOOL_PROP(EcfvDiscretization, UseLinearizationLock, false);
114 
115 } // namespace Properties
116 } // namespace Ewoms
117 
118 namespace Ewoms {
124 template<class TypeTag>
125 class EcfvDiscretization : public FvBaseDiscretization<TypeTag>
126 {
127  typedef FvBaseDiscretization<TypeTag> ParentType;
128 
129  typedef typename GET_PROP_TYPE(TypeTag, Model) Implementation;
130  typedef typename GET_PROP_TYPE(TypeTag, DofMapper) DofMapper;
131  typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
132  typedef typename GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector;
133  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
134  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
135 
136 public:
137  EcfvDiscretization(Simulator& simulator)
138  : ParentType(simulator)
139  { }
140 
144  static std::string discretizationName()
145  { return "ecfv"; }
146 
150  size_t numGridDof() const
151  { return static_cast<size_t>(this->gridView_.size(/*codim=*/0)); }
152 
157  const DofMapper& dofMapper() const
158  { return this->elementMapper(); }
159 
169  void syncOverlap()
170  {
171  // syncronize the solution on the ghost and overlap elements
172  typedef GridCommHandleGhostSync<PrimaryVariables,
173  SolutionVector,
174  DofMapper,
175  /*commCodim=*/0> GhostSyncHandle;
176 
177  auto ghostSync = GhostSyncHandle(this->solution(/*timeIdx=*/0),
178  asImp_().dofMapper());
179  this->gridView().communicate(ghostSync,
180  Dune::InteriorBorder_All_Interface,
181  Dune::ForwardCommunication);
182  }
183 
191  template <class Restarter>
192  void serialize(Restarter& res)
193  { res.template serializeEntities</*codim=*/0>(asImp_(), this->gridView_); }
194 
202  template <class Restarter>
203  void deserialize(Restarter& res)
204  {
205  res.template deserializeEntities</*codim=*/0>(asImp_(), this->gridView_);
206  this->solution(/*timeIdx=*/1) = this->solution(/*timeIdx=*/0);
207  }
208 
209 private:
210  Implementation& asImp_()
211  { return *static_cast<Implementation*>(this); }
212  const Implementation& asImp_() const
213  { return *static_cast<const Implementation*>(this); }
214 };
215 } // namespace Ewoms
216 
217 #endif
void serialize(Restarter &res)
Serializes the current state of the model.
Definition: ecfvdiscretization.hh:192
void deserialize(Restarter &res)
Deserializes the state of the model.
Definition: ecfvdiscretization.hh:203
#define SET_BOOL_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant boolean value.
Definition: propertysystem.hh:361
Represents the stencil (finite volume geometry) of a single element in the ECFV discretization.
void syncOverlap()
Syncronize the values of the primary variables on the degrees of freedom that overlap with the neighb...
Definition: ecfvdiscretization.hh:169
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
size_t numGridDof() const
Returns the number of global degrees of freedom (DOFs) due to the grid.
Definition: ecfvdiscretization.hh:150
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
static std::string discretizationName()
Returns a string of discretization&#39;s human-readable name.
Definition: ecfvdiscretization.hh:144
The base class for the finite volume discretization schemes.
A class which provides types for DUNE grid handles for communication.
#define SET_PROP(EffTypeTagName, PropTagName)
Set a property for a specific type tag.
Definition: propertysystem.hh:297
const DofMapper & dofMapper() const
Mapper to convert the Dune entities of the discretization&#39;s degrees of freedoms are to indices...
Definition: ecfvdiscretization.hh:157
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.
Data handle for parallel communication which can be used to set the values values of ghost and overla...
Definition: gridcommhandles.hh:103
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
Declare the basic properties used by the common infrastructure of the element-centered finite volume ...