31 #ifndef OPM_DENSEAD_EVALUATION11_HPP 32 #define OPM_DENSEAD_EVALUATION11_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()
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 11 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 11 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];
234 data_[11] = other.data_[11];
241 assert(
size() == other.size());
243 data_[0] += other.data_[0];
244 data_[1] += other.data_[1];
245 data_[2] += other.data_[2];
246 data_[3] += other.data_[3];
247 data_[4] += other.data_[4];
248 data_[5] += other.data_[5];
249 data_[6] += other.data_[6];
250 data_[7] += other.data_[7];
251 data_[8] += other.data_[8];
252 data_[9] += other.data_[9];
253 data_[10] += other.data_[10];
254 data_[11] += other.data_[11];
260 template <
class RhsValueType>
261 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
272 assert(
size() == other.size());
274 data_[0] -= other.data_[0];
275 data_[1] -= other.data_[1];
276 data_[2] -= other.data_[2];
277 data_[3] -= other.data_[3];
278 data_[4] -= other.data_[4];
279 data_[5] -= other.data_[5];
280 data_[6] -= other.data_[6];
281 data_[7] -= other.data_[7];
282 data_[8] -= other.data_[8];
283 data_[9] -= other.data_[9];
284 data_[10] -= other.data_[10];
285 data_[11] -= other.data_[11];
291 template <
class RhsValueType>
292 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
303 assert(
size() == other.size());
314 data_[1] = data_[1] * v + other.data_[1] * u;
315 data_[2] = data_[2] * v + other.data_[2] * u;
316 data_[3] = data_[3] * v + other.data_[3] * u;
317 data_[4] = data_[4] * v + other.data_[4] * u;
318 data_[5] = data_[5] * v + other.data_[5] * u;
319 data_[6] = data_[6] * v + other.data_[6] * u;
320 data_[7] = data_[7] * v + other.data_[7] * u;
321 data_[8] = data_[8] * v + other.data_[8] * u;
322 data_[9] = data_[9] * v + other.data_[9] * u;
323 data_[10] = data_[10] * v + other.data_[10] * u;
324 data_[11] = data_[11] * v + other.data_[11] * u;
330 template <
class RhsValueType>
331 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
352 assert(
size() == other.size());
358 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
359 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
360 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
361 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
362 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
363 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
364 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
365 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
366 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
367 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
368 data_[11] = (v*data_[11] - u*other.data_[11])/(v*v);
375 template <
class RhsValueType>
376 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
399 assert(
size() == other.size());
409 template <
class RhsValueType>
410 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 422 assert(
size() == other.size());
432 template <
class RhsValueType>
433 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 448 result.data_[0] = - data_[0];
449 result.data_[1] = - data_[1];
450 result.data_[2] = - data_[2];
451 result.data_[3] = - data_[3];
452 result.data_[4] = - data_[4];
453 result.data_[5] = - data_[5];
454 result.data_[6] = - data_[6];
455 result.data_[7] = - data_[7];
456 result.data_[8] = - data_[8];
457 result.data_[9] = - data_[9];
458 result.data_[10] = - data_[10];
459 result.data_[11] = - data_[11];
466 assert(
size() == other.size());
475 template <
class RhsValueType>
476 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 487 assert(
size() == other.size());
496 template <
class RhsValueType>
497 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 506 template <
class RhsValueType>
507 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
518 template <
class RhsValueType>
519 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 520 {
return value() == other; }
522 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 524 assert(
size() == other.size());
526 for (
int idx = 0; idx <
length_(); ++idx) {
527 if (data_[idx] != other.data_[idx]) {
534 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 535 {
return !operator==(other); }
537 template <
class RhsValueType>
538 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 539 {
return !operator==(other); }
541 template <
class RhsValueType>
542 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 543 {
return value() > other; }
545 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 547 assert(
size() == other.size());
549 return value() > other.value();
552 template <
class RhsValueType>
553 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 554 {
return value() < other; }
556 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 558 assert(
size() == other.size());
560 return value() < other.value();
563 template <
class RhsValueType>
564 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 565 {
return value() >= other; }
567 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 569 assert(
size() == other.size());
571 return value() >= other.value();
574 template <
class RhsValueType>
575 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 576 {
return value() <= other; }
578 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 580 assert(
size() == other.size());
582 return value() <= other.value();
590 template <
class RhsValueType>
591 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
595 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 597 assert(0 <= varIdx && varIdx <
size());
599 return data_[
dstart_() + varIdx];
603 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
605 assert(0 <= varIdx && varIdx <
size());
607 data_[
dstart_() + varIdx] = derVal;
610 template<
class Serializer>
611 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
617 std::array<ValueT, 12> data_;
623 #endif // OPM_DENSEAD_EVALUATION11_HPP OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation.hpp:86
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation11.hpp:73
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation11.hpp:91
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 void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition: Evaluation11.hpp:81
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation.hpp:104
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation.hpp:78
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation11.hpp:60
ValueT ValueType
field type
Definition: Evaluation.hpp:70
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation11.hpp:76
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation.hpp:73
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation11.hpp:65
static const int numVars
the template argument which specifies the number of derivatives (-1 == "DynamicSize" means runtime de...
Definition: Evaluation.hpp:67
ValueT ValueType
field type
Definition: Evaluation11.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
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: Evaluation11.hpp:70