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()
54 procedure, pass(this) :: init_base => mapping_init_base
56 procedure, pass(this) :: free_base => mapping_free_base
58 procedure, pass(this) :: apply_forward => mapping_apply_forward_wrapper
60 procedure, pass(this) :: apply_backward => mapping_apply_backward_wrapper
64 procedure(mapping_free), pass(this),
deferred :: free
66 procedure(mapping_forward_mapping), pass(this),
deferred :: forward_mapping
68 procedure(mapping_backward_mapping), pass(this),
deferred :: &
78 procedure, pass(this) :: free => mapping_wrapper_free
88 class(mapping_t),
intent(inout) :: this
89 type(json_file),
intent(inout) :: json
90 type(coef_t),
intent(inout) :: coef
96 subroutine mapping_free(this)
98 class(mapping_t),
intent(inout) :: this
99 end subroutine mapping_free
107 subroutine mapping_forward_mapping(this, X_out, X_in)
109 class(mapping_t),
intent(inout) :: this
110 type(field_t),
intent(in) :: X_in
111 type(field_t),
intent(inout) :: X_out
112 end subroutine mapping_forward_mapping
125 subroutine mapping_backward_mapping(this, sens_out, sens_in, X_in)
127 class(mapping_t),
intent(inout) :: this
128 type(field_t),
intent(in) :: sens_in
129 type(field_t),
intent(in) :: X_in
130 type(field_t),
intent(inout) :: sens_out
131 end subroutine mapping_backward_mapping
139 module subroutine mapping_factory(object, json, coef)
140 class(mapping_t),
allocatable,
intent(inout) :: object
141 type(json_file),
intent(inout) :: json
142 type(coef_t),
intent(inout) :: coef
143 end subroutine mapping_factory
144 end interface mapping_factory
146 public :: mapping_factory
150 subroutine mapping_init_base(this, json, coef)
151 class(mapping_t),
intent(inout) :: this
152 type(json_file),
intent(inout) :: json
153 type(coef_t),
intent(inout),
target :: coef
156 call this%X_in%init(coef%dof)
158 end subroutine mapping_init_base
161 subroutine mapping_free_base(this)
162 class(mapping_t),
intent(inout) :: this
164 call this%X_in%free()
167 end subroutine mapping_free_base
170 subroutine mapping_wrapper_free(this)
171 class(mapping_wrapper_t),
intent(inout) :: this
173 if (
allocated(this%mapping))
then
174 call this%mapping%free()
175 deallocate(this%mapping)
177 end subroutine mapping_wrapper_free
183 subroutine mapping_apply_forward_wrapper(this, X_out, X_in)
184 class(mapping_t),
intent(inout) :: this
185 type(field_t),
intent(inout) :: X_out
186 type(field_t),
intent(in) :: X_in
188 call field_copy(this%X_in, x_in)
189 call this%forward_mapping(x_out, this%X_in)
191 end subroutine mapping_apply_forward_wrapper
201 subroutine mapping_apply_backward_wrapper(this, sens_out, sens_in)
202 class(mapping_t),
intent(inout) :: this
203 type(field_t),
intent(inout) :: sens_out
204 type(field_t),
intent(in) :: sens_in
210 call this%backward_mapping(sens_out, sens_in, this%X_in)
212 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.