All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fvbasenewtonmethod.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_FV_BASE_NEWTON_METHOD_HH
29 #define EWOMS_FV_BASE_NEWTON_METHOD_HH
30 
32 
35 
36 namespace Ewoms {
37 
38 template <class TypeTag>
40 
41 template <class TypeTag>
43 } // namespace Ewoms
44 
45 namespace Ewoms {
46 namespace Properties {
49 
51 NEW_PROP_TAG(Model);
52 
54 NEW_PROP_TAG(PrimaryVariables);
55 
58 NEW_PROP_TAG(EqVector);
59 
61 NEW_PROP_TAG(NumEq);
62 
64 NEW_PROP_TAG(DiscNewtonMethod);
65 
68 
69 // set default values
70 SET_TYPE_PROP(FvBaseNewtonMethod, DiscNewtonMethod,
73  typename GET_PROP_TYPE(TypeTag, DiscNewtonMethod));
74 SET_TYPE_PROP(FvBaseNewtonMethod, NewtonConvergenceWriter,
76 } // namespace Properties
77 
86 template <class TypeTag>
87 class FvBaseNewtonMethod : public NewtonMethod<TypeTag>
88 {
89  typedef Ewoms::NewtonMethod<TypeTag> ParentType;
90  typedef typename GET_PROP_TYPE(TypeTag, NewtonMethod) Implementation;
91 
92  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
93  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
94  typedef typename GET_PROP_TYPE(TypeTag, Model) Model;
95  typedef typename GET_PROP_TYPE(TypeTag, Linearizer) Linearizer;
96  typedef typename GET_PROP_TYPE(TypeTag, NewtonMethod) NewtonMethod;
97  typedef typename GET_PROP_TYPE(TypeTag, GlobalEqVector) GlobalEqVector;
98  typedef typename GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector;
99  typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
100  typedef typename GET_PROP_TYPE(TypeTag, EqVector) EqVector;
101 
102 
103 public:
104  FvBaseNewtonMethod(Simulator& simulator)
105  : ParentType(simulator)
106  { }
107 
108 protected:
109  friend class Ewoms::NewtonMethod<TypeTag>;
110 
128  void update_(SolutionVector& nextSolution,
129  const SolutionVector& currentSolution,
130  const GlobalEqVector& solutionUpdate,
131  const GlobalEqVector& currentResidual)
132  {
133  ParentType::update_(nextSolution, currentSolution, solutionUpdate, currentResidual);
134 
135  // make sure that the intensive quantities get recalculated at the next
136  // linearization
137  if (model_().storeIntensiveQuantities()) {
138  for (unsigned dofIdx = 0; dofIdx < model_().numGridDof(); ++dofIdx)
139  model_().setIntensiveQuantitiesCacheEntryValidity(dofIdx,
140  /*timeIdx=*/0,
141  /*valid=*/false);
142  }
143  }
144 
149  {
150  model_().syncOverlap();
151 
153  }
154 
158  Model& model_()
159  { return ParentType::model(); }
160 
164  const Model& model_() const
165  { return ParentType::model(); }
166 
167 private:
168  Implementation& asImp_()
169  { return *static_cast<Implementation*>(this); }
170 
171  const Implementation& asImp_() const
172  { return *static_cast<const Implementation*>(this); }
173 };
174 } // namespace Ewoms
175 
176 #endif
void beginIteration_()
Indicates the beginning of a Newton iteration.
Definition: newtonmethod.hh:596
The multi-dimensional Newton method.
void beginIteration_()
Indicates the beginning of a Newton iteration.
Definition: fvbasenewtonmethod.hh:148
Writes the intermediate solutions during the Newton scheme for models using a finite volume discretiz...
Definition: fvbasenewtonconvergencewriter.hh:55
#define NEW_TYPE_TAG(...)
Define a new type tag.
Definition: propertysystem.hh:169
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
#define INHERITS_FROM(...)
Syntactic sugar for NEW_TYPE_TAG.
Definition: propertysystem.hh:230
The multi-dimensional Newton method.
Definition: newtonmethod.hh:56
Provides the magic behind the eWoms property system.
Writes the intermediate solutions during the Newton scheme for models using a finite volume discretiz...
void update_(SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate, const GlobalEqVector &currentResidual)
Update the current solution with a delta vector.
Definition: newtonmethod.hh:678
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
Model & model()
Returns a reference to the numeric model.
Definition: newtonmethod.hh:256
A Newton method for models using a finite volume discretization.
Definition: fvbasenewtonmethod.hh:39
const Model & model_() const
Returns a reference to the model.
Definition: fvbasenewtonmethod.hh:164
Model & model_()
Returns a reference to the model.
Definition: fvbasenewtonmethod.hh:158
void update_(SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate, const GlobalEqVector &currentResidual)
Update the current solution with a delta vector.
Definition: fvbasenewtonmethod.hh:128