Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
sponge_source_term_device.f90
Go to the documentation of this file.
1! Copyright (c) 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 field_list, only : field_list_t
37 use field, only : field_t
40 use, intrinsic :: iso_c_binding
41 implicit none
42 private
43
45
46contains
47
59 subroutine sponge_source_term_compute_device(fields, u, v, w, &
60 u_bf, v_bf, w_bf, fringe, a_x, a_y, a_z)
61 type(field_list_t), intent(inout) :: fields
62 type(field_t), intent(in) :: u, v, w, fringe, u_bf, v_bf, w_bf
63 real(kind=rp), intent(in) :: a_x, a_y, a_z
64 integer :: n
65 type(field_t), pointer :: fu, fv, fw
66 integer :: tmp_index
67 type(c_ptr) :: wk
68 ! The RHS components
69 fu => fields%get_by_index(1)
70 fv => fields%get_by_index(2)
71 fw => fields%get_by_index(3)
72
73 n = fu%size()
74 call neko_scratch_registry%request(wk, tmp_index, n, .false.)
75
76 ! wk = u_bf - u
77 call device_sub3(wk, u_bf%x_d, u%x_d, n)
78 ! wk = fringe * wk = fringe * (u_bf - u)
79 call device_col2(wk, fringe%x_d, n)
80 ! fu = fu + a_x*wk = fu + a_x*fringe*(u_bf - u)
81 call device_add2s2(fu%x_d, wk, a_x, n)
82
83 call device_sub3(wk, v_bf%x_d, v%x_d, n)
84 call device_col2(wk, fringe%x_d, n)
85 call device_add2s2(fv%x_d, wk, a_y, n)
86
87 call device_sub3(wk, w_bf%x_d, w%x_d, n)
88 call device_col2(wk, fringe%x_d, n)
89 call device_add2s2(fw%x_d, wk, a_z, n)
90
91 call neko_scratch_registry%relinquish(tmp_index)
92
94
subroutine, public device_sub3(a_d, b_d, c_d, n, strm)
Vector subtraction .
subroutine, public device_add2s2(a_d, b_d, c1, n, strm)
Vector addition with scalar multiplication (multiplication on first argument)
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
Defines a field.
Definition field.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
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 sponge_source_term_t type.
subroutine, public sponge_source_term_compute_device(fields, u, v, w, u_bf, v_bf, w_bf, fringe, a_x, a_y, a_z)
Computes the sponge source term on the device.
field_list_t, To be able to group fields together