Neko 1.99.3
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
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 time_state, only : time_state_t
43 implicit none
44 private
45
47 type, public, extends(bc_t) :: inflow_t
48 real(kind=rp), dimension(3) :: x = [0d0, 0d0, 0d0]
49 contains
50 procedure, pass(this) :: apply_scalar => inflow_apply_scalar
51 procedure, pass(this) :: apply_vector => inflow_apply_vector
52 procedure, pass(this) :: apply_scalar_dev => inflow_apply_scalar_dev
53 procedure, pass(this) :: apply_vector_dev => inflow_apply_vector_dev
55 procedure, pass(this) :: init => inflow_init
57 procedure, pass(this) :: free => inflow_free
59 procedure, pass(this) :: finalize => inflow_finalize
60 end type inflow_t
61
62contains
63
67 subroutine inflow_init(this, coef, json)
68 class(inflow_t), intent(inout), target :: this
69 type(coef_t), target, intent(in) :: coef
70 type(json_file), intent(inout) ::json
71 real(kind=rp), allocatable :: x(:)
72
73 call this%init_base(coef)
74 call json_get_or_lookup(json, 'value', x)
75 this%x = x
76 end subroutine inflow_init
77
79 subroutine inflow_apply_scalar(this, x, n, time, strong)
80 class(inflow_t), intent(inout) :: this
81 integer, intent(in) :: n
82 real(kind=rp), intent(inout), dimension(n) :: x
83 type(time_state_t), intent(in), optional :: time
84 logical, intent(in), optional :: strong
85 end subroutine inflow_apply_scalar
86
88 subroutine inflow_apply_scalar_dev(this, x_d, time, strong, strm)
89 class(inflow_t), intent(inout), target :: this
90 type(c_ptr), intent(inout) :: x_d
91 type(time_state_t), intent(in), optional :: time
92 logical, intent(in), optional :: strong
93 type(c_ptr), intent(inout) :: strm
94 end subroutine inflow_apply_scalar_dev
95
97 subroutine inflow_apply_vector(this, x, y, z, n, time, strong)
98 class(inflow_t), intent(inout) :: this
99 integer, intent(in) :: n
100 real(kind=rp), intent(inout), dimension(n) :: x
101 real(kind=rp), intent(inout), dimension(n) :: y
102 real(kind=rp), intent(inout), dimension(n) :: z
103 type(time_state_t), intent(in), optional :: time
104 logical, intent(in), optional :: strong
105 integer :: i, m, k
106 logical :: strong_
107
108 if (present(strong)) then
109 strong_ = strong
110 else
111 strong_ = .true.
112 end if
113
114 m = this%msk(0)
115
116 if (strong_) then
117 !$omp do
118 do i = 1, m
119 k = this%msk(i)
120 x(k) = this%x(1)
121 y(k) = this%x(2)
122 z(k) = this%x(3)
123 end do
124 !$omp end do
125 end if
126 end subroutine inflow_apply_vector
127
129 subroutine inflow_apply_vector_dev(this, x_d, y_d, z_d, &
130 time, strong, strm)
131 class(inflow_t), intent(inout), target :: this
132 type(c_ptr), intent(inout) :: x_d
133 type(c_ptr), intent(inout) :: y_d
134 type(c_ptr), intent(inout) :: z_d
135 type(time_state_t), intent(in), optional :: time
136 logical, intent(in), optional :: strong
137 type(c_ptr), intent(inout) :: strm
138 logical :: strong_
139
140 if (present(strong)) then
141 strong_ = strong
142 else
143 strong_ = .true.
144 end if
145
146 if (strong_ .and. (this%msk(0) .gt. 0)) then
147 call device_inflow_apply_vector(this%msk_d, x_d, y_d, z_d, &
148 c_loc(this%x), this%msk(0), strm)
149 end if
150
151 end subroutine inflow_apply_vector_dev
152
154 subroutine inflow_free(this)
155 class(inflow_t), target, intent(inout) :: this
156
157 call this%free_base()
158 end subroutine inflow_free
159
161 subroutine inflow_finalize(this, only_facets)
162 class(inflow_t), target, intent(inout) :: this
163 logical, optional, intent(in) :: only_facets
164 logical :: only_facets_
165
166 integer :: i
167
168 if (present(only_facets)) then
169 only_facets_ = only_facets
170 else
171 only_facets_ = .false.
172 end if
173
174 call this%finalize_base(only_facets_)
175 end subroutine inflow_finalize
176
177
178end module inflow
Defines a boundary condition.
Definition bc.f90:34
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:89
subroutine inflow_apply_scalar(this, x, n, time, strong)
No-op scalar apply.
Definition inflow.f90:80
subroutine inflow_finalize(this, only_facets)
Finalize.
Definition inflow.f90:162
subroutine inflow_init(this, coef, json)
Constructor.
Definition inflow.f90:68
subroutine inflow_apply_vector(this, x, y, z, n, time, strong)
Apply inflow conditions (vector valued)
Definition inflow.f90:98
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:131
subroutine inflow_free(this)
Destructor.
Definition inflow.f90:155
Utilities for retrieving parameters from the case files.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Module with things related to the simulation time.
Base type for a boundary condition.
Definition bc.f90:62
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:63
Dirichlet condition for inlet (vector valued)
Definition inflow.f90:47
A struct that contains all info about the time, expand as needed.