31 #ifndef OPM_DENSEAD_EVALUATION7_HPP 32 #define OPM_DENSEAD_EVALUATION7_HPP 37 #include <opm/common/Valgrind.hpp> 39 #include <dune/common/version.hh> 51 template <
class ValueT>
59 static constexpr
int size = 7;
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()
122 template <
class RhsValueType>
123 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
132 template <
class RhsValueType>
133 static Evaluation createConstant(
const RhsValueType& value)
139 void print(std::ostream& os = std::cout)
const 142 os <<
"v: " << value() <<
" / d:";
145 for (
int varIdx = 0; varIdx <
size; ++varIdx) {
146 os <<
" " << derivative(varIdx);
153 data_[1] = other.data_[1];
154 data_[2] = other.data_[2];
155 data_[3] = other.data_[3];
156 data_[4] = other.data_[4];
157 data_[5] = other.data_[5];
158 data_[6] = other.data_[6];
159 data_[7] = other.data_[7];
166 data_[0] += other.data_[0];
167 data_[1] += other.data_[1];
168 data_[2] += other.data_[2];
169 data_[3] += other.data_[3];
170 data_[4] += other.data_[4];
171 data_[5] += other.data_[5];
172 data_[6] += other.data_[6];
173 data_[7] += other.data_[7];
179 template <
class RhsValueType>
180 Evaluation& operator+=(
const RhsValueType& other)
191 data_[0] -= other.data_[0];
192 data_[1] -= other.data_[1];
193 data_[2] -= other.data_[2];
194 data_[3] -= other.data_[3];
195 data_[4] -= other.data_[4];
196 data_[5] -= other.data_[5];
197 data_[6] -= other.data_[6];
198 data_[7] -= other.data_[7];
204 template <
class RhsValueType>
205 Evaluation& operator-=(
const RhsValueType& other)
225 data_[1] = data_[1] * v + other.data_[1] * u;
226 data_[2] = data_[2] * v + other.data_[2] * u;
227 data_[3] = data_[3] * v + other.data_[3] * u;
228 data_[4] = data_[4] * v + other.data_[4] * u;
229 data_[5] = data_[5] * v + other.data_[5] * u;
230 data_[6] = data_[6] * v + other.data_[6] * u;
231 data_[7] = data_[7] * v + other.data_[7] * u;
237 template <
class RhsValueType>
238 Evaluation& operator*=(
const RhsValueType& other)
259 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
260 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
261 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
262 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
263 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
264 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
265 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
272 template <
class RhsValueType>
273 Evaluation& operator/=(
const RhsValueType& other)
300 template <
class RhsValueType>
301 Evaluation operator+(
const RhsValueType& other)
const 321 template <
class RhsValueType>
322 Evaluation operator-(
const RhsValueType& other)
const 337 result.data_[0] = - data_[0];
338 result.data_[1] = - data_[1];
339 result.data_[2] = - data_[2];
340 result.data_[3] = - data_[3];
341 result.data_[4] = - data_[4];
342 result.data_[5] = - data_[5];
343 result.data_[6] = - data_[6];
344 result.data_[7] = - data_[7];
358 template <
class RhsValueType>
359 Evaluation operator*(
const RhsValueType& other)
const 377 template <
class RhsValueType>
378 Evaluation operator/(
const RhsValueType& other)
const 387 template <
class RhsValueType>
388 Evaluation& operator=(
const RhsValueType& other)
399 template <
class RhsValueType>
400 bool operator==(
const RhsValueType& other)
const 401 {
return value() == other; }
403 bool operator==(
const Evaluation& other)
const 405 for (
int idx = 0; idx <
length_; ++idx) {
406 if (data_[idx] != other.data_[idx]) {
413 bool operator!=(
const Evaluation& other)
const 414 {
return !operator==(other); }
416 template <
class RhsValueType>
417 bool operator>(RhsValueType other)
const 418 {
return value() > other; }
421 {
return value() > other.value(); }
423 template <
class RhsValueType>
424 bool operator<(RhsValueType other)
const 425 {
return value() < other; }
428 {
return value() < other.value(); }
430 template <
class RhsValueType>
431 bool operator>=(RhsValueType other)
const 432 {
return value() >= other; }
434 bool operator>=(
const Evaluation& other)
const 435 {
return value() >= other.value(); }
437 template <
class RhsValueType>
438 bool operator<=(RhsValueType other)
const 439 {
return value() <= other; }
441 bool operator<=(
const Evaluation& other)
const 442 {
return value() <= other.value(); }
449 template <
class RhsValueType>
450 void setValue(
const RhsValueType& val)
454 const ValueType& derivative(
int varIdx)
const 456 assert(0 <= varIdx && varIdx <
size);
458 return data_[
dstart_ + varIdx];
462 void setDerivative(
int varIdx,
const ValueType& derVal)
464 assert(0 <= varIdx && varIdx <
size);
466 data_[
dstart_ + varIdx] = derVal;
470 std::array<ValueT, length_> data_;
475 #endif // OPM_DENSEAD_EVALUATION7_HPP Evaluation()
default constructor
Definition: Evaluation.hpp:79
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
Evaluation()
default constructor
Definition: Evaluation7.hpp:74
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
ValueT ValueType
field type
Definition: Evaluation7.hpp:56
Representation of an evaluation of a function and its derivatives w.r.t.