-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathm_check_patches.fpp
More file actions
542 lines (411 loc) · 29.7 KB
/
m_check_patches.fpp
File metadata and controls
542 lines (411 loc) · 29.7 KB
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
!>
!! @file
!! @brief Contains module m_check_patches
#:include 'macros.fpp'
!> @brief Validates geometry parameters and constraints for initial condition patches
#:include 'macros.fpp'
module m_check_patches
! Dependencies
use m_derived_types
use m_global_parameters
use m_mpi_proxy
use m_data_output
#ifdef MFC_MPI
use mpi !< Message passing interface (MPI) module
#endif
use m_compile_specific
use m_helper_basic
use m_helper
implicit none
private; public :: s_check_patches
character(len=10) :: iStr
contains
!> Validate the geometry parameters of all active and inactive initial condition patches.
impure subroutine s_check_patches
integer :: i
character(len=10) :: num_patches_str
call s_int_to_str(num_patches, num_patches_str)
do i = 1, num_patches_max
if (i <= num_patches) then
call s_int_to_str(i, iStr)
@:PROHIBIT(patch_icpp(i)%geometry == 6, &
& "Invalid patch geometry number. " // "patch_icpp(" // trim(iStr) // ")%geometry is deprecated.")
@:PROHIBIT(patch_icpp(i)%geometry == 7, &
& "Invalid patch geometry number. " // "patch_icpp(" // trim(iStr) // ")%geometry is deprecated.")
@:PROHIBIT(patch_icpp(i)%geometry == 15, &
& "Invalid patch geometry number. " // "patch_icpp(" // trim(iStr) // ")%geometry is deprecated.")
@:PROHIBIT(patch_icpp(i)%geometry == dflt_int, &
& "Invalid patch geometry number. " // "patch_icpp(" // trim(iStr) // ")%geometry must be set.")
! Constraints on the geometric initial condition patch parameters
if (patch_icpp(i)%geometry == 1) then
call s_check_line_segment_patch_geometry(i)
else if (patch_icpp(i)%geometry == 2) then
call s_check_circle_patch_geometry(i)
else if (patch_icpp(i)%geometry == 3) then
call s_check_rectangle_patch_geometry(i)
else if (patch_icpp(i)%geometry == 4) then
call s_check_line_sweep_patch_geometry(i)
else if (patch_icpp(i)%geometry == 5) then
call s_check_ellipse_patch_geometry(i)
else if (patch_icpp(i)%geometry == 8) then
call s_check_sphere_patch_geometry(i)
else if (patch_icpp(i)%geometry == 9) then
call s_check_cuboid_patch_geometry(i)
else if (patch_icpp(i)%geometry == 10) then
call s_check_cylinder_patch_geometry(i)
else if (patch_icpp(i)%geometry == 11) then
call s_check_plane_sweep_patch_geometry(i)
else if (patch_icpp(i)%geometry == 12) then
call s_check_ellipsoid_patch_geometry(i)
else if (patch_icpp(i)%geometry == 13) then
call s_check_2d_modal_patch_geometry(i)
else if (patch_icpp(i)%geometry == 14) then
call s_check_3d_spherical_harmonic_patch_geometry(i)
else if (patch_icpp(i)%geometry == 20) then
call s_check_2D_TaylorGreen_vortex_patch_geometry(i)
else if (patch_icpp(i)%geometry == 21) then
call s_check_model_geometry(i)
else
call s_prohibit_abort("Invalid patch geometry number", &
& "patch_icpp(" // trim(iStr) // ")%geometry " // "must be between 1 and 21")
end if
else
@:PROHIBIT(patch_icpp(i)%geometry /= dflt_int, &
& "Inactive patch defined. " // "patch_icpp(" // trim(iStr) &
& // ")%geometry not be set for inactive patches. " // "Patch " // trim(iStr) &
& // " is inactive as the number of patches is " // trim(num_patches_str))
call s_check_inactive_patch_geometry(i)
end if
end do
! Constraints on overwrite rights initial condition patch parameters
do i = 1, num_patches
if (i <= num_patches) then
call s_check_active_patch_alteration_rights(i)
else
call s_check_inactive_patch_alteration_rights(i)
end if
end do
! Constraints on smoothing initial condition patch parameters
do i = 1, num_patches
if (i > 1 .and. (patch_icpp(i)%geometry == 2 .or. patch_icpp(i)%geometry == 3 .or. patch_icpp(i)%geometry == 4 &
& .or. patch_icpp(i)%geometry == 5 .or. patch_icpp(i)%geometry == 8 .or. patch_icpp(i)%geometry == 9 &
& .or. patch_icpp(i)%geometry == 10 .or. patch_icpp(i)%geometry == 11 .or. patch_icpp(i)%geometry == 12 &
& .or. patch_icpp(i)%geometry == 13 .or. patch_icpp(i)%geometry == 14)) then
call s_check_supported_patch_smoothing(i)
else
call s_check_unsupported_patch_smoothing(i)
end if
end do
! Constraints on flow variables initial condition patch parameters
do i = 1, num_patches
if (i <= num_patches) then
call s_check_active_patch_primitive_variables(i)
else
call s_check_inactive_patch_primitive_variables(i)
end if
end do
end subroutine s_check_patches
!> Check the line segment patch input
impure subroutine s_check_line_segment_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(n > 0, "Line segment patch "//trim(iStr)//": n must be zero")
@:PROHIBIT(patch_icpp(patch_id)%length_x <= 0._wp, &
& "Line segment patch " // trim(iStr) // ": length_x must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Line segment patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(cyl_coord, "Line segment patch "//trim(iStr)//": cyl_coord is not supported")
end subroutine s_check_line_segment_patch_geometry
!> Check the circle patch input
impure subroutine s_check_circle_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(n == 0, "Circle patch "//trim(iStr)//": n must be zero")
@:PROHIBIT(p > 0, "Circle patch "//trim(iStr)//": p must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "Circle patch "//trim(iStr)//": radius must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Circle patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Circle patch "//trim(iStr)//": y_centroid must be set")
end subroutine s_check_circle_patch_geometry
!> Check the rectangle patch input
impure subroutine s_check_rectangle_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(n == 0, "Rectangle patch "//trim(iStr)//": n must be greater than zero")
@:PROHIBIT(p > 0, "Rectangle patch "//trim(iStr)//": p must be zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Rectangle patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Rectangle patch "//trim(iStr)//": y_centroid must be set")
@:PROHIBIT(patch_icpp(patch_id)%length_x <= 0._wp, "Rectangle patch "//trim(iStr)//": length_x must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%length_y <= 0._wp, "Rectangle patch "//trim(iStr)//": length_y must be greater than zero")
end subroutine s_check_rectangle_patch_geometry
!> Check the line sweep patch input
impure subroutine s_check_line_sweep_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(n == 0, "Line sweep patch "//trim(iStr)//": n must be greater than zero")
@:PROHIBIT(p > 0, "Line sweep patch "//trim(iStr)//": p must be zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Line sweep patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Line sweep patch "//trim(iStr)//": y_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%normal(1)), "Line sweep patch "//trim(iStr)//": normal(1) must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%normal(2)), "Line sweep patch "//trim(iStr)//": normal(2) must be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%normal(3)), &
& "Line sweep patch " // trim(iStr) // ": normal(3) must not be set")
end subroutine s_check_line_sweep_patch_geometry
!> Check the ellipse patch input
impure subroutine s_check_ellipse_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(n == 0, "Ellipse patch "//trim(iStr)//": n must be greater than zero")
@:PROHIBIT(p > 0, "Ellipse patch "//trim(iStr)//": p must be zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Ellipse patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Ellipse patch "//trim(iStr)//": y_centroid must be set")
@:PROHIBIT(patch_icpp(patch_id)%radii(1) <= 0._wp, "Ellipse patch "//trim(iStr)//": radii(1) must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%radii(2) <= 0._wp, "Ellipse patch "//trim(iStr)//": radii(2) must be greater than zero")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%radii(3)), "Ellipse patch "//trim(iStr)//": radii(3) must not be set")
end subroutine s_check_ellipse_patch_geometry
!> Check the model patch input
impure subroutine s_check_2D_TaylorGreen_vortex_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(n == 0, "Taylor Green vortex patch "//trim(iStr)//": n must be greater than zero")
@:PROHIBIT(p > 0, "Taylor Green vortex patch "//trim(iStr)//": p must be zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), &
& "Taylor Green vortex patch " // trim(iStr) // ": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), &
& "Taylor Green vortex patch " // trim(iStr) // ": y_centroid must be set")
@:PROHIBIT(patch_icpp(patch_id)%length_x <= 0._wp, &
& "Taylor Green vortex patch " // trim(iStr) // ": length_x must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%length_y <= 0._wp, &
& "Taylor Green vortex patch " // trim(iStr) // ": length_y must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%vel(2) <= 0._wp, &
& "Taylor Green vortex patch " // trim(iStr) // ": vel(2) must be greater than zero")
end subroutine s_check_2D_TaylorGreen_vortex_patch_geometry
!> Check the model patch input
impure subroutine s_check_sphere_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(p == 0, "Sphere patch "//trim(iStr)//": p must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "Sphere patch "//trim(iStr)//": radius must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Sphere patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Sphere patch "//trim(iStr)//": y_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Sphere patch "//trim(iStr)//": z_centroid must be set")
end subroutine s_check_sphere_patch_geometry
!> Validate geometry parameters for a 2D modal (Fourier) patch
impure subroutine s_check_2d_modal_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(n == 0, "2D modal patch "//trim(iStr)//": n must be greater than zero")
@:PROHIBIT(p > 0, "2D modal patch "//trim(iStr)//": p must be zero")
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "2D modal patch "//trim(iStr)//": radius must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "2D modal patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "2D modal patch "//trim(iStr)//": y_centroid must be set")
end subroutine s_check_2d_modal_patch_geometry
!> Validate geometry parameters for a 3D spherical harmonic patch
impure subroutine s_check_3d_spherical_harmonic_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(p == 0, "Spherical harmonic patch "//trim(iStr)//": p must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, &
& "Spherical harmonic patch " // trim(iStr) // ": radius must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), &
& "Spherical harmonic patch " // trim(iStr) // ": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), &
& "Spherical harmonic patch " // trim(iStr) // ": y_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), &
& "Spherical harmonic patch " // trim(iStr) // ": z_centroid must be set")
end subroutine s_check_3d_spherical_harmonic_patch_geometry
!> Check the model patch input
impure subroutine s_check_cuboid_patch_geometry(patch_id)
! Patch identifier
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(p == 0, "Cuboid patch "//trim(iStr)//": p must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Cuboid patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Cuboid patch "//trim(iStr)//": y_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Cuboid patch "//trim(iStr)//": z_centroid must be set")
@:PROHIBIT(patch_icpp(patch_id)%length_x <= 0._wp, "Cuboid patch "//trim(iStr)//": length_x must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%length_y <= 0._wp, "Cuboid patch "//trim(iStr)//": length_y must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%length_z <= 0._wp, "Cuboid patch "//trim(iStr)//": length_z must be greater than zero")
end subroutine s_check_cuboid_patch_geometry
!> Check the model patch input
impure subroutine s_check_cylinder_patch_geometry(patch_id)
! Patch identifier
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(p == 0, "Cylinder patch "//trim(iStr)//": p must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Cylinder patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Cylinder patch "//trim(iStr)//": y_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Cylinder patch "//trim(iStr)//": z_centroid must be set")
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "Cylinder patch "//trim(iStr)//": radius must be greater than zero")
! Check if exactly one length is defined
@:PROHIBIT(count([patch_icpp(patch_id)%length_x > 0._wp, patch_icpp(patch_id)%length_y > 0._wp, &
& patch_icpp(patch_id)%length_z > 0._wp]) /= 1, &
& "Cylinder patch " // trim(iStr) &
& // ": Exactly one of length_x, length_y, or length_z must be defined and positive")
! Ensure the defined length is positive
@:PROHIBIT((.not. f_is_default(patch_icpp(patch_id)%length_x) .and. patch_icpp(patch_id)%length_x <= 0._wp) &
& .or. (.not. f_is_default(patch_icpp(patch_id)%length_y) .and. patch_icpp(patch_id)%length_y <= 0._wp) &
& .or. (.not. f_is_default(patch_icpp(patch_id)%length_z) .and. patch_icpp(patch_id)%length_z <= 0._wp), &
& "Cylinder patch " // trim(iStr) // ": The defined length_{} must be greater than zero")
end subroutine s_check_cylinder_patch_geometry
!> Check the model patch input
impure subroutine s_check_plane_sweep_patch_geometry(patch_id)
! Patch identifier
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(p == 0, "Plane sweep patch "//trim(iStr)//": p must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Plane sweep patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Plane sweep patch "//trim(iStr)//": y_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Plane sweep patch "//trim(iStr)//": z_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%normal(1)), "Plane sweep patch "//trim(iStr)//": normal(1) must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%normal(2)), "Plane sweep patch "//trim(iStr)//": normal(2) must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%normal(3)), "Plane sweep patch "//trim(iStr)//": normal(3) must be set")
end subroutine s_check_plane_sweep_patch_geometry
!> Check the model patch input
impure subroutine s_check_ellipsoid_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(p == 0, "Ellipsoid patch "//trim(iStr)//": p must be greater than zero")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Ellipsoid patch "//trim(iStr)//": x_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Ellipsoid patch "//trim(iStr)//": y_centroid must be set")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Ellipsoid patch "//trim(iStr)//": z_centroid must be set")
@:PROHIBIT(patch_icpp(patch_id)%radii(1) <= 0._wp, "Ellipsoid patch "//trim(iStr)//": radii(1) must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%radii(2) <= 0._wp, "Ellipsoid patch "//trim(iStr)//": radii(2) must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%radii(3) <= 0._wp, "Ellipsoid patch "//trim(iStr)//": radii(3) must be greater than zero")
end subroutine s_check_ellipsoid_patch_geometry
!> Verify that inactive patch geometry parameters remain at defaults
impure subroutine s_check_inactive_patch_geometry(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%x_centroid), &
& "Inactive patch " // trim(iStr) // ": x_centroid must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%y_centroid), &
& "Inactive patch " // trim(iStr) // ": y_centroid must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%z_centroid), &
& "Inactive patch " // trim(iStr) // ": z_centroid must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%length_x), "Inactive patch "//trim(iStr)//": length_x must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%length_y), "Inactive patch "//trim(iStr)//": length_y must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%length_z), "Inactive patch "//trim(iStr)//": length_z must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%radius), "Inactive patch "//trim(iStr)//": radius must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%epsilon), "Inactive patch "//trim(iStr)//": epsilon must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%beta), "Inactive patch "//trim(iStr)//": beta must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%normal(1)), "Inactive patch "//trim(iStr)//": normal(1) must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%normal(2)), "Inactive patch "//trim(iStr)//": normal(2) must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%normal(3)), "Inactive patch "//trim(iStr)//": normal(3) must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%radii(1)), "Inactive patch "//trim(iStr)//": radii(1) must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%radii(2)), "Inactive patch "//trim(iStr)//": radii(2) must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%radii(3)), "Inactive patch "//trim(iStr)//": radii(3) must not be set")
end subroutine s_check_inactive_patch_geometry
!> Verify the active patch's right to overwrite the preceding patches
impure subroutine s_check_active_patch_alteration_rights(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(.not. patch_icpp(patch_id)%alter_patch(0), "Patch "//trim(iStr)//": alter_patch(0) must be true")
@:PROHIBIT(any(patch_icpp(patch_id)%alter_patch(patch_id:)), &
& "Patch " // trim(iStr) // ":alter_patch(i) must be false for i >= " // trim(iStr) &
& // ". Only preceding patches can be altered")
end subroutine s_check_active_patch_alteration_rights
!> Verify that inactive patches cannot overwrite other patches
impure subroutine s_check_inactive_patch_alteration_rights(patch_id)
! Patch identifier
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(.not. patch_icpp(patch_id)%alter_patch(0), "Inactive patch "//trim(iStr)//": cannot have alter_patch(0) altered")
@:PROHIBIT(any(patch_icpp(patch_id)%alter_patch(1:)), &
& "Inactive patch " // trim(iStr) // ": cannot have any alter_patch(i) enabled")
end subroutine s_check_inactive_patch_alteration_rights
!> Check the smoothing parameters
impure subroutine s_check_supported_patch_smoothing(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
if (patch_icpp(patch_id)%smoothen) then
@:PROHIBIT(patch_icpp(patch_id)%smooth_patch_id >= patch_id, &
& "Smoothen enabled. Patch " // trim(iStr) // ": smooth_patch_id must be less than patch_id")
@:PROHIBIT(patch_icpp(patch_id)%smooth_patch_id == 0, &
& "Smoothen enabled. Patch " // trim(iStr) // ": smooth_patch_id must be greater than zero")
@:PROHIBIT(patch_icpp(patch_id)%smooth_coeff <= 0._wp, &
& "Smoothen enabled. Patch " // trim(iStr) // ": smooth_coeff must be greater than zero")
else
@:PROHIBIT(patch_icpp(patch_id)%smooth_patch_id /= patch_id, &
& "Smoothen disabled. Patch " // trim(iStr) // ": smooth_patch_id must be equal to patch_id")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%smooth_coeff), &
& "Smoothen disabled. Patch " // trim(iStr) // ": smooth_coeff must not be set")
end if
end subroutine s_check_supported_patch_smoothing
!> Verify that inactive patches cannot be smoothed
impure subroutine s_check_unsupported_patch_smoothing(patch_id)
! Patch identifier
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(patch_icpp(patch_id)%smoothen, "Inactive patch "//trim(iStr)//": cannot have smoothen enabled")
@:PROHIBIT(patch_icpp(patch_id)%smooth_patch_id /= patch_id, &
& "Inactive patch " // trim(iStr) // ": smooth_patch_id must be equal to patch_id")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%smooth_coeff), &
& "Inactive patch " // trim(iStr) // ": smooth_coeff must not be set")
end subroutine s_check_unsupported_patch_smoothing
!> Check the primitive variables
impure subroutine s_check_active_patch_primitive_variables(patch_id)
integer, intent(in) :: patch_id
logical, dimension(3) :: is_set_B
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%vel(1)), "Patch "//trim(iStr)//": vel(1) must be set")
@:PROHIBIT(n == 0 .and. (.not. f_is_default(patch_icpp(patch_id)%vel(2))) &
& .and. (.not. f_approx_equal(patch_icpp(patch_id)%vel(2), 0._wp)) .and. (.not. mhd), &
& "Patch " // trim(iStr) // ": vel(2) must not be set when n = 0")
@:PROHIBIT(n > 0 .and. f_is_default(patch_icpp(patch_id)%vel(2)), "Patch "//trim(iStr)//": vel(2) must be set when n > 0")
@:PROHIBIT(p == 0 .and. (.not. f_is_default(patch_icpp(patch_id)%vel(3))) &
& .and. (.not. f_approx_equal(patch_icpp(patch_id)%vel(3), 0._wp)) .and. (.not. mhd), &
& "Patch " // trim(iStr) // ": vel(3) must not be set when p = 0")
@:PROHIBIT(p > 0 .and. f_is_default(patch_icpp(patch_id)%vel(3)), "Patch "//trim(iStr)//": vel(3) must be set when p > 0")
@:PROHIBIT(mhd .and. (f_is_default(patch_icpp(patch_id)%vel(2)) .or. f_is_default(patch_icpp(patch_id)%vel(3))), &
& "Patch " // trim(iStr) // ": All velocities (vel(1:3)) must be set when mhd = true")
@:PROHIBIT(model_eqns == 1 .and. patch_icpp(patch_id)%rho <= 0._wp, &
& "Patch " // trim(iStr) // ": rho must be greater than zero when model_eqns = 1")
@:PROHIBIT(model_eqns == 1 .and. patch_icpp(patch_id)%gamma <= 0._wp, &
& "Patch " // trim(iStr) // ": gamma must be greater than zero when model_eqns = 1")
@:PROHIBIT(model_eqns == 1 .and. patch_icpp(patch_id)%pi_inf < 0._wp, &
& "Patch " // trim(iStr) // ": pi_inf must be greater than or equal to zero when model_eqns = 1")
@:PROHIBIT(patch_icpp(patch_id)%geometry == 5 .and. patch_icpp(patch_id)%pi_inf > 0, &
& "Patch " // trim(iStr) // ": pi_inf must be less than or equal to zero when geometry = 5")
@:PROHIBIT(model_eqns == 2 .and. any(patch_icpp(patch_id)%alpha_rho(1:num_fluids) < 0._wp), &
& "Patch " // trim(iStr) &
& // ": alpha_rho(1:num_fluids) must be greater than or equal to zero when model_eqns = 2")
is_set_B(1) = .not. f_is_default(patch_icpp(patch_id)%Bx)
is_set_B(2) = .not. f_is_default(patch_icpp(patch_id)%By)
is_set_B(3) = .not. f_is_default(patch_icpp(patch_id)%Bz)
@:PROHIBIT(.not. mhd .and. any(is_set_B), "Bx, By, and Bz must not be set if MHD is not enabled")
@:PROHIBIT(mhd .and. n == 0 .and. is_set_B(1), "Bx must not be set in 1D MHD simulations")
@:PROHIBIT(mhd .and. n > 0 .and. .not. is_set_B(1), "Bx must be set in 2D/3D MHD simulations")
@:PROHIBIT(mhd .and. .not. (is_set_B(2) .and. is_set_B(3)), "By and Bz must be set in all MHD simulations")
if (model_eqns == 2 .and. num_fluids < num_fluids_max) then
@:PROHIBIT(.not. f_all_default(patch_icpp(patch_id)%alpha_rho(num_fluids + 1:)), &
& "Patch " // trim(iStr) // ": alpha_rho(i) must not be set for i > num_fluids")
@:PROHIBIT(.not. f_all_default(patch_icpp(patch_id)%alpha(num_fluids + 1:)), &
& "Patch " // trim(iStr) // ": alpha(i) must not be set for i > num_fluids")
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%alpha(num_fluids)), &
& "Patch " // trim(iStr) // ": alpha(num_fluids) must be set")
end if
if (chemistry) then
end if
end subroutine s_check_active_patch_primitive_variables
!> Verify that the primitive variables associated with the given inactive patch remain unaltered by the user inputs.
impure subroutine s_check_inactive_patch_primitive_variables(patch_id)
integer, intent(in) :: patch_id
call s_int_to_str(patch_id, iStr)
@:PROHIBIT(.not. f_all_default(patch_icpp(patch_id)%alpha_rho), &
& "Inactive patch " // trim(iStr) // ": alpha_rho must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%rho), "Inactive patch "//trim(iStr)//": rho must not be set")
@:PROHIBIT(.not. f_all_default(patch_icpp(patch_id)%vel), "Inactive patch "//trim(iStr)//": vel must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%pres), "Inactive patch "//trim(iStr)//": pres must not be set")
@:PROHIBIT(.not. f_all_default(patch_icpp(patch_id)%alpha), "Inactive patch "//trim(iStr)//": alpha must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%gamma), "Inactive patch "//trim(iStr)//": gamma must not be set")
@:PROHIBIT(.not. f_is_default(patch_icpp(patch_id)%pi_inf), "Inactive patch "//trim(iStr)//": pi_inf must not be set")
end subroutine s_check_inactive_patch_primitive_variables
!> Verify that the model file referenced by the given patch exists on disk.
impure subroutine s_check_model_geometry(patch_id)
integer, intent(in) :: patch_id
logical :: file_exists
inquire (file=patch_icpp(patch_id)%model_filepath, exist=file_exists)
@:PROHIBIT(.not. file_exists, &
& "Model file " // trim(patch_icpp(patch_id)%model_filepath) // " requested by patch " // trim(iStr) &
& // " does not exist")
end subroutine s_check_model_geometry
end module m_check_patches