libMesh
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. More...
 

Function Documentation

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 39 of file exact_solution.C.

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

Referenced by assemble_poisson().

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