Skip to content

Commit 6f9ba91

Browse files
committed
Unify geometry IDs for Immersed Boundaries and ICPP Fixes #1543
1 parent 90755b3 commit 6f9ba91

2 files changed

Lines changed: 70 additions & 160 deletions

File tree

src/pre_process/m_check_ib_patches.fpp

Lines changed: 37 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,12 @@ contains
4040
@:PROHIBIT(patch_ib(i)%geometry == dflt_int, "IB patch undefined. patch_ib("//trim(iStr)//")%geometry must be set.")
4141

4242
! Constraints on the geometric initial condition patch parameters
43-
if (patch_ib(i)%geometry == 2) then
43+
if (patch_ib(i)%geometry == 2 .or. patch_ib(i)%geometry == 8 .or. patch_ib(i)%geometry == 10) then
4444
call s_check_circle_ib_patch_geometry(i)
45-
else if (patch_ib(i)%geometry == 3) then
45+
else if (patch_ib(i)%geometry == 3 .or. patch_ib(i)%geometry == 9) then
4646
call s_check_rectangle_ib_patch_geometry(i)
47-
else if (patch_ib(i)%geometry == 8) then
48-
call s_check_sphere_ib_patch_geometry(i)
49-
else if (patch_ib(i)%geometry == 9) then
50-
call s_check_cuboid_ib_patch_geometry(i)
51-
else if (patch_ib(i)%geometry == 4) then
47+
else if (patch_ib(i)%geometry == 4 .or. patch_ib(i)%geometry == 11) then
5248
call s_check_airfoil_ib_patch_geometry(i)
53-
else if (patch_ib(i)%geometry == 11) then
54-
call s_check_3d_airfoil_ib_patch_geometry(i)
55-
else if (patch_ib(i)%geometry == 10) then
56-
call s_check_cylinder_ib_patch_geometry(i)
5749
else if (patch_ib(i)%geometry == 5 .or. patch_ib(i)%geometry == 12) then
5850
call s_check_model_ib_patch_geometry(i)
5951
else if (patch_ib(i)%geometry == 6) then
@@ -80,8 +72,24 @@ contains
8072

8173
call s_int_to_str(patch_id, iStr)
8274

83-
@:PROHIBIT(n == 0 .or. p > 0 .or. patch_ib(patch_id)%radius <= 0._wp .or. f_is_default(patch_ib(patch_id)%x_centroid) &
84-
& .or. f_is_default(patch_ib(patch_id)%y_centroid), 'in circle IB patch ' // trim(iStr))
75+
@:PROHIBIT(n == 0 .or. patch_ib(patch_id)%radius <= 0._wp .or. f_is_default(patch_ib(patch_id)%x_centroid) &
76+
& .or. f_is_default(patch_ib(patch_id)%y_centroid), 'in circle/cylilder/sphere IB patch ' // trim(iStr))
77+
! Additional checks strictly for 3D shapes (Spheres and Cylinders)
78+
if (p > 0) then
79+
! Both Spheres and Cyilders require Z centroid
80+
@:PROHIBIT(f_is_default(patch_ib(patch_id)%z_centroid), 'in 3D sphere/cyilinder IB patch' //trim(iStr))
81+
82+
! If any length is defined, it is a Cylinder. Ensure exactly ONE length is defined.
83+
if (patch_ib(patch_id)%length_x > 0._wp .or. patch_ib(patch_id)%length_y > 0._wp &
84+
& .or. patch_ib(patch_id)%length_z > 0._wp) then
85+
@:PROHIBIT((patch_ib(patch_id)%length_x > 0._wp .and. ((.not. f_is_default(patch_ib(patch_id)%length_y)) &
86+
& .or. (.not. f_is_default(patch_ib(patch_id)%length_z)))) .or. (patch_ib(patch_id)%length_y > 0._wp &
87+
& .and. ((.not. f_is_default(patch_ib(patch_id)%length_x)) &
88+
& .or. (.not. f_is_default(patch_ib(patch_id)%length_z)))) .or. (patch_ib(patch_id)%length_z > 0._wp &
89+
& .and. ((.not. f_is_default(patch_ib(patch_id)%length_x)) &
90+
& .or. (.not. f_is_default(patch_ib(patch_id)%length_y)))), 'in cylinder IB patch ' // trim(iStr))
91+
end if
92+
end if
8593

8694
end subroutine s_check_circle_ib_patch_geometry
8795

@@ -107,33 +115,22 @@ contains
107115

108116
call s_int_to_str(patch_id, iStr)
109117

110-
@:PROHIBIT(n == 0 .or. p > 0 .or. patch_ib(patch_id)%airfoil_id <= 0 &
111-
& .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%c <= 0._wp &
118+
@:PROHIBIT(n == 0 .or. patch_ib(patch_id)%airfoil_id <= 0 .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%c <= 0._wp &
112119
& .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%p <= 0._wp &
113120
& .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%t <= 0._wp &
114121
& .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%m <= 0._wp .or. f_is_default(patch_ib(patch_id)%x_centroid) &
115122
& .or. f_is_default(patch_ib(patch_id)%y_centroid), 'in airfoil IB patch ' // trim(iStr))
116123

124+
! Additional checks strictly for 3D airfoils
125+
if (p > 0) then
126+
@:PROHIBIT(f_is_default(patch_ib(patch_id)%z_centroid) .or. f_is_default(patch_ib(patch_id)%length_z), &
127+
& 'in 3D airfoil IB patch ' // trim(iStr))
128+
end if
129+
117130
end subroutine s_check_airfoil_ib_patch_geometry
118131

119132
!> Verify that the geometric parameters of the 3D airfoil patch have been consistently inputted.
120133

121-
impure subroutine s_check_3d_airfoil_ib_patch_geometry(patch_id)
122-
123-
integer, intent(in) :: patch_id
124-
125-
call s_int_to_str(patch_id, iStr)
126-
127-
@:PROHIBIT(n == 0 .or. p == 0 .or. patch_ib(patch_id)%airfoil_id <= 0 &
128-
& .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%c <= 0._wp &
129-
& .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%p <= 0._wp &
130-
& .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%t <= 0._wp &
131-
& .or. ib_airfoil(patch_ib(patch_id)%airfoil_id)%m <= 0._wp .or. f_is_default(patch_ib(patch_id)%x_centroid) &
132-
& .or. f_is_default(patch_ib(patch_id)%y_centroid) .or. f_is_default(patch_ib(patch_id)%z_centroid) &
133-
& .or. f_is_default(patch_ib(patch_id)%length_z), 'in 3d airfoil IB patch ' // trim(iStr))
134-
135-
end subroutine s_check_3d_airfoil_ib_patch_geometry
136-
137134
!> Verify that the geometric parameters of the rectangle patch have been consistently inputted.
138135

139136
impure subroutine s_check_rectangle_ib_patch_geometry(patch_id)
@@ -142,62 +139,17 @@ contains
142139

143140
call s_int_to_str(patch_id, iStr)
144141

145-
@:PROHIBIT(n == 0 .or. p > 0 .or. f_is_default(patch_ib(patch_id)%x_centroid) &
146-
& .or. f_is_default(patch_ib(patch_id)%y_centroid) .or. patch_ib(patch_id)%length_x <= 0._wp &
147-
& .or. patch_ib(patch_id)%length_y <= 0._wp, 'in rectangle IB patch ' // trim(iStr))
148-
149-
end subroutine s_check_rectangle_ib_patch_geometry
150-
151-
!> Verify that the geometric parameters of the sphere patch have been consistently inputted.
152-
153-
impure subroutine s_check_sphere_ib_patch_geometry(patch_id)
154-
155-
integer, intent(in) :: patch_id
156-
157-
call s_int_to_str(patch_id, iStr)
158-
159-
@:PROHIBIT(n == 0 .or. p == 0 .or. f_is_default(patch_ib(patch_id)%x_centroid) &
160-
& .or. f_is_default(patch_ib(patch_id)%y_centroid) .or. f_is_default(patch_ib(patch_id)%z_centroid) &
161-
& .or. patch_ib(patch_id)%radius <= 0._wp, 'in sphere IB patch ' // trim(iStr))
162-
163-
end subroutine s_check_sphere_ib_patch_geometry
164-
165-
!> Verify that the geometric parameters of the cuboid patch have been consistently inputted.
166-
167-
impure subroutine s_check_cuboid_ib_patch_geometry(patch_id)
168-
169-
integer, intent(in) :: patch_id
170-
171-
call s_int_to_str(patch_id, iStr)
172-
173-
@:PROHIBIT(n == 0 .or. p == 0 .or. f_is_default(patch_ib(patch_id)%x_centroid) &
174-
& .or. f_is_default(patch_ib(patch_id)%y_centroid) .or. f_is_default(patch_ib(patch_id)%z_centroid) &
175-
& .or. patch_ib(patch_id)%length_x <= 0._wp .or. patch_ib(patch_id)%length_y <= 0._wp &
176-
& .or. patch_ib(patch_id)%length_z <= 0._wp, 'in cuboid IB patch ' // trim(iStr))
142+
@:PROHIBIT(n == 0 .or. f_is_default(patch_ib(patch_id)%x_centroid) .or. f_is_default(patch_ib(patch_id)%y_centroid) &
143+
& .or. patch_ib(patch_id)%length_x <= 0._wp .or. patch_ib(patch_id)%length_y <= 0._wp, &
144+
& 'in rectangle/cuboid IB patch ' // trim(iStr))
177145

178-
end subroutine s_check_cuboid_ib_patch_geometry
146+
! If the simulation is 3D, also mandate Z lengths and centroids
147+
if (p > 0) then
148+
@:PROHIBIT(f_is_default(patch_ib(patch_id)%z_centroid) .or. patch_ib(patch_id)%length_z <= 0._wp, &
149+
& 'in 3D cuboid IB patch ' // trim(iStr))
150+
end if
179151

180-
!> Verify that the geometric parameters of the cylinder patch have been consistently inputted.
181-
182-
impure subroutine s_check_cylinder_ib_patch_geometry(patch_id)
183-
184-
integer, intent(in) :: patch_id
185-
186-
call s_int_to_str(patch_id, iStr)
187-
188-
@:PROHIBIT(p == 0 .or. f_is_default(patch_ib(patch_id)%x_centroid) .or. f_is_default(patch_ib(patch_id)%y_centroid) &
189-
& .or. f_is_default(patch_ib(patch_id)%z_centroid) .or. (patch_ib(patch_id)%length_x <= 0._wp &
190-
& .and. patch_ib(patch_id)%length_y <= 0._wp .and. patch_ib(patch_id)%length_z <= 0._wp) &
191-
& .or. patch_ib(patch_id)%radius <= 0._wp, 'in cylinder IB patch ' // trim(iStr))
192-
193-
@:PROHIBIT((patch_ib(patch_id)%length_x > 0._wp .and. ((.not. f_is_default(patch_ib(patch_id)%length_y)) &
194-
& .or. (.not. f_is_default(patch_ib(patch_id)%length_z)))) .or. (patch_ib(patch_id)%length_y > 0._wp &
195-
& .and. ((.not. f_is_default(patch_ib(patch_id)%length_x)) &
196-
& .or. (.not. f_is_default(patch_ib(patch_id)%length_z)))) .or. (patch_ib(patch_id)%length_z > 0._wp &
197-
& .and. ((.not. f_is_default(patch_ib(patch_id)%length_x)) &
198-
& .or. (.not. f_is_default(patch_ib(patch_id)%length_y)))), 'in cylinder IB patch ' // trim(iStr))
199-
200-
end subroutine s_check_cylinder_ib_patch_geometry
152+
end subroutine s_check_rectangle_ib_patch_geometry
201153

202154
!> Verify that the geometric parameters of the model patch have been consistently inputted.
203155

src/pre_process/m_check_patches.fpp

Lines changed: 33 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,14 @@ contains
5454
! Constraints on the geometric initial condition patch parameters
5555
if (patch_icpp(i)%geometry == 1) then
5656
call s_check_line_segment_patch_geometry(i)
57-
else if (patch_icpp(i)%geometry == 2) then
57+
else if (patch_icpp(i)%geometry == 2 .or. patch_icpp(i)%geometry == 8 .or. patch_icpp(i)%geometry == 10) then
5858
call s_check_circle_patch_geometry(i)
59-
else if (patch_icpp(i)%geometry == 3) then
59+
else if (patch_icpp(i)%geometry == 3 .or. patch_icpp(i)%geometry == 9) then
6060
call s_check_rectangle_patch_geometry(i)
6161
else if (patch_icpp(i)%geometry == 4) then
6262
call s_check_line_sweep_patch_geometry(i)
6363
else if (patch_icpp(i)%geometry == 5) then
6464
call s_check_ellipse_patch_geometry(i)
65-
else if (patch_icpp(i)%geometry == 8) then
66-
call s_check_sphere_patch_geometry(i)
67-
else if (patch_icpp(i)%geometry == 9) then
68-
call s_check_cuboid_patch_geometry(i)
69-
else if (patch_icpp(i)%geometry == 10) then
70-
call s_check_cylinder_patch_geometry(i)
7165
else if (patch_icpp(i)%geometry == 11) then
7266
call s_check_plane_sweep_patch_geometry(i)
7367
else if (patch_icpp(i)%geometry == 12) then
@@ -147,11 +141,30 @@ contains
147141

148142
call s_int_to_str(patch_id, iStr)
149143

150-
@:PROHIBIT(n == 0, "Circle patch "//trim(iStr)//": n must be zero")
151-
@:PROHIBIT(p > 0, "Circle patch "//trim(iStr)//": p must be greater than zero")
152-
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "Circle patch "//trim(iStr)//": radius must be greater than zero")
153-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Circle patch "//trim(iStr)//": x_centroid must be set")
154-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Circle patch "//trim(iStr)//": y_centroid must be set")
144+
! Core checks for all (Circle, Sphere, Cylinder)
145+
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), &
146+
& "Circle/Sphere/Cylinder patch "//trim(iStr)//": x_centroid must be set")
147+
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), &
148+
& "Circle/Sphere/Cylinder patch "//trim(iStr)//": y_centroid must be set")
149+
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, &
150+
& "Circle/Sphere/Cylinder patch "//trim(iStr)//": radius must be greater than zero")
151+
152+
! 3D-specific checks (Spheres and Cylinders)
153+
if (p > 0) then
154+
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), &
155+
& "3D Sphere/Cylinder patch "//trim(iStr)//": z_centroid must be set")
156+
157+
! If any extrusion length is set, it's a Cylinder. Verify exactly ONE length axis is defined.
158+
if (patch_icpp(patch_id)%length_x > 0._wp .or. patch_icpp(patch_id)%length_y > 0._wp &
159+
& .or. patch_icpp(patch_id)%length_z > 0._wp) then
160+
@:PROHIBIT((patch_icpp(patch_id)%length_x > 0._wp .and. ((.not. f_is_default(patch_icpp(patch_id)%length_y)) &
161+
& .or. (.not. f_is_default(patch_icpp(patch_id)%length_z)))) &
162+
& .or. (patch_icpp(patch_id)%length_y > 0._wp .and. ((.not. f_is_default(patch_icpp(patch_id)%length_x) &
163+
& ) .or. (.not. f_is_default(patch_icpp(patch_id)%length_z)))) &
164+
& .or. (patch_icpp(patch_id)%length_z > 0._wp .and. ((.not. f_is_default(patch_icpp(patch_id)%length_x) &
165+
& ) .or. (.not. f_is_default(patch_icpp(patch_id)%length_y)))), 'in cylinder patch ' // trim(iStr))
166+
end if
167+
end if
155168
156169
end subroutine s_check_circle_patch_geometry
157170
@@ -163,12 +176,18 @@ contains
163176
call s_int_to_str(patch_id, iStr)
164177
165178
@:PROHIBIT(n == 0, "Rectangle patch "//trim(iStr)//": n must be greater than zero")
166-
@:PROHIBIT(p > 0, "Rectangle patch "//trim(iStr)//": p must be zero")
167179
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Rectangle patch "//trim(iStr)//": x_centroid must be set")
168180
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Rectangle patch "//trim(iStr)//": y_centroid must be set")
169181
@:PROHIBIT(patch_icpp(patch_id)%length_x <= 0._wp, "Rectangle patch "//trim(iStr)//": length_x must be greater than zero")
170182
@:PROHIBIT(patch_icpp(patch_id)%length_y <= 0._wp, "Rectangle patch "//trim(iStr)//": length_y must be greater than zero")
171183
184+
! 3D checks:
185+
if (p > 0) then
186+
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "3D Cuboid patch "//trim(iStr)//": z_centroid must be set")
187+
@:PROHIBIT(patch_icpp(patch_id)%length_z <= 0._wp, &
188+
& "3D Cuboid patch "//trim(iStr)//": length_z must be greater than zero")
189+
end if
190+
172191
end subroutine s_check_rectangle_patch_geometry
173192
174193
!> Check the line sweep patch input
@@ -228,21 +247,6 @@ contains
228247
229248
end subroutine s_check_2D_TaylorGreen_vortex_patch_geometry
230249
231-
!> Check the model patch input
232-
impure subroutine s_check_sphere_patch_geometry(patch_id)
233-
234-
integer, intent(in) :: patch_id
235-
236-
call s_int_to_str(patch_id, iStr)
237-
238-
@:PROHIBIT(p == 0, "Sphere patch "//trim(iStr)//": p must be greater than zero")
239-
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "Sphere patch "//trim(iStr)//": radius must be greater than zero")
240-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Sphere patch "//trim(iStr)//": x_centroid must be set")
241-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Sphere patch "//trim(iStr)//": y_centroid must be set")
242-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Sphere patch "//trim(iStr)//": z_centroid must be set")
243-
244-
end subroutine s_check_sphere_patch_geometry
245-
246250
!> Validate geometry parameters for a 2D modal (Fourier) patch
247251
impure subroutine s_check_2d_modal_patch_geometry(patch_id)
248252
@@ -277,52 +281,6 @@ contains
277281
278282
end subroutine s_check_3d_spherical_harmonic_patch_geometry
279283
280-
!> Check the model patch input
281-
impure subroutine s_check_cuboid_patch_geometry(patch_id)
282-
283-
! Patch identifier
284-
integer, intent(in) :: patch_id
285-
286-
call s_int_to_str(patch_id, iStr)
287-
288-
@:PROHIBIT(p == 0, "Cuboid patch "//trim(iStr)//": p must be greater than zero")
289-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Cuboid patch "//trim(iStr)//": x_centroid must be set")
290-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Cuboid patch "//trim(iStr)//": y_centroid must be set")
291-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Cuboid patch "//trim(iStr)//": z_centroid must be set")
292-
@:PROHIBIT(patch_icpp(patch_id)%length_x <= 0._wp, "Cuboid patch "//trim(iStr)//": length_x must be greater than zero")
293-
@:PROHIBIT(patch_icpp(patch_id)%length_y <= 0._wp, "Cuboid patch "//trim(iStr)//": length_y must be greater than zero")
294-
@:PROHIBIT(patch_icpp(patch_id)%length_z <= 0._wp, "Cuboid patch "//trim(iStr)//": length_z must be greater than zero")
295-
296-
end subroutine s_check_cuboid_patch_geometry
297-
298-
!> Check the model patch input
299-
impure subroutine s_check_cylinder_patch_geometry(patch_id)
300-
301-
! Patch identifier
302-
integer, intent(in) :: patch_id
303-
304-
call s_int_to_str(patch_id, iStr)
305-
306-
@:PROHIBIT(p == 0, "Cylinder patch "//trim(iStr)//": p must be greater than zero")
307-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%x_centroid), "Cylinder patch "//trim(iStr)//": x_centroid must be set")
308-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%y_centroid), "Cylinder patch "//trim(iStr)//": y_centroid must be set")
309-
@:PROHIBIT(f_is_default(patch_icpp(patch_id)%z_centroid), "Cylinder patch "//trim(iStr)//": z_centroid must be set")
310-
@:PROHIBIT(patch_icpp(patch_id)%radius <= 0._wp, "Cylinder patch "//trim(iStr)//": radius must be greater than zero")
311-
312-
! Check if exactly one length is defined
313-
@:PROHIBIT(count([patch_icpp(patch_id)%length_x > 0._wp, patch_icpp(patch_id)%length_y > 0._wp, &
314-
& patch_icpp(patch_id)%length_z > 0._wp]) /= 1, &
315-
& "Cylinder patch " // trim(iStr) &
316-
& // ": Exactly one of length_x, length_y, or length_z must be defined and positive")
317-
318-
! Ensure the defined length is positive
319-
@:PROHIBIT((.not. f_is_default(patch_icpp(patch_id)%length_x) .and. patch_icpp(patch_id)%length_x <= 0._wp) &
320-
& .or. (.not. f_is_default(patch_icpp(patch_id)%length_y) .and. patch_icpp(patch_id)%length_y <= 0._wp) &
321-
& .or. (.not. f_is_default(patch_icpp(patch_id)%length_z) .and. patch_icpp(patch_id)%length_z <= 0._wp), &
322-
& "Cylinder patch " // trim(iStr) // ": The defined length_{} must be greater than zero")
323-
324-
end subroutine s_check_cylinder_patch_geometry
325-
326284
!> Check the model patch input
327285
impure subroutine s_check_plane_sweep_patch_geometry(patch_id)
328286

0 commit comments

Comments
 (0)