16 #include <deal.II/base/flow_function.h> 17 #include <deal.II/base/point.h> 18 #include <deal.II/base/tensor.h> 20 #include <deal.II/lac/vector.h> 25 DEAL_II_NAMESPACE_OPEN
35 , aux_gradients(dim + 1)
54 const unsigned int n_points = points.size();
55 Assert(values.size() == n_points,
60 std::lock_guard<std::mutex> lock(mutex);
62 for (
unsigned int d = 0; d < dim + 1; ++d)
63 aux_values[d].resize(n_points);
64 vector_values(points, aux_values);
66 for (
unsigned int k = 0; k < n_points; ++k)
68 Assert(values[k].size() == dim + 1,
70 for (
unsigned int d = 0; d < dim + 1; ++d)
71 values[k](d) = aux_values[d][k];
84 const unsigned int n_points = 1;
85 std::vector<Point<dim>> points(1);
90 std::lock_guard<std::mutex> lock(mutex);
92 for (
unsigned int d = 0; d < dim + 1; ++d)
93 aux_values[d].resize(n_points);
94 vector_values(points, aux_values);
96 for (
unsigned int d = 0; d < dim + 1; ++d)
97 value(d) = aux_values[d][0];
104 const unsigned int comp)
const 107 const unsigned int n_points = 1;
108 std::vector<Point<dim>> points(1);
113 std::lock_guard<std::mutex> lock(mutex);
115 for (
unsigned int d = 0; d < dim + 1; ++d)
116 aux_values[d].resize(n_points);
117 vector_values(points, aux_values);
119 return aux_values[comp][0];
129 const unsigned int n_points = points.size();
130 Assert(values.size() == n_points,
135 std::lock_guard<std::mutex> lock(mutex);
137 for (
unsigned int d = 0; d < dim + 1; ++d)
138 aux_gradients[d].resize(n_points);
139 vector_gradients(points, aux_gradients);
141 for (
unsigned int k = 0; k < n_points; ++k)
143 Assert(values[k].size() == dim + 1,
145 for (
unsigned int d = 0; d < dim + 1; ++d)
146 values[k][d] = aux_gradients[d][k];
157 const unsigned int n_points = points.size();
158 Assert(values.size() == n_points,
163 std::lock_guard<std::mutex> lock(mutex);
165 for (
unsigned int d = 0; d < dim + 1; ++d)
166 aux_values[d].resize(n_points);
167 vector_laplacians(points, aux_values);
169 for (
unsigned int k = 0; k < n_points; ++k)
171 Assert(values[k].size() == dim + 1,
173 for (
unsigned int d = 0; d < dim + 1; ++d)
174 values[k](d) = aux_values[d][k];
204 std::vector<std::vector<double>> &values)
const 206 unsigned int n = points.size();
207 double stretch = 1. / radius;
209 Assert(values.size() == dim + 1,
211 for (
unsigned int d = 0; d < dim + 1; ++d)
214 for (
unsigned int k = 0; k < n; ++k)
222 for (
unsigned int d = 1; d < dim; ++d)
223 r2 += p(d) * p(d) * stretch * stretch;
226 values[0][k] = 1. - r2;
228 for (
unsigned int d = 1; d < dim; ++d)
231 values[dim][k] = -2 * (dim - 1) * stretch * stretch * p(0) / Reynolds +
244 unsigned int n = points.size();
245 double stretch = 1. / radius;
247 Assert(values.size() == dim + 1,
249 for (
unsigned int d = 0; d < dim + 1; ++d)
252 for (
unsigned int k = 0; k < n; ++k)
256 values[0][k][0] = 0.;
257 for (
unsigned int d = 1; d < dim; ++d)
258 values[0][k][d] = -2. * p(d) * stretch * stretch;
260 for (
unsigned int d = 1; d < dim; ++d)
263 values[dim][k][0] = -2 * (dim - 1) * stretch * stretch / Reynolds;
264 for (
unsigned int d = 1; d < dim; ++d)
265 values[dim][k][d] = 0.;
275 std::vector<std::vector<double>> &values)
const 277 unsigned int n = points.size();
279 Assert(values.size() == dim + 1,
281 for (
unsigned int d = 0; d < dim + 1; ++d)
284 for (
auto &point_values : values)
285 std::fill(point_values.begin(), point_values.end(), 0.);
311 std::vector<std::vector<double>> &values)
const 313 unsigned int n = points.size();
315 Assert(values.size() == dim + 1,
317 for (
unsigned int d = 0; d < dim + 1; ++d)
320 for (
unsigned int k = 0; k < n; ++k)
325 const double cx = std::cos(x);
326 const double cy = std::cos(y);
327 const double sx = std::sin(x);
328 const double sy = std::sin(y);
332 values[0][k] = cx * cx * cy * sy;
333 values[1][k] = -cx * sx * cy * cy;
334 values[2][k] = cx * sx * cy * sy + this->mean_pressure;
339 const double cz = std::cos(z);
340 const double sz = std::sin(z);
342 values[0][k] = cx * cx * cy * sy * cz * sz;
343 values[1][k] = cx * sx * cy * cy * cz * sz;
344 values[2][k] = -2. * cx * sx * cy * sy * cz * cz;
345 values[3][k] = cx * sx * cy * sy * cz * sz + this->mean_pressure;
362 unsigned int n = points.size();
364 Assert(values.size() == dim + 1,
366 for (
unsigned int d = 0; d < dim + 1; ++d)
369 for (
unsigned int k = 0; k < n; ++k)
374 const double c2x = std::cos(2 * x);
375 const double c2y = std::cos(2 * y);
376 const double s2x = std::sin(2 * x);
377 const double s2y = std::sin(2 * y);
378 const double cx2 = .5 + .5 * c2x;
379 const double cy2 = .5 + .5 * c2y;
393 const double c2z = std::cos(2 * z);
394 const double s2z = std::sin(2 * z);
395 const double cz2 = .5 + .5 * c2z;
397 values[0][k][0] = -.125 *
numbers::PI * s2x * s2y * s2z;
398 values[0][k][1] = .25 *
numbers::PI * cx2 * c2y * s2z;
399 values[0][k][2] = .25 *
numbers::PI * cx2 * s2y * c2z;
401 values[1][k][0] = .25 *
numbers::PI * c2x * cy2 * s2z;
402 values[1][k][1] = -.125 *
numbers::PI * s2x * s2y * s2z;
403 values[1][k][2] = .25 *
numbers::PI * s2x * cy2 * c2z;
405 values[2][k][0] = -.5 *
numbers::PI * c2x * s2y * cz2;
406 values[2][k][1] = -.5 *
numbers::PI * s2x * c2y * cz2;
407 values[2][k][2] = .25 *
numbers::PI * s2x * s2y * s2z;
409 values[3][k][0] = .125 *
numbers::PI * c2x * s2y * s2z;
410 values[3][k][1] = .125 *
numbers::PI * s2x * c2y * s2z;
411 values[3][k][2] = .125 *
numbers::PI * s2x * s2y * c2z;
426 std::vector<std::vector<double>> &values)
const 428 unsigned int n = points.size();
430 Assert(values.size() == dim + 1,
432 for (
unsigned int d = 0; d < dim + 1; ++d)
437 vector_values(points, values);
438 for (
unsigned int d = 0; d < dim; ++d)
439 for (
double &point_value : values[d])
440 point_value *= -reaction;
444 for (
unsigned int d = 0; d < dim; ++d)
445 std::fill(values[d].begin(), values[d].end(), 0.);
449 for (
unsigned int k = 0; k < n; ++k)
454 const double c2x = std::cos(2 * x);
455 const double c2y = std::cos(2 * y);
456 const double s2x = std::sin(2 * x);
457 const double s2y = std::sin(2 * y);
462 values[0][k] += -viscosity * pi2 * (1. + 2. * c2x) * s2y -
464 values[1][k] += viscosity * pi2 * s2x * (1. + 2. * c2y) -
471 const double c2z = std::cos(2 * z);
472 const double s2z = std::sin(2 * z);
475 -.5 * viscosity * pi2 * (1. + 2. * c2x) * s2y * s2z -
477 values[1][k] += .5 * viscosity * pi2 * s2x * (1. + 2. * c2y) * s2z -
480 -.5 * viscosity * pi2 * s2x * s2y * (1. + 2. * c2z) -
498 , coslo(
std::cos(lambda * omega))
507 return coslo * (std::sin(
lp * phi) /
lp - std::sin(
lm * phi) /
lm) -
508 std::cos(
lp * phi) + std::cos(
lm * phi);
515 return coslo * (std::cos(
lp * phi) - std::cos(
lm * phi)) +
516 lp * std::sin(
lp * phi) -
lm * std::sin(
lm * phi);
523 return coslo * (
lm * std::sin(
lm * phi) -
lp * std::sin(
lp * phi)) +
524 lp *
lp * std::cos(
lp * phi) -
lm *
lm * std::cos(
lm * phi);
532 (
lm *
lm * std::cos(
lm * phi) -
lp *
lp * std::cos(
lp * phi)) +
542 lm *
lm *
lm * std::sin(
lm * phi)) +
549 StokesLSingularity::vector_values(
550 const std::vector<
Point<2>> & points,
551 std::vector<std::vector<double>> &values)
const 553 unsigned int n = points.size();
556 for (
unsigned int d = 0; d < 2 + 1; ++d)
559 for (
unsigned int k = 0; k < n; ++k)
562 const double x = p(0);
563 const double y = p(1);
565 if ((x < 0) || (y < 0))
567 const double phi = std::atan2(y, -x) +
numbers::PI;
568 const double r2 = x * x + y * y;
569 const double rl = std::pow(r2,
lambda / 2.);
570 const double rl1 = std::pow(r2,
lambda / 2. - .5);
572 rl * (
lp * std::sin(phi) *
Psi(phi) + std::cos(phi) *
Psi_1(phi));
574 rl * (
lp * std::cos(phi) *
Psi(phi) - std::sin(phi) *
Psi_1(phi));
580 for (
unsigned int d = 0; d < 3; ++d)
589 StokesLSingularity::vector_gradients(
590 const std::vector<
Point<2>> & points,
593 unsigned int n = points.size();
596 for (
unsigned int d = 0;
d < 2 + 1; ++
d)
599 for (
unsigned int k = 0; k < n; ++k)
602 const double x = p(0);
603 const double y = p(1);
605 if ((x < 0) || (y < 0))
607 const double phi = std::atan2(y, -x) +
numbers::PI;
608 const double r2 = x * x + y * y;
609 const double r = std::sqrt(r2);
610 const double rl = std::pow(r2,
lambda / 2.);
611 const double rl1 = std::pow(r2,
lambda / 2. - .5);
612 const double rl2 = std::pow(r2,
lambda / 2. - 1.);
613 const double psi =
Psi(phi);
614 const double psi1 =
Psi_1(phi);
615 const double psi2 =
Psi_2(phi);
616 const double cosp = std::cos(phi);
617 const double sinp = std::sin(phi);
620 const double udr =
lambda * rl1 * (
lp * sinp * psi + cosp * psi1);
621 const double udp = rl * (
lp * cosp * psi +
lp * sinp * psi1 -
622 sinp * psi1 + cosp * psi2);
624 const double vdr =
lambda * rl1 * (
lp * cosp * psi - sinp * psi1);
625 const double vdp = rl * (
lp * (cosp * psi1 - sinp * psi) -
626 cosp * psi1 - sinp * psi2);
630 const double pdp = -rl1 * (
lp *
lp * psi2 +
Psi_4(phi)) /
lm;
631 values[0][k][0] = cosp * udr - sinp / r * udp;
632 values[0][k][1] = -sinp * udr - cosp / r * udp;
633 values[1][k][0] = cosp * vdr - sinp / r * vdp;
634 values[1][k][1] = -sinp * vdr - cosp / r * vdp;
635 values[2][k][0] = cosp * pdr - sinp / r * pdp;
636 values[2][k][1] = -sinp * pdr - cosp / r * pdp;
640 for (
unsigned int d = 0;
d < 3; ++
d)
649 StokesLSingularity::vector_laplacians(
650 const std::vector<
Point<2>> & points,
651 std::vector<std::vector<double>> &values)
const 653 unsigned int n = points.size();
656 for (
unsigned int d = 0;
d < 2 + 1; ++
d)
659 for (
auto &point_values : values)
660 std::fill(point_values.begin(), point_values.end(), 0.);
670 long double r2 = Reynolds / 2.;
672 long double l = -b / (r2 + std::sqrt(r2 * r2 + b));
677 p_average = 1 / (8 * l) * (std::exp(3. * l) - std::exp(-l));
683 Kovasznay::vector_values(
const std::vector<
Point<2>> & points,
684 std::vector<std::vector<double>> &values)
const 686 unsigned int n = points.size();
689 for (
unsigned int d = 0; d < 2 + 1; ++d)
692 for (
unsigned int k = 0; k < n; ++k)
695 const double x = p(0);
697 const double elx = std::exp(lbda * x);
699 values[0][k] = 1. - elx * std::cos(y);
700 values[1][k] = .5 /
numbers::PI * lbda * elx * std::sin(y);
701 values[2][k] = -.5 * elx * elx + p_average + this->
mean_pressure;
707 Kovasznay::vector_gradients(
708 const std::vector<
Point<2>> & points,
709 std::vector<std::vector<
Tensor<1, 2>>> &gradients)
const 711 unsigned int n = points.size();
714 Assert(gradients[0].size() == n,
717 for (
unsigned int i = 0; i < n; ++i)
719 const double x = points[i](0);
720 const double y = points[i](1);
722 const double elx = std::exp(lbda * x);
727 gradients[0][i][0] = -lbda * elx * cy;
729 gradients[1][i][0] = lbda * lbda / (2 *
numbers::PI) * elx * sy;
730 gradients[1][i][1] = lbda * elx * cy;
732 gradients[2][i][0] = -lbda * elx * elx;
733 gradients[2][i][1] = 0.;
740 Kovasznay::vector_laplacians(
const std::vector<
Point<2>> & points,
741 std::vector<std::vector<double>> &values)
const 743 unsigned int n = points.size();
745 for (
unsigned int d = 0;
d < 2 + 1; ++
d)
751 for (
unsigned int k = 0; k < n; ++k)
754 const double x = p(0);
755 const double y = zp * p(1);
756 const double elx = std::exp(lbda * x);
757 const double u = 1. - elx * std::cos(y);
758 const double ux = -lbda * elx * std::cos(y);
759 const double uy = elx * zp * std::sin(y);
760 const double v = lbda / zp * elx * std::sin(y);
761 const double vx = lbda * lbda / zp * elx * std::sin(y);
762 const double vy = zp * lbda / zp * elx * std::cos(y);
764 values[0][k] = u * ux + v * uy;
765 values[1][k] = u * vx + v * vy;
771 for (
auto &point_values : values)
772 std::fill(point_values.begin(), point_values.end(), 0.);
794 DEAL_II_NAMESPACE_CLOSE
virtual void vector_laplacians(const std::vector< Point< dim >> &points, std::vector< std::vector< double >> &values) const override
const double lm
Auxiliary variable 1-lambda.
virtual void vector_laplacians(const std::vector< Point< dim >> &points, std::vector< std::vector< double >> &values) const override
virtual void vector_gradients(const std::vector< Point< dim >> &points, std::vector< std::vector< Tensor< 1, dim >>> &gradients) const override
const double lp
Auxiliary variable 1+lambda.
static const double lambda
StokesCosine(const double viscosity=1., const double reaction=0.)
void set_parameters(const double viscosity, const double reaction)
double Psi(double phi) const
The auxiliary function Psi.
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
double lambda() const
The value of lambda.
static ::ExceptionBase & ExcMessage(std::string arg1)
virtual void vector_values(const std::vector< Point< dim >> &points, std::vector< std::vector< double >> &values) const override
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual void vector_values(const std::vector< Point< dim >> &points, std::vector< std::vector< double >> &values) const override
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
double Psi_1(double phi) const
The derivative of Psi()
static constexpr double PI
const double coslo
Cosine of lambda times omega.
double Psi_4(double phi) const
The 4th derivative of Psi()
double Psi_3(double phi) const
The 3rd derivative of Psi()
StokesLSingularity()
Constructor setting up some data.
static ::ExceptionBase & ExcNotImplemented()
virtual void vector_gradients(const std::vector< Point< dim >> &points, std::vector< std::vector< Tensor< 1, dim >>> &gradients) const override
Kovasznay(const double Re, bool Stokes=false)
double Psi_2(double phi) const
The 2nd derivative of Psi()