All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vcfvdiscretization.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_VCFV_DISCRETIZATION_HH
29 #define EWOMS_VCFV_DISCRETIZATION_HH
30 
31 #include <opm/material/densead/Math.hpp>
32 
33 #include "vcfvproperties.hh"
34 #include "vcfvstencil.hh"
37 #include "vcfvbaseoutputmodule.hh"
38 
41 
42 #if HAVE_DUNE_FEM
43 #include <dune/fem/space/common/functionspace.hh>
44 #include <dune/fem/space/lagrange.hh>
45 #endif
46 
47 namespace Ewoms {
48 template <class TypeTag>
50 
51 namespace Properties {
54 {
55 private:
56  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
57  typedef typename GridView::ctype CoordScalar;
58 
59 public:
60  typedef Ewoms::VcfvStencil<CoordScalar, GridView> type;
61 };
62 
64 SET_TYPE_PROP(VcfvDiscretization, DofMapper, typename GET_PROP_TYPE(TypeTag, VertexMapper));
65 
67 SET_TYPE_PROP(VcfvDiscretization, Discretization, Ewoms::VcfvDiscretization<TypeTag>);
68 
71 SET_TYPE_PROP(VcfvDiscretization, DiscBaseOutputModule,
72  Ewoms::VcfvBaseOutputModule<TypeTag>);
73 
75 SET_TYPE_PROP(VcfvDiscretization, GradientCalculator,
76  Ewoms::P1FeGradientCalculator<TypeTag>);
77 
79 SET_TYPE_PROP(VcfvDiscretization, GridCommHandleFactory,
80  Ewoms::VcfvGridCommHandleFactory<TypeTag>);
81 
83 SET_BOOL_PROP(VcfvDiscretization, UseP1FiniteElementGradients, false);
84 
85 #if HAVE_DUNE_FEM
86 SET_PROP(VcfvDiscretization, DiscreteFunctionSpace)
88 {
89 private:
90  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
91  typedef typename GET_PROP_TYPE(TypeTag, GridPart) GridPart;
92  enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
93  typedef Dune::Fem::FunctionSpace<typename GridPart::GridType::ctype,
94  Scalar,
95  GridPart::GridType::dimensionworld,
96  numEq> FunctionSpace;
97 public:
98  // Lagrange discrete function space with unknowns at the cell vertices
99  typedef Dune::Fem::LagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, 1 > type;
100 };
101 #endif
102 
104 SET_PROP(VcfvDiscretization, BorderListCreator)
105 { private:
106  typedef typename GET_PROP_TYPE(TypeTag, VertexMapper) VertexMapper;
107  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
108 public:
109  typedef Ewoms::Linear::VertexBorderListFromGrid<GridView, VertexMapper> type;
110 };
111 
115 SET_BOOL_PROP(VcfvDiscretization, LinearizeNonLocalElements, false);
116 
117 } // namespace Properties
118 
124 template<class TypeTag>
125 class VcfvDiscretization : public FvBaseDiscretization<TypeTag>
126 {
127  typedef FvBaseDiscretization<TypeTag> ParentType;
128  typedef typename GET_PROP_TYPE(TypeTag, Model) Implementation;
129  typedef typename GET_PROP_TYPE(TypeTag, DofMapper) DofMapper;
130  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
131  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
132 
133  enum { dim = GridView::dimension };
134 
135 public:
136  VcfvDiscretization(Simulator& simulator)
137  : ParentType(simulator)
138  { }
139 
143  static std::string discretizationName()
144  { return "vcfv"; }
145 
149  size_t numGridDof() const
150  { return static_cast<size_t>(this->gridView_.size(/*codim=*/dim)); }
151 
156  const DofMapper& dofMapper() const
157  { return this->vertexMapper(); }
158 
166  template <class Restarter>
167  void serialize(Restarter& res)
168  { res.template serializeEntities</*codim=*/dim>(asImp_(), this->gridView_); }
169 
177  template <class Restarter>
178  void deserialize(Restarter& res)
179  {
180  res.template deserializeEntities</*codim=*/dim>(asImp_(), this->gridView_);
181  this->solution(/*timeIdx=*/1) = this->solution(/*timeIdx=*/0);
182  }
183 
184 private:
185  Implementation& asImp_()
186  { return *static_cast<Implementation*>(this); }
187  const Implementation& asImp_() const
188  { return *static_cast<const Implementation*>(this); }
189 };
190 } // namespace Ewoms
191 
192 #endif
const DofMapper & dofMapper() const
Mapper to convert the Dune entities of the discretization&#39;s degrees of freedoms are to indices...
Definition: vcfvdiscretization.hh:156
#define SET_BOOL_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant boolean value.
Definition: propertysystem.hh:361
size_t numGridDof() const
Returns the number of global degrees of freedom (DOFs) due to the grid.
Definition: vcfvdiscretization.hh:149
void serialize(Restarter &res)
Serializes the current state of the model.
Definition: vcfvdiscretization.hh:167
The base class for the vertex centered finite volume discretization scheme.
Definition: vcfvdiscretization.hh:49
Represents the finite volume geometry of a single element in the VCFV discretization.
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
A class which provides types for DUNE grid handles for communication.
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
The base class for the finite volume discretization schemes.
Uses communication on the grid to find the initial seed list of indices.
void deserialize(Restarter &res)
Deserializes the state of the model.
Definition: vcfvdiscretization.hh:178
Implements the discretization specific parts of writing files.
#define SET_PROP(EffTypeTagName, PropTagName)
Set a property for a specific type tag.
Definition: propertysystem.hh:297
This class calculates gradients of arbitrary quantities at flux integration points using first order ...
Definition: p1fegradientcalculator.hh:65
Declares the basic properties used by the common infrastructure of the vertex-centered finite volume ...
A class which provides types for DUNE grid handles for communication.
Definition: vcfvgridcommhandlefactory.hh:45
This class calculates gradients of arbitrary quantities at flux integration points using first order ...
Implements the discretization specific parts of writing files.
Definition: vcfvbaseoutputmodule.hh:45
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
static std::string discretizationName()
Returns a string of discretization&#39;s human-readable name.
Definition: vcfvdiscretization.hh:143
Represents the finite volume geometry of a single element in the VCFV discretization.
Definition: vcfvstencil.hh:467