31 #ifndef OPM_DENSEAD_EVALUATION12_HPP 32 #define OPM_DENSEAD_EVALUATION12_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()
164 template <
class RhsValueType>
165 OPM_HOST_DEVICE
static Evaluation createVariable(
const RhsValueType&
value,
int varPos)
172 template <
class RhsValueType>
173 OPM_HOST_DEVICE
static Evaluation createVariable(
int nVars,
const RhsValueType&
value,
int varPos)
176 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 177 " with 12 derivatives");
184 template <
class RhsValueType>
195 template <
class RhsValueType>
196 OPM_HOST_DEVICE
static Evaluation createConstant(
int nVars,
const RhsValueType&
value)
199 throw std::logic_error(
"This statically-sized evaluation can only represent objects" 200 " with 12 derivatives");
206 template <
class RhsValueType>
207 OPM_HOST_DEVICE
static Evaluation createConstant(
const RhsValueType&
value)
214 template <
class RhsValueType>
221 OPM_HOST_DEVICE
void copyDerivatives(
const Evaluation& other)
223 assert(
size() == other.size());
225 data_[1] = other.data_[1];
226 data_[2] = other.data_[2];
227 data_[3] = other.data_[3];
228 data_[4] = other.data_[4];
229 data_[5] = other.data_[5];
230 data_[6] = other.data_[6];
231 data_[7] = other.data_[7];
232 data_[8] = other.data_[8];
233 data_[9] = other.data_[9];
234 data_[10] = other.data_[10];
235 data_[11] = other.data_[11];
236 data_[12] = other.data_[12];
243 assert(
size() == other.size());
245 data_[0] += other.data_[0];
246 data_[1] += other.data_[1];
247 data_[2] += other.data_[2];
248 data_[3] += other.data_[3];
249 data_[4] += other.data_[4];
250 data_[5] += other.data_[5];
251 data_[6] += other.data_[6];
252 data_[7] += other.data_[7];
253 data_[8] += other.data_[8];
254 data_[9] += other.data_[9];
255 data_[10] += other.data_[10];
256 data_[11] += other.data_[11];
257 data_[12] += other.data_[12];
263 template <
class RhsValueType>
264 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
275 assert(
size() == other.size());
277 data_[0] -= other.data_[0];
278 data_[1] -= other.data_[1];
279 data_[2] -= other.data_[2];
280 data_[3] -= other.data_[3];
281 data_[4] -= other.data_[4];
282 data_[5] -= other.data_[5];
283 data_[6] -= other.data_[6];
284 data_[7] -= other.data_[7];
285 data_[8] -= other.data_[8];
286 data_[9] -= other.data_[9];
287 data_[10] -= other.data_[10];
288 data_[11] -= other.data_[11];
289 data_[12] -= other.data_[12];
295 template <
class RhsValueType>
296 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
307 assert(
size() == other.size());
318 data_[1] = data_[1] * v + other.data_[1] * u;
319 data_[2] = data_[2] * v + other.data_[2] * u;
320 data_[3] = data_[3] * v + other.data_[3] * u;
321 data_[4] = data_[4] * v + other.data_[4] * u;
322 data_[5] = data_[5] * v + other.data_[5] * u;
323 data_[6] = data_[6] * v + other.data_[6] * u;
324 data_[7] = data_[7] * v + other.data_[7] * u;
325 data_[8] = data_[8] * v + other.data_[8] * u;
326 data_[9] = data_[9] * v + other.data_[9] * u;
327 data_[10] = data_[10] * v + other.data_[10] * u;
328 data_[11] = data_[11] * v + other.data_[11] * u;
329 data_[12] = data_[12] * v + other.data_[12] * u;
335 template <
class RhsValueType>
336 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
358 assert(
size() == other.size());
364 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
365 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
366 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
367 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
368 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
369 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
370 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
371 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
372 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
373 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
374 data_[11] = (v*data_[11] - u*other.data_[11])/(v*v);
375 data_[12] = (v*data_[12] - u*other.data_[12])/(v*v);
382 template <
class RhsValueType>
383 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
407 assert(
size() == other.size());
417 template <
class RhsValueType>
418 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 430 assert(
size() == other.size());
440 template <
class RhsValueType>
441 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 456 result.data_[0] = - data_[0];
457 result.data_[1] = - data_[1];
458 result.data_[2] = - data_[2];
459 result.data_[3] = - data_[3];
460 result.data_[4] = - data_[4];
461 result.data_[5] = - data_[5];
462 result.data_[6] = - data_[6];
463 result.data_[7] = - data_[7];
464 result.data_[8] = - data_[8];
465 result.data_[9] = - data_[9];
466 result.data_[10] = - data_[10];
467 result.data_[11] = - data_[11];
468 result.data_[12] = - data_[12];
475 assert(
size() == other.size());
484 template <
class RhsValueType>
485 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 496 assert(
size() == other.size());
505 template <
class RhsValueType>
506 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 515 template <
class RhsValueType>
516 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
527 template <
class RhsValueType>
528 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 529 {
return value() == other; }
531 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 533 assert(
size() == other.size());
535 for (
int idx = 0; idx <
length_(); ++idx) {
536 if (data_[idx] != other.data_[idx]) {
543 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 544 {
return !operator==(other); }
546 template <
class RhsValueType>
547 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 548 {
return !operator==(other); }
550 template <
class RhsValueType>
551 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 552 {
return value() > other; }
554 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 556 assert(
size() == other.size());
558 return value() > other.value();
561 template <
class RhsValueType>
562 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 563 {
return value() < other; }
565 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 567 assert(
size() == other.size());
569 return value() < other.value();
572 template <
class RhsValueType>
573 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 574 {
return value() >= other; }
576 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 578 assert(
size() == other.size());
580 return value() >= other.value();
583 template <
class RhsValueType>
584 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 585 {
return value() <= other; }
587 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 589 assert(
size() == other.size());
591 return value() <= other.value();
599 template <
class RhsValueType>
600 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
604 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 606 assert(0 <= varIdx && varIdx <
size());
608 return data_[
dstart_() + varIdx];
612 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
614 assert(0 <= varIdx && varIdx <
size());
616 data_[
dstart_() + varIdx] = derVal;
619 template<
class Serializer>
620 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
626 std::array<ValueT, 13> data_;
632 #endif // OPM_DENSEAD_EVALUATION12_HPP OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation.hpp:86
ValueT ValueType
field type
Definition: Evaluation12.hpp:57
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 length_() const
length of internal data vector
Definition: Evaluation12.hpp:65
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
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation12.hpp:60
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:81
ValueT ValueType
field type
Definition: Evaluation.hpp:70
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation.hpp:73
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 Evaluation()
default constructor
Definition: Evaluation12.hpp:91
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation12.hpp:76
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: Evaluation12.hpp:70
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation12.hpp:73