From 5ac24f9b8daaa0f41146a51fd5eeb0cea496a788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 15 Jan 2013 13:44:18 +0100 Subject: [PATCH] Added addConstant() and multiplyGradient() methods. So far only to class DGBasisBoundedTotalDegree. --- .../TransportModelTracerTofDiscGal.cpp | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/opm/core/transport/reorder/TransportModelTracerTofDiscGal.cpp b/opm/core/transport/reorder/TransportModelTracerTofDiscGal.cpp index 19a64cb3a..44585673f 100644 --- a/opm/core/transport/reorder/TransportModelTracerTofDiscGal.cpp +++ b/opm/core/transport/reorder/TransportModelTracerTofDiscGal.cpp @@ -108,6 +108,42 @@ namespace Opm } } } + + /// Modify basis coefficients to add to the function value. + /// A function f = sum_i c_i b_i is assumed, and we change + /// it to (f + increment) by modifying the c_i. This is done without + /// modifying its gradient. + /// \param[in] increment Add this value to the function. + /// \param[in] dim Number of space dimensions. + /// \param[in] degree Polynomial degree of basis. + /// \param[out] coefficients Coefficients {c_i} for a single cell. + static void addConstant(const double increment, + const int /*dim*/, + const int /*degree*/, + double* coefficients) + { + coefficients[0] += increment; + } + + /// Modify basis coefficients to change the function's slope. + /// A function f = sum_i c_i b_i is assumed, and we change + /// it to a function g with the property that grad g = factor * grad f + /// by modifying the c_i. This is done without modifying the average, + /// i.e. the integrals of g and f over the cell are the same. + /// \param[in] factor Multiply gradient by this factor. + /// \param[in] dim Number of space dimensions. + /// \param[in] degree Polynomial degree of basis. + /// \param[out] coefficients Coefficients {c_i} for a single cell. + static void multiplyGradient(const double factor, + const int dim, + const int degree, + double* coefficients) + { + const int nb = numBasisFunc(dim, degree); + for (int ix = 1; ix < nb; ++ix) { + coefficients[ix] *= factor; + } + } };