libMesh
Loading...
Searching...
No Matches
Functions
exact_solution.C File Reference

Go to the source code of this file.

Functions

Real exact_solution (const int component, const Real x, const Real y, const Real z=0.)
 This is the exact solution that we are trying to obtain.
 
Real forcing_function (const int component, const Real x, const Real y, const Real z=0.)
 

Function Documentation

◆ exact_solution()

Real exact_solution ( const int  component,
const Real  x,
const Real  y,
const Real  z = 0. 
)

This is the exact solution that we are trying to obtain.

We will solve

  • (u_xx + u_yy) = f

and take a finite difference approximation using this function to get f. This is the well-known "method of manufactured solutions".

Definition at line 38 of file exact_solution.C.

39{
40 static const Real pi = acos(-1.);
41
42 switch (component)
43 {
44 case 0:
45 return cos(.5 * pi * x) * sin(.5 * pi * y) * cos(.5 * pi * z);
46 case 1:
47 return sin(.5 * pi * x) * cos(.5 * pi * y) * cos(.5 * pi * z);
48 case 2:
49 return 0;
50 default:
51 libmesh_error_msg("Invalid component = " << component);
52 }
53
54 // dummy
55 return 0.0;
56}
const Real pi
.
Definition libmesh.h:292
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

References libMesh::pi, and libMesh::Real.

◆ forcing_function()

Real forcing_function ( const int  component,
const Real  x,
const Real  y,
const Real  z = 0. 
)

Definition at line 59 of file exact_solution.C.

60{
61 static const Real pi = acos(-1.);
62
63 switch (component)
64 {
65 case 0:
66 return -3. * pi * pi * sin(pi * y / 2.) * cos(pi * x / 2.) * cos(pi * z / 2.) / 4.;
67 case 1:
68 return -3. * pi * pi * sin(pi * x / 2.) * cos(pi * y / 2.) * cos(pi * z / 2.) / 4.;
69 case 2:
70 return 0;
71 default:
72 libmesh_error_msg("Invalid component = " << component);
73 }
74
75 // dummy
76 return 0.0;
77}

References libMesh::pi, and libMesh::Real.