template <int dim>
PoisseuilleFlow<dim>::PoisseuilleFlow(const double r, const double Re)
- : radius(r)
+ : inv_sqr_radius(1 / r / r)
, Reynolds(Re)
{
Assert(Reynolds != 0., ExcMessage("Reynolds number cannot be zero"));
const std::vector<Point<dim>> & points,
std::vector<std::vector<double>> &values) const
{
- unsigned int n = points.size();
- double stretch = 1. / radius;
+ const unsigned int n = points.size();
Assert(values.size() == dim + 1,
ExcDimensionMismatch(values.size(), dim + 1));
for (unsigned int k = 0; k < n; ++k)
{
const Point<dim> &p = points[k];
- // First, compute the
- // square of the distance to
- // the x-axis divided by the
- // radius.
+ // First, compute the square of the distance to the x-axis divided by
+ // the radius.
double r2 = 0;
for (unsigned int d = 1; d < dim; ++d)
- r2 += p(d) * p(d) * stretch * stretch;
+ r2 += p(d) * p(d);
+ r2 *= inv_sqr_radius;
// x-velocity
values[0][k] = 1. - r2;
for (unsigned int d = 1; d < dim; ++d)
values[d][k] = 0.;
// pressure
- values[dim][k] = -2 * (dim - 1) * stretch * stretch * p(0) / Reynolds +
+ values[dim][k] = -2 * (dim - 1) * inv_sqr_radius * p(0) / Reynolds +
this->mean_pressure;
}
}
const std::vector<Point<dim>> & points,
std::vector<std::vector<Tensor<1, dim>>> &values) const
{
- unsigned int n = points.size();
- double stretch = 1. / radius;
+ const unsigned int n = points.size();
Assert(values.size() == dim + 1,
ExcDimensionMismatch(values.size(), dim + 1));
// x-velocity
values[0][k][0] = 0.;
for (unsigned int d = 1; d < dim; ++d)
- values[0][k][d] = -2. * p(d) * stretch * stretch;
+ values[0][k][d] = -2. * p(d) * inv_sqr_radius;
// other velocities
for (unsigned int d = 1; d < dim; ++d)
values[d][k] = 0.;
// pressure
- values[dim][k][0] = -2 * (dim - 1) * stretch * stretch / Reynolds;
+ values[dim][k][0] = -2 * (dim - 1) * inv_sqr_radius / Reynolds;
for (unsigned int d = 1; d < dim; ++d)
values[dim][k][d] = 0.;
}
const std::vector<Point<dim>> & points,
std::vector<std::vector<double>> &values) const
{
- unsigned int n = points.size();
+ const unsigned int n = points.size();
(void)n;
Assert(values.size() == dim + 1,
ExcDimensionMismatch(values.size(), dim + 1));