38 use num_types,
only : rp
39 use field_list,
only : field_list_t
40 use field,
only: field_t
41 use registry,
only: neko_registry
42 use scratch_registry,
only: neko_scratch_registry
43 use json_module,
only : json_file
44 use time_state,
only: time_state_t
45 use json_utils,
only: json_get, json_get_or_default
46 use source_term,
only : source_term_t
47 use coefs,
only : coef_t
48 use field_math,
only: field_add2s2, field_copy, field_cadd
50 use point_zone,
only: point_zone_t
66 type(field_t),
pointer :: s => null()
68 real(kind=rp) :: obj_scale
70 real(kind=rp) :: phi_ref
72 class(point_zone_t),
pointer :: mask => null()
76 real(kind=rp) :: mask_volume
79 procedure, pass(this) :: init => &
80 adjoint_mixing_scalar_source_term_init_from_json
82 procedure, pass(this) :: init_from_components => &
83 adjoint_mixing_scalar_source_term_init_from_components
85 procedure, pass(this) :: free => adjoint_mixing_scalar_source_term_free
87 procedure, pass(this) :: compute_ => &
88 adjoint_mixing_scalar_source_term_compute
94 class(source_term_t),
allocatable,
intent(inout) :: obj
104 subroutine adjoint_mixing_scalar_source_term_init_from_json(this, &
105 json, fields, coef, variable_name)
107 type(json_file),
intent(inout) :: json
108 type(field_list_t),
intent(in),
target :: fields
109 type(coef_t),
intent(in),
target :: coef
110 character(len=*),
intent(in) :: variable_name
113 end subroutine adjoint_mixing_scalar_source_term_init_from_json
126 subroutine adjoint_mixing_scalar_source_term_init_from_components(this, &
127 f_s, s, obj_scale, phi_ref, mask, if_mask, coef, start_time, end_time)
129 type(field_t),
pointer,
intent(in) :: f_s
130 type(field_t),
intent(in),
target :: s
131 real(kind=rp),
intent(in) :: obj_scale
132 real(kind=rp),
intent(in) :: phi_ref
133 class(point_zone_t),
intent(in),
target :: mask
134 logical,
intent(in) :: if_mask
135 type(coef_t),
intent(in) :: coef
136 real(kind=rp),
intent(in) :: start_time
137 real(kind=rp),
intent(in) :: end_time
139 type(field_list_t) :: fields
146 call fields%assign(1, f_s)
148 call this%init_base(fields, coef, start_time, end_time)
153 this%obj_scale = obj_scale
154 this%phi_ref = phi_ref
155 this%if_mask = if_mask
157 if (this%if_mask)
then
161 this%mask_volume = coef%volume
164 end subroutine adjoint_mixing_scalar_source_term_init_from_components
167 subroutine adjoint_mixing_scalar_source_term_free(this)
170 call this%free_base()
174 end subroutine adjoint_mixing_scalar_source_term_free
179 subroutine adjoint_mixing_scalar_source_term_compute(this, time)
181 type(time_state_t),
intent(in) :: time
182 type(field_t),
pointer :: fs
183 type(field_t),
pointer :: work
184 integer :: temp_indices(1)
187 fs => this%fields%get(1)
189 call neko_scratch_registry%request_field(work, temp_indices(1), .false.)
191 call field_copy(work, this%s)
193 call field_cadd(work, -this%phi_ref)
195 if (this%if_mask)
then
200 call field_add2s2(fs, work, this%obj_scale / this%mask_volume)
201 call neko_scratch_registry%relinquish_field(temp_indices)
204 end subroutine adjoint_mixing_scalar_source_term_compute
Implements the adjoint_mixing_scalar_source_term type.
subroutine, public adjoint_mixing_scalar_source_term_allocate(obj)
Allocator for the adjoint mixing scalar source term.
Some common Masking operations we may need.
real(kind=rp) function, public compute_masked_volume(mask, coef)
Compute the volume of the domain contained within the mask.