Loading [MathJax]/extensions/tex2jax.js
Neko 0.9.99
A portable framework for high-order spectral element flow simulations
All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Pages
user_intf.f90
Go to the documentation of this file.
1! Copyright (c) 2020-2024, 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
41 use coefs, only : coef_t
42 use bc_list, only : bc_list_t
43 use mesh, only : mesh_t
47 use num_types, only : rp
48 use json_module, only : json_file
50 use utils, only : neko_error, neko_warning
51 use logger, only : neko_log
52 use bc, only : bc_t
54 implicit none
55 private
56
58 abstract interface
59 subroutine user_startup_intrf(params)
60 import json_file
61 type(json_file), intent(inout) :: params
62 end subroutine user_startup_intrf
63 end interface
64
66 abstract interface
67 subroutine useric(u, v, w, p, params)
68 import field_t
69 import json_file
70 type(field_t), intent(inout) :: u
71 type(field_t), intent(inout) :: v
72 type(field_t), intent(inout) :: w
73 type(field_t), intent(inout) :: p
74 type(json_file), intent(inout) :: params
75 end subroutine useric
76 end interface
77
79 abstract interface
80 subroutine useric_compressible(rho, u, v, w, p, params)
81 import field_t
82 import json_file
83 type(field_t), intent(inout) :: rho
84 type(field_t), intent(inout) :: u
85 type(field_t), intent(inout) :: v
86 type(field_t), intent(inout) :: w
87 type(field_t), intent(inout) :: p
88 type(json_file), intent(inout) :: params
89 end subroutine useric_compressible
90 end interface
91
93 abstract interface
94 subroutine useric_scalar(s, params)
95 import field_t
96 import json_file
97 type(field_t), intent(inout) :: s
98 type(json_file), intent(inout) :: params
99 end subroutine useric_scalar
100 end interface
101
103 abstract interface
104 subroutine user_initialize_modules(t, u, v, w, p, coef, params)
105 import field_t
106 import json_file
107 import coef_t
108 import rp
109 real(kind=rp) :: t
110 type(field_t), intent(inout) :: u
111 type(field_t), intent(inout) :: v
112 type(field_t), intent(inout) :: w
113 type(field_t), intent(inout) :: p
114 type(coef_t), intent(inout) :: coef
115 type(json_file), intent(inout) :: params
116 end subroutine user_initialize_modules
117 end interface
118
120 abstract interface
121 subroutine user_simcomp_init(params)
122 import json_file
123 type(json_file), intent(inout) :: params
124 end subroutine user_simcomp_init
125 end interface
126
128 abstract interface
129 subroutine usermsh(msh)
130 import mesh_t
131 type(mesh_t), intent(inout) :: msh
132 end subroutine usermsh
133 end interface
134
136 abstract interface
137 subroutine usercheck(t, tstep, u, v, w, p, coef, param)
138 import field_t
139 import coef_t
140 import json_file
141 import rp
142 real(kind=rp), intent(in) :: t
143 integer, intent(in) :: tstep
144 type(field_t), intent(inout) :: u
145 type(field_t), intent(inout) :: v
146 type(field_t), intent(inout) :: w
147 type(field_t), intent(inout) :: p
148 type(coef_t), intent(inout) :: coef
149 type(json_file), intent(inout) :: param
150 end subroutine usercheck
151 end interface
152
154 abstract interface
155 subroutine user_final_modules(t, param)
156 import json_file
157 import rp
158 real(kind=rp) :: t
159 type(json_file), intent(inout) :: param
160 end subroutine user_final_modules
161 end interface
162
170 abstract interface
171 subroutine user_material_properties(t, tstep, rho, mu, cp, lambda, params)
172 import rp
173 import json_file
174 real(kind=rp), intent(in) :: t
175 integer, intent(in) :: tstep
176 real(kind=rp), intent(inout) :: rho, mu, cp, lambda
177 type(json_file), intent(inout) :: params
178 end subroutine user_material_properties
179 end interface
180
182 type, public :: user_t
185 procedure(user_startup_intrf), nopass, pointer :: &
186 user_startup => null()
189 procedure(user_initialize_modules), nopass, pointer :: &
190 user_init_modules => null()
192 procedure(useric), nopass, pointer :: fluid_user_ic => null()
194 procedure(useric_compressible), nopass, pointer :: &
195 fluid_compressible_user_ic => null()
197 procedure(useric_scalar), nopass, pointer :: scalar_user_ic => null()
200 procedure(user_simcomp_init), nopass, pointer :: &
201 init_user_simcomp => null()
203 procedure(usermsh), nopass, pointer :: user_mesh_setup => null()
206 procedure(usercheck), nopass, pointer :: user_check => null()
209 procedure(user_final_modules), nopass, pointer :: &
210 user_finalize_modules => null()
212 procedure(fluid_source_compute_pointwise), nopass, pointer :: &
213 fluid_user_f => null()
215 procedure(fluid_source_compute_vector), nopass, pointer :: &
216 fluid_user_f_vector => null()
218 procedure(scalar_source_compute_pointwise), nopass, pointer :: &
219 scalar_user_f => null()
221 procedure(scalar_source_compute_vector), nopass, pointer :: &
222 scalar_user_f_vector => null()
224 procedure(usr_inflow_eval), nopass, pointer :: fluid_user_if => null()
226 procedure(usr_scalar_bc_eval), nopass, pointer :: scalar_user_bc => null()
229 procedure(field_dirichlet_update), nopass, pointer :: &
230 user_dirichlet_update => null()
232 procedure(user_material_properties), nopass, pointer :: &
233 material_properties => null()
234 contains
242 procedure, pass(this) :: init => user_intf_init
243 end type user_t
244
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%user_startup)) then
260 this%user_startup => dummy_user_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%fluid_user_ic)) then
268 this%fluid_user_ic => dummy_user_ic
269 else
270 user_extended = .true.
271 n = n + 1
272 write(extensions(n), '(A)') '- Fluid initial condition'
273 end if
274
275 if (.not. associated(this%scalar_user_ic)) then
276 this%scalar_user_ic => dummy_user_ic_scalar
277 else
278 user_extended = .true.
279 n = n + 1
280 write(extensions(n), '(A)') '- Scalar initial condition'
281 end if
282
283 if (.not. associated(this%fluid_compressible_user_ic)) then
284 this%fluid_compressible_user_ic => dummy_user_ic_compressible
285 else
286 user_extended = .true.
287 n = n + 1
288 write(extensions(n), '(A)') '- Compressible fluid initial condition'
289 end if
290
291 if (.not. associated(this%fluid_user_f)) then
292 this%fluid_user_f => dummy_user_f
293 else
294 user_extended = .true.
295 n = n + 1
296 write(extensions(n), '(A)') '- Fluid source term'
297 end if
298
299 if (.not. associated(this%fluid_user_f_vector)) then
300 this%fluid_user_f_vector => dummy_user_f_vector
301 else
302 user_extended = .true.
303 n = n + 1
304 write(extensions(n), '(A)') '- Fluid source term vector'
305 end if
306
307 if (.not. associated(this%scalar_user_f)) then
308 this%scalar_user_f => dummy_scalar_user_f
309 else
310 user_extended = .true.
311 n = n + 1
312 write(extensions(n), '(A)') '- Scalar source term'
313 end if
314
315 if (.not. associated(this%scalar_user_f_vector)) then
316 this%scalar_user_f_vector => dummy_user_scalar_f_vector
317 else
318 user_extended = .true.
319 n = n + 1
320 write(extensions(n), '(A)') '- Scalar source term vector'
321 end if
322
323 if (.not. associated(this%scalar_user_bc)) then
324 this%scalar_user_bc => dummy_scalar_user_bc
325 else
326 user_extended = .true.
327 n = n + 1
328 write(extensions(n), '(A)') '- Scalar boundary condition'
329 end if
330
331 if (.not. associated(this%user_dirichlet_update)) then
332 this%user_dirichlet_update => dirichlet_do_nothing
333 else
334 user_extended = .true.
335 n = n + 1
336 write(extensions(n), '(A)') '- Dirichlet boundary condition'
337 end if
338
339 if (.not. associated(this%user_mesh_setup)) then
340 this%user_mesh_setup => dummy_user_mesh_setup
341 else
342 user_extended = .true.
343 n = n + 1
344 write(extensions(n), '(A)') '- Mesh setup'
345 end if
346
347 if (.not. associated(this%user_check)) then
348 this%user_check => dummy_user_check
349 else
350 user_extended = .true.
351 n = n + 1
352 write(extensions(n), '(A)') '- User check'
353 end if
354
355 if (.not. associated(this%user_init_modules)) then
356 this%user_init_modules => dummy_user_init_no_modules
357 else
358 user_extended = .true.
359 n = n + 1
360 write(extensions(n), '(A)') '- Initialize modules'
361 end if
362
363 if (.not. associated(this%init_user_simcomp)) then
364 this%init_user_simcomp => dummy_user_init_no_simcomp
365 end if
366
367 if (.not. associated(this%user_finalize_modules)) then
368 this%user_finalize_modules => dummy_user_final_no_modules
369 else
370 user_extended = .true.
371 n = n + 1
372 write(extensions(n), '(A)') '- Finalize modules'
373 end if
374
375 if (.not. associated(this%material_properties)) then
376 this%material_properties => dummy_user_material_properties
377 else
378 user_extended = .true.
379 n = n + 1
380 write(extensions(n), '(A)') '- Material properties'
381 end if
382
383 if (user_extended) then
384 call neko_log%section('User defined extensions')
385
386 do i = 1, n
387 call neko_log%message(extensions(i))
388 end do
389
390 call neko_log%end_section()
391 end if
392
393 end subroutine user_intf_init
394
395
396 !
397 ! Below is the dummy user interface
398 ! when running in pure turboNEKO mode
399 !
400
402 subroutine dummy_user_startup(params)
403 type(json_file), intent(inout) :: params
404 end subroutine dummy_user_startup
405
407 subroutine dummy_user_ic(u, v, w, p, params)
408 type(field_t), intent(inout) :: u
409 type(field_t), intent(inout) :: v
410 type(field_t), intent(inout) :: w
411 type(field_t), intent(inout) :: p
412 type(json_file), intent(inout) :: params
413 call neko_error('Dummy user defined initial condition set')
414 end subroutine dummy_user_ic
415
417 subroutine dummy_user_ic_compressible(rho, u, v, w, p, params)
418 type(field_t), intent(inout) :: rho
419 type(field_t), intent(inout) :: u
420 type(field_t), intent(inout) :: v
421 type(field_t), intent(inout) :: w
422 type(field_t), intent(inout) :: p
423 type(json_file), intent(inout) :: params
424 call neko_error('Dummy user defined initial condition set')
425 end subroutine dummy_user_ic_compressible
426
430 subroutine dummy_user_ic_scalar(s, params)
431 type(field_t), intent(inout) :: s
432 type(json_file), intent(inout) :: params
433 call neko_error('Dummy user defined scalar initial condition set')
434 end subroutine dummy_user_ic_scalar
435
437 subroutine dummy_user_f_vector(f, t)
438 class(fluid_user_source_term_t), intent(inout) :: f
439 real(kind=rp), intent(in) :: t
440 call neko_error('Dummy user defined vector valued forcing set')
441 end subroutine dummy_user_f_vector
442
444 subroutine dummy_user_f(u, v, w, j, k, l, e, t)
445 real(kind=rp), intent(inout) :: u
446 real(kind=rp), intent(inout) :: v
447 real(kind=rp), intent(inout) :: w
448 integer, intent(in) :: j
449 integer, intent(in) :: k
450 integer, intent(in) :: l
451 integer, intent(in) :: e
452 real(kind=rp), intent(in) :: t
453 call neko_error('Dummy user defined forcing set')
454 end subroutine dummy_user_f
455
458 class(scalar_user_source_term_t), intent(inout) :: f
459 real(kind=rp), intent(in) :: t
460 call neko_error('Dummy user defined vector valued forcing set')
461 end subroutine dummy_user_scalar_f_vector
462
464 subroutine dummy_scalar_user_f(s, j, k, l, e, t)
465 real(kind=rp), intent(inout) :: s
466 integer, intent(in) :: j
467 integer, intent(in) :: k
468 integer, intent(in) :: l
469 integer, intent(in) :: e
470 real(kind=rp), intent(in) :: t
471 call neko_error('Dummy user defined forcing set')
472 end subroutine dummy_scalar_user_f
473
475 subroutine dummy_scalar_user_bc(s, x, y, z, nx, ny, nz, ix, iy, iz, ie, t, &
476 tstep)
477 real(kind=rp), intent(inout) :: s
478 real(kind=rp), intent(in) :: x
479 real(kind=rp), intent(in) :: y
480 real(kind=rp), intent(in) :: z
481 real(kind=rp), intent(in) :: nx
482 real(kind=rp), intent(in) :: ny
483 real(kind=rp), intent(in) :: nz
484 integer, intent(in) :: ix
485 integer, intent(in) :: iy
486 integer, intent(in) :: iz
487 integer, intent(in) :: ie
488 real(kind=rp), intent(in) :: t
489 integer, intent(in) :: tstep
490 call neko_warning('Dummy scalar user bc set, applied on all' // &
491 ' non-labeled zones')
492 end subroutine dummy_scalar_user_bc
493
495 subroutine dummy_user_mesh_setup(msh)
496 type(mesh_t), intent(inout) :: msh
497 end subroutine dummy_user_mesh_setup
498
500 subroutine dummy_user_check(t, tstep, u, v, w, p, coef, params)
501 real(kind=rp), intent(in) :: t
502 integer, intent(in) :: tstep
503 type(field_t), intent(inout) :: u
504 type(field_t), intent(inout) :: v
505 type(field_t), intent(inout) :: w
506 type(field_t), intent(inout) :: p
507 type(coef_t), intent(inout) :: coef
508 type(json_file), intent(inout) :: params
509 end subroutine dummy_user_check
510
511 subroutine dummy_user_init_no_modules(t, u, v, w, p, coef, params)
512 real(kind=rp) :: t
513 type(field_t), intent(inout) :: u
514 type(field_t), intent(inout) :: v
515 type(field_t), intent(inout) :: w
516 type(field_t), intent(inout) :: p
517 type(coef_t), intent(inout) :: coef
518 type(json_file), intent(inout) :: params
519 end subroutine dummy_user_init_no_modules
520
521 subroutine dummy_user_init_no_simcomp(params)
522 type(json_file), intent(inout) :: params
523 end subroutine dummy_user_init_no_simcomp
524
525 subroutine dummy_user_final_no_modules(t, params)
526 real(kind=rp) :: t
527 type(json_file), intent(inout) :: params
528 end subroutine dummy_user_final_no_modules
529
530 subroutine dirichlet_do_nothing(dirichlet_field_list, dirichlet_bc, &
531 coef, t, tstep)
532 type(field_list_t), intent(inout) :: dirichlet_field_list
533 type(field_dirichlet_t), intent(in) :: dirichlet_bc
534 type(coef_t), intent(inout) :: coef
535 real(kind=rp), intent(in) :: t
536 integer, intent(in) :: tstep
537 end subroutine dirichlet_do_nothing
538
539 subroutine dummy_user_material_properties(t, tstep, rho, mu, cp, lambda,&
540 params)
541 real(kind=rp), intent(in) :: t
542 integer, intent(in) :: tstep
543 real(kind=rp), intent(inout) :: rho, mu, cp, lambda
544 type(json_file), intent(inout) :: params
545 end subroutine dummy_user_material_properties
546
547 ! ========================================================================== !
548 ! Helper functions for user defined interfaces
549
554 function simulation_component_user_settings(name, params) result(comp_subdict)
555 character(len=*), intent(in) :: name
556 type(json_file), intent(inout) :: params
557 type(json_file) :: comp_subdict
558
559 character(len=:), allocatable :: current_type
560 integer :: n_simcomps
561 integer :: i
562 logical :: found, is_user
563
564 call params%info('', n_children = n_simcomps)
565
566 found = .false.
567 do i = 1, n_simcomps
568 call json_extract_item(params, "", i, comp_subdict)
569 call json_get_or_default(comp_subdict, "is_user", is_user, .false.)
570 if (.not. is_user) cycle
571
572 call json_get(comp_subdict, "type", current_type)
573 if (trim(current_type) .eq. trim(name)) then
574 found = .true.
575 exit
576 end if
577 end do
578
579 if (.not. found) then
580 call neko_error("User-defined simulation component " &
581 // trim(name) // " not found in case file.")
582 end if
583
585
586
593end module user_intf
Abstract interface defining a dirichlet condition on a list of fields.
Computes the source term and adds the result to 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.
Computes the source term and adds the result to fields.
Abstract interface for finalizating user variables.
Abstract interface for initilialization of modules.
Abstract interface for setting material properties.
Abstract interface for adding user defined simulation components.
Abstract interface for a user start-up routine.
Definition user_intf.f90:59
Abstract interface for user defined check functions.
Abstract interface for user defined initial conditions.
Definition user_intf.f90:80
Abstract interface for user defined scalar initial conditions.
Definition user_intf.f90:94
Abstract interface for user defined initial conditions.
Definition user_intf.f90:67
Abstract interface for user defined mesh deformation functions.
Abstract interface defining a user defined inflow condition (pointwise)
Abstract interface defining a user defined scalar boundary condition (pointwise) Just imitating inflo...
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 a field.
Definition field.f90:34
Implements the fluid_user_source_term_t type.
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:65
Defines a mesh.
Definition mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Implements the scalar_user_source_term_t type.
Interfaces for user interaction with NEKO.
Definition user_intf.f90:34
subroutine dummy_user_f_vector(f, t)
Dummy user (fluid) forcing.
subroutine dummy_user_ic_scalar(s, params)
Dummy user initial condition for scalar field.
type(json_file) function, public simulation_component_user_settings(name, params)
JSON extraction helper function for simulation components.
subroutine dummy_user_final_no_modules(t, params)
subroutine dummy_user_init_no_simcomp(params)
subroutine dummy_scalar_user_f(s, j, k, l, e, t)
Dummy user (scalar) forcing.
subroutine user_intf_init(this)
Constructor.
subroutine dummy_user_f(u, v, w, j, k, l, e, t)
Dummy user (fluid) forcing.
subroutine dummy_user_mesh_setup(msh)
Dummy user mesh apply.
subroutine dummy_user_startup(params)
Dummy user startup.
subroutine dummy_user_ic(u, v, w, p, params)
Dummy user initial condition.
subroutine, public dummy_user_material_properties(t, tstep, rho, mu, cp, lambda, params)
subroutine dummy_user_ic_compressible(rho, u, v, w, p, params)
Dummy user initial condition.
subroutine dirichlet_do_nothing(dirichlet_field_list, dirichlet_bc, coef, t, tstep)
subroutine dummy_user_check(t, tstep, u, v, w, p, coef, params)
Dummy user check.
subroutine dummy_user_scalar_f_vector(f, t)
Dummy user (scalar) forcing.
subroutine dummy_scalar_user_bc(s, x, y, z, nx, ny, nz, ix, iy, iz, ie, t, tstep)
Dummy user boundary condition for scalar.
subroutine dummy_user_init_no_modules(t, u, v, w, p, coef, params)
Defines inflow dirichlet conditions.
Defines dirichlet conditions for scalars.
Utilities.
Definition utils.f90:35
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Definition utils.f90:266
Base type for a boundary condition.
Definition bc.f90:57
A list of allocatable `bc_t`. Follows the standard interface of lists.
Definition bc_list.f90:47
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:55
User defined dirichlet condition, for which the user can work with an entire field....
field_list_t, To be able to group fields together
A source-term for the fluid, with procedure pointers pointing to the actual implementation in the use...
A source-term for the scalar, with procedure pointers pointing to the actual implementation in the us...
A type collecting all the overridable user routines.
User defined dirichlet condition for velocity.
User defined dirichlet condition for scalars.