Neko 1.99.9
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
72 abstract interface
73 subroutine user_initial_conditions_intf(scheme_name, fields)
74 import field_list_t
75 character(len=*), intent(in) :: scheme_name
76 type(field_list_t), intent(inout) :: fields
77 end subroutine user_initial_conditions_intf
78 end interface
79
82 abstract interface
83 subroutine user_initialize_intf(time)
84 import time_state_t
85 type(time_state_t), intent(in) :: time
86 end subroutine user_initialize_intf
87 end interface
88
92 abstract interface
93 subroutine user_mesh_setup_intf(msh, time)
94 import mesh_t, time_state_t
95 type(mesh_t), intent(inout) :: msh
96 type(time_state_t), intent(in) :: time
97 end subroutine user_mesh_setup_intf
98 end interface
99
104 abstract interface
105 subroutine user_wall_sampling_gll_intf(bc_name, msk, indices)
106 character(len=*), intent(in) :: bc_name
107 integer, intent(in) :: msk(:)
108 integer, intent(out) :: indices(:,:)
109 end subroutine user_wall_sampling_gll_intf
110 end interface
111
116 abstract interface
117 subroutine user_wall_sampling_distance_intf(bc_name, msk, distances)
118 import rp
119 character(len=*), intent(in) :: bc_name
120 integer, intent(in) :: msk(:)
121 real(kind=rp), intent(out) :: distances(:,:)
123 end interface
124
127 abstract interface
128 subroutine user_compute_intf(time)
129 import time_state_t
130 type(time_state_t), intent(in) :: time
131 end subroutine user_compute_intf
132 end interface
133
136 abstract interface
137 subroutine user_finalize_intf(time)
138 import json_file
139 import time_state_t
140 type(time_state_t), intent(in) :: time
141 end subroutine user_finalize_intf
142 end interface
143
148 abstract interface
149 subroutine user_source_term_intf(scheme_name, rhs, time)
151 character(len=*), intent(in) :: scheme_name
152 type(field_list_t), intent(inout) :: rhs
153 type(time_state_t), intent(in) :: time
154 end subroutine user_source_term_intf
155 end interface
156
164 abstract interface
165 subroutine user_material_properties_intf(scheme_name, properties, time)
167 character(len=*), intent(in) :: scheme_name
168 type(field_list_t), intent(inout) :: properties
169 type(time_state_t), intent(in) :: time
170 end subroutine user_material_properties_intf
171 end interface
172
179 abstract interface
180 subroutine user_ale_mesh_velocity_intf(wm_x, wm_y, wm_z, coef, &
181 x_ref, y_ref, z_ref, base_shapes, time)
183 type(coef_t), intent(in) :: coef
184 type(field_t), intent(in) :: x_ref, y_ref, z_ref
185 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
186 type(field_t), intent(in) :: base_shapes(:)
187 type(time_state_t), intent(in) :: time
188 end subroutine user_ale_mesh_velocity_intf
189 end interface
190
193 abstract interface
194 subroutine user_ale_base_shapes_intf(base_shapes)
195 import field_t
196 type(field_t), intent(inout) :: base_shapes(:)
197 end subroutine user_ale_base_shapes_intf
198 end interface
199
205 abstract interface
206 subroutine user_ale_rigid_kinematics_intf(body_id, time, &
207 vel_trans, vel_ang)
208 import rp, time_state_t
209 integer, intent(in) :: body_id
210 type(time_state_t), intent(in) :: time
211 real(kind=rp), intent(inout) :: vel_trans(3)
212 real(kind=rp), intent(inout) :: vel_ang(3)
213 end subroutine user_ale_rigid_kinematics_intf
214 end interface
215
216
219 type, public :: user_t
224 logical :: suppress_type_injection = .false.
227 procedure(user_startup_intf), nopass, pointer :: startup => null()
230 procedure(user_initialize_intf), nopass, pointer :: initialize => null()
232 procedure(user_initial_conditions_intf), nopass, pointer :: &
233 initial_conditions => null()
234 procedure(user_mesh_setup_intf), nopass, pointer :: mesh_setup => null()
236 procedure(user_wall_sampling_gll_intf), nopass, pointer :: &
237 wall_sampling_gll => null()
239 procedure(user_wall_sampling_distance_intf), nopass, pointer :: &
240 wall_sampling_distance => null()
242 procedure(user_compute_intf), nopass, pointer :: preprocess => null()
245 procedure(user_compute_intf), nopass, pointer :: compute => null()
248 procedure(user_finalize_intf), nopass, pointer :: &
249 finalize => null()
251 procedure(user_source_term_intf), nopass, pointer :: &
252 source_term => null()
254 procedure(field_dirichlet_update), nopass, pointer :: &
255 dirichlet_conditions => null()
257 procedure(field_neumann_update), nopass, pointer :: &
258 neumann_conditions => null()
260 procedure(user_material_properties_intf), nopass, pointer :: &
261 material_properties => null()
263 procedure(user_ale_mesh_velocity_intf), nopass, pointer :: &
264 ale_mesh_velocity => null()
266 procedure(user_ale_rigid_kinematics_intf), nopass, pointer :: &
267 ale_rigid_kinematics => null()
269 procedure(user_ale_base_shapes_intf), nopass, pointer :: &
270 ale_base_shapes => null()
272 procedure(morph_overset_interface), nopass, pointer :: &
273 morph_interface => null()
274 contains
282 procedure, pass(this) :: init => user_intf_init
283 end type user_t
284
294contains
295
297 subroutine user_intf_init(this)
298 class(user_t), intent(inout) :: this
299 logical :: user_extended = .false.
300 character(len=256), dimension(20) :: extensions
301 integer :: i, n
302
303 n = 0
304 if (.not. associated(this%startup)) then
305 this%startup => dummy_startup
306 else
307 user_extended = .true.
308 n = n + 1
309 write(extensions(n), '(A)') '- Startup'
310 end if
311
312 if (.not. associated(this%initial_conditions)) then
313 this%initial_conditions => dummy_user_initial_conditions
314 else
315 user_extended = .true.
316 n = n + 1
317 write(extensions(n), '(A)') '- Initial condition'
318 end if
319
320 if (.not. associated(this%source_term)) then
321 this%source_term => dummy_user_source_term
322 else
323 user_extended = .true.
324 n = n + 1
325 write(extensions(n), '(A)') '- Source term'
326 end if
327
328 if (.not. associated(this%dirichlet_conditions)) then
329 this%dirichlet_conditions => dirichlet_do_nothing
330 else
331 user_extended = .true.
332 n = n + 1
333 write(extensions(n), '(A)') '- Dirichlet boundary condition'
334 end if
335
336 if (.not. associated(this%neumann_conditions)) then
337 this%neumann_conditions => neumann_do_nothing
338 else
339 user_extended = .true.
340 n = n + 1
341 write(extensions(n), '(A)') '- Neumann boundary condition'
342 end if
343
344 if (.not. associated(this%mesh_setup)) then
345 this%mesh_setup => dummy_user_mesh_setup
346 else
347 user_extended = .true.
348 n = n + 1
349 write(extensions(n), '(A)') '- Mesh setup'
350 end if
351
352 if (.not. associated(this%wall_sampling_gll)) then
353 this%wall_sampling_gll => dummy_user_wall_sampling_gll
354 else
355 user_extended = .true.
356 n = n + 1
357 write(extensions(n), '(A)') '- GLL wall sampling'
358 end if
359
360 if (.not. associated(this%wall_sampling_distance)) then
361 this%wall_sampling_distance => dummy_user_wall_sampling_distance
362 else
363 user_extended = .true.
364 n = n + 1
365 write(extensions(n), '(A)') '- Distance wall sampling'
366 end if
367
368 if (.not. associated(this%compute)) then
369 this%compute => dummy_user_compute
370 else
371 user_extended = .true.
372 n = n + 1
373 write(extensions(n), '(A)') '- User compute'
374 end if
375
376 if (.not. associated(this%preprocess)) then
377 this%preprocess => dummy_user_compute
378 else
379 user_extended = .true.
380 n = n + 1
381 write(extensions(n), '(A)') '- User preprocess'
382 end if
383
384 if (.not. associated(this%initialize)) then
385 this%initialize => dummy_initialize
386 else
387 user_extended = .true.
388 n = n + 1
389 write(extensions(n), '(A)') '- Initialize modules'
390 end if
391
392 if (.not. associated(this%finalize)) then
393 this%finalize => dummy_user_finalize
394 else
395 user_extended = .true.
396 n = n + 1
397 write(extensions(n), '(A)') '- Finalize modules'
398 end if
399
400 if (.not. associated(this%material_properties)) then
401 this%material_properties => dummy_user_material_properties
402 else
403 user_extended = .true.
404 n = n + 1
405 write(extensions(n), '(A)') '- Material properties'
406 end if
407
408 if (.not. associated(this%ale_mesh_velocity)) then
409 this%ale_mesh_velocity => dummy_user_ale_mesh_velocity
410 else
411 user_extended = .true.
412 n = n + 1
413 write(extensions(n), '(A)') '- ALE mesh velocity'
414 end if
415
416 if (.not. associated(this%ale_rigid_kinematics)) then
417 this%ale_rigid_kinematics => dummy_user_ale_rigid_kinematics
418 else
419 user_extended = .true.
420 n = n + 1
421 write(extensions(n), '(A)') '- ALE kinematics'
422 end if
423
424 if (.not. associated(this%ale_base_shapes)) then
425 this%ale_base_shapes => dummy_user_ale_base_shapes
426 else
427 user_extended = .true.
428 n = n + 1
429 write(extensions(n), '(A)') '- ALE base shapes'
430 end if
431
432 if (.not. associated(this%morph_interface)) then
433 this%morph_interface => dummy_morph_overset_interface
434 else
435 user_extended = .true.
436 n = n + 1
437 write(extensions(n), '(A)') '- Morph overset interface'
438 end if
439
440 if (user_extended) then
441 call neko_log%section('User defined extensions')
442
443 do i = 1, n
444 call neko_log%message(extensions(i))
445 end do
446
447 call neko_log%end_section()
448 end if
449
450 end subroutine user_intf_init
451
452
453 !
454 ! Below is the dummy user interface
455 ! when running in pure turboNEKO mode
456 !
457
459 subroutine dummy_startup(params)
460 type(json_file), intent(inout) :: params
461 end subroutine dummy_startup
462
464 subroutine dummy_user_initial_conditions(scheme_name, fields)
465 character(len=*), intent(in) :: scheme_name
466 type(field_list_t), intent(inout) :: fields
467
468 call neko_error('Dummy user defined initial condition set')
469 end subroutine dummy_user_initial_conditions
470
472 subroutine dummy_user_source_term(scheme_name, rhs, time)
473 character(len=*), intent(in) :: scheme_name
474 type(field_list_t), intent(inout) :: rhs
475 type(time_state_t), intent(in) :: time
476 call neko_error('Dummy user defined source term set')
477 end subroutine dummy_user_source_term
478
480 subroutine dummy_user_mesh_setup(msh, time)
481 type(mesh_t), intent(inout) :: msh
482 type(time_state_t), intent(in) :: time
483 end subroutine dummy_user_mesh_setup
484
489 subroutine dummy_user_wall_sampling_gll(bc_name, msk, indices)
490 character(len=*), intent(in) :: bc_name
491 integer, intent(in) :: msk(:)
492 integer, intent(out) :: indices(:,:)
493
494 call neko_error('Wall sampling for '//trim(bc_name)// &
495 ' is configured as user, but wall_sampling_gll is not set')
496 end subroutine dummy_user_wall_sampling_gll
497
502 subroutine dummy_user_wall_sampling_distance(bc_name, msk, distances)
503 character(len=*), intent(in) :: bc_name
504 integer, intent(in) :: msk(:)
505 real(kind=rp), intent(out) :: distances(:,:)
506
507 call neko_error('Wall sampling for '//trim(bc_name)// &
508 ' is configured as user, but wall_sampling_distance is not set')
510
512 subroutine dummy_user_compute(time)
513 type(time_state_t), intent(in) :: time
514 end subroutine dummy_user_compute
515
516 subroutine dummy_initialize(time)
517 type(time_state_t), intent(in) :: time
518 end subroutine dummy_initialize
519
520 subroutine dummy_user_finalize(time)
521 type(time_state_t), intent(in) :: time
522 end subroutine dummy_user_finalize
523
524 subroutine dirichlet_do_nothing(fields, bc, time)
525 type(field_list_t), intent(inout) :: fields
526 type(field_dirichlet_t), intent(in) :: bc
527 type(time_state_t), intent(in) :: time
528 end subroutine dirichlet_do_nothing
529
530 subroutine neumann_do_nothing(fields, bc, time)
531 type(field_list_t), intent(inout) :: fields
532 type(field_neumann_t), intent(in) :: bc
533 type(time_state_t), intent(in) :: time
534 end subroutine neumann_do_nothing
535
536 subroutine dummy_user_material_properties(scheme_name, properties, time)
537 character(len=*), intent(in) :: scheme_name
538 type(field_list_t), intent(inout) :: properties
539 type(time_state_t), intent(in) :: time
540 end subroutine dummy_user_material_properties
541
542 subroutine dummy_morph_overset_interface(interface_dof, interface_field, &
543 interface_mask, time, bc_name, &
544 find_interface)
545 type(vector_list_t), intent(inout) :: interface_dof
546 type(vector_list_t), intent(inout) :: interface_field
547 type(mask_t), intent(in) :: interface_mask
548 type(time_state_t), intent(in) :: time
549 character(len=*), intent(in) :: bc_name
550 logical, intent(inout) :: find_interface
551 end subroutine dummy_morph_overset_interface
552
553 subroutine dummy_user_ale_mesh_velocity(wm_x, wm_y, wm_z, coef, &
554 x_ref, y_ref, z_ref, base_shapes, time)
555 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
556 type(coef_t), intent(in) :: coef
557 type(field_t), intent(in) :: x_ref, y_ref, z_ref
558 type(field_t), intent(in) :: base_shapes(:)
559 type(time_state_t), intent(in) :: time
560 end subroutine dummy_user_ale_mesh_velocity
561
562 subroutine dummy_user_ale_base_shapes(base_shapes)
563 type(field_t), intent(inout) :: base_shapes(:)
564 end subroutine dummy_user_ale_base_shapes
565
566 subroutine dummy_user_ale_rigid_kinematics(body_id, time, vel_trans, vel_ang)
567 integer, intent(in) :: body_id
568 type(time_state_t), intent(in) :: time
569 real(kind=rp), intent(inout) :: vel_trans(3)
570 real(kind=rp), intent(inout) :: vel_ang(3)
572
573end 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:73
Abstract interface for initilialization of modules.
Definition user_intf.f90:83
Abstract interface for setting material properties.
Abstract interface for user defined mesh deformation functions.
Definition user_intf.f90:93
Abstract interface for user defined source term.
Abstract interface for a user start-up routine.
Definition user_intf.f90:60
Abstract interface for user-defined physical-distance for wall models.
Abstract interface for user-defined GLL sampling for wall models.
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:92
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:14
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_wall_sampling_distance(bc_name, msk, distances)
Dummy user-defined physical-distance wall-sampling callback.
subroutine dummy_user_initial_conditions(scheme_name, fields)
Dummy user initial condition.
subroutine dummy_user_compute(time)
Dummy user compute.
subroutine dummy_user_wall_sampling_gll(bc_name, msk, indices)
Dummy user-defined GLL wall-sampling callback.
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:454
Base type for a boundary condition.
Definition bc.f90:73
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:136
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