31 #ifndef OPM_DENSEAD_EVALUATION2_HPP
32 #define OPM_DENSEAD_EVALUATION2_HPP
37 #include <opm/common/Valgrind.hpp>
39 #include <dune/common/version.hh>
51 template <
class ValueT>
59 static constexpr
int size = 2;
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()
117 template <
class RhsValueType>
118 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
127 template <
class RhsValueType>
128 static Evaluation createConstant(
const RhsValueType& value)
134 void print(std::ostream& os = std::cout)
const
137 os <<
"v: " << value() <<
" / d:";
140 for (
int varIdx = 0; varIdx <
size; ++varIdx) {
141 os <<
" " << derivative(varIdx);
148 data_[1] = other.data_[1];
149 data_[2] = other.data_[2];
156 data_[0] += other.data_[0];
157 data_[1] += other.data_[1];
158 data_[2] += other.data_[2];
164 template <
class RhsValueType>
165 Evaluation& operator+=(
const RhsValueType& other)
176 data_[0] -= other.data_[0];
177 data_[1] -= other.data_[1];
178 data_[2] -= other.data_[2];
184 template <
class RhsValueType>
185 Evaluation& operator-=(
const RhsValueType& other)
205 data_[1] = data_[1] * v + other.data_[1] * u;
206 data_[2] = data_[2] * v + other.data_[2] * u;
212 template <
class RhsValueType>
213 Evaluation& operator*=(
const RhsValueType& other)
229 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
230 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
237 template <
class RhsValueType>
238 Evaluation& operator/=(
const RhsValueType& other)
260 template <
class RhsValueType>
261 Evaluation operator+(
const RhsValueType& other)
const
281 template <
class RhsValueType>
282 Evaluation operator-(
const RhsValueType& other)
const
297 result.data_[0] = - data_[0];
298 result.data_[1] = - data_[1];
299 result.data_[2] = - data_[2];
313 template <
class RhsValueType>
314 Evaluation operator*(
const RhsValueType& other)
const
332 template <
class RhsValueType>
333 Evaluation operator/(
const RhsValueType& other)
const
342 template <
class RhsValueType>
343 Evaluation& operator=(
const RhsValueType& other)
354 template <
class RhsValueType>
355 bool operator==(
const RhsValueType& other)
const
356 {
return value() == other; }
358 bool operator==(
const Evaluation& other)
const
360 for (
int idx = 0; idx <
length_; ++idx) {
361 if (data_[idx] != other.data_[idx]) {
368 bool operator!=(
const Evaluation& other)
const
369 {
return !operator==(other); }
371 template <
class RhsValueType>
372 bool operator>(RhsValueType other)
const
373 {
return value() > other; }
376 {
return value() > other.value(); }
378 template <
class RhsValueType>
379 bool operator<(RhsValueType other)
const
380 {
return value() < other; }
383 {
return value() < other.value(); }
385 template <
class RhsValueType>
386 bool operator>=(RhsValueType other)
const
387 {
return value() >= other; }
389 bool operator>=(
const Evaluation& other)
const
390 {
return value() >= other.value(); }
392 template <
class RhsValueType>
393 bool operator<=(RhsValueType other)
const
394 {
return value() <= other; }
396 bool operator<=(
const Evaluation& other)
const
397 {
return value() <= other.value(); }
404 template <
class RhsValueType>
405 void setValue(
const RhsValueType& val)
409 const ValueType& derivative(
int varIdx)
const
411 assert(0 <= varIdx && varIdx <
size);
413 return data_[
dstart_ + varIdx];
417 void setDerivative(
int varIdx,
const ValueType& derVal)
419 assert(0 <= varIdx && varIdx <
size);
421 data_[
dstart_ + varIdx] = derVal;
425 std::array<ValueT, length_> data_;
430 #endif // OPM_DENSEAD_EVALUATION2_HPP
Evaluation()
default constructor
Definition: Evaluation.hpp:79
Evaluation()
default constructor
Definition: Evaluation2.hpp:74
ValueT ValueType
field type
Definition: Evaluation2.hpp:56
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
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.