36 use num_types,
only: rp
38 use json_module,
only: json_file
39 use field,
only: field_t
40 use coefs,
only: coef_t
41 use neko_config,
only: neko_bcknd_device
42 use device_simp_mapping,
only: device_simp_mapping_apply, &
43 device_simp_mapping_apply_backward
46 use json_utils,
only: json_get, json_get_or_default
57 real(kind=rp) :: f_min
59 real(kind=rp) :: f_max
65 procedure, pass(this) :: init => simp_mapping_init_from_json
67 procedure, pass(this) :: init_from_attributes => &
68 simp_mapping_init_from_attributes
70 procedure, pass(this) :: free => simp_mapping_free
72 procedure, pass(this) :: forward_mapping => simp_forward_mapping
74 procedure, pass(this) :: backward_mapping => simp_backward_mapping
80 subroutine simp_mapping_init_from_json(this, json, coef)
82 type(json_file),
intent(inout) :: json
83 type(coef_t),
intent(inout) :: coef
84 real(kind=rp) :: f_min, f_max, p
86 call json_get_or_default(json,
'f_min', f_min, 0.0_rp)
87 call nekotop_continuation%json_get_or_register(json,
'f_max', this%f_max, &
89 call nekotop_continuation%json_get_or_register(json,
'p', this%p, p, 1.0_rp)
91 call this%init_base(json, coef,
"SIMP_mapping")
92 call this%init_from_attributes(coef, f_min, f_max, p)
94 end subroutine simp_mapping_init_from_json
97 subroutine simp_mapping_init_from_attributes(this, coef, f_min, f_max, p)
99 type(coef_t),
intent(inout) :: coef
100 real(kind=rp),
intent(in) :: f_min, f_max, p
106 end subroutine simp_mapping_init_from_attributes
109 subroutine simp_mapping_free(this)
112 call this%free_base()
114 end subroutine simp_mapping_free
120 subroutine simp_forward_mapping(this, X_out, X_in)
122 type(field_t),
intent(in) :: X_in
123 type(field_t),
intent(inout) :: X_out
127 if (neko_bcknd_device .eq. 1)
then
128 call device_simp_mapping_apply(this%f_min, this%f_max, this%p, &
129 x_out%x_d, x_in%x_d, n)
135 end subroutine simp_forward_mapping
143 subroutine simp_backward_mapping(this, sens_out, sens_in, X_in)
145 type(field_t),
intent(in) :: X_in
146 type(field_t),
intent(in) :: sens_in
147 type(field_t),
intent(inout) :: sens_out
151 if (neko_bcknd_device .eq. 1)
then
152 call device_simp_mapping_apply_backward(this%f_min, this%f_max, this%p, &
153 sens_out%x_d, sens_in%x_d, x_in%x_d, n)
156 sens_out%x, sens_in%x, x_in%x, n)
159 end subroutine simp_backward_mapping
Continuation scheduler for the optimization loop.
Mappings to be applied to a scalar field.
CPU backend for SIMP mapping operations.
subroutine, public simp_mapping_apply_backward_cpu(f_min, f_max, p, sens_out, sens_in, x_in, n)
Apply SIMP chain rule on CPU.
subroutine, public simp_mapping_apply_cpu(f_min, f_max, p, x_out, x_in, n)
Apply SIMP forward mapping on CPU.
A SIMP mapping of coefficients.
Base abstract class for mapping.
A SIMP mapping of coefficients.