Skip to content

Commit 579a578

Browse files
committed
Fix STL+IBM test suite and refactor
1 parent 2e4fa7d commit 579a578

File tree

12 files changed

+101
-108
lines changed

12 files changed

+101
-108
lines changed

examples/2D_IBM_STL/case.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
# Dynamic Viscosity
77
Mu1 = 0.0000184
88
#Mu2 = 0.01
9-
rho1 = 1.19 #rho1 = 0.2199
9+
rho1 = 1.19 #0.2199
1010
gam_a = 1.4
1111
# Patch Design
12-
D = 0.01
12+
D = 0.1
1313

1414
# Configuring case dictionary
1515
print(json.dumps({
@@ -22,10 +22,10 @@
2222
'x_domain%end' : 6*D,
2323
'y_domain%beg' : -3*D,
2424
'y_domain%end' : 3*D,
25-
'm' : 199,
26-
'n' : 99,
25+
'm' : 60,
26+
'n' : 30,
2727
'p' : 0,
28-
'dt' : 1.0E-12,
28+
'dt' : 1.0E-9,
2929
't_step_start' : 0,
3030
't_step_stop' : 3000,
3131
't_step_save' : 30,
@@ -47,7 +47,7 @@
4747
'mp_weno' : 'F',
4848
'riemann_solver' : 2,
4949
'wave_speeds' : 1,
50-
'viscous' : 'T',
50+
'viscous' : 'F',
5151
'bc_x%beg' : -3,
5252
'bc_x%end' : -3,
5353
'bc_y%beg' : -3,
@@ -71,26 +71,24 @@
7171
'patch_icpp(1)%y_centroid' : 0,
7272
'patch_icpp(1)%length_x' : 1000*D,
7373
'patch_icpp(1)%length_y' : 1000*D,
74-
'patch_icpp(1)%vel(1)' : 10, #527.2E+00,
74+
'patch_icpp(1)%vel(1)' : 1,
7575
'patch_icpp(1)%vel(2)' : 0.0E+00,
76-
'patch_icpp(1)%pres' : 100000, #10918.2549,
76+
'patch_icpp(1)%pres' : 100000,
7777
'patch_icpp(1)%alpha_rho(1)' : (1.0)*rho1,
7878
'patch_icpp(1)%alpha(1)' : 1.0,
7979
# ==========================================================================
8080
'patch_ib(1)%geometry' : 5,
8181
'patch_ib(1)%model%filepath' : 'Circle_IBM.stl',
82-
'patch_ib(1)%model%translate(1)' : -0.05 + 0.0424444350,
83-
'patch_ib(1)%model%translate(2)' : -0.05 + 0.0445000000,
84-
'patch_ib(1)%model%spc' : 2000,
82+
'patch_ib(1)%model%translate(1)' : -0.05,
83+
'patch_ib(1)%model%translate(2)' : -0.05,
84+
'patch_ib(1)%model%spc' : 200,
8585
'patch_ib(1)%model%threshold' : 0.99,
8686
'patch_ib(1)%slip' : 'F',
8787
# # ========================================================================
8888

8989
# Fluids Physical Parameters ===============================================
9090
'fluid_pp(1)%gamma' : 1.E+00/(gam_a-1.E+00),
9191
'fluid_pp(1)%pi_inf' : 0,
92-
'fluid_pp(1)%Re(1)' : 5000,
93-
#'fluid_pp(1)%Re(1)' : 7535533.2,
9492
# ==========================================================================
9593
}))
9694

examples/3D_IBM_STL/case.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
Mu = 1.84E-05
55
gam_a = 1.4
6-
rho1 = 0.2199
7-
D = 0.02
6+
rho1 = 1.19
7+
D = 2
88

99
# Configuring case dictionary
1010
print(json.dumps({
@@ -13,8 +13,7 @@
1313
# ==========================================================================
1414

1515
# Computational Domain Parameters ==========================================
16-
# x direction
17-
'x_domain%beg' : -4.0*D,
16+
'x_domain%beg' : -4*D,
1817
'x_domain%end' : 4.0*D,
1918
# y direction
2019
'y_domain%beg' : -2*D,
@@ -23,10 +22,10 @@
2322
'z_domain%beg' : -2*D,
2423
'z_domain%end' : 2*D,
2524
'cyl_coord' : 'F',
26-
'm' : 99,
27-
'n' : 49,
28-
'p' : 49,
29-
'dt' : 1.0E-12,
25+
'm' : 59,
26+
'n' : 29,
27+
'p' : 29,
28+
'dt' : 1.0E-9,
3029
't_step_start' : 0,
3130
't_step_stop' : 1000,
3231
't_step_save' : 10,
@@ -42,15 +41,15 @@
4241
'time_stepper' : 3,
4342
'weno_order' : 5,
4443
'weno_eps' : 1.E-16,
45-
'weno_Re_flux' : 'T',
44+
'weno_Re_flux' : 'F',
4645
'weno_avg' : 'T',
4746
'avg_state' : 2,
4847
'mapped_weno' : 'T',
4948
'null_weights' : 'F',
5049
'mp_weno' : 'F',
5150
'riemann_solver' : 2,
5251
'wave_speeds' : 1,
53-
'viscous' :'T',
52+
'viscous' :'F',
5453
'bc_x%beg' : -3,
5554
'bc_x%end' : -3,
5655
'bc_y%beg' : -3,
@@ -81,28 +80,27 @@
8180
'patch_icpp(1)%length_x' : 100*D,
8281
'patch_icpp(1)%length_y' : 50*D,
8382
'patch_icpp(1)%length_z' : 50*D,
84-
'patch_icpp(1)%vel(1)' : 527.2E+00,
83+
'patch_icpp(1)%vel(1)' : 1,
8584
'patch_icpp(1)%vel(2)' : 0.0E+00,
8685
'patch_icpp(1)%vel(3)' : 0.0E+00,
87-
'patch_icpp(1)%pres' : 10918.2549,
86+
'patch_icpp(1)%pres' : 100000,
8887
'patch_icpp(1)%alpha_rho(1)' : (1.0)*rho1,
8988
'patch_icpp(1)%alpha(1)' : 1.E+00,
9089
# # ========================================================================
9190

9291
# Patch: Model Immersed Boundary ===========================================
9392
'patch_ib(1)%geometry' : 12,
9493
'patch_ib(1)%model%filepath' : 'Sphere_IBM.stl',
95-
'patch_ib(1)%model%translate(1)' : 0 - 0.02056,
96-
'patch_ib(1)%model%translate(2)' : 0 - 0.01,
97-
'patch_ib(1)%model%translate(3)' : 0 - 0.01,
98-
'patch_ib(1)%model%spc' : 200,
99-
'patch_ib(1)%model%threshold' : 0.99,
94+
'patch_ib(1)%model%translate(1)' : 0,
95+
'patch_ib(1)%model%translate(2)' : -0.05,
96+
'patch_ib(1)%model%translate(3)' : -0.05,
97+
'patch_ib(1)%model%spc' : 100,
98+
'patch_ib(1)%model%threshold' : 0.95,
10099
'patch_ib(1)%slip' : 'F',
101100
# ==========================================================================
102101

103102
# Fluids Physical Parameters ===============================================
104103
'fluid_pp(1)%gamma' : 1.E+00/(gam_a-1.E+00),
105104
'fluid_pp(1)%pi_inf' : 0,
106-
'fluid_pp(1)%Re(1)' : 7535533.2,
107105
# ==========================================================================
108106
}))

src/common/m_constants.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ module m_constants
3232
integer, parameter :: Ifactor_2D = 100 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 2D models
3333
integer, parameter :: Ifactor_3D = 10 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 3D models
3434
integer, parameter :: Ifactor_bary_3D = 30 !< Multiple factor of the ratio (triangle area to cell face area) for interpolation on triangle facets for 3D models
35+
integer, parameter :: num_ray = 20 !< Default number of rays traced per cell
36+
real(kind(0d0)), parameter :: ray_tracing_threshold = 0.9d0 !< Threshold above which the cell is marked as the model patch
3537
real(kind(0d0)), parameter :: threshold_vector_zero = 1d-10 !< Threshold to treat the component of a vector to be zero
3638
real(kind(0d0)), parameter :: threshold_edge_zero = 1d-8 !< Threshold to treat two edges to be overlapped
3739
real(kind(0d0)), parameter :: threshold_bary = 1d-1 !< Threshold to interpolate a barycentric facet

src/pre_process/m_check_ib_patches.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ contains
269269

270270
call s_int_to_str(patch_id, iStr)
271271

272-
@:PROHIBIT(patch_ib(patch_id)%model%filepath == ' ', &
272+
@:PROHIBIT(patch_ib(patch_id)%model%filepath == dflt_char, &
273273
'Empty model file path for patch '//trim(iStr))
274274

275275
@:PROHIBIT(patch_ib(patch_id)%model%scale(1) <= 0d0 &

src/pre_process/m_global_parameters.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ contains
342342
patch_icpp(i)%geometry = dflt_int
343343
patch_icpp(i)%model%scale(:) = 1d0
344344
patch_icpp(i)%model%translate(:) = 0d0
345-
patch_icpp(i)%model%filepath(:) = ' '
346-
patch_icpp(i)%model%spc = 10
347-
patch_icpp(i)%model%threshold = 0.9d0
345+
patch_icpp(i)%model%filepath(:) = dflt_char
346+
patch_icpp(i)%model%spc = num_ray
347+
patch_icpp(i)%model%threshold = ray_tracing_threshold
348348
patch_icpp(i)%x_centroid = dflt_real
349349
patch_icpp(i)%y_centroid = dflt_real
350350
patch_icpp(i)%z_centroid = dflt_real
@@ -450,9 +450,9 @@ contains
450450
patch_ib(i)%model%scale(:) = 1d0
451451
patch_ib(i)%model%translate(:) = 0d0
452452
patch_ib(i)%model%rotate(:) = 0d0
453-
patch_ib(i)%model%filepath(:) = ' '
454-
patch_ib(i)%model%spc = 20
455-
patch_ib(i)%model%threshold = 0.9d0
453+
patch_ib(i)%model%filepath(:) = dflt_char
454+
patch_ib(i)%model%spc = num_ray
455+
patch_ib(i)%model%threshold = ray_tracing_threshold
456456
end do
457457

458458
! Fluids physical parameters

src/pre_process/m_initial_condition.fpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ contains
229229
!> @{
230230
! Circular patch
231231
if (patch_icpp(i)%geometry == 2) then
232-
call s_circle(i, patch_id_fp, q_prim_vf, .false.)
232+
call s_circle(i, patch_id_fp, q_prim_vf)
233233

234234
! Rectangular patch
235235
elseif (patch_icpp(i)%geometry == 3) then
236-
call s_rectangle(i, patch_id_fp, q_prim_vf, .false.)
236+
call s_rectangle(i, patch_id_fp, q_prim_vf)
237237

238238
! Swept line patch
239239
elseif (patch_icpp(i)%geometry == 4) then
@@ -266,7 +266,7 @@ contains
266266

267267
! STL patch
268268
elseif (patch_icpp(i)%geometry == 21) then
269-
call s_model(i, patch_id_fp, q_prim_vf, .false.)
269+
call s_model(i, patch_id_fp, q_prim_vf)
270270

271271
end if
272272
!> @}

src/pre_process/m_model.fpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -582,18 +582,18 @@ contains
582582
! Collect all edges of all triangles and store them
583583
do i = 1, model%ntrs
584584
! First edge (v1, v2)
585-
edge(1, :) = model%trs(i)%v(1, 1:2)
586-
edge(2, :) = model%trs(i)%v(2, 1:2)
585+
edge(1, 1:2) = model%trs(i)%v(1, 1:2)
586+
edge(2, 1:2) = model%trs(i)%v(2, 1:2)
587587
call f_register_edge(temp_boundary_v, edge, edge_index, edge_count)
588588

589589
! Second edge (v2, v3)
590-
edge(1, :) = model%trs(i)%v(2, 1:2)
591-
edge(2, :) = model%trs(i)%v(3, 1:2)
590+
edge(1, 1:2) = model%trs(i)%v(2, 1:2)
591+
edge(2, 1:2) = model%trs(i)%v(3, 1:2)
592592
call f_register_edge(temp_boundary_v, edge, edge_index, edge_count)
593593

594594
! Third edge (v3, v1)
595-
edge(1, :) = model%trs(i)%v(3, 1:2)
596-
edge(2, :) = model%trs(i)%v(1, 1:2)
595+
edge(1, 1:2) = model%trs(i)%v(3, 1:2)
596+
edge(2, 1:2) = model%trs(i)%v(1, 1:2)
597597
call f_register_edge(temp_boundary_v, edge, edge_index, edge_count)
598598
end do
599599

@@ -635,8 +635,8 @@ contains
635635
do i = 1, edge_count
636636
if (edge_occurrence(i) == 0) then
637637
store_index = store_index + 1
638-
boundary_v(store_index, 1, :) = temp_boundary_v(i, 1, :)
639-
boundary_v(store_index, 2, :) = temp_boundary_v(i, 2, :)
638+
boundary_v(store_index, 1, 1:2) = temp_boundary_v(i, 1, 1:2)
639+
boundary_v(store_index, 2, 1:2) = temp_boundary_v(i, 2, 1:2)
640640
end if
641641
end do
642642

@@ -680,8 +680,8 @@ contains
680680

681681
! Increment edge index and store the edge
682682
edge_index = edge_index + 1
683-
temp_boundary_v(edge_index, 1, :) = edge(1, :)
684-
temp_boundary_v(edge_index, 2, :) = edge(2, :)
683+
temp_boundary_v(edge_index, 1, 1:2) = edge(1, 1:2)
684+
temp_boundary_v(edge_index, 2, 1:2) = edge(2, 1:2)
685685

686686
end subroutine f_register_edge
687687

@@ -693,24 +693,19 @@ contains
693693
subroutine f_check_interpolation_2D(boundary_v, boundary_edge_count, spacing, interpolate)
694694
logical, intent(out) :: interpolate !< Logical indicator of interpolation
695695
integer, intent(in) :: boundary_edge_count !< Number of boundary edges
696-
real(kind(0d0)), optional, intent(in), dimension(1:boundary_edge_count, 1:3, 1:2) :: boundary_v
696+
real(kind(0d0)), intent(in), dimension(1:boundary_edge_count, 1:3, 1:2) :: boundary_v
697697
t_vec3, intent(in) :: spacing
698698

699699
real(kind(0d0)) :: l1, cell_width !< Length of each boundary edge and cell width
700-
real(kind(0d0)), dimension(1:2, 1:2) :: edge_v !< Boundary points of each boundary edge
701700
integer :: j !< Boundary edge index iterator
702701

703702
cell_width = minval(spacing(1:2))
704703
interpolate = .false.
705704

706705
do j = 1, boundary_edge_count
707-
edge_v(1, 1) = boundary_v(j, 1, 1)
708-
edge_v(2, 1) = boundary_v(j, 2, 1)
709-
edge_v(1, 2) = boundary_v(j, 1, 2)
710-
edge_v(2, 2) = boundary_v(j, 2, 2)
711706

712-
l1 = dsqrt((edge_v(2, 1) - edge_v(1, 1))**2 + &
713-
(edge_v(2, 2) - edge_v(1, 2))**2)
707+
l1 = dsqrt((boundary_v(j, 2, 1) - boundary_v(j, 1, 1))**2 + &
708+
(boundary_v(j, 2, 2) - boundary_v(j, 1, 2))**2)
714709

715710
if ((l1 > cell_width)) then
716711
interpolate = .true.

src/pre_process/m_patches.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ contains
20122012
if (p > 0) then
20132013
call f_check_interpolation_3D(model, (/dx, dy, dz/), interpolate)
20142014
else
2015-
call f_check_interpolation_2D(boundary_v, boundary_vertex_count, (/dx, dy, dz/), interpolate)
2015+
call f_check_interpolation_2D(boundary_v, boundary_edge_count, (/dx, dy, dz/), interpolate)
20162016
end if
20172017
20182018
! Show the number of edges and boundary edges in 2D STL models

tests/4E0FBE72/golden-metadata.txt

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/4E0FBE72/golden.txt

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)