mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-07 23:13:01 -06:00
Added functionAverage() method to DGBasis classes.
This commit is contained in:
parent
763d14ce4d
commit
1093e09d65
@ -154,6 +154,12 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
/// Compute the average of the function f = sum_i c_i b_i.
|
||||
/// \param[in] coefficients Coefficients {c_i} for a single cell.
|
||||
double DGBasisBoundedTotalDegree::functionAverage(const double* coefficients) const
|
||||
{
|
||||
return coefficients[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -300,11 +306,18 @@ namespace Opm
|
||||
double* coefficients) const
|
||||
{
|
||||
const int nb = numBasisFunc();
|
||||
const double average = std::accumulate(coefficients, coefficients + nb, 0.0)/double(nb);
|
||||
const double aver = functionAverage(coefficients);
|
||||
for (int ix = 0; ix < nb; ++ix) {
|
||||
coefficients[ix] = factor*(coefficients[ix] - average) + average;
|
||||
coefficients[ix] = factor*(coefficients[ix] - aver) + aver;
|
||||
}
|
||||
}
|
||||
|
||||
/// Compute the average of the function f = sum_i c_i b_i.
|
||||
/// \param[in] coefficients Coefficients {c_i} for a single cell.
|
||||
double DGBasisMultilin::functionAverage(const double* coefficients) const
|
||||
{
|
||||
const int nb = numBasisFunc();
|
||||
return std::accumulate(coefficients, coefficients + nb, 0.0)/double(nb);
|
||||
}
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -75,6 +75,10 @@ namespace Opm
|
||||
/// \param[out] coefficients Coefficients {c_i} for a single cell.
|
||||
virtual void multiplyGradient(const double factor,
|
||||
double* coefficients) const = 0;
|
||||
|
||||
/// Compute the average of the function f = sum_i c_i b_i.
|
||||
/// \param[in] coefficients Coefficients {c_i} for a single cell.
|
||||
virtual double functionAverage(const double* coefficients) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -144,6 +148,10 @@ namespace Opm
|
||||
virtual void multiplyGradient(const double factor,
|
||||
double* coefficients) const;
|
||||
|
||||
/// Compute the average of the function f = sum_i c_i b_i.
|
||||
/// \param[in] coefficients Coefficients {c_i} for a single cell.
|
||||
virtual double functionAverage(const double* coefficients) const;
|
||||
|
||||
private:
|
||||
const UnstructuredGrid& grid_;
|
||||
const int degree_;
|
||||
@ -217,6 +225,10 @@ namespace Opm
|
||||
virtual void multiplyGradient(const double factor,
|
||||
double* coefficients) const;
|
||||
|
||||
/// Compute the average of the function f = sum_i c_i b_i.
|
||||
/// \param[in] coefficients Coefficients {c_i} for a single cell.
|
||||
virtual double functionAverage(const double* coefficients) const;
|
||||
|
||||
private:
|
||||
const UnstructuredGrid& grid_;
|
||||
const int degree_;
|
||||
|
Loading…
Reference in New Issue
Block a user