31 #ifndef OPM_DENSEAD_EVALUATION9_HPP 32 #define OPM_DENSEAD_EVALUATION9_HPP 37 #include <opm/common/Valgrind.hpp> 39 #include <dune/common/version.hh> 51 template <
class ValueT>
59 static constexpr
int size = 9;
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()
124 template <
class RhsValueType>
125 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
134 template <
class RhsValueType>
135 static Evaluation createConstant(
const RhsValueType& value)
141 void print(std::ostream& os = std::cout)
const 144 os <<
"v: " << value() <<
" / d:";
147 for (
int varIdx = 0; varIdx <
size; ++varIdx) {
148 os <<
" " << derivative(varIdx);
155 data_[1] = other.data_[1];
156 data_[2] = other.data_[2];
157 data_[3] = other.data_[3];
158 data_[4] = other.data_[4];
159 data_[5] = other.data_[5];
160 data_[6] = other.data_[6];
161 data_[7] = other.data_[7];
162 data_[8] = other.data_[8];
163 data_[9] = other.data_[9];
170 data_[0] += other.data_[0];
171 data_[1] += other.data_[1];
172 data_[2] += other.data_[2];
173 data_[3] += other.data_[3];
174 data_[4] += other.data_[4];
175 data_[5] += other.data_[5];
176 data_[6] += other.data_[6];
177 data_[7] += other.data_[7];
178 data_[8] += other.data_[8];
179 data_[9] += other.data_[9];
185 template <
class RhsValueType>
186 Evaluation& operator+=(
const RhsValueType& other)
197 data_[0] -= other.data_[0];
198 data_[1] -= other.data_[1];
199 data_[2] -= other.data_[2];
200 data_[3] -= other.data_[3];
201 data_[4] -= other.data_[4];
202 data_[5] -= other.data_[5];
203 data_[6] -= other.data_[6];
204 data_[7] -= other.data_[7];
205 data_[8] -= other.data_[8];
206 data_[9] -= other.data_[9];
212 template <
class RhsValueType>
213 Evaluation& operator-=(
const RhsValueType& other)
233 data_[1] = data_[1] * v + other.data_[1] * u;
234 data_[2] = data_[2] * v + other.data_[2] * u;
235 data_[3] = data_[3] * v + other.data_[3] * u;
236 data_[4] = data_[4] * v + other.data_[4] * u;
237 data_[5] = data_[5] * v + other.data_[5] * u;
238 data_[6] = data_[6] * v + other.data_[6] * u;
239 data_[7] = data_[7] * v + other.data_[7] * u;
240 data_[8] = data_[8] * v + other.data_[8] * u;
241 data_[9] = data_[9] * v + other.data_[9] * u;
247 template <
class RhsValueType>
248 Evaluation& operator*=(
const RhsValueType& other)
271 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
272 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
273 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
274 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
275 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
276 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
277 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
278 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
279 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
286 template <
class RhsValueType>
287 Evaluation& operator/=(
const RhsValueType& other)
316 template <
class RhsValueType>
317 Evaluation operator+(
const RhsValueType& other)
const 337 template <
class RhsValueType>
338 Evaluation operator-(
const RhsValueType& other)
const 353 result.data_[0] = - data_[0];
354 result.data_[1] = - data_[1];
355 result.data_[2] = - data_[2];
356 result.data_[3] = - data_[3];
357 result.data_[4] = - data_[4];
358 result.data_[5] = - data_[5];
359 result.data_[6] = - data_[6];
360 result.data_[7] = - data_[7];
361 result.data_[8] = - data_[8];
362 result.data_[9] = - data_[9];
376 template <
class RhsValueType>
377 Evaluation operator*(
const RhsValueType& other)
const 395 template <
class RhsValueType>
396 Evaluation operator/(
const RhsValueType& other)
const 405 template <
class RhsValueType>
406 Evaluation& operator=(
const RhsValueType& other)
417 template <
class RhsValueType>
418 bool operator==(
const RhsValueType& other)
const 419 {
return value() == other; }
421 bool operator==(
const Evaluation& other)
const 423 for (
int idx = 0; idx <
length_; ++idx) {
424 if (data_[idx] != other.data_[idx]) {
431 bool operator!=(
const Evaluation& other)
const 432 {
return !operator==(other); }
434 template <
class RhsValueType>
435 bool operator>(RhsValueType other)
const 436 {
return value() > other; }
439 {
return value() > other.value(); }
441 template <
class RhsValueType>
442 bool operator<(RhsValueType other)
const 443 {
return value() < other; }
446 {
return value() < other.value(); }
448 template <
class RhsValueType>
449 bool operator>=(RhsValueType other)
const 450 {
return value() >= other; }
452 bool operator>=(
const Evaluation& other)
const 453 {
return value() >= other.value(); }
455 template <
class RhsValueType>
456 bool operator<=(RhsValueType other)
const 457 {
return value() <= other; }
459 bool operator<=(
const Evaluation& other)
const 460 {
return value() <= other.value(); }
467 template <
class RhsValueType>
468 void setValue(
const RhsValueType& val)
472 const ValueType& derivative(
int varIdx)
const 474 assert(0 <= varIdx && varIdx <
size);
476 return data_[
dstart_ + varIdx];
480 void setDerivative(
int varIdx,
const ValueType& derVal)
482 assert(0 <= varIdx && varIdx <
size);
484 data_[
dstart_ + varIdx] = derVal;
488 std::array<ValueT, length_> data_;
493 #endif // OPM_DENSEAD_EVALUATION9_HPP Evaluation()
default constructor
Definition: Evaluation.hpp:79
ValueT ValueType
field type
Definition: Evaluation9.hpp:56
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
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
Evaluation()
default constructor
Definition: Evaluation9.hpp:74
Representation of an evaluation of a function and its derivatives w.r.t.