-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbaffle.cpp
200 lines (179 loc) · 3.89 KB
/
baffle.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <fstream>
# include <ctime>
# include <cmath>
using namespace std;
//****************************************************************************80
void dirichlet_condition ( int node_num, double node_xy[], double node_bc[] )
//****************************************************************************80
//
// Purpose:
//
// DIRICHLET_CONDITION sets the value of a Dirichlet boundary condition.
//
// Discussion:
//
// This routine specifies that the solution is zero on the boundary.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 25 January 2013
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int NODE_NUM, the number of nodes.
//
// Input, double NODE_XY[2*NODE_NUM], the coordinates of the points.
//
// Output, double NODE_BC[NODE_NUM], the value of the
// Dirichlet boundary conditions at the points.
//
{
int node;
for ( node = 0; node < node_num; node++ )
{
node_bc[node] = 0.0;
}
return;
}
//****************************************************************************80
void h_coef ( int node_num, double node_xy[], double node_h[] )
//****************************************************************************80
//
// Purpose:
//
// H_COEF evaluates the coefficient H(X,Y) of DEL U in the Poisson equation.
//
// Discussion:
//
// The equation is
//
// -DEL H(X,Y) DEL U(X,Y) + K(X,Y) * U(X,Y) = F(X,Y)
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 25 January 2013
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int NODE_NUM, the number of nodes.
//
// Input, double NODE_XY[2*NODE_NUM], the coordinates of the points.
//
// Output, double NODE_H[NODE_NUM], the value of the
// H function at the points.
//
{
int node;
for ( node = 0; node < node_num; node++ )
{
node_h[node] = 1.0;
}
return;
}
//****************************************************************************80
void k_coef ( int node_num, double node_xy[], double node_k[] )
//****************************************************************************80
//
// Purpose:
//
// K_COEF evaluates the coefficient K(X,Y) of U in the Poisson equation.
//
// Discussion:
//
// The equation is
//
// -DEL H(X,Y) DEL U(X,Y) + K(X,Y) * U(X,Y) = F(X,Y)
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 25 January 2013
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int NODE_NUM, the number of nodes.
//
// Input, double NODE_XY[2*NODE_NUM], the coordinates of the points.
//
// Output, double NODE_K[NODE_NUM], the value of the
// K function at the points.
//
{
int node;
for ( node = 0; node < node_num; node++ )
{
node_k[node] = 0.0;
}
return;
}
//****************************************************************************80
void rhs ( int node_num, double node_xy[], double node_rhs[] )
//****************************************************************************80
//
// Purpose:
//
// RHS gives the right-hand side of the differential equation.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 25 January 2013
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int NODE_NUM, the number of nodes.
//
// Input, double NODE_XY[2*NODE_NUM], the coordinates of the points.
//
// Output, double NODE_RHS[NODE_NUM], the value of the
// right hand side function at the points.
//
{
int node;
double z;
for ( node = 0; node < node_num; node++ )
{
z = 4.0 - sqrt (
pow ( node_xy[0+node*2] - 2.0, 2 )
+ pow ( node_xy[1+node*2] - 2.0, 2 ) );
if ( z < 0.0 )
{
z = 0.0;
}
node_rhs[node] = z;
}
return;
}