37 use num_types,
only: rp
38 use field_math,
only: field_copy, field_cmult, field_cadd
40 use num_types,
only: rp
41 use json_module,
only: json_file
42 use field,
only: field_t
43 use coefs,
only: coef_t
44 use json_utils,
only: json_get, json_get_or_default
52 real(kind=rp) :: f_min
54 real(kind=rp) :: f_max
60 procedure, pass(this) :: init_from_attributes => &
61 linear_mapping_init_from_attributes
63 procedure, pass(this) :: free => linear_mapping_free
65 procedure, pass(this) :: forward_mapping => linear_forward_mapping
67 procedure, pass(this) :: backward_mapping => &
68 linear_backward_mapping
76 type(json_file),
intent(inout) :: json
77 type(coef_t),
intent(inout) :: coef
78 real(kind=rp) :: f_min, f_max
80 call json_get_or_default(json,
'f_min', f_min, 0.0_rp)
81 call nekotop_continuation%json_get_or_register(json,
'f_max', this%f_max, &
84 call this%init_base(json, coef,
"linear_mapping")
85 call linear_mapping_init_from_attributes(this, coef, f_min, f_max)
90 subroutine linear_mapping_init_from_attributes(this, coef, f_min, f_max)
92 type(coef_t),
intent(inout) :: coef
93 real(kind=rp),
intent(in) :: f_min, f_max
98 end subroutine linear_mapping_init_from_attributes
101 subroutine linear_mapping_free(this)
104 call this%free_base()
106 end subroutine linear_mapping_free
112 subroutine linear_forward_mapping(this, X_out, X_in)
114 type(field_t),
intent(in) :: X_in
115 type(field_t),
intent(inout) :: X_out
118 call field_copy(x_out, x_in)
119 call field_cmult(x_out, this%f_max - this%f_min)
120 call field_cadd(x_out, this%f_min)
122 end subroutine linear_forward_mapping
130 subroutine linear_backward_mapping(this, sens_out, sens_in, X_in)
132 type(field_t),
intent(in) :: X_in
133 type(field_t),
intent(in) :: sens_in
134 type(field_t),
intent(inout) :: sens_out
140 call field_copy(sens_out, sens_in)
141 call field_cmult(sens_out, this%f_max - this%f_min)
143 end subroutine linear_backward_mapping
Continuation scheduler for the optimization loop.
A linear mapping of coefficients.
subroutine linear_mapping_init_from_json(this, json, coef)
Constructor from json.
Mappings to be applied to a scalar field.
A linear mapping of coefficients $f(x) = f_{min} + (f_{max} - f_{min}) x$.
Base abstract class for mapping.