Neko  0.8.1
A portable framework for high-order spectral element flow simulations
inflow.f90
Go to the documentation of this file.
1 ! Copyright (c) 2020-2021, 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 !
34 module inflow
35  use device_inflow
36  use num_types
37  use dirichlet, only : dirichlet_t
38  use, intrinsic :: iso_c_binding, only : c_ptr, c_loc
39  implicit none
40  private
41 
43  type, public, extends(dirichlet_t) :: inflow_t
44  real(kind=rp), dimension(3) :: x = (/0d0, 0d0, 0d0 /)
45  contains
46  procedure, pass(this) :: apply_scalar => inflow_apply_scalar
47  procedure, pass(this) :: apply_vector => inflow_apply_vector
48  procedure, pass(this) :: apply_scalar_dev => inflow_apply_scalar_dev
49  procedure, pass(this) :: apply_vector_dev => inflow_apply_vector_dev
50  procedure, pass(this) :: set_inflow => inflow_set_vector
51  end type inflow_t
52 
53 contains
54 
56  subroutine inflow_apply_scalar(this, x, n, t, tstep)
57  class(inflow_t), intent(inout) :: this
58  integer, intent(in) :: n
59  real(kind=rp), intent(inout), dimension(n) :: x
60  real(kind=rp), intent(in), optional :: t
61  integer, intent(in), optional :: tstep
62  end subroutine inflow_apply_scalar
63 
65  subroutine inflow_apply_scalar_dev(this, x_d, t, tstep)
66  class(inflow_t), intent(inout), target :: this
67  type(c_ptr) :: x_d
68  real(kind=rp), intent(in), optional :: t
69  integer, intent(in), optional :: tstep
70  end subroutine inflow_apply_scalar_dev
71 
73  subroutine inflow_apply_vector(this, x, y, z, n, t, tstep)
74  class(inflow_t), intent(inout) :: this
75  integer, intent(in) :: n
76  real(kind=rp), intent(inout), dimension(n) :: x
77  real(kind=rp), intent(inout), dimension(n) :: y
78  real(kind=rp), intent(inout), dimension(n) :: z
79  real(kind=rp), intent(in), optional :: t
80  integer, intent(in), optional :: tstep
81  integer :: i, m, k
82 
83  m = this%msk(0)
84  do i = 1, m
85  k = this%msk(i)
86  x(k) = this%x(1)
87  y(k) = this%x(2)
88  z(k) = this%x(3)
89  end do
90  end subroutine inflow_apply_vector
91 
93  subroutine inflow_apply_vector_dev(this, x_d, y_d, z_d, t, tstep)
94  class(inflow_t), intent(inout), target :: this
95  type(c_ptr) :: x_d
96  type(c_ptr) :: y_d
97  type(c_ptr) :: z_d
98  real(kind=rp), intent(in), optional :: t
99  integer, intent(in), optional :: tstep
100 
101  call device_inflow_apply_vector(this%msk_d, x_d, y_d, z_d, &
102  c_loc(this%x), this%msk(0))
103 
104  end subroutine inflow_apply_vector_dev
105 
107  subroutine inflow_set_vector(this, x)
108  class(inflow_t), intent(inout) :: this
109  real(kind=rp), dimension(3), intent(inout) :: x
110  this%x = x
111  end subroutine inflow_set_vector
112 
113 
114 end module inflow
subroutine, public device_inflow_apply_vector(msk, x, y, z, g, m)
Defines a dirichlet boundary condition.
Definition: dirichlet.f90:34
Defines inflow dirichlet conditions.
Definition: inflow.f90:34
subroutine inflow_set_vector(this, x)
Set inflow vector.
Definition: inflow.f90:108
subroutine inflow_apply_scalar(this, x, n, t, tstep)
No-op scalar apply.
Definition: inflow.f90:57
subroutine inflow_apply_vector_dev(this, x_d, y_d, z_d, t, tstep)
Apply inflow conditions (vector valued) (device version)
Definition: inflow.f90:94
subroutine inflow_apply_vector(this, x, y, z, n, t, tstep)
Apply inflow conditions (vector valued)
Definition: inflow.f90:74
subroutine inflow_apply_scalar_dev(this, x_d, t, tstep)
No-op scalar apply (device version)
Definition: inflow.f90:66
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Generic Dirichlet boundary condition on .
Definition: dirichlet.f90:44
Dirichlet condition for inlet (vector valued)
Definition: inflow.f90:43