31 #ifndef OPM_DENSEAD_EVALUATION6_HPP 32 #define OPM_DENSEAD_EVALUATION6_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()
158 template <
class RhsValueType>
159 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType&
value,
int varPos)
166 template <
class RhsValueType>
167 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType&
value,
int varPos)
170 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 171 " with 6 derivatives");
178 template <
class RhsValueType>
189 template <
class RhsValueType>
190 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType&
value)
193 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 194 " with 6 derivatives");
200 template <
class RhsValueType>
201 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType&
value)
208 template <
class RhsValueType>
215 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
217 assert(
size() == other.size());
219 data_[1] = other.data_[1];
220 data_[2] = other.data_[2];
221 data_[3] = other.data_[3];
222 data_[4] = other.data_[4];
223 data_[5] = other.data_[5];
224 data_[6] = other.data_[6];
231 assert(
size() == other.size());
233 data_[0] += other.data_[0];
234 data_[1] += other.data_[1];
235 data_[2] += other.data_[2];
236 data_[3] += other.data_[3];
237 data_[4] += other.data_[4];
238 data_[5] += other.data_[5];
239 data_[6] += other.data_[6];
245 template <
class RhsValueType>
246 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
257 assert(
size() == other.size());
259 data_[0] -= other.data_[0];
260 data_[1] -= other.data_[1];
261 data_[2] -= other.data_[2];
262 data_[3] -= other.data_[3];
263 data_[4] -= other.data_[4];
264 data_[5] -= other.data_[5];
265 data_[6] -= other.data_[6];
271 template <
class RhsValueType>
272 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
283 assert(
size() == other.size());
294 data_[1] = data_[1] * v + other.data_[1] * u;
295 data_[2] = data_[2] * v + other.data_[2] * u;
296 data_[3] = data_[3] * v + other.data_[3] * u;
297 data_[4] = data_[4] * v + other.data_[4] * u;
298 data_[5] = data_[5] * v + other.data_[5] * u;
299 data_[6] = data_[6] * v + other.data_[6] * u;
305 template <
class RhsValueType>
306 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
322 assert(
size() == other.size());
328 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
329 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
330 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
331 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
332 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
333 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
340 template <
class RhsValueType>
341 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
359 assert(
size() == other.size());
369 template <
class RhsValueType>
370 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 382 assert(
size() == other.size());
392 template <
class RhsValueType>
393 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 408 result.data_[0] = - data_[0];
409 result.data_[1] = - data_[1];
410 result.data_[2] = - data_[2];
411 result.data_[3] = - data_[3];
412 result.data_[4] = - data_[4];
413 result.data_[5] = - data_[5];
414 result.data_[6] = - data_[6];
421 assert(
size() == other.size());
430 template <
class RhsValueType>
431 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 442 assert(
size() == other.size());
451 template <
class RhsValueType>
452 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 461 template <
class RhsValueType>
462 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
473 template <
class RhsValueType>
474 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 475 {
return value() == other; }
477 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 479 assert(
size() == other.size());
481 for (
int idx = 0; idx <
length_(); ++idx) {
482 if (data_[idx] != other.data_[idx]) {
489 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 490 {
return !operator==(other); }
492 template <
class RhsValueType>
493 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 494 {
return !operator==(other); }
496 template <
class RhsValueType>
497 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 498 {
return value() > other; }
500 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 502 assert(
size() == other.size());
504 return value() > other.value();
507 template <
class RhsValueType>
508 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 509 {
return value() < other; }
511 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 513 assert(
size() == other.size());
515 return value() < other.value();
518 template <
class RhsValueType>
519 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 520 {
return value() >= other; }
522 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 524 assert(
size() == other.size());
526 return value() >= other.value();
529 template <
class RhsValueType>
530 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 531 {
return value() <= other; }
533 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 535 assert(
size() == other.size());
537 return value() <= other.value();
545 template <
class RhsValueType>
546 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
550 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 552 assert(0 <= varIdx && varIdx <
size());
554 return data_[
dstart_() + varIdx];
558 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
560 assert(0 <= varIdx && varIdx <
size());
562 data_[
dstart_() + varIdx] = derVal;
565 template<
class Serializer>
566 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
572 std::array<ValueT, 7> data_;
578 #endif // OPM_DENSEAD_EVALUATION6_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 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: Evaluation6.hpp:70
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
ValueT ValueType
field type
Definition: Evaluation.hpp:70
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation6.hpp:76
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
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation6.hpp:73
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation6.hpp:65
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation6.hpp:91
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:62
ValueT ValueType
field type
Definition: Evaluation6.hpp:57
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation6.hpp:60
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: Evaluation6.hpp:81