Neko 1.99.5
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 vector_list, only : vector_list_t
38 use mask, only : mask_t
39 use coefs, only : coef_t
40 use bc_list, only : bc_list_t
41 use mesh, only : mesh_t
45 use num_types, only : rp
46 use json_module, only : json_file
48 use utils, only : neko_error, neko_warning
49 use logger, only : neko_log
50 use bc, only : bc_t
53 use time_state, only : time_state_t
54 implicit none
55 private
56
59 abstract interface
60 subroutine user_startup_intf(params)
61 import json_file
62 type(json_file), intent(inout) :: params
63 end subroutine user_startup_intf
64 end interface
65
69 abstract interface
70 subroutine user_initial_conditions_intf(scheme_name, fields)
71 import field_list_t
72 character(len=*), intent(in) :: scheme_name
73 type(field_list_t), intent(inout) :: fields
74 end subroutine user_initial_conditions_intf
75 end interface
76
79 abstract interface
80 subroutine user_initialize_intf(time)
81 import time_state_t
82 type(time_state_t), intent(in) :: time
83 end subroutine user_initialize_intf
84 end interface
85
89 abstract interface
90 subroutine user_mesh_setup_intf(msh, time)
91 import mesh_t, time_state_t
92 type(mesh_t), intent(inout) :: msh
93 type(time_state_t), intent(in) :: time
94 end subroutine user_mesh_setup_intf
95 end interface
96
99 abstract interface
100 subroutine user_compute_intf(time)
101 import time_state_t
102 type(time_state_t), intent(in) :: time
103 end subroutine user_compute_intf
104 end interface
105
108 abstract interface
109 subroutine user_finalize_intf(time)
110 import json_file
111 import time_state_t
112 type(time_state_t), intent(in) :: time
113 end subroutine user_finalize_intf
114 end interface
115
120 abstract interface
121 subroutine user_source_term_intf(scheme_name, rhs, time)
123 character(len=*), intent(in) :: scheme_name
124 type(field_list_t), intent(inout) :: rhs
125 type(time_state_t), intent(in) :: time
126 end subroutine user_source_term_intf
127 end interface
128
136 abstract interface
137 subroutine user_material_properties_intf(scheme_name, properties, time)
139 character(len=*), intent(in) :: scheme_name
140 type(field_list_t), intent(inout) :: properties
141 type(time_state_t), intent(in) :: time
142 end subroutine user_material_properties_intf
143 end interface
144
151 abstract interface
152 subroutine user_ale_mesh_velocity_intf(wm_x, wm_y, wm_z, coef, &
153 x_ref, y_ref, z_ref, base_shapes, time)
155 type(coef_t), intent(in) :: coef
156 type(field_t), intent(in) :: x_ref, y_ref, z_ref
157 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
158 type(field_t), intent(in) :: base_shapes(:)
159 type(time_state_t), intent(in) :: time
160 end subroutine user_ale_mesh_velocity_intf
161 end interface
162
165 abstract interface
166 subroutine user_ale_base_shapes_intf(base_shapes)
167 import field_t
168 type(field_t), intent(inout) :: base_shapes(:)
169 end subroutine user_ale_base_shapes_intf
170 end interface
171
177 abstract interface
178 subroutine user_ale_rigid_kinematics_intf(body_id, time, &
179 vel_trans, vel_ang)
180 import rp, time_state_t
181 integer, intent(in) :: body_id
182 type(time_state_t), intent(in) :: time
183 real(kind=rp), intent(inout) :: vel_trans(3)
184 real(kind=rp), intent(inout) :: vel_ang(3)
185 end subroutine user_ale_rigid_kinematics_intf
186 end interface
187
188
191 type, public :: user_t
196 logical :: suppress_type_injection = .false.
199 procedure(user_startup_intf), nopass, pointer :: startup => null()
202 procedure(user_initialize_intf), nopass, pointer :: initialize => null()
204 procedure(user_initial_conditions_intf), nopass, pointer :: &
205 initial_conditions => null()
206 procedure(user_mesh_setup_intf), nopass, pointer :: mesh_setup => null()
208 procedure(user_compute_intf), nopass, pointer :: preprocess => null()
211 procedure(user_compute_intf), nopass, pointer :: compute => null()
214 procedure(user_finalize_intf), nopass, pointer :: &
215 finalize => null()
217 procedure(user_source_term_intf), nopass, pointer :: &
218 source_term => null()
221 procedure(field_dirichlet_update), nopass, pointer :: &
222 dirichlet_conditions => null()
224 procedure(field_neumann_update), nopass, pointer :: &
225 neumann_conditions => null()
227 procedure(user_material_properties_intf), nopass, pointer :: &
228 material_properties => null()
230 procedure(user_ale_mesh_velocity_intf), nopass, pointer :: &
231 ale_mesh_velocity => null()
233 procedure(user_ale_rigid_kinematics_intf), nopass, pointer :: &
234 ale_rigid_kinematics => null()
236 procedure(user_ale_base_shapes_intf), nopass, pointer :: &
237 ale_base_shapes => null()
239 procedure(morph_overset_interface), nopass, pointer :: &
240 morph_interface => null()
241 contains
249 procedure, pass(this) :: init => user_intf_init
250 end type user_t
251
260contains
261
263 subroutine user_intf_init(this)
264 class(user_t), intent(inout) :: this
265 logical :: user_extended = .false.
266 character(len=256), dimension(15) :: extensions
267 integer :: i, n
268
269 n = 0
270 if (.not. associated(this%startup)) then
271 this%startup => dummy_startup
272 else
273 user_extended = .true.
274 n = n + 1
275 write(extensions(n), '(A)') '- Startup'
276 end if
277
278 if (.not. associated(this%initial_conditions)) then
279 this%initial_conditions => dummy_user_initial_conditions
280 else
281 user_extended = .true.
282 n = n + 1
283 write(extensions(n), '(A)') '- Initial condition'
284 end if
285
286 if (.not. associated(this%source_term)) then
287 this%source_term => dummy_user_source_term
288 else
289 user_extended = .true.
290 n = n + 1
291 write(extensions(n), '(A)') '- Source term'
292 end if
293
294 if (.not. associated(this%dirichlet_conditions)) then
295 this%dirichlet_conditions => dirichlet_do_nothing
296 else
297 user_extended = .true.
298 n = n + 1
299 write(extensions(n), '(A)') '- Dirichlet boundary condition'
300 end if
301
302 if (.not. associated(this%neumann_conditions)) then
303 this%neumann_conditions => neumann_do_nothing
304 else
305 user_extended = .true.
306 n = n + 1
307 write(extensions(n), '(A)') '- Neumann boundary condition'
308 end if
309
310 if (.not. associated(this%mesh_setup)) then
311 this%mesh_setup => dummy_user_mesh_setup
312 else
313 user_extended = .true.
314 n = n + 1
315 write(extensions(n), '(A)') '- Mesh setup'
316 end if
317
318 if (.not. associated(this%compute)) then
319 this%compute => dummy_user_compute
320 else
321 user_extended = .true.
322 n = n + 1
323 write(extensions(n), '(A)') '- User compute'
324 end if
325
326 if (.not. associated(this%preprocess)) then
327 this%preprocess => dummy_user_compute
328 else
329 user_extended = .true.
330 n = n + 1
331 write(extensions(n), '(A)') '- User preprocess'
332 end if
333
334 if (.not. associated(this%initialize)) then
335 this%initialize => dummy_initialize
336 else
337 user_extended = .true.
338 n = n + 1
339 write(extensions(n), '(A)') '- Initialize modules'
340 end if
341
342 if (.not. associated(this%finalize)) then
343 this%finalize => dummy_user_finalize
344 else
345 user_extended = .true.
346 n = n + 1
347 write(extensions(n), '(A)') '- Finalize modules'
348 end if
349
350 if (.not. associated(this%material_properties)) then
351 this%material_properties => dummy_user_material_properties
352 else
353 user_extended = .true.
354 n = n + 1
355 write(extensions(n), '(A)') '- Material properties'
356 end if
357
358 if (.not. associated(this%ale_mesh_velocity)) then
359 this%ale_mesh_velocity => dummy_user_ale_mesh_velocity
360 else
361 user_extended = .true.
362 n = n + 1
363 write(extensions(n), '(A)') '- ALE mesh velocity'
364 end if
365
366 if (.not. associated(this%ale_rigid_kinematics)) then
367 this%ale_rigid_kinematics => dummy_user_ale_rigid_kinematics
368 else
369 user_extended = .true.
370 n = n + 1
371 write(extensions(n), '(A)') '- ALE kinematics'
372 end if
373
374 if (.not. associated(this%ale_base_shapes)) then
375 this%ale_base_shapes => dummy_user_ale_base_shapes
376 else
377 user_extended = .true.
378 n = n + 1
379 write(extensions(n), '(A)') '- ALE base shapes'
380 end if
381
382 if (.not. associated(this%morph_interface)) then
383 this%morph_interface => dummy_morph_overset_interface
384 else
385 user_extended = .true.
386 n = n + 1
387 write(extensions(n), '(A)') '- Morph overset interface'
388 end if
389
390 if (user_extended) then
391 call neko_log%section('User defined extensions')
392
393 do i = 1, n
394 call neko_log%message(extensions(i))
395 end do
396
397 call neko_log%end_section()
398 end if
399
400 end subroutine user_intf_init
401
402
403 !
404 ! Below is the dummy user interface
405 ! when running in pure turboNEKO mode
406 !
407
409 subroutine dummy_startup(params)
410 type(json_file), intent(inout) :: params
411 end subroutine dummy_startup
412
414 subroutine dummy_user_initial_conditions(scheme_name, fields)
415 character(len=*), intent(in) :: scheme_name
416 type(field_list_t), intent(inout) :: fields
417
418 call neko_error('Dummy user defined initial condition set')
419 end subroutine dummy_user_initial_conditions
420
422 subroutine dummy_user_source_term(scheme_name, rhs, time)
423 character(len=*), intent(in) :: scheme_name
424 type(field_list_t), intent(inout) :: rhs
425 type(time_state_t), intent(in) :: time
426 call neko_error('Dummy user defined source term set')
427 end subroutine dummy_user_source_term
428
430 subroutine dummy_user_mesh_setup(msh, time)
431 type(mesh_t), intent(inout) :: msh
432 type(time_state_t), intent(in) :: time
433 end subroutine dummy_user_mesh_setup
434
436 subroutine dummy_user_compute(time)
437 type(time_state_t), intent(in) :: time
438 end subroutine dummy_user_compute
439
440 subroutine dummy_initialize(time)
441 type(time_state_t), intent(in) :: time
442 end subroutine dummy_initialize
443
444 subroutine dummy_user_finalize(time)
445 type(time_state_t), intent(in) :: time
446 end subroutine dummy_user_finalize
447
448 subroutine dirichlet_do_nothing(fields, bc, time)
449 type(field_list_t), intent(inout) :: fields
450 type(field_dirichlet_t), intent(in) :: bc
451 type(time_state_t), intent(in) :: time
452 end subroutine dirichlet_do_nothing
453
454 subroutine neumann_do_nothing(fields, bc, time)
455 type(field_list_t), intent(inout) :: fields
456 type(field_neumann_t), intent(in) :: bc
457 type(time_state_t), intent(in) :: time
458 end subroutine neumann_do_nothing
459
460 subroutine dummy_user_material_properties(scheme_name, properties, time)
461 character(len=*), intent(in) :: scheme_name
462 type(field_list_t), intent(inout) :: properties
463 type(time_state_t), intent(in) :: time
464 end subroutine dummy_user_material_properties
465
466 subroutine dummy_morph_overset_interface(interface_dof, interface_field, &
467 interface_mask, time, bc_name, &
468 find_interface)
469 type(vector_list_t), intent(inout) :: interface_dof
470 type(vector_list_t), intent(inout) :: interface_field
471 type(mask_t), intent(in) :: interface_mask
472 type(time_state_t), intent(in) :: time
473 character(len=*), intent(in) :: bc_name
474 logical, intent(inout) :: find_interface
475 end subroutine dummy_morph_overset_interface
476
477 subroutine dummy_user_ale_mesh_velocity(wm_x, wm_y, wm_z, coef, &
478 x_ref, y_ref, z_ref, base_shapes, time)
479 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
480 type(coef_t), intent(in) :: coef
481 type(field_t), intent(in) :: x_ref, y_ref, z_ref
482 type(field_t), intent(in) :: base_shapes(:)
483 type(time_state_t), intent(in) :: time
484 end subroutine dummy_user_ale_mesh_velocity
485
486 subroutine dummy_user_ale_base_shapes(base_shapes)
487 type(field_t), intent(inout) :: base_shapes(:)
488 end subroutine dummy_user_ale_base_shapes
489
490 subroutine dummy_user_ale_rigid_kinematics(body_id, time, vel_trans, vel_ang)
491 integer, intent(in) :: body_id
492 type(time_state_t), intent(in) :: time
493 real(kind=rp), intent(inout) :: vel_trans(3)
494 real(kind=rp), intent(inout) :: vel_ang(3)
496
497end 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.
User callback for overset-interface morphing and boundary-value updates.
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.
Abstract interface for finalizating user variables.
Abstract interface for user defined initial conditions.
Definition user_intf.f90:70
Abstract interface for initilialization of modules.
Definition user_intf.f90:80
Abstract interface for setting material properties.
Abstract interface for user defined mesh deformation functions.
Definition user_intf.f90:90
Abstract interface for user defined source term.
Abstract interface for a user start-up routine.
Definition user_intf.f90:60
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:80
Object for handling masks in Neko.
Definition mask.f90:34
Defines a mesh.
Definition mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines overset interface scalar boundary conditions.
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, public dummy_user_ale_mesh_velocity(wm_x, wm_y, wm_z, coef, x_ref, y_ref, z_ref, base_shapes, 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, public dummy_user_ale_base_shapes(base_shapes)
subroutine dummy_user_initial_conditions(scheme_name, fields)
Dummy user initial condition.
subroutine dummy_user_compute(time)
Dummy user compute.
subroutine dummy_morph_overset_interface(interface_dof, interface_field, interface_mask, time, bc_name, find_interface)
subroutine, public dummy_user_ale_rigid_kinematics(body_id, time, vel_trans, vel_ang)
Utilities.
Definition utils.f90:35
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Definition utils.f90:398
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:49
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...
Type for consistently handling masks in Neko. This type encapsulates the mask array and its associate...
Definition mask.f90:51
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...
vector_list_t, To be able to group vectors together