Added functionAverage() method to DGBasis classes.
This commit is contained in:
parent
1113e65eec
commit
de66f358b0
@ -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
|
double* coefficients) const
|
||||||
{
|
{
|
||||||
const int nb = numBasisFunc();
|
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) {
|
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
|
} // namespace Opm
|
||||||
|
@ -75,6 +75,10 @@ namespace Opm
|
|||||||
/// \param[out] coefficients Coefficients {c_i} for a single cell.
|
/// \param[out] coefficients Coefficients {c_i} for a single cell.
|
||||||
virtual void multiplyGradient(const double factor,
|
virtual void multiplyGradient(const double factor,
|
||||||
double* coefficients) const = 0;
|
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,
|
virtual void multiplyGradient(const double factor,
|
||||||
double* coefficients) const;
|
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:
|
private:
|
||||||
const UnstructuredGrid& grid_;
|
const UnstructuredGrid& grid_;
|
||||||
const int degree_;
|
const int degree_;
|
||||||
@ -217,6 +225,10 @@ namespace Opm
|
|||||||
virtual void multiplyGradient(const double factor,
|
virtual void multiplyGradient(const double factor,
|
||||||
double* coefficients) const;
|
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:
|
private:
|
||||||
const UnstructuredGrid& grid_;
|
const UnstructuredGrid& grid_;
|
||||||
const int degree_;
|
const int degree_;
|
||||||
|
Loading…
Reference in New Issue
Block a user