31 #ifndef OPM_DENSEAD_EVALUATION10_HPP 32 #define OPM_DENSEAD_EVALUATION10_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()
163 template <
class RhsValueType>
164 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType&
value,
int varPos)
171 template <
class RhsValueType>
172 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType&
value,
int varPos)
175 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 176 " with 10 derivatives");
183 template <
class RhsValueType>
194 template <
class RhsValueType>
195 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType&
value)
198 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 199 " with 10 derivatives");
205 template <
class RhsValueType>
206 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType&
value)
213 template <
class RhsValueType>
220 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
222 assert(
size() == other.size());
224 data_[1] = other.data_[1];
225 data_[2] = other.data_[2];
226 data_[3] = other.data_[3];
227 data_[4] = other.data_[4];
228 data_[5] = other.data_[5];
229 data_[6] = other.data_[6];
230 data_[7] = other.data_[7];
231 data_[8] = other.data_[8];
232 data_[9] = other.data_[9];
233 data_[10] = other.data_[10];
240 assert(
size() == other.size());
242 data_[0] += other.data_[0];
243 data_[1] += other.data_[1];
244 data_[2] += other.data_[2];
245 data_[3] += other.data_[3];
246 data_[4] += other.data_[4];
247 data_[5] += other.data_[5];
248 data_[6] += other.data_[6];
249 data_[7] += other.data_[7];
250 data_[8] += other.data_[8];
251 data_[9] += other.data_[9];
252 data_[10] += other.data_[10];
258 template <
class RhsValueType>
259 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
270 assert(
size() == other.size());
272 data_[0] -= other.data_[0];
273 data_[1] -= other.data_[1];
274 data_[2] -= other.data_[2];
275 data_[3] -= other.data_[3];
276 data_[4] -= other.data_[4];
277 data_[5] -= other.data_[5];
278 data_[6] -= other.data_[6];
279 data_[7] -= other.data_[7];
280 data_[8] -= other.data_[8];
281 data_[9] -= other.data_[9];
282 data_[10] -= other.data_[10];
288 template <
class RhsValueType>
289 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
300 assert(
size() == other.size());
311 data_[1] = data_[1] * v + other.data_[1] * u;
312 data_[2] = data_[2] * v + other.data_[2] * u;
313 data_[3] = data_[3] * v + other.data_[3] * u;
314 data_[4] = data_[4] * v + other.data_[4] * u;
315 data_[5] = data_[5] * v + other.data_[5] * u;
316 data_[6] = data_[6] * v + other.data_[6] * u;
317 data_[7] = data_[7] * v + other.data_[7] * u;
318 data_[8] = data_[8] * v + other.data_[8] * u;
319 data_[9] = data_[9] * v + other.data_[9] * u;
320 data_[10] = data_[10] * v + other.data_[10] * u;
326 template <
class RhsValueType>
327 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
347 assert(
size() == other.size());
353 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
354 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
355 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
356 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
357 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
358 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
359 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
360 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
361 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
362 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
369 template <
class RhsValueType>
370 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
392 assert(
size() == other.size());
402 template <
class RhsValueType>
403 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 415 assert(
size() == other.size());
425 template <
class RhsValueType>
426 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 441 result.data_[0] = - data_[0];
442 result.data_[1] = - data_[1];
443 result.data_[2] = - data_[2];
444 result.data_[3] = - data_[3];
445 result.data_[4] = - data_[4];
446 result.data_[5] = - data_[5];
447 result.data_[6] = - data_[6];
448 result.data_[7] = - data_[7];
449 result.data_[8] = - data_[8];
450 result.data_[9] = - data_[9];
451 result.data_[10] = - data_[10];
458 assert(
size() == other.size());
467 template <
class RhsValueType>
468 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 479 assert(
size() == other.size());
488 template <
class RhsValueType>
489 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 498 template <
class RhsValueType>
499 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
510 template <
class RhsValueType>
511 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 512 {
return value() == other; }
514 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 516 assert(
size() == other.size());
518 for (
int idx = 0; idx <
length_(); ++idx) {
519 if (data_[idx] != other.data_[idx]) {
526 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 527 {
return !operator==(other); }
529 template <
class RhsValueType>
530 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 531 {
return !operator==(other); }
533 template <
class RhsValueType>
534 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 535 {
return value() > other; }
537 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 539 assert(
size() == other.size());
541 return value() > other.value();
544 template <
class RhsValueType>
545 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 546 {
return value() < other; }
548 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 550 assert(
size() == other.size());
552 return value() < other.value();
555 template <
class RhsValueType>
556 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 557 {
return value() >= other; }
559 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 561 assert(
size() == other.size());
563 return value() >= other.value();
566 template <
class RhsValueType>
567 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 568 {
return value() <= other; }
570 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 572 assert(
size() == other.size());
574 return value() <= other.value();
582 template <
class RhsValueType>
583 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
587 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 589 assert(0 <= varIdx && varIdx <
size());
591 return data_[
dstart_() + varIdx];
595 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
597 assert(0 <= varIdx && varIdx <
size());
599 data_[
dstart_() + varIdx] = derVal;
602 template<
class Serializer>
603 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
609 std::array<ValueT, 11> data_;
615 #endif // OPM_DENSEAD_EVALUATION10_HPP OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation.hpp:87
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 dstart_() const
start index for derivatives
Definition: Evaluation10.hpp:74
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:82
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation.hpp:105
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation10.hpp:77
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation.hpp:79
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation10.hpp:66
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 valuepos_() const
position index for value
Definition: Evaluation10.hpp:71
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation10.hpp:92
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 size() const
number of derivatives
Definition: Evaluation10.hpp:61
ValueT ValueType
field type
Definition: Evaluation10.hpp:58
Some templates to wrap the valgrind client request macros.
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:63