-
Notifications
You must be signed in to change notification settings - Fork 7
/
boundsint.c
285 lines (241 loc) · 7.8 KB
/
boundsint.c
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#include "decs.h"
// this is the presently used function
// Regarding GRID SECTIONING, the pflag can be set using LOOPF's not COMPLOOPF since no benefit in moving where define "real" boundary
// needed as global so all subfunctions have it set
int inboundloop[NDIM];
int outboundloop[NDIM];
int innormalloop[NDIM];
int outnormalloop[NDIM];
int inoutlohi[NUMUPDOWN][NUMUPDOWN][NDIM];
int riin,riout,rjin,rjout,rkin,rkout;
int dosetbc[COMPDIM*2];
// only bounds +-1 cell as required for pflags to exist for check_solution() checking and fixup_utoprim() averaging
int bound_pflag_user(int boundstage, int finalstep, SFTYPE boundtime, int boundvartype, PFTYPE (*prim)[NSTORE2][NSTORE3][NUMPFLAGS])
{
int i,j,k,pl,pliter;
int failreturn;
int ri, rj, rk; // reference i,j,k
// includes all conditions from global.h except NSSURFACE and FIXED
// OUTFLOW: direct copy here since value is discrete and has discrete meaning
// that is, properties are just copied.
/* if fixed BC: do nothing */
// GODMARK: no, since doing multi-steps, one should assign some fixed primitive to prim, as done for real primitives
// general assume flag doesn't care about FIXED, since represents a failure. One's own FIXED conditions shouldn't fail.
////////////////////////
//
// set bound loop
//
///////////////////////
set_boundloop(boundvartype, inboundloop,outboundloop,innormalloop,outnormalloop,inoutlohi, &riin, &riout, &rjin, &rjout, &rkin, &rkout, dosetbc);
/////////////////////
//
// PERIODIC
//
/////////////////////
// periodic x1
if ( (mycpupos[1] == 0)&&(mycpupos[1] == ncpux1 - 1) ) {
if( (BCtype[X1DN]==PERIODIC)&&(BCtype[X1UP]==PERIODIC) ){
// just copy from one side to another
LOOPX1dir{
// copy from upper side to lower boundary zones
ri=riout;
rj=j;
rk=k;
LOOPBOUND1IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri+1+i,rj,rk,pl);
// copy from lower side to upper boundary zones
ri=riin;
rj=j;
rk=k;
LOOPBOUND1OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri+(i-N1),rj,rk,pl);
}
}
}
// periodic x2
if ( (mycpupos[2] == 0)&&(mycpupos[2] == ncpux2 - 1) ) {
if( (BCtype[X2DN]==PERIODIC)&&(BCtype[X2UP]==PERIODIC) ){
// just copy from one side to another
LOOPX2dir{
// copy from upper side to lower boundary zones
ri=i;
rj=rjout;
rk=k;
LOOPBOUND2IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj+1+j,rk,pl);
// copy from lower side to upper boundary zones
ri=i;
rj=rjin;
rk=k;
LOOPBOUND2OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj+(j-N2),rk,pl);
}
}
}
// periodic x3
if ( (mycpupos[3] == 0)&&(mycpupos[3] == ncpux3 - 1) ) {
if( (BCtype[X3DN]==PERIODIC)&&(BCtype[X3UP]==PERIODIC) ){
// just copy from one side to another
LOOPX3dir{
// copy from upper side to lower boundary zones
ri=i;
rj=j;
rk=rkout;
LOOPBOUND3IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk+1+k,pl);
// copy from lower side to upper boundary zones
ri=i;
rj=j;
rk=rkin;
LOOPBOUND3OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk+(k-N3),pl);
}
}
}
/////////////////////
//
// OUTFLOW/FIXEDOUTFLOW (for events, just copy)
//
/////////////////////
// outflow inner x1
if (mycpupos[1] == 0) {
if( (BCtype[X1DN]==OUTFLOW)||(BCtype[X1DN]==FIXEDOUTFLOW)||(BCtype[X1DN]==OUTFLOWNOINFLOW) ){
/* inner r boundary condition: u, just copy */
LOOPX1dir{
ri=riin;
rj=j;
rk=k;
LOOPBOUND1IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk,pl);
}
}
}
// outflow outer x1
if (mycpupos[1] == ncpux1 - 1) {
if( (BCtype[X1UP]==OUTFLOW)||(BCtype[X1UP]==FIXEDOUTFLOW)||(BCtype[X1UP]==OUTFLOWNOINFLOW) ){
/* outer r BC: outflow */
LOOPX1dir{
ri=riout;
rj=j;
rk=k;
LOOPBOUND1OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk,pl);
}
}
}
// outflow inner x2
if (mycpupos[2] == 0) {
if( (BCtype[X2DN]==OUTFLOW)||(BCtype[X2DN]==FIXEDOUTFLOW)||(BCtype[X2DN]==OUTFLOWNOINFLOW) ){
/* inner r boundary condition: u, just copy */
LOOPX2dir{
ri=i;
rj=rjin;
rk=k;
LOOPBOUND2IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk,pl);
}
}
}
// outflow outer x2
if (mycpupos[2] == ncpux2 - 1) {
if( (BCtype[X2UP]==OUTFLOW)||(BCtype[X2UP]==FIXEDOUTFLOW)||(BCtype[X2UP]==OUTFLOWNOINFLOW) ){
/* outer r BC: outflow */
LOOPX2dir{
ri=i;
rj=rjout;
rk=k;
LOOPBOUND2OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk,pl);
}
}
}
// outflow inner x3
if (mycpupos[3] == 0) {
if( (BCtype[X3DN]==OUTFLOW)||(BCtype[X3DN]==FIXEDOUTFLOW)||(BCtype[X3DN]==OUTFLOWNOINFLOW) ){
/* inner r boundary condition: u, just copy */
LOOPX3dir{
ri=i;
rj=j;
rk=rkin;
LOOPBOUND3IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk,pl);
}
}
}
// outflow outer x3
if (mycpupos[3] == ncpux3 - 1) {
if( (BCtype[X3UP]==OUTFLOW)||(BCtype[X3UP]==FIXEDOUTFLOW)||(BCtype[X3UP]==OUTFLOWNOINFLOW) ){
/* outer r BC: outflow */
LOOPX3dir{
ri=i;
rj=j;
rk=rkout;
LOOPBOUND3OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk,pl);
}
}
}
/////////////////////
//
// POLARAXIS/SYMM/ASYMM (for events (not values) these are the same)
//
/////////////////////
// symmetry on inner x1
if (mycpupos[1] == 0) {
if( (BCtype[X1DN]==R0SING)||(BCtype[X1DN]==POLARAXIS)||(BCtype[X1DN]==SYMM)||(BCtype[X1DN]==ASYMM)) {
LOOPX1dir{
ri=riin;
rj=j;
rk=k;
// symmetric copy
LOOPBOUND1IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri+(ri-i-1),rj,rk,pl);
}
}
}
// symmetry on outer x1
if (mycpupos[1] == ncpux1 - 1) {
if( (BCtype[X1UP]==R0SING)||(BCtype[X1UP]==POLARAXIS)||(BCtype[X1UP]==SYMM)||(BCtype[X1UP]==ASYMM)) {
LOOPX1dir{
ri=riout;
rj=j;
rk=k;
LOOPBOUND1OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri+(ri-i+1),rj,rk,pl);
}
}
}
// symmetry on inner x2
if (mycpupos[2] == 0) {
if( (BCtype[X2DN]==R0SING)||(BCtype[X2DN]==POLARAXIS)||(BCtype[X2DN]==SYMM)||(BCtype[X2DN]==ASYMM)) {
LOOPX2dir{
ri=i;
rj=rjin;
rk=k;
// symmetric copy
LOOPBOUND2IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj+(rj-j-1),rk,pl);
}
}
}
// symmetry on outer x2
if (mycpupos[2] == ncpux2 - 1) {
if( (BCtype[X2UP]==R0SING)||(BCtype[X2UP]==POLARAXIS)||(BCtype[X2UP]==SYMM)||(BCtype[X2UP]==ASYMM)) {
LOOPX2dir{
ri=i;
rj=rjout;
rk=k;
LOOPBOUND2OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj+(rj-j+1),rk,pl);
}
}
}
// symmetry on inner x3
if (mycpupos[3] == 0) {
if( (BCtype[X3DN]==R0SING)||(BCtype[X3DN]==POLARAXIS)||(BCtype[X3DN]==SYMM)||(BCtype[X3DN]==ASYMM)) {
LOOPX3dir{
ri=i;
rj=j;
rk=rkin;
// symmetric copy
LOOPBOUND3IN FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk+(rk-k-1),pl);
}
}
}
// symmetry on outer x3
if (mycpupos[3] == ncpux3 - 1) {
if( (BCtype[X3UP]==R0SING)||(BCtype[X3UP]==POLARAXIS)||(BCtype[X3UP]==SYMM)||(BCtype[X3UP]==ASYMM)) {
LOOPX3dir{
ri=i;
rj=j;
rk=rkout;
LOOPBOUND3OUT FBOUNDLOOP(pl) MACP0A1(prim,i,j,k,pl) = MACP0A1(prim,ri,rj,rk+(rk-k+1),pl);
}
}
}
return (0);
}