31 #ifndef OPM_DENSEAD_EVALUATION9_HPP 32 #define OPM_DENSEAD_EVALUATION9_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()
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 9 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 9 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];
238 assert(
size() == other.size());
240 data_[0] += other.data_[0];
241 data_[1] += other.data_[1];
242 data_[2] += other.data_[2];
243 data_[3] += other.data_[3];
244 data_[4] += other.data_[4];
245 data_[5] += other.data_[5];
246 data_[6] += other.data_[6];
247 data_[7] += other.data_[7];
248 data_[8] += other.data_[8];
249 data_[9] += other.data_[9];
255 template <
class RhsValueType>
256 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
267 assert(
size() == other.size());
269 data_[0] -= other.data_[0];
270 data_[1] -= other.data_[1];
271 data_[2] -= other.data_[2];
272 data_[3] -= other.data_[3];
273 data_[4] -= other.data_[4];
274 data_[5] -= other.data_[5];
275 data_[6] -= other.data_[6];
276 data_[7] -= other.data_[7];
277 data_[8] -= other.data_[8];
278 data_[9] -= other.data_[9];
284 template <
class RhsValueType>
285 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
296 assert(
size() == other.size());
307 data_[1] = data_[1] * v + other.data_[1] * u;
308 data_[2] = data_[2] * v + other.data_[2] * u;
309 data_[3] = data_[3] * v + other.data_[3] * u;
310 data_[4] = data_[4] * v + other.data_[4] * u;
311 data_[5] = data_[5] * v + other.data_[5] * u;
312 data_[6] = data_[6] * v + other.data_[6] * u;
313 data_[7] = data_[7] * v + other.data_[7] * u;
314 data_[8] = data_[8] * v + other.data_[8] * u;
315 data_[9] = data_[9] * v + other.data_[9] * u;
321 template <
class RhsValueType>
322 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
341 assert(
size() == other.size());
347 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
348 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
349 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
350 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
351 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
352 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
353 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
354 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
355 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
362 template <
class RhsValueType>
363 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
384 assert(
size() == other.size());
394 template <
class RhsValueType>
395 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 407 assert(
size() == other.size());
417 template <
class RhsValueType>
418 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 433 result.data_[0] = - data_[0];
434 result.data_[1] = - data_[1];
435 result.data_[2] = - data_[2];
436 result.data_[3] = - data_[3];
437 result.data_[4] = - data_[4];
438 result.data_[5] = - data_[5];
439 result.data_[6] = - data_[6];
440 result.data_[7] = - data_[7];
441 result.data_[8] = - data_[8];
442 result.data_[9] = - data_[9];
449 assert(
size() == other.size());
458 template <
class RhsValueType>
459 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 470 assert(
size() == other.size());
479 template <
class RhsValueType>
480 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 489 template <
class RhsValueType>
490 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
501 template <
class RhsValueType>
502 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 503 {
return value() == other; }
505 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 507 assert(
size() == other.size());
509 for (
int idx = 0; idx <
length_(); ++idx) {
510 if (data_[idx] != other.data_[idx]) {
517 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 518 {
return !operator==(other); }
520 template <
class RhsValueType>
521 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 522 {
return !operator==(other); }
524 template <
class RhsValueType>
525 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 526 {
return value() > other; }
528 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 530 assert(
size() == other.size());
532 return value() > other.value();
535 template <
class RhsValueType>
536 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 537 {
return value() < other; }
539 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 541 assert(
size() == other.size());
543 return value() < other.value();
546 template <
class RhsValueType>
547 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 548 {
return value() >= other; }
550 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 552 assert(
size() == other.size());
554 return value() >= other.value();
557 template <
class RhsValueType>
558 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 559 {
return value() <= other; }
561 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 563 assert(
size() == other.size());
565 return value() <= other.value();
573 template <
class RhsValueType>
574 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
578 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 580 assert(0 <= varIdx && varIdx <
size());
582 return data_[
dstart_() + varIdx];
586 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
588 assert(0 <= varIdx && varIdx <
size());
590 data_[
dstart_() + varIdx] = derVal;
593 template<
class Serializer>
594 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
600 std::array<ValueT, 10> data_;
606 #endif // OPM_DENSEAD_EVALUATION9_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 length_() const
length of internal data vector
Definition: Evaluation9.hpp:66
ValueT ValueType
field type
Definition: Evaluation9.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: Evaluation9.hpp:82
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 valuepos_() const
position index for value
Definition: Evaluation9.hpp:71
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation9.hpp:61
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation9.hpp:77
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation9.hpp:92
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
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation9.hpp:74
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:63