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 field,
only: field_t
54 use field_math,
only: field_addcol3, field_copy, field_cmult
55 use scratch_registry,
only: neko_scratch_registry
57 use point_zone,
only: point_zone_t
58 use utils,
only: neko_error
59 use field_registry,
only: neko_field_registry
68 type(field_t),
pointer :: u => null()
70 type(field_t),
pointer :: v => null()
72 type(field_t),
pointer :: w => null()
74 type(field_t),
pointer :: chi => null()
78 class(point_zone_t),
pointer :: mask => null()
84 procedure, pass(this) :: init => adjoint_lube_source_term_init_from_json
86 procedure, pass(this) :: init_from_components => &
87 adjoint_lube_source_term_init_from_components
89 procedure, pass(this) :: free => adjoint_lube_source_term_free
91 procedure, pass(this) :: compute_ => adjoint_lube_source_term_compute
100 subroutine adjoint_lube_source_term_init_from_json(this, json, fields, coef)
102 type(json_file),
intent(inout) :: json
103 type(field_list_t),
intent(in),
target :: fields
104 type(coef_t),
intent(in),
target :: coef
113 end subroutine adjoint_lube_source_term_init_from_json
124 subroutine adjoint_lube_source_term_init_from_components(this, &
125 f_x, f_y, f_z, design, K, &
130 type(field_t),
pointer,
intent(in) :: f_x, f_y, f_z
131 class(
design_t),
intent(in),
target :: design
132 class(point_zone_t),
intent(in),
target :: mask
133 type(coef_t),
intent(in) :: coef
134 real(kind=rp) :: start_time
135 real(kind=rp) :: end_time
136 type(field_list_t) :: fields
139 type(field_t),
intent(in),
target :: u, v, w
144 end_time = 100000000.0_rp
151 call fields%assign(1, f_x)
152 call fields%assign(2, f_y)
153 call fields%assign(3, f_z)
155 call this%init_base(fields, coef, start_time, end_time)
166 this%chi => neko_field_registry%get_field(
"brinkman_amplitude")
168 call neko_error(
'Unknown design type')
172 this%if_mask = if_mask
173 if (this%if_mask)
then
177 end subroutine adjoint_lube_source_term_init_from_components
180 subroutine adjoint_lube_source_term_free(this)
183 call this%free_base()
184 end subroutine adjoint_lube_source_term_free
190 subroutine adjoint_lube_source_term_compute(this, t, tstep)
192 real(kind=rp),
intent(in) :: t
193 integer,
intent(in) :: tstep
194 type(field_t),
pointer :: fu, fv, fw
195 type(field_t),
pointer :: work
196 integer :: temp_indices(1)
198 fu => this%fields%get_by_index(1)
199 fv => this%fields%get_by_index(2)
200 fw => this%fields%get_by_index(3)
206 call neko_scratch_registry%request_field(work, temp_indices(1))
207 call field_copy(work, this%chi)
210 call field_cmult(work, this%K)
213 if (this%if_mask)
then
218 call field_addcol3(fu, this%u, work)
219 call field_addcol3(fv, this%v, work)
220 call field_addcol3(fw, this%w, work)
221 call neko_scratch_registry%relinquish_field(temp_indices)
223 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.