Neko  0.9.99
A portable framework for high-order spectral element flow simulations
point_zone_fctry.f90
Go to the documentation of this file.
1 ! Copyright (c) 2023-2024, 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 !
35 submodule(point_zone) point_zone_fctry
39  use json_utils, only: json_get
40  use utils, only : concat_string_array
41  implicit none
42 
43  ! List of all possible types created by the factory routine
44  character(len=20) :: POINTZ_KNOWN_TYPES(3) = [character(len=20) :: &
45  "box", &
46  "sphere", &
47  "cylinder"]
48 
49 contains
50 
56  module subroutine point_zone_factory(object, json, dof)
57  class(point_zone_t), allocatable, intent(inout) :: object
58  type(json_file), intent(inout) :: json
59  type(dofmap_t), intent(inout), optional :: dof
60  character(len=:), allocatable :: type_name
61  character(len=:), allocatable :: type_string
62 
63  call json_get(json, "geometry", type_name)
64 
65  if (trim(type_name) .eq. "box") then
66  allocate(box_point_zone_t::object)
67  else if (trim(type_name) .eq. "sphere") then
68  allocate(sphere_point_zone_t::object)
69  else if (trim(type_name) .eq. "cylinder") then
70  allocate(cylinder_point_zone_t::object)
71  else
72  type_string = concat_string_array(pointz_known_types, &
73  new_line('A') // "- ", .true.)
74  call neko_error("Unknown point zone type: " &
75  // trim(type_name) // ". Known types are: " &
76  // type_string)
77  end if
78 
79  if (present(dof)) then
80  call object%init(json, dof%size())
81  call object%map(dof)
82  call object%finalize()
83  else
84  ! This is for initializing zones inside a combine point zone,
85  ! as they don't need to be mapped
86  call object%init(json, 1)
87  call object%finalize()
88  end if
89 
90 
91  end subroutine point_zone_factory
92 
93 end submodule point_zone_fctry
Retrieves a parameter by name or throws an error.
Definition: json_utils.f90:45
Implements a cylinder geometry subset.
Utilities for retrieving parameters from the case files.
Definition: json_utils.f90:34
Utilities.
Definition: utils.f90:35
character(:) function, allocatable, public concat_string_array(array, sep, prepend)
Concatenate an array of strings into one string with array items separated by spaces.
Definition: utils.f90:255
A box-shaped point zone.