Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
inflow.f90
Go to the documentation of this file.
1! Copyright (c) 2020-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!
34module inflow
36 use num_types, only : rp
37 use bc, only : bc_t, bc_dirichlet
38 use, intrinsic :: iso_c_binding, only : c_ptr, c_loc
39 use coefs, only : coef_t
40 use json_module, only : json_file
42 use utils, only : neko_error
43 use time_state, only : time_state_t
44 implicit none
45 private
46
48 type, public, extends(bc_t) :: inflow_t
49 real(kind=rp), dimension(3) :: x = [0d0, 0d0, 0d0]
50 contains
51 procedure, pass(this) :: apply_scalar => inflow_apply_scalar
52 procedure, pass(this) :: apply_vector => inflow_apply_vector
53 procedure, pass(this) :: apply_scalar_dev => inflow_apply_scalar_dev
54 procedure, pass(this) :: apply_vector_dev => inflow_apply_vector_dev
56 procedure, pass(this) :: init => inflow_init
58 procedure, pass(this) :: init_from_components => &
61 procedure, pass(this) :: free => inflow_free
63 procedure, pass(this) :: finalize => inflow_finalize
64 end type inflow_t
65
66contains
67
71 subroutine inflow_init(this, coef, json)
72 class(inflow_t), intent(inout), target :: this
73 type(coef_t), target, intent(in) :: coef
74 type(json_file), intent(inout) ::json
75 real(kind=rp), allocatable :: x(:)
76
77 call json_get_or_lookup(json, 'value', x)
78 if (size(x) .ne. 3) then
79 call neko_error("The inflow boundary condition requires a " // &
80 "3-component value vector.")
81 end if
82 call this%init_from_components(coef, x)
83 end subroutine inflow_init
84
88 subroutine inflow_init_from_components(this, coef, x)
89 class(inflow_t), intent(inout), target :: this
90 type(coef_t), target, intent(in) :: coef
91 real(kind=rp), intent(in) :: x(3)
92
93 call this%init_base(coef)
94 this%bc_type = bc_dirichlet
95 this%x = x
96 end subroutine inflow_init_from_components
97
99 subroutine inflow_apply_scalar(this, x, n, time, strong)
100 class(inflow_t), intent(inout) :: this
101 integer, intent(in) :: n
102 real(kind=rp), intent(inout), dimension(n) :: x
103 type(time_state_t), intent(in), optional :: time
104 logical, intent(in), optional :: strong
105 end subroutine inflow_apply_scalar
106
108 subroutine inflow_apply_scalar_dev(this, x_d, time, strong, strm)
109 class(inflow_t), intent(inout), target :: this
110 type(c_ptr), intent(inout) :: x_d
111 type(time_state_t), intent(in), optional :: time
112 logical, intent(in), optional :: strong
113 type(c_ptr), intent(inout) :: strm
114 end subroutine inflow_apply_scalar_dev
115
117 subroutine inflow_apply_vector(this, x, y, z, n, time, strong)
118 class(inflow_t), intent(inout) :: this
119 integer, intent(in) :: n
120 real(kind=rp), intent(inout), dimension(n) :: x
121 real(kind=rp), intent(inout), dimension(n) :: y
122 real(kind=rp), intent(inout), dimension(n) :: z
123 type(time_state_t), intent(in), optional :: time
124 logical, intent(in), optional :: strong
125 integer :: i, m, k
126 logical :: strong_
127
128 if (present(strong)) then
129 strong_ = strong
130 else
131 strong_ = .true.
132 end if
133
134 m = this%msk(0)
135
136 if (strong_) then
137 !$omp do
138 do i = 1, m
139 k = this%msk(i)
140 x(k) = this%x(1)
141 y(k) = this%x(2)
142 z(k) = this%x(3)
143 end do
144 !$omp end do
145 end if
146 end subroutine inflow_apply_vector
147
149 subroutine inflow_apply_vector_dev(this, x_d, y_d, z_d, &
150 time, strong, strm)
151 class(inflow_t), intent(inout), target :: this
152 type(c_ptr), intent(inout) :: x_d
153 type(c_ptr), intent(inout) :: y_d
154 type(c_ptr), intent(inout) :: z_d
155 type(time_state_t), intent(in), optional :: time
156 logical, intent(in), optional :: strong
157 type(c_ptr), intent(inout) :: strm
158 logical :: strong_
159
160 if (present(strong)) then
161 strong_ = strong
162 else
163 strong_ = .true.
164 end if
165
166 if (strong_ .and. (this%msk(0) .gt. 0)) then
167 call device_inflow_apply_vector(this%msk_d, x_d, y_d, z_d, &
168 c_loc(this%x), this%msk(0), strm)
169 end if
170
171 end subroutine inflow_apply_vector_dev
172
174 subroutine inflow_free(this)
175 class(inflow_t), target, intent(inout) :: this
176
177 call this%free_base()
178 end subroutine inflow_free
179
181 subroutine inflow_finalize(this)
182 class(inflow_t), target, intent(inout) :: this
183 integer :: i
184
185 call this%finalize_base()
186 end subroutine inflow_finalize
187
188
189end module inflow
Defines a boundary condition.
Definition bc.f90:34
integer, parameter, public bc_dirichlet
Supported boundary condition types. The values are set in order of precedence for global resolution....
Definition bc.f90:66
Coefficients.
Definition coef.f90:34
subroutine, public device_inflow_apply_vector(msk, x, y, z, g, m, strm)
Defines inflow dirichlet conditions.
Definition inflow.f90:34
subroutine inflow_apply_scalar_dev(this, x_d, time, strong, strm)
No-op scalar apply (device version)
Definition inflow.f90:109
subroutine inflow_apply_scalar(this, x, n, time, strong)
No-op scalar apply.
Definition inflow.f90:100
subroutine inflow_finalize(this)
Finalize.
Definition inflow.f90:182
subroutine inflow_init(this, coef, json)
Constructor.
Definition inflow.f90:72
subroutine inflow_apply_vector(this, x, y, z, n, time, strong)
Apply inflow conditions (vector valued)
Definition inflow.f90:118
subroutine inflow_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
Apply inflow conditions (vector valued) (device version)
Definition inflow.f90:151
subroutine inflow_free(this)
Destructor.
Definition inflow.f90:175
subroutine inflow_init_from_components(this, coef, x)
Constructor from components.
Definition inflow.f90:89
Utilities for retrieving parameters from the case files.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Module with things related to the simulation time.
Utilities.
Definition utils.f90:35
Base type for a boundary condition.
Definition bc.f90:72
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:93
Dirichlet condition for inlet (vector valued)
Definition inflow.f90:48
A struct that contains all info about the time, expand as needed.