36 use num_types,
only: rp
37 use field_list,
only: field_list_t
38 use field,
only: field_t
39 use scratch_registry,
only: neko_scratch_registry
40 use json_module,
only: json_file
41 use time_state,
only: time_state_t
42 use source_term,
only: source_term_t
43 use coefs,
only: coef_t
44 use field_math,
only: field_subcol3
45 use operators,
only: grad
58 type,
public,
extends(source_term_t) :: &
61 type(field_t),
pointer :: s_adj => null()
63 type(field_t),
pointer :: s => null()
66 procedure, pass(this) :: init => &
67 adjoint_scalar_convection_source_term_init_from_json
69 procedure, pass(this) :: init_from_components => &
70 adjoint_scalar_convection_source_term_init_from_components
72 procedure, pass(this) :: free => adjoint_scalar_convection_source_term_free
74 procedure, pass(this) :: compute_ => &
75 adjoint_scalar_convection_source_term_compute
85 subroutine adjoint_scalar_convection_source_term_init_from_json(this, &
86 json, fields, coef, variable_name)
88 type(json_file),
intent(inout) :: json
89 type(field_list_t),
intent(in),
target :: fields
90 type(coef_t),
intent(in),
target :: coef
91 character(len=*),
intent(in) :: variable_name
101 end subroutine adjoint_scalar_convection_source_term_init_from_json
104 subroutine adjoint_scalar_convection_source_term_init_from_components(this,&
105 f_x, f_y, f_z, s, s_adj, coef)
107 type(field_t),
pointer,
intent(in) :: f_x, f_y, f_z
108 type(field_list_t) :: fields
110 real(kind=rp) :: start_time
111 real(kind=rp) :: end_time
112 type(field_t),
intent(in),
target :: s, s_adj
117 end_time = 100000000.0_rp
124 call fields%assign(1, f_x)
125 call fields%assign(2, f_y)
126 call fields%assign(3, f_z)
128 call this%init_base(fields, coef, start_time, end_time)
134 end subroutine adjoint_scalar_convection_source_term_init_from_components
137 subroutine adjoint_scalar_convection_source_term_free(this)
140 call this%free_base()
141 end subroutine adjoint_scalar_convection_source_term_free
146 subroutine adjoint_scalar_convection_source_term_compute(this, time)
148 type(time_state_t),
intent(in) :: time
149 type(field_t),
pointer :: fu, fv, fw
150 integer :: temp_indices(3)
151 type(field_t),
pointer :: dsdx, dsdy, dsdz
154 call neko_scratch_registry%request_field(dsdx, temp_indices(1))
155 call neko_scratch_registry%request_field(dsdy, temp_indices(2))
156 call neko_scratch_registry%request_field(dsdz, temp_indices(3))
158 fu => this%fields%get(1)
159 fv => this%fields%get(2)
160 fw => this%fields%get(3)
170 call grad(dsdx%x, dsdy%x, dsdz%x, this%s%x, this%coef)
177 call field_subcol3(fu, this%s_adj, dsdx)
178 call field_subcol3(fv, this%s_adj, dsdy)
179 call field_subcol3(fw, this%s_adj, dsdz)
182 call neko_scratch_registry%relinquish_field(temp_indices)
183 end subroutine adjoint_scalar_convection_source_term_compute
Implements the adjoint_scalar_convection_source_term type.