Skip to content

Commit 4ad7a41

Browse files
authored
DRY m_check_patches & m_check_ib_patches (#607)
1 parent 0c345ea commit 4ad7a41

File tree

2 files changed

+279
-648
lines changed

2 files changed

+279
-648
lines changed

src/pre_process/m_check_ib_patches.fpp

Lines changed: 53 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
!> @brief This module contains subroutines that read, and check consistency
22
!! of, the user provided inputs and data.
3+
4+
#:include 'macros.fpp'
5+
36
module m_check_ib_patches
47

58
! Dependencies =============================================================
@@ -40,6 +43,7 @@ contains
4043
if (i <= num_ibs) then
4144
! call s_check_patch_geometry(i)
4245
call s_int_to_str(i, iStr)
46+
4347
! Constraints on the geometric initial condition patch parameters
4448
if (patch_ib(i)%geometry == 2) then
4549
call s_check_circle_ib_patch_geometry(i)
@@ -50,21 +54,24 @@ contains
5054
else if (patch_ib(i)%geometry == 4) then
5155
call s_check_airfoil_ib_patch_geometry(i)
5256
else if (patch_ib(i)%geometry == 11) then
53-
call s_check_3D_airfoil_ib_patch_geometry(i)
57+
call s_check_3d_airfoil_ib_patch_geometry(i)
5458
else if (patch_ib(i)%geometry == 10) then
5559
call s_check_cylinder_ib_patch_geometry(i)
60+
else if (patch_ib(i)%geometry == dflt_int) then
61+
call s_prohibit_abort("IB patch undefined", &
62+
"patch_ib("//trim(iStr)//")%geometry must be set.")
5663
else
57-
call s_mpi_abort('Unsupported choice of the '// &
58-
'geometry of active patch '//trim(iStr)// &
59-
' detected. Exiting ...')
64+
call s_prohibit_abort("Invalid IB patch", &
65+
"patch_ib("//trim(iStr)//")%geometry must be "// &
66+
"2-4, 8, 10, or 11.")
6067
end if
6168
else
6269
if (patch_ib(i)%geometry == dflt_int) then
6370
call s_check_inactive_ib_patch_geometry(i)
6471
else
65-
call s_mpi_abort('Unsupported choice of the '// &
66-
'geometry of inactive patch '//trim(iStr)// &
67-
' detected. Exiting ...')
72+
call s_prohibit_abort("Inactive IB patch defined", &
73+
"patch_ib("//trim(iStr)//")%geometry "// &
74+
"must not be set for inactive patches.")
6875
end if
6976
end if
7077
end do
@@ -81,18 +88,11 @@ contains
8188

8289
call s_int_to_str(patch_id, iStr)
8390

84-
! Constraints on the geometric parameters of the circle patch
85-
if (n == 0 .or. p > 0 .or. patch_ib(patch_id)%radius <= 0d0 &
86-
.or. &
87-
f_is_default(patch_ib(patch_id)%x_centroid) &
88-
.or. &
89-
f_is_default(patch_ib(patch_id)%y_centroid)) then
90-
91-
call s_mpi_abort('Inconsistency(ies) detected in '// &
92-
'geometric parameters of circle '// &
93-
'patch '//trim(iStr)//'. Exiting ...')
94-
95-
end if
91+
@:PROHIBIT(n == 0 .or. p > 0 &
92+
.or. patch_ib(patch_id)%radius <= 0d0 &
93+
.or. f_is_default(patch_ib(patch_id)%x_centroid) &
94+
.or. f_is_default(patch_ib(patch_id)%y_centroid), &
95+
'in circle IB patch '//trim(iStr))
9696

9797
end subroutine s_check_circle_ib_patch_geometry
9898

@@ -106,17 +106,14 @@ contains
106106

107107
call s_int_to_str(patch_id, iStr)
108108

109-
! Constraints on the geometric parameters of the airfoil patch
110-
if (n == 0 .or. p > 0 .or. patch_ib(patch_id)%c <= 0d0 &
111-
.or. patch_ib(patch_id)%p <= 0d0 .or. patch_ib(patch_id)%t <= 0d0 &
112-
.or. patch_ib(patch_id)%m <= 0d0 .or. f_is_default(patch_ib(patch_id)%x_centroid) &
113-
.or. f_is_default(patch_ib(patch_id)%y_centroid)) then
114-
115-
call s_mpi_abort('Inconsistency(ies) detected in '// &
116-
'geometric parameters of airfoil '// &
117-
'patch '//trim(iStr)//'. Exiting ...')
118-
119-
end if
109+
@:PROHIBIT(n == 0 .or. p > 0 &
110+
.or. patch_ib(patch_id)%c <= 0d0 &
111+
.or. patch_ib(patch_id)%p <= 0d0 &
112+
.or. patch_ib(patch_id)%t <= 0d0 &
113+
.or. patch_ib(patch_id)%m <= 0d0 &
114+
.or. f_is_default(patch_ib(patch_id)%x_centroid) &
115+
.or. f_is_default(patch_ib(patch_id)%y_centroid), &
116+
'in airfoil IB patch '//trim(iStr))
120117

121118
end subroutine s_check_airfoil_ib_patch_geometry
122119

@@ -130,18 +127,16 @@ contains
130127

131128
call s_int_to_str(patch_id, iStr)
132129

133-
! Constraints on the geometric parameters of the 3d airfoil patch
134-
if (n == 0 .or. p == 0 .or. patch_ib(patch_id)%c <= 0d0 &
135-
.or. patch_ib(patch_id)%p <= 0d0 .or. patch_ib(patch_id)%t <= 0d0 &
136-
.or. patch_ib(patch_id)%m <= 0d0 .or. f_is_default(patch_ib(patch_id)%x_centroid) &
137-
.or. f_is_default(patch_ib(patch_id)%y_centroid) .or. f_is_default(patch_ib(patch_id)%z_centroid) &
138-
.or. f_is_default(patch_ib(patch_id)%length_z)) then
139-
140-
call s_mpi_abort('Inconsistency(ies) detected in '// &
141-
'geometric parameters of airfoil '// &
142-
'patch '//trim(iStr)//'. Exiting ...')
143-
144-
end if
130+
@:PROHIBIT(n == 0 .or. p == 0 &
131+
.or. patch_ib(patch_id)%c <= 0d0 &
132+
.or. patch_ib(patch_id)%p <= 0d0 &
133+
.or. patch_ib(patch_id)%t <= 0d0 &
134+
.or. patch_ib(patch_id)%m <= 0d0 &
135+
.or. f_is_default(patch_ib(patch_id)%x_centroid) &
136+
.or. f_is_default(patch_ib(patch_id)%y_centroid) &
137+
.or. f_is_default(patch_ib(patch_id)%z_centroid) &
138+
.or. f_is_default(patch_ib(patch_id)%length_z), &
139+
'in 3d airfoil IB patch '//trim(iStr))
145140

146141
end subroutine s_check_3d_airfoil_ib_patch_geometry
147142

@@ -155,22 +150,16 @@ contains
155150

156151
call s_int_to_str(patch_id, iStr)
157152

158-
! Constraints on the geometric parameters of the rectangle patch
159-
if (n == 0 .or. p > 0 &
153+
@:PROHIBIT(n == 0 .or. p > 0 &
160154
.or. &
161155
f_is_default(patch_ib(patch_id)%x_centroid) &
162156
.or. &
163157
f_is_default(patch_ib(patch_id)%y_centroid) &
164158
.or. &
165159
patch_ib(patch_id)%length_x <= 0d0 &
166160
.or. &
167-
patch_ib(patch_id)%length_y <= 0d0) then
168-
169-
call s_mpi_abort('Inconsistency(ies) detected in '// &
170-
'geometric parameters of rectangle '// &
171-
'patch '//trim(iStr)//'. Exiting ...')
172-
173-
end if
161+
patch_ib(patch_id)%length_y <= 0d0, &
162+
'in rectangle IB patch '//trim(iStr))
174163

175164
end subroutine s_check_rectangle_ib_patch_geometry
176165

@@ -184,22 +173,16 @@ contains
184173

185174
call s_int_to_str(patch_id, iStr)
186175

187-
! Constraints on the geometric parameters of the sphere patch
188-
if (n == 0 .or. p == 0 &
176+
@:PROHIBIT(n == 0 .or. p == 0 &
189177
.or. &
190178
f_is_default(patch_ib(patch_id)%x_centroid) &
191179
.or. &
192180
f_is_default(patch_ib(patch_id)%y_centroid) &
193181
.or. &
194182
f_is_default(patch_ib(patch_id)%z_centroid) &
195183
.or. &
196-
patch_ib(patch_id)%radius <= 0d0) then
197-
198-
call s_mpi_abort('Inconsistency(ies) detected in '// &
199-
'geometric parameters of rectangle '// &
200-
'patch '//trim(iStr)//'. Exiting ...')
201-
202-
end if
184+
patch_ib(patch_id)%radius <= 0d0, &
185+
'in sphere IB patch '//trim(iStr))
203186

204187
end subroutine s_check_sphere_ib_patch_geometry
205188

@@ -213,8 +196,7 @@ contains
213196

214197
call s_int_to_str(patch_id, iStr)
215198

216-
! Constraints on the geometric parameters of the cylinder patch
217-
if (p == 0 &
199+
@:PROHIBIT(p == 0 &
218200
.or. &
219201
f_is_default(patch_ib(patch_id)%x_centroid) &
220202
.or. &
@@ -226,6 +208,10 @@ contains
226208
patch_ib(patch_id)%length_y <= 0d0 .and. &
227209
patch_ib(patch_id)%length_z <= 0d0) &
228210
.or. &
211+
patch_ib(patch_id)%radius <= 0d0, &
212+
'in cylinder IB patch '//trim(iStr))
213+
214+
@:PROHIBIT( &
229215
(patch_ib(patch_id)%length_x > 0d0 .and. &
230216
((.not. f_is_default(patch_ib(patch_id)%length_y)) .or. &
231217
(.not. f_is_default(patch_ib(patch_id)%length_z)))) &
@@ -236,15 +222,8 @@ contains
236222
.or. &
237223
(patch_ib(patch_id)%length_z > 0d0 .and. &
238224
((.not. f_is_default(patch_ib(patch_id)%length_x)) .or. &
239-
(.not. f_is_default(patch_ib(patch_id)%length_y)))) &
240-
.or. &
241-
patch_ib(patch_id)%radius <= 0d0) then
242-
243-
call s_mpi_abort('Inconsistency(ies) detected in '// &
244-
'geometric parameters of cylinder '// &
245-
'patch '//trim(iStr)//'. Exiting ...')
246-
247-
end if
225+
(.not. f_is_default(patch_ib(patch_id)%length_y)))), &
226+
'in cylinder IB patch '//trim(iStr))
248227

249228
end subroutine s_check_cylinder_ib_patch_geometry
250229

@@ -257,8 +236,7 @@ contains
257236

258237
call s_int_to_str(patch_id, iStr)
259238

260-
! Constraints on the geometric parameters of the inactive patch
261-
if ((.not. f_is_default(patch_ib(patch_id)%x_centroid)) &
239+
@:PROHIBIT((.not. f_is_default(patch_ib(patch_id)%x_centroid)) &
262240
.or. &
263241
(.not. f_is_default(patch_ib(patch_id)%y_centroid)) &
264242
.or. &
@@ -270,13 +248,8 @@ contains
270248
.or. &
271249
(.not. f_is_default(patch_ib(patch_id)%length_z)) &
272250
.or. &
273-
(.not. f_is_default(patch_ib(patch_id)%radius))) then
274-
275-
call s_mpi_abort('Inconsistency(ies) detected in '// &
276-
'geometric parameters of inactive '// &
277-
'patch '//trim(iStr)//'. Exiting ...')
278-
279-
end if
251+
(.not. f_is_default(patch_ib(patch_id)%radius)), &
252+
'in inactive IB patch '//trim(iStr))
280253

281254
end subroutine s_check_inactive_ib_patch_geometry
282255

0 commit comments

Comments
 (0)