40 use num_types,
only: rp
41 use field_list,
only: field_list_t
42 use json_module,
only: json_file
43 use json_utils,
only: json_get, json_get_or_default
44 use source_term,
only: source_term_t
45 use coefs,
only: coef_t
46 use neko_config,
only: neko_bcknd_device
47 use utils,
only: neko_error
48 use field,
only: field_t
49 use field_math,
only: field_subcol3, field_add2, field_add2s2
50 use json_module,
only: json_file
51 use time_state,
only: time_state_t
53 use simcomp_executor,
only: neko_simcomps
54 use user_source_term,
only: user_source_term_t
55 use num_types,
only: rp
56 use field,
only: field_t
57 use field_registry,
only: neko_field_registry
58 use math,
only: rzero, copy, chsign
59 use device_math,
only: device_copy, device_cmult
60 use neko_config,
only: neko_bcknd_device
61 use operators,
only: curl
62 use scratch_registry,
only: neko_scratch_registry
64 use point_zone,
only: point_zone_t
70 type,
public,
extends(source_term_t) :: &
73 type(field_t),
pointer :: u => null()
75 type(field_t),
pointer :: v => null()
77 type(field_t),
pointer :: w => null()
79 real(kind=rp) :: obj_scale
81 class(point_zone_t),
pointer :: mask => null()
87 procedure, pass(this) :: init => &
88 adjoint_minimum_dissipation_source_term_init_from_json
90 procedure, pass(this) :: init_from_components => &
91 adjoint_minimum_dissipation_source_term_init_from_components
93 procedure, pass(this) :: free => &
94 adjoint_minimum_dissipation_source_term_free
96 procedure, pass(this) :: compute_ => &
97 adjoint_minimum_dissipation_source_term_compute
107 subroutine adjoint_minimum_dissipation_source_term_init_from_json(this, &
108 json, fields, coef, variable_name)
110 type(json_file),
intent(inout) :: json
111 type(field_list_t),
intent(in),
target :: fields
112 type(coef_t),
intent(in),
target :: coef
113 character(len=*),
intent(in) :: variable_name
119 end subroutine adjoint_minimum_dissipation_source_term_init_from_json
129 subroutine adjoint_minimum_dissipation_source_term_init_from_components(this,&
131 u, v, w, obj_scale, &
135 type(field_t),
pointer,
intent(in) :: f_x, f_y, f_z
136 type(field_list_t) :: fields
138 real(kind=rp) :: start_time
139 real(kind=rp) :: end_time
140 real(kind=rp) :: obj_scale
141 type(field_t),
intent(in),
target :: u, v, w
142 class(point_zone_t),
intent(in),
target :: mask
148 end_time = 100000000.0_rp
155 call fields%assign(1, f_x)
156 call fields%assign(2, f_y)
157 call fields%assign(3, f_z)
159 call this%init_base(fields, coef, start_time, end_time)
166 this%obj_scale = obj_scale
168 this%if_mask = if_mask
169 if (this%if_mask)
then
173 end subroutine adjoint_minimum_dissipation_source_term_init_from_components
176 subroutine adjoint_minimum_dissipation_source_term_free(this)
179 call this%free_base()
180 end subroutine adjoint_minimum_dissipation_source_term_free
185 subroutine adjoint_minimum_dissipation_source_term_compute(this, time)
187 type(time_state_t),
intent(in) :: time
188 type(field_t),
pointer :: u, v, w
189 type(field_t),
pointer :: fu, fv, fw
193 type(field_t),
pointer :: wo1, wo2, wo3, wo4, wo5, wo6
194 type(field_t),
pointer :: t1 , t2
195 integer :: temp_indices(8)
199 fu => this%fields%get_by_index(1)
200 fv => this%fields%get_by_index(2)
201 fw => this%fields%get_by_index(3)
211 call neko_scratch_registry%request_field(wo1, temp_indices(1))
212 call neko_scratch_registry%request_field(wo2, temp_indices(2))
213 call neko_scratch_registry%request_field(wo3, temp_indices(3))
214 call neko_scratch_registry%request_field(wo4, temp_indices(4))
215 call neko_scratch_registry%request_field(wo5, temp_indices(5))
216 call neko_scratch_registry%request_field(wo6, temp_indices(6))
217 call neko_scratch_registry%request_field(t1 , temp_indices(7))
218 call neko_scratch_registry%request_field(t2 , temp_indices(8))
240 call curl(wo1, wo2, wo3, u, v, w, t1, t2, this%coef)
241 call curl(wo4, wo5, wo6, wo1, wo2, wo3, t1, t2, this%coef)
244 if (this%if_mask)
then
250 call field_add2s2(fu, wo4, this%obj_scale)
251 call field_add2s2(fv, wo5, this%obj_scale)
252 call field_add2s2(fw, wo6, this%obj_scale)
256 call neko_scratch_registry%relinquish_field(temp_indices)
258 end subroutine adjoint_minimum_dissipation_source_term_compute
Implements the adjoint_minimum_dissipation_source_term_t type.
Some common Masking operations we may need.
Implements the steady_simcomp_t type.
An adjoint source term for objectives of minimum dissipation.
The steady_simcomp_t type is a simulation component that terminates a simulation when the normed diff...