libMesh
mixed_exact_solution.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef MIXED_EXACT_SOLUTION_H
19 #define MIXED_EXACT_SOLUTION_H
20 
21 #include "libmesh/libmesh_common.h"
22 #include "libmesh/vector_value.h"
23 
24 using namespace libMesh;
25 
27 {
28 public:
29  MixedExactSolution() = default;
30  ~MixedExactSolution() = default;
31 
33  {
34  return cos(.5*pi*x)*sin(.5*pi*y);
35  }
36 
38  {
39  return cos(.5*pi*x)*sin(.5*pi*y)*cos(.5*pi*z);
40  }
41 
42  RealGradient operator() (Real x, Real y)
43  {
44  const Real ux = .5*pi*sin(.5*pi*x)*sin(.5*pi*y);
45  const Real uy = -.5*pi*cos(.5*pi*x)*cos(.5*pi*y);
46 
47  return RealGradient(ux, uy);
48  }
49 
50  RealGradient operator() (Real x, Real y, Real z)
51  {
52  const Real ux = .5*pi*sin(.5*pi*x)*sin(.5*pi*y)*cos(.5*pi*z);
53  const Real uy = -.5*pi*cos(.5*pi*x)*cos(.5*pi*y)*cos(.5*pi*z);
54  const Real uz = .5*pi*cos(.5*pi*x)*sin(.5*pi*y)*sin(.5*pi*z);
55 
56  return RealGradient(ux, uy, uz);
57  }
58 
60  {
61  const Real dux_dx = .5*pi*.5*pi*cos(.5*pi*x)*sin(.5*pi*y);
62  const Real dux_dy = .5*pi*.5*pi*sin(.5*pi*x)*cos(.5*pi*y);
63  const Real duy_dx = .5*pi*.5*pi*sin(.5*pi*x)*cos(.5*pi*y);
64  const Real duy_dy = .5*pi*.5*pi*cos(.5*pi*x)*sin(.5*pi*y);
65 
66  return RealTensor(dux_dx, dux_dy, Real(0), duy_dx, duy_dy);
67  }
68 
70  {
71  const Real dux_dx = .5*pi*.5*pi*cos(.5*pi*x)*sin(.5*pi*y)*cos(.5*pi*z);
72  const Real dux_dy = .5*pi*.5*pi*sin(.5*pi*x)*cos(.5*pi*y)*cos(.5*pi*z);
73  const Real dux_dz = -.5*pi*.5*pi*sin(.5*pi*x)*sin(.5*pi*y)*sin(.5*pi*z);
74  const Real duy_dx = .5*pi*.5*pi*sin(.5*pi*x)*cos(.5*pi*y)*cos(.5*pi*z);
75  const Real duy_dy = .5*pi*.5*pi*cos(.5*pi*x)*sin(.5*pi*y)*cos(.5*pi*z);
76  const Real duy_dz = .5*pi*.5*pi*cos(.5*pi*x)*cos(.5*pi*y)*sin(.5*pi*z);
77  const Real duz_dx = -.5*pi*.5*pi*sin(.5*pi*x)*sin(.5*pi*y)*sin(.5*pi*z);
78  const Real duz_dy = .5*pi*.5*pi*cos(.5*pi*x)*cos(.5*pi*y)*sin(.5*pi*z);
79  const Real duz_dz = .5*pi*.5*pi*cos(.5*pi*x)*sin(.5*pi*y)*cos(.5*pi*z);
80 
81  return RealTensor(dux_dx, dux_dy, dux_dz, duy_dx, duy_dy, duy_dz, duz_dx, duz_dy, duz_dz);
82  }
83 
84  Real div(Real x, Real y)
85  {
86  const Real dux_dx = grad(x, y)(0, 0);
87  const Real duy_dy = grad(x, y)(1, 1);
88 
89  return dux_dx + duy_dy;
90  }
91 
92  Real div(Real x, Real y, Real z)
93  {
94  const Real dux_dx = grad(x, y, z)(0, 0);
95  const Real duy_dy = grad(x, y, z)(1, 1);
96  const Real duz_dz = grad(x, y, z)(2, 2);
97 
98  return dux_dx + duy_dy + duz_dz;
99  }
100 
102  {
103  return div(x, y);
104  }
105 
107  {
108  return div(x, y, z);
109  }
110 };
111 
112 #endif // MIXED_EXACT_SOLUTION_H
Real scalar(Real x, Real y, Real z)
RealVectorValue RealGradient
RealTensor grad(Real x, Real y, Real z)
Real div(Real x, Real y, Real z)
Real scalar(Real x, Real y)
RealTensorValue RealTensor
The libMesh namespace provides an interface to certain functionality in the library.
Real forcing(Real x, Real y, Real z)
Real forcing(Real x, Real y)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
RealTensor grad(Real x, Real y)
Real div(Real x, Real y)
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
const Real pi
.
Definition: libmesh.h:299