Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
mapping.f90
Go to the documentation of this file.
1
34!
36module mapping
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
42 implicit none
43 private
44
46 type, abstract, public :: mapping_t
48 type(coef_t), pointer :: coef => null()
50 type(field_t) :: x_in
51
52 contains
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
62 procedure(mapping_init), pass(this), deferred :: init
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 :: &
69 backward_mapping
70 end type mapping_t
71
73 type, public :: mapping_wrapper_t
75 class(mapping_t), allocatable :: mapping
76 contains
78 procedure, pass(this) :: free => mapping_wrapper_free
79 end type mapping_wrapper_t
80
81 abstract interface
82
86 subroutine mapping_init(this, json, coef)
87 import mapping_t, json_file, coef_t
88 class(mapping_t), intent(inout) :: this
89 type(json_file), intent(inout) :: json
90 type(coef_t), intent(inout) :: coef
91 end subroutine mapping_init
92 end interface
93
94 abstract interface
95
96 subroutine mapping_free(this)
97 import mapping_t
98 class(mapping_t), intent(inout) :: this
99 end subroutine mapping_free
100 end interface
101
102 abstract interface
103
107 subroutine mapping_forward_mapping(this, X_out, X_in)
108 import mapping_t, field_t
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
113 end interface
114
115 abstract interface
116
125 subroutine mapping_backward_mapping(this, sens_out, sens_in, X_in)
126 import mapping_t, field_t
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
132 end interface
133
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
145
146 public :: mapping_factory
147contains
148
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
154
155 this%coef => coef
156 call this%X_in%init(coef%dof)
157
158 end subroutine mapping_init_base
159
161 subroutine mapping_free_base(this)
162 class(mapping_t), intent(inout) :: this
163
164 call this%X_in%free()
165 nullify(this%coef)
166
167 end subroutine mapping_free_base
168
170 subroutine mapping_wrapper_free(this)
171 class(mapping_wrapper_t), intent(inout) :: this
172
173 if (allocated(this%mapping)) then
174 call this%mapping%free()
175 deallocate(this%mapping)
176 end if
177 end subroutine mapping_wrapper_free
178
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
187
188 call field_copy(this%X_in, x_in)
189 call this%forward_mapping(x_out, this%X_in)
190
191 end subroutine mapping_apply_forward_wrapper
192
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
205 ! @todo
206 ! hmmmm, it would be silly to call mapping backward without mapping forward
207 ! but at least this%X_in is certainly initialized.
208 ! but it won't contain the correct information unless a map forward has
209 ! occured.
210 call this%backward_mapping(sens_out, sens_in, this%X_in)
211
212 end subroutine mapping_apply_backward_wrapper
213
214end module mapping
mapping factory. Both constructs and initializes the object.
Definition mapping.f90:138
The common constructor using a JSON dictionary.
Definition mapping.f90:86
Mappings to be applied to a scalar field.
Definition mapping.f90:36
Base abstract class for mapping.
Definition mapping.f90:46
A helper type that is needed to have an array of polymorphic objects.
Definition mapping.f90:73