31 #ifndef OPM_DENSEAD_EVALUATION1_HPP
32 #define OPM_DENSEAD_EVALUATION1_HPP
37 #include <opm/common/Valgrind.hpp>
39 #include <dune/common/version.hh>
51 template <
class ValueT>
59 static constexpr
int size = 1;
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()
116 template <
class RhsValueType>
117 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
126 template <
class RhsValueType>
127 static Evaluation createConstant(
const RhsValueType& value)
133 void print(std::ostream& os = std::cout)
const
136 os <<
"v: " << value() <<
" / d:";
139 for (
int varIdx = 0; varIdx <
size; ++varIdx) {
140 os <<
" " << derivative(varIdx);
147 data_[1] = other.data_[1];
154 data_[0] += other.data_[0];
155 data_[1] += other.data_[1];
161 template <
class RhsValueType>
162 Evaluation& operator+=(
const RhsValueType& other)
173 data_[0] -= other.data_[0];
174 data_[1] -= other.data_[1];
180 template <
class RhsValueType>
181 Evaluation& operator-=(
const RhsValueType& other)
201 data_[1] = data_[1] * v + other.data_[1] * u;
207 template <
class RhsValueType>
208 Evaluation& operator*=(
const RhsValueType& other)
223 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
230 template <
class RhsValueType>
231 Evaluation& operator/=(
const RhsValueType& other)
252 template <
class RhsValueType>
253 Evaluation operator+(
const RhsValueType& other)
const
273 template <
class RhsValueType>
274 Evaluation operator-(
const RhsValueType& other)
const
289 result.data_[0] = - data_[0];
290 result.data_[1] = - data_[1];
304 template <
class RhsValueType>
305 Evaluation operator*(
const RhsValueType& other)
const
323 template <
class RhsValueType>
324 Evaluation operator/(
const RhsValueType& other)
const
333 template <
class RhsValueType>
334 Evaluation& operator=(
const RhsValueType& other)
345 template <
class RhsValueType>
346 bool operator==(
const RhsValueType& other)
const
347 {
return value() == other; }
349 bool operator==(
const Evaluation& other)
const
351 for (
int idx = 0; idx <
length_; ++idx) {
352 if (data_[idx] != other.data_[idx]) {
359 bool operator!=(
const Evaluation& other)
const
360 {
return !operator==(other); }
362 template <
class RhsValueType>
363 bool operator>(RhsValueType other)
const
364 {
return value() > other; }
367 {
return value() > other.value(); }
369 template <
class RhsValueType>
370 bool operator<(RhsValueType other)
const
371 {
return value() < other; }
374 {
return value() < other.value(); }
376 template <
class RhsValueType>
377 bool operator>=(RhsValueType other)
const
378 {
return value() >= other; }
380 bool operator>=(
const Evaluation& other)
const
381 {
return value() >= other.value(); }
383 template <
class RhsValueType>
384 bool operator<=(RhsValueType other)
const
385 {
return value() <= other; }
387 bool operator<=(
const Evaluation& other)
const
388 {
return value() <= other.value(); }
395 template <
class RhsValueType>
396 void setValue(
const RhsValueType& val)
400 const ValueType& derivative(
int varIdx)
const
402 assert(0 <= varIdx && varIdx <
size);
404 return data_[
dstart_ + varIdx];
408 void setDerivative(
int varIdx,
const ValueType& derVal)
410 assert(0 <= varIdx && varIdx <
size);
412 data_[
dstart_ + varIdx] = derVal;
416 std::array<ValueT, length_> data_;
421 #endif // OPM_DENSEAD_EVALUATION1_HPP
Evaluation()
default constructor
Definition: Evaluation.hpp:79
ValueT ValueType
field type
Definition: Evaluation1.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
Evaluation()
default constructor
Definition: Evaluation1.hpp:74
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.