Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
no_slip.f90
Go to the documentation of this file.
1! Copyright (c) 2020-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!
34module no_slip
35 use num_types, only : rp
36 use coefs, only : coef_t
37 use field, only : field_t
39 use json_module, only : json_file
41 use time_state, only : time_state_t
42 use math, only : masked_copy_0
44 use utils, only : neko_error
45 use registry, only : neko_registry
46 use, intrinsic :: iso_c_binding, only : c_ptr
47 implicit none
48 private
49
50 type, public, extends(zero_dirichlet_t) :: no_slip_t
51 ! mesh velocity fields.
52 type(field_t), pointer :: wx => null()
53 type(field_t), pointer :: wy => null()
54 type(field_t), pointer :: wz => null()
55 logical :: is_moving = .false.
56 contains
57 procedure, pass(this) :: init => no_slip_init
58 procedure, pass(this) :: apply_vector => no_slip_apply_vector
59 procedure, pass(this) :: apply_vector_dev => no_slip_apply_vector_dev
60 procedure, pass(this) :: free => no_slip_free
61 end type no_slip_t
62
63contains
64
65 subroutine no_slip_init(this, coef, json)
66 class(no_slip_t), intent(inout), target :: this
67 type(coef_t), intent(in), target :: coef
68 type(json_file), intent(inout) :: json
69
70 ! Normal init (zero_dirichlet)
71 call this%zero_dirichlet_t%init(coef, json)
72 call json_get_or_default(json, "moving", this%is_moving, .false.)
73
74 ! If wm_x exists, wm_y and wm_z also exist!
75 if (neko_registry%field_exists('wm_x')) then
76 this%wx => neko_registry%get_field('wm_x')
77 this%wy => neko_registry%get_field('wm_y')
78 this%wz => neko_registry%get_field('wm_z')
79 end if
80
81 ! If moving is requested, mesh velocitiy fileds should be linked already
82 ! in ale_manager.
83 if (this%is_moving) then
84 if (.not. associated(this%wx) .or. .not. associated(this%wy) .or. &
85 .not. associated(this%wz)) then
86 call neko_error("Velocity BC 'no_slip' with moving: true is &
87 &found, but ALE is not activated in case file.")
88 end if
89 end if
90 end subroutine no_slip_init
91
92
93 subroutine no_slip_apply_vector(this, x, y, z, n, time, strong)
94 class(no_slip_t), intent(inout) :: this
95 integer, intent(in) :: n
96 real(kind=rp), intent(inout), dimension(n) :: x, y, z
97 type(time_state_t), intent(in), optional :: time
98 logical, intent(in), optional :: strong
99 logical :: strong_
100
101 strong_ = .true.
102 if (present(strong)) strong_ = strong
103 if (.not. strong_) return
104
105 if (this%is_moving) then
106 ! moving wall: u_wall = w_mesh
107 call masked_copy_0(x, this%wx%x, this%msk, n, this%msk(0))
108 call masked_copy_0(y, this%wy%x, this%msk, n, this%msk(0))
109 call masked_copy_0(z, this%wz%x, this%msk, n, this%msk(0))
110 else
111 call this%zero_dirichlet_t%apply_vector(x, y, z, n, time, strong_)
112 end if
113 end subroutine no_slip_apply_vector
114
115
116 subroutine no_slip_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
117 class(no_slip_t), intent(inout), target :: this
118 type(c_ptr), intent(inout) :: x_d, y_d, z_d
119 type(time_state_t), intent(in), optional :: time
120 logical, intent(in), optional :: strong
121 type(c_ptr), intent(inout) :: strm
122 logical :: strong_
123
124 strong_ = .true.
125 if (present(strong)) strong_ = strong
126 if (.not. strong_) return
127
128 if (this%is_moving) then
129 call device_masked_copy_0(x_d, this%wx%x_d, this%msk_d, &
130 this%wx%dof%size(), this%msk(0), strm)
131 call device_masked_copy_0(y_d, this%wy%x_d, this%msk_d, &
132 this%wy%dof%size(), this%msk(0), strm)
133 call device_masked_copy_0(z_d, this%wz%x_d, this%msk_d, &
134 this%wz%dof%size(), this%msk(0), strm)
135 else
136 call this%zero_dirichlet_t%apply_vector_dev(x_d, y_d, z_d, time, &
137 strong_, strm)
138 end if
139 end subroutine no_slip_apply_vector_dev
140
141
142 subroutine no_slip_free(this)
143 class(no_slip_t), intent(inout), target :: this
144
145 call this%zero_dirichlet_t%free()
146 nullify(this%wx)
147 nullify(this%wy)
148 nullify(this%wz)
149 end subroutine no_slip_free
150
151end module no_slip
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Coefficients.
Definition coef.f90:34
subroutine, public device_masked_copy_0(a_d, b_d, mask_d, n, n_mask, strm)
Copy a masked vector .
Defines a field.
Definition field.f90:34
Utilities for retrieving parameters from the case files.
Definition math.f90:60
subroutine, public masked_copy_0(a, b, mask, n, n_mask)
Copy a masked vector .
Definition math.f90:269
Defines no-slip boundary condition (extends zero_dirichlet)
Definition no_slip.f90:34
subroutine no_slip_free(this)
Definition no_slip.f90:143
subroutine no_slip_apply_vector(this, x, y, z, n, time, strong)
Definition no_slip.f90:94
subroutine no_slip_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
Definition no_slip.f90:117
subroutine no_slip_init(this, coef, json)
Definition no_slip.f90:66
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:144
Module with things related to the simulation time.
Utilities.
Definition utils.f90:35
Defines a zero-valued Dirichlet boundary condition.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:62
A struct that contains all info about the time, expand as needed.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...