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
101 subroutine adjoint_lube_source_term_init_from_json(this, json, fields, coef, &
104 type(json_file),
intent(inout) :: json
105 type(field_list_t),
intent(in),
target :: fields
106 type(coef_t),
intent(in),
target :: coef
107 character(len=*),
intent(in) :: variable_name
116 end subroutine adjoint_lube_source_term_init_from_json
127 subroutine adjoint_lube_source_term_init_from_components(this, &
128 f_x, f_y, f_z, design, K, &
133 type(field_t),
pointer,
intent(in) :: f_x, f_y, f_z
134 class(
design_t),
intent(in),
target :: design
135 class(point_zone_t),
intent(in),
target :: mask
136 type(coef_t),
intent(in) :: coef
137 real(kind=rp) :: start_time
138 real(kind=rp) :: end_time
139 type(field_list_t) :: fields
142 type(field_t),
intent(in),
target :: u, v, w
147 end_time = 100000000.0_rp
154 call fields%assign(1, f_x)
155 call fields%assign(2, f_y)
156 call fields%assign(3, f_z)
158 call this%init_base(fields, coef, start_time, end_time)
169 this%chi => neko_field_registry%get_field(
"brinkman_amplitude")
171 call neko_error(
'Unknown design type')
175 this%if_mask = if_mask
176 if (this%if_mask)
then
180 end subroutine adjoint_lube_source_term_init_from_components
183 subroutine adjoint_lube_source_term_free(this)
186 call this%free_base()
187 end subroutine adjoint_lube_source_term_free
193 subroutine adjoint_lube_source_term_compute(this, t, tstep)
195 real(kind=rp),
intent(in) :: t
196 integer,
intent(in) :: tstep
197 type(field_t),
pointer :: fu, fv, fw
198 type(field_t),
pointer :: work
199 integer :: temp_indices(1)
201 fu => this%fields%get_by_index(1)
202 fv => this%fields%get_by_index(2)
203 fw => this%fields%get_by_index(3)
209 call neko_scratch_registry%request_field(work, temp_indices(1))
210 call field_copy(work, this%chi)
213 call field_cmult(work, this%K)
216 if (this%if_mask)
then
221 call field_addcol3(fu, this%u, work)
222 call field_addcol3(fv, this%v, work)
223 call field_addcol3(fw, this%w, work)
224 call neko_scratch_registry%relinquish_field(temp_indices)
226 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.