Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
user_intf.f90
Go to the documentation of this file.
1! Copyright (c) 2020-2025, 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!
35 use field, only : field_t
36 use field_list, only : field_list_t
37 use coefs, only : coef_t
38 use bc_list, only : bc_list_t
39 use mesh, only : mesh_t
41 use num_types, only : rp
42 use json_module, only : json_file
44 use utils, only : neko_error, neko_warning
45 use logger, only : neko_log
46 use bc, only : bc_t
48 use time_state, only : time_state_t
49 implicit none
50 private
51
54 abstract interface
55 subroutine user_startup_intf(params)
56 import json_file
57 type(json_file), intent(inout) :: params
58 end subroutine user_startup_intf
59 end interface
60
64 abstract interface
65 subroutine user_initial_conditions_intf(scheme_name, fields)
66 import field_list_t
67 character(len=*), intent(in) :: scheme_name
68 type(field_list_t), intent(inout) :: fields
69 end subroutine user_initial_conditions_intf
70 end interface
71
74 abstract interface
75 subroutine user_initialize_intf(time)
76 import time_state_t
77 type(time_state_t), intent(in) :: time
78 end subroutine user_initialize_intf
79 end interface
80
84 abstract interface
85 subroutine user_mesh_setup_intf(msh, time)
86 import mesh_t, time_state_t
87 type(mesh_t), intent(inout) :: msh
88 type(time_state_t), intent(in) :: time
89 end subroutine user_mesh_setup_intf
90 end interface
91
94 abstract interface
95 subroutine user_compute_intf(time)
96 import time_state_t
97 type(time_state_t), intent(in) :: time
98 end subroutine user_compute_intf
99 end interface
100
103 abstract interface
104 subroutine user_finalize_intf(time)
105 import json_file
106 import time_state_t
107 type(time_state_t), intent(in) :: time
108 end subroutine user_finalize_intf
109 end interface
110
115 abstract interface
116 subroutine user_source_term_intf(scheme_name, rhs, time)
118 character(len=*), intent(in) :: scheme_name
119 type(field_list_t), intent(inout) :: rhs
120 type(time_state_t), intent(in) :: time
121 end subroutine user_source_term_intf
122 end interface
123
131 abstract interface
132 subroutine user_material_properties_intf(scheme_name, properties, time)
134 character(len=*), intent(in) :: scheme_name
135 type(field_list_t), intent(inout) :: properties
136 type(time_state_t), intent(in) :: time
137 end subroutine user_material_properties_intf
138 end interface
139
142 type, public :: user_t
147 logical :: suppress_type_injection = .false.
150 procedure(user_startup_intf), nopass, pointer :: startup => null()
153 procedure(user_initialize_intf), nopass, pointer :: initialize => null()
155 procedure(user_initial_conditions_intf), nopass, pointer :: &
156 initial_conditions => null()
157 procedure(user_mesh_setup_intf), nopass, pointer :: mesh_setup => null()
159 procedure(user_compute_intf), nopass, pointer :: preprocess => null()
162 procedure(user_compute_intf), nopass, pointer :: compute => null()
165 procedure(user_finalize_intf), nopass, pointer :: &
166 finalize => null()
168 procedure(user_source_term_intf), nopass, pointer :: &
169 source_term => null()
172 procedure(field_dirichlet_update), nopass, pointer :: &
173 dirichlet_conditions => null()
175 procedure(user_material_properties_intf), nopass, pointer :: &
176 material_properties => null()
177 contains
185 procedure, pass(this) :: init => user_intf_init
186 end type user_t
187
192contains
193
195 subroutine user_intf_init(this)
196 class(user_t), intent(inout) :: this
197 logical :: user_extended = .false.
198 character(len=256), dimension(14) :: extensions
199 integer :: i, n
200
201 n = 0
202 if (.not. associated(this%startup)) then
203 this%startup => dummy_startup
204 else
205 user_extended = .true.
206 n = n + 1
207 write(extensions(n), '(A)') '- Startup'
208 end if
209
210 if (.not. associated(this%initial_conditions)) then
211 this%initial_conditions => dummy_user_initial_conditions
212 else
213 user_extended = .true.
214 n = n + 1
215 write(extensions(n), '(A)') '- Initial condition'
216 end if
217
218 if (.not. associated(this%source_term)) then
219 this%source_term => dummy_user_source_term
220 else
221 user_extended = .true.
222 n = n + 1
223 write(extensions(n), '(A)') '- Source term'
224 end if
225
226 if (.not. associated(this%dirichlet_conditions)) then
227 this%dirichlet_conditions => dirichlet_do_nothing
228 else
229 user_extended = .true.
230 n = n + 1
231 write(extensions(n), '(A)') '- Dirichlet boundary condition'
232 end if
233
234 if (.not. associated(this%mesh_setup)) then
235 this%mesh_setup => dummy_user_mesh_setup
236 else
237 user_extended = .true.
238 n = n + 1
239 write(extensions(n), '(A)') '- Mesh setup'
240 end if
241
242 if (.not. associated(this%compute)) then
243 this%compute => dummy_user_compute
244 else
245 user_extended = .true.
246 n = n + 1
247 write(extensions(n), '(A)') '- User compute'
248 end if
249
250 if (.not. associated(this%preprocess)) then
251 this%preprocess => dummy_user_compute
252 else
253 user_extended = .true.
254 n = n + 1
255 write(extensions(n), '(A)') '- User preprocess'
256 end if
257
258 if (.not. associated(this%initialize)) then
259 this%initialize => dummy_initialize
260 else
261 user_extended = .true.
262 n = n + 1
263 write(extensions(n), '(A)') '- Initialize modules'
264 end if
265
266 if (.not. associated(this%finalize)) then
267 this%finalize => dummy_user_finalize
268 else
269 user_extended = .true.
270 n = n + 1
271 write(extensions(n), '(A)') '- Finalize modules'
272 end if
273
274 if (.not. associated(this%material_properties)) then
275 this%material_properties => dummy_user_material_properties
276 else
277 user_extended = .true.
278 n = n + 1
279 write(extensions(n), '(A)') '- Material properties'
280 end if
281
282 if (user_extended) then
283 call neko_log%section('User defined extensions')
284
285 do i = 1, n
286 call neko_log%message(extensions(i))
287 end do
288
289 call neko_log%end_section()
290 end if
291
292 end subroutine user_intf_init
293
294
295 !
296 ! Below is the dummy user interface
297 ! when running in pure turboNEKO mode
298 !
299
301 subroutine dummy_startup(params)
302 type(json_file), intent(inout) :: params
303 end subroutine dummy_startup
304
306 subroutine dummy_user_initial_conditions(scheme_name, fields)
307 character(len=*), intent(in) :: scheme_name
308 type(field_list_t), intent(inout) :: fields
309
310 call neko_error('Dummy user defined initial condition set')
311 end subroutine dummy_user_initial_conditions
312
314 subroutine dummy_user_source_term(scheme_name, rhs, time)
315 character(len=*), intent(in) :: scheme_name
316 type(field_list_t), intent(inout) :: rhs
317 type(time_state_t), intent(in) :: time
318 call neko_error('Dummy user defined source term set')
319 end subroutine dummy_user_source_term
320
322 subroutine dummy_user_mesh_setup(msh, time)
323 type(mesh_t), intent(inout) :: msh
324 type(time_state_t), intent(in) :: time
325 end subroutine dummy_user_mesh_setup
326
328 subroutine dummy_user_compute(time)
329 type(time_state_t), intent(in) :: time
330 end subroutine dummy_user_compute
331
332 subroutine dummy_initialize(time)
333 type(time_state_t), intent(in) :: time
334 end subroutine dummy_initialize
335
336 subroutine dummy_user_finalize(time)
337 type(time_state_t), intent(in) :: time
338 end subroutine dummy_user_finalize
339
340 subroutine dirichlet_do_nothing(fields, bc, time)
341 type(field_list_t), intent(inout) :: fields
342 type(field_dirichlet_t), intent(in) :: bc
343 type(time_state_t), intent(in) :: time
344 end subroutine dirichlet_do_nothing
345
346 subroutine dummy_user_material_properties(scheme_name, properties, time)
347 character(len=*), intent(in) :: scheme_name
348 type(field_list_t), intent(inout) :: properties
349 type(time_state_t), intent(in) :: time
350 end subroutine dummy_user_material_properties
351
352
353end module user_intf
Abstract interface defining a dirichlet condition on a list of fields.
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Abstract interface for user defined check functions.
Definition user_intf.f90:95
Abstract interface for finalizating user variables.
Abstract interface for user defined initial conditions.
Definition user_intf.f90:65
Abstract interface for initilialization of modules.
Definition user_intf.f90:75
Abstract interface for setting material properties.
Abstract interface for user defined mesh deformation functions.
Definition user_intf.f90:85
Abstract interface for user defined source term.
Abstract interface for a user start-up routine.
Definition user_intf.f90:55
Defines a list of bc_t.
Definition bc_list.f90:34
Defines a boundary condition.
Definition bc.f90:34
Coefficients.
Definition coef.f90:34
Defines user dirichlet condition for a scalar field.
Defines a field.
Definition field.f90:34
Utilities for retrieving parameters from the case files.
Logging routines.
Definition log.f90:34
type(log_t), public neko_log
Global log stream.
Definition log.f90:70
Defines a mesh.
Definition mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Module with things related to the simulation time.
Interfaces for user interaction with NEKO.
Definition user_intf.f90:34
subroutine dummy_user_finalize(time)
subroutine dummy_user_source_term(scheme_name, rhs, time)
Dummy user source_term.
subroutine user_intf_init(this)
Constructor.
subroutine dummy_initialize(time)
subroutine, public dummy_user_material_properties(scheme_name, properties, time)
subroutine dummy_startup(params)
Dummy user startup.
subroutine dirichlet_do_nothing(fields, bc, time)
subroutine dummy_user_mesh_setup(msh, time)
Dummy user mesh apply.
subroutine dummy_user_initial_conditions(scheme_name, fields)
Dummy user initial condition.
subroutine dummy_user_compute(time)
Dummy user compute.
Utilities.
Definition utils.f90:35
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Definition utils.f90:284
Base type for a boundary condition.
Definition bc.f90:61
A list of allocatable `bc_t`. Follows the standard interface of lists.
Definition bc_list.f90:48
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:55
User defined dirichlet condition, for which the user can work with an entire field....
field_list_t, To be able to group fields together
A struct that contains all info about the time, expand as needed.
A type collecting all the overridable user routines and flag to suppress type injection from custom m...