31 #ifndef OPM_DENSEAD_EVALUATION10_HPP 32 #define OPM_DENSEAD_EVALUATION10_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()
162 template <
class RhsValueType>
163 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType&
value,
int varPos)
170 template <
class RhsValueType>
171 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType&
value,
int varPos)
174 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 175 " with 10 derivatives");
182 template <
class RhsValueType>
193 template <
class RhsValueType>
194 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType&
value)
197 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 198 " with 10 derivatives");
204 template <
class RhsValueType>
205 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType&
value)
212 template <
class RhsValueType>
219 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
221 assert(
size() == other.size());
223 data_[1] = other.data_[1];
224 data_[2] = other.data_[2];
225 data_[3] = other.data_[3];
226 data_[4] = other.data_[4];
227 data_[5] = other.data_[5];
228 data_[6] = other.data_[6];
229 data_[7] = other.data_[7];
230 data_[8] = other.data_[8];
231 data_[9] = other.data_[9];
232 data_[10] = other.data_[10];
239 assert(
size() == other.size());
241 data_[0] += other.data_[0];
242 data_[1] += other.data_[1];
243 data_[2] += other.data_[2];
244 data_[3] += other.data_[3];
245 data_[4] += other.data_[4];
246 data_[5] += other.data_[5];
247 data_[6] += other.data_[6];
248 data_[7] += other.data_[7];
249 data_[8] += other.data_[8];
250 data_[9] += other.data_[9];
251 data_[10] += other.data_[10];
257 template <
class RhsValueType>
258 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
269 assert(
size() == other.size());
271 data_[0] -= other.data_[0];
272 data_[1] -= other.data_[1];
273 data_[2] -= other.data_[2];
274 data_[3] -= other.data_[3];
275 data_[4] -= other.data_[4];
276 data_[5] -= other.data_[5];
277 data_[6] -= other.data_[6];
278 data_[7] -= other.data_[7];
279 data_[8] -= other.data_[8];
280 data_[9] -= other.data_[9];
281 data_[10] -= other.data_[10];
287 template <
class RhsValueType>
288 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
299 assert(
size() == other.size());
310 data_[1] = data_[1] * v + other.data_[1] * u;
311 data_[2] = data_[2] * v + other.data_[2] * u;
312 data_[3] = data_[3] * v + other.data_[3] * u;
313 data_[4] = data_[4] * v + other.data_[4] * u;
314 data_[5] = data_[5] * v + other.data_[5] * u;
315 data_[6] = data_[6] * v + other.data_[6] * u;
316 data_[7] = data_[7] * v + other.data_[7] * u;
317 data_[8] = data_[8] * v + other.data_[8] * u;
318 data_[9] = data_[9] * v + other.data_[9] * u;
319 data_[10] = data_[10] * v + other.data_[10] * u;
325 template <
class RhsValueType>
326 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
346 assert(
size() == other.size());
352 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
353 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
354 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
355 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
356 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
357 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
358 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
359 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
360 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
361 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
368 template <
class RhsValueType>
369 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
391 assert(
size() == other.size());
401 template <
class RhsValueType>
402 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 414 assert(
size() == other.size());
424 template <
class RhsValueType>
425 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 440 result.data_[0] = - data_[0];
441 result.data_[1] = - data_[1];
442 result.data_[2] = - data_[2];
443 result.data_[3] = - data_[3];
444 result.data_[4] = - data_[4];
445 result.data_[5] = - data_[5];
446 result.data_[6] = - data_[6];
447 result.data_[7] = - data_[7];
448 result.data_[8] = - data_[8];
449 result.data_[9] = - data_[9];
450 result.data_[10] = - data_[10];
457 assert(
size() == other.size());
466 template <
class RhsValueType>
467 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 478 assert(
size() == other.size());
487 template <
class RhsValueType>
488 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 497 template <
class RhsValueType>
498 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
509 template <
class RhsValueType>
510 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 511 {
return value() == other; }
513 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 515 assert(
size() == other.size());
517 for (
int idx = 0; idx <
length_(); ++idx) {
518 if (data_[idx] != other.data_[idx]) {
525 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 526 {
return !operator==(other); }
528 template <
class RhsValueType>
529 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 530 {
return !operator==(other); }
532 template <
class RhsValueType>
533 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 534 {
return value() > other; }
536 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 538 assert(
size() == other.size());
540 return value() > other.value();
543 template <
class RhsValueType>
544 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 545 {
return value() < other; }
547 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 549 assert(
size() == other.size());
551 return value() < other.value();
554 template <
class RhsValueType>
555 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 556 {
return value() >= other; }
558 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 560 assert(
size() == other.size());
562 return value() >= other.value();
565 template <
class RhsValueType>
566 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 567 {
return value() <= other; }
569 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 571 assert(
size() == other.size());
573 return value() <= other.value();
581 template <
class RhsValueType>
582 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
586 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 588 assert(0 <= varIdx && varIdx <
size());
590 return data_[
dstart_() + varIdx];
594 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
596 assert(0 <= varIdx && varIdx <
size());
598 data_[
dstart_() + varIdx] = derVal;
601 template<
class Serializer>
602 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
608 std::array<ValueT, 11> data_;
614 #endif // OPM_DENSEAD_EVALUATION10_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 dstart_() const
start index for derivatives
Definition: Evaluation10.hpp:73
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: Evaluation10.hpp:81
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation.hpp:104
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation10.hpp:76
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation.hpp:78
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation10.hpp:65
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 valuepos_() const
position index for value
Definition: Evaluation10.hpp:70
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation10.hpp:91
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 size() const
number of derivatives
Definition: Evaluation10.hpp:60
ValueT ValueType
field type
Definition: Evaluation10.hpp:57
Some templates to wrap the valgrind client request macros.
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:62