31#ifndef OPM_DENSEAD_EVALUATION1_HPP
32#define OPM_DENSEAD_EVALUATION1_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()
153 template <
class RhsValueType>
154 static Evaluation createVariable(
const RhsValueType& value,
int varPos)
161 template <
class RhsValueType>
162 static Evaluation createVariable(
int nVars,
const RhsValueType& value,
int varPos)
165 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
166 " with 1 derivatives");
173 template <
class RhsValueType>
184 template <
class RhsValueType>
185 static Evaluation createConstant(
int nVars,
const RhsValueType& value)
188 throw std::logic_error(
"This statically-sized evaluation can only represent objects"
189 " with 1 derivatives");
195 template <
class RhsValueType>
196 static Evaluation createConstant(
const RhsValueType& value)
203 template <
class RhsValueType>
212 assert(
size() == other.size());
214 data_[1] = other.data_[1];
221 assert(
size() == other.size());
223 data_[0] += other.data_[0];
224 data_[1] += other.data_[1];
230 template <
class RhsValueType>
231 Evaluation& operator+=(
const RhsValueType& other)
242 assert(
size() == other.size());
244 data_[0] -= other.data_[0];
245 data_[1] -= other.data_[1];
251 template <
class RhsValueType>
252 Evaluation& operator-=(
const RhsValueType& other)
263 assert(
size() == other.size());
274 data_[1] = data_[1] * v + other.data_[1] * u;
280 template <
class RhsValueType>
281 Evaluation& operator*=(
const RhsValueType& other)
292 assert(
size() == other.size());
298 data_[1] = (v*data_[1] - u*other.data_[1])/(v*v);
305 template <
class RhsValueType>
306 Evaluation& operator/=(
const RhsValueType& other)
319 assert(
size() == other.size());
329 template <
class RhsValueType>
330 Evaluation operator+(
const RhsValueType& other)
const
342 assert(
size() == other.size());
352 template <
class RhsValueType>
353 Evaluation operator-(
const RhsValueType& other)
const
368 result.data_[0] = - data_[0];
369 result.data_[1] = - data_[1];
376 assert(
size() == other.size());
385 template <
class RhsValueType>
386 Evaluation operator*(
const RhsValueType& other)
const
397 assert(
size() == other.size());
406 template <
class RhsValueType>
407 Evaluation operator/(
const RhsValueType& other)
const
416 template <
class RhsValueType>
417 Evaluation& operator=(
const RhsValueType& other)
428 template <
class RhsValueType>
429 bool operator==(
const RhsValueType& other)
const
430 {
return value() == other; }
432 bool operator==(
const Evaluation& other)
const
434 assert(
size() == other.size());
436 for (
int idx = 0; idx <
length_(); ++idx) {
437 if (data_[idx] != other.data_[idx]) {
444 bool operator!=(
const Evaluation& other)
const
445 {
return !operator==(other); }
447 template <
class RhsValueType>
448 bool operator!=(
const RhsValueType& other)
const
449 {
return !operator==(other); }
451 template <
class RhsValueType>
452 bool operator>(RhsValueType other)
const
453 {
return value() > other; }
457 assert(
size() == other.size());
459 return value() > other.value();
462 template <
class RhsValueType>
463 bool operator<(RhsValueType other)
const
464 {
return value() < other; }
468 assert(
size() == other.size());
470 return value() < other.value();
473 template <
class RhsValueType>
474 bool operator>=(RhsValueType other)
const
475 {
return value() >= other; }
477 bool operator>=(
const Evaluation& other)
const
479 assert(
size() == other.size());
481 return value() >= other.value();
484 template <
class RhsValueType>
485 bool operator<=(RhsValueType other)
const
486 {
return value() <= other; }
488 bool operator<=(
const Evaluation& other)
const
490 assert(
size() == other.size());
492 return value() <= other.value();
500 template <
class RhsValueType>
501 void setValue(
const RhsValueType& val)
505 const ValueType& derivative(
int varIdx)
const
507 assert(0 <= varIdx && varIdx <
size());
509 return data_[
dstart_() + varIdx];
513 void setDerivative(
int varIdx,
const ValueType& derVal)
515 assert(0 <= varIdx && varIdx <
size());
517 data_[
dstart_() + varIdx] = derVal;
520 template<
class Serializer>
521 void serializeOp(Serializer& serializer)
527 std::array<ValueT, 2> data_;
Some templates to wrap the valgrind client request macros.
constexpr int length_() const
length of internal data vector
Definition Evaluation1.hpp:63
Evaluation()
default constructor
Definition Evaluation1.hpp:89
void checkDefined_() const
instruct valgrind to check that the value and all derivatives of the Evaluation object are well-defin...
Definition Evaluation1.hpp:79
Evaluation(const Evaluation &other)=default
copy other function evaluation
ValueT ValueType
field type
Definition Evaluation1.hpp:55
constexpr int dstart_() const
start index for derivatives
Definition Evaluation1.hpp:71
constexpr int size() const
number of derivatives
Definition Evaluation1.hpp:58
constexpr int dend_() const
end+1 index for derivatives
Definition Evaluation1.hpp:74
constexpr int valuepos_() const
position index for value
Definition Evaluation1.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