31 #ifndef OPM_DENSEAD_EVALUATION12_HPP 32 #define OPM_DENSEAD_EVALUATION12_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()
165 template <
class RhsValueType>
166 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType&
value,
int varPos)
173 template <
class RhsValueType>
174 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType&
value,
int varPos)
177 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 178 " with 12 derivatives");
185 template <
class RhsValueType>
196 template <
class RhsValueType>
197 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType&
value)
200 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 201 " with 12 derivatives");
207 template <
class RhsValueType>
208 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType&
value)
215 template <
class RhsValueType>
222 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
224 assert(
size() == other.size());
226 data_[1] = other.data_[1];
227 data_[2] = other.data_[2];
228 data_[3] = other.data_[3];
229 data_[4] = other.data_[4];
230 data_[5] = other.data_[5];
231 data_[6] = other.data_[6];
232 data_[7] = other.data_[7];
233 data_[8] = other.data_[8];
234 data_[9] = other.data_[9];
235 data_[10] = other.data_[10];
236 data_[11] = other.data_[11];
237 data_[12] = other.data_[12];
244 assert(
size() == other.size());
246 data_[0] += other.data_[0];
247 data_[1] += other.data_[1];
248 data_[2] += other.data_[2];
249 data_[3] += other.data_[3];
250 data_[4] += other.data_[4];
251 data_[5] += other.data_[5];
252 data_[6] += other.data_[6];
253 data_[7] += other.data_[7];
254 data_[8] += other.data_[8];
255 data_[9] += other.data_[9];
256 data_[10] += other.data_[10];
257 data_[11] += other.data_[11];
258 data_[12] += other.data_[12];
264 template <
class RhsValueType>
265 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
276 assert(
size() == other.size());
278 data_[0] -= other.data_[0];
279 data_[1] -= other.data_[1];
280 data_[2] -= other.data_[2];
281 data_[3] -= other.data_[3];
282 data_[4] -= other.data_[4];
283 data_[5] -= other.data_[5];
284 data_[6] -= other.data_[6];
285 data_[7] -= other.data_[7];
286 data_[8] -= other.data_[8];
287 data_[9] -= other.data_[9];
288 data_[10] -= other.data_[10];
289 data_[11] -= other.data_[11];
290 data_[12] -= other.data_[12];
296 template <
class RhsValueType>
297 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
308 assert(
size() == other.size());
319 data_[1] = data_[1] * v + other.data_[1] * u;
320 data_[2] = data_[2] * v + other.data_[2] * u;
321 data_[3] = data_[3] * v + other.data_[3] * u;
322 data_[4] = data_[4] * v + other.data_[4] * u;
323 data_[5] = data_[5] * v + other.data_[5] * u;
324 data_[6] = data_[6] * v + other.data_[6] * u;
325 data_[7] = data_[7] * v + other.data_[7] * u;
326 data_[8] = data_[8] * v + other.data_[8] * u;
327 data_[9] = data_[9] * v + other.data_[9] * u;
328 data_[10] = data_[10] * v + other.data_[10] * u;
329 data_[11] = data_[11] * v + other.data_[11] * u;
330 data_[12] = data_[12] * v + other.data_[12] * u;
336 template <
class RhsValueType>
337 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
359 assert(
size() == other.size());
365 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
366 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
367 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
368 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
369 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
370 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
371 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
372 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
373 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
374 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
375 data_[11] = (v*data_[11] - u*other.data_[11])/(v*v);
376 data_[12] = (v*data_[12] - u*other.data_[12])/(v*v);
383 template <
class RhsValueType>
384 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
408 assert(
size() == other.size());
418 template <
class RhsValueType>
419 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 431 assert(
size() == other.size());
441 template <
class RhsValueType>
442 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 457 result.data_[0] = - data_[0];
458 result.data_[1] = - data_[1];
459 result.data_[2] = - data_[2];
460 result.data_[3] = - data_[3];
461 result.data_[4] = - data_[4];
462 result.data_[5] = - data_[5];
463 result.data_[6] = - data_[6];
464 result.data_[7] = - data_[7];
465 result.data_[8] = - data_[8];
466 result.data_[9] = - data_[9];
467 result.data_[10] = - data_[10];
468 result.data_[11] = - data_[11];
469 result.data_[12] = - data_[12];
476 assert(
size() == other.size());
485 template <
class RhsValueType>
486 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 497 assert(
size() == other.size());
506 template <
class RhsValueType>
507 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 516 template <
class RhsValueType>
517 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
528 template <
class RhsValueType>
529 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 530 {
return value() == other; }
532 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 534 assert(
size() == other.size());
536 for (
int idx = 0; idx <
length_(); ++idx) {
537 if (data_[idx] != other.data_[idx]) {
544 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 545 {
return !operator==(other); }
547 template <
class RhsValueType>
548 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 549 {
return !operator==(other); }
551 template <
class RhsValueType>
552 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 553 {
return value() > other; }
555 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 557 assert(
size() == other.size());
559 return value() > other.value();
562 template <
class RhsValueType>
563 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 564 {
return value() < other; }
566 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 568 assert(
size() == other.size());
570 return value() < other.value();
573 template <
class RhsValueType>
574 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 575 {
return value() >= other; }
577 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 579 assert(
size() == other.size());
581 return value() >= other.value();
584 template <
class RhsValueType>
585 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 586 {
return value() <= other; }
588 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 590 assert(
size() == other.size());
592 return value() <= other.value();
600 template <
class RhsValueType>
601 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
605 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 607 assert(0 <= varIdx && varIdx <
size());
609 return data_[
dstart_() + varIdx];
613 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
615 assert(0 <= varIdx && varIdx <
size());
617 data_[
dstart_() + varIdx] = derVal;
620 template<
class Serializer>
621 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
627 std::array<ValueT, 13> data_;
633 #endif // OPM_DENSEAD_EVALUATION12_HPP OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation.hpp:87
ValueT ValueType
field type
Definition: Evaluation12.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 constexpr int length_() const
length of internal data vector
Definition: Evaluation12.hpp:66
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation.hpp:105
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation.hpp:79
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation12.hpp:61
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
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: Evaluation12.hpp:82
ValueT ValueType
field type
Definition: Evaluation.hpp:71
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation.hpp:74
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 Evaluation()
default constructor
Definition: Evaluation12.hpp:92
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation12.hpp:77
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 valuepos_() const
position index for value
Definition: Evaluation12.hpp:71
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation12.hpp:74