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
58 const unsigned int n_points = points.size();
65 for (
unsigned int d=0; d<dim+1; ++d)
66 aux_values[d].resize(n_points);
67 vector_values(points, aux_values);
69 for (
unsigned int k=0; k<n_points; ++k)
72 for (
unsigned int d=0; d<dim+1; ++d)
73 values[k](d) = aux_values[d][k];
85 const unsigned int n_points = 1;
86 std::vector<Point<dim> > points(1);
93 for (
unsigned int d=0; d<dim+1; ++d)
94 aux_values[d].resize(n_points);
95 vector_values(points, aux_values);
97 for (
unsigned int d=0; d<dim+1; ++d)
98 value(d) = aux_values[d][0];
105 const unsigned int comp)
const 108 const unsigned int n_points = 1;
109 std::vector<Point<dim> > points(1);
116 for (
unsigned int d=0; d<dim+1; ++d)
117 aux_values[d].resize(n_points);
118 vector_values(points, aux_values);
120 return aux_values[comp][0];
129 const unsigned int n_points = points.size();
136 for (
unsigned int d=0; d<dim+1; ++d)
137 aux_gradients[d].resize(n_points);
138 vector_gradients(points, aux_gradients);
140 for (
unsigned int k=0; k<n_points; ++k)
143 for (
unsigned int d=0; d<dim+1; ++d)
144 values[k][d] = aux_gradients[d][k];
154 const unsigned int n_points = points.size();
161 for (
unsigned int d=0; d<dim+1; ++d)
162 aux_values[d].resize(n_points);
163 vector_laplacians(points, aux_values);
165 for (
unsigned int k=0; k<n_points; ++k)
168 for (
unsigned int d=0; d<dim+1; ++d)
169 values[k](d) = aux_values[d][k];
189 radius(r), Reynolds(Re)
203 std::vector<std::vector<double> > &values)
const 205 unsigned int n = points.size();
206 double stretch = 1./radius;
209 for (
unsigned int d=0; d<dim+1; ++d)
212 for (
unsigned int k=0; k<n; ++k)
220 for (
unsigned int d=1; d<dim; ++d)
221 r2 += p(d)*p(d)*stretch*stretch;
224 values[0][k] = 1.-r2;
226 for (
unsigned int d=1; d<dim; ++d)
229 values[dim][k] = -2*(dim-1)*stretch*stretch*p(0)/Reynolds + this->mean_pressure;
240 unsigned int n = points.size();
241 double stretch = 1./radius;
244 for (
unsigned int d=0; d<dim+1; ++d)
247 for (
unsigned int k=0; k<n; ++k)
251 values[0][k][0] = 0.;
252 for (
unsigned int d=1; d<dim; ++d)
253 values[0][k][d] = -2.*p(d)*stretch*stretch;
255 for (
unsigned int d=1; d<dim; ++d)
258 values[dim][k][0] = -2*(dim-1)*stretch*stretch/Reynolds;
259 for (
unsigned int d=1; d<dim; ++d)
260 values[dim][k][d] = 0.;
269 std::vector<std::vector<double> > &values)
const 271 unsigned int n = points.size();
274 for (
unsigned int d=0; d<dim+1; ++d)
277 for (
unsigned int d=0; d<values.size(); ++d)
278 for (
unsigned int k=0; k<values[d].size(); ++k)
287 viscosity(nu), reaction(r)
308 std::vector<std::vector<double> > &values)
const 310 unsigned int n = points.size();
313 for (
unsigned int d=0; d<dim+1; ++d)
316 for (
unsigned int k=0; k<n; ++k)
321 const double cx = cos(x);
322 const double cy = cos(y);
323 const double sx = sin(x);
324 const double sy = sin(y);
328 values[0][k] = cx*cx*cy*sy;
329 values[1][k] = -cx*sx*cy*cy;
330 values[2][k] = cx*sx*cy*sy + this->mean_pressure;
335 const double cz = cos(z);
336 const double sz = sin(z);
338 values[0][k] = cx*cx*cy*sy*cz*sz;
339 values[1][k] = cx*sx*cy*cy*cz*sz;
340 values[2][k] = -2.*cx*sx*cy*sy*cz*cz;
341 values[3][k] = cx*sx*cy*sy*cz*sz + this->mean_pressure;
357 unsigned int n = points.size();
360 for (
unsigned int d=0; d<dim+1; ++d)
363 for (
unsigned int k=0; k<n; ++k)
368 const double c2x = cos(2*x);
369 const double c2y = cos(2*y);
370 const double s2x = sin(2*x);
371 const double s2y = sin(2*y);
372 const double cx2 = .5+.5*c2x;
373 const double cy2 = .5+.5*c2y;
387 const double c2z = cos(2*z);
388 const double s2z = sin(2*z);
389 const double cz2 = .5+.5*c2z;
419 std::vector<std::vector<double> > &values)
const 421 unsigned int n = points.size();
424 for (
unsigned int d=0; d<dim+1; ++d)
429 vector_values(points, values);
430 for (
unsigned int d=0; d<dim; ++d)
431 for (
unsigned int k=0; k<values[d].size(); ++k)
432 values[d][k] *= -reaction;
436 for (
unsigned int d=0; d<dim; ++d)
437 for (
unsigned int k=0; k<values[d].size(); ++k)
442 for (
unsigned int k=0; k<n; ++k)
447 const double c2x = cos(2*x);
448 const double c2y = cos(2*y);
449 const double s2x = sin(2*x);
450 const double s2y = sin(2*y);
455 values[0][k] += - viscosity*pi2 * (1.+2.*c2x) * s2y -
numbers::PI/4. * c2x*s2y;
456 values[1][k] += viscosity*pi2 * s2x * (1.+2.*c2y) -
numbers::PI/4. * s2x*c2y;
462 const double c2z = cos(2*z);
463 const double s2z = sin(2*z);
465 values[0][k] += - .5*viscosity*pi2 * (1.+2.*c2x) * s2y * s2z -
numbers::PI/8. * c2x * s2y * s2z;
466 values[1][k] += .5*viscosity*pi2 * s2x * (1.+2.*c2y) * s2z -
numbers::PI/8. * s2x * c2y * s2z;
467 values[2][k] += - .5*viscosity*pi2 * s2x * s2y * (1.+2.*c2z) -
numbers::PI/8. * s2x * s2y * c2z;
485 coslo (cos(lambda *omega)),
496 - cos(
lp*phi) + cos(
lm*phi);
504 return coslo * (cos(
lp*phi) - cos(
lm*phi))
536 void StokesLSingularity::vector_values (
537 const std::vector<
Point<2> > &points,
538 std::vector<std::vector<double> > &values)
const 540 unsigned int n = points.size();
543 for (
unsigned int d=0; d<2+1; ++d)
546 for (
unsigned int k=0; k<n; ++k)
549 const double x = p(0);
550 const double y = p(1);
555 const double r2 = x*x+y*y;
556 const double rl = pow(r2,
lambda/2.);
557 const double rl1 = pow(r2,
lambda/2.-.5);
558 values[0][k] = rl * (
lp*sin(phi)*
Psi(phi) + cos(phi)*
Psi_1(phi));
559 values[1][k] = rl * (
lp*cos(phi)*
Psi(phi) - sin(phi)*
Psi_1(phi));
564 for (
unsigned int d=0; d<3; ++d)
572 void StokesLSingularity::vector_gradients (
573 const std::vector<
Point<2> > &points,
574 std::vector<std::vector<
Tensor<1,2> > > &values)
const 576 unsigned int n = points.size();
579 for (
unsigned int d=0;
d<2+1; ++
d)
582 for (
unsigned int k=0; k<n; ++k)
585 const double x = p(0);
586 const double y = p(1);
591 const double r2 = x*x+y*y;
592 const double r = sqrt(r2);
593 const double rl = pow(r2,
lambda/2.);
594 const double rl1 = pow(r2,
lambda/2.-.5);
595 const double rl2 = pow(r2,
lambda/2.-1.);
596 const double psi =
Psi(phi);
597 const double psi1=
Psi_1(phi);
598 const double psi2=
Psi_2(phi);
599 const double cosp= cos(phi);
600 const double sinp= sin(phi);
603 const double udr =
lambda * rl1 * (
lp*sinp*psi + cosp*psi1);
604 const double udp = rl * (
lp*cosp*psi +
lp*sinp*psi1 - sinp*psi1 + cosp*psi2);
606 const double vdr =
lambda * rl1 * (
lp*cosp*psi - sinp*psi1);
607 const double vdp = rl * (
lp*(cosp*psi1 - sinp*psi) - cosp*psi1 - sinp*psi2);
610 const double pdp = -rl1 * (
lp*
lp*psi2+
Psi_4(phi)) /
lm;
611 values[0][k][0] = cosp*udr - sinp/r*udp;
612 values[0][k][1] = - sinp*udr - cosp/r*udp;
613 values[1][k][0] = cosp*vdr - sinp/r*vdp;
614 values[1][k][1] = - sinp*vdr - cosp/r*vdp;
615 values[2][k][0] = cosp*pdr - sinp/r*pdp;
616 values[2][k][1] = - sinp*pdr - cosp/r*pdp;
620 for (
unsigned int d=0;
d<3; ++
d)
628 void StokesLSingularity::vector_laplacians (
629 const std::vector<
Point<2> > &points,
630 std::vector<std::vector<double> > &values)
const 632 unsigned int n = points.size();
635 for (
unsigned int d=0;
d<2+1; ++
d)
638 for (
unsigned int d=0;
d<values.size(); ++
d)
639 for (
unsigned int k=0; k<values[
d].size(); ++k)
651 long double r2 = Reynolds/2.;
653 long double l = -b/(r2+std::sqrt(r2*r2+b));
658 p_average = 1/(8*l)*(std::exp(3.*l)-std::exp(-l));
662 Kovasznay::~Kovasznay()
666 void Kovasznay::vector_values (
667 const std::vector<
Point<2> > &points,
668 std::vector<std::vector<double> > &values)
const 670 unsigned int n = points.size();
673 for (
unsigned int d=0; d<2+1; ++d)
676 for (
unsigned int k=0; k<n; ++k)
679 const double x = p(0);
681 const double elx = std::exp(lbda*x);
683 values[0][k] = 1. - elx * cos(y);
684 values[1][k] = .5 /
numbers::PI * lbda * elx * sin(y);
685 values[2][k] = -.5 * elx * elx + p_average + this->
mean_pressure;
690 void Kovasznay::vector_gradients (
691 const std::vector<
Point<2> > &points,
692 std::vector<std::vector<
Tensor<1,2> > > &gradients)
const 694 unsigned int n = points.size();
697 Assert (gradients[0].size() == n,
700 for (
unsigned int i=0; i<n; ++i)
702 const double x = points[i](0);
703 const double y = points[i](1);
705 const double elx = std::exp(lbda*x);
710 gradients[0][i][0] = -lbda*elx*cy;
712 gradients[1][i][0] = lbda*lbda/(2*
numbers::PI)*elx*sy;
713 gradients[1][i][1] =lbda*elx*cy;
715 gradients[2][i][0] = -lbda*elx*elx;
716 gradients[2][i][1] = 0.;
722 void Kovasznay::vector_laplacians (
723 const std::vector<
Point<2> > &points,
724 std::vector<std::vector<double> > &values)
const 726 unsigned int n = points.size();
728 for (
unsigned int d=0;
d<2+1; ++
d)
734 for (
unsigned int k=0; k<n; ++k)
737 const double x = p(0);
738 const double y = zp * p(1);
739 const double elx = std::exp(lbda*x);
740 const double u = 1. - elx * cos(y);
741 const double ux = -lbda * elx * cos(y);
742 const double uy = elx * zp * sin(y);
743 const double v = lbda/zp * elx * sin(y);
744 const double vx = lbda*lbda/zp * elx * sin(y);
745 const double vy = zp*lbda/zp * elx * cos(y);
747 values[0][k] = u*ux+v*uy;
748 values[1][k] = u*vx+v*vy;
754 for (
unsigned int d=0;
d<values.size(); ++
d)
755 for (
unsigned int k=0; k<values[
d].size(); ++k)
778 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
The exponent of the radius.
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()