33module adjoint_fluid_scheme
35 use gather_scatter,
only: gs_t
36 use mean_sqr_flow,
only: mean_sqr_flow_t
37 use neko_config,
only: neko_bcknd_device
38 use checkpoint,
only: chkp_t
39 use mean_flow,
only: mean_flow_t
40 use num_types,
only: rp, i8
41 use comm,
only: neko_comm
43 use field,
only: field_t
44 use space,
only: space_t, gll
45 use dofmap,
only: dofmap_t
46 use zero_dirichlet,
only: zero_dirichlet_t
47 use krylov,
only: ksp_t, krylov_solver_factory, ksp_max_iter
48 use coefs,
only: coef_t
49 use usr_inflow,
only: usr_inflow_t, usr_inflow_eval
50 use dirichlet,
only: dirichlet_t
51 use field_dirichlet,
only: field_dirichlet_t
52 use field_dirichlet_vector,
only: field_dirichlet_vector_t
53 use jacobi,
only: jacobi_t
54 use sx_jacobi,
only: sx_jacobi_t
55 use device_jacobi,
only: device_jacobi_t
56 use hsmg,
only: hsmg_t
57 use phmg,
only: phmg_t
58 use precon,
only: pc_t, precon_factory, precon_destroy
59 use fluid_stats,
only: fluid_stats_t
60 use bc_list,
only: bc_list_t
61 use mesh,
only: mesh_t, neko_msh_max_zlbls, neko_msh_max_zlbl_len
62 use math,
only: cfill, add2s2, glsum
63 use device_math,
only: device_cfill, device_add2s2
64 use time_scheme_controller,
only: time_scheme_controller_t
65 use operators,
only: cfl
66 use logger,
only: neko_log, log_size, neko_log_verbose
67 use field_registry,
only: neko_field_registry
68 use json_utils,
only: json_get, json_get_or_default, json_extract_object, &
70 use json_module,
only: json_file, json_core, json_value
71 use scratch_registry,
only: scratch_registry_t
72 use user_intf,
only: user_t, dummy_user_material_properties, &
73 user_material_properties
74 use utils,
only: neko_error, neko_warning
75 use field_series,
only: field_series_t
76 use time_step_controller,
only: time_step_controller_t
77 use field_math,
only: field_cfill, field_add2s2
78 use wall_model_bc,
only: wall_model_bc_t
79 use shear_stress,
only: shear_stress_t
80 use field_list,
only : field_list_t
81 use time_state,
only: time_state_t
82 use field_math,
only: field_addcol3
84 use mpi_f08,
only: mpi_integer, mpi_sum, mpi_allreduce
86 use device,
only : device_event_sync, glb_cmd_event, device_to_host, &
95 character(len=:),
allocatable :: name
98 type(dofmap_t) :: dm_xh
102 type(time_scheme_controller_t),
allocatable :: ext_bdf
105 type(field_t),
pointer :: u_adj => null()
106 type(field_t),
pointer :: v_adj => null()
107 type(field_t),
pointer :: w_adj => null()
108 type(field_t),
pointer :: p_adj => null()
109 type(field_series_t) :: ulag, vlag, wlag
112 type(chkp_t),
pointer :: chkp => null()
115 type(field_t),
pointer :: f_adj_x => null()
117 type(field_t),
pointer :: f_adj_y => null()
119 type(field_t),
pointer :: f_adj_z => null()
123 type(bc_list_t) :: bcs_prs
125 type(bc_list_t) :: bcs_vel
127 type(json_file),
pointer :: params
128 type(mesh_t),
pointer :: msh => null()
131 character(len=NEKO_MSH_MAX_ZLBL_LEN),
allocatable :: bc_labels(:)
140 type(field_list_t) :: material_properties
143 logical :: freeze = .false.
146 procedure(user_material_properties),
nopass,
pointer :: &
147 user_material_properties => null()
151 procedure(adjoint_fluid_scheme_init_intrf), pass(this),
deferred :: init
153 procedure(adjoint_fluid_scheme_free_intrf), pass(this),
deferred :: free
155 procedure(adjoint_fluid_scheme_step_intrf), pass(this),
deferred :: step
157 procedure(adjoint_fluid_scheme_restart_intrf), &
158 pass(this),
deferred :: restart
160 procedure(adjoint_fluid_scheme_setup_bcs_intrf), pass(this),
deferred :: &
164 procedure(validate_intrf), pass(this),
deferred :: validate
166 procedure(fluid_scheme_base_compute_cfl_intrf), pass(this),
deferred :: compute_cfl
168 procedure(update_material_properties), pass(this),
deferred :: update_material_properties
174 kspp_init, scheme, user)
181 class(adjoint_fluid_scheme_t),
target,
intent(inout) :: this
182 type(mesh_t),
target,
intent(inout) :: msh
183 integer,
intent(inout) :: lx
184 type(json_file),
target,
intent(inout) :: params
185 type(user_t),
target,
intent(in) :: user
188 character(len=*),
intent(in) :: scheme
189 real(kind=rp) :: abs_tol
190 integer :: integer_val, ierr
191 logical :: logical_val
192 character(len=:),
allocatable :: solver_type, precon_type
193 character(len=LOG_SIZE) :: log_buf
194 real(kind=rp) :: gjp_param_a, gjp_param_b
200 subroutine adjoint_fluid_init_common_intrf(this, msh, lx, params, scheme, &
209 class(adjoint_fluid_scheme_t),
target,
intent(inout) :: this
210 type(mesh_t),
target,
intent(inout) :: msh
211 integer,
intent(inout) :: lx
212 character(len=*),
intent(in) :: scheme
213 type(json_file),
target,
intent(inout) :: params
214 type(user_t),
target,
intent(in) :: user
215 logical,
intent(in) :: kspv_init
216 type(dirichlet_t) :: bdry_mask
217 character(len=LOG_SIZE) :: log_buf
218 real(kind=rp),
allocatable :: real_vec(:)
219 real(kind=rp) :: real_val, kappa, b, z0
220 logical :: logical_val
221 integer :: integer_val, ierr
222 type(json_file) :: wm_json
223 character(len=:),
allocatable :: string_val1, string_val2
224 end subroutine adjoint_fluid_init_common_intrf
229 subroutine adjoint_fluid_free_intrf(this)
231 class(adjoint_fluid_scheme_t),
intent(inout) :: this
232 end subroutine adjoint_fluid_free_intrf
237 subroutine adjoint_fluid_scheme_init_intrf(this, msh, lx, params, user, &
244 class(adjoint_fluid_scheme_t),
target,
intent(inout) :: this
245 type(mesh_t),
target,
intent(inout) :: msh
246 integer,
intent(in) :: lx
247 type(json_file),
target,
intent(inout) :: params
248 type(user_t),
target,
intent(in) :: user
249 type(chkp_t),
target,
intent(inout) :: chkp
250 end subroutine adjoint_fluid_scheme_init_intrf
255 subroutine adjoint_fluid_scheme_free_intrf(this)
257 class(adjoint_fluid_scheme_t),
intent(inout) :: this
258 end subroutine adjoint_fluid_scheme_free_intrf
263 subroutine adjoint_fluid_scheme_step_intrf(this, time, dt_controller)
266 import time_step_controller_t
267 class(adjoint_fluid_scheme_t),
target,
intent(inout) :: this
268 type(time_state_t),
intent(in) :: time
269 type(time_step_controller_t),
intent(in) :: dt_controller
270 end subroutine adjoint_fluid_scheme_step_intrf
275 subroutine adjoint_fluid_scheme_restart_intrf(this, chkp)
278 class(adjoint_fluid_scheme_t),
target,
intent(inout) :: this
279 type(chkp_t),
intent(inout) :: chkp
280 end subroutine adjoint_fluid_scheme_restart_intrf
285 subroutine adjoint_fluid_scheme_setup_bcs_intrf(this, user, params)
287 class(adjoint_fluid_scheme_t),
intent(inout) :: this
288 type(user_t),
target,
intent(in) :: user
289 type(json_file),
intent(inout) :: params
290 end subroutine adjoint_fluid_scheme_setup_bcs_intrf
295 subroutine validate_intrf(this)
297 class(adjoint_fluid_scheme_t),
target,
intent(inout) :: this
298 end subroutine validate_intrf
303 subroutine update_material_properties(this, t, tstep)
305 class(adjoint_fluid_scheme_t),
intent(inout) :: this
306 real(kind=rp),
intent(in) :: t
307 integer,
intent(in) :: tstep
308 end subroutine update_material_properties
313 function fluid_scheme_base_compute_cfl_intrf(this, dt)
result(c)
316 class(adjoint_fluid_scheme_t),
intent(in) :: this
317 real(kind=rp),
intent(in) :: dt
319 end function fluid_scheme_base_compute_cfl_intrf
324 module subroutine adjoint_fluid_scheme_factory(object, type_name)
325 class(adjoint_fluid_scheme_t),
intent(inout),
allocatable :: object
326 character(len=*) :: type_name
327 end subroutine adjoint_fluid_scheme_factory
329end module adjoint_fluid_scheme
Implements the adjoint_source_term_t type.
Base type of all fluid formulations.
Wrapper contaning and executing the adjoint source terms.