31#ifndef OPM_DENSEAD_EVALUATION2_HPP
32#define OPM_DENSEAD_EVALUATION2_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()
154 template <
class RhsValueType>
155 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
162 template <
class RhsValueType>
163 static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
166 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
167 " with 2 derivatives");
174 template <
class RhsValueType>
185 template <
class RhsValueType>
186 static Evaluation createConstant(
int nVars,
const RhsValueType& value)
189 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
190 " with 2 derivatives");
196 template <
class RhsValueType>
197 static Evaluation createConstant(
const RhsValueType& value)
204 template <
class RhsValueType>
213 assert(
size() == other.size());
215 data_[1] = other.data_[1];
216 data_[2] = other.data_[2];
223 assert(
size() == other.size());
225 data_[0] += other.data_[0];
226 data_[1] += other.data_[1];
227 data_[2] += other.data_[2];
233 template <
class RhsValueType>
234 Evaluation& operator+=(
const RhsValueType& other)
245 assert(
size() == other.size());
247 data_[0] -= other.data_[0];
248 data_[1] -= other.data_[1];
249 data_[2] -= other.data_[2];
255 template <
class RhsValueType>
256 Evaluation& operator-=(
const RhsValueType& other)
267 assert(
size() == other.size());
278 data_[1] = data_[1] * v + other.data_[1] * u;
279 data_[2] = data_[2] * v + other.data_[2] * u;
285 template <
class RhsValueType>
286 Evaluation& operator*=(
const RhsValueType& other)
298 assert(
size() == other.size());
304 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
305 data_[2] = (v*data_[2] - u*other.data_[2])/(v*v);
312 template <
class RhsValueType>
313 Evaluation& operator/=(
const RhsValueType& other)
327 assert(
size() == other.size());
337 template <
class RhsValueType>
338 Evaluation operator+(
const RhsValueType& other)
const
350 assert(
size() == other.size());
360 template <
class RhsValueType>
361 Evaluation operator-(
const RhsValueType& other)
const
376 result.data_[0] = - data_[0];
377 result.data_[1] = - data_[1];
378 result.data_[2] = - data_[2];
385 assert(
size() == other.size());
394 template <
class RhsValueType>
395 Evaluation operator*(
const RhsValueType& other)
const
406 assert(
size() == other.size());
415 template <
class RhsValueType>
416 Evaluation operator/(
const RhsValueType& other)
const
425 template <
class RhsValueType>
426 Evaluation& operator=(
const RhsValueType& other)
437 template <
class RhsValueType>
438 bool operator==(
const RhsValueType& other)
const
439 {
return value() == other; }
441 bool operator==(
const Evaluation& other)
const
443 assert(
size() == other.size());
445 for (
int idx = 0; idx <
length_(); ++idx) {
446 if (data_[idx] != other.data_[idx]) {
453 bool operator!=(
const Evaluation& other)
const
454 {
return !operator==(other); }
456 template <
class RhsValueType>
457 bool operator!=(
const RhsValueType& other)
const
458 {
return !operator==(other); }
460 template <
class RhsValueType>
461 bool operator>(RhsValueType other)
const
462 {
return value() > other; }
466 assert(
size() == other.size());
468 return value() > other.value();
471 template <
class RhsValueType>
472 bool operator<(RhsValueType other)
const
473 {
return value() < other; }
477 assert(
size() == other.size());
479 return value() < other.value();
482 template <
class RhsValueType>
483 bool operator>=(RhsValueType other)
const
484 {
return value() >= other; }
486 bool operator>=(
const Evaluation& other)
const
488 assert(
size() == other.size());
490 return value() >= other.value();
493 template <
class RhsValueType>
494 bool operator<=(RhsValueType other)
const
495 {
return value() <= other; }
497 bool operator<=(
const Evaluation& other)
const
499 assert(
size() == other.size());
501 return value() <= other.value();
509 template <
class RhsValueType>
510 void setValue(
const RhsValueType& val)
514 const ValueType& derivative(
int varIdx)
const
516 assert(0 <= varIdx && varIdx <
size());
518 return data_[
dstart_() + varIdx];
522 void setDerivative(
int varIdx,
const ValueType& derVal)
524 assert(0 <= varIdx && varIdx <
size());
526 data_[
dstart_() + varIdx] = derVal;
529 template<
class Serializer>
530 void serializeOp(Serializer& serializer)
536 std::array<ValueT, 3> data_;
Some templates to wrap the valgrind client request macros.
constexpr int valuepos_() const
position index for value
Definition Evaluation2.hpp:68
ValueT ValueType
field type
Definition Evaluation2.hpp:55
constexpr int dstart_() const
start index for derivatives
Definition Evaluation2.hpp:71
constexpr int size() const
number of derivatives
Definition Evaluation2.hpp:58
Evaluation()
default constructor
Definition Evaluation2.hpp:89
void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition Evaluation2.hpp:79
constexpr int dend_() const
end+1 index for derivatives
Definition Evaluation2.hpp:74
constexpr int length_() const
length of internal data vector
Definition Evaluation2.hpp:63
Evaluation(const Evaluation &other)=default
copy other function evaluation
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