@@ -18,20 +18,7 @@ module m_initial_condition
1818
1919 implicit none
2020
21- ! NOTE: Abstract interface enables dynamic dispatch without repeated model_eqns checks
22- type(scalar_field), allocatable, dimension (:) :: q_prim_vf !< primitive variables
23- type(scalar_field), allocatable, dimension (:) :: q_cons_vf !< conservative variables
24- type(scalar_field) :: q_T_sf !< Temperature field
25- type(integer_field), dimension (:,:), allocatable :: bc_type !< bc_type fields
26- !> @cond
27- #ifdef MFC_MIXED_PRECISION
28- integer (kind= 1 ), allocatable, dimension (:,:,:) :: patch_id_fp
29- #else
30- !> @endcond
31- integer , allocatable, dimension (:,:,:) :: patch_id_fp
32- !> @cond
33- #endif
34- !> @endcond
21+ type(ic_context) :: ic !< Initial- condition state (fields, bc types, patch ids)
3522
3623contains
3724
@@ -40,82 +27,82 @@ contains
4027
4128 integer :: i, j, k, l
4229
43- allocate (q_prim_vf(1 :sys_size))
44- allocate (q_cons_vf(1 :sys_size))
30+ allocate (ic% q_prim_vf(1 :sys_size))
31+ allocate (ic% q_cons_vf(1 :sys_size))
4532
4633 do i = 1 , sys_size
47- allocate (q_prim_vf(i)%sf(idwbuff(1 )%beg:idwbuff(1 )%end,idwbuff(2 )%beg:idwbuff(2 )%end,idwbuff(3 )%beg:idwbuff(3 )%end))
48- allocate (q_cons_vf(i)%sf(idwbuff(1 )%beg:idwbuff(1 )%end,idwbuff(2 )%beg:idwbuff(2 )%end,idwbuff(3 )%beg:idwbuff(3 )%end))
34+ allocate (ic% q_prim_vf(i)%sf(idwbuff(1 )%beg:idwbuff(1 )%end,idwbuff(2 )%beg:idwbuff(2 )%end,idwbuff(3 )%beg:idwbuff(3 )%end))
35+ allocate (ic% q_cons_vf(i)%sf(idwbuff(1 )%beg:idwbuff(1 )%end,idwbuff(2 )%beg:idwbuff(2 )%end,idwbuff(3 )%beg:idwbuff(3 )%end))
4936 end do
5037
5138 if (chemistry) then
52- allocate (q_T_sf%sf(idwbuff(1 )%beg:idwbuff(1 )%end,idwbuff(2 )%beg:idwbuff(2 )%end,idwbuff(3 )%beg:idwbuff(3 )%end))
39+ allocate (ic% q_T_sf%sf(idwbuff(1 )%beg:idwbuff(1 )%end,idwbuff(2 )%beg:idwbuff(2 )%end,idwbuff(3 )%beg:idwbuff(3 )%end))
5340 end if
5441
55- allocate (patch_id_fp(0 :m,0 :n,0 :p))
42+ allocate (ic% patch_id_fp(0 :m,0 :n,0 :p))
5643
5744 if (qbmm .and. .not. polytropic) then
5845 allocate (pb%sf(0 :m,0 :n,0 :p,1 :nnode,1 :nb))
5946 allocate (mv%sf(0 :m,0 :n,0 :p,1 :nnode,1 :nb))
6047 end if
6148
6249 do i = 1 , sys_size
63- q_cons_vf(i)%sf = - 1.e-6_stp ! real (dflt_real, kind= stp) ! TODO :: remove this magic number
64- q_prim_vf(i)%sf = - 1.e-6_stp ! real (dflt_real, kind= stp)
50+ ic% q_cons_vf(i)%sf = - 1.e-6_stp ! real (dflt_real, kind= stp) ! TODO :: remove this magic number
51+ ic% q_prim_vf(i)%sf = - 1.e-6_stp ! real (dflt_real, kind= stp)
6552 end do
6653
67- allocate (bc_type(1 :num_dims,1 :2 ))
54+ allocate (ic% bc_type(1 :num_dims,1 :2 ))
6855
69- allocate (bc_type(1 , 1 )%sf(0 :0 ,0 :n,0 :p))
70- allocate (bc_type(1 , 2 )%sf(0 :0 ,0 :n,0 :p))
56+ allocate (ic% bc_type(1 , 1 )%sf(0 :0 ,0 :n,0 :p))
57+ allocate (ic% bc_type(1 , 2 )%sf(0 :0 ,0 :n,0 :p))
7158
7259 do l = 0 , p
7360 do k = 0 , n
74- bc_type(1 , 1 )%sf(0 , k, l) = int (min (bc_x%beg, 0 ), kind= 1 )
75- bc_type(1 , 2 )%sf(0 , k, l) = int (min (bc_x%end, 0 ), kind= 1 )
61+ ic% bc_type(1 , 1 )%sf(0 , k, l) = int (min (bc_x%beg, 0 ), kind= 1 )
62+ ic% bc_type(1 , 2 )%sf(0 , k, l) = int (min (bc_x%end, 0 ), kind= 1 )
7663 end do
7764 end do
7865
7966 if (n > 0 ) then
80- allocate (bc_type(2 , 1 )%sf(- buff_size:m + buff_size,0 :0 ,0 :p))
81- allocate (bc_type(2 , 2 )%sf(- buff_size:m + buff_size,0 :0 ,0 :p))
67+ allocate (ic% bc_type(2 , 1 )%sf(- buff_size:m + buff_size,0 :0 ,0 :p))
68+ allocate (ic% bc_type(2 , 2 )%sf(- buff_size:m + buff_size,0 :0 ,0 :p))
8269
8370 do l = 0 , p
8471 do j = - buff_size, m + buff_size
85- bc_type(2 , 1 )%sf(j, 0 , l) = int (min (bc_y%beg, 0 ), kind= 1 )
86- bc_type(2 , 2 )%sf(j, 0 , l) = int (min (bc_y%end, 0 ), kind= 1 )
72+ ic% bc_type(2 , 1 )%sf(j, 0 , l) = int (min (bc_y%beg, 0 ), kind= 1 )
73+ ic% bc_type(2 , 2 )%sf(j, 0 , l) = int (min (bc_y%end, 0 ), kind= 1 )
8774 end do
8875 end do
8976
9077 if (p > 0 ) then
91- allocate (bc_type(3 , 1 )%sf(- buff_size:m + buff_size,- buff_size:n + buff_size,0 :0 ))
92- allocate (bc_type(3 , 2 )%sf(- buff_size:m + buff_size,- buff_size:n + buff_size,0 :0 ))
78+ allocate (ic% bc_type(3 , 1 )%sf(- buff_size:m + buff_size,- buff_size:n + buff_size,0 :0 ))
79+ allocate (ic% bc_type(3 , 2 )%sf(- buff_size:m + buff_size,- buff_size:n + buff_size,0 :0 ))
9380
9481 do k = - buff_size, n + buff_size
9582 do j = - buff_size, m + buff_size
96- bc_type(3 , 1 )%sf(j, k, 0 ) = int (min (bc_z%beg, 0 ), kind= 1 )
97- bc_type(3 , 2 )%sf(j, k, 0 ) = int (min (bc_z%end, 0 ), kind= 1 )
83+ ic% bc_type(3 , 1 )%sf(j, k, 0 ) = int (min (bc_z%beg, 0 ), kind= 1 )
84+ ic% bc_type(3 , 2 )%sf(j, k, 0 ) = int (min (bc_z%end, 0 ), kind= 1 )
9885 end do
9986 end do
10087 end if
10188 end if
10289
10390 ! Initial damage state is always zero
10491 if (cont_damage) then
105- q_cons_vf(eqn_idx%damage)%sf = 0._wp
106- q_prim_vf(eqn_idx%damage)%sf = 0._wp
92+ ic% q_cons_vf(eqn_idx%damage)%sf = 0._wp
93+ ic% q_prim_vf(eqn_idx%damage)%sf = 0._wp
10794 end if
10895
10996 ! Initial hyper_cleaning state is always zero TODO more general
11097 if (hyper_cleaning) then
111- q_cons_vf(eqn_idx%psi)%sf = 0._wp
112- q_prim_vf(eqn_idx%psi)%sf = 0._wp
98+ ic% q_cons_vf(eqn_idx%psi)%sf = 0._wp
99+ ic% q_prim_vf(eqn_idx%psi)%sf = 0._wp
113100 end if
114101
115102 ! Setting default values for patch identities bookkeeping variable. This is necessary to avoid any confusion in the
116103 ! assessment of the extent of application that the overwrite permissions give a patch when it is being applied in the
117104 ! domain.
118- patch_id_fp = 0
105+ ic% patch_id_fp = 0
119106
120107 end subroutine s_initialize_initial_condition_module
121108
@@ -127,31 +114,31 @@ contains
127114 integer :: i
128115
129116 if (old_ic) then
130- call s_convert_conservative_to_primitive_variables(q_cons_vf, q_T_sf, q_prim_vf, idwbuff)
117+ call s_convert_conservative_to_primitive_variables(ic% q_cons_vf, ic% q_T_sf, ic% q_prim_vf, idwbuff)
131118 end if
132119
133- call s_apply_icpp_patches(patch_id_fp, q_prim_vf)
120+ call s_apply_icpp_patches(ic% patch_id_fp, ic% q_prim_vf)
134121
135- if (num_bc_patches > 0 ) call s_apply_boundary_patches(q_prim_vf, bc_type)
122+ if (num_bc_patches > 0 ) call s_apply_boundary_patches(ic% q_prim_vf, ic% bc_type)
136123
137- if (perturb_flow) call s_perturb_surrounding_flow(q_prim_vf)
138- if (perturb_sph) call s_perturb_sphere(q_prim_vf)
139- if (mixlayer_perturb) call s_perturb_mixlayer(q_prim_vf)
140- if (simplex_perturb) call s_perturb_simplex(q_prim_vf)
141- if (chemistry) call s_compute_T_from_primitives(q_T_sf, q_prim_vf, idwint)
124+ if (perturb_flow) call s_perturb_surrounding_flow(ic% q_prim_vf)
125+ if (perturb_sph) call s_perturb_sphere(ic% q_prim_vf)
126+ if (mixlayer_perturb) call s_perturb_mixlayer(ic% q_prim_vf)
127+ if (simplex_perturb) call s_perturb_simplex(ic% q_prim_vf)
128+ if (chemistry) call s_compute_T_from_primitives(ic% q_T_sf, ic% q_prim_vf, idwint)
142129
143130 if (elliptic_smoothing .and. chemistry) then
144- call s_elliptic_smoothing(q_prim_vf, bc_type, q_T_sf)
145- call s_compute_T_from_primitives(q_T_sf, q_prim_vf, idwint)
131+ call s_elliptic_smoothing(ic% q_prim_vf, ic% bc_type, ic% q_T_sf)
132+ call s_compute_T_from_primitives(ic% q_T_sf, ic% q_prim_vf, idwint)
146133 else if (elliptic_smoothing) then
147- call s_elliptic_smoothing(q_prim_vf, bc_type)
134+ call s_elliptic_smoothing(ic% q_prim_vf, ic% bc_type)
148135 end if
149136
150- call s_convert_primitive_to_conservative_variables(q_prim_vf, q_cons_vf)
137+ call s_convert_primitive_to_conservative_variables(ic% q_prim_vf, ic% q_cons_vf)
151138
152139 if (qbmm .and. .not. polytropic) then
153- call s_initialize_mv(q_cons_vf, mv%sf)
154- call s_initialize_pb(q_cons_vf, mv%sf, pb%sf)
140+ call s_initialize_mv(ic% q_cons_vf, mv%sf)
141+ call s_initialize_pb(ic% q_cons_vf, mv%sf, pb%sf)
155142 end if
156143
157144 end subroutine s_generate_initial_condition
@@ -162,33 +149,33 @@ contains
162149 integer :: i
163150
164151 do i = 1 , sys_size
165- deallocate (q_prim_vf(i)%sf)
166- deallocate (q_cons_vf(i)%sf)
152+ deallocate (ic% q_prim_vf(i)%sf)
153+ deallocate (ic% q_cons_vf(i)%sf)
167154 end do
168155
169- deallocate (q_prim_vf)
170- deallocate (q_cons_vf)
156+ deallocate (ic% q_prim_vf)
157+ deallocate (ic% q_cons_vf)
171158
172159 if (chemistry) then
173- deallocate (q_T_sf%sf)
160+ deallocate (ic% q_T_sf%sf)
174161 end if
175162
176- deallocate (patch_id_fp)
163+ deallocate (ic% patch_id_fp)
177164
178- deallocate (bc_type(1 , 1 )%sf)
179- deallocate (bc_type(1 , 2 )%sf)
165+ deallocate (ic% bc_type(1 , 1 )%sf)
166+ deallocate (ic% bc_type(1 , 2 )%sf)
180167
181168 if (n > 0 ) then
182- deallocate (bc_type(2 , 1 )%sf)
183- deallocate (bc_type(2 , 2 )%sf)
169+ deallocate (ic% bc_type(2 , 1 )%sf)
170+ deallocate (ic% bc_type(2 , 2 )%sf)
184171 end if
185172
186173 if (p > 0 ) then
187- deallocate (bc_type(3 , 1 )%sf)
188- deallocate (bc_type(3 , 2 )%sf)
174+ deallocate (ic% bc_type(3 , 1 )%sf)
175+ deallocate (ic% bc_type(3 , 2 )%sf)
189176 end if
190177
191- deallocate (bc_type)
178+ deallocate (ic% bc_type)
192179
193180 end subroutine s_finalize_initial_condition_module
194181
0 commit comments