Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
deardorff_device.f90
Go to the documentation of this file.
1! Copyright (c) 2025-2026, 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 num_types, only : rp
36 use utils, only : neko_error
37 use math, only : neko_eps
39 use registry, only : neko_registry
40 use field, only : field_t
41 use operators, only : grad
42 use coefs, only : coef_t
43 use gs_ops, only : gs_op_add
44 use device_math, only : device_col2
46 implicit none
47 private
48
50
51contains
52
67 subroutine deardorff_compute_device(t, tstep, coef, &
68 temperature_field_name, TKE_field_name, &
69 nut, temperature_alphat, &
70 TKE_alphat, TKE_source, &
71 delta, c_k, T0, g)
72 real(kind=rp), intent(in) :: t
73 integer, intent(in) :: tstep
74 type(coef_t), intent(in) :: coef
75 character(len=*), intent(in) :: temperature_field_name
76 character(len=*), intent(in) :: tke_field_name
77 type(field_t), intent(inout) :: nut, temperature_alphat
78 type(field_t), intent(inout) :: tke_alphat, tke_source
79 type(field_t), intent(in) :: delta
80 real(kind=rp), intent(in) :: c_k, t0, g(3)
81
82 type(field_t), pointer :: tke, temperature
83 type(field_t), pointer :: dtdx, dtdy, dtdz
84 type(field_t), pointer :: u, v, w
85 type(field_t), pointer :: a11, a12, a13, a21, a22, a23, a31, a32, a33
86 integer :: temp_indices(12)
87
88 tke => neko_registry%get_field_by_name(tke_field_name)
89 temperature => neko_registry%get_field_by_name(temperature_field_name)
90
91 u => neko_registry%get_field_by_name("u")
92 v => neko_registry%get_field_by_name("v")
93 w => neko_registry%get_field_by_name("w")
94
95 call neko_scratch_registry%request_field(dtdx, temp_indices(1), .false.)
96 call neko_scratch_registry%request_field(dtdy, temp_indices(2), .false.)
97 call neko_scratch_registry%request_field(dtdz, temp_indices(3), .false.)
98
99 ! Calculate vertical temperature gradients
100 call grad(dtdx%x, dtdy%x, dtdz%x, temperature%x, coef)
101
102 call coef%gs_h%op(dtdx, gs_op_add)
103 call coef%gs_h%op(dtdy, gs_op_add)
104 call coef%gs_h%op(dtdz, gs_op_add)
105 call device_col2(dtdx%x_d, coef%mult_d, nut%dof%size())
106 call device_col2(dtdy%x_d, coef%mult_d, nut%dof%size())
107 call device_col2(dtdz%x_d, coef%mult_d, nut%dof%size())
108
109 ! Compute velocity gradients
110 call neko_scratch_registry%request_field(a11, temp_indices(4), .false.)
111 call neko_scratch_registry%request_field(a12, temp_indices(5), .false.)
112 call neko_scratch_registry%request_field(a13, temp_indices(6), .false.)
113 call neko_scratch_registry%request_field(a21, temp_indices(7), .false.)
114 call neko_scratch_registry%request_field(a22, temp_indices(8), .false.)
115 call neko_scratch_registry%request_field(a23, temp_indices(9), .false.)
116 call neko_scratch_registry%request_field(a31, temp_indices(10), .false.)
117 call neko_scratch_registry%request_field(a32, temp_indices(11), .false.)
118 call neko_scratch_registry%request_field(a33, temp_indices(12), .false.)
119
120 call grad(a11%x, a12%x, a13%x, u%x, coef)
121 call grad(a21%x, a22%x, a23%x, v%x, coef)
122 call grad(a31%x, a32%x, a33%x, w%x, coef)
123
124 call coef%gs_h%op(a11, gs_op_add)
125 call coef%gs_h%op(a12, gs_op_add)
126 call coef%gs_h%op(a13, gs_op_add)
127 call coef%gs_h%op(a21, gs_op_add)
128 call coef%gs_h%op(a22, gs_op_add)
129 call coef%gs_h%op(a23, gs_op_add)
130 call coef%gs_h%op(a31, gs_op_add)
131 call coef%gs_h%op(a32, gs_op_add)
132 call coef%gs_h%op(a33, gs_op_add)
133
134 call device_col2(a11%x_d, coef%mult_d, nut%dof%size())
135 call device_col2(a12%x_d, coef%mult_d, nut%dof%size())
136 call device_col2(a13%x_d, coef%mult_d, nut%dof%size())
137 call device_col2(a21%x_d, coef%mult_d, nut%dof%size())
138 call device_col2(a22%x_d, coef%mult_d, nut%dof%size())
139 call device_col2(a23%x_d, coef%mult_d, nut%dof%size())
140 call device_col2(a31%x_d, coef%mult_d, nut%dof%size())
141 call device_col2(a32%x_d, coef%mult_d, nut%dof%size())
142 call device_col2(a33%x_d, coef%mult_d, nut%dof%size())
143
144 call device_deardorff_nut_compute(tke%x_d, &
145 dtdx%x_d, dtdy%x_d, dtdz%x_d, &
146 a11%x_d, a12%x_d, a13%x_d, &
147 a21%x_d, a22%x_d, a23%x_d, &
148 a31%x_d, a32%x_d, a33%x_d, &
149 delta%x_d, nut%x_d, temperature_alphat%x_d, &
150 tke_alphat%x_d, tke_source%x_d, &
151 c_k, t0, g, neko_eps, a11%dof%size())
152
153 call neko_scratch_registry%relinquish_field(temp_indices)
154 end subroutine deardorff_compute_device
155
156end module deardorff_device
157
Coefficients.
Definition coef.f90:34
Implements the device kernel for the deardorff_t type.
subroutine, public deardorff_compute_device(t, tstep, coef, temperature_field_name, tke_field_name, nut, temperature_alphat, tke_alphat, tke_source, delta, c_k, t0, g)
Compute eddy viscosity on the device.
Device kernel wrapper for computing Deardorff SGS quantities.
subroutine, public device_deardorff_nut_compute(tke_d, dtdx_d, dtdy_d, dtdz_d, a11_d, a12_d, a13_d, a21_d, a22_d, a23_d, a31_d, a32_d, a33_d, delta_d, nut_d, temperature_alphat, tke_alphat, tke_source, c_k, t0, g, eps, n)
Compute Deardorff SGS quantities on the device backend.
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
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:69
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Operators.
Definition operators.f90:34
subroutine, public grad(ux, uy, uz, u, coef)
Compute the gradient of a scalar field.
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:144
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.
Utilities.
Definition utils.f90:35
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:58