31 #ifndef OPM_DENSEAD_EVALUATION11_HPP
32 #define OPM_DENSEAD_EVALUATION11_HPP
37 #include <opm/common/Valgrind.hpp>
39 #include <dune/common/version.hh>
51 template <
class ValueT>
59 static constexpr
int size = 11;
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()
126 template <
class RhsValueType>
127 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
136 template <
class RhsValueType>
137 static Evaluation createConstant(
const RhsValueType& value)
143 void print(std::ostream& os = std::cout)
const
146 os <<
"v: " << value() <<
" / d:";
149 for (
int varIdx = 0; varIdx <
size; ++varIdx) {
150 os <<
" " << derivative(varIdx);
157 data_[1] = other.data_[1];
158 data_[2] = other.data_[2];
159 data_[3] = other.data_[3];
160 data_[4] = other.data_[4];
161 data_[5] = other.data_[5];
162 data_[6] = other.data_[6];
163 data_[7] = other.data_[7];
164 data_[8] = other.data_[8];
165 data_[9] = other.data_[9];
166 data_[10] = other.data_[10];
167 data_[11] = other.data_[11];
174 data_[0] += other.data_[0];
175 data_[1] += other.data_[1];
176 data_[2] += other.data_[2];
177 data_[3] += other.data_[3];
178 data_[4] += other.data_[4];
179 data_[5] += other.data_[5];
180 data_[6] += other.data_[6];
181 data_[7] += other.data_[7];
182 data_[8] += other.data_[8];
183 data_[9] += other.data_[9];
184 data_[10] += other.data_[10];
185 data_[11] += other.data_[11];
191 template <
class RhsValueType>
192 Evaluation& operator+=(
const RhsValueType& other)
203 data_[0] -= other.data_[0];
204 data_[1] -= other.data_[1];
205 data_[2] -= other.data_[2];
206 data_[3] -= other.data_[3];
207 data_[4] -= other.data_[4];
208 data_[5] -= other.data_[5];
209 data_[6] -= other.data_[6];
210 data_[7] -= other.data_[7];
211 data_[8] -= other.data_[8];
212 data_[9] -= other.data_[9];
213 data_[10] -= other.data_[10];
214 data_[11] -= other.data_[11];
220 template <
class RhsValueType>
221 Evaluation& operator-=(
const RhsValueType& other)
241 data_[1] = data_[1] * v + other.data_[1] * u;
242 data_[2] = data_[2] * v + other.data_[2] * u;
243 data_[3] = data_[3] * v + other.data_[3] * u;
244 data_[4] = data_[4] * v + other.data_[4] * u;
245 data_[5] = data_[5] * v + other.data_[5] * u;
246 data_[6] = data_[6] * v + other.data_[6] * u;
247 data_[7] = data_[7] * v + other.data_[7] * u;
248 data_[8] = data_[8] * v + other.data_[8] * u;
249 data_[9] = data_[9] * v + other.data_[9] * u;
250 data_[10] = data_[10] * v + other.data_[10] * u;
251 data_[11] = data_[11] * v + other.data_[11] * u;
257 template <
class RhsValueType>
258 Evaluation& operator*=(
const RhsValueType& other)
283 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
284 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
285 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
286 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
287 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
288 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
289 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
290 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
291 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
292 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
293 data_[11] = (v*data_[11] - u*other.data_[11])/(v*v);
300 template <
class RhsValueType>
301 Evaluation& operator/=(
const RhsValueType& other)
332 template <
class RhsValueType>
333 Evaluation operator+(
const RhsValueType& other)
const
353 template <
class RhsValueType>
354 Evaluation operator-(
const RhsValueType& other)
const
369 result.data_[0] = - data_[0];
370 result.data_[1] = - data_[1];
371 result.data_[2] = - data_[2];
372 result.data_[3] = - data_[3];
373 result.data_[4] = - data_[4];
374 result.data_[5] = - data_[5];
375 result.data_[6] = - data_[6];
376 result.data_[7] = - data_[7];
377 result.data_[8] = - data_[8];
378 result.data_[9] = - data_[9];
379 result.data_[10] = - data_[10];
380 result.data_[11] = - data_[11];
394 template <
class RhsValueType>
395 Evaluation operator*(
const RhsValueType& other)
const
413 template <
class RhsValueType>
414 Evaluation operator/(
const RhsValueType& other)
const
423 template <
class RhsValueType>
424 Evaluation& operator=(
const RhsValueType& other)
435 template <
class RhsValueType>
436 bool operator==(
const RhsValueType& other)
const
437 {
return value() == other; }
439 bool operator==(
const Evaluation& other)
const
441 for (
int idx = 0; idx <
length_; ++idx) {
442 if (data_[idx] != other.data_[idx]) {
449 bool operator!=(
const Evaluation& other)
const
450 {
return !operator==(other); }
452 template <
class RhsValueType>
453 bool operator>(RhsValueType other)
const
454 {
return value() > other; }
457 {
return value() > other.value(); }
459 template <
class RhsValueType>
460 bool operator<(RhsValueType other)
const
461 {
return value() < other; }
464 {
return value() < other.value(); }
466 template <
class RhsValueType>
467 bool operator>=(RhsValueType other)
const
468 {
return value() >= other; }
470 bool operator>=(
const Evaluation& other)
const
471 {
return value() >= other.value(); }
473 template <
class RhsValueType>
474 bool operator<=(RhsValueType other)
const
475 {
return value() <= other; }
477 bool operator<=(
const Evaluation& other)
const
478 {
return value() <= other.value(); }
485 template <
class RhsValueType>
486 void setValue(
const RhsValueType& val)
490 const ValueType& derivative(
int varIdx)
const
492 assert(0 <= varIdx && varIdx <
size);
494 return data_[
dstart_ + varIdx];
498 void setDerivative(
int varIdx,
const ValueType& derVal)
500 assert(0 <= varIdx && varIdx <
size);
502 data_[
dstart_ + varIdx] = derVal;
506 std::array<ValueT, length_> data_;
511 #endif // OPM_DENSEAD_EVALUATION11_HPP
Evaluation()
default constructor
Definition: Evaluation.hpp:79
Evaluation()
default constructor
Definition: Evaluation11.hpp:74
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
ValueT ValueType
field type
Definition: Evaluation11.hpp:56
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.