libMesh
laplace_exact_solution.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 #include "libmesh/libmesh_common.h"
19 
20 using namespace libMesh;
21 
22 #ifndef LAPLACE_EXACT_SOLUTION_H
23 #define LAPLACE_EXACT_SOLUTION_H
24 
26 {
27 public:
29 
31 
32  Real operator() (unsigned int component,
33  Real x,
34  Real y,
35  Real z = 0.0)
36  {
37  const Real hp = 0.5*pi;
38 
39  switch(component)
40  {
41  case 0:
42  return cos(hp*x)*sin(hp*y)*cos(hp*z);
43 
44  case 1:
45  return sin(hp*x)*cos(hp*y)*cos(hp*z);
46 
47  case 2:
48  return sin(hp*x)*cos(hp*y)*sin(hp*z);
49 
50  default:
51  libmesh_error_msg("Invalid component = " << component);
52  }
53  }
54 };
55 
56 
58 {
59 public:
61 
63 
64  RealGradient operator() (unsigned int component,
65  Real x,
66  Real y,
67  Real z = 0.0)
68  {
69  const Real hp = 0.5*pi;
70 
71  switch(component)
72  {
73  case 0:
74  return RealGradient(-hp*sin(hp*x)*sin(hp*y)*cos(hp*z),
75  cos(hp*x)*(hp)*cos(hp*y)*cos(hp*z),
76  cos(hp*x)*sin(hp*y)*(-hp)*sin(hp*z));
77 
78  case 1:
79  return RealGradient(hp*cos(hp*x)*cos(hp*y)*cos(hp*z),
80  sin(hp*x)*(-hp)*sin(hp*y)*cos(hp*z),
81  sin(hp*x)*cos(hp*y)*(-hp)*sin(hp*z));
82 
83  case 2:
84  return RealGradient(hp*cos(hp*x)*cos(hp*y)*sin(hp*z),
85  sin(hp*x)*(-hp)*sin(hp*y)*sin(hp*z),
86  sin(hp*x)*cos(hp*y)*(hp)*cos(hp*z));
87 
88  default:
89  libmesh_error_msg("Invalid component = " << component);
90  }
91  }
92 };
93 
94 #endif // LAPLACE_EXACT_SOLUTION_H
RealVectorValue RealGradient
The libMesh namespace provides an interface to certain functionality in the library.
PetscErrorCode Vec x
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real pi
.
Definition: libmesh.h:172