All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fvbaseprimaryvariables.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_PRIMARY_VARIABLES_HH
29 #define EWOMS_FV_BASE_PRIMARY_VARIABLES_HH
30 
31 #include "fvbaseproperties.hh"
32 
33 #include <opm/common/Valgrind.hpp>
34 #include <opm/common/Unused.hpp>
35 #include <opm/common/ErrorMacros.hpp>
36 #include <opm/common/Exceptions.hpp>
37 
38 #include <dune/common/fvector.hh>
39 
40 namespace Ewoms {
41 
47 template <class TypeTag>
49  : public Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar),
50  GET_PROP_VALUE(TypeTag, NumEq)>
51 {
52  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
53  typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
54 
55  enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
56 
57  typedef Opm::MathToolbox<Evaluation> Toolbox;
58  typedef Dune::FieldVector<Scalar, numEq> ParentType;
59 
60 public:
62  : ParentType()
63  { Opm::Valgrind::SetUndefined(*this); }
64 
68  FvBasePrimaryVariables(Scalar value)
69  : ParentType(value)
70  { }
71 
75  FvBasePrimaryVariables(const FvBasePrimaryVariables& value) = default;
76 
81 
89  Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx) const
90  {
91  if (timeIdx == 0)
92  return Toolbox::createVariable((*this)[varIdx], varIdx);
93  else
94  return Toolbox::createConstant((*this)[varIdx]);
95  }
96 
107  template <class FluidState>
108  void assignNaive(const FluidState& fluidState OPM_UNUSED)
109  {
110  OPM_THROW(std::runtime_error,
111  "The PrimaryVariables class does not define a assignNaive() method");
112  }
117  void checkDefined() const
118  {
119  Opm::Valgrind::CheckDefined(*static_cast<const ParentType*>(this));
120  }
121 };
122 
123 } // namespace Ewoms
124 
125 #endif
void checkDefined() const
Instruct valgrind to check the definedness of all attributes of this class.
Definition: fvbaseprimaryvariables.hh:117
FvBasePrimaryVariables(Scalar value)
Construction from a scalar value.
Definition: fvbaseprimaryvariables.hh:68
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
Declare the properties used by the infrastructure code of the finite volume discretizations.
Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx) const
Return a primary variable intensive evaluation.
Definition: fvbaseprimaryvariables.hh:89
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:48
FvBasePrimaryVariables & operator=(const FvBasePrimaryVariables &value)=default
Assignment from another primary variables object.
void assignNaive(const FluidState &fluidState OPM_UNUSED)
Assign the primary variables &quot;somehow&quot; from a fluid state.
Definition: fvbaseprimaryvariables.hh:108