My Project
Loading...
Searching...
No Matches
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 <dune/common/fvector.hh>
34
35#include <opm/material/common/MathToolbox.hpp>
36#include <opm/material/common/Valgrind.hpp>
37
38#include <stdexcept>
39#include <type_traits>
40
41namespace Opm {
42
48template <class TypeTag>
50 : public Dune::FieldVector<GetPropType<TypeTag, Properties::Scalar>,
51 getPropValue<TypeTag, Properties::NumEq>()>
52{
55
57
58 using Toolbox = MathToolbox<Evaluation>;
59 using ParentType = Dune::FieldVector<Scalar, numEq>;
60
61public:
63 : ParentType()
64 { Valgrind::SetUndefined(*this); }
65
70
75
76 using ParentType::operator=;
77
78 static void init()
79 {
80 // Nothing required by default.
81 }
82
83 static void registerParameters()
84 {
85 // No parameters to register by default.
86 }
87
95 Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx, LinearizationType linearizationType = LinearizationType()) const
96 {
97 if (std::is_same<Evaluation, Scalar>::value)
98 return (*this)[varIdx]; // finite differences
99 else {
100 // automatic differentiation
101 if (timeIdx == linearizationType.time)
102 return Toolbox::createVariable((*this)[varIdx], varIdx);
103 else
104 return Toolbox::createConstant((*this)[varIdx]);
105 }
106 }
107
118 template <class FluidState>
119 void assignNaive(const FluidState&)
120 {
121 throw std::runtime_error("The PrimaryVariables class does not define "
122 "an assignNaive() method");
123 }
124
128 void checkDefined() const
129 {
130 Valgrind::CheckDefined(*static_cast<const ParentType*>(this));
131 }
132};
133
134} // namespace Opm
135
136namespace Dune {
137
140 template<class TypeTag, bool>
141 struct FieldTraitsImpl;
142
145 template<class TypeTag>
146 struct FieldTraitsImpl< TypeTag, true >
147 : public FieldTraits<FieldVector<Opm::GetPropType<TypeTag, Opm::Properties::Scalar>,
148 Opm::getPropValue<TypeTag, Opm::Properties::NumEq>()> >
149 {
150 };
151
154 template<class T>
155 struct FieldTraitsImpl< T, false >
156 : public FieldTraits< T >
157 {
158 };
159
160
162 template<class TypeTag, template <class> class EwomsPrimaryVariable>
163 struct FieldTraits< EwomsPrimaryVariable< TypeTag > >
164 : public FieldTraitsImpl< TypeTag,
165 std::is_base_of< Opm::FvBasePrimaryVariables< TypeTag >,
166 EwomsPrimaryVariable< TypeTag > > :: value >
167 {
168 };
169}
170
171#endif
Represents the primary variables used by the a model.
Definition fvbaseprimaryvariables.hh:52
static void init()
< Import base class assignment operators.
Definition fvbaseprimaryvariables.hh:78
FvBasePrimaryVariables(const FvBasePrimaryVariables &value)=default
Assignment from another primary variables object.
FvBasePrimaryVariables & operator=(const FvBasePrimaryVariables &value)=default
Assignment from another primary variables object.
void checkDefined() const
Instruct valgrind to check the definedness of all attributes of this class.
Definition fvbaseprimaryvariables.hh:128
void assignNaive(const FluidState &)
Assign the primary variables "somehow" from a fluid state.
Definition fvbaseprimaryvariables.hh:119
Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx, LinearizationType linearizationType=LinearizationType()) const
Return a primary variable intensive evaluation.
Definition fvbaseprimaryvariables.hh:95
Declare the properties used by the infrastructure code of the finite volume discretizations.
The common code for the linearizers of non-linear systems of equations.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
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:235
Definition linearizationtype.hh:35