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