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_ramp_mapping,
only: device_convex_down_ramp_mapping_apply, &
44 device_convex_down_ramp_mapping_apply_backward
47 use json_utils,
only: json_get, json_get_or_default
48 use logger,
only: neko_log
49 use utils,
only: neko_error
75 real(kind=rp) :: f_min
77 real(kind=rp) :: f_max
85 procedure, pass(this) :: init_from_attributes => &
86 ramp_mapping_init_from_attributes
88 procedure, pass(this) :: free => ramp_mapping_free
90 procedure, pass(this) :: forward_mapping => ramp_forward_mapping
92 procedure, pass(this) :: backward_mapping => ramp_backward_mapping
100 type(json_file),
intent(inout) :: json
101 type(coef_t),
intent(inout) :: coef
102 real(kind=rp) :: f_min, f_max, q
106 if (json%valid_path(
'convex_up'))
then
107 call neko_error(
"RAMP mapping's 'convex_up' option has been " // &
108 "removed -- plain RAMP is now always the down/increasing form " // &
109 "(x=0:fluid, x=1:solid). For the x=0:solid/x=1:fluid form, " // &
110 "use type 'Borrvall_Petersson' instead.")
113 call json_get_or_default(json,
'f_min', f_min, 0.0_rp)
114 call nekotop_continuation%json_get_or_register(json,
'f_max', this%f_max, &
116 call nekotop_continuation%json_get_or_register(json,
'q', this%q, q, 1.0_rp)
118 call this%init_base(json, coef,
"RAMP_mapping")
119 call this%init_from_attributes(coef, f_min, f_max, q)
124 subroutine ramp_mapping_init_from_attributes(this, coef, f_min, f_max, q)
126 type(coef_t),
intent(inout) :: coef
127 real(kind=rp),
intent(in) :: f_min, f_max, q
128 character(len=256) :: msg
134 call neko_log%section(
'RAMP Mapping')
135 write(msg,
'(A,F8.4)')
' f_min: ', this%f_min
136 call neko_log%message(msg)
137 write(msg,
'(A,F8.4)')
' f_max: ', this%f_max
138 call neko_log%message(msg)
139 write(msg,
'(A,F8.4)')
' q: ', this%q
140 call neko_log%message(msg)
141 call neko_log%end_section()
143 end subroutine ramp_mapping_init_from_attributes
146 subroutine ramp_mapping_free(this)
149 call this%free_base()
151 end subroutine ramp_mapping_free
157 subroutine ramp_forward_mapping(this, X_out, X_in)
159 type(field_t),
intent(in) :: X_in
160 type(field_t),
intent(inout) :: X_out
162 call convex_down_ramp_mapping_apply(this%f_min, this%f_max, &
165 end subroutine ramp_forward_mapping
173 subroutine ramp_backward_mapping(this, sens_out, sens_in, X_in)
175 type(field_t),
intent(in) :: X_in
176 type(field_t),
intent(in) :: sens_in
177 type(field_t),
intent(inout) :: sens_out
179 call convex_down_ramp_mapping_apply_backward(this%f_min, this%f_max, &
180 this%q, sens_out, sens_in, x_in)
182 end subroutine ramp_backward_mapping
190 subroutine convex_down_ramp_mapping_apply(f_min, f_max, q, X_out, X_in)
191 real(kind=rp),
intent(in) :: q, f_min, f_max
192 type(field_t),
intent(in) :: x_in
193 type(field_t),
intent(inout) :: X_out
199 if (neko_bcknd_device .eq. 1)
then
200 call device_convex_down_ramp_mapping_apply(f_min, f_max, q, &
201 x_out%x_d, x_in%x_d, n)
207 end subroutine convex_down_ramp_mapping_apply
217 subroutine convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
218 sens_out, sens_in, X_in)
219 real(kind=rp),
intent(in) :: f_min, f_max, q
220 type(field_t),
intent(in) :: x_in
221 type(field_t),
intent(in) :: sens_in
222 type(field_t),
intent(inout) :: sens_out
231 if (neko_bcknd_device .eq. 1)
then
232 call device_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
233 sens_out%x_d, sens_in%x_d, x_in%x_d, n)
236 sens_out%x, sens_in%x, x_in%x, n)
239 end subroutine convex_down_ramp_mapping_apply_backward
Continuation scheduler for the optimization loop.
Mappings to be applied to a scalar field.
CPU backend for RAMP mapping operations.
subroutine, public convex_down_ramp_mapping_apply_backward_cpu(f_min, f_max, q, sens_out, sens_in, x_in, n)
Apply convex-down RAMP chain rule on CPU.
subroutine, public convex_down_ramp_mapping_apply_cpu(f_min, f_max, q, x_out, x_in, n)
Apply convex-down RAMP forward mapping on CPU.
A RAMP mapping of coefficients.
subroutine ramp_mapping_init_from_json(this, json, coef)
Constructor from json.
Base abstract class for mapping.
A RAMP mapping of coefficients This is the standard RAMP described in https://doi....