36 use num_types,
only: rp
37 use json_module,
only: json_file
38 use coefs,
only: coef_t
39 use field,
only: field_t
40 use field_math,
only: field_copy
47 type(coef_t),
pointer :: coef => null()
53 procedure, pass(this) :: init_base => mapping_init_base
55 procedure, pass(this) :: free_base => mapping_free_base
57 procedure, pass(this) :: apply_forward => mapping_apply_forward_wrapper
59 procedure, pass(this) :: apply_backward => mapping_apply_backward_wrapper
63 procedure(mapping_free), pass(this),
deferred :: free
65 procedure(mapping_forward_mapping), pass(this),
deferred :: forward_mapping
67 procedure(mapping_backward_mapping), pass(this),
deferred :: &
77 procedure, pass(this) :: free => mapping_wrapper_free
87 class(mapping_t),
intent(inout) :: this
88 type(json_file),
intent(inout) :: json
89 type(coef_t),
intent(inout) :: coef
95 subroutine mapping_free(this)
97 class(mapping_t),
intent(inout) :: this
98 end subroutine mapping_free
106 subroutine mapping_forward_mapping(this, X_out, X_in)
108 class(mapping_t),
intent(inout) :: this
109 type(field_t),
intent(in) :: X_in
110 type(field_t),
intent(inout) :: X_out
111 end subroutine mapping_forward_mapping
124 subroutine mapping_backward_mapping(this, sens_out, sens_in, X_in)
126 class(mapping_t),
intent(inout) :: this
127 type(field_t),
intent(in) :: sens_in
128 type(field_t),
intent(in) :: X_in
129 type(field_t),
intent(inout) :: sens_out
130 end subroutine mapping_backward_mapping
138 module subroutine mapping_factory(object, json, coef)
139 class(mapping_t),
allocatable,
intent(inout) :: object
140 type(json_file),
intent(inout) :: json
141 type(coef_t),
intent(inout) :: coef
142 end subroutine mapping_factory
143 end interface mapping_factory
145 public :: mapping_factory
149 subroutine mapping_init_base(this, json, coef)
150 class(mapping_t),
intent(inout) :: this
151 type(json_file),
intent(inout) :: json
152 type(coef_t),
intent(inout),
target :: coef
155 call this%X_in%init(coef%dof)
157 end subroutine mapping_init_base
160 subroutine mapping_free_base(this)
161 class(mapping_t),
intent(inout) :: this
163 call this%X_in%free()
166 end subroutine mapping_free_base
169 subroutine mapping_wrapper_free(this)
170 class(mapping_wrapper_t),
intent(inout) :: this
172 if (
allocated(this%mapping))
then
173 call this%mapping%free()
174 deallocate(this%mapping)
176 end subroutine mapping_wrapper_free
182 subroutine mapping_apply_forward_wrapper(this, X_out, X_in)
183 class(mapping_t),
intent(inout) :: this
184 type(field_t),
intent(inout) :: X_out
185 type(field_t),
intent(in) :: X_in
187 call field_copy(this%X_in, x_in)
188 call this%forward_mapping(x_out, this%X_in)
190 end subroutine mapping_apply_forward_wrapper
200 subroutine mapping_apply_backward_wrapper(this, sens_out, sens_in)
201 class(mapping_t),
intent(inout) :: this
202 type(field_t),
intent(inout) :: sens_out
203 type(field_t),
intent(in) :: sens_in
209 call this%backward_mapping(sens_out, sens_in, this%X_in)
211 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.