Neko 0.9.99
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
78 call json_get(json, "x_bounds", values)
79 xmin = values(1)
80 xmax = values(2)
81 call json_get(json, "y_bounds", values)
82 ymin = values(1)
83 ymax = values(2)
84 call json_get(json, "z_bounds", values)
85 zmin = values(1)
86 zmax = values(2)
87 call json_get(json, "name", str_read)
88
89 call json_get(json, "name", str_read)
90 call json_get_or_default(json, "invert", invert, .false.)
91
92 call box_point_zone_init_common(this, size, trim(str_read), invert, &
93 xmin, xmax, ymin, ymax, zmin, zmax)
94
96
106 subroutine box_point_zone_init_common(this, size, name, invert, xmin, xmax, &
107 ymin, ymax, zmin, zmax)
108 class(box_point_zone_t), intent(inout) :: this
109 integer, intent(in), optional :: size
110 character(len=*), intent(in) :: name
111 logical, intent(in) :: invert
112 real(kind=rp), intent(in) :: xmin
113 real(kind=rp), intent(in) :: xmax
114 real(kind=rp), intent(in) :: ymin
115 real(kind=rp), intent(in) :: ymax
116 real(kind=rp), intent(in) :: zmin
117 real(kind=rp), intent(in) :: zmax
118
119 call this%init_base(size, name, invert)
120
121 this%xmin = xmin
122 this%xmax = xmax
123 this%ymin = ymin
124 this%ymax = ymax
125 this%zmin = zmin
126 this%zmax = zmax
127
128 end subroutine box_point_zone_init_common
129
131 subroutine box_point_zone_free(this)
132 class(box_point_zone_t), intent(inout) :: this
133
134 this%xmin = 0.0_rp
135 this%xmax = 0.0_rp
136 this%ymin = 0.0_rp
137 this%ymax = 0.0_rp
138 this%zmin = 0.0_rp
139 this%zmax = 0.0_rp
140
141 call this%free_base()
142
143 end subroutine box_point_zone_free
144
160 pure function box_point_zone_criterion(this, x, y, z, j, k, l, e) &
161 result(is_inside)
162 class(box_point_zone_t), intent(in) :: this
163 real(kind=rp), intent(in) :: x
164 real(kind=rp), intent(in) :: y
165 real(kind=rp), intent(in) :: z
166 integer, intent(in) :: j
167 integer, intent(in) :: k
168 integer, intent(in) :: l
169 integer, intent(in) :: e
170 logical :: is_inside
171 logical :: in_x, in_y, in_z
172
173 ! inside x if xmin <= x <= xmax
174 in_x = ( (x .gt. this%xmin .and. x .lt. this%xmax) .or. &
175 (abscmp(x, this%xmin) .or. abscmp(x, this%xmax)))
176
177 ! inside y if ymin <= y <= ymax
178 in_y = ( (y .gt. this%ymin .and. y .lt. this%ymax) .or. &
179 (abscmp(y, this%ymin) .or. abscmp(y, this%ymax)))
180
181 ! inside z if zmin <= z <= zmax
182 in_z = ( (z .gt. this%zmin .and. z .lt. this%zmax) .or. &
183 (abscmp(z, this%zmin) .or. abscmp(z, this%zmax)))
184
185 is_inside = in_x .and. in_y .and. in_z
186 end function box_point_zone_criterion
187
188end 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_common(this, size, name, invert, xmin, xmax, ymin, ymax, zmin, zmax)
Initializes a box point zone from its coordinates.
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_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.