Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
sigma_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 `sigma_t` type.
35 use num_types, only : rp
36 use field_list, only : field_list_t
37 use device_math, only : device_col2
38 use math, only : neko_eps
40 use registry, only : neko_registry
41 use field, only : field_t
42 use operators, only : dudxyz
43 use coefs, only : coef_t
44 use gs_ops, only : gs_op_add
45 use device, only : glb_cmd_event
47 implicit none
48 private
49
50 public :: sigma_compute_device
51
52contains
53
54 !> Compute eddy viscosity on device.
55 !! @param if_ext If extrapolate the velocity field to evaluate
56 !! @param t The time value.
57 !! @param tstep The current time-step.
58 !! @param coef SEM coefficients.
59 !! @param nut The SGS viscosity array.
60 !! @param delta The LES lengthscale.
61 !! @param c The Sigma model constant
62 subroutine sigma_compute_device(if_ext, t, tstep, coef, nut, delta, c)
63 logical, intent(in) :: if_ext
64 real(kind=rp), intent(in) :: t
65 integer, intent(in) :: tstep
66 type(coef_t), intent(in) :: coef
67 type(field_t), intent(inout) :: nut
68 type(field_t), intent(in) :: delta
69 real(kind=rp), intent(in) :: c
70 ! This is the velocity gradient tensor
71 type(field_t), pointer :: g11, g12, g13, g21, g22, g23, g31, g32, g33
72 type(field_t), pointer :: u, v, w
73
74 real(kind=rp) :: pi_3 = 4.0_rp/3.0_rp*atan(1.0_rp)
75 real(kind=rp) :: eps
76
77 integer :: temp_indices(9)
78 integer :: e, i
79
80 ! some constant
81 eps = neko_eps
82
83 ! get fields from registry
84 if (if_ext .eqv. .true.) then
85 u => neko_registry%get_field_by_name("u_e")
86 v => neko_registry%get_field_by_name("v_e")
87 w => neko_registry%get_field_by_name("w_e")
88 else
89 u => neko_registry%get_field_by_name("u")
90 v => neko_registry%get_field_by_name("v")
91 w => neko_registry%get_field_by_name("w")
92 end if
93
94 call neko_scratch_registry%request_field(g11, temp_indices(1), .false.)
95 call neko_scratch_registry%request_field(g12, temp_indices(2), .false.)
96 call neko_scratch_registry%request_field(g13, temp_indices(3), .false.)
97 call neko_scratch_registry%request_field(g21, temp_indices(4), .false.)
98 call neko_scratch_registry%request_field(g22, temp_indices(5), .false.)
99 call neko_scratch_registry%request_field(g23, temp_indices(6), .false.)
100 call neko_scratch_registry%request_field(g31, temp_indices(7), .false.)
101 call neko_scratch_registry%request_field(g32, temp_indices(8), .false.)
102 call neko_scratch_registry%request_field(g33, temp_indices(9), .false.)
103
104 ! Compute the derivatives of the velocity (the components of the g tensor)
105 call dudxyz(g11%x_d, u%x_d, coef%drdx_d, coef%dsdx_d, coef%dtdx_d, coef)
106 call dudxyz(g12%x_d, u%x_d, coef%drdy_d, coef%dsdy_d, coef%dtdy_d, coef)
107 call dudxyz(g13%x_d, u%x_d, coef%drdz_d, coef%dsdz_d, coef%dtdz_d, coef)
108
109 call dudxyz(g21%x_d, v%x_d, coef%drdx_d, coef%dsdx_d, coef%dtdx_d, coef)
110 call dudxyz(g22%x_d, v%x_d, coef%drdy_d, coef%dsdy_d, coef%dtdy_d, coef)
111 call dudxyz(g23%x_d, v%x_d, coef%drdz_d, coef%dsdz_d, coef%dtdz_d, coef)
112
113 call dudxyz(g31%x_d, w%x_d, coef%drdx_d, coef%dsdx_d, coef%dtdx_d, coef)
114 call dudxyz(g32%x_d, w%x_d, coef%drdy_d, coef%dsdy_d, coef%dtdy_d, coef)
115 call dudxyz(g33%x_d, w%x_d, coef%drdz_d, coef%dsdz_d, coef%dtdz_d, coef)
116
117 call coef%gs_h%op(g11%x, g12%x, g13%x, g11%dof%size(), gs_op_add, &
119 call coef%gs_h%op(g21%x, g22%x, g23%x, g21%dof%size(), gs_op_add, &
121 call coef%gs_h%op(g31%x, g32%x, g33%x, g31%dof%size(), gs_op_add, &
123
124 call device_sigma_nut_compute(g11%x_d, g12%x_d, g13%x_d, &
125 g21%x_d, g22%x_d, g23%x_d, &
126 g31%x_d, g32%x_d, g33%x_d, &
127 delta%x_d, nut%x_d, coef%mult_d, &
128 c, eps, g11%dof%size())
129
130 call coef%gs_h%op(nut, gs_op_add, glb_cmd_event)
131 call device_col2(nut%x_d, coef%mult_d, nut%dof%size())
132
133 call neko_scratch_registry%relinquish_field(temp_indices)
134 end subroutine sigma_compute_device
135end module sigma_device
Compute derivative of a scalar field along a single direction.
Definition operators.f90:79
Coefficients.
Definition coef.f90:34
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
subroutine, public device_sigma_nut_compute(g11_d, g12_d, g13_d, g21_d, g22_d, g23_d, g31_d, g32_d, g33_d, delta_d, nut_d, mult_d, c, eps, 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
Definition math.F90:60
real(kind=rp), parameter, public neko_eps
Machine epsilon .
Definition math.F90:70
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 sigma_t type.
subroutine, public sigma_compute_device(if_ext, t, tstep, coef, nut, delta, c)
Compute eddy viscosity on 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