31#ifndef OPM_DENSEAD_EVALUATION3_HPP
32#define OPM_DENSEAD_EVALUATION3_HPP
46template <
class ValueT>
64 {
return size() + 1; }
82 for (
const auto& v: data_)
83 Valgrind::CheckDefined(v);
100 template <
class RhsValueType>
113 template <
class RhsValueType>
117 assert(0 <= varPos && varPos <
size());
122 data_[varPos +
dstart_()] = 1.0;
128 void clearDerivatives()
155 template <
class RhsValueType>
156 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
163 template <
class RhsValueType>
164 static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
167 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
168 " with 3 derivatives");
175 template <
class RhsValueType>
186 template <
class RhsValueType>
187 static Evaluation createConstant(
int nVars,
const RhsValueType& value)
190 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
191 " with 3 derivatives");
197 template <
class RhsValueType>
198 static Evaluation createConstant(
const RhsValueType& value)
205 template <
class RhsValueType>
214 assert(
size() == other.size());
216 data_[1] = other.data_[1];
217 data_[2] = other.data_[2];
218 data_[3] = other.data_[3];
225 assert(
size() == other.size());
227 data_[0] += other.data_[0];
228 data_[1] += other.data_[1];
229 data_[2] += other.data_[2];
230 data_[3] += other.data_[3];
236 template <
class RhsValueType>
237 Evaluation& operator+=(
const RhsValueType& other)
248 assert(
size() == other.size());
250 data_[0] -= other.data_[0];
251 data_[1] -= other.data_[1];
252 data_[2] -= other.data_[2];
253 data_[3] -= other.data_[3];
259 template <
class RhsValueType>
260 Evaluation& operator-=(
const RhsValueType& other)
271 assert(
size() == other.size());
282 data_[1] = data_[1] * v + other.data_[1] * u;
283 data_[2] = data_[2] * v + other.data_[2] * u;
284 data_[3] = data_[3] * v + other.data_[3] * u;
290 template <
class RhsValueType>
291 Evaluation& operator*=(
const RhsValueType& other)
304 assert(
size() == other.size());
310 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
311 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
312 data_[3] = (v*data_[3] - u*other.data_[3])/(v*v);
319 template <
class RhsValueType>
320 Evaluation& operator/=(
const RhsValueType& other)
335 assert(
size() == other.size());
345 template <
class RhsValueType>
346 Evaluation operator+(
const RhsValueType& other)
const
358 assert(
size() == other.size());
368 template <
class RhsValueType>
369 Evaluation operator-(
const RhsValueType& other)
const
384 result.data_[0] = - data_[0];
385 result.data_[1] = - data_[1];
386 result.data_[2] = - data_[2];
387 result.data_[3] = - data_[3];
394 assert(
size() == other.size());
403 template <
class RhsValueType>
404 Evaluation operator*(
const RhsValueType& other)
const
415 assert(
size() == other.size());
424 template <
class RhsValueType>
425 Evaluation operator/(
const RhsValueType& other)
const
434 template <
class RhsValueType>
435 Evaluation& operator=(
const RhsValueType& other)
446 template <
class RhsValueType>
447 bool operator==(
const RhsValueType& other)
const
448 {
return value() == other; }
450 bool operator==(
const Evaluation& other)
const
452 assert(
size() == other.size());
454 for (
int idx = 0; idx <
length_(); ++idx) {
455 if (data_[idx] != other.data_[idx]) {
462 bool operator!=(
const Evaluation& other)
const
463 {
return !operator==(other); }
465 template <
class RhsValueType>
466 bool operator!=(
const RhsValueType& other)
const
467 {
return !operator==(other); }
469 template <
class RhsValueType>
470 bool operator>(RhsValueType other)
const
471 {
return value() > other; }
475 assert(
size() == other.size());
477 return value() > other.value();
480 template <
class RhsValueType>
481 bool operator<(RhsValueType other)
const
482 {
return value() < other; }
486 assert(
size() == other.size());
488 return value() < other.value();
491 template <
class RhsValueType>
492 bool operator>=(RhsValueType other)
const
493 {
return value() >= other; }
495 bool operator>=(
const Evaluation& other)
const
497 assert(
size() == other.size());
499 return value() >= other.value();
502 template <
class RhsValueType>
503 bool operator<=(RhsValueType other)
const
504 {
return value() <= other; }
506 bool operator<=(
const Evaluation& other)
const
508 assert(
size() == other.size());
510 return value() <= other.value();
518 template <
class RhsValueType>
519 void setValue(
const RhsValueType& val)
523 const ValueType& derivative(
int varIdx)
const
525 assert(0 <= varIdx && varIdx <
size());
527 return data_[
dstart_() + varIdx];
531 void setDerivative(
int varIdx,
const ValueType& derVal)
533 assert(0 <= varIdx && varIdx <
size());
535 data_[
dstart_() + varIdx] = derVal;
538 template<
class Serializer>
539 void serializeOp(Serializer& serializer)
545 std::array<ValueT, 4> data_;
Some templates to wrap the valgrind client request macros.
constexpr int dend_() const
end+1 index for derivatives
Definition Evaluation3.hpp:74
constexpr int length_() const
length of internal data vector
Definition Evaluation3.hpp:63
constexpr int size() const
number of derivatives
Definition Evaluation3.hpp:58
Evaluation()
default constructor
Definition Evaluation3.hpp:89
Evaluation(const Evaluation &other)=default
copy other function evaluation
void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition Evaluation3.hpp:79
ValueT ValueType
field type
Definition Evaluation3.hpp:55
constexpr int dstart_() const
start index for derivatives
Definition Evaluation3.hpp:71
constexpr int valuepos_() const
position index for value
Definition Evaluation3.hpp:68
Represents a function evaluation and its derivatives w.r.t.
Definition Evaluation.hpp:57
Evaluation()
default constructor
Definition Evaluation.hpp:98
ValueT ValueType
field type
Definition Evaluation.hpp:64
void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition Evaluation.hpp:88
static const int numVars
the template argument which specifies the number of derivatives (-1 == "DynamicSize" means runtime de...
Definition Evaluation.hpp:61
constexpr int size() const
number of derivatives
Definition Evaluation.hpp:67
constexpr int valuepos_() const
position index for value
Definition Evaluation.hpp:77
constexpr int length_() const
length of internal data vector
Definition Evaluation.hpp:72
constexpr int dstart_() const
start index for derivatives
Definition Evaluation.hpp:80
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30