Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
scalar_scheme_fctry.f90
Go to the documentation of this file.
1! Copyright (c) 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!
34submodule(scalar_scheme) scalar_scheme_fctry
35 use scalar_pnpn, only : scalar_pnpn_t
37 implicit none
38
39 ! List of all possible types created by the factory routine
40 character(len=20) :: SCALAR_KNOWN_TYPES(1) = [character(len=20) :: &
41 "pnpn"]
42
43contains
44
57 module subroutine scalar_scheme_factory(object, msh, coef, gs, params, &
58 numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
59 class(scalar_scheme_t), allocatable, intent(inout) :: object
60 type(mesh_t), target, intent(in) :: msh
61 type(coef_t), target, intent(in) :: coef
62 type(gs_t), target, intent(inout) :: gs
63 type(json_file), target, intent(inout) :: params
64 type(json_file), target, intent(inout) :: numerics_params
65 type(user_t), target, intent(in) :: user
66 type(chkp_t), target, intent(inout) :: chkp
67 type(field_series_t), target, intent(in) :: ulag, vlag, wlag
68 type(time_scheme_controller_t), target, intent(in) :: time_scheme
69 type(field_t), target, intent(in) :: rho
70 character(len=:), allocatable :: type_name
71
72 call json_get_or_default(params, "scheme", type_name, "pnpn")
73
74 call scalar_scheme_allocator(object, type_name)
75
76 call object%init(msh, coef, gs, params, numerics_params, user, chkp, &
77 ulag, vlag, wlag, time_scheme, rho)
78
79 end subroutine scalar_scheme_factory
80
84 module subroutine scalar_scheme_allocator(object, type_name)
85 class(scalar_scheme_t), allocatable, intent(inout) :: object
86 character(len=*), intent(in):: type_name
87 integer :: i
88
89 if (allocated(object)) then
90 call object%free()
91 deallocate(object)
92 end if
93
94 select case (trim(type_name))
95 case ("pnpn")
96 allocate(scalar_pnpn_t::object)
97 case default
98 do i = 1, scalar_scheme_registry_size
99 if (trim(type_name) == &
100 trim(scalar_scheme_registry(i)%type_name)) then
101 call scalar_scheme_registry(i)%allocator(object)
102 return
103 end if
104 end do
105 call neko_type_error("scalar scheme", trim(type_name), &
106 scalar_known_types)
107 end select
108
109 end subroutine scalar_scheme_allocator
110
116 module subroutine register_scalar_scheme(type_name, allocator)
117 character(len=*), intent(in) :: type_name
118 procedure(scalar_scheme_allocate), pointer, intent(in) :: allocator
119 type(scalar_scheme_allocator_entry), allocatable :: temp(:)
120 integer :: i
121
122 do i = 1, size(scalar_known_types)
123 if (trim(type_name) .eq. trim(scalar_known_types(i))) then
124 call neko_type_registration_error("scalar scheme", type_name, &
125 .true.)
126 end if
127 end do
128
129 do i = 1, scalar_scheme_registry_size
130 if (trim(type_name) .eq. &
131 trim(scalar_scheme_registry(i)%type_name)) then
132 call neko_type_registration_error("scalar scheme", type_name, &
133 .false.)
134 end if
135 end do
136
137 ! Expand registry
138 if (scalar_scheme_registry_size == 0) then
139 allocate(scalar_scheme_registry(1))
140 else
141 allocate(temp(scalar_scheme_registry_size + 1))
142 temp(1:scalar_scheme_registry_size) = scalar_scheme_registry
143 call move_alloc(temp, scalar_scheme_registry)
144 end if
145
146 scalar_scheme_registry_size = scalar_scheme_registry_size + 1
147 scalar_scheme_registry(scalar_scheme_registry_size)%type_name = type_name
148 scalar_scheme_registry(scalar_scheme_registry_size)%allocator => allocator
149 end subroutine register_scalar_scheme
150
151end submodule scalar_scheme_fctry
Contains the scalar_pnpn_t type.
Contains the scalar_scheme_t type.
Base class for time integration schemes.
Utilities.
Definition utils.f90:35
subroutine, public neko_type_registration_error(base_type, wrong_type, known)
Definition utils.f90:328
subroutine, public neko_type_error(base_type, wrong_type, known_types)
Reports an error allocating a type for a particular base pointer class.
Definition utils.f90:313