16 #include <deal.II/base/tensor.h> 17 #include <deal.II/base/point.h> 18 #include <deal.II/base/flow_function.h> 19 #include <deal.II/lac/vector.h> 24 DEAL_II_NAMESPACE_OPEN
54 const unsigned int n_points = points.size();
61 for (
unsigned int d=0; d<dim+1; ++d)
62 aux_values[d].resize(n_points);
63 vector_values(points, aux_values);
65 for (
unsigned int k=0; k<n_points; ++k)
68 for (
unsigned int d=0; d<dim+1; ++d)
69 values[k](d) = aux_values[d][k];
81 const unsigned int n_points = 1;
82 std::vector<Point<dim> > points(1);
89 for (
unsigned int d=0; d<dim+1; ++d)
90 aux_values[d].resize(n_points);
91 vector_values(points, aux_values);
93 for (
unsigned int d=0; d<dim+1; ++d)
94 value(d) = aux_values[d][0];
101 const unsigned int comp)
const 104 const unsigned int n_points = 1;
105 std::vector<Point<dim> > points(1);
112 for (
unsigned int d=0; d<dim+1; ++d)
113 aux_values[d].resize(n_points);
114 vector_values(points, aux_values);
116 return aux_values[comp][0];
125 const unsigned int n_points = points.size();
132 for (
unsigned int d=0; d<dim+1; ++d)
133 aux_gradients[d].resize(n_points);
134 vector_gradients(points, aux_gradients);
136 for (
unsigned int k=0; k<n_points; ++k)
139 for (
unsigned int d=0; d<dim+1; ++d)
140 values[k][d] = aux_gradients[d][k];
150 const unsigned int n_points = points.size();
157 for (
unsigned int d=0; d<dim+1; ++d)
158 aux_values[d].resize(n_points);
159 vector_laplacians(points, aux_values);
161 for (
unsigned int k=0; k<n_points; ++k)
164 for (
unsigned int d=0; d<dim+1; ++d)
165 values[k](d) = aux_values[d][k];
185 radius(r), Reynolds(Re)
195 std::vector<std::vector<double> > &values)
const 197 unsigned int n = points.size();
198 double stretch = 1./radius;
201 for (
unsigned int d=0; d<dim+1; ++d)
204 for (
unsigned int k=0; k<n; ++k)
212 for (
unsigned int d=1; d<dim; ++d)
213 r2 += p(d)*p(d)*stretch*stretch;
216 values[0][k] = 1.-r2;
218 for (
unsigned int d=1; d<dim; ++d)
221 values[dim][k] = -2*(dim-1)*stretch*stretch*p(0)/Reynolds + this->mean_pressure;
232 unsigned int n = points.size();
233 double stretch = 1./radius;
236 for (
unsigned int d=0; d<dim+1; ++d)
239 for (
unsigned int k=0; k<n; ++k)
243 values[0][k][0] = 0.;
244 for (
unsigned int d=1; d<dim; ++d)
245 values[0][k][d] = -2.*p(d)*stretch*stretch;
247 for (
unsigned int d=1; d<dim; ++d)
250 values[dim][k][0] = -2*(dim-1)*stretch*stretch/Reynolds;
251 for (
unsigned int d=1; d<dim; ++d)
252 values[dim][k][d] = 0.;
261 std::vector<std::vector<double> > &values)
const 263 unsigned int n = points.size();
266 for (
unsigned int d=0; d<dim+1; ++d)
269 for (
unsigned int d=0; d<values.size(); ++d)
270 for (
unsigned int k=0; k<values[d].size(); ++k)
279 viscosity(nu), reaction(r)
296 std::vector<std::vector<double> > &values)
const 298 unsigned int n = points.size();
301 for (
unsigned int d=0; d<dim+1; ++d)
304 for (
unsigned int k=0; k<n; ++k)
309 const double cx = cos(x);
310 const double cy = cos(y);
311 const double sx = sin(x);
312 const double sy = sin(y);
316 values[0][k] = cx*cx*cy*sy;
317 values[1][k] = -cx*sx*cy*cy;
318 values[2][k] = cx*sx*cy*sy + this->mean_pressure;
323 const double cz = cos(z);
324 const double sz = sin(z);
326 values[0][k] = cx*cx*cy*sy*cz*sz;
327 values[1][k] = cx*sx*cy*cy*cz*sz;
328 values[2][k] = -2.*cx*sx*cy*sy*cz*cz;
329 values[3][k] = cx*sx*cy*sy*cz*sz + this->mean_pressure;
345 unsigned int n = points.size();
348 for (
unsigned int d=0; d<dim+1; ++d)
351 for (
unsigned int k=0; k<n; ++k)
356 const double c2x = cos(2*x);
357 const double c2y = cos(2*y);
358 const double s2x = sin(2*x);
359 const double s2y = sin(2*y);
360 const double cx2 = .5+.5*c2x;
361 const double cy2 = .5+.5*c2y;
375 const double c2z = cos(2*z);
376 const double s2z = sin(2*z);
377 const double cz2 = .5+.5*c2z;
407 std::vector<std::vector<double> > &values)
const 409 unsigned int n = points.size();
412 for (
unsigned int d=0; d<dim+1; ++d)
417 vector_values(points, values);
418 for (
unsigned int d=0; d<dim; ++d)
419 for (
unsigned int k=0; k<values[d].size(); ++k)
420 values[d][k] *= -reaction;
424 for (
unsigned int d=0; d<dim; ++d)
425 for (
unsigned int k=0; k<values[d].size(); ++k)
430 for (
unsigned int k=0; k<n; ++k)
435 const double c2x = cos(2*x);
436 const double c2y = cos(2*y);
437 const double s2x = sin(2*x);
438 const double s2y = sin(2*y);
443 values[0][k] += - viscosity*pi2 * (1.+2.*c2x) * s2y -
numbers::PI/4. * c2x*s2y;
444 values[1][k] += viscosity*pi2 * s2x * (1.+2.*c2y) -
numbers::PI/4. * s2x*c2y;
450 const double c2z = cos(2*z);
451 const double s2z = sin(2*z);
453 values[0][k] += - .5*viscosity*pi2 * (1.+2.*c2x) * s2y * s2z -
numbers::PI/8. * c2x * s2y * s2z;
454 values[1][k] += .5*viscosity*pi2 * s2x * (1.+2.*c2y) * s2z -
numbers::PI/8. * s2x * c2y * s2z;
455 values[2][k] += - .5*viscosity*pi2 * s2x * s2y * (1.+2.*c2z) -
numbers::PI/8. * s2x * s2y * c2z;
473 coslo (cos(lambda *omega)),
484 - cos(
lp*phi) + cos(
lm*phi);
492 return coslo * (cos(
lp*phi) - cos(
lm*phi))
524 void StokesLSingularity::vector_values (
525 const std::vector<
Point<2> > &points,
526 std::vector<std::vector<double> > &values)
const 528 unsigned int n = points.size();
531 for (
unsigned int d=0; d<2+1; ++d)
534 for (
unsigned int k=0; k<n; ++k)
537 const double x = p(0);
538 const double y = p(1);
543 const double r2 = x*x+y*y;
544 const double rl = pow(r2,
lambda/2.);
545 const double rl1 = pow(r2,
lambda/2.-.5);
546 values[0][k] = rl * (
lp*sin(phi)*
Psi(phi) + cos(phi)*
Psi_1(phi));
547 values[1][k] = rl * (
lp*cos(phi)*
Psi(phi) - sin(phi)*
Psi_1(phi));
552 for (
unsigned int d=0; d<3; ++d)
560 void StokesLSingularity::vector_gradients (
561 const std::vector<
Point<2> > &points,
562 std::vector<std::vector<
Tensor<1,2> > > &values)
const 564 unsigned int n = points.size();
567 for (
unsigned int d=0;
d<2+1; ++
d)
570 for (
unsigned int k=0; k<n; ++k)
573 const double x = p(0);
574 const double y = p(1);
579 const double r2 = x*x+y*y;
580 const double r = sqrt(r2);
581 const double rl = pow(r2,
lambda/2.);
582 const double rl1 = pow(r2,
lambda/2.-.5);
583 const double rl2 = pow(r2,
lambda/2.-1.);
584 const double psi =
Psi(phi);
585 const double psi1=
Psi_1(phi);
586 const double psi2=
Psi_2(phi);
587 const double cosp= cos(phi);
588 const double sinp= sin(phi);
591 const double udr =
lambda * rl1 * (
lp*sinp*psi + cosp*psi1);
592 const double udp = rl * (
lp*cosp*psi +
lp*sinp*psi1 - sinp*psi1 + cosp*psi2);
594 const double vdr =
lambda * rl1 * (
lp*cosp*psi - sinp*psi1);
595 const double vdp = rl * (
lp*(cosp*psi1 - sinp*psi) - cosp*psi1 - sinp*psi2);
598 const double pdp = -rl1 * (
lp*
lp*psi2+
Psi_4(phi)) /
lm;
599 values[0][k][0] = cosp*udr - sinp/r*udp;
600 values[0][k][1] = - sinp*udr - cosp/r*udp;
601 values[1][k][0] = cosp*vdr - sinp/r*vdp;
602 values[1][k][1] = - sinp*vdr - cosp/r*vdp;
603 values[2][k][0] = cosp*pdr - sinp/r*pdp;
604 values[2][k][1] = - sinp*pdr - cosp/r*pdp;
608 for (
unsigned int d=0;
d<3; ++
d)
616 void StokesLSingularity::vector_laplacians (
617 const std::vector<
Point<2> > &points,
618 std::vector<std::vector<double> > &values)
const 620 unsigned int n = points.size();
623 for (
unsigned int d=0;
d<2+1; ++
d)
626 for (
unsigned int d=0;
d<values.size(); ++
d)
627 for (
unsigned int k=0; k<values[
d].size(); ++k)
639 long double r2 = Reynolds/2.;
641 long double l = -b/(r2+std::sqrt(r2*r2+b));
646 p_average = 1/(8*l)*(std::exp(3.*l)-std::exp(-l));
651 void Kovasznay::vector_values (
652 const std::vector<
Point<2> > &points,
653 std::vector<std::vector<double> > &values)
const 655 unsigned int n = points.size();
658 for (
unsigned int d=0; d<2+1; ++d)
661 for (
unsigned int k=0; k<n; ++k)
664 const double x = p(0);
666 const double elx = std::exp(lbda*x);
668 values[0][k] = 1. - elx * cos(y);
669 values[1][k] = .5 /
numbers::PI * lbda * elx * sin(y);
670 values[2][k] = -.5 * elx * elx + p_average + this->
mean_pressure;
675 void Kovasznay::vector_gradients (
676 const std::vector<
Point<2> > &points,
677 std::vector<std::vector<
Tensor<1,2> > > &gradients)
const 679 unsigned int n = points.size();
682 Assert (gradients[0].size() == n,
685 for (
unsigned int i=0; i<n; ++i)
687 const double x = points[i](0);
688 const double y = points[i](1);
690 const double elx = std::exp(lbda*x);
695 gradients[0][i][0] = -lbda*elx*cy;
697 gradients[1][i][0] = lbda*lbda/(2*
numbers::PI)*elx*sy;
698 gradients[1][i][1] =lbda*elx*cy;
700 gradients[2][i][0] = -lbda*elx*elx;
701 gradients[2][i][1] = 0.;
707 void Kovasznay::vector_laplacians (
708 const std::vector<
Point<2> > &points,
709 std::vector<std::vector<double> > &values)
const 711 unsigned int n = points.size();
713 for (
unsigned int d=0;
d<2+1; ++
d)
719 for (
unsigned int k=0; k<n; ++k)
722 const double x = p(0);
723 const double y = zp * p(1);
724 const double elx = std::exp(lbda*x);
725 const double u = 1. - elx * cos(y);
726 const double ux = -lbda * elx * cos(y);
727 const double uy = elx * zp * sin(y);
728 const double v = lbda/zp * elx * sin(y);
729 const double vx = lbda*lbda/zp * elx * sin(y);
730 const double vy = zp*lbda/zp * elx * cos(y);
732 values[0][k] = u*ux+v*uy;
733 values[1][k] = u*vx+v*vy;
739 for (
unsigned int d=0;
d<values.size(); ++
d)
740 for (
unsigned int k=0; k<values[
d].size(); ++k)
763 DEAL_II_NAMESPACE_CLOSE
const double lm
Auxiliary variable 1-lambda.
const double lp
Auxiliary variable 1+lambda.
virtual void vector_values(const std::vector< Point< dim > > &points, std::vector< std::vector< double > > &values) const
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)
virtual void vector_gradients(const std::vector< Point< dim > > &points, std::vector< std::vector< Tensor< 1, dim > > > &gradients) const
virtual void vector_gradients(const std::vector< Point< dim > > &points, std::vector< std::vector< Tensor< 1, dim > > > &gradients) const
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
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual void vector_laplacians(const std::vector< Point< dim > > &points, std::vector< std::vector< double > > &values) const
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()
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_laplacians(const std::vector< Point< dim > > &points, std::vector< std::vector< double > > &values) const
Kovasznay(const double Re, bool Stokes=false)
double Psi_2(double phi) const
The 2nd derivative of Psi()