Neko 1.99.9
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 call object%register_checkpoint(chkp)
79
80 end subroutine scalar_scheme_factory
81
85 module subroutine scalar_scheme_allocator(object, type_name)
86 class(scalar_scheme_t), allocatable, intent(inout) :: object
87 character(len=*), intent(in):: type_name
88 integer :: i
89
90 if (allocated(object)) then
91 call object%free()
92 deallocate(object)
93 end if
94
95 select case (trim(type_name))
96 case ("pnpn")
97 allocate(scalar_pnpn_t::object)
98 case default
99 do i = 1, scalar_scheme_registry_size
100 if (trim(type_name) == &
101 trim(scalar_scheme_registry(i)%type_name)) then
102 call scalar_scheme_registry(i)%allocator(object)
103 return
104 end if
105 end do
106 call neko_type_error("scalar scheme", trim(type_name), &
107 scalar_known_types)
108 end select
109
110 end subroutine scalar_scheme_allocator
111
117 module subroutine register_scalar_scheme(type_name, allocator)
118 character(len=*), intent(in) :: type_name
119 procedure(scalar_scheme_allocate), pointer, intent(in) :: allocator
120 type(scalar_scheme_allocator_entry), allocatable :: temp(:)
121 integer :: i
122
123 do i = 1, size(scalar_known_types)
124 if (trim(type_name) .eq. trim(scalar_known_types(i))) then
125 call neko_type_registration_error("scalar scheme", type_name, &
126 .true.)
127 end if
128 end do
129
130 do i = 1, scalar_scheme_registry_size
131 if (trim(type_name) .eq. &
132 trim(scalar_scheme_registry(i)%type_name)) then
133 call neko_type_registration_error("scalar scheme", type_name, &
134 .false.)
135 end if
136 end do
137
138 ! Expand registry
139 if (scalar_scheme_registry_size == 0) then
140 allocate(scalar_scheme_registry(1))
141 else
142 allocate(temp(scalar_scheme_registry_size + 1))
143 temp(1:scalar_scheme_registry_size) = scalar_scheme_registry
144 call move_alloc(temp, scalar_scheme_registry)
145 end if
146
147 scalar_scheme_registry_size = scalar_scheme_registry_size + 1
148 scalar_scheme_registry(scalar_scheme_registry_size)%type_name = type_name
149 scalar_scheme_registry(scalar_scheme_registry_size)%allocator => allocator
150 end subroutine register_scalar_scheme
151
152end 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:431
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:413