42 use num_types,
only: rp
43 use field_list,
only: field_list_t
44 use json_module,
only: json_file
45 use json_utils,
only: json_get, json_get_or_default
46 use source_term,
only: source_term_t
47 use coefs,
only: coef_t
48 use neko_config,
only: neko_bcknd_device
49 use utils,
only: neko_error
50 use field,
only: field_t
51 use field_math,
only: field_subcol3, field_add2, field_add2s2, field_rzero
52 use json_module,
only: json_file
53 use time_state,
only: time_state_t
55 use simcomp_executor,
only: neko_simcomps
56 use user_source_term,
only: user_source_term_t
57 use num_types,
only: rp
58 use field,
only: field_t
59 use registry,
only: neko_registry
60 use math,
only: rzero, copy, chsign, cfill, invcol2
61 use device_math,
only: device_copy, device_cmult, device_cfill, device_invcol2
62 use neko_config,
only: neko_bcknd_device
63 use scratch_registry,
only: neko_scratch_registry
65 use point_zone,
only: point_zone_t
66 use ax_product,
only : ax_t, ax_helm_factory
74 type,
public,
extends(source_term_t) :: &
77 type(field_t),
pointer :: u => null()
79 type(field_t),
pointer :: v => null()
81 type(field_t),
pointer :: w => null()
83 real(kind=rp) :: obj_scale
85 class(point_zone_t),
pointer :: mask => null()
89 class(ax_t),
allocatable :: ax
91 real(kind=rp) :: volume
95 procedure, pass(this) :: init => &
96 adjoint_viscous_dissipation_source_term_init_from_json
98 procedure, pass(this) :: init_from_components => &
99 adjoint_viscous_dissipation_source_term_init_from_components
101 procedure, pass(this) :: free => &
102 adjoint_viscous_dissipation_source_term_free
104 procedure, pass(this) :: compute_ => &
105 adjoint_viscous_dissipation_source_term_compute
112 class(source_term_t),
allocatable,
intent(inout) :: obj
122 subroutine adjoint_viscous_dissipation_source_term_init_from_json(this, &
123 json, fields, coef, variable_name)
125 type(json_file),
intent(inout) :: json
126 type(field_list_t),
intent(in),
target :: fields
127 type(coef_t),
intent(in),
target :: coef
128 character(len=*),
intent(in) :: variable_name
134 end subroutine adjoint_viscous_dissipation_source_term_init_from_json
147 subroutine adjoint_viscous_dissipation_source_term_init_from_components( &
148 this, f_x, f_y, f_z, u, v, w, obj_scale, mask, if_mask, coef, &
149 volume, start_time, end_time)
151 type(field_t),
pointer,
intent(in) :: f_x, f_y, f_z
152 type(field_t),
intent(in),
target :: u, v, w
153 real(kind=rp),
intent(in) :: obj_scale
154 class(point_zone_t),
intent(in),
target :: mask
155 logical,
intent(in) :: if_mask
156 type(coef_t),
intent(in) :: coef
157 real(kind=rp),
intent(in) :: volume
158 real(kind=rp),
intent(in) :: start_time
159 real(kind=rp),
intent(in) :: end_time
161 type(field_list_t) :: fields
168 call fields%assign(1, f_x)
169 call fields%assign(2, f_y)
170 call fields%assign(3, f_z)
172 call this%init_base(fields, coef, start_time, end_time)
180 this%obj_scale = obj_scale
183 this%if_mask = if_mask
184 if (this%if_mask)
then
189 call ax_helm_factory(this%Ax, full_formulation = .false.)
191 end subroutine adjoint_viscous_dissipation_source_term_init_from_components
194 subroutine adjoint_viscous_dissipation_source_term_free(this)
197 call this%free_base()
202 if (
allocated(this%Ax))
then
206 end subroutine adjoint_viscous_dissipation_source_term_free
211 subroutine adjoint_viscous_dissipation_source_term_compute(this, time)
213 type(time_state_t),
intent(in) :: time
214 type(field_t),
pointer :: u, v, w
215 type(field_t),
pointer :: fu, fv, fw
216 type(field_t),
pointer :: work
217 integer :: temp_indices(1)
220 fu => this%fields%get_by_index(1)
221 fv => this%fields%get_by_index(2)
222 fw => this%fields%get_by_index(3)
230 call neko_scratch_registry%request_field(work, temp_indices(1), .false.)
232 associate(coef => this%coef)
236 if (neko_bcknd_device .eq. 1)
then
237 call device_cfill(coef%h1_d, 1.0_rp, n)
238 call device_cfill(coef%h2_d, 0.0_rp, n)
240 call cfill(coef%h1, 1.0_rp, n)
241 call cfill(coef%h2, 0.0_rp, n)
248 call this%Ax%compute(work%x, u%x, coef, coef%msh, coef%xh)
251 if (neko_bcknd_device .eq. 1)
then
252 call device_invcol2(work%x_d, coef%B_d, work%size())
254 call invcol2(work%x, coef%B, work%size())
258 if (this%if_mask)
then
263 call field_add2s2(fu, work, this%obj_scale / this%volume)
268 call this%Ax%compute(work%x, v%x, coef, coef%msh, coef%xh)
271 if (neko_bcknd_device .eq. 1)
then
272 call device_invcol2(work%x_d, coef%B_d, work%size())
274 call invcol2(work%x, coef%B, work%size())
278 if (this%if_mask)
then
283 call field_add2s2(fv, work, this%obj_scale / this%volume)
288 call this%Ax%compute(work%x, w%x, coef, coef%msh, coef%xh)
291 if (neko_bcknd_device .eq. 1)
then
292 call device_invcol2(work%x_d, coef%B_d, work%size())
294 call invcol2(work%x, coef%B, work%size())
298 if (this%if_mask)
then
303 call field_add2s2(fw, work, this%obj_scale / this%volume)
305 call neko_scratch_registry%relinquish_field(temp_indices)
309 end subroutine adjoint_viscous_dissipation_source_term_compute
Implements the adjoint_viscous_dissipation_source_term_t type.
subroutine, public adjoint_viscous_dissipation_source_term_allocate(obj)
Allocator for the adjoint viscous dissipation source term.
Some common Masking operations we may need.
Implements the steady_simcomp_t type.
An adjoint source term for objectives of viscous dissipation.
The steady_simcomp_t type is a simulation component that terminates a simulation when the normed diff...