37 use num_types,
only: rp
39 use json_module,
only: json_file
40 use field,
only: field_t
41 use coefs,
only: coef_t
42 use neko_config,
only: neko_bcknd_device
43 use device_borrvall_petersson_mapping,
only: &
44 device_borrvall_petersson_mapping_apply, &
45 device_borrvall_petersson_mapping_apply_backward
49 use json_utils,
only: json_get, json_get_or_default
50 use logger,
only: neko_log
83 real(kind=rp) :: f_min
85 real(kind=rp) :: f_max
93 procedure, pass(this) :: init_from_attributes => &
94 borrvall_petersson_mapping_init_from_attributes
96 procedure, pass(this) :: free => borrvall_petersson_mapping_free
98 procedure, pass(this) :: forward_mapping => &
99 borrvall_petersson_forward_mapping
101 procedure, pass(this) :: backward_mapping => &
102 borrvall_petersson_backward_mapping
110 type(json_file),
intent(inout) :: json
111 type(coef_t),
intent(inout) :: coef
112 real(kind=rp) :: f_min, f_max, q
114 call json_get_or_default(json,
'f_min', f_min, 0.0_rp)
115 call nekotop_continuation%json_get_or_register(json,
'f_max', this%f_max, &
117 call nekotop_continuation%json_get_or_register(json,
'q', this%q, q, 1.0_rp)
119 call this%init_base(json, coef,
"Borrvall_Petersson_mapping")
120 call this%init_from_attributes(coef, f_min, f_max, q)
125 subroutine borrvall_petersson_mapping_init_from_attributes(this, coef, &
128 type(coef_t),
intent(inout) :: coef
129 real(kind=rp),
intent(in) :: f_min, f_max, q
130 character(len=256) :: msg
136 call neko_log%section(
'Borrvall & Petersson Mapping')
137 write(msg,
'(A,F8.4)')
' f_min: ', this%f_min
138 call neko_log%message(msg)
139 write(msg,
'(A,F8.4)')
' f_max: ', this%f_max
140 call neko_log%message(msg)
141 write(msg,
'(A,F8.4)')
' q: ', this%q
142 call neko_log%message(msg)
143 call neko_log%end_section()
145 end subroutine borrvall_petersson_mapping_init_from_attributes
148 subroutine borrvall_petersson_mapping_free(this)
151 call this%free_base()
153 end subroutine borrvall_petersson_mapping_free
159 subroutine borrvall_petersson_forward_mapping(this, X_out, X_in)
161 type(field_t),
intent(in) :: X_in
162 type(field_t),
intent(inout) :: X_out
172 if (neko_bcknd_device .eq. 1)
then
173 call device_borrvall_petersson_mapping_apply(this%f_max, this%f_min, &
174 this%q, x_out%x_d, x_in%x_d, n)
177 this%q, x_out%x, x_in%x, n)
180 end subroutine borrvall_petersson_forward_mapping
188 subroutine borrvall_petersson_backward_mapping(this, sens_out, sens_in, X_in)
190 type(field_t),
intent(in) :: X_in
191 type(field_t),
intent(in) :: sens_in
192 type(field_t),
intent(inout) :: sens_out
200 if (neko_bcknd_device .eq. 1)
then
201 call device_borrvall_petersson_mapping_apply_backward(this%f_max, &
202 this%f_min, this%q, sens_out%x_d, sens_in%x_d, x_in%x_d, n)
205 this%f_min, this%q, sens_out%x, sens_in%x, x_in%x, n)
208 end subroutine borrvall_petersson_backward_mapping
Continuation scheduler for the optimization loop.
Mappings to be applied to a scalar field.
Base abstract class for mapping.