31 #ifndef OPM_DENSEAD_EVALUATION1_HPP 32 #define OPM_DENSEAD_EVALUATION1_HPP 43 #include <opm/common/ErrorMacros.hpp> 44 #include <opm/common/utility/gpuDecorators.hpp> 49 template <
class ValueT>
61 OPM_HOST_DEVICE constexpr
int size()
const 66 OPM_HOST_DEVICE constexpr
int length_()
const 67 {
return size() + 1; }
74 OPM_HOST_DEVICE constexpr
int dstart_()
const 77 OPM_HOST_DEVICE constexpr
int dend_()
const 85 for (
const auto& v: data_)
86 Valgrind::CheckDefined(v);
103 template <
class RhsValueType>
104 OPM_HOST_DEVICE constexpr
Evaluation(
const RhsValueType& c): data_{}
114 template <
class RhsValueType>
115 OPM_HOST_DEVICE
Evaluation(
const RhsValueType& c,
int varPos)
118 assert(0 <= varPos && varPos <
size());
123 data_[varPos +
dstart_()] = 1.0;
129 OPM_HOST_DEVICE constexpr
void clearDerivatives()
154 template <
class RhsValueType>
155 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType&
value,
int varPos)
162 template <
class RhsValueType>
163 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType&
value,
int varPos)
166 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 167 " with 1 derivatives");
174 template <
class RhsValueType>
185 template <
class RhsValueType>
186 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType&
value)
189 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 190 " with 1 derivatives");
196 template <
class RhsValueType>
197 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType&
value)
204 template <
class RhsValueType>
211 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
213 assert(
size() == other.size());
215 data_[1] = other.data_[1];
222 assert(
size() == other.size());
224 data_[0] += other.data_[0];
225 data_[1] += other.data_[1];
231 template <
class RhsValueType>
232 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
243 assert(
size() == other.size());
245 data_[0] -= other.data_[0];
246 data_[1] -= other.data_[1];
252 template <
class RhsValueType>
253 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
264 assert(
size() == other.size());
275 data_[1] = data_[1] * v + other.data_[1] * u;
281 template <
class RhsValueType>
282 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
293 assert(
size() == other.size());
299 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
306 template <
class RhsValueType>
307 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
320 assert(
size() == other.size());
330 template <
class RhsValueType>
331 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 343 assert(
size() == other.size());
353 template <
class RhsValueType>
354 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 369 result.data_[0] = - data_[0];
370 result.data_[1] = - data_[1];
377 assert(
size() == other.size());
386 template <
class RhsValueType>
387 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 398 assert(
size() == other.size());
407 template <
class RhsValueType>
408 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 417 template <
class RhsValueType>
418 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
429 template <
class RhsValueType>
430 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 431 {
return value() == other; }
433 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 435 assert(
size() == other.size());
437 for (
int idx = 0; idx <
length_(); ++idx) {
438 if (data_[idx] != other.data_[idx]) {
445 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 446 {
return !operator==(other); }
448 template <
class RhsValueType>
449 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 450 {
return !operator==(other); }
452 template <
class RhsValueType>
453 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 454 {
return value() > other; }
456 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 458 assert(
size() == other.size());
460 return value() > other.value();
463 template <
class RhsValueType>
464 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 465 {
return value() < other; }
467 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 469 assert(
size() == other.size());
471 return value() < other.value();
474 template <
class RhsValueType>
475 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 476 {
return value() >= other; }
478 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 480 assert(
size() == other.size());
482 return value() >= other.value();
485 template <
class RhsValueType>
486 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 487 {
return value() <= other; }
489 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 491 assert(
size() == other.size());
493 return value() <= other.value();
501 template <
class RhsValueType>
502 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
506 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 508 assert(0 <= varIdx && varIdx <
size());
510 return data_[
dstart_() + varIdx];
514 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
516 assert(0 <= varIdx && varIdx <
size());
518 data_[
dstart_() + varIdx] = derVal;
521 template<
class Serializer>
522 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
528 std::array<ValueT, 2> data_;
534 #endif // OPM_DENSEAD_EVALUATION1_HPP OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation.hpp:87
ValueT ValueType
field type
Definition: Evaluation1.hpp:58
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:95
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: Evaluation.hpp:84
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation1.hpp:92
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation.hpp:105
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: Evaluation1.hpp:82
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation.hpp:79
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation1.hpp:74
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:71
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation.hpp:74
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation1.hpp:66
static const int numVars
the template argument which specifies the number of derivatives (-1 == "DynamicSize" means runtime de...
Definition: Evaluation.hpp:68
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: Evaluation1.hpp:71
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation1.hpp:61
Some templates to wrap the valgrind client request macros.
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:63
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation1.hpp:77