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 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()
229 procedure(user_ale_mesh_velocity_intf), nopass, pointer :: &
230 ale_mesh_velocity => null()
231 procedure(user_ale_rigid_kinematics_intf), nopass, pointer :: &
232 ale_rigid_kinematics => null()
233 procedure(user_ale_base_shapes_intf), nopass, pointer :: &
234 ale_base_shapes => null()
236 procedure(morph_overset_interface), nopass, pointer :: &
237 morph_interface => null()
238 contains
246 procedure, pass(this) :: init => user_intf_init
247 end type user_t
248
255contains
256
258 subroutine user_intf_init(this)
259 class(user_t), intent(inout) :: this
260 logical :: user_extended = .false.
261 character(len=256), dimension(14) :: extensions
262 integer :: i, n
263
264 n = 0
265 if (.not. associated(this%startup)) then
266 this%startup => dummy_startup
267 else
268 user_extended = .true.
269 n = n + 1
270 write(extensions(n), '(A)') '- Startup'
271 end if
272
273 if (.not. associated(this%initial_conditions)) then
274 this%initial_conditions => dummy_user_initial_conditions
275 else
276 user_extended = .true.
277 n = n + 1
278 write(extensions(n), '(A)') '- Initial condition'
279 end if
280
281 if (.not. associated(this%source_term)) then
282 this%source_term => dummy_user_source_term
283 else
284 user_extended = .true.
285 n = n + 1
286 write(extensions(n), '(A)') '- Source term'
287 end if
288
289 if (.not. associated(this%dirichlet_conditions)) then
290 this%dirichlet_conditions => dirichlet_do_nothing
291 else
292 user_extended = .true.
293 n = n + 1
294 write(extensions(n), '(A)') '- Dirichlet boundary condition'
295 end if
296
297 if (.not. associated(this%neumann_conditions)) then
298 this%neumann_conditions => neumann_do_nothing
299 else
300 user_extended = .true.
301 n = n + 1
302 write(extensions(n), '(A)') '- Neumann boundary condition'
303 end if
304
305 if (.not. associated(this%mesh_setup)) then
306 this%mesh_setup => dummy_user_mesh_setup
307 else
308 user_extended = .true.
309 n = n + 1
310 write(extensions(n), '(A)') '- Mesh setup'
311 end if
312
313 if (.not. associated(this%compute)) then
314 this%compute => dummy_user_compute
315 else
316 user_extended = .true.
317 n = n + 1
318 write(extensions(n), '(A)') '- User compute'
319 end if
320
321 if (.not. associated(this%preprocess)) then
322 this%preprocess => dummy_user_compute
323 else
324 user_extended = .true.
325 n = n + 1
326 write(extensions(n), '(A)') '- User preprocess'
327 end if
328
329 if (.not. associated(this%initialize)) then
330 this%initialize => dummy_initialize
331 else
332 user_extended = .true.
333 n = n + 1
334 write(extensions(n), '(A)') '- Initialize modules'
335 end if
336
337 if (.not. associated(this%finalize)) then
338 this%finalize => dummy_user_finalize
339 else
340 user_extended = .true.
341 n = n + 1
342 write(extensions(n), '(A)') '- Finalize modules'
343 end if
344
345 if (.not. associated(this%material_properties)) then
346 this%material_properties => dummy_user_material_properties
347 else
348 user_extended = .true.
349 n = n + 1
350 write(extensions(n), '(A)') '- Material properties'
351 end if
352
353 if (associated(this%ale_mesh_velocity)) then
354 user_extended = .true.
355 n = n + 1
356 write(extensions(n), '(A)') '- ALE mesh velocity'
357 end if
358
359 if (associated(this%ale_rigid_kinematics)) then
360 user_extended = .true.
361 n = n + 1
362 write(extensions(n), '(A)') '- ALE kinematics'
363 end if
364
365 if (associated(this%ale_base_shapes)) then
366 user_extended = .true.
367 n = n + 1
368 write(extensions(n), '(A)') '- ALE base shapes'
369 end if
370
371 if (.not. associated(this%morph_interface)) then
372 this%morph_interface => dummy_morph_overset_interface
373 else
374 user_extended = .true.
375 n = n + 1
376 write(extensions(n), '(A)') '- Morph overset interface'
377 end if
378
379 if (user_extended) then
380 call neko_log%section('User defined extensions')
381
382 do i = 1, n
383 call neko_log%message(extensions(i))
384 end do
385
386 call neko_log%end_section()
387 end if
388
389 end subroutine user_intf_init
390
391
392 !
393 ! Below is the dummy user interface
394 ! when running in pure turboNEKO mode
395 !
396
398 subroutine dummy_startup(params)
399 type(json_file), intent(inout) :: params
400 end subroutine dummy_startup
401
403 subroutine dummy_user_initial_conditions(scheme_name, fields)
404 character(len=*), intent(in) :: scheme_name
405 type(field_list_t), intent(inout) :: fields
406
407 call neko_error('Dummy user defined initial condition set')
408 end subroutine dummy_user_initial_conditions
409
411 subroutine dummy_user_source_term(scheme_name, rhs, time)
412 character(len=*), intent(in) :: scheme_name
413 type(field_list_t), intent(inout) :: rhs
414 type(time_state_t), intent(in) :: time
415 call neko_error('Dummy user defined source term set')
416 end subroutine dummy_user_source_term
417
419 subroutine dummy_user_mesh_setup(msh, time)
420 type(mesh_t), intent(inout) :: msh
421 type(time_state_t), intent(in) :: time
422 end subroutine dummy_user_mesh_setup
423
425 subroutine dummy_user_compute(time)
426 type(time_state_t), intent(in) :: time
427 end subroutine dummy_user_compute
428
429 subroutine dummy_initialize(time)
430 type(time_state_t), intent(in) :: time
431 end subroutine dummy_initialize
432
433 subroutine dummy_user_finalize(time)
434 type(time_state_t), intent(in) :: time
435 end subroutine dummy_user_finalize
436
437 subroutine dirichlet_do_nothing(fields, bc, time)
438 type(field_list_t), intent(inout) :: fields
439 type(field_dirichlet_t), intent(in) :: bc
440 type(time_state_t), intent(in) :: time
441 end subroutine dirichlet_do_nothing
442
443 subroutine neumann_do_nothing(fields, bc, time)
444 type(field_list_t), intent(inout) :: fields
445 type(field_neumann_t), intent(in) :: bc
446 type(time_state_t), intent(in) :: time
447 end subroutine neumann_do_nothing
448
449 subroutine dummy_user_material_properties(scheme_name, properties, time)
450 character(len=*), intent(in) :: scheme_name
451 type(field_list_t), intent(inout) :: properties
452 type(time_state_t), intent(in) :: time
453 end subroutine dummy_user_material_properties
454
455 subroutine dummy_morph_overset_interface(interface_dof, interface_field, &
456 interface_mask, time, bc_name, &
457 find_interface)
458 type(vector_list_t), intent(inout) :: interface_dof
459 type(vector_list_t), intent(inout) :: interface_field
460 type(mask_t), intent(in) :: interface_mask
461 type(time_state_t), intent(in) :: time
462 character(len=*), intent(in) :: bc_name
463 logical, intent(inout) :: find_interface
464 end subroutine dummy_morph_overset_interface
465
466end 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:79
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 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.
subroutine dummy_morph_overset_interface(interface_dof, interface_field, interface_mask, time, bc_name, find_interface)
Utilities.
Definition utils.f90:35
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Definition utils.f90:392
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:63
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