Neko 1.99.10
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
smagorinsky_device.f90
Go to the documentation of this file.
1! Copyright (c) 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!
33!> Implements the device kernel for the `smagorinsky_t` type.
35 use num_types, only : rp
36 use field_list, only : field_list_t
38 use registry, only : neko_registry
39 use field, only : field_t
40 use operators, only : strain_rate
41 use coefs, only : coef_t
42 use gs_ops, only : gs_op_add
43 use device, only : glb_cmd_event
44 use device_math, only : device_col2
46 implicit none
47 private
48
50
51contains
52
53 !> Compute eddy viscosity on the device.
54 !! @param if_ext If extrapolate the velocity field to evaluate
55 !! @param t The time value.
56 !! @param tstep The current time-step.
57 !! @param coef SEM coefficients.
58 !! @param nut The SGS viscosity array.
59 !! @param delta The LES lengthscale.
60 !! @param c_s The smagorinsky model constant
61 subroutine smagorinsky_compute_device(if_ext, t, tstep, coef, nut, delta, c_s)
62 logical, intent(in) :: if_ext
63 real(kind=rp), intent(in) :: t
64 integer, intent(in) :: tstep
65 type(coef_t), intent(in) :: coef
66 type(field_t), intent(inout) :: nut
67 type(field_t), intent(in) :: delta
68 real(kind=rp), intent(in) :: c_s
69 type(field_t), pointer :: u, v, w
70 ! double of the strain rate tensor
71 type(field_t), pointer :: s11, s22, s33, s12, s13, s23
72 integer :: temp_indices(6)
73 integer :: e, i
74
75 if (if_ext .eqv. .true.) then
76 u => neko_registry%get_field_by_name("u_e")
77 v => neko_registry%get_field_by_name("v_e")
78 w => neko_registry%get_field_by_name("w_e")
79 else
80 u => neko_registry%get_field_by_name("u")
81 v => neko_registry%get_field_by_name("v")
82 w => neko_registry%get_field_by_name("w")
83 end if
84
85 call neko_scratch_registry%request_field(s11, temp_indices(1), .false.)
86 call neko_scratch_registry%request_field(s22, temp_indices(2), .false.)
87 call neko_scratch_registry%request_field(s33, temp_indices(3), .false.)
88 call neko_scratch_registry%request_field(s12, temp_indices(4), .false.)
89 call neko_scratch_registry%request_field(s13, temp_indices(5), .false.)
90 call neko_scratch_registry%request_field(s23, temp_indices(6), .false.)
91
92 ! Compute the strain rate tensor
93 call strain_rate(s11%x_d, s22%x_d, s33%x_d, s12%x_d, s13%x_d, s23%x_d, &
94 u%x_d, v%x_d, w%x_d, coef)
95
96 call coef%gs_h%op(s11%x, s22%x, s33%x, s11%dof%size(), gs_op_add, &
98 call coef%gs_h%op(s12%x, s13%x, s23%x, s12%dof%size(), gs_op_add, &
100
101 call device_smagorinsky_nut_compute(s11%x_d, s22%x_d, s33%x_d, &
102 s12%x_d, s13%x_d, s23%x_d, &
103 delta%x_d, nut%x_d, coef%mult_d, &
104 c_s, s11%dof%size())
105
106 call coef%gs_h%op(nut, gs_op_add, glb_cmd_event)
107 call device_col2(nut%x_d, coef%mult_d, nut%dof%size())
108
109 call neko_scratch_registry%relinquish_field(temp_indices)
110 end subroutine smagorinsky_compute_device
111
112end module smagorinsky_device
113
Compute the strain rate tensor of a vector field.
Coefficients.
Definition coef.f90:34
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
subroutine, public device_smagorinsky_nut_compute(s11_d, s22_d, s33_d, s12_d, s13_d, s23_d, delta_d, nut_d, mult_d, c_s, n)
Compute the eddy viscosity field for the Sigma model indevice.
Device abstraction, common interface for various accelerators.
Definition device.F90:34
type(c_ptr), bind(C), public glb_cmd_event
Event for the global command queue.
Definition device.F90:63
Defines a field.
Definition field.f90:34
Defines Gather-scatter operations.
Definition gs_ops.f90:34
integer, parameter, public gs_op_add
Definition gs_ops.f90:36
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Operators.
Definition operators.f90:34
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:158
Defines a registry for storing and requesting temporary objects This can be used when you have a func...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Implements the device kernel for the smagorinsky_t type.
subroutine, public smagorinsky_compute_device(if_ext, t, tstep, coef, nut, delta, c_s)
Compute eddy viscosity on the device.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:136
field_list_t, To be able to group fields together