Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_fctry.f90
Go to the documentation of this file.
1! Copyright (c) 2021-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!
33submodule(ax_product) ax_helm_fctry
38 use ax_helm_sx, only : ax_helm_sx_t
39 use ax_helm, only : ax_helm_t
40 use ax_helm_cpu, only : ax_helm_cpu_t
50 implicit none
51
52 ! List of all possible types created by the allocator routine
53 character(len=20) :: AX_HELM_KNOWN_TYPES(4) = [character(len=20) :: &
54 "standard", &
55 "full", &
56 "standard_svv", &
57 "full_svv"]
58
59contains
60
65 module subroutine ax_helm_allocator(object, type_name)
66 class(ax_t), allocatable, intent(inout) :: object
67 character(len=*), intent(in) :: type_name
68 integer :: i
69
70 if (allocated(object)) then
71 call object%free()
72 deallocate(object)
73 end if
74
75 select case (trim(type_name))
76 case ("standard")
77 if (neko_bcknd_sx .eq. 1) then
78 allocate(ax_helm_sx_t::object)
79 else if (neko_bcknd_xsmm .eq. 1) then
80 allocate(ax_helm_xsmm_t::object)
81 else if (neko_bcknd_device .eq. 1) then
82 allocate(ax_helm_device_t::object)
83 else
84 allocate(ax_helm_cpu_t::object)
85 end if
86 case ("full")
87 if (neko_bcknd_xsmm .eq. 1) then
88 call neko_error("Full stress formulation is only available " // &
89 "on the CPU and device")
90 else if (neko_bcknd_device .eq. 1) then
91 allocate(ax_helm_full_device_t::object)
92 else
93 allocate(ax_helm_full_cpu_t::object)
94 end if
95 case ("standard_svv")
96 if (neko_bcknd_sx .eq. 1 .or. neko_bcknd_xsmm .eq. 1) then
97 call neko_error("SVV is not available with the SX or " // &
98 "XSMM backend")
99 else if (neko_bcknd_device .eq. 1) then
100 if (neko_bcknd_cuda .ne. 1 .and. neko_bcknd_hip .ne. 1) then
101 call neko_error("SVV is only available on CPU, " // &
102 "CUDA, and HIP backends")
103 end if
104 allocate(ax_helm_svv_one_sided_device_t::object)
105 else
106 allocate(ax_helm_svv_one_sided_cpu_t::object)
107 end if
108 case ("full_svv")
109 if (neko_bcknd_sx .eq. 1 .or. neko_bcknd_xsmm .eq. 1) then
110 call neko_error("Full stress formulation is only available &
111 &on the CPU and device")
112 else if (neko_bcknd_device .eq. 1) then
113 if (neko_bcknd_cuda .ne. 1 .and. neko_bcknd_hip .ne. 1) then
114 call neko_error("Full-stress SVV is only " // &
115 "available on CPU, CUDA, and HIP backends")
116 end if
118 else
119 allocate(ax_helm_svv_one_sided_full_cpu_t::object)
120 end if
121 case default
122 do i = 1, ax_helm_registry_size
123 if (trim(type_name) .eq. &
124 trim(ax_helm_registry(i)%type_name)) then
125 call ax_helm_registry(i)%allocator(object)
126 return
127 end if
128 end do
129
130 call neko_type_error("matrix-vector product", type_name, &
131 ax_helm_known_types)
132 end select
133
134 end subroutine ax_helm_allocator
135
141 module subroutine register_ax_helm(type_name, allocator)
142 character(len=*), intent(in) :: type_name
143 procedure(ax_helm_allocate), pointer, intent(in) :: allocator
144 type(ax_helm_allocator_entry), allocatable :: temp(:)
145 integer :: i
146
147 do i = 1, size(ax_helm_known_types)
148 if (trim(type_name) .eq. trim(ax_helm_known_types(i))) then
149 call neko_type_registration_error("matrix-vector product", &
150 type_name, .true.)
151 end if
152 end do
153
154 do i = 1, ax_helm_registry_size
155 if (trim(type_name) .eq. trim(ax_helm_registry(i)%type_name)) then
156 call neko_type_registration_error("matrix-vector product", &
157 type_name, .false.)
158 end if
159 end do
160
161 if (ax_helm_registry_size .eq. 0) then
162 allocate(ax_helm_registry(1))
163 else
164 allocate(temp(ax_helm_registry_size + 1))
165 temp(1:ax_helm_registry_size) = ax_helm_registry
166 call move_alloc(temp, ax_helm_registry)
167 end if
168
169 ax_helm_registry_size = ax_helm_registry_size + 1
170 ax_helm_registry(ax_helm_registry_size)%type_name = type_name
171 ax_helm_registry(ax_helm_registry_size)%allocator => allocator
172 end subroutine register_ax_helm
173
174end submodule ax_helm_fctry
CPU implementation of the one-sided SVV Helmholtz operator.
CPU implementation of the full-stress one-sided SVV Helmholtz operator.
Device implementation of the full-stress one-sided SVV operator.
Defines a Matrix-vector product.
Definition ax.f90:34
Build configurations.
integer, parameter neko_bcknd_sx
integer, parameter neko_bcknd_hip
integer, parameter neko_bcknd_device
integer, parameter neko_bcknd_cuda
integer, parameter neko_bcknd_xsmm
Data and filter construction for spectral vanishing viscosity.
Utilities.
Definition utils.f90:35
subroutine, public neko_type_registration_error(base_type, wrong_type, known)
Definition utils.f90:393
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:376
Matrix-vector product for a Helmholtz problem.
Definition ax_helm.f90:44
CPU matrix-vector product for a Helmholtz problem.
CPU matrix-vector product for a Helmholtz problem with full stress tensor.
Device matrix-vector product for an SVV Helmholtz problem.
Spectral vanishing viscosity configuration and coefficients.