Reference documentation for deal.II version 9.0.0
flow_function.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2007 - 2017 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
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>
20 
21 #include <cmath>
22 
23 
24 DEAL_II_NAMESPACE_OPEN
25 
26 
27 namespace Functions
28 {
29 
30  template <int dim>
32  :
33  Function<dim>(dim+1),
34  mean_pressure(0),
35  aux_values(dim+1),
36  aux_gradients(dim+1)
37  {}
38 
39 
40 
41  template <int dim>
42  void
44  {
45  mean_pressure = p;
46  }
47 
48 
49  template <int dim>
51  const std::vector<Point<dim> > &points,
52  std::vector<Vector<double> > &values) const
53  {
54  const unsigned int n_points = points.size();
55  Assert(values.size() == n_points, ExcDimensionMismatch(values.size(), n_points));
56 
57  // guard access to the aux_*
58  // variables in multithread mode
59  Threads::Mutex::ScopedLock lock (mutex);
60 
61  for (unsigned int d=0; d<dim+1; ++d)
62  aux_values[d].resize(n_points);
63  vector_values(points, aux_values);
64 
65  for (unsigned int k=0; k<n_points; ++k)
66  {
67  Assert(values[k].size() == dim+1, ExcDimensionMismatch(values[k].size(), dim+1));
68  for (unsigned int d=0; d<dim+1; ++d)
69  values[k](d) = aux_values[d][k];
70  }
71  }
72 
73 
74  template <int dim>
76  const Point<dim> &point,
77  Vector<double> &value) const
78  {
79  Assert(value.size() == dim+1, ExcDimensionMismatch(value.size(), dim+1));
80 
81  const unsigned int n_points = 1;
82  std::vector<Point<dim> > points(1);
83  points[0] = point;
84 
85  // guard access to the aux_*
86  // variables in multithread mode
87  Threads::Mutex::ScopedLock lock (mutex);
88 
89  for (unsigned int d=0; d<dim+1; ++d)
90  aux_values[d].resize(n_points);
91  vector_values(points, aux_values);
92 
93  for (unsigned int d=0; d<dim+1; ++d)
94  value(d) = aux_values[d][0];
95  }
96 
97 
98  template <int dim>
100  const Point<dim> &point,
101  const unsigned int comp) const
102  {
103  Assert(comp < dim+1, ExcIndexRange(comp, 0, dim+1));
104  const unsigned int n_points = 1;
105  std::vector<Point<dim> > points(1);
106  points[0] = point;
107 
108  // guard access to the aux_*
109  // variables in multithread mode
110  Threads::Mutex::ScopedLock lock (mutex);
111 
112  for (unsigned int d=0; d<dim+1; ++d)
113  aux_values[d].resize(n_points);
114  vector_values(points, aux_values);
115 
116  return aux_values[comp][0];
117  }
118 
119 
120  template <int dim>
122  const std::vector<Point<dim> > &points,
123  std::vector<std::vector<Tensor<1,dim> > > &values) const
124  {
125  const unsigned int n_points = points.size();
126  Assert(values.size() == n_points, ExcDimensionMismatch(values.size(), n_points));
127 
128  // guard access to the aux_*
129  // variables in multithread mode
130  Threads::Mutex::ScopedLock lock (mutex);
131 
132  for (unsigned int d=0; d<dim+1; ++d)
133  aux_gradients[d].resize(n_points);
134  vector_gradients(points, aux_gradients);
135 
136  for (unsigned int k=0; k<n_points; ++k)
137  {
138  Assert(values[k].size() == dim+1, ExcDimensionMismatch(values[k].size(), dim+1));
139  for (unsigned int d=0; d<dim+1; ++d)
140  values[k][d] = aux_gradients[d][k];
141  }
142  }
143 
144 
145  template <int dim>
147  const std::vector<Point<dim> > &points,
148  std::vector<Vector<double> > &values) const
149  {
150  const unsigned int n_points = points.size();
151  Assert(values.size() == n_points, ExcDimensionMismatch(values.size(), n_points));
152 
153  // guard access to the aux_*
154  // variables in multithread mode
155  Threads::Mutex::ScopedLock lock (mutex);
156 
157  for (unsigned int d=0; d<dim+1; ++d)
158  aux_values[d].resize(n_points);
159  vector_laplacians(points, aux_values);
160 
161  for (unsigned int k=0; k<n_points; ++k)
162  {
163  Assert(values[k].size() == dim+1, ExcDimensionMismatch(values[k].size(), dim+1));
164  for (unsigned int d=0; d<dim+1; ++d)
165  values[k](d) = aux_values[d][k];
166  }
167  }
168 
169 
170  template <int dim>
171  std::size_t
173  {
174  Assert(false, ExcNotImplemented());
175  return 0;
176  }
177 
178 
179 //----------------------------------------------------------------------//
180 
181  template <int dim>
183  const double Re)
184  :
185  radius(r), Reynolds(Re)
186  {
187  Assert(Reynolds != 0., ExcMessage("Reynolds number cannot be zero"));
188  }
189 
190 
191 
192  template <int dim>
194  const std::vector<Point<dim> > &points,
195  std::vector<std::vector<double> > &values) const
196  {
197  unsigned int n = points.size();
198  double stretch = 1./radius;
199 
200  Assert(values.size() == dim+1, ExcDimensionMismatch(values.size(), dim+1));
201  for (unsigned int d=0; d<dim+1; ++d)
202  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
203 
204  for (unsigned int k=0; k<n; ++k)
205  {
206  const Point<dim> &p = points[k];
207  // First, compute the
208  // square of the distance to
209  // the x-axis divided by the
210  // radius.
211  double r2 = 0;
212  for (unsigned int d=1; d<dim; ++d)
213  r2 += p(d)*p(d)*stretch*stretch;
214 
215  // x-velocity
216  values[0][k] = 1.-r2;
217  // other velocities
218  for (unsigned int d=1; d<dim; ++d)
219  values[d][k] = 0.;
220  // pressure
221  values[dim][k] = -2*(dim-1)*stretch*stretch*p(0)/Reynolds + this->mean_pressure;
222  }
223  }
224 
225 
226 
227  template <int dim>
229  const std::vector<Point<dim> > &points,
230  std::vector<std::vector<Tensor<1,dim> > > &values) const
231  {
232  unsigned int n = points.size();
233  double stretch = 1./radius;
234 
235  Assert(values.size() == dim+1, ExcDimensionMismatch(values.size(), dim+1));
236  for (unsigned int d=0; d<dim+1; ++d)
237  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
238 
239  for (unsigned int k=0; k<n; ++k)
240  {
241  const Point<dim> &p = points[k];
242  // x-velocity
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;
246  // other velocities
247  for (unsigned int d=1; d<dim; ++d)
248  values[d][k] = 0.;
249  // pressure
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.;
253  }
254  }
255 
256 
257 
258  template <int dim>
260  const std::vector<Point<dim> > &points,
261  std::vector<std::vector<double> > &values) const
262  {
263  unsigned int n = points.size();
264  (void)n;
265  Assert(values.size() == dim+1, ExcDimensionMismatch(values.size(), dim+1));
266  for (unsigned int d=0; d<dim+1; ++d)
267  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
268 
269  for (unsigned int d=0; d<values.size(); ++d)
270  for (unsigned int k=0; k<values[d].size(); ++k)
271  values[d][k] = 0.;
272  }
273 
274 //----------------------------------------------------------------------//
275 
276  template <int dim>
277  StokesCosine<dim>::StokesCosine(const double nu, const double r)
278  :
279  viscosity(nu), reaction(r)
280  {}
281 
282 
283 
284  template <int dim>
285  void
286  StokesCosine<dim>::set_parameters(const double nu, const double r)
287  {
288  viscosity = nu;
289  reaction = r;
290  }
291 
292 
293  template <int dim>
295  const std::vector<Point<dim> > &points,
296  std::vector<std::vector<double> > &values) const
297  {
298  unsigned int n = points.size();
299 
300  Assert(values.size() == dim+1, ExcDimensionMismatch(values.size(), dim+1));
301  for (unsigned int d=0; d<dim+1; ++d)
302  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
303 
304  for (unsigned int k=0; k<n; ++k)
305  {
306  const Point<dim> &p = points[k];
307  const double x = numbers::PI/2. * p(0);
308  const double y = numbers::PI/2. * p(1);
309  const double cx = cos(x);
310  const double cy = cos(y);
311  const double sx = sin(x);
312  const double sy = sin(y);
313 
314  if (dim==2)
315  {
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;
319  }
320  else if (dim==3)
321  {
322  const double z = numbers::PI/2. * p(2);
323  const double cz = cos(z);
324  const double sz = sin(z);
325 
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;
330  }
331  else
332  {
333  Assert(false, ExcNotImplemented());
334  }
335  }
336  }
337 
338 
339 
340  template <int dim>
342  const std::vector<Point<dim> > &points,
343  std::vector<std::vector<Tensor<1,dim> > > &values) const
344  {
345  unsigned int n = points.size();
346 
347  Assert(values.size() == dim+1, ExcDimensionMismatch(values.size(), dim+1));
348  for (unsigned int d=0; d<dim+1; ++d)
349  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
350 
351  for (unsigned int k=0; k<n; ++k)
352  {
353  const Point<dim> &p = points[k];
354  const double x = numbers::PI/2. * p(0);
355  const double y = numbers::PI/2. * p(1);
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; // cos^2 x
361  const double cy2 = .5+.5*c2y; // cos^2 y
362 
363  if (dim==2)
364  {
365  values[0][k][0] = -.25*numbers::PI * s2x*s2y;
366  values[0][k][1] = .5 *numbers::PI * cx2*c2y;
367  values[1][k][0] = -.5 *numbers::PI * c2x*cy2;
368  values[1][k][1] = .25*numbers::PI * s2x*s2y;
369  values[2][k][0] = .25*numbers::PI * c2x*s2y;
370  values[2][k][1] = .25*numbers::PI * s2x*c2y;
371  }
372  else if (dim==3)
373  {
374  const double z = numbers::PI/2. * p(2);
375  const double c2z = cos(2*z);
376  const double s2z = sin(2*z);
377  const double cz2 = .5+.5*c2z; // cos^2 z
378 
379  values[0][k][0] = -.125*numbers::PI * s2x*s2y*s2z;
380  values[0][k][1] = .25 *numbers::PI * cx2*c2y*s2z;
381  values[0][k][2] = .25 *numbers::PI * cx2*s2y*c2z;
382 
383  values[1][k][0] = .25 *numbers::PI * c2x*cy2*s2z;
384  values[1][k][1] = -.125*numbers::PI * s2x*s2y*s2z;
385  values[1][k][2] = .25 *numbers::PI * s2x*cy2*c2z;
386 
387  values[2][k][0] = -.5 *numbers::PI * c2x*s2y*cz2;
388  values[2][k][1] = -.5 *numbers::PI * s2x*c2y*cz2;
389  values[2][k][2] = .25 *numbers::PI * s2x*s2y*s2z;
390 
391  values[3][k][0] = .125*numbers::PI * c2x*s2y*s2z;
392  values[3][k][1] = .125*numbers::PI * s2x*c2y*s2z;
393  values[3][k][2] = .125*numbers::PI * s2x*s2y*c2z;
394  }
395  else
396  {
397  Assert(false, ExcNotImplemented());
398  }
399  }
400  }
401 
402 
403 
404  template <int dim>
406  const std::vector<Point<dim> > &points,
407  std::vector<std::vector<double> > &values) const
408  {
409  unsigned int n = points.size();
410 
411  Assert(values.size() == dim+1, ExcDimensionMismatch(values.size(), dim+1));
412  for (unsigned int d=0; d<dim+1; ++d)
413  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
414 
415  if (reaction != 0.)
416  {
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;
421  }
422  else
423  {
424  for (unsigned int d=0; d<dim; ++d)
425  for (unsigned int k=0; k<values[d].size(); ++k)
426  values[d][k] = 0.;
427  }
428 
429 
430  for (unsigned int k=0; k<n; ++k)
431  {
432  const Point<dim> &p = points[k];
433  const double x = numbers::PI/2. * p(0);
434  const double y = numbers::PI/2. * p(1);
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);
439  const double pi2 = .25 * numbers::PI * numbers::PI;
440 
441  if (dim==2)
442  {
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;
445  values[2][k] = 0.;
446  }
447  else if (dim==3)
448  {
449  const double z = numbers::PI * p(2);
450  const double c2z = cos(2*z);
451  const double s2z = sin(2*z);
452 
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;
456  values[3][k] = 0.;
457  }
458  else
459  {
460  Assert(false, ExcNotImplemented());
461  }
462  }
463  }
464 
465 
466 //----------------------------------------------------------------------//
467 
468  const double StokesLSingularity::lambda = 0.54448373678246;
469 
471  :
472  omega (3./2.*numbers::PI),
473  coslo (cos(lambda *omega)),
474  lp(1.+lambda),
475  lm(1.-lambda)
476  {}
477 
478 
479  inline
480  double
481  StokesLSingularity::Psi(double phi) const
482  {
483  return coslo * (sin(lp*phi)/lp - sin(lm*phi)/lm)
484  - cos(lp*phi) + cos(lm*phi);
485  }
486 
487 
488  inline
489  double
490  StokesLSingularity::Psi_1(double phi) const
491  {
492  return coslo * (cos(lp*phi) - cos(lm*phi))
493  + lp*sin(lp*phi) - lm*sin(lm*phi);
494  }
495 
496 
497  inline
498  double
499  StokesLSingularity::Psi_2(double phi) const
500  {
501  return coslo * (lm*sin(lm*phi) - lp*sin(lp*phi))
502  + lp*lp*cos(lp*phi) - lm*lm*cos(lm*phi);
503  }
504 
505 
506  inline
507  double
508  StokesLSingularity::Psi_3(double phi) const
509  {
510  return coslo * (lm*lm*cos(lm*phi) - lp*lp*cos(lp*phi))
511  + lm*lm*lm*sin(lm*phi) - lp*lp*lp*sin(lp*phi);
512  }
513 
514 
515  inline
516  double
517  StokesLSingularity::Psi_4(double phi) const
518  {
519  return coslo * (lp*lp*lp*sin(lp*phi) - lm*lm*lm*sin(lm*phi))
520  + lm*lm*lm*lm*cos(lm*phi) - lp*lp*lp*lp*cos(lp*phi);
521  }
522 
523 
524  void StokesLSingularity::vector_values (
525  const std::vector<Point<2> > &points,
526  std::vector<std::vector<double> > &values) const
527  {
528  unsigned int n = points.size();
529 
530  Assert(values.size() == 2+1, ExcDimensionMismatch(values.size(), 2+1));
531  for (unsigned int d=0; d<2+1; ++d)
532  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
533 
534  for (unsigned int k=0; k<n; ++k)
535  {
536  const Point<2> &p = points[k];
537  const double x = p(0);
538  const double y = p(1);
539 
540  if ((x<0) || (y<0))
541  {
542  const double phi = std::atan2(y,-x)+numbers::PI;
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));
548  values[2][k] = -rl1 * (lp*lp*Psi_1(phi) + Psi_3(phi)) / lm + this->mean_pressure;
549  }
550  else
551  {
552  for (unsigned int d=0; d<3; ++d)
553  values[d][k] = 0.;
554  }
555  }
556  }
557 
558 
559 
560  void StokesLSingularity::vector_gradients (
561  const std::vector<Point<2> > &points,
562  std::vector<std::vector<Tensor<1,2> > > &values) const
563  {
564  unsigned int n = points.size();
565 
566  Assert(values.size() == 2+1, ExcDimensionMismatch(values.size(), 2+1));
567  for (unsigned int d=0; d<2+1; ++d)
568  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
569 
570  for (unsigned int k=0; k<n; ++k)
571  {
572  const Point<2> &p = points[k];
573  const double x = p(0);
574  const double y = p(1);
575 
576  if ((x<0) || (y<0))
577  {
578  const double phi = std::atan2(y,-x)+numbers::PI;
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);
589 
590  // Derivatives of u with respect to r, 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);
593  // Derivatives of v with respect to r, phi
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);
596  // Derivatives of p with respect to r, phi
597  const double pdr = -(lambda-1.) * rl2 * (lp*lp*psi1+Psi_3(phi)) / lm;
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;
605  }
606  else
607  {
608  for (unsigned int d=0; d<3; ++d)
609  values[d][k] = 0.;
610  }
611  }
612  }
613 
614 
615 
616  void StokesLSingularity::vector_laplacians (
617  const std::vector<Point<2> > &points,
618  std::vector<std::vector<double> > &values) const
619  {
620  unsigned int n = points.size();
621  (void)n;
622  Assert(values.size() == 2+1, ExcDimensionMismatch(values.size(), 2+1));
623  for (unsigned int d=0; d<2+1; ++d)
624  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
625 
626  for (unsigned int d=0; d<values.size(); ++d)
627  for (unsigned int k=0; k<values[d].size(); ++k)
628  values[d][k] = 0.;
629  }
630 
631 
632 //----------------------------------------------------------------------//
633 
634  Kovasznay::Kovasznay(double Re, bool stokes)
635  :
636  Reynolds(Re),
637  stokes(stokes)
638  {
639  long double r2 = Reynolds/2.;
640  long double b = 4*numbers::PI*numbers::PI;
641  long double l = -b/(r2+std::sqrt(r2*r2+b));
642  lbda = l;
643  // mean pressure for a domain
644  // spreading from -.5 to 1.5 in
645  // x-direction
646  p_average = 1/(8*l)*(std::exp(3.*l)-std::exp(-l));
647  }
648 
649 
650 
651  void Kovasznay::vector_values (
652  const std::vector<Point<2> > &points,
653  std::vector<std::vector<double> > &values) const
654  {
655  unsigned int n = points.size();
656 
657  Assert(values.size() == 2+1, ExcDimensionMismatch(values.size(), 2+1));
658  for (unsigned int d=0; d<2+1; ++d)
659  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
660 
661  for (unsigned int k=0; k<n; ++k)
662  {
663  const Point<2> &p = points[k];
664  const double x = p(0);
665  const double y = 2. * numbers::PI * p(1);
666  const double elx = std::exp(lbda*x);
667 
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;
671  }
672  }
673 
674 
675  void Kovasznay::vector_gradients (
676  const std::vector<Point<2> > &points,
677  std::vector<std::vector<Tensor<1,2> > > &gradients) const
678  {
679  unsigned int n = points.size();
680 
681  Assert (gradients.size() == 3, ExcDimensionMismatch(gradients.size(), 3));
682  Assert (gradients[0].size() == n,
683  ExcDimensionMismatch(gradients[0].size(), n));
684 
685  for (unsigned int i=0; i<n; ++i)
686  {
687  const double x = points[i](0);
688  const double y = points[i](1);
689 
690  const double elx = std::exp(lbda*x);
691  const double cy = cos(2*numbers::PI*y);
692  const double sy = sin(2*numbers::PI*y);
693 
694  // u
695  gradients[0][i][0] = -lbda*elx*cy;
696  gradients[0][i][1] = 2. * numbers::PI*elx*sy;
697  gradients[1][i][0] = lbda*lbda/(2*numbers::PI)*elx*sy;
698  gradients[1][i][1] =lbda*elx*cy;
699  // p
700  gradients[2][i][0] = -lbda*elx*elx;
701  gradients[2][i][1] = 0.;
702  }
703  }
704 
705 
706 
707  void Kovasznay::vector_laplacians (
708  const std::vector<Point<2> > &points,
709  std::vector<std::vector<double> > &values) const
710  {
711  unsigned int n = points.size();
712  Assert(values.size() == 2+1, ExcDimensionMismatch(values.size(), 2+1));
713  for (unsigned int d=0; d<2+1; ++d)
714  Assert(values[d].size() == n, ExcDimensionMismatch(values[d].size(), n));
715 
716  if (stokes)
717  {
718  const double zp = 2. * numbers::PI;
719  for (unsigned int k=0; k<n; ++k)
720  {
721  const Point<2> &p = points[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);
731 
732  values[0][k] = u*ux+v*uy;
733  values[1][k] = u*vx+v*vy;
734  values[2][k] = 0.;
735  }
736  }
737  else
738  {
739  for (unsigned int d=0; d<values.size(); ++d)
740  for (unsigned int k=0; k<values[d].size(); ++k)
741  values[d][k] = 0.;
742  }
743  }
744 
745  double
747  {
748  return lbda;
749  }
750 
751 
752 
753  template class FlowFunction<2>;
754  template class FlowFunction<3>;
755  template class PoisseuilleFlow<2>;
756  template class PoisseuilleFlow<3>;
757  template class StokesCosine<2>;
758  template class StokesCosine<3>;
759 }
760 
761 
762 
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 const double PI
Definition: numbers.h:127
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)
Definition: exceptions.h:1142
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()
size_type size() const
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()