Neko 1.99.5
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
box_point_zone.f90
Go to the documentation of this file.
1! Copyright (c) 2019-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!
33! Implements a box geometry subset.
35 use point_zone, only: point_zone_t
36 use num_types, only: rp
38 use json_module, only: json_file
39 use math, only: abscmp
40 implicit none
41 private
42
47 type, public, extends(point_zone_t) :: box_point_zone_t
48 real(kind=rp) :: xmin
49 real(kind=rp) :: xmax
50 real(kind=rp) :: ymin
51 real(kind=rp) :: ymax
52 real(kind=rp) :: zmin
53 real(kind=rp) :: zmax
54 contains
56 procedure, pass(this) :: init => box_point_zone_init_from_json
58 procedure, pass(this) :: free => box_point_zone_free
60 procedure, pass(this) :: criterion => box_point_zone_criterion
61 end type box_point_zone_t
62
63contains
64
68 subroutine box_point_zone_init_from_json(this, json, size)
69 class(box_point_zone_t), intent(inout) :: this
70 type(json_file), intent(inout) :: json
71 integer, intent(in) :: size
72
73 character(len=:), allocatable :: str_read
74 real(kind=rp), allocatable :: values(:)
75 real(kind=rp) :: xmin, xmax, ymin, ymax, zmin, zmax
76 logical :: invert
77 logical :: full_elements
78
79 call json_get_or_lookup(json, "x_bounds", values)
80 xmin = values(1)
81 xmax = values(2)
82 call json_get_or_lookup(json, "y_bounds", values)
83 ymin = values(1)
84 ymax = values(2)
85 call json_get_or_lookup(json, "z_bounds", values)
86 zmin = values(1)
87 zmax = values(2)
88 call json_get(json, "name", str_read)
89
90 call json_get(json, "name", str_read)
91 call json_get_or_default(json, "invert", invert, .false.)
92 call json_get_or_default(json, "full_elements", full_elements, .false.)
93
94 call box_point_zone_init_common(this, size, trim(str_read), invert, &
95 full_elements, &
96 xmin, xmax, ymin, ymax, zmin, zmax)
97
99
111 subroutine box_point_zone_init_common(this, size, name, invert, &
112 full_elements, xmin, xmax, ymin, ymax, zmin, zmax)
113 class(box_point_zone_t), intent(inout) :: this
114 integer, intent(in), optional :: size
115 character(len=*), intent(in) :: name
116 logical, intent(in) :: invert
117 logical, intent(in) :: full_elements
118 real(kind=rp), intent(in) :: xmin
119 real(kind=rp), intent(in) :: xmax
120 real(kind=rp), intent(in) :: ymin
121 real(kind=rp), intent(in) :: ymax
122 real(kind=rp), intent(in) :: zmin
123 real(kind=rp), intent(in) :: zmax
124
125 call this%init_base(size, name, invert, full_elements)
126
127 this%xmin = xmin
128 this%xmax = xmax
129 this%ymin = ymin
130 this%ymax = ymax
131 this%zmin = zmin
132 this%zmax = zmax
133
134 end subroutine box_point_zone_init_common
135
137 subroutine box_point_zone_free(this)
138 class(box_point_zone_t), intent(inout) :: this
139
140 this%xmin = 0.0_rp
141 this%xmax = 0.0_rp
142 this%ymin = 0.0_rp
143 this%ymax = 0.0_rp
144 this%zmin = 0.0_rp
145 this%zmax = 0.0_rp
146
147 call this%free_base()
148
149 end subroutine box_point_zone_free
150
166 pure function box_point_zone_criterion(this, x, y, z, j, k, l, e) &
167 result(is_inside)
168 class(box_point_zone_t), intent(in) :: this
169 real(kind=rp), intent(in) :: x
170 real(kind=rp), intent(in) :: y
171 real(kind=rp), intent(in) :: z
172 integer, intent(in) :: j
173 integer, intent(in) :: k
174 integer, intent(in) :: l
175 integer, intent(in) :: e
176 logical :: is_inside
177 logical :: in_x, in_y, in_z
178
179 ! inside x if xmin <= x <= xmax
180 in_x = ( (x .gt. this%xmin .and. x .lt. this%xmax) .or. &
181 (abscmp(x, this%xmin) .or. abscmp(x, this%xmax)))
182
183 ! inside y if ymin <= y <= ymax
184 in_y = ( (y .gt. this%ymin .and. y .lt. this%ymax) .or. &
185 (abscmp(y, this%ymin) .or. abscmp(y, this%ymax)))
186
187 ! inside z if zmin <= z <= zmax
188 in_z = ( (z .gt. this%zmin .and. z .lt. this%zmax) .or. &
189 (abscmp(z, this%zmin) .or. abscmp(z, this%zmax)))
190
191 is_inside = in_x .and. in_y .and. in_z
192 end function box_point_zone_criterion
193
194end module box_point_zone
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
subroutine box_point_zone_init_from_json(this, json, size)
Constructor from json object file.
pure logical function box_point_zone_criterion(this, x, y, z, j, k, l, e)
Defines the criterion of selection of a GLL point in the box point zone. In the case of a box point z...
subroutine box_point_zone_init_common(this, size, name, invert, full_elements, xmin, xmax, ymin, ymax, zmin, zmax)
Initializes a box point zone from its coordinates.
subroutine box_point_zone_free(this)
Destructor.
Utilities for retrieving parameters from the case files.
Definition math.f90:60
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Base abstract type for point zones.