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
116 subroutine adjoint_mixing_scalar_source_term_init_from_components(this, &
117 f_s, s, obj_scale, phi_ref, mask, if_mask, coef)
119 type(field_t),
pointer,
intent(in) :: f_s
120 real(kind=rp),
intent(in) :: phi_ref
121 type(field_t),
intent(in),
target :: s
122 class(point_zone_t),
intent(in),
target :: mask
123 type(field_list_t) :: fields
125 real(kind=rp) :: start_time
126 real(kind=rp) :: end_time
127 real(kind=rp) :: obj_scale
132 end_time = 100000000.0_rp
140 call fields%assign(1, f_s)
142 call this%init_base(fields, coef, start_time, end_time)
146 this%obj_scale = obj_scale
147 this%phi_ref = phi_ref
148 this%if_mask = if_mask
150 if (this%if_mask)
then
154 this%mask_volume = coef%volume
157 end subroutine adjoint_mixing_scalar_source_term_init_from_components
160 subroutine adjoint_mixing_scalar_source_term_free(this)
163 call this%free_base()
167 end subroutine adjoint_mixing_scalar_source_term_free
172 subroutine adjoint_mixing_scalar_source_term_compute(this, time)
174 type(time_state_t),
intent(in) :: time
175 type(field_t),
pointer :: fs
176 type(field_t),
pointer :: work
177 integer :: temp_indices(1)
180 fs => this%fields%get(1)
182 call neko_scratch_registry%request_field(work, temp_indices(1), .false.)
184 call field_copy(work, this%s)
186 call field_cadd(work, -this%phi_ref)
188 if (this%if_mask)
then
193 call field_add2s2(fs, work, this%obj_scale / this%mask_volume)
194 call neko_scratch_registry%relinquish_field(temp_indices)
197 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.