31 #ifndef OPM_DENSEAD_EVALUATION8_HPP 32 #define OPM_DENSEAD_EVALUATION8_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()
160 template <
class RhsValueType>
161 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType&
value,
int varPos)
168 template <
class RhsValueType>
169 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType&
value,
int varPos)
172 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 173 " with 8 derivatives");
180 template <
class RhsValueType>
191 template <
class RhsValueType>
192 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType&
value)
195 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 196 " with 8 derivatives");
202 template <
class RhsValueType>
203 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType&
value)
210 template <
class RhsValueType>
217 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
219 assert(
size() == other.size());
221 data_[1] = other.data_[1];
222 data_[2] = other.data_[2];
223 data_[3] = other.data_[3];
224 data_[4] = other.data_[4];
225 data_[5] = other.data_[5];
226 data_[6] = other.data_[6];
227 data_[7] = other.data_[7];
228 data_[8] = other.data_[8];
235 assert(
size() == other.size());
237 data_[0] += other.data_[0];
238 data_[1] += other.data_[1];
239 data_[2] += other.data_[2];
240 data_[3] += other.data_[3];
241 data_[4] += other.data_[4];
242 data_[5] += other.data_[5];
243 data_[6] += other.data_[6];
244 data_[7] += other.data_[7];
245 data_[8] += other.data_[8];
251 template <
class RhsValueType>
252 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
263 assert(
size() == other.size());
265 data_[0] -= other.data_[0];
266 data_[1] -= other.data_[1];
267 data_[2] -= other.data_[2];
268 data_[3] -= other.data_[3];
269 data_[4] -= other.data_[4];
270 data_[5] -= other.data_[5];
271 data_[6] -= other.data_[6];
272 data_[7] -= other.data_[7];
273 data_[8] -= other.data_[8];
279 template <
class RhsValueType>
280 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
291 assert(
size() == other.size());
302 data_[1] = data_[1] * v + other.data_[1] * u;
303 data_[2] = data_[2] * v + other.data_[2] * u;
304 data_[3] = data_[3] * v + other.data_[3] * u;
305 data_[4] = data_[4] * v + other.data_[4] * u;
306 data_[5] = data_[5] * v + other.data_[5] * u;
307 data_[6] = data_[6] * v + other.data_[6] * u;
308 data_[7] = data_[7] * v + other.data_[7] * u;
309 data_[8] = data_[8] * v + other.data_[8] * u;
315 template <
class RhsValueType>
316 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
334 assert(
size() == other.size());
340 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
341 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
342 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
343 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
344 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
345 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
346 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
347 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
354 template <
class RhsValueType>
355 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
375 assert(
size() == other.size());
385 template <
class RhsValueType>
386 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 398 assert(
size() == other.size());
408 template <
class RhsValueType>
409 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 424 result.data_[0] = - data_[0];
425 result.data_[1] = - data_[1];
426 result.data_[2] = - data_[2];
427 result.data_[3] = - data_[3];
428 result.data_[4] = - data_[4];
429 result.data_[5] = - data_[5];
430 result.data_[6] = - data_[6];
431 result.data_[7] = - data_[7];
432 result.data_[8] = - data_[8];
439 assert(
size() == other.size());
448 template <
class RhsValueType>
449 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 460 assert(
size() == other.size());
469 template <
class RhsValueType>
470 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 479 template <
class RhsValueType>
480 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
491 template <
class RhsValueType>
492 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 493 {
return value() == other; }
495 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 497 assert(
size() == other.size());
499 for (
int idx = 0; idx <
length_(); ++idx) {
500 if (data_[idx] != other.data_[idx]) {
507 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 508 {
return !operator==(other); }
510 template <
class RhsValueType>
511 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 512 {
return !operator==(other); }
514 template <
class RhsValueType>
515 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 516 {
return value() > other; }
518 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 520 assert(
size() == other.size());
522 return value() > other.value();
525 template <
class RhsValueType>
526 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 527 {
return value() < other; }
529 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 531 assert(
size() == other.size());
533 return value() < other.value();
536 template <
class RhsValueType>
537 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 538 {
return value() >= other; }
540 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 542 assert(
size() == other.size());
544 return value() >= other.value();
547 template <
class RhsValueType>
548 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 549 {
return value() <= other; }
551 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 553 assert(
size() == other.size());
555 return value() <= other.value();
563 template <
class RhsValueType>
564 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
568 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 570 assert(0 <= varIdx && varIdx <
size());
572 return data_[
dstart_() + varIdx];
576 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
578 assert(0 <= varIdx && varIdx <
size());
580 data_[
dstart_() + varIdx] = derVal;
583 template<
class Serializer>
584 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
590 std::array<ValueT, 9> data_;
596 #endif // OPM_DENSEAD_EVALUATION8_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: Evaluation8.hpp:65
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: Evaluation8.hpp:81
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation8.hpp:60
ValueT ValueType
field type
Definition: Evaluation8.hpp:57
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 dstart_() const
start index for derivatives
Definition: Evaluation8.hpp:73
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 size() const
number of derivatives
Definition: Evaluation.hpp:73
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation8.hpp:76
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 Evaluation()
default constructor
Definition: Evaluation8.hpp:91
Some templates to wrap the valgrind client request macros.
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:62
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: Evaluation8.hpp:70