opm-common
DynamicEvaluation.hpp
Go to the documentation of this file.
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
32 #ifndef OPM_DENSEAD_EVALUATION_DYNAMIC_HPP
33 #define OPM_DENSEAD_EVALUATION_DYNAMIC_HPP
34 
35 #ifndef NDEBUG
37 #endif
39 
40 #include <cassert>
41 #include <iosfwd>
42 #include <stdexcept>
43 
44 #include <opm/common/utility/gpuDecorators.hpp>
45 
46 namespace Opm {
47 namespace DenseAd {
48 
53 template <class ValueT, unsigned staticSize>
54 class Evaluation<ValueT, DynamicSize, staticSize>
55 {
56 public:
59  static const int numVars = DynamicSize;
60 
62  typedef ValueT ValueType;
63 
65  OPM_HOST_DEVICE int size() const
66  { return data_.size() - 1; }
67 
68 protected:
70  OPM_HOST_DEVICE int length_() const
71  { return data_.size(); }
72 
73 
75  OPM_HOST_DEVICE constexpr int valuepos_() const
76  { return 0; }
78  OPM_HOST_DEVICE constexpr int dstart_() const
79  { return 1; }
81  OPM_HOST_DEVICE int dend_() const
82  { return length_(); }
83 
86  OPM_HOST_DEVICE constexpr void checkDefined_() const
87  {
88 #ifndef NDEBUG
89  for (int i = dstart_(); i < dend_(); ++i)
90  Valgrind::CheckDefined(data_[i]);
91 #endif
92  }
93 
94 public:
96  OPM_HOST_DEVICE Evaluation() : data_()
97  {}
98 
100  Evaluation(const Evaluation& other) = default;
101 
104  OPM_HOST_DEVICE Evaluation(Evaluation&& other)
105  : data_(std::move(other.data_))
106  { }
107 
109  OPM_HOST_DEVICE Evaluation& operator=(Evaluation&& other)
110  {
111  data_ = std::move(other.data_);
112  return *this;
113  }
114 
115  // create a dynamic evaluation which represents a constant function
116  //
117  // i.e., f(x) = c. this implies an evaluation with the given value and all
118  // derivatives being zero.
119  template <class RhsValueType>
120  OPM_HOST_DEVICE Evaluation(int numDerivatives, const RhsValueType& c)
121  : data_(1 + numDerivatives, 0.0)
122  {
123  //clearDerivatives();
124  setValue(c);
125 
126  checkDefined_();
127  }
128 
129  // create a dynamic evaluation which represents a constant function
130  // by using zero number of derivatives.
131  //
132  // i.e., f(x) = c. this implies an evaluation with the given value and all
133  // derivatives being zero.
134  template <class RhsValueType>
135  OPM_HOST_DEVICE Evaluation(const RhsValueType& c)
136  : Evaluation(0, c)
137  {
138  }
139 
140  // create an evaluation representing a variable with the variable position of varPos
141  // The value is set to c, all derivatives are zero except for the one at varPos, which is set to 1.
142  template <class RhsValueType>
143  OPM_HOST_DEVICE Evaluation(int nVars, const RhsValueType& c, int varPos)
144  : data_(1 + nVars, 0.0)
145  {
146  // The variable position must be in represented by the given variable descriptor
147  assert(0 <= varPos && varPos < size());
148 
149  setValue(c);
150 
151  data_[varPos + dstart_()] = 1.0;
152 
153  checkDefined_();
154  }
155 
156  // set all derivatives to zero
157  OPM_HOST_DEVICE constexpr void clearDerivatives()
158  {
159  for (int i = dstart_(); i < dend_(); ++i)
160  data_[i] = 0.0;
161  }
162 
163  // create an uninitialized Evaluation object that is compatible with the
164  // argument, but not initialized
165  //
166  // This basically boils down to the copy constructor without copying
167  // anything. If the number of derivatives is known at compile time, this
168  // is equivalent to creating an uninitialized object using the default
169  // constructor, while for dynamic evaluations, it creates an Evaluation
170  // object which exhibits the same number of derivatives as the argument.
171  OPM_HOST_DEVICE static Evaluation createBlank(const Evaluation& x)
172  { return Evaluation(x.size()); }
173 
174  // create an Evaluation with value and all the derivatives to be zero
175  OPM_HOST_DEVICE static Evaluation createConstantZero(const Evaluation& x)
176  { return Evaluation(x.size(), 0.0); }
177 
178  // create an Evaluation with value to be one and all the derivatives to be zero
179  OPM_HOST_DEVICE static Evaluation createConstantOne(const Evaluation& x)
180  { return Evaluation(x.size(), 1.); }
181 
182  // create a function evaluation for a "naked" depending variable (i.e., f(x) = x)
183  template <class RhsValueType>
184  OPM_HOST_DEVICE static Evaluation createVariable(const RhsValueType&, int)
185  {
186  throw std::logic_error("Dynamically sized evaluations require that the number of "
187  "derivatives is specified when creating an evaluation");
188  }
189 
190  template <class RhsValueType>
191  OPM_HOST_DEVICE static Evaluation createVariable(int nVars, const RhsValueType& value, int varPos)
192  {
193  // copy function value and set all derivatives to 0, except for the variable
194  // which is represented by the value (which is set to 1.0)
195  return Evaluation(nVars, value, varPos);
196  }
197 
198  template <class RhsValueType>
199  OPM_HOST_DEVICE static Evaluation createVariable(const Evaluation& x, const RhsValueType& value, int varPos)
200  {
201  // copy function value and set all derivatives to 0, except for the variable
202  // which is represented by the value (which is set to 1.0)
203  return Evaluation(x.size(), value, varPos);
204  }
205 
206 
207  // "evaluate" a constant function (i.e. a function that does not depend on the set of
208  // relevant variables, f(x) = c).
209  template <class RhsValueType>
210  OPM_HOST_DEVICE static Evaluation createConstant(int nVars, const RhsValueType& value)
211  {
212  return Evaluation(nVars, value);
213  }
214 
215  // "evaluate" a constant function (i.e. a function that does not depend on the set of
216  // relevant variables, f(x) = c).
217  template <class RhsValueType>
218  OPM_HOST_DEVICE static Evaluation createConstant(const RhsValueType& value)
219  {
220  // using an evaluation without derivatives
221  return Evaluation(value);
222  }
223 
224  // "evaluate" a constant function (i.e. a function that does not depend on the set of
225  // relevant variables, f(x) = c).
226  template <class RhsValueType>
227  OPM_HOST_DEVICE static Evaluation createConstant(const Evaluation& x, const RhsValueType& value)
228  {
229  return Evaluation(x.size(), value);
230  }
231 
232  // copy all derivatives from other
233  OPM_HOST_DEVICE void copyDerivatives(const Evaluation& other)
234  {
235  assert(size() == other.size());
236 
237  for (int i = dstart_(); i < dend_(); ++i)
238  data_[i] = other.data_[i];
239  }
240 
241 
242  // add value and derivatives from other to this value and derivatives
243  OPM_HOST_DEVICE Evaluation& operator+=(const Evaluation& other)
244  {
245  const int thisSize = size();
246  const int otherSize = other.size();
247 
248  // Allow operation if sizes match or one is constant (size == 0)
249  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
250 
251  if (thisSize == otherSize) {
252  for (int i = 0; i < length_(); ++i)
253  data_[i] += other.data_[i];
254  return *this;
255  }
256  if (otherSize == 0) {
257  *this += other.value();
258  return *this;
259  }
260  if (thisSize == 0) {
261  assert(otherSize > 0);
262  this->appendDerivativesToConstant(otherSize);
263  data_[valuepos_()] += other.data_[valuepos_()];
264  for (int i = dstart_(); i < dend_(); ++i)
265  data_[i] = other.data_[i];
266  return *this;
267  }
268  throw std::logic_error(
269  "Cannot operate Evaluations with different number of derivatives "
270  "unless one of them has no derivatives"
271  );
272  }
273 
274  // add value from other to this values
275  template <class RhsValueType>
276  OPM_HOST_DEVICE Evaluation& operator+=(const RhsValueType& other)
277  {
278  // value is added, derivatives stay the same
279  data_[valuepos_()] += other;
280 
281  return *this;
282  }
283 
284  // subtract other's value and derivatives from this values
285  OPM_HOST_DEVICE Evaluation& operator-=(const Evaluation& other)
286  {
287  const int thisSize = size();
288  const int otherSize = other.size();
289 
290  // Allow operation if sizes match or one is constant (size == 0)
291  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
292 
293  if (thisSize == otherSize) {
294  for (int i = 0; i < length_(); ++i)
295  data_[i] -= other.data_[i];
296  return *this;
297  }
298  if (otherSize == 0) {
299  *this -= other.value();
300  return *this;
301  }
302  if (thisSize == 0) {
303  assert(otherSize > 0);
304  this->appendDerivativesToConstant(otherSize);
305  for (int i = 0; i < other.length_(); ++i)
306  data_[i] -= other.data_[i];
307  return *this;
308  }
309  throw std::logic_error(
310  "Cannot operate Evaluations with different number of derivatives "
311  "unless one of them has no derivatives"
312  );
313  }
314 
315  // subtract other's value from this values
316  template <class RhsValueType>
317  OPM_HOST_DEVICE Evaluation& operator-=(const RhsValueType& other)
318  {
319  // for constants, values are subtracted, derivatives stay the same
320  data_[valuepos_()] -= other;
321 
322  return *this;
323  }
324 
325  // multiply values and apply chain rule to derivatives: (u*v)' = (v'u + u'v)
326  OPM_HOST_DEVICE Evaluation& operator*=(const Evaluation& other)
327  {
328  const int thisSize = size();
329  const int otherSize = other.size();
330 
331  // Allow operation if sizes match or one is constant (size == 0)
332  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
333 
334  if (thisSize == otherSize) {
335  // while the values are multiplied, the derivatives follow the product rule,
336  // i.e., (u*v)' = (v'u + u'v).
337  const ValueType u = this->value();
338  const ValueType v = other.value();
339 
340  // value
341  data_[valuepos_()] *= v ;
342 
343  // derivatives
344  for (int i = dstart_(); i < dend_(); ++i)
345  data_[i] = data_[i] * v + other.data_[i] * u;
346 
347  return *this;
348  }
349 
350  if (otherSize == 0) {
351  *this *= other.value();
352  return *this;
353  }
354 
355  if (thisSize == 0) {
356  assert(otherSize > 0);
357  this->appendDerivativesToConstant(otherSize);
358  const ValueType u = this->value();
359  for (int i = 0; i < length_(); ++i) {
360  data_[i] = u * other.data_[i];
361  }
362  return *this;
363  }
364  throw std::logic_error(
365  "Cannot operate Evaluations with different number of derivatives "
366  "unless one of them has no derivatives"
367  );
368  }
369 
370  // m(c*u)' = c*u'
371  template <class RhsValueType>
372  OPM_HOST_DEVICE Evaluation& operator*=(const RhsValueType& other)
373  {
374  for (int i = 0; i < length_(); ++i)
375  data_[i] *= other;
376 
377  return *this;
378  }
379 
380  // m(u*v)' = (vu' - uv')/v^2
381  OPM_HOST_DEVICE Evaluation& operator/=(const Evaluation& other)
382  {
383  const int thisSize = size();
384  const int otherSize = other.size();
385 
386  // Allow operation if sizes match or one is constant (size == 0)
387  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
388 
389  if (thisSize == otherSize) {
390  // while the values are divided, the derivatives follow the rule for division,
391  // i.e., (u/v)' = (v'u - u'v)/v^2.
392  ValueType& u = data_[valuepos_()];
393  const ValueType& v = other.value();
394 
395  // derivatives
396  for (int idx = dstart_(); idx < dend_(); ++idx) {
397  const ValueType& uPrime = data_[idx];
398  const ValueType& vPrime = other.data_[idx];
399 
400  data_[idx] = (v*uPrime - u*vPrime)/(v*v);
401  }
402 
403  // value
404  u /= v;
405 
406  return *this;
407  }
408 
409  if (otherSize == 0) {
410  *this /= other.value();
411  return *this;
412  }
413 
414  if (thisSize == 0) {
415  assert(otherSize > 0);
416  // if *this is a constant, extend to hold derivatives before division
417  this->appendDerivativesToConstant(otherSize);
418 
419  // values are divided, derivatives follow the rule for division, i.e., (u/v)' = (v'u -
420  // u'v)/v^2.
421  ValueType& u = data_[valuepos_()];
422  const ValueType& v = other.value();
423  for (int idx = dstart_(); idx < dend_(); ++idx) {
424  const ValueType& vPrime = other.data_[idx];
425  data_[idx] = -u * vPrime / (v * v);
426  }
427  u /= v;
428 
429  return *this;
430  }
431  throw std::logic_error(
432  "Cannot operate Evaluations with different number of derivatives "
433  "unless one of them has no derivatives"
434  );
435  }
436 
437  // divide value and derivatives by value of other
438  template <class RhsValueType>
439  OPM_HOST_DEVICE Evaluation& operator/=(const RhsValueType& other)
440  {
441  const ValueType tmp = 1.0/other;
442 
443  for (int i = 0; i < length_(); ++i)
444  data_[i] *= tmp;
445 
446  return *this;
447  }
448 
449  // add two evaluation objects
450  OPM_HOST_DEVICE Evaluation operator+(const Evaluation& other) const
451  {
452 #ifndef NDEBUG
453  const int thisSize = size();
454  const int otherSize = other.size();
455 
456  // Allow operation if sizes match or one is constant (size == 0)
457  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
458 #endif
459 
460  Evaluation result(*this);
461 
462  result += other;
463 
464  return result;
465  }
466 
467  // add constant to this object
468  template <class RhsValueType>
469  OPM_HOST_DEVICE Evaluation operator+(const RhsValueType& other) const
470  {
471  Evaluation result(*this);
472 
473  result += other;
474 
475  return result;
476  }
477 
478  // subtract two evaluation objects
479  OPM_HOST_DEVICE Evaluation operator-(const Evaluation& other) const
480  {
481 #ifndef NDEBUG
482  const int thisSize = size();
483  const int otherSize = other.size();
484 
485  // Allow operation if sizes match or one is constant (size == 0)
486  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
487 #endif
488 
489  Evaluation result(*this);
490 
491  result -= other;
492 
493  return result;
494  }
495 
496  // subtract constant from evaluation object
497  template <class RhsValueType>
498  OPM_HOST_DEVICE Evaluation operator-(const RhsValueType& other) const
499  {
500  Evaluation result(*this);
501 
502  result -= other;
503 
504  return result;
505  }
506 
507  // negation (unary minus) operator
508  OPM_HOST_DEVICE Evaluation operator-() const
509  {
510  Evaluation result(*this);
511 
512  // set value and derivatives to negative
513  for (int i = 0; i < length_(); ++i)
514  result.data_[i] = - data_[i];
515 
516  return result;
517  }
518 
519  OPM_HOST_DEVICE Evaluation operator*(const Evaluation& other) const
520  {
521 #ifndef NDEBUG
522  const int thisSize = size();
523  const int otherSize = other.size();
524 
525  // Allow operation if sizes match or one is constant (size == 0)
526  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
527 #endif
528 
529  Evaluation result(*this);
530 
531  result *= other;
532 
533  return result;
534  }
535 
536  template <class RhsValueType>
537  OPM_HOST_DEVICE Evaluation operator*(const RhsValueType& other) const
538  {
539  Evaluation result(*this);
540 
541  result *= other;
542 
543  return result;
544  }
545 
546  OPM_HOST_DEVICE Evaluation operator/(const Evaluation& other) const
547  {
548 #ifndef NDEBUG
549  const int thisSize = size();
550  const int otherSize = other.size();
551 
552  // Allow operation if sizes match or one is constant (size == 0)
553  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
554 #endif
555 
556  Evaluation result(*this);
557 
558  result /= other;
559 
560  return result;
561  }
562 
563  template <class RhsValueType>
564  OPM_HOST_DEVICE Evaluation operator/(const RhsValueType& other) const
565  {
566  Evaluation result(*this);
567 
568  result /= other;
569 
570  return result;
571  }
572 
573  template <class RhsValueType>
574  OPM_HOST_DEVICE Evaluation& operator=(const RhsValueType& other)
575  {
576  setValue( other );
577  clearDerivatives();
578 
579  return *this;
580  }
581 
582  // copy assignment from evaluation
583  Evaluation& operator=(const Evaluation& other) = default;
584 
585  template <class RhsValueType>
586  OPM_HOST_DEVICE bool operator==(const RhsValueType& other) const
587  { return value() == other; }
588 
589  OPM_HOST_DEVICE bool operator==(const Evaluation& other) const
590  {
591  const int thisSize = size();
592  const int otherSize = other.size();
593 
594  // Allow operation if sizes match or one is constant (size == 0)
595  assert(thisSize == otherSize || thisSize == 0 || otherSize == 0);
596 
597  if (thisSize == otherSize) {
598  for (int idx = 0; idx < length_(); ++idx) {
599  if (data_[idx] != other.data_[idx]) {
600  return false;
601  }
602  }
603  } else {
604  return value() == other.value();
605  }
606  return true;
607  }
608 
609  OPM_HOST_DEVICE bool operator!=(const Evaluation& other) const
610  { return !operator==(other); }
611 
612  template <class RhsValueType>
613  OPM_HOST_DEVICE bool operator!=(const RhsValueType& other) const
614  { return !operator==(other); }
615 
616  template <class RhsValueType>
617  OPM_HOST_DEVICE bool operator>(RhsValueType other) const
618  { return value() > other; }
619 
620  OPM_HOST_DEVICE bool operator>(const Evaluation& other) const
621  {
622  assert(size() == other.size() || size() == 0 || other.size() == 0);
623 
624  return value() > other.value();
625  }
626 
627  template <class RhsValueType>
628  OPM_HOST_DEVICE bool operator<(RhsValueType other) const
629  { return value() < other; }
630 
631  OPM_HOST_DEVICE bool operator<(const Evaluation& other) const
632  {
633  assert(size() == other.size() || size() == 0 || other.size() == 0);
634 
635  return value() < other.value();
636  }
637 
638  template <class RhsValueType>
639  OPM_HOST_DEVICE bool operator>=(RhsValueType other) const
640  { return value() >= other; }
641 
642  OPM_HOST_DEVICE bool operator>=(const Evaluation& other) const
643  {
644  assert(size() == other.size() || size() == 0 || other.size() == 0);
645 
646  return value() >= other.value();
647  }
648 
649  template <class RhsValueType>
650  OPM_HOST_DEVICE bool operator<=(RhsValueType other) const
651  { return value() <= other; }
652 
653  OPM_HOST_DEVICE bool operator<=(const Evaluation& other) const
654  {
655  assert(size() == other.size() || size() == 0 || other.size() == 0);
656 
657  return value() <= other.value();
658  }
659 
660  // return value of variable
661  OPM_HOST_DEVICE const ValueType& value() const
662  { return data_[valuepos_()]; }
663 
664  // set value of variable
665  template <class RhsValueType>
666  OPM_HOST_DEVICE constexpr void setValue(const RhsValueType& val)
667  {
668  if (data_.size() == 0) {
669  data_.resize(1);
670  }
671  data_[valuepos_()] = val;
672  }
673 
674  // return varIdx'th derivative
675  OPM_HOST_DEVICE const ValueType& derivative(int varIdx) const
676  {
677  assert(size() == 0 || (0 <= varIdx && varIdx < size()) );
678 
679  if (size() == 0) {
680  static const ValueType zero {0.0};
681  return zero;
682  }
683 
684  return data_[dstart_() + varIdx];
685  }
686 
687  // set derivative at position varIdx
688  OPM_HOST_DEVICE void setDerivative(int varIdx, const ValueType& derVal, const int nVars = -1)
689  {
690  // if size() == 0, we need nVars to be positive to extend the number of derivatives
691  // if size() > 0, nVars must be either negative (i.e. ignore) or match size()
692  assert( (size() == 0 && nVars > 0) ||
693  ((size() > 0 && (nVars < 0 || nVars == size()))) );
694 
695  if (size() == 0) {
696  if (nVars < 0) {
697  throw std::logic_error("Cannot set derivative for a DynamicEvaluation initialized from a scalar "
698  "without specifying a positive number of derivatives");
699  }
700 
701  this->appendDerivativesToConstant(nVars);
702  }
703 
704  assert(0 <= varIdx && varIdx < size());
705 
706  data_[dstart_() + varIdx] = derVal;
707  }
708 
709  template<class Serializer>
710  OPM_HOST_DEVICE void serializeOp(Serializer& serializer)
711  {
712  serializer(data_);
713  }
714 
715 private:
716  FastSmallVector<ValueT, staticSize> data_;
717 
718  void appendDerivativesToConstant(size_t numDer) {
719  assert(size() == 0); // we only append derivatives to a constant
720  if (numDer > 0) {
721  data_.resize(1 + numDer);
722  }
723  }
724 };
725 
726 template <class Scalar, unsigned staticSize = 0>
727 using DynamicEvaluation = Evaluation<Scalar, DynamicSize, staticSize>;
728 
729 } // namespace DenseAd
730 
731 template <class Scalar, unsigned staticSize>
732 OPM_HOST_DEVICE DenseAd::Evaluation<Scalar, -1, staticSize> constant(int numDerivatives, const Scalar& value)
733 { return DenseAd::Evaluation<Scalar, -1, staticSize>::createConstant(numDerivatives, value); }
734 
735 template <class Scalar, unsigned staticSize>
736 OPM_HOST_DEVICE DenseAd::Evaluation<Scalar, -1, staticSize> variable(int numDerivatives, const Scalar& value, unsigned idx)
737 { return DenseAd::Evaluation<Scalar, -1, staticSize>::createVariable(numDerivatives, value, idx); }
738 
739 } // namespace Opm
740 
741 #endif // OPM_DENSEAD_EVALUATION_DYNAMIC_HPP
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: Evaluation.hpp:86
OPM_HOST_DEVICE Evaluation & operator=(Evaluation &&other)
move assignment
Definition: DynamicEvaluation.hpp:109
OPM_HOST_DEVICE int length_() const
length of internal data vector
Definition: DynamicEvaluation.hpp:70
OPM_HOST_DEVICE int dend_() const
end+1 index for derivatives
Definition: DynamicEvaluation.hpp:81
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: DynamicEvaluation.hpp:86
OPM_HOST_DEVICE int size() const
number of derivatives
Definition: DynamicEvaluation.hpp:65
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:94
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: Evaluation.hpp:83
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: Evaluation.hpp:104
OPM_HOST_DEVICE constexpr int length_() const
length of internal data vector
Definition: Evaluation.hpp:78
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
ValueT ValueType
field type
Definition: DynamicEvaluation.hpp:62
ValueT ValueType
field type
Definition: Evaluation.hpp:70
OPM_HOST_DEVICE constexpr int size() const
number of derivatives
Definition: Evaluation.hpp:73
static const int numVars
the template argument which specifies the number of derivatives (-1 == "DynamicSize" means runtime de...
Definition: Evaluation.hpp:67
OPM_HOST_DEVICE Evaluation()
default constructor
Definition: DynamicEvaluation.hpp:96
OPM_HOST_DEVICE constexpr int dstart_() const
start index for derivatives
Definition: DynamicEvaluation.hpp:78
OPM_HOST_DEVICE constexpr int valuepos_() const
position index for value
Definition: DynamicEvaluation.hpp:75
Some templates to wrap the valgrind client request macros.
Represents a function evaluation and its derivatives w.r.t.
Definition: Evaluation.hpp:62
An implementation of vector/array based on small object optimization.
OPM_HOST_DEVICE constexpr int dend_() const
end+1 index for derivatives
Definition: Evaluation.hpp:89
OPM_HOST_DEVICE Evaluation(Evaluation &&other)
move other function evaluation (this only makes sense for dynamically allocated Evaluations) ...
Definition: DynamicEvaluation.hpp:104