Neko 1.99.3
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
42 use num_types, only : rp
43 use json_module, only : json_file
45 use utils, only : neko_error, neko_warning
46 use logger, only : neko_log
47 use bc, only : bc_t
50 use time_state, only : time_state_t
51 implicit none
52 private
53
56 abstract interface
57 subroutine user_startup_intf(params)
58 import json_file
59 type(json_file), intent(inout) :: params
60 end subroutine user_startup_intf
61 end interface
62
66 abstract interface
67 subroutine user_initial_conditions_intf(scheme_name, fields)
68 import field_list_t
69 character(len=*), intent(in) :: scheme_name
70 type(field_list_t), intent(inout) :: fields
71 end subroutine user_initial_conditions_intf
72 end interface
73
76 abstract interface
77 subroutine user_initialize_intf(time)
78 import time_state_t
79 type(time_state_t), intent(in) :: time
80 end subroutine user_initialize_intf
81 end interface
82
86 abstract interface
87 subroutine user_mesh_setup_intf(msh, time)
88 import mesh_t, time_state_t
89 type(mesh_t), intent(inout) :: msh
90 type(time_state_t), intent(in) :: time
91 end subroutine user_mesh_setup_intf
92 end interface
93
96 abstract interface
97 subroutine user_compute_intf(time)
98 import time_state_t
99 type(time_state_t), intent(in) :: time
100 end subroutine user_compute_intf
101 end interface
102
105 abstract interface
106 subroutine user_finalize_intf(time)
107 import json_file
108 import time_state_t
109 type(time_state_t), intent(in) :: time
110 end subroutine user_finalize_intf
111 end interface
112
117 abstract interface
118 subroutine user_source_term_intf(scheme_name, rhs, time)
120 character(len=*), intent(in) :: scheme_name
121 type(field_list_t), intent(inout) :: rhs
122 type(time_state_t), intent(in) :: time
123 end subroutine user_source_term_intf
124 end interface
125
133 abstract interface
134 subroutine user_material_properties_intf(scheme_name, properties, time)
136 character(len=*), intent(in) :: scheme_name
137 type(field_list_t), intent(inout) :: properties
138 type(time_state_t), intent(in) :: time
139 end subroutine user_material_properties_intf
140 end interface
141
148 abstract interface
149 subroutine user_ale_mesh_velocity_intf(wm_x, wm_y, wm_z, coef, &
150 x_ref, y_ref, z_ref, base_shapes, time)
152 type(coef_t), intent(in) :: coef
153 type(field_t), intent(in) :: x_ref, y_ref, z_ref
154 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
155 type(field_t), intent(in) :: base_shapes(:)
156 type(time_state_t), intent(in) :: time
157 end subroutine user_ale_mesh_velocity_intf
158 end interface
159
162 abstract interface
163 subroutine user_ale_base_shapes_intf(base_shapes)
164 import field_t
165 type(field_t), intent(inout) :: base_shapes(:)
166 end subroutine user_ale_base_shapes_intf
167 end interface
168
174 abstract interface
175 subroutine user_ale_rigid_kinematics_intf(body_id, time, &
176 vel_trans, vel_ang)
177 import rp, time_state_t
178 integer, intent(in) :: body_id
179 type(time_state_t), intent(in) :: time
180 real(kind=rp), intent(inout) :: vel_trans(3)
181 real(kind=rp), intent(inout) :: vel_ang(3)
182 end subroutine user_ale_rigid_kinematics_intf
183 end interface
184
185
188 type, public :: user_t
193 logical :: suppress_type_injection = .false.
196 procedure(user_startup_intf), nopass, pointer :: startup => null()
199 procedure(user_initialize_intf), nopass, pointer :: initialize => null()
201 procedure(user_initial_conditions_intf), nopass, pointer :: &
202 initial_conditions => null()
203 procedure(user_mesh_setup_intf), nopass, pointer :: mesh_setup => null()
205 procedure(user_compute_intf), nopass, pointer :: preprocess => null()
208 procedure(user_compute_intf), nopass, pointer :: compute => null()
211 procedure(user_finalize_intf), nopass, pointer :: &
212 finalize => null()
214 procedure(user_source_term_intf), nopass, pointer :: &
215 source_term => null()
218 procedure(field_dirichlet_update), nopass, pointer :: &
219 dirichlet_conditions => null()
221 procedure(field_neumann_update), nopass, pointer :: &
222 neumann_conditions => null()
224 procedure(user_material_properties_intf), nopass, pointer :: &
225 material_properties => null()
226 procedure(user_ale_mesh_velocity_intf), nopass, pointer :: &
227 ale_mesh_velocity => null()
228 procedure(user_ale_rigid_kinematics_intf), nopass, pointer :: &
229 ale_rigid_kinematics => null()
230 procedure(user_ale_base_shapes_intf), nopass, pointer :: &
231 ale_base_shapes => null()
232 contains
240 procedure, pass(this) :: init => user_intf_init
241 end type user_t
242
249contains
250
252 subroutine user_intf_init(this)
253 class(user_t), intent(inout) :: this
254 logical :: user_extended = .false.
255 character(len=256), dimension(14) :: extensions
256 integer :: i, n
257
258 n = 0
259 if (.not. associated(this%startup)) then
260 this%startup => dummy_startup
261 else
262 user_extended = .true.
263 n = n + 1
264 write(extensions(n), '(A)') '- Startup'
265 end if
266
267 if (.not. associated(this%initial_conditions)) then
268 this%initial_conditions => dummy_user_initial_conditions
269 else
270 user_extended = .true.
271 n = n + 1
272 write(extensions(n), '(A)') '- Initial condition'
273 end if
274
275 if (.not. associated(this%source_term)) then
276 this%source_term => dummy_user_source_term
277 else
278 user_extended = .true.
279 n = n + 1
280 write(extensions(n), '(A)') '- Source term'
281 end if
282
283 if (.not. associated(this%dirichlet_conditions)) then
284 this%dirichlet_conditions => dirichlet_do_nothing
285 else
286 user_extended = .true.
287 n = n + 1
288 write(extensions(n), '(A)') '- Dirichlet boundary condition'
289 end if
290
291 if (.not. associated(this%neumann_conditions)) then
292 this%neumann_conditions => neumann_do_nothing
293 else
294 user_extended = .true.
295 n = n + 1
296 write(extensions(n), '(A)') '- Neumann boundary condition'
297 end if
298
299 if (.not. associated(this%mesh_setup)) then
300 this%mesh_setup => dummy_user_mesh_setup
301 else
302 user_extended = .true.
303 n = n + 1
304 write(extensions(n), '(A)') '- Mesh setup'
305 end if
306
307 if (.not. associated(this%compute)) then
308 this%compute => dummy_user_compute
309 else
310 user_extended = .true.
311 n = n + 1
312 write(extensions(n), '(A)') '- User compute'
313 end if
314
315 if (.not. associated(this%preprocess)) then
316 this%preprocess => dummy_user_compute
317 else
318 user_extended = .true.
319 n = n + 1
320 write(extensions(n), '(A)') '- User preprocess'
321 end if
322
323 if (.not. associated(this%initialize)) then
324 this%initialize => dummy_initialize
325 else
326 user_extended = .true.
327 n = n + 1
328 write(extensions(n), '(A)') '- Initialize modules'
329 end if
330
331 if (.not. associated(this%finalize)) then
332 this%finalize => dummy_user_finalize
333 else
334 user_extended = .true.
335 n = n + 1
336 write(extensions(n), '(A)') '- Finalize modules'
337 end if
338
339 if (.not. associated(this%material_properties)) then
340 this%material_properties => dummy_user_material_properties
341 else
342 user_extended = .true.
343 n = n + 1
344 write(extensions(n), '(A)') '- Material properties'
345 end if
346
347 if (associated(this%ale_mesh_velocity)) then
348 user_extended = .true.
349 n = n + 1
350 write(extensions(n), '(A)') '- ALE mesh velocity'
351 end if
352
353 if (associated(this%ale_rigid_kinematics)) then
354 user_extended = .true.
355 n = n + 1
356 write(extensions(n), '(A)') '- ALE kinematics'
357 end if
358
359 if (associated(this%ale_base_shapes)) then
360 user_extended = .true.
361 n = n + 1
362 write(extensions(n), '(A)') '- ALE base shapes'
363 end if
364
365 if (user_extended) then
366 call neko_log%section('User defined extensions')
367
368 do i = 1, n
369 call neko_log%message(extensions(i))
370 end do
371
372 call neko_log%end_section()
373 end if
374
375 end subroutine user_intf_init
376
377
378 !
379 ! Below is the dummy user interface
380 ! when running in pure turboNEKO mode
381 !
382
384 subroutine dummy_startup(params)
385 type(json_file), intent(inout) :: params
386 end subroutine dummy_startup
387
389 subroutine dummy_user_initial_conditions(scheme_name, fields)
390 character(len=*), intent(in) :: scheme_name
391 type(field_list_t), intent(inout) :: fields
392
393 call neko_error('Dummy user defined initial condition set')
394 end subroutine dummy_user_initial_conditions
395
397 subroutine dummy_user_source_term(scheme_name, rhs, time)
398 character(len=*), intent(in) :: scheme_name
399 type(field_list_t), intent(inout) :: rhs
400 type(time_state_t), intent(in) :: time
401 call neko_error('Dummy user defined source term set')
402 end subroutine dummy_user_source_term
403
405 subroutine dummy_user_mesh_setup(msh, time)
406 type(mesh_t), intent(inout) :: msh
407 type(time_state_t), intent(in) :: time
408 end subroutine dummy_user_mesh_setup
409
411 subroutine dummy_user_compute(time)
412 type(time_state_t), intent(in) :: time
413 end subroutine dummy_user_compute
414
415 subroutine dummy_initialize(time)
416 type(time_state_t), intent(in) :: time
417 end subroutine dummy_initialize
418
419 subroutine dummy_user_finalize(time)
420 type(time_state_t), intent(in) :: time
421 end subroutine dummy_user_finalize
422
423 subroutine dirichlet_do_nothing(fields, bc, time)
424 type(field_list_t), intent(inout) :: fields
425 type(field_dirichlet_t), intent(in) :: bc
426 type(time_state_t), intent(in) :: time
427 end subroutine dirichlet_do_nothing
428
429 subroutine neumann_do_nothing(fields, bc, time)
430 type(field_list_t), intent(inout) :: fields
431 type(field_neumann_t), intent(in) :: bc
432 type(time_state_t), intent(in) :: time
433 end subroutine neumann_do_nothing
434
435 subroutine dummy_user_material_properties(scheme_name, properties, time)
436 character(len=*), intent(in) :: scheme_name
437 type(field_list_t), intent(inout) :: properties
438 type(time_state_t), intent(in) :: time
439 end subroutine dummy_user_material_properties
440
441end module user_intf
Abstract interface defining a dirichlet condition on a list of fields.
Abstract interface defining a neumann 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 ALE base shapes.
Abstract interface for user defined ALE mesh velocity.
Abstract interface for user defined ALE rigid body kinematics.
Abstract interface for user defined check functions.
Definition user_intf.f90:97
Abstract interface for finalizating user variables.
Abstract interface for user defined initial conditions.
Definition user_intf.f90:67
Abstract interface for initilialization of modules.
Definition user_intf.f90:77
Abstract interface for setting material properties.
Abstract interface for user defined mesh deformation functions.
Definition user_intf.f90:87
Abstract interface for user defined source term.
Abstract interface for a user start-up routine.
Definition user_intf.f90:57
Defines data structures and algorithms for configuring, calculating, and time-integrating the rigid-b...
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 user neumann 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:79
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 neumann_do_nothing(fields, bc, 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:346
Base type for a boundary condition.
Definition bc.f90:62
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:62
User defined dirichlet condition, for which the user can work with an entire field....
field_list_t, To be able to group fields together
User defined neumann condition, for which the user can work with an entire field. The type stores a s...
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...