31 #ifndef OPM_DENSEAD_EVALUATION12_HPP 32 #define OPM_DENSEAD_EVALUATION12_HPP 37 #include <opm/common/Valgrind.hpp> 39 #include <dune/common/version.hh> 51 template <
class ValueT>
59 static constexpr
int size = 12;
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()
127 template <
class RhsValueType>
128 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
137 template <
class RhsValueType>
138 static Evaluation createConstant(
const RhsValueType& value)
144 void print(std::ostream& os = std::cout)
const 147 os <<
"v: " << value() <<
" / d:";
150 for (
int varIdx = 0; varIdx <
size; ++varIdx) {
151 os <<
" " << derivative(varIdx);
158 data_[1] = other.data_[1];
159 data_[2] = other.data_[2];
160 data_[3] = other.data_[3];
161 data_[4] = other.data_[4];
162 data_[5] = other.data_[5];
163 data_[6] = other.data_[6];
164 data_[7] = other.data_[7];
165 data_[8] = other.data_[8];
166 data_[9] = other.data_[9];
167 data_[10] = other.data_[10];
168 data_[11] = other.data_[11];
169 data_[12] = other.data_[12];
176 data_[0] += other.data_[0];
177 data_[1] += other.data_[1];
178 data_[2] += other.data_[2];
179 data_[3] += other.data_[3];
180 data_[4] += other.data_[4];
181 data_[5] += other.data_[5];
182 data_[6] += other.data_[6];
183 data_[7] += other.data_[7];
184 data_[8] += other.data_[8];
185 data_[9] += other.data_[9];
186 data_[10] += other.data_[10];
187 data_[11] += other.data_[11];
188 data_[12] += other.data_[12];
194 template <
class RhsValueType>
195 Evaluation& operator+=(
const RhsValueType& other)
206 data_[0] -= other.data_[0];
207 data_[1] -= other.data_[1];
208 data_[2] -= other.data_[2];
209 data_[3] -= other.data_[3];
210 data_[4] -= other.data_[4];
211 data_[5] -= other.data_[5];
212 data_[6] -= other.data_[6];
213 data_[7] -= other.data_[7];
214 data_[8] -= other.data_[8];
215 data_[9] -= other.data_[9];
216 data_[10] -= other.data_[10];
217 data_[11] -= other.data_[11];
218 data_[12] -= other.data_[12];
224 template <
class RhsValueType>
225 Evaluation& operator-=(
const RhsValueType& other)
245 data_[1] = data_[1] * v + other.data_[1] * u;
246 data_[2] = data_[2] * v + other.data_[2] * u;
247 data_[3] = data_[3] * v + other.data_[3] * u;
248 data_[4] = data_[4] * v + other.data_[4] * u;
249 data_[5] = data_[5] * v + other.data_[5] * u;
250 data_[6] = data_[6] * v + other.data_[6] * u;
251 data_[7] = data_[7] * v + other.data_[7] * u;
252 data_[8] = data_[8] * v + other.data_[8] * u;
253 data_[9] = data_[9] * v + other.data_[9] * u;
254 data_[10] = data_[10] * v + other.data_[10] * u;
255 data_[11] = data_[11] * v + other.data_[11] * u;
256 data_[12] = data_[12] * v + other.data_[12] * u;
262 template <
class RhsValueType>
263 Evaluation& operator*=(
const RhsValueType& other)
289 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
290 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
291 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
292 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
293 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
294 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
295 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
296 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
297 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
298 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
299 data_[11] = (v*data_[11] - u*other.data_[11])/(v*v);
300 data_[12] = (v*data_[12] - u*other.data_[12])/(v*v);
307 template <
class RhsValueType>
308 Evaluation& operator/=(
const RhsValueType& other)
340 template <
class RhsValueType>
341 Evaluation operator+(
const RhsValueType& other)
const 361 template <
class RhsValueType>
362 Evaluation operator-(
const RhsValueType& other)
const 377 result.data_[0] = - data_[0];
378 result.data_[1] = - data_[1];
379 result.data_[2] = - data_[2];
380 result.data_[3] = - data_[3];
381 result.data_[4] = - data_[4];
382 result.data_[5] = - data_[5];
383 result.data_[6] = - data_[6];
384 result.data_[7] = - data_[7];
385 result.data_[8] = - data_[8];
386 result.data_[9] = - data_[9];
387 result.data_[10] = - data_[10];
388 result.data_[11] = - data_[11];
389 result.data_[12] = - data_[12];
403 template <
class RhsValueType>
404 Evaluation operator*(
const RhsValueType& other)
const 422 template <
class RhsValueType>
423 Evaluation operator/(
const RhsValueType& other)
const 432 template <
class RhsValueType>
433 Evaluation& operator=(
const RhsValueType& other)
444 template <
class RhsValueType>
445 bool operator==(
const RhsValueType& other)
const 446 {
return value() == other; }
448 bool operator==(
const Evaluation& other)
const 450 for (
int idx = 0; idx <
length_; ++idx) {
451 if (data_[idx] != other.data_[idx]) {
458 bool operator!=(
const Evaluation& other)
const 459 {
return !operator==(other); }
461 template <
class RhsValueType>
462 bool operator>(RhsValueType other)
const 463 {
return value() > other; }
466 {
return value() > other.value(); }
468 template <
class RhsValueType>
469 bool operator<(RhsValueType other)
const 470 {
return value() < other; }
473 {
return value() < other.value(); }
475 template <
class RhsValueType>
476 bool operator>=(RhsValueType other)
const 477 {
return value() >= other; }
479 bool operator>=(
const Evaluation& other)
const 480 {
return value() >= other.value(); }
482 template <
class RhsValueType>
483 bool operator<=(RhsValueType other)
const 484 {
return value() <= other; }
486 bool operator<=(
const Evaluation& other)
const 487 {
return value() <= other.value(); }
494 template <
class RhsValueType>
495 void setValue(
const RhsValueType& val)
499 const ValueType& derivative(
int varIdx)
const 501 assert(0 <= varIdx && varIdx <
size);
503 return data_[
dstart_ + varIdx];
507 void setDerivative(
int varIdx,
const ValueType& derVal)
509 assert(0 <= varIdx && varIdx <
size);
511 data_[
dstart_ + varIdx] = derVal;
515 std::array<ValueT, length_> data_;
520 #endif // OPM_DENSEAD_EVALUATION12_HPP Evaluation()
default constructor
Definition: Evaluation.hpp:79
ValueT ValueType
field type
Definition: Evaluation12.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
Evaluation()
default constructor
Definition: Evaluation12.hpp:74
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.