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 time_state,
only: time_state_t
43 use json_utils,
only: json_get, json_get_or_default
44 use source_term,
only : source_term_t
45 use coefs,
only : coef_t
46 use field_math,
only: field_add2s2, field_copy, field_cadd
48 use point_zone,
only: point_zone_t
63 type(field_t),
pointer :: s => null()
65 real(kind=rp) :: obj_scale
67 real(kind=rp) :: phi_ref
69 class(point_zone_t),
pointer :: mask => null()
73 real(kind=rp) :: mask_volume
76 procedure, pass(this) :: init => &
77 adjoint_mixing_scalar_source_term_init_from_json
79 procedure, pass(this) :: init_from_components => &
80 adjoint_mixing_scalar_source_term_init_from_components
82 procedure, pass(this) :: free => adjoint_mixing_scalar_source_term_free
84 procedure, pass(this) :: compute_ => &
85 adjoint_mixing_scalar_source_term_compute
95 subroutine adjoint_mixing_scalar_source_term_init_from_json(this, &
96 json, fields, coef, variable_name)
98 type(json_file),
intent(inout) :: json
99 type(field_list_t),
intent(in),
target :: fields
100 type(coef_t),
intent(in),
target :: coef
101 character(len=*),
intent(in) :: variable_name
104 end subroutine adjoint_mixing_scalar_source_term_init_from_json
107 subroutine adjoint_mixing_scalar_source_term_init_from_components(this, &
108 f_s, s, obj_scale, phi_ref, mask, if_mask, coef)
110 type(field_t),
pointer,
intent(in) :: f_s
111 real(kind=rp),
intent(in) :: phi_ref
112 type(field_t),
intent(in),
target :: s
113 class(point_zone_t),
intent(in),
target :: mask
114 type(field_list_t) :: fields
116 real(kind=rp) :: start_time
117 real(kind=rp) :: end_time
118 real(kind=rp) :: obj_scale
123 end_time = 100000000.0_rp
131 call fields%assign(1, f_s)
133 call this%init_base(fields, coef, start_time, end_time)
137 this%obj_scale = obj_scale
138 this%phi_ref = phi_ref
139 this%if_mask = if_mask
141 if (this%if_mask)
then
143 this%mask_volume = compute_masked_volume(this%mask, coef)
145 this%mask_volume = coef%volume
148 end subroutine adjoint_mixing_scalar_source_term_init_from_components
151 subroutine adjoint_mixing_scalar_source_term_free(this)
154 call this%free_base()
155 end subroutine adjoint_mixing_scalar_source_term_free
160 subroutine adjoint_mixing_scalar_source_term_compute(this, time)
162 type(time_state_t),
intent(in) :: time
163 type(field_t),
pointer :: fs
164 type(field_t),
pointer :: work
165 integer :: temp_indices(1)
168 fs => this%fields%get(1)
170 call neko_scratch_registry%request_field(work, temp_indices(1))
172 call field_copy(work, this%s)
174 call field_cadd(work, -this%phi_ref)
176 if (this%if_mask)
then
181 call field_add2s2(fs, work, this%obj_scale / this%mask_volume)
182 call neko_scratch_registry%relinquish_field(temp_indices)
185 end subroutine adjoint_mixing_scalar_source_term_compute
Implements the adjoint_mixing_scalar_source_term type.
Some common Masking operations we may need.