opm-common
GenericMaterialState.hpp
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 GENERIC_MATERIAL_STATE_HPP
26 #define GENERIC_MATERIAL_STATE_HPP
27 
30 
31 #include <array>
32 
33 
34 namespace Opm {
35 
36 template <class Scalar>
38 {
39 public:
44  {
45  Valgrind::SetUndefined(displacement_);
46  }
47 
51  virtual ~GenericMaterialState() = default;
52 
58  const Scalar displacement(unsigned dirIdx) const
59  {
60  return displacement_[dirIdx];
61  }
62 
69  void setDisplacement(unsigned dirIdx, const Scalar value)
70  {
71  Valgrind::CheckDefined(value);
72  Valgrind::SetUndefined(displacement_[dirIdx]);
73 
74  displacement_[dirIdx] = value;
75  }
76 
82  template <class MaterialState>
83  void assign(const MaterialState& ms)
84  {
85  // Assign displacement and rotation
86  for (unsigned dirIdx = 0; dirIdx < 3; ++dirIdx) {
87  displacement_[dirIdx] = Opm::decay<Scalar>(ms.displacement(dirIdx));
88  }
89  }
90 
94  void checkDefined() const
95  {
96  Valgrind::CheckDefined(displacement_);
97  }
98 
99 protected:
100  std::array<Scalar, 3> displacement_{};
101 }; // class GenericMaterialState
102 
103 } // namespace Opm
104 
105 #endif
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
void checkDefined() const
Instruct Valgrind to check the definedness of all attributes of this class.
Definition: GenericMaterialState.hpp:94
void assign(const MaterialState &ms)
Assign from another material state container.
Definition: GenericMaterialState.hpp:83
virtual ~GenericMaterialState()=default
Destructor.
const Scalar displacement(unsigned dirIdx) const
Return direction (x-, y- or z-) component of displacement.
Definition: GenericMaterialState.hpp:58
Some templates to wrap the valgrind client request macros.
GenericMaterialState()
Constructor.
Definition: GenericMaterialState.hpp:43
Definition: GenericMaterialState.hpp:37
void setDisplacement(unsigned dirIdx, const Scalar value)
Set a direction (x-, y- or z-) component of displacement.
Definition: GenericMaterialState.hpp:69