Neko  0.8.1
A portable framework for high-order spectral element flow simulations
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
37  use json_utils, only: json_get
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 
63 contains
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 
77  call json_get(json, "x_bounds", values)
78  xmin = values(1)
79  xmax = values(2)
80  call json_get(json, "y_bounds", values)
81  ymin = values(1)
82  ymax = values(2)
83  call json_get(json, "z_bounds", values)
84  zmin = values(1)
85  zmax = values(2)
86  call json_get(json, "name", str_read)
87 
88  call box_point_zone_init_common(this, size, trim(str_read), xmin, &
89  xmax, ymin, ymax, zmin, zmax)
90 
91  end subroutine box_point_zone_init_from_json
92 
102  subroutine box_point_zone_init_common(this, size, name, xmin, xmax, ymin, ymax, &
103  zmin, zmax)
104  class(box_point_zone_t), intent(inout) :: this
105  integer, intent(in), optional :: size
106  character(len=*), intent(in) :: name
107  real(kind=rp), intent(in) :: xmin
108  real(kind=rp), intent(in) :: xmax
109  real(kind=rp), intent(in) :: ymin
110  real(kind=rp), intent(in) :: ymax
111  real(kind=rp), intent(in) :: zmin
112  real(kind=rp), intent(in) :: zmax
113 
114  call this%init_base(size, name)
115 
116  this%xmin = xmin
117  this%xmax = xmax
118  this%ymin = ymin
119  this%ymax = ymax
120  this%zmin = zmin
121  this%zmax = zmax
122 
123  end subroutine box_point_zone_init_common
124 
126  subroutine box_point_zone_free(this)
127  class(box_point_zone_t), intent(inout) :: this
128 
129  this%xmin = 0.0_rp
130  this%xmax = 0.0_rp
131  this%ymin = 0.0_rp
132  this%ymax = 0.0_rp
133  this%zmin = 0.0_rp
134  this%zmax = 0.0_rp
135 
136  call this%free_base()
137 
138  end subroutine box_point_zone_free
139 
155  pure function box_point_zone_criterion(this, x, y, z, j, k, l, e) result(is_inside)
156  class(box_point_zone_t), intent(in) :: this
157  real(kind=rp), intent(in) :: x
158  real(kind=rp), intent(in) :: y
159  real(kind=rp), intent(in) :: z
160  integer, intent(in) :: j
161  integer, intent(in) :: k
162  integer, intent(in) :: l
163  integer, intent(in) :: e
164  logical :: is_inside
165  logical :: in_x, in_y, in_z
166 
167  ! inside x if xmin <= x <= xmax
168  in_x = ( (x .gt. this%xmin .and. x .lt. this%xmax) .or. &
169  (abscmp(x, this%xmin) .or. abscmp(x, this%xmax)))
170 
171  ! inside y if ymin <= y <= ymax
172  in_y = ( (y .gt. this%ymin .and. y .lt. this%ymax) .or. &
173  (abscmp(y, this%ymin) .or. abscmp(y, this%ymax)))
174 
175  ! inside z if zmin <= z <= zmax
176  in_z = ( (z .gt. this%zmin .and. z .lt. this%zmax) .or. &
177  (abscmp(z, this%zmin) .or. abscmp(z, this%zmax)))
178 
179  is_inside = in_x .and. in_y .and. in_z
180  end function box_point_zone_criterion
181 
182 end module box_point_zone
Retrieves a parameter by name or throws an error.
Definition: json_utils.f90:44
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, 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: json_utils.f90:34
Definition: math.f90:60
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
A box-shaped point zone.
Base abstract type for point zones.
Definition: point_zone.f90:47