46 use num_types,
only: rp
47 use field_list,
only: field_list_t
48 use json_module,
only: json_file
49 use source_term,
only: source_term_t
50 use coefs,
only: coef_t
51 use interpolation,
only: interpolator_t
52 use space,
only: space_t, gl
53 use field,
only: field_t
54 use time_state,
only: time_state_t
57 use field_math,
only: field_addcol3, field_copy, field_cmult, field_add2, &
60 use point_zone,
only: point_zone_t
61 use utils,
only: neko_error
62 use field_registry,
only : neko_field_registry
63 use scratch_registry,
only: scratch_registry_t, neko_scratch_registry
64 use neko_config,
only: neko_bcknd_device
65 use math,
only: col2, invcol2
66 use device_math,
only: device_col2, device_invcol2
75 type(field_t),
pointer :: u => null()
77 type(field_t),
pointer :: v => null()
79 type(field_t),
pointer :: w => null()
81 type(field_t),
pointer :: chi => null()
85 class(point_zone_t),
pointer :: mask => null()
91 type(space_t),
pointer :: xh_gll
93 type(space_t),
pointer :: xh_gl
95 type(coef_t),
pointer :: c_xh_gl
97 type(interpolator_t),
pointer :: gll_to_gl
99 type(scratch_registry_t),
pointer :: scratch_gl
101 real(kind=rp) :: volume
105 procedure, pass(this) :: init => adjoint_lube_source_term_init_from_json
107 procedure, pass(this) :: init_from_components => &
108 adjoint_lube_source_term_init_from_components
110 procedure, pass(this) :: free => adjoint_lube_source_term_free
112 procedure, pass(this) :: compute_ => adjoint_lube_source_term_compute
122 subroutine adjoint_lube_source_term_init_from_json(this, json, fields, coef, &
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
137 end subroutine adjoint_lube_source_term_init_from_json
153 subroutine adjoint_lube_source_term_init_from_components(this, &
154 f_x, f_y, f_z, design, K, &
157 coef, c_Xh_GL, GLL_to_GL, dealias, volume, scratch_GL)
159 type(field_t),
pointer,
intent(in) :: f_x, f_y, f_z
160 class(
design_t),
intent(in),
target :: design
161 real(kind=rp),
intent(in) :: k
162 type(field_t),
intent(in),
target :: u, v, w
163 class(point_zone_t),
intent(in),
target :: mask
165 type(coef_t),
intent(in) :: coef
166 type(coef_t),
intent(in),
target :: c_Xh_GL
167 type(interpolator_t),
intent(in),
target :: GLL_to_GL
168 logical,
intent(in) :: dealias
169 real(kind=rp),
intent(in) :: volume
170 type(scratch_registry_t),
intent(in),
target :: scratch_gl
171 real(kind=rp) :: start_time
172 real(kind=rp) :: end_time
173 type(field_list_t) :: fields
178 end_time = 100000000.0_rp
185 call fields%assign(1, f_x)
186 call fields%assign(2, f_y)
187 call fields%assign(3, f_z)
189 call this%init_base(fields, coef, start_time, end_time)
192 this%c_Xh_GL => c_xh_gl
193 this%Xh_GL => this%c_Xh_GL%Xh
194 this%Xh_GLL => this%coef%Xh
195 this%GLL_to_GL => gll_to_gl
196 this%dealias = dealias
197 this%scratch_GL => scratch_gl
206 this%chi => neko_field_registry%get_field(
"brinkman_amplitude")
208 call neko_error(
'Unknown design type')
212 this%if_mask = if_mask
213 if (this%if_mask)
then
217 end subroutine adjoint_lube_source_term_init_from_components
220 subroutine adjoint_lube_source_term_free(this)
223 call this%free_base()
227 nullify(this%c_Xh_GL)
230 nullify(this%GLL_to_GL)
232 nullify(this%scratch_GL)
234 end subroutine adjoint_lube_source_term_free
239 subroutine adjoint_lube_source_term_compute(this, time)
241 type(time_state_t),
intent(in) :: time
242 type(field_t),
pointer :: fu, fv, fw
243 type(field_t),
pointer :: work
244 integer :: temp_indices(1)
245 type(field_t),
pointer :: accumulate, fld_GL, chi_GL
246 integer :: temp_indices_GL(3)
249 fu => this%fields%get_by_index(1)
250 fv => this%fields%get_by_index(2)
251 fw => this%fields%get_by_index(3)
257 call neko_scratch_registry%request_field(work, temp_indices(1))
258 call field_copy(work, this%chi)
261 call field_cmult(work, this%K / this%volume)
264 if (this%if_mask)
then
268 if (this%dealias)
then
269 nel = this%coef%msh%nelv
270 n_gl = nel * this%Xh_GL%lxyz
271 call this%scratch_GL%request_field(accumulate, temp_indices_gl(1))
272 call this%scratch_GL%request_field(fld_gl, temp_indices_gl(2))
273 call this%scratch_GL%request_field(chi_gl, temp_indices_gl(3))
275 call this%GLL_to_GL%map(chi_gl%x, work%x, nel, this%Xh_GL)
278 call this%GLL_to_GL%map(fld_gl%x, this%u%x, nel, this%Xh_GL)
279 call field_col3(accumulate, chi_gl, fld_gl)
280 if (neko_bcknd_device .eq. 1)
then
281 call device_col2(accumulate%x_d, this%c_Xh_GL%B_d, n_gl)
282 call this%GLL_to_GL%map(work%x, accumulate%x, nel, this%Xh_GLL)
283 call device_invcol2(work%x_d, this%coef%B_d, work%size())
285 call col2(accumulate%x, this%c_Xh_GL%B, n_gl)
286 call this%GLL_to_GL%map(work%x, accumulate%x, nel, this%Xh_GLL)
287 call invcol2(work%x, this%coef%B, work%size())
289 call field_add2(fu, work)
292 call this%GLL_to_GL%map(fld_gl%x, this%v%x, nel, this%Xh_GL)
293 call field_col3(accumulate, chi_gl, fld_gl)
294 if (neko_bcknd_device .eq. 1)
then
295 call device_col2(accumulate%x_d, this%c_Xh_GL%B_d, n_gl)
296 call this%GLL_to_GL%map(work%x, accumulate%x, nel, this%Xh_GLL)
297 call device_invcol2(work%x_d, this%coef%B_d, work%size())
299 call col2(accumulate%x, this%c_Xh_GL%B, n_gl)
300 call this%GLL_to_GL%map(work%x, accumulate%x, nel, this%Xh_GLL)
301 call invcol2(work%x, this%coef%B, work%size())
303 call field_add2(fv, work)
306 call this%GLL_to_GL%map(fld_gl%x, this%w%x, nel, this%Xh_GL)
307 call field_col3(accumulate, chi_gl, fld_gl)
308 if (neko_bcknd_device .eq. 1)
then
309 call device_col2(accumulate%x_d, this%c_Xh_GL%B_d, n_gl)
310 call this%GLL_to_GL%map(work%x, accumulate%x, nel, this%Xh_GLL)
311 call device_invcol2(work%x_d, this%coef%B_d, work%size())
313 call col2(accumulate%x, this%c_Xh_GL%B, n_gl)
314 call this%GLL_to_GL%map(work%x, accumulate%x, nel, this%Xh_GLL)
315 call invcol2(work%x, this%coef%B, work%size())
317 call field_add2(fw, work)
319 call this%scratch_GL%relinquish_field(temp_indices_gl)
323 call field_addcol3(fu, this%u, work)
324 call field_addcol3(fv, this%v, work)
325 call field_addcol3(fw, this%w, work)
329 call neko_scratch_registry%relinquish_field(temp_indices)
331 end subroutine adjoint_lube_source_term_compute
Implements the adjoint_lube_source_term_t type.
Some common Masking operations we may need.
A adjoint source term corresponding to an objective of.
A topology optimization design variable.