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
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
101 abstract interface
102 subroutine user_wall_sampling_gll_intf(bc_name, msk, indices)
103 character(len=*), intent(in) :: bc_name
104 integer, intent(in) :: msk(:)
105 integer, intent(out) :: indices(:,:)
106 end subroutine user_wall_sampling_gll_intf
107 end interface
108
113 abstract interface
114 subroutine user_wall_sampling_distance_intf(bc_name, msk, distances)
115 import rp
116 character(len=*), intent(in) :: bc_name
117 integer, intent(in) :: msk(:)
118 real(kind=rp), intent(out) :: distances(:,:)
120 end interface
121
124 abstract interface
125 subroutine user_compute_intf(time)
126 import time_state_t
127 type(time_state_t), intent(in) :: time
128 end subroutine user_compute_intf
129 end interface
130
133 abstract interface
134 subroutine user_finalize_intf(time)
135 import json_file
136 import time_state_t
137 type(time_state_t), intent(in) :: time
138 end subroutine user_finalize_intf
139 end interface
140
145 abstract interface
146 subroutine user_source_term_intf(scheme_name, rhs, time)
148 character(len=*), intent(in) :: scheme_name
149 type(field_list_t), intent(inout) :: rhs
150 type(time_state_t), intent(in) :: time
151 end subroutine user_source_term_intf
152 end interface
153
161 abstract interface
162 subroutine user_material_properties_intf(scheme_name, properties, time)
164 character(len=*), intent(in) :: scheme_name
165 type(field_list_t), intent(inout) :: properties
166 type(time_state_t), intent(in) :: time
167 end subroutine user_material_properties_intf
168 end interface
169
176 abstract interface
177 subroutine user_ale_mesh_velocity_intf(wm_x, wm_y, wm_z, coef, &
178 x_ref, y_ref, z_ref, base_shapes, time)
180 type(coef_t), intent(in) :: coef
181 type(field_t), intent(in) :: x_ref, y_ref, z_ref
182 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
183 type(field_t), intent(in) :: base_shapes(:)
184 type(time_state_t), intent(in) :: time
185 end subroutine user_ale_mesh_velocity_intf
186 end interface
187
190 abstract interface
191 subroutine user_ale_base_shapes_intf(base_shapes)
192 import field_t
193 type(field_t), intent(inout) :: base_shapes(:)
194 end subroutine user_ale_base_shapes_intf
195 end interface
196
202 abstract interface
203 subroutine user_ale_rigid_kinematics_intf(body_id, time, &
204 vel_trans, vel_ang)
205 import rp, time_state_t
206 integer, intent(in) :: body_id
207 type(time_state_t), intent(in) :: time
208 real(kind=rp), intent(inout) :: vel_trans(3)
209 real(kind=rp), intent(inout) :: vel_ang(3)
210 end subroutine user_ale_rigid_kinematics_intf
211 end interface
212
213
216 type, public :: user_t
221 logical :: suppress_type_injection = .false.
224 procedure(user_startup_intf), nopass, pointer :: startup => null()
227 procedure(user_initialize_intf), nopass, pointer :: initialize => null()
229 procedure(user_initial_conditions_intf), nopass, pointer :: &
230 initial_conditions => null()
231 procedure(user_mesh_setup_intf), nopass, pointer :: mesh_setup => null()
233 procedure(user_wall_sampling_gll_intf), nopass, pointer :: &
234 wall_sampling_gll => null()
236 procedure(user_wall_sampling_distance_intf), nopass, pointer :: &
237 wall_sampling_distance => null()
239 procedure(user_compute_intf), nopass, pointer :: preprocess => null()
242 procedure(user_compute_intf), nopass, pointer :: compute => null()
245 procedure(user_finalize_intf), nopass, pointer :: &
246 finalize => null()
248 procedure(user_source_term_intf), nopass, pointer :: &
249 source_term => null()
251 procedure(field_dirichlet_update), nopass, pointer :: &
252 dirichlet_conditions => null()
254 procedure(field_neumann_update), nopass, pointer :: &
255 neumann_conditions => null()
257 procedure(user_material_properties_intf), nopass, pointer :: &
258 material_properties => null()
260 procedure(user_ale_mesh_velocity_intf), nopass, pointer :: &
261 ale_mesh_velocity => null()
263 procedure(user_ale_rigid_kinematics_intf), nopass, pointer :: &
264 ale_rigid_kinematics => null()
266 procedure(user_ale_base_shapes_intf), nopass, pointer :: &
267 ale_base_shapes => null()
269 procedure(morph_overset_interface), nopass, pointer :: &
270 morph_interface => null()
271 contains
279 procedure, pass(this) :: init => user_intf_init
280 end type user_t
281
291contains
292
294 subroutine user_intf_init(this)
295 class(user_t), intent(inout) :: this
296 logical :: user_extended = .false.
297 character(len=256), dimension(20) :: extensions
298 integer :: i, n
299
300 n = 0
301 if (.not. associated(this%startup)) then
302 this%startup => dummy_startup
303 else
304 user_extended = .true.
305 n = n + 1
306 write(extensions(n), '(A)') '- Startup'
307 end if
308
309 if (.not. associated(this%initial_conditions)) then
310 this%initial_conditions => dummy_user_initial_conditions
311 else
312 user_extended = .true.
313 n = n + 1
314 write(extensions(n), '(A)') '- Initial condition'
315 end if
316
317 if (.not. associated(this%source_term)) then
318 this%source_term => dummy_user_source_term
319 else
320 user_extended = .true.
321 n = n + 1
322 write(extensions(n), '(A)') '- Source term'
323 end if
324
325 if (.not. associated(this%dirichlet_conditions)) then
326 this%dirichlet_conditions => dirichlet_do_nothing
327 else
328 user_extended = .true.
329 n = n + 1
330 write(extensions(n), '(A)') '- Dirichlet boundary condition'
331 end if
332
333 if (.not. associated(this%neumann_conditions)) then
334 this%neumann_conditions => neumann_do_nothing
335 else
336 user_extended = .true.
337 n = n + 1
338 write(extensions(n), '(A)') '- Neumann boundary condition'
339 end if
340
341 if (.not. associated(this%mesh_setup)) then
342 this%mesh_setup => dummy_user_mesh_setup
343 else
344 user_extended = .true.
345 n = n + 1
346 write(extensions(n), '(A)') '- Mesh setup'
347 end if
348
349 if (.not. associated(this%wall_sampling_gll)) then
350 this%wall_sampling_gll => dummy_user_wall_sampling_gll
351 else
352 user_extended = .true.
353 n = n + 1
354 write(extensions(n), '(A)') '- GLL wall sampling'
355 end if
356
357 if (.not. associated(this%wall_sampling_distance)) then
358 this%wall_sampling_distance => dummy_user_wall_sampling_distance
359 else
360 user_extended = .true.
361 n = n + 1
362 write(extensions(n), '(A)') '- Distance wall sampling'
363 end if
364
365 if (.not. associated(this%compute)) then
366 this%compute => dummy_user_compute
367 else
368 user_extended = .true.
369 n = n + 1
370 write(extensions(n), '(A)') '- User compute'
371 end if
372
373 if (.not. associated(this%preprocess)) then
374 this%preprocess => dummy_user_compute
375 else
376 user_extended = .true.
377 n = n + 1
378 write(extensions(n), '(A)') '- User preprocess'
379 end if
380
381 if (.not. associated(this%initialize)) then
382 this%initialize => dummy_initialize
383 else
384 user_extended = .true.
385 n = n + 1
386 write(extensions(n), '(A)') '- Initialize modules'
387 end if
388
389 if (.not. associated(this%finalize)) then
390 this%finalize => dummy_user_finalize
391 else
392 user_extended = .true.
393 n = n + 1
394 write(extensions(n), '(A)') '- Finalize modules'
395 end if
396
397 if (.not. associated(this%material_properties)) then
398 this%material_properties => dummy_user_material_properties
399 else
400 user_extended = .true.
401 n = n + 1
402 write(extensions(n), '(A)') '- Material properties'
403 end if
404
405 if (.not. associated(this%ale_mesh_velocity)) then
406 this%ale_mesh_velocity => dummy_user_ale_mesh_velocity
407 else
408 user_extended = .true.
409 n = n + 1
410 write(extensions(n), '(A)') '- ALE mesh velocity'
411 end if
412
413 if (.not. associated(this%ale_rigid_kinematics)) then
414 this%ale_rigid_kinematics => dummy_user_ale_rigid_kinematics
415 else
416 user_extended = .true.
417 n = n + 1
418 write(extensions(n), '(A)') '- ALE kinematics'
419 end if
420
421 if (.not. associated(this%ale_base_shapes)) then
422 this%ale_base_shapes => dummy_user_ale_base_shapes
423 else
424 user_extended = .true.
425 n = n + 1
426 write(extensions(n), '(A)') '- ALE base shapes'
427 end if
428
429 if (.not. associated(this%morph_interface)) then
430 this%morph_interface => dummy_morph_overset_interface
431 else
432 user_extended = .true.
433 n = n + 1
434 write(extensions(n), '(A)') '- Morph overset interface'
435 end if
436
437 if (user_extended) then
438 call neko_log%section('User defined extensions')
439
440 do i = 1, n
441 call neko_log%message(extensions(i))
442 end do
443
444 call neko_log%end_section()
445 end if
446
447 end subroutine user_intf_init
448
449
450 !
451 ! Below is the dummy user interface
452 ! when running in pure turboNEKO mode
453 !
454
456 subroutine dummy_startup(params)
457 type(json_file), intent(inout) :: params
458 end subroutine dummy_startup
459
461 subroutine dummy_user_initial_conditions(scheme_name, fields)
462 character(len=*), intent(in) :: scheme_name
463 type(field_list_t), intent(inout) :: fields
464
465 call neko_error('Dummy user defined initial condition set')
466 end subroutine dummy_user_initial_conditions
467
469 subroutine dummy_user_source_term(scheme_name, rhs, time)
470 character(len=*), intent(in) :: scheme_name
471 type(field_list_t), intent(inout) :: rhs
472 type(time_state_t), intent(in) :: time
473 call neko_error('Dummy user defined source term set')
474 end subroutine dummy_user_source_term
475
477 subroutine dummy_user_mesh_setup(msh, time)
478 type(mesh_t), intent(inout) :: msh
479 type(time_state_t), intent(in) :: time
480 end subroutine dummy_user_mesh_setup
481
486 subroutine dummy_user_wall_sampling_gll(bc_name, msk, indices)
487 character(len=*), intent(in) :: bc_name
488 integer, intent(in) :: msk(:)
489 integer, intent(out) :: indices(:,:)
490
491 call neko_error('Wall sampling for '//trim(bc_name)// &
492 ' is configured as user, but wall_sampling_gll is not set')
493 end subroutine dummy_user_wall_sampling_gll
494
499 subroutine dummy_user_wall_sampling_distance(bc_name, msk, distances)
500 character(len=*), intent(in) :: bc_name
501 integer, intent(in) :: msk(:)
502 real(kind=rp), intent(out) :: distances(:,:)
503
504 call neko_error('Wall sampling for '//trim(bc_name)// &
505 ' is configured as user, but wall_sampling_distance is not set')
507
509 subroutine dummy_user_compute(time)
510 type(time_state_t), intent(in) :: time
511 end subroutine dummy_user_compute
512
513 subroutine dummy_initialize(time)
514 type(time_state_t), intent(in) :: time
515 end subroutine dummy_initialize
516
517 subroutine dummy_user_finalize(time)
518 type(time_state_t), intent(in) :: time
519 end subroutine dummy_user_finalize
520
521 subroutine dirichlet_do_nothing(fields, bc, time)
522 type(field_list_t), intent(inout) :: fields
523 type(field_dirichlet_t), intent(in) :: bc
524 type(time_state_t), intent(in) :: time
525 end subroutine dirichlet_do_nothing
526
527 subroutine neumann_do_nothing(fields, bc, time)
528 type(field_list_t), intent(inout) :: fields
529 type(field_neumann_t), intent(in) :: bc
530 type(time_state_t), intent(in) :: time
531 end subroutine neumann_do_nothing
532
533 subroutine dummy_user_material_properties(scheme_name, properties, time)
534 character(len=*), intent(in) :: scheme_name
535 type(field_list_t), intent(inout) :: properties
536 type(time_state_t), intent(in) :: time
537 end subroutine dummy_user_material_properties
538
539 subroutine dummy_morph_overset_interface(interface_dof, interface_field, &
540 interface_mask, time, bc_name, &
541 find_interface)
542 type(vector_list_t), intent(inout) :: interface_dof
543 type(vector_list_t), intent(inout) :: interface_field
544 type(mask_t), intent(in) :: interface_mask
545 type(time_state_t), intent(in) :: time
546 character(len=*), intent(in) :: bc_name
547 logical, intent(inout) :: find_interface
548 end subroutine dummy_morph_overset_interface
549
550 subroutine dummy_user_ale_mesh_velocity(wm_x, wm_y, wm_z, coef, &
551 x_ref, y_ref, z_ref, base_shapes, time)
552 type(field_t), intent(inout) :: wm_x, wm_y, wm_z
553 type(coef_t), intent(in) :: coef
554 type(field_t), intent(in) :: x_ref, y_ref, z_ref
555 type(field_t), intent(in) :: base_shapes(:)
556 type(time_state_t), intent(in) :: time
557 end subroutine dummy_user_ale_mesh_velocity
558
559 subroutine dummy_user_ale_base_shapes(base_shapes)
560 type(field_t), intent(inout) :: base_shapes(:)
561 end subroutine dummy_user_ale_base_shapes
562
563 subroutine dummy_user_ale_rigid_kinematics(body_id, time, vel_trans, vel_ang)
564 integer, intent(in) :: body_id
565 type(time_state_t), intent(in) :: time
566 real(kind=rp), intent(inout) :: vel_trans(3)
567 real(kind=rp), intent(inout) :: vel_ang(3)
569
570end 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
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: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: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:398
Base type for a boundary condition.
Definition bc.f90:72
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:93
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