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 <type_traits>
32
33#include "fvbaseproperties.hh"
34#include "linearizationtype.hh"
35#include <opm/material/common/Valgrind.hpp>
36
37#include <dune/common/fvector.hh>
38
39#include <stdexcept>
40
41namespace Opm {
42
48template <class TypeTag>
50 : public Dune::FieldVector<GetPropType<TypeTag, Properties::Scalar>,
51 getPropValue<TypeTag, Properties::NumEq>()>
52{
55
56 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
57
58 using Toolbox = MathToolbox<Evaluation>;
59 using ParentType = Dune::FieldVector<Scalar, numEq>;
60
61public:
63 : ParentType()
64 { Valgrind::SetUndefined(*this); }
65
70 : ParentType(value)
71 { }
72
77
82
83 static void init()
84 {
85 // Nothing required by default.
86 }
87
88 static void registerParameters()
89 {
90 // No parameters to register by default.
91 }
92
100 Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx, LinearizationType linearizationType = LinearizationType()) const
101 {
102 if (std::is_same<Evaluation, Scalar>::value)
103 return (*this)[varIdx]; // finite differences
104 else {
105 // automatic differentiation
106 if (timeIdx == linearizationType.time)
107 return Toolbox::createVariable((*this)[varIdx], varIdx);
108 else
109 return Toolbox::createConstant((*this)[varIdx]);
110 }
111 }
112
123 template <class FluidState>
124 void assignNaive(const FluidState&)
125 {
126 throw std::runtime_error("The PrimaryVariables class does not define "
127 "an assignNaive() method");
128 }
129
133 void checkDefined() const
134 {
135 Valgrind::CheckDefined(*static_cast<const ParentType*>(this));
136 }
137};
138
139} // namespace Opm
140
141namespace Dune {
142
145 template<class TypeTag, bool>
147
150 template<class TypeTag>
151 struct FieldTraitsImpl< TypeTag, true >
152 : public FieldTraits<FieldVector<Opm::GetPropType<TypeTag, Opm::Properties::Scalar>,
153 Opm::getPropValue<TypeTag, Opm::Properties::NumEq>()> >
154 {
155 };
156
159 template<class T>
160 struct FieldTraitsImpl< T, false >
161 : public FieldTraits< T >
162 {
163 };
164
165
167 template<class TypeTag, template <class> class EwomsPrimaryVariable>
168 struct FieldTraits< EwomsPrimaryVariable< TypeTag > >
169 : public FieldTraitsImpl< TypeTag,
170 std::is_base_of< Opm::FvBasePrimaryVariables< TypeTag >,
171 EwomsPrimaryVariable< TypeTag > > :: value >
172 {
173 };
174}
175
176#endif
Represents the primary variables used by the a model.
Definition: fvbaseprimaryvariables.hh:52
FvBasePrimaryVariables()
Definition: fvbaseprimaryvariables.hh:62
static void registerParameters()
Definition: fvbaseprimaryvariables.hh:88
static void init()
Definition: fvbaseprimaryvariables.hh:83
FvBasePrimaryVariables(const FvBasePrimaryVariables &value)=default
Assignment from another primary variables object.
FvBasePrimaryVariables & operator=(const FvBasePrimaryVariables &value)=default
Assignment from another primary variables object.
FvBasePrimaryVariables(Scalar value)
Construction from a scalar value.
Definition: fvbaseprimaryvariables.hh:69
void checkDefined() const
Instruct valgrind to check the definedness of all attributes of this class.
Definition: fvbaseprimaryvariables.hh:133
void assignNaive(const FluidState &)
Assign the primary variables "somehow" from a fluid state.
Definition: fvbaseprimaryvariables.hh:124
Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx, LinearizationType linearizationType=LinearizationType()) const
Return a primary variable intensive evaluation.
Definition: fvbaseprimaryvariables.hh:100
Declare the properties used by the infrastructure code of the finite volume discretizations.
Definition: fvbaseprimaryvariables.hh:141
Definition: blackoilboundaryratevector.hh:37
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:242
Definition: fvbaseprimaryvariables.hh:146
Definition: linearizationtype.hh:35