31 #ifndef OPM_DENSEAD_EVALUATION9_HPP 32 #define OPM_DENSEAD_EVALUATION9_HPP 43 #include <opm/common/utility/gpuDecorators.hpp> 48 template <
class ValueT>
60 OPM_HOST_DEVICE constexpr
int size()
const 65 OPM_HOST_DEVICE constexpr
int length_()
const 66 {
return size() + 1; }
73 OPM_HOST_DEVICE constexpr
int dstart_()
const 76 OPM_HOST_DEVICE constexpr
int dend_()
const 84 for (
const auto& v: data_)
85 Valgrind::CheckDefined(v);
102 template <
class RhsValueType>
103 OPM_HOST_DEVICE constexpr
Evaluation(
const RhsValueType& c): data_{}
113 template <
class RhsValueType>
114 OPM_HOST_DEVICE
Evaluation(
const RhsValueType& c,
int varPos)
117 assert(0 <= varPos && varPos <
size());
122 data_[varPos +
dstart_()] = 1.0;
128 OPM_HOST_DEVICE constexpr
void clearDerivatives()
161 template <
class RhsValueType>
162 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType&
value,
int varPos)
169 template <
class RhsValueType>
170 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType&
value,
int varPos)
173 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 174 " with 9 derivatives");
181 template <
class RhsValueType>
192 template <
class RhsValueType>
193 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType&
value)
196 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 197 " with 9 derivatives");
203 template <
class RhsValueType>
204 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType&
value)
211 template <
class RhsValueType>
218 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
220 assert(
size() == other.size());
222 data_[1] = other.data_[1];
223 data_[2] = other.data_[2];
224 data_[3] = other.data_[3];
225 data_[4] = other.data_[4];
226 data_[5] = other.data_[5];
227 data_[6] = other.data_[6];
228 data_[7] = other.data_[7];
229 data_[8] = other.data_[8];
230 data_[9] = other.data_[9];
237 assert(
size() == other.size());
239 data_[0] += other.data_[0];
240 data_[1] += other.data_[1];
241 data_[2] += other.data_[2];
242 data_[3] += other.data_[3];
243 data_[4] += other.data_[4];
244 data_[5] += other.data_[5];
245 data_[6] += other.data_[6];
246 data_[7] += other.data_[7];
247 data_[8] += other.data_[8];
248 data_[9] += other.data_[9];
254 template <
class RhsValueType>
255 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
266 assert(
size() == other.size());
268 data_[0] -= other.data_[0];
269 data_[1] -= other.data_[1];
270 data_[2] -= other.data_[2];
271 data_[3] -= other.data_[3];
272 data_[4] -= other.data_[4];
273 data_[5] -= other.data_[5];
274 data_[6] -= other.data_[6];
275 data_[7] -= other.data_[7];
276 data_[8] -= other.data_[8];
277 data_[9] -= other.data_[9];
283 template <
class RhsValueType>
284 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
295 assert(
size() == other.size());
306 data_[1] = data_[1] * v + other.data_[1] * u;
307 data_[2] = data_[2] * v + other.data_[2] * u;
308 data_[3] = data_[3] * v + other.data_[3] * u;
309 data_[4] = data_[4] * v + other.data_[4] * u;
310 data_[5] = data_[5] * v + other.data_[5] * u;
311 data_[6] = data_[6] * v + other.data_[6] * u;
312 data_[7] = data_[7] * v + other.data_[7] * u;
313 data_[8] = data_[8] * v + other.data_[8] * u;
314 data_[9] = data_[9] * v + other.data_[9] * u;
320 template <
class RhsValueType>
321 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
340 assert(
size() == other.size());
346 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
347 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
348 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
349 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
350 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
351 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
352 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
353 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
354 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
361 template <
class RhsValueType>
362 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
383 assert(
size() == other.size());
393 template <
class RhsValueType>
394 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 406 assert(
size() == other.size());
416 template <
class RhsValueType>
417 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 432 result.data_[0] = - data_[0];
433 result.data_[1] = - data_[1];
434 result.data_[2] = - data_[2];
435 result.data_[3] = - data_[3];
436 result.data_[4] = - data_[4];
437 result.data_[5] = - data_[5];
438 result.data_[6] = - data_[6];
439 result.data_[7] = - data_[7];
440 result.data_[8] = - data_[8];
441 result.data_[9] = - data_[9];
448 assert(
size() == other.size());
457 template <
class RhsValueType>
458 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 469 assert(
size() == other.size());
478 template <
class RhsValueType>
479 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 488 template <
class RhsValueType>
489 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
500 template <
class RhsValueType>
501 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 502 {
return value() == other; }
504 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 506 assert(
size() == other.size());
508 for (
int idx = 0; idx <
length_(); ++idx) {
509 if (data_[idx] != other.data_[idx]) {
516 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 517 {
return !operator==(other); }
519 template <
class RhsValueType>
520 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 521 {
return !operator==(other); }
523 template <
class RhsValueType>
524 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 525 {
return value() > other; }
527 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 529 assert(
size() == other.size());
531 return value() > other.value();
534 template <
class RhsValueType>
535 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 536 {
return value() < other; }
538 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 540 assert(
size() == other.size());
542 return value() < other.value();
545 template <
class RhsValueType>
546 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 547 {
return value() >= other; }
549 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 551 assert(
size() == other.size());
553 return value() >= other.value();
556 template <
class RhsValueType>
557 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 558 {
return value() <= other; }
560 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 562 assert(
size() == other.size());
564 return value() <= other.value();
572 template <
class RhsValueType>
573 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
577 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 579 assert(0 <= varIdx && varIdx <
size());
581 return data_[
dstart_() + varIdx];
585 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
587 assert(0 <= varIdx && varIdx <
size());
589 data_[
dstart_() + varIdx] = derVal;
592 template<
class Serializer>
593 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
599 std::array<ValueT, 10> data_;
605 #endif // OPM_DENSEAD_EVALUATION9_HPP OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation.hpp:86
OPM_HOST_DEVICE constexpr void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition: Evaluation.hpp:94
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: Evaluation.hpp:83
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation9.hpp:65
ValueT ValueType
field type
Definition: Evaluation9.hpp:57
OPM_HOST_DEVICE constexpr void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition: Evaluation9.hpp:81
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation.hpp:104
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation.hpp:78
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: Evaluation9.hpp:70
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation9.hpp:60
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation9.hpp:76
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation9.hpp:91
ValueT ValueType
field type
Definition: Evaluation.hpp:70
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation.hpp:73
static const int numVars
the template argument which specifies the number of derivatives (-1 == "DynamicSize" means runtime de...
Definition: Evaluation.hpp:67
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation9.hpp:73
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:62