31 #ifndef OPM_DENSEAD_EVALUATION11_HPP 32 #define OPM_DENSEAD_EVALUATION11_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()
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 11 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 11 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];
242 assert(
size() == other.size());
244 data_[0] += other.data_[0];
245 data_[1] += other.data_[1];
246 data_[2] += other.data_[2];
247 data_[3] += other.data_[3];
248 data_[4] += other.data_[4];
249 data_[5] += other.data_[5];
250 data_[6] += other.data_[6];
251 data_[7] += other.data_[7];
252 data_[8] += other.data_[8];
253 data_[9] += other.data_[9];
254 data_[10] += other.data_[10];
255 data_[11] += other.data_[11];
261 template <
class RhsValueType>
262 OPM_HOST_DEVICE
Evaluation& operator+=(
const RhsValueType& other)
273 assert(
size() == other.size());
275 data_[0] -= other.data_[0];
276 data_[1] -= other.data_[1];
277 data_[2] -= other.data_[2];
278 data_[3] -= other.data_[3];
279 data_[4] -= other.data_[4];
280 data_[5] -= other.data_[5];
281 data_[6] -= other.data_[6];
282 data_[7] -= other.data_[7];
283 data_[8] -= other.data_[8];
284 data_[9] -= other.data_[9];
285 data_[10] -= other.data_[10];
286 data_[11] -= other.data_[11];
292 template <
class RhsValueType>
293 OPM_HOST_DEVICE
Evaluation& operator-=(
const RhsValueType& other)
304 assert(
size() == other.size());
315 data_[1] = data_[1] * v + other.data_[1] * u;
316 data_[2] = data_[2] * v + other.data_[2] * u;
317 data_[3] = data_[3] * v + other.data_[3] * u;
318 data_[4] = data_[4] * v + other.data_[4] * u;
319 data_[5] = data_[5] * v + other.data_[5] * u;
320 data_[6] = data_[6] * v + other.data_[6] * u;
321 data_[7] = data_[7] * v + other.data_[7] * u;
322 data_[8] = data_[8] * v + other.data_[8] * u;
323 data_[9] = data_[9] * v + other.data_[9] * u;
324 data_[10] = data_[10] * v + other.data_[10] * u;
325 data_[11] = data_[11] * v + other.data_[11] * u;
331 template <
class RhsValueType>
332 OPM_HOST_DEVICE
Evaluation& operator*=(
const RhsValueType& other)
353 assert(
size() == other.size());
359 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
360 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
361 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
362 data_[4] = (v*data_[4] - u*other.data_[4])/(v*v);
363 data_[5] = (v*data_[5] - u*other.data_[5])/(v*v);
364 data_[6] = (v*data_[6] - u*other.data_[6])/(v*v);
365 data_[7] = (v*data_[7] - u*other.data_[7])/(v*v);
366 data_[8] = (v*data_[8] - u*other.data_[8])/(v*v);
367 data_[9] = (v*data_[9] - u*other.data_[9])/(v*v);
368 data_[10] = (v*data_[10] - u*other.data_[10])/(v*v);
369 data_[11] = (v*data_[11] - u*other.data_[11])/(v*v);
376 template <
class RhsValueType>
377 OPM_HOST_DEVICE
Evaluation& operator/=(
const RhsValueType& other)
400 assert(
size() == other.size());
410 template <
class RhsValueType>
411 OPM_HOST_DEVICE
Evaluation operator+(
const RhsValueType& other)
const 423 assert(
size() == other.size());
433 template <
class RhsValueType>
434 OPM_HOST_DEVICE
Evaluation operator-(
const RhsValueType& other)
const 449 result.data_[0] = - data_[0];
450 result.data_[1] = - data_[1];
451 result.data_[2] = - data_[2];
452 result.data_[3] = - data_[3];
453 result.data_[4] = - data_[4];
454 result.data_[5] = - data_[5];
455 result.data_[6] = - data_[6];
456 result.data_[7] = - data_[7];
457 result.data_[8] = - data_[8];
458 result.data_[9] = - data_[9];
459 result.data_[10] = - data_[10];
460 result.data_[11] = - data_[11];
467 assert(
size() == other.size());
476 template <
class RhsValueType>
477 OPM_HOST_DEVICE
Evaluation operator*(
const RhsValueType& other)
const 488 assert(
size() == other.size());
497 template <
class RhsValueType>
498 OPM_HOST_DEVICE
Evaluation operator/(
const RhsValueType& other)
const 507 template <
class RhsValueType>
508 OPM_HOST_DEVICE
Evaluation& operator=(
const RhsValueType& other)
519 template <
class RhsValueType>
520 OPM_HOST_DEVICE
bool operator==(
const RhsValueType& other)
const 521 {
return value() == other; }
523 OPM_HOST_DEVICE
bool operator==(
const Evaluation& other)
const 525 assert(
size() == other.size());
527 for (
int idx = 0; idx <
length_(); ++idx) {
528 if (data_[idx] != other.data_[idx]) {
535 OPM_HOST_DEVICE
bool operator!=(
const Evaluation& other)
const 536 {
return !operator==(other); }
538 template <
class RhsValueType>
539 OPM_HOST_DEVICE
bool operator!=(
const RhsValueType& other)
const 540 {
return !operator==(other); }
542 template <
class RhsValueType>
543 OPM_HOST_DEVICE
bool operator>(RhsValueType other)
const 544 {
return value() > other; }
546 OPM_HOST_DEVICE
bool operator>(
const Evaluation& other)
const 548 assert(
size() == other.size());
550 return value() > other.value();
553 template <
class RhsValueType>
554 OPM_HOST_DEVICE
bool operator<(RhsValueType other)
const 555 {
return value() < other; }
557 OPM_HOST_DEVICE
bool operator<(
const Evaluation& other)
const 559 assert(
size() == other.size());
561 return value() < other.value();
564 template <
class RhsValueType>
565 OPM_HOST_DEVICE
bool operator>=(RhsValueType other)
const 566 {
return value() >= other; }
568 OPM_HOST_DEVICE
bool operator>=(
const Evaluation& other)
const 570 assert(
size() == other.size());
572 return value() >= other.value();
575 template <
class RhsValueType>
576 OPM_HOST_DEVICE
bool operator<=(RhsValueType other)
const 577 {
return value() <= other; }
579 OPM_HOST_DEVICE
bool operator<=(
const Evaluation& other)
const 581 assert(
size() == other.size());
583 return value() <= other.value();
591 template <
class RhsValueType>
592 OPM_HOST_DEVICE constexpr
void setValue(
const RhsValueType& val)
596 OPM_HOST_DEVICE
const ValueType& derivative(
int varIdx)
const 598 assert(0 <= varIdx && varIdx <
size());
600 return data_[
dstart_() + varIdx];
604 OPM_HOST_DEVICE
void setDerivative(
int varIdx,
const ValueType& derVal)
606 assert(0 <= varIdx && varIdx <
size());
608 data_[
dstart_() + varIdx] = derVal;
611 template<
class Serializer>
612 OPM_HOST_DEVICE
void serializeOp(Serializer& serializer)
618 std::array<ValueT, 12> data_;
624 #endif // OPM_DENSEAD_EVALUATION11_HPP OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation.hpp:87
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation11.hpp:74
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation11.hpp:92
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 void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition: Evaluation11.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
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:61
ValueT ValueType
field type
Definition: Evaluation.hpp:71
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation11.hpp:77
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation.hpp:74
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation11.hpp:66
static const int numVars
the template argument which specifies the number of derivatives (-1 == "DynamicSize" means runtime de...
Definition: Evaluation.hpp:68
ValueT ValueType
field type
Definition: Evaluation11.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
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: Evaluation11.hpp:71