Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
adjoint_fluid_scheme.f90
1! Copyright (c) 2020-2024, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
33module adjoint_fluid_scheme
34 use gather_scatter, only: gs_t
35 use checkpoint, only: chkp_t
36 use num_types, only: rp
37 use field, only: field_t
38 use space, only: space_t
39 use dofmap, only: dofmap_t
40 use coefs, only: coef_t
41 use dirichlet, only: dirichlet_t
42 use precon, only: pc_t, precon_factory, precon_destroy
43 use fluid_stats, only: fluid_stats_t
44 use bc_list, only: bc_list_t
45 use mesh, only: mesh_t, neko_msh_max_zlbl_len
46 use time_state, only: time_state_t
47 use time_scheme_controller, only: time_scheme_controller_t
48 use logger, only: log_size
49 use json_module, only: json_file
50 use user_intf, only: user_t, user_material_properties_intf
51 use field_series, only: field_series_t
52 use time_step_controller, only: time_step_controller_t
53 use field_list, only : field_list_t
54 use interpolation, only: interpolator_t
55 use scratch_registry, only : scratch_registry_t
56
57 implicit none
58 private
59 public :: adjoint_fluid_scheme_t, adjoint_fluid_scheme_factory
60
62 type, abstract :: adjoint_fluid_scheme_t
64 character(len=:), allocatable :: name
65
66 type(space_t) :: xh
67 type(dofmap_t) :: dm_xh
68 type(gs_t) :: gs_xh
69 type(coef_t) :: c_xh
70
71 ! Tim. This will need to be refactored, but since we have so many extra
72 ! terms that involve products of variables, we often need to increase our
73 ! quadrature. So it's natural to have an over integration coef and a
74 ! way of converting between them
75 type(space_t) :: xh_gl
76 type(dofmap_t) :: dm_xh_gl
77 type(gs_t) :: gs_xh_gl
78 type(coef_t) :: c_xh_gl
80 type(interpolator_t) :: gll_to_gl
82 type(scratch_registry_t) :: scratch_gl
83
84 type(time_scheme_controller_t), allocatable :: ext_bdf
85
87 type(field_t), pointer :: u_adj => null()
88 type(field_t), pointer :: v_adj => null()
89 type(field_t), pointer :: w_adj => null()
90 type(field_t), pointer :: p_adj => null()
91 type(field_series_t) :: ulag, vlag, wlag
92
93 type(field_t), pointer :: u_b => null()
94 type(field_t), pointer :: v_b => null()
95 type(field_t), pointer :: w_b => null()
96 type(field_t), pointer :: p_b => null()
97
99 type(chkp_t), pointer :: chkp => null()
100
102 type(field_t), pointer :: f_adj_x => null()
104 type(field_t), pointer :: f_adj_y => null()
106 type(field_t), pointer :: f_adj_z => null()
107
109 ! List of boundary conditions for pressure
110 type(bc_list_t) :: bcs_prs
111 ! List of boundary conditions for velocity
112 type(bc_list_t) :: bcs_vel
113
114 type(json_file), pointer :: params
115 type(mesh_t), pointer :: msh => null()
116
118 character(len=NEKO_MSH_MAX_ZLBL_LEN), allocatable :: bc_labels(:)
119
121 type(field_t) :: rho
122
124 type(field_t) :: mu
125
127 type(field_list_t) :: material_properties
128
130 logical :: freeze = .false.
131
133 procedure(user_material_properties_intf), nopass, pointer :: &
134 user_material_properties => null()
135
136 contains
138 procedure(adjoint_fluid_scheme_init_intrf), pass(this), deferred :: init
140 procedure(adjoint_fluid_scheme_free_intrf), pass(this), deferred :: free
142 procedure(adjoint_fluid_scheme_step_intrf), pass(this), deferred :: step
144 procedure(adjoint_fluid_scheme_restart_intrf), &
145 pass(this), deferred :: restart
147 procedure(adjoint_fluid_scheme_setup_bcs_intrf), pass(this), deferred :: &
148 setup_bcs
149
151 procedure(validate_intrf), pass(this), deferred :: validate
153 procedure(fluid_scheme_base_compute_cfl_intrf), pass(this), deferred :: compute_cfl
155 procedure(update_material_properties), pass(this), deferred :: update_material_properties
157
159 abstract interface
160 subroutine adjoint_fluid_init_all_intrf(this, msh, lx, params, kspv_init, &
161 kspp_init, scheme, user)
163 import mesh_t
164 import json_file
165 import user_t
166 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
167 type(mesh_t), target, intent(inout) :: msh
168 integer, intent(inout) :: lx
169 type(json_file), target, intent(inout) :: params
170 logical, intent(inout) :: kspv_init
171 logical, intent(inout) :: kspp_init
172 type(user_t), target, intent(in) :: user
173 character(len=*), intent(in) :: scheme
174 end subroutine adjoint_fluid_init_all_intrf
175 end interface
176
178 abstract interface
179 subroutine adjoint_fluid_init_common_intrf(this, msh, lx, params, scheme, &
180 user, kspv_init)
182 import mesh_t
183 import json_file
184 import user_t
185 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
186 type(mesh_t), target, intent(inout) :: msh
187 integer, intent(inout) :: lx
188 character(len=*), intent(in) :: scheme
189 type(json_file), target, intent(inout) :: params
190 type(user_t), target, intent(in) :: user
191 logical, intent(in) :: kspv_init
192 end subroutine adjoint_fluid_init_common_intrf
193 end interface
194
196 abstract interface
197 subroutine adjoint_fluid_free_intrf(this)
199 class(adjoint_fluid_scheme_t), intent(inout) :: this
200 end subroutine adjoint_fluid_free_intrf
201 end interface
202
204 abstract interface
205 subroutine adjoint_fluid_scheme_init_intrf(this, msh, lx, params, user, &
206 chkp)
208 import json_file
209 import mesh_t
210 import user_t
211 import chkp_t
212 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
213 type(mesh_t), target, intent(inout) :: msh
214 integer, intent(in) :: lx
215 type(json_file), target, intent(inout) :: params
216 type(user_t), target, intent(in) :: user
217 type(chkp_t), target, intent(inout) :: chkp
218 end subroutine adjoint_fluid_scheme_init_intrf
219 end interface
220
222 abstract interface
223 subroutine adjoint_fluid_scheme_free_intrf(this)
225 class(adjoint_fluid_scheme_t), intent(inout) :: this
226 end subroutine adjoint_fluid_scheme_free_intrf
227 end interface
228
230 abstract interface
231 subroutine adjoint_fluid_scheme_step_intrf(this, time, dt_controller)
232 import time_state_t
234 import time_step_controller_t
235 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
236 type(time_state_t), intent(in) :: time
237 type(time_step_controller_t), intent(in) :: dt_controller
238 end subroutine adjoint_fluid_scheme_step_intrf
239 end interface
240
242 abstract interface
243 subroutine adjoint_fluid_scheme_restart_intrf(this, chkp)
245 import chkp_t
246 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
247 type(chkp_t), intent(inout) :: chkp
248 end subroutine adjoint_fluid_scheme_restart_intrf
249 end interface
250
252 abstract interface
253 subroutine adjoint_fluid_scheme_setup_bcs_intrf(this, user, params)
254 import adjoint_fluid_scheme_t, user_t, json_file
255 class(adjoint_fluid_scheme_t), intent(inout) :: this
256 type(user_t), target, intent(in) :: user
257 type(json_file), intent(inout) :: params
258 end subroutine adjoint_fluid_scheme_setup_bcs_intrf
259 end interface
260
262 abstract interface
263 subroutine validate_intrf(this)
265 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
266 end subroutine validate_intrf
267 end interface
268
270 abstract interface
271 subroutine update_material_properties(this, time)
272 import adjoint_fluid_scheme_t, time_state_t
273 class(adjoint_fluid_scheme_t), intent(inout) :: this
274 type(time_state_t), intent(in) :: time
275 end subroutine update_material_properties
276 end interface
277
279 abstract interface
280 function fluid_scheme_base_compute_cfl_intrf(this, dt) result(c)
282 import rp
283 class(adjoint_fluid_scheme_t), intent(in) :: this
284 real(kind=rp), intent(in) :: dt
285 real(kind=rp) :: c
286 end function fluid_scheme_base_compute_cfl_intrf
287 end interface
288
289 interface
290
291 module subroutine adjoint_fluid_scheme_factory(object, type_name)
292 class(adjoint_fluid_scheme_t), intent(inout), allocatable :: object
293 character(len=*) :: type_name
294 end subroutine adjoint_fluid_scheme_factory
295 end interface
296end module adjoint_fluid_scheme