36 use num_types,
only : rp
37 use field_list,
only : field_list_t
38 use field,
only: field_t
39 use field_registry,
only: neko_field_registry
40 use scratch_registry,
only: neko_scratch_registry
41 use json_module,
only : json_file
42 use json_utils,
only: json_get, json_get_or_default
43 use source_term,
only : source_term_t
44 use coefs,
only : coef_t
45 use field_math,
only: field_add2s2, field_copy, field_cadd
47 use point_zone,
only: point_zone_t
62 type(field_t),
pointer :: s => null()
64 real(kind=rp) :: obj_scale
66 real(kind=rp) :: phi_ref
68 class(point_zone_t),
pointer :: mask => null()
72 real(kind=rp) :: mask_volume
75 procedure, pass(this) :: init => &
76 adjoint_mixing_scalar_source_term_init_from_json
78 procedure, pass(this) :: init_from_components => &
79 adjoint_mixing_scalar_source_term_init_from_components
81 procedure, pass(this) :: free => adjoint_mixing_scalar_source_term_free
83 procedure, pass(this) :: compute_ => &
84 adjoint_mixing_scalar_source_term_compute
93 subroutine adjoint_mixing_scalar_source_term_init_from_json(this, &
96 type(json_file),
intent(inout) :: json
97 type(field_list_t),
intent(in),
target :: fields
98 type(coef_t),
intent(in),
target :: coef
101 end subroutine adjoint_mixing_scalar_source_term_init_from_json
104 subroutine adjoint_mixing_scalar_source_term_init_from_components(this, &
105 f_s, s, obj_scale, phi_ref, mask, if_mask, coef)
107 type(field_t),
pointer,
intent(in) :: f_s
108 real(kind=rp),
intent(in) :: phi_ref
109 type(field_t),
intent(in),
target :: s
110 class(point_zone_t),
intent(in),
target :: mask
111 type(field_list_t) :: fields
113 real(kind=rp) :: start_time
114 real(kind=rp) :: end_time
115 real(kind=rp) :: obj_scale
120 end_time = 100000000.0_rp
128 call fields%assign(1, f_s)
130 call this%init_base(fields, coef, start_time, end_time)
134 this%obj_scale = obj_scale
135 this%phi_ref = phi_ref
136 this%if_mask = if_mask
138 if (this%if_mask)
then
140 this%mask_volume = compute_masked_volume(this%mask, coef)
142 this%mask_volume = coef%volume
145 end subroutine adjoint_mixing_scalar_source_term_init_from_components
148 subroutine adjoint_mixing_scalar_source_term_free(this)
151 call this%free_base()
152 end subroutine adjoint_mixing_scalar_source_term_free
158 subroutine adjoint_mixing_scalar_source_term_compute(this, t, tstep)
160 real(kind=rp),
intent(in) :: t
161 integer,
intent(in) :: tstep
162 type(field_t),
pointer :: fs
163 type(field_t),
pointer :: work
164 integer :: temp_indices(1)
167 fs => this%fields%get(1)
169 call neko_scratch_registry%request_field(work, temp_indices(1))
171 call field_copy(work, this%s)
173 call field_cadd(work, -this%phi_ref)
175 if (this%if_mask)
then
180 call field_add2s2(fs, work, this%obj_scale / this%mask_volume)
181 call neko_scratch_registry%relinquish_field(temp_indices)
184 end subroutine adjoint_mixing_scalar_source_term_compute
Implements the adjoint_mixing_scalar_source_term type.
Some common Masking operations we may need.