FE-Project
Loading...
Searching...
No Matches
scale_multigrid_fieldset_base.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Multigrid / Field set base
3!!
4!! @par Description
5!! Manage field sets for multigrid method
6!!
7!! @author Yuta Kawai, Team SCALE
8!<
9!-------------------------------------------------------------------------------
10#include "scaleFElib.h"
12
13 !-----------------------------------------------------------------------------
14 !
15 !++ used modules
16 !
17 !
18 use scale_precision
19 use scale_io
20 use scale_prc, only: prc_abort
21
22 use scale_sparsemat, only: sparsemat
23
26
33
34 use scale_meshfield_base, only: &
41
42 !-----------------------------------------------------------------------------
43 implicit none
44 private
45
46 !-----------------------------------------------------------------------------
47 !
48 !++ Public type & procedure
49 !
50
51 !> Base type for multigrid field set
52 type :: mgfieldbase
53 integer :: var_num !< Number of variables
54 integer :: level_id !< Level ID in multigrid hierarchy
55
56 integer :: aux_var_num_tot !< Total number of auxiliary variables
57
58 class(MeshFieldCommBase), pointer :: var_comm_ptr !< Pointer to communicator for main variables
59 class(MeshFieldCommBase), pointer :: aux_comm_ptr !< Pointer to communicator for auxiliary variables
60 end type mgfieldbase
61
62 !> Derived type for 2D multigrid field set
63 type, extends(mgfieldbase), public :: mgfieldset2d
64 type(meshfield2d) :: dq
65 type(meshfield2d) :: f
66 type(meshfield2d) :: res
67 type(meshfield2d), allocatable :: aux_var(:)
68
69 type(sparsemat) :: dx
70 type(sparsemat) :: dy
71 type(sparsemat) :: lift
72 contains
73 procedure :: init => mgfieldset2d_init
74 procedure :: final => mgfieldset2d_final
75 end type mgfieldset2d
76
77 !> Derived type for 3D multigrid field set
78 type, extends(mgfieldbase), public :: mgfieldset3d
79 type(meshfield3d) :: dq
80 type(meshfield3d) :: f
81 type(meshfield3d) :: res
82 type(meshfield3d), allocatable :: aux_var(:)
83
84 type(sparsemat) :: dx
85 type(sparsemat) :: dy
86 type(sparsemat) :: dz
87 type(sparsemat) :: lift
88 contains
89 procedure :: init => mgfieldset3d_init
90 procedure :: final => mgfieldset3d_final
91 end type mgfieldset3d
92
93contains
94
95!- 2D
96 !> Initialize an object to manage multigrid field set in 2D
97!OCL SERIAL
98 subroutine mgfieldset2d_init(this, mesh2D, aux_scalar_num, aux_vec_num, level_id)
100 implicit none
101 class(mgfieldset2d), intent(inout), target :: this
102 class(meshbase2d), intent(in) :: mesh2D
103 integer, intent(in) :: aux_scalar_num
104 integer, intent(in) :: aux_vec_num
105 integer, intent(in) :: level_id
106
107 integer :: iv
108
109 type(meshfieldcommrectdom2d), pointer :: var_comm2D
110 type(meshfieldcommrectdom2d), pointer :: aux_comm2D
111
112 type(meshfieldcommcubedspheredom2d), pointer :: var_comm2D_cs
113 type(meshfieldcommcubedspheredom2d), pointer :: aux_comm2D_cs
114 !---------------------------------
115
116 this%level_id = level_id
117
118 call this%dq%Init( "dq", "1", mesh2d )
119 call this%f%Init( "f", "1", mesh2d )
120 call this%res%Init( "res", "1", mesh2d )
121
122 this%aux_var_num_tot = aux_scalar_num + 2*aux_vec_num
123 if ( this%aux_var_num_tot > 0 ) then
124 allocate( this%aux_var(this%aux_var_num_tot) )
125 do iv=1, this%aux_var_num_tot
126 call this%aux_var(iv)%Init( "aux_var", "1", mesh2d )
127 end do
128 end if
129
130 select type(mesh2d)
131 type is (meshrectdom2d)
132 allocate(var_comm2d)
133 call var_comm2d%Init( 1, 0, 0, mesh2d )
134 this%var_comm_ptr => var_comm2d
135 type is (meshcubedspheredom2d)
136 allocate(var_comm2d_cs)
137 call var_comm2d_cs%Init( 1, 0, 0, mesh2d )
138 this%var_comm_ptr => var_comm2d_cs
139 end select
140
141 if ( this%aux_var_num_tot > 0 ) then
142 select type(mesh2d)
143 type is (meshrectdom2d)
144 allocate( aux_comm2d )
145 call aux_comm2d%Init( aux_scalar_num, aux_vec_num, 0, mesh2d )
146 this%aux_comm_ptr => aux_comm2d
147 type is (meshcubedspheredom2d)
148 allocate( aux_comm2d_cs )
149 call aux_comm2d_cs%Init( aux_scalar_num, aux_vec_num, 0, mesh2d )
150 this%aux_comm_ptr => aux_comm2d_cs
151 end select
152 end if
153
154 call this%Dx%Init( mesh2d%refElem2D%Dx1, storage_format='ELL')
155 call this%Dy%Init( mesh2d%refElem2D%Dx2, storage_format='ELL')
156 call this%Lift%Init( mesh2d%refElem2D%Lift, storage_format='ELL')
157 return
158 end subroutine mgfieldset2d_init
159
160 !> Finalize an object to manage multigrid field set in 2D
161!OCL SERIAL
162 subroutine mgfieldset2d_final(this)
163 implicit none
164 class(mgfieldset2d), intent(inout) :: this
165
166 integer :: iv
167 class(meshfieldcommbase), pointer :: comm_ptr
168 !---------------------------------
169
170 call this%dq%Final()
171 call this%f%Final()
172 call this%res%Final()
173
174 select type(comm_ptr => this%var_comm_ptr)
175 type is (meshfieldcommrectdom2d)
176 call comm_ptr%Final()
178 call comm_ptr%Final()
179 end select
180 deallocate(this%var_comm_ptr)
181
182 if ( this%aux_var_num_tot > 0 ) then
183
184 select type(comm_ptr => this%aux_comm_ptr)
185 type is (meshfieldcommrectdom2d)
186 call comm_ptr%Final()
188 call comm_ptr%Final()
189 end select
190 deallocate(this%aux_comm_ptr)
191
192 do iv=1, this%aux_var_num_tot
193 call this%aux_var(iv)%Final()
194 end do
195 end if
196
197 call this%Dx%Final()
198 call this%Dy%Final()
199
200 return
201 end subroutine mgfieldset2d_final
202
203!- 3D
204 !> Initialize an object to manage multigrid field set in 3D
205!OCL SERIAL
206 subroutine mgfieldset3d_init(this, mesh3D, aux_scalar_num, aux_hvec_num, level_id)
208 implicit none
209 class(mgfieldset3d), intent(inout), target :: this
210 class(meshbase3d), intent(in) :: mesh3D
211 integer, intent(in) :: aux_scalar_num
212 integer, intent(in) :: aux_hvec_num
213 integer, intent(in) :: level_id
214
215 integer :: iv
216
217 type(meshfieldcommcubedom3d), pointer :: var_comm3D
218 type(meshfieldcommcubedom3d), pointer :: aux_comm3D
219
220 type(meshfieldcommcubedspheredom3d), pointer :: var_comm3D_cs
221 type(meshfieldcommcubedspheredom3d), pointer :: aux_comm3D_cs
222 !---------------------------------
223
224 this%level_id = level_id
225
226 call this%dq%Init( "dq", "1", mesh3d )
227 call this%f%Init( "f", "1", mesh3d )
228 call this%res%Init( "res", "1", mesh3d )
229
230 this%aux_var_num_tot = aux_scalar_num + 2*aux_hvec_num
231 if ( this%aux_var_num_tot > 0 ) then
232 allocate( this%aux_var(this%aux_var_num_tot) )
233 do iv=1, this%aux_var_num_tot
234 call this%aux_var(iv)%Init( "aux_var", "1", mesh3d )
235 end do
236 end if
237
238 select type(mesh3d)
239 type is (meshcubedom3d)
240 allocate(var_comm3d)
241 call var_comm3d%Init( 1, 0, 0, mesh3d )
242 this%var_comm_ptr => var_comm3d
243 type is (meshcubedspheredom3d)
244 allocate(var_comm3d_cs)
245 call var_comm3d_cs%Init( 1, 0, 0, mesh3d )
246 this%var_comm_ptr => var_comm3d_cs
247 end select
248
249 !-
250 if ( this%aux_var_num_tot > 0 ) then
251 select type(mesh3d)
252 type is (meshcubedom3d)
253 allocate( aux_comm3d )
254 call aux_comm3d%Init( aux_scalar_num, aux_hvec_num, 0, mesh3d )
255 this%aux_comm_ptr => aux_comm3d
256 type is (meshcubedspheredom3d)
257 allocate( aux_comm3d_cs )
258 call aux_comm3d_cs%Init( aux_scalar_num, aux_hvec_num, 0, mesh3d )
259 this%aux_comm_ptr => aux_comm3d_cs
260 end select
261 end if
262
263 !-
264 call this%Dx%Init( mesh3d%refElem3D%Dx1, storage_format='ELL')
265 call this%Dy%Init( mesh3d%refElem3D%Dx2, storage_format='ELL')
266 call this%Dz%Init( mesh3d%refElem3D%Dx3, storage_format='ELL')
267 call this%Lift%Init( mesh3d%refElem3D%Lift, storage_format='ELL')
268 return
269 end subroutine mgfieldset3d_init
270
271 !> Finalize an object to manage multigrid field set in 3D
272!OCL SERIAL
273 subroutine mgfieldset3d_final(this)
274 implicit none
275 class(mgfieldset3d), intent(inout) :: this
276
277 integer :: iv
278 class(meshfieldcommbase), pointer :: comm_ptr
279 !---------------------------------
280
281 call this%dq%Final()
282 call this%f%Final()
283 call this%res%Final()
284
285 select type(comm_ptr => this%var_comm_ptr)
286 type is (meshfieldcommcubedom3d)
287 call comm_ptr%Final()
289 call comm_ptr%Final()
290 end select
291 deallocate(this%var_comm_ptr)
292
293 if ( this%aux_var_num_tot > 0 ) then
294
295 select type(comm_ptr => this%aux_comm_ptr)
296 type is (meshfieldcommcubedom3d)
297 call comm_ptr%Final()
299 call comm_ptr%Final()
300 end select
301 deallocate(this%aux_comm_ptr)
302
303 do iv=1, this%aux_var_num_tot
304 call this%aux_var(iv)%Final()
305 end do
306 end if
307
308 call this%Dx%Final()
309 call this%Dy%Final()
310 call this%Dz%Final()
311
312 return
313 end subroutine mgfieldset3d_final
314
module FElib / Element / Base
module FElib / Element / Quadrilateral
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
module FElib / Mesh / Cubic 3D domain
module FElib / Mesh / Cubed-sphere 2D domain
module FElib / Mesh / Cubed-sphere 3D domain
module FElib / Mesh / Rectangle 2D domain
module FElib / Data / base
module FElib / Data / Communication base
module FElib / Data / Communication 3D cubic domain
module FElib / Data / Communication in 2D cubed-sphere domain
module FElib / Data / Communication in 3D cubed-sphere domain
module FElib / Data / Communication 2D rectangle domain
module FElib / Multigrid / Field set base
subroutine mgfieldset2d_init(this, mesh2d, aux_scalar_num, aux_vec_num, level_id)
Initialize an object to manage multigrid field set in 2D.
Module common / sparsemat.
Derived type representing a 2D reference element.
Derived type representing a quadrilateral element.
Derived type to manage a computational mesh (base type for 2D domain)
Derived type to manage a computational mesh (base type for 3D domain)
Derived type to manage a cubic 3D computational domain.
Derived type to manage a cubed-sphere 2D computational domain.
Derived type to manage a cubed-sphere 3D computational domain.
Derived type to manage a rectangular 2D computational domain.
Derived type representing a field with 2D mesh.
Derived type representing a field with 3D mesh.
Base derived type to manage data communication.
Base derived type to manage data communication with 3D cubic domain.
Base derived type to manage data communication with 2D cubed-sphere domain.
Base derived type to manage data communication with 3D cubed-sphere domain.
Base derived type to manage data communication with 2D rectangle domain.
Derived type to manage a sparse matrix.