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 source_term,
only: source_term_t
42 use coefs,
only: coef_t
43 use field_math,
only: field_subcol3
44 use operators,
only: grad
57 type,
public,
extends(source_term_t) :: &
60 type(field_t),
pointer :: s_adj => null()
62 type(field_t),
pointer :: s => null()
65 procedure, pass(this) :: init => &
66 adjoint_scalar_convection_source_term_init_from_json
68 procedure, pass(this) :: init_from_components => &
69 adjoint_scalar_convection_source_term_init_from_components
71 procedure, pass(this) :: free => adjoint_scalar_convection_source_term_free
73 procedure, pass(this) :: compute_ => &
74 adjoint_scalar_convection_source_term_compute
83 subroutine adjoint_scalar_convection_source_term_init_from_json(this, &
86 type(json_file),
intent(inout) :: json
87 type(field_list_t),
intent(in),
target :: fields
88 type(coef_t),
intent(in),
target :: coef
98 end subroutine adjoint_scalar_convection_source_term_init_from_json
101 subroutine adjoint_scalar_convection_source_term_init_from_components(this,&
102 f_x, f_y, f_z, s, s_adj, coef)
104 type(field_t),
pointer,
intent(in) :: f_x, f_y, f_z
105 type(field_list_t) :: fields
107 real(kind=rp) :: start_time
108 real(kind=rp) :: end_time
109 type(field_t),
intent(in),
target :: s, s_adj
114 end_time = 100000000.0_rp
121 call fields%assign(1, f_x)
122 call fields%assign(2, f_y)
123 call fields%assign(3, f_z)
125 call this%init_base(fields, coef, start_time, end_time)
131 end subroutine adjoint_scalar_convection_source_term_init_from_components
134 subroutine adjoint_scalar_convection_source_term_free(this)
137 call this%free_base()
138 end subroutine adjoint_scalar_convection_source_term_free
144 subroutine adjoint_scalar_convection_source_term_compute(this, t, tstep)
146 real(kind=rp),
intent(in) :: t
147 integer,
intent(in) :: tstep
148 type(field_t),
pointer :: fu, fv, fw
149 integer :: temp_indices(3)
150 type(field_t),
pointer :: dsdx, dsdy, dsdz
153 call neko_scratch_registry%request_field(dsdx, temp_indices(1))
154 call neko_scratch_registry%request_field(dsdy, temp_indices(2))
155 call neko_scratch_registry%request_field(dsdz, temp_indices(3))
157 fu => this%fields%get(1)
158 fv => this%fields%get(2)
159 fw => this%fields%get(3)
169 call grad(dsdx%x, dsdy%x, dsdz%x, this%s%x, this%coef)
176 call field_subcol3(fu, this%s_adj, dsdx)
177 call field_subcol3(fv, this%s_adj, dsdy)
178 call field_subcol3(fw, this%s_adj, dsdz)
181 call neko_scratch_registry%relinquish_field(temp_indices)
182 end subroutine adjoint_scalar_convection_source_term_compute
Implements the adjoint_scalar_convection_source_term type.