elasticityprimaryvariables.hpp
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 2025 NORCE AS
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
21 Consult the COPYING file in the top-level source directory of this
22 module for the precise wording of the license and the list of
23 copyright holders.
24*/
25#ifndef ELASTICITY_PRIMARY_VARIABLES_HPP
26#define ELASTICITY_PRIMARY_VARIABLES_HPP
27
28#include <dune/common/fvector.hh>
29
30#include <opm/material/common/MathToolbox.hpp>
31#include <opm/material/common/Valgrind.hpp>
32
36
37#include <type_traits>
38
39
40namespace Opm {
41
50template <class TypeTag>
52 : public Dune::FieldVector<GetPropType<TypeTag, Properties::Scalar>,
53 getPropValue<TypeTag, Properties::NumEqTPSA>()>
54{
58
59 using Toolbox = Opm::MathToolbox<Evaluation>;
60
61 enum { disp0Idx = Indices::disp0Idx };
62 enum { rot0Idx = Indices::rot0Idx };
63 enum { solidPres0Idx = Indices::solidPres0Idx };
64
65 enum { numEq = getPropValue<TypeTag, Properties::NumEqTPSA>() };
66
67 using ParentType = Dune::FieldVector<Scalar, numEq>;
68
69public:
74 {
75 Valgrind::SetUndefined(*this);
76 }
77
82
87
88 using ParentType::operator=;
89
102 Evaluation makeEvaluation(unsigned varIdx,
103 unsigned timeIdx,
104 Opm::LinearizationType linearizationType = LinearizationType()) const
105 {
106 // Finite difference
107 if constexpr (std::is_same_v<Evaluation, Scalar>) {
108 return (*this)[varIdx];
109 }
110 // Automatic differentiation
111 else {
112 if (timeIdx == linearizationType.time) {
113 return Toolbox::createVariable((*this)[varIdx], varIdx);
114 }
115 else {
116 return Toolbox::createConstant((*this)[varIdx]);
117 }
118 }
119 }
120
126 template <class MaterialState>
127 void assignNaive(const MaterialState& materialState)
128 {
129 // Reset primary variables vector
130 (*this) = 0.0;
131
132 // Assign displacement and rotation vectors
133 for (unsigned dirIdx = 0; dirIdx < 3; ++dirIdx) {
134 (*this)[disp0Idx + dirIdx] = Opm::getValue(materialState.displacement(dirIdx));
135 (*this)[rot0Idx + dirIdx] = Opm::getValue(materialState.rotation(dirIdx));
136 }
137
138 // Assign solid pressure
139 (*this)[solidPres0Idx] = Opm::getValue(materialState.solidPressure());
140 }
141
145 void checkDefined() const
146 {
147 Valgrind::CheckDefined(*static_cast<const ParentType*>(this));
148 }
149}; // class ElasticityPrimaryVariables
150
151} // namespace Opm
152
153#endif
Defines a type tags and some fundamental properties all models.
Primary variables in (linear) elasticity equations.
Definition: elasticityprimaryvariables.hpp:54
ElasticityPrimaryVariables(const ElasticityPrimaryVariables &value)=default
Default copy constructor.
Evaluation makeEvaluation(unsigned varIdx, unsigned timeIdx, Opm::LinearizationType linearizationType=LinearizationType()) const
< Import base class assignment operators.
Definition: elasticityprimaryvariables.hpp:102
void assignNaive(const MaterialState &materialState)
Assign primary variables from a material state container.
Definition: elasticityprimaryvariables.hpp:127
ElasticityPrimaryVariables()
Constructor.
Definition: elasticityprimaryvariables.hpp:73
void checkDefined() const
Instruct Valgrind to check the definedness of all attributes of this class.
Definition: elasticityprimaryvariables.hpp:145
ElasticityPrimaryVariables & operator=(const ElasticityPrimaryVariables &value)=default
Default assignment constructor.
Definition: blackoilbioeffectsmodules.hh:45
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:233
Definition: linearizationtype.hh:34