Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
coriolis_source_term_device.f90
Go to the documentation of this file.
1! Copyright (c) 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 num_types, only : rp
36 use field_list, only : field_list_t
37 use field, only : field_t
40 implicit none
41 private
42
44
45contains
46
54 subroutine coriolis_source_term_compute_device(u, v, w, fields, omega, u_geo)
55 type(field_t), intent(in) :: u, v, w
56 type(field_list_t), intent(inout) :: fields
57 real(kind=rp), intent(in) :: omega(3)
58 real(kind=rp), intent(in) :: u_geo(3)
59 integer :: n
60 type(field_t), pointer :: fu, fv, fw
61 real(kind=rp) :: ui, vi, wi
62 integer :: tmp_index(6)
63 type(field_t), pointer :: tmp_u, tmp_v, tmp_w
64 type(field_t), pointer :: tmp_fu, tmp_fv, tmp_fw
65
66 call neko_scratch_registry%request_field(tmp_u, tmp_index(1))
67 call neko_scratch_registry%request_field(tmp_v, tmp_index(2))
68 call neko_scratch_registry%request_field(tmp_w, tmp_index(3))
69 call neko_scratch_registry%request_field(tmp_fu, tmp_index(4))
70 call neko_scratch_registry%request_field(tmp_fv, tmp_index(5))
71 call neko_scratch_registry%request_field(tmp_fw, tmp_index(6))
72
73 ! The RHS components
74 fu => fields%get_by_index(1)
75 fv => fields%get_by_index(2)
76 fw => fields%get_by_index(3)
77
78 n = fu%size()
79
80 ! Copy over velocity arrays for manipulation
81 call device_copy(tmp_u%x_d, u%x_d, n)
82 call device_copy(tmp_v%x_d, v%x_d, n)
83 call device_copy(tmp_w%x_d, w%x_d, n)
84
85 ! velocity minus u_geo
86 call device_cadd(tmp_u%x_d, -u_geo(1), n)
87 call device_cadd(tmp_v%x_d, -u_geo(2), n)
88 call device_cadd(tmp_w%x_d, -u_geo(3), n)
89
90 ! The Coriolis term to be added to the RHS
91 call device_add3s2(tmp_fu%x_d, tmp_w%x_d, tmp_v%x_d, -2.0_rp * omega(2), &
92 2.0_rp * omega(3), n)
93 call device_add3s2(tmp_fv%x_d, tmp_u%x_d, tmp_w%x_d, -2.0_rp * omega(3), &
94 2.0_rp * omega(1), n)
95 call device_add3s2(tmp_fw%x_d, tmp_v%x_d, tmp_u%x_d, -2.0_rp * omega(1), &
96 2.0_rp * omega(2), n)
97
98 ! Add the Coriolis term to the RHS
99 call device_add2(fu%x_d, tmp_fu%x_d, n)
100 call device_add2(fv%x_d, tmp_fv%x_d, n)
101 call device_add2(fw%x_d, tmp_fw%x_d, n)
102
103 call neko_scratch_registry%relinquish_field(tmp_index)
104
106
Implements the device kernel for the coriolis_source_term_t type.
subroutine, public coriolis_source_term_compute_device(u, v, w, fields, omega, u_geo)
Computes the Coriolis source term on the device.
subroutine, public device_add2(a_d, b_d, n, strm)
Vector addition .
subroutine, public device_add3s2(a_d, b_d, c_d, c1, c2, n, strm)
Returns .
subroutine, public device_copy(a_d, b_d, n, strm)
Copy a vector .
Defines a field.
Definition field.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines a registry for storing and requesting temporary fields This can be used when you have a funct...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
field_list_t, To be able to group fields together