138 type(json_file),
intent(inout) :: json
139 class(
design_t),
intent(in) :: design
141 character(len=:),
allocatable :: name
142 character(len=:),
allocatable :: mask_name
143 real(kind=rp) :: weight
145 call json_get_or_default(json,
"weight", weight, 1.0_rp)
146 call json_get_or_default(json,
"mask_name", mask_name,
"")
147 call json_get_or_default(json,
"name", name,
"Dissipation")
158 weight, name, mask_name)
160 class(
design_t),
intent(in) :: design
162 real(kind=rp),
intent(in) :: weight
163 character(len=*),
intent(in) :: name
164 character(len=*),
intent(in) :: mask_name
168 call this%init_base(name,
design%size(), weight, mask_name)
171 this%u => neko_field_registry%get_field(
'u')
172 this%v => neko_field_registry%get_field(
'v')
173 this%w => neko_field_registry%get_field(
'w')
175 this%adjoint_u => neko_field_registry%get_field(
'u_adj')
176 this%adjoint_v => neko_field_registry%get_field(
'v_adj')
177 this%adjoint_w => neko_field_registry%get_field(
'w_adj')
182 call adjoint_forcing%init_from_components( &
186 this%u, this%v, this%w, this%weight, &
187 this%mask, this%has_mask, &
191 call simulation%adjoint_case%scheme%source_term%add_source_term( &
218 class(
design_t),
intent(in) :: design
219 type(field_t),
pointer :: wo1, wo2, wo3, work
220 type(field_t),
pointer :: objective_field
221 integer :: temp_indices(5)
224 call neko_scratch_registry%request_field(wo1, temp_indices(1))
225 call neko_scratch_registry%request_field(wo2, temp_indices(2))
226 call neko_scratch_registry%request_field(wo3, temp_indices(3))
227 call neko_scratch_registry%request_field(objective_field, temp_indices(4))
228 call neko_scratch_registry%request_field(work, temp_indices(5))
231 call grad(wo1%x, wo2%x, wo3%x, this%u%x, this%c_Xh)
232 call field_col3(objective_field, wo1, wo1)
233 call field_addcol3(objective_field, wo2, wo2)
234 call field_addcol3(objective_field, wo3, wo3)
236 call grad(wo1%x, wo2%x, wo3%x, this%v%x, this%c_Xh)
237 call field_addcol3(objective_field, wo1, wo1)
238 call field_addcol3(objective_field, wo2, wo2)
239 call field_addcol3(objective_field, wo3, wo3)
241 call grad(wo1%x, wo2%x, wo3%x, this%w%x, this%c_Xh)
242 call field_addcol3(objective_field, wo1, wo1)
243 call field_addcol3(objective_field, wo2, wo2)
244 call field_addcol3(objective_field, wo3, wo3)
248 if (this%has_mask)
then
249 if (neko_bcknd_device .eq. 1)
then
252 call field_copy(work, objective_field)
254 this%value = device_glsc2(work%x_d, this%c_xh%B_d, n)
256 this%value =
glsc2_mask(objective_field%x, this%C_Xh%b, &
257 n, this%mask%mask, this%mask%size)
260 if (neko_bcknd_device .eq. 1)
then
261 this%value = device_glsc2(objective_field%x_d, &
264 this%value = glsc2(objective_field%x, this%C_Xh%b, n)
268 call neko_scratch_registry%relinquish_field(temp_indices)
276 class(
design_t),
intent(in) :: design
277 type(field_t),
pointer :: work
278 integer :: temp_indices(1)
280 call neko_scratch_registry%request_field(work, temp_indices(1))
283 call field_col3(work, this%u, this%adjoint_u)
284 call field_addcol3(work, this%v, this%adjoint_v)
285 call field_addcol3(work, this%w, this%adjoint_w)
287 call field_cmult(work, -1.0_rp)
289 if (neko_bcknd_device .eq. 1)
then
290 call device_copy(this%sensitivity%x_d, work%x_d, this%sensitivity%size())
292 call copy(this%sensitivity%x, work%x, this%sensitivity%size())
295 call neko_scratch_registry%relinquish_field(temp_indices)