37 use num_types,
only: rp
38 use json_module,
only: json_file
39 use coefs,
only: coef_t
40 use field,
only: field_t
41 use field_math,
only: field_copy
48 type(coef_t),
pointer :: coef => null()
52 character(len=80) :: fld_name =
""
56 procedure, pass(this) :: init_base => mapping_init_base
58 procedure, pass(this) :: free_base => mapping_free_base
60 procedure, pass(this) :: apply_forward => mapping_apply_forward_wrapper
62 procedure, pass(this) :: apply_backward => mapping_apply_backward_wrapper
66 procedure(mapping_free), pass(this),
deferred :: free
68 procedure(mapping_forward_mapping), pass(this),
deferred :: forward_mapping
70 procedure(mapping_backward_mapping), pass(this),
deferred :: &
80 procedure, pass(this) :: free => mapping_wrapper_free
90 class(mapping_t),
intent(inout) :: this
91 type(json_file),
intent(inout) :: json
92 type(coef_t),
intent(inout) :: coef
98 subroutine mapping_free(this)
100 class(mapping_t),
intent(inout) :: this
101 end subroutine mapping_free
109 subroutine mapping_forward_mapping(this, X_out, X_in)
111 class(mapping_t),
intent(inout) :: this
112 type(field_t),
intent(in) :: X_in
113 type(field_t),
intent(inout) :: X_out
114 end subroutine mapping_forward_mapping
127 subroutine mapping_backward_mapping(this, sens_out, sens_in, X_in)
129 class(mapping_t),
intent(inout) :: this
130 type(field_t),
intent(in) :: sens_in
131 type(field_t),
intent(in) :: X_in
132 type(field_t),
intent(inout) :: sens_out
133 end subroutine mapping_backward_mapping
141 module subroutine mapping_factory(object, json, coef)
142 class(mapping_t),
allocatable,
intent(inout) :: object
143 type(json_file),
intent(inout) :: json
144 type(coef_t),
intent(inout) :: coef
145 end subroutine mapping_factory
146 end interface mapping_factory
148 public :: mapping_factory
152 subroutine mapping_init_base(this, json, coef, fld_name)
153 class(mapping_t),
intent(inout) :: this
154 type(json_file),
intent(inout) :: json
155 character(len=*),
intent(in) :: fld_name
156 type(coef_t),
intent(inout),
target :: coef
159 this%fld_name = fld_name
161 call this%X_in%init(coef%dof)
163 end subroutine mapping_init_base
166 subroutine mapping_free_base(this)
167 class(mapping_t),
intent(inout) :: this
169 call this%X_in%free()
172 end subroutine mapping_free_base
175 subroutine mapping_wrapper_free(this)
176 class(mapping_wrapper_t),
intent(inout) :: this
178 if (
allocated(this%mapping))
then
179 call this%mapping%free()
180 deallocate(this%mapping)
182 end subroutine mapping_wrapper_free
188 subroutine mapping_apply_forward_wrapper(this, X_out, X_in)
189 class(mapping_t),
intent(inout) :: this
190 type(field_t),
intent(inout) :: X_out
191 type(field_t),
intent(in) :: X_in
193 call field_copy(this%X_in, x_in)
194 call this%forward_mapping(x_out, this%X_in)
196 end subroutine mapping_apply_forward_wrapper
206 subroutine mapping_apply_backward_wrapper(this, sens_out, sens_in)
207 class(mapping_t),
intent(inout) :: this
208 type(field_t),
intent(inout) :: sens_out
209 type(field_t),
intent(in) :: sens_in
215 call this%backward_mapping(sens_out, sens_in, this%X_in)
217 end subroutine mapping_apply_backward_wrapper
mapping factory. Both constructs and initializes the object.
The common constructor using a JSON dictionary.
Mappings to be applied to a scalar field.
Base abstract class for mapping.
A helper type that is needed to have an array of polymorphic objects.