31#ifndef OPM_DENSEAD_EVALUATION1_HPP
32#define OPM_DENSEAD_EVALUATION1_HPP
43#include <opm/common/utility/gpuDecorators.hpp>
48template <
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
Evaluation(
const RhsValueType& c)
115 template <
class RhsValueType>
116 OPM_HOST_DEVICE
Evaluation(
const RhsValueType& c,
int varPos)
119 assert(0 <= varPos && varPos <
size());
124 data_[varPos +
dstart_()] = 1.0;
130 OPM_HOST_DEVICE
void clearDerivatives()
155 template <
class RhsValueType>
156 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType& value,
int varPos)
163 template <
class RhsValueType>
164 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
167 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
168 " with 1 derivatives");
175 template <
class RhsValueType>
176 OPM_HOST_DEVICE
static Evaluation createVariable(
const Evaluation&,
const RhsValueType& value,
int varPos)
186 template <
class RhsValueType>
187 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType& value)
190 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
191 " with 1 derivatives");
197 template <
class RhsValueType>
198 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType& value)
205 template <
class RhsValueType>
212 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
214 assert(
size() == other.size());
216 data_[1] = other.data_[1];
223 assert(
size() == other.size());
225 data_[0] += other.data_[0];
226 data_[1] += other.data_[1];
232 template <
class RhsValueType>
233 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
244 assert(
size() == other.size());
246 data_[0] -= other.data_[0];
247 data_[1] -= other.data_[1];
253 template <
class RhsValueType>
254 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
265 assert(
size() == other.size());
276 data_[1] = data_[1] * v + other.data_[1] * u;
282 template <
class RhsValueType>
283 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
294 assert(
size() == other.size());
300 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
307 template <
class RhsValueType>
308 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
321 assert(
size() == other.size());
331 template <
class RhsValueType>
332 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const
344 assert(
size() == other.size());
354 template <
class RhsValueType>
355 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const
370 result.data_[0] = - data_[0];
371 result.data_[1] = - data_[1];
378 assert(
size() == other.size());
387 template <
class RhsValueType>
388 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const
399 assert(
size() == other.size());
408 template <
class RhsValueType>
409 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const
418 template <
class RhsValueType>
419 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
430 template <
class RhsValueType>
431 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const
432 {
return value() == other; }
434 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const
436 assert(
size() == other.size());
438 for (
int idx = 0; idx <
length_(); ++idx) {
439 if (data_[idx] != other.data_[idx]) {
446 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const
447 {
return !operator==(other); }
449 template <
class RhsValueType>
450 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const
451 {
return !operator==(other); }
453 template <
class RhsValueType>
454 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const
455 {
return value() > other; }
457 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const
459 assert(
size() == other.size());
461 return value() > other.value();
464 template <
class RhsValueType>
465 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const
466 {
return value() < other; }
468 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const
470 assert(
size() == other.size());
472 return value() < other.value();
475 template <
class RhsValueType>
476 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const
477 {
return value() >= other; }
479 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const
481 assert(
size() == other.size());
483 return value() >= other.value();
486 template <
class RhsValueType>
487 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const
488 {
return value() <= other; }
490 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const
492 assert(
size() == other.size());
494 return value() <= other.value();
498 OPM_HOST_DEVICE
const ValueType& value()
const
502 template <
class RhsValueType>
503 OPM_HOST_DEVICE
void setValue(
const RhsValueType& val)
507 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const
509 assert(0 <= varIdx && varIdx <
size());
511 return data_[
dstart_() + varIdx];
515 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
517 assert(0 <= varIdx && varIdx <
size());
519 data_[
dstart_() + varIdx] = derVal;
522 template<
class Serializer>
523 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
529 std::array<ValueT, 2> data_;
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition Evaluation1.hpp:65
OPM_HOST_DEVICE Evaluation()
default constructor
Definition Evaluation1.hpp:91
Evaluation(const Evaluation &other)=default
copy other function evaluation
ValueT ValueType
field type
Definition Evaluation1.hpp:57
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition Evaluation1.hpp:60
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition Evaluation1.hpp:73
OPM_HOST_DEVICE void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition Evaluation1.hpp:81
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition Evaluation1.hpp:76
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition Evaluation1.hpp:70
Represents a function evaluation and its derivatives w.r.t.
Definition Evaluation.hpp:59
ValueT ValueType
field type
Definition Evaluation.hpp:66
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition Evaluation.hpp:82
static const int numVars
the template argument which specifies the number of derivatives (-1 == "DynamicSize" means runtime de...
Definition Evaluation.hpp:63
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition Evaluation.hpp:74
OPM_HOST_DEVICE void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition Evaluation.hpp:90
OPM_HOST_DEVICE Evaluation()
default constructor
Definition Evaluation.hpp:100
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition Evaluation.hpp:79
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition Evaluation.hpp:69
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30