baseauxiliarymodule.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  Copyright (C) 2014 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
25 #ifndef EWOMS_BASE_AUXILIARY_MODULE_HH
26 #define EWOMS_BASE_AUXILIARY_MODULE_HH
27 
29 
31 
32 #include <set>
33 #include <vector>
34 
35 namespace Ewoms {
36 namespace Properties {
37 NEW_TYPE_TAG(AuxModule);
38 
39 // declare the properties required by the for the ecl grid manager
40 NEW_PROP_TAG(Grid);
41 NEW_PROP_TAG(GridView);
42 NEW_PROP_TAG(Scalar);
43 NEW_PROP_TAG(DofMapper);
44 NEW_PROP_TAG(GlobalEqVector);
45 NEW_PROP_TAG(JacobianMatrix);
46 } // namespace Properties
47 
56 template <class TypeTag>
58 {
59  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
60  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
61  typedef typename GET_PROP_TYPE(TypeTag, GlobalEqVector) GlobalEqVector;
62  typedef typename GET_PROP_TYPE(TypeTag, JacobianMatrix) JacobianMatrix;
63 
64 protected:
65  typedef std::set<int> NeighborSet;
66 
67 public:
72  virtual int numDofs() const = 0;
73 
78  void setDofOffset(int value)
79  { dofOffset_ = value; }
80 
85  int dofOffset()
86  { return dofOffset_; }
87 
92  int localToGlobalDof(int localDofIdx) const
93  {
94  assert(0 <= localDofIdx);
95  assert(localDofIdx < numDofs());
96  return dofOffset_ + localDofIdx;
97  }
98 
103  virtual void addNeighbors(std::vector<NeighborSet>& neighbors) const = 0;
104 
108  virtual void applyInitial() = 0;
109 
113  virtual void linearize(JacobianMatrix& matrix, GlobalEqVector& residual) = 0;
114 
115 private:
116  int dofOffset_;
117 };
118 
119 } // namespace Ewoms
120 
121 #endif
void setDofOffset(int value)
Set the offset in the global system of equations for the first degree of freedom of this auxiliary mo...
Definition: baseauxiliarymodule.hh:78
Declare the properties used by the infrastructure code of the finite volume discretizations.
virtual int numDofs() const =0
Returns the number of additional degrees of freedom required for the auxiliary module.
virtual void applyInitial()=0
Set the initial condition of the auxiliary module in the solution vector.
NEW_PROP_TAG(Grid)
The type of the DUNE grid.
int dofOffset()
Return the offset in the global system of equations for the first degree of freedom of this auxiliary...
Definition: baseauxiliarymodule.hh:85
Definition: baseauxiliarymodule.hh:35
virtual void linearize(JacobianMatrix &matrix, GlobalEqVector &residual)=0
Linearize the auxiliary equation.
int localToGlobalDof(int localDofIdx) const
Given a degree of freedom relative to the current auxiliary equation, return the corresponding index ...
Definition: baseauxiliarymodule.hh:92
Base class for specifying auxiliary equations.
Definition: baseauxiliarymodule.hh:57
virtual void addNeighbors(std::vector< NeighborSet > &neighbors) const =0
Specify the additional neighboring correlations caused by the auxiliary module.
std::set< int > NeighborSet
Definition: baseauxiliarymodule.hh:65
NEW_TYPE_TAG(AuxModule)
Provides the magic behind the eWoms property system.