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
55 implicit none
56 private
57 public :: adjoint_fluid_scheme_t, adjoint_fluid_scheme_factory
58
60 type, abstract :: adjoint_fluid_scheme_t
62 character(len=:), allocatable :: name
63
64 type(space_t) :: xh
65 type(dofmap_t) :: dm_xh
66 type(gs_t) :: gs_xh
67 type(coef_t) :: c_xh
68
69 type(time_scheme_controller_t), allocatable :: ext_bdf
70
72 type(field_t), pointer :: u_adj => null()
73 type(field_t), pointer :: v_adj => null()
74 type(field_t), pointer :: w_adj => null()
75 type(field_t), pointer :: p_adj => null()
76 type(field_series_t) :: ulag, vlag, wlag
77
78 type(field_t), pointer :: u_b => null()
79 type(field_t), pointer :: v_b => null()
80 type(field_t), pointer :: w_b => null()
81 type(field_t), pointer :: p_b => null()
82
84 type(chkp_t), pointer :: chkp => null()
85
87 type(field_t), pointer :: f_adj_x => null()
89 type(field_t), pointer :: f_adj_y => null()
91 type(field_t), pointer :: f_adj_z => null()
92
94 ! List of boundary conditions for pressure
95 type(bc_list_t) :: bcs_prs
96 ! List of boundary conditions for velocity
97 type(bc_list_t) :: bcs_vel
98
99 type(json_file), pointer :: params
100 type(mesh_t), pointer :: msh => null()
101
103 character(len=NEKO_MSH_MAX_ZLBL_LEN), allocatable :: bc_labels(:)
104
106 type(field_t) :: rho
107
109 type(field_t) :: mu
110
112 type(field_list_t) :: material_properties
113
115 logical :: freeze = .false.
116
118 procedure(user_material_properties_intf), nopass, pointer :: &
119 user_material_properties => null()
120
121 contains
123 procedure(adjoint_fluid_scheme_init_intrf), pass(this), deferred :: init
125 procedure(adjoint_fluid_scheme_free_intrf), pass(this), deferred :: free
127 procedure(adjoint_fluid_scheme_step_intrf), pass(this), deferred :: step
129 procedure(adjoint_fluid_scheme_restart_intrf), &
130 pass(this), deferred :: restart
132 procedure(adjoint_fluid_scheme_setup_bcs_intrf), pass(this), deferred :: &
133 setup_bcs
134
136 procedure(validate_intrf), pass(this), deferred :: validate
138 procedure(fluid_scheme_base_compute_cfl_intrf), pass(this), deferred :: compute_cfl
140 procedure(update_material_properties), pass(this), deferred :: update_material_properties
142
144 abstract interface
145 subroutine adjoint_fluid_init_all_intrf(this, msh, lx, params, kspv_init, &
146 kspp_init, scheme, user)
148 import mesh_t
149 import json_file
150 import user_t
151 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
152 type(mesh_t), target, intent(inout) :: msh
153 integer, intent(inout) :: lx
154 type(json_file), target, intent(inout) :: params
155 logical, intent(inout) :: kspv_init
156 logical, intent(inout) :: kspp_init
157 type(user_t), target, intent(in) :: user
158 character(len=*), intent(in) :: scheme
159 end subroutine adjoint_fluid_init_all_intrf
160 end interface
161
163 abstract interface
164 subroutine adjoint_fluid_init_common_intrf(this, msh, lx, params, scheme, &
165 user, kspv_init)
167 import mesh_t
168 import json_file
169 import user_t
170 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
171 type(mesh_t), target, intent(inout) :: msh
172 integer, intent(inout) :: lx
173 character(len=*), intent(in) :: scheme
174 type(json_file), target, intent(inout) :: params
175 type(user_t), target, intent(in) :: user
176 logical, intent(in) :: kspv_init
177 end subroutine adjoint_fluid_init_common_intrf
178 end interface
179
181 abstract interface
182 subroutine adjoint_fluid_free_intrf(this)
184 class(adjoint_fluid_scheme_t), intent(inout) :: this
185 end subroutine adjoint_fluid_free_intrf
186 end interface
187
189 abstract interface
190 subroutine adjoint_fluid_scheme_init_intrf(this, msh, lx, params, user, &
191 chkp)
193 import json_file
194 import mesh_t
195 import user_t
196 import chkp_t
197 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
198 type(mesh_t), target, intent(inout) :: msh
199 integer, intent(in) :: lx
200 type(json_file), target, intent(inout) :: params
201 type(user_t), target, intent(in) :: user
202 type(chkp_t), target, intent(inout) :: chkp
203 end subroutine adjoint_fluid_scheme_init_intrf
204 end interface
205
207 abstract interface
208 subroutine adjoint_fluid_scheme_free_intrf(this)
210 class(adjoint_fluid_scheme_t), intent(inout) :: this
211 end subroutine adjoint_fluid_scheme_free_intrf
212 end interface
213
215 abstract interface
216 subroutine adjoint_fluid_scheme_step_intrf(this, time, dt_controller)
217 import time_state_t
219 import time_step_controller_t
220 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
221 type(time_state_t), intent(in) :: time
222 type(time_step_controller_t), intent(in) :: dt_controller
223 end subroutine adjoint_fluid_scheme_step_intrf
224 end interface
225
227 abstract interface
228 subroutine adjoint_fluid_scheme_restart_intrf(this, chkp)
230 import chkp_t
231 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
232 type(chkp_t), intent(inout) :: chkp
233 end subroutine adjoint_fluid_scheme_restart_intrf
234 end interface
235
237 abstract interface
238 subroutine adjoint_fluid_scheme_setup_bcs_intrf(this, user, params)
239 import adjoint_fluid_scheme_t, user_t, json_file
240 class(adjoint_fluid_scheme_t), intent(inout) :: this
241 type(user_t), target, intent(in) :: user
242 type(json_file), intent(inout) :: params
243 end subroutine adjoint_fluid_scheme_setup_bcs_intrf
244 end interface
245
247 abstract interface
248 subroutine validate_intrf(this)
250 class(adjoint_fluid_scheme_t), target, intent(inout) :: this
251 end subroutine validate_intrf
252 end interface
253
255 abstract interface
256 subroutine update_material_properties(this, time)
257 import adjoint_fluid_scheme_t, time_state_t
258 class(adjoint_fluid_scheme_t), intent(inout) :: this
259 type(time_state_t), intent(in) :: time
260 end subroutine update_material_properties
261 end interface
262
264 abstract interface
265 function fluid_scheme_base_compute_cfl_intrf(this, dt) result(c)
267 import rp
268 class(adjoint_fluid_scheme_t), intent(in) :: this
269 real(kind=rp), intent(in) :: dt
270 real(kind=rp) :: c
271 end function fluid_scheme_base_compute_cfl_intrf
272 end interface
273
274 interface
275
276 module subroutine adjoint_fluid_scheme_factory(object, type_name)
277 class(adjoint_fluid_scheme_t), intent(inout), allocatable :: object
278 character(len=*) :: type_name
279 end subroutine adjoint_fluid_scheme_factory
280 end interface
281end module adjoint_fluid_scheme