31 #ifndef OPM_DENSEAD_EVALUATION5_HPP 32 #define OPM_DENSEAD_EVALUATION5_HPP 37 #include <opm/common/Valgrind.hpp> 39 #include <dune/common/version.hh> 51 template <
class ValueT>
59 static constexpr
int size = 5;
84 template <
class RhsValueType>
89 Valgrind::CheckDefined( data_ );
96 template <
class RhsValueType>
100 assert(0 <= varPos && varPos <
size);
106 Valgrind::CheckDefined(data_);
110 void clearDerivatives()
120 template <
class RhsValueType>
121 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
130 template <
class RhsValueType>
131 static Evaluation createConstant(
const RhsValueType& value)
137 void print(std::ostream& os = std::cout)
const 140 os <<
"v: " << value() <<
" / d:";
143 for (
int varIdx = 0; varIdx <
size; ++varIdx) {
144 os <<
" " << derivative(varIdx);
151 data_[1] = other.data_[1];
152 data_[2] = other.data_[2];
153 data_[3] = other.data_[3];
154 data_[4] = other.data_[4];
155 data_[5] = other.data_[5];
162 data_[0] += other.data_[0];
163 data_[1] += other.data_[1];
164 data_[2] += other.data_[2];
165 data_[3] += other.data_[3];
166 data_[4] += other.data_[4];
167 data_[5] += other.data_[5];
173 template <
class RhsValueType>
174 Evaluation& operator+=(
const RhsValueType& other)
185 data_[0] -= other.data_[0];
186 data_[1] -= other.data_[1];
187 data_[2] -= other.data_[2];
188 data_[3] -= other.data_[3];
189 data_[4] -= other.data_[4];
190 data_[5] -= other.data_[5];
196 template <
class RhsValueType>
197 Evaluation& operator-=(
const RhsValueType& other)
217 data_[1] = data_[1] * v + other.data_[1] * u;
218 data_[2] = data_[2] * v + other.data_[2] * u;
219 data_[3] = data_[3] * v + other.data_[3] * u;
220 data_[4] = data_[4] * v + other.data_[4] * u;
221 data_[5] = data_[5] * v + other.data_[5] * u;
227 template <
class RhsValueType>
228 Evaluation& operator*=(
const RhsValueType& other)
247 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
248 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
249 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
250 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
251 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
258 template <
class RhsValueType>
259 Evaluation& operator/=(
const RhsValueType& other)
284 template <
class RhsValueType>
285 Evaluation operator+(
const RhsValueType& other)
const 305 template <
class RhsValueType>
306 Evaluation operator-(
const RhsValueType& other)
const 321 result.data_[0] = - data_[0];
322 result.data_[1] = - data_[1];
323 result.data_[2] = - data_[2];
324 result.data_[3] = - data_[3];
325 result.data_[4] = - data_[4];
326 result.data_[5] = - data_[5];
340 template <
class RhsValueType>
341 Evaluation operator*(
const RhsValueType& other)
const 359 template <
class RhsValueType>
360 Evaluation operator/(
const RhsValueType& other)
const 369 template <
class RhsValueType>
370 Evaluation& operator=(
const RhsValueType& other)
381 template <
class RhsValueType>
382 bool operator==(
const RhsValueType& other)
const 383 {
return value() == other; }
385 bool operator==(
const Evaluation& other)
const 387 for (
int idx = 0; idx <
length_; ++idx) {
388 if (data_[idx] != other.data_[idx]) {
395 bool operator!=(
const Evaluation& other)
const 396 {
return !operator==(other); }
398 template <
class RhsValueType>
399 bool operator>(RhsValueType other)
const 400 {
return value() > other; }
403 {
return value() > other.value(); }
405 template <
class RhsValueType>
406 bool operator<(RhsValueType other)
const 407 {
return value() < other; }
410 {
return value() < other.value(); }
412 template <
class RhsValueType>
413 bool operator>=(RhsValueType other)
const 414 {
return value() >= other; }
416 bool operator>=(
const Evaluation& other)
const 417 {
return value() >= other.value(); }
419 template <
class RhsValueType>
420 bool operator<=(RhsValueType other)
const 421 {
return value() <= other; }
423 bool operator<=(
const Evaluation& other)
const 424 {
return value() <= other.value(); }
431 template <
class RhsValueType>
432 void setValue(
const RhsValueType& val)
436 const ValueType& derivative(
int varIdx)
const 438 assert(0 <= varIdx && varIdx <
size);
440 return data_[
dstart_ + varIdx];
444 void setDerivative(
int varIdx,
const ValueType& derVal)
446 assert(0 <= varIdx && varIdx <
size);
448 data_[
dstart_ + varIdx] = derVal;
452 std::array<ValueT, length_> data_;
457 #endif // OPM_DENSEAD_EVALUATION5_HPP Evaluation()
default constructor
Definition: Evaluation.hpp:79
Evaluation()
default constructor
Definition: Evaluation5.hpp:74
Definition: Air_Mesitylene.hpp:33
A number of commonly used algebraic functions for the localized OPM automatic differentiation (AD) fr...
ValueT ValueType
field type
Definition: Evaluation.hpp:61
static constexpr int valuepos_
position index for value
Definition: Evaluation.hpp:71
ValueT ValueType
field type
Definition: Evaluation5.hpp:56
static constexpr int length_
length of internal data vector
Definition: Evaluation.hpp:68
static constexpr int dstart_
start index for derivatives
Definition: Evaluation.hpp:73
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:57
static constexpr int size
number of derivatives
Definition: Evaluation.hpp:64
static constexpr int dend_
end+1 index for derivatives
Definition: Evaluation.hpp:75
Representation of an evaluation of a function and its derivatives w.r.t.