FE-Project
Loading...
Searching...
No Matches
scale_mesh_hierarchy_base.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Mesh / Hierarchy base
3!!
4!! @par Description
5!! A base module to provide a mesh hierarchy
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
22
23 !-----------------------------------------------------------------------------
24 implicit none
25 private
26
27 !-----------------------------------------------------------------------------
28 !
29 !++ Public type & procedure
30 !
31
32 !> Base type to manage local mesh data for multigrid
34 real(rp), allocatable :: ic2f(:,:,:) !< Matrix for correction operation in h-MG
35 integer, allocatable :: ic2f_emap(:) !< Mapping of elements used for correction operation in h-MG
36 integer, allocatable :: if2c_emap(:,:) !< Mapping of elements used for restriction operation in h-MG
37
38 integer, allocatable :: coarselocalmesh_tileidlist(:)
39 integer, allocatable :: coarselocalmesh_lcdomidlist(:)
43
44 type, public :: meshhierarchylevelbase
45 integer :: hierarchy_type
46 integer :: level_id = 0
48
49 !> Base type for mesh hierarchy
50 type, public :: meshhierarchybase
51 integer :: num_tot_level !< Total number of levels
52 integer :: num_hmg_level !< Number of h-MG levels
53 integer :: num_pmg_level !< Number of p-MG levels
54 contains
55 end type meshhierarchybase
58
60
61 !-----------------------------------------------------------------------------
62 !
63 !++ Public parameters & variables
64 !
65 integer, public, parameter :: mesh_hierarchy_pmg_finest_level = 1 !< Finest level index in p-MG
66 integer, public, parameter :: mesh_hierarchy_hmg_finest_level = 1 !< Finest level index in h-MG
67
68 integer, public, parameter :: mesh_hierarchy_type_pmg = 1 !< Type ID of mesh hierarchy: p-MG
69 integer, public, parameter :: mesh_hierarchy_type_hmg = 2 !< Type ID of mesh hierarchy: h-MG
70
71 !-----------------------------------------------------------------------------
72 !
73 !++ Private procedure
74 !
75
76 !-----------------------------------------------------------------------------
77 !
78 !++ Private parameters & variables
79 !
80contains
81 !> Initialize a base object for mesh hierarchy
82!OCL SERIAL
83 subroutine meshhierarchybase_init( this, &
84 p_LEVEL_NUM, &
85 h_LEVEL_NUM )
86 implicit none
87 class(meshhierarchybase), intent(inout) :: this
88 integer, intent(in) :: p_level_num !< Number of p-mesh levels
89 integer, intent(in) :: h_level_num !< Number of h-mesh levels
90 !-------------------------------------------------------------
91
92 this%NUM_TOT_LEVEL = 0
93 this%NUM_hMG_LEVEL = h_level_num
94 this%NUM_pMG_LEVEL = p_level_num
95
96 this%NUM_TOT_LEVEL = this%NUM_hMG_LEVEL + this%NUM_pMG_LEVEL
97 return
98 end subroutine meshhierarchybase_init
99
100 !> Finalize a base object for mesh hierarchy
101!OCL SERIAL
102 subroutine meshhierarchybase_final(this)
103 implicit none
104 class(meshhierarchybase), intent(inout) :: this
105 !-------------------------------------------------------------
106 return
107 end subroutine meshhierarchybase_final
108
109 !> Construct a 1D p-multigrid matrix used for transfer between different p-levels
110!OCL SERIAL
111 subroutine meshhierarchy_construct_pmg_mat1d( mat1D, np_i, np_o )
112 use scale_polynomial, only: &
117 implicit none
118 integer, intent(in) :: np_i !< Number of points with input DOF
119 integer, intent(in) :: np_o !< Number of points with output DOF
120 real(rp), intent(out) :: mat1d(np_o,np_i) !< Transfer matrix with p-MG
121
122 type(lineelement) :: elem1d_i
123 type(lineelement) :: elem1d_o
124
125 real(rp), allocatable :: lag_i(:,:)
126 real(rp), allocatable :: lag_o(:,:)
127
128 integer :: np_int
129 real(rp), allocatable :: int_w(:)
130 real(rp), allocatable :: int_pts(:)
131
132 integer :: pi, po
133 !---------------------------------------------------------------------
134
135 call elem1d_i%Init( np_i-1, .false. )
136 call elem1d_o%Init( np_o-1, .false. )
137
138 !-
139 np_int = max(np_i,np_o)
140
141 allocate( int_pts(np_int) )
142 int_pts(:) = polynomial_gengausslegendrept(np_int)
143
144 allocate( int_w(np_int) )
146
147 !-
148 allocate( lag_i(np_int,np_i) )
149 lag_i(:,:) = polynomial_genlagrangepoly(elem1d_i%PolyOrder, elem1d_i%x1, int_pts)
150
151 allocate( lag_o(np_int,np_o) )
152 lag_o(:,:) = polynomial_genlagrangepoly(elem1d_o%PolyOrder, elem1d_o%x1, int_pts)
153
154 do pi=1, np_i
155 do po=1, np_o
156 mat1d(po,pi) = sum( int_w(:) * lag_i(:,pi) * lag_o(:,po) )
157 end do
158 end do
159 mat1d(:,:) = matmul( elem1d_o%invM, mat1d )
160
161 !-
162 call elem1d_i%Final()
163 call elem1d_o%Final()
164
165 return
167
168!-
169 !> Initialize a base object to manage local multigrid data for mesh hierarchy
170!OCL SERIAL
172 lcmesh )
173 implicit none
174 class(meshhierarchylocalmgdatabase), intent(inout) :: this
175 class(localmeshbase), intent(in) :: lcmesh
176 !-------------------------------------------------------------
177
178 allocate( this%Ic2f(lcmesh%refElem%Np,lcmesh%refElem%Nv,lcmesh%NeA) )
179 allocate( this%Ic2f_emap(lcmesh%Ne) )
180
181 allocate( this%CoarseLocalMesh_tileIDlist(1) )
182 allocate( this%CoarseLocalMesh_lcdomIDlist(1) )
183 return
185
186 !> Finalize a base object to manage local multigrid data for mesh hierarchy
187!OCL SERIAL
189 implicit none
190 class(meshhierarchylocalmgdatabase), intent(inout) :: this
191 !-------------------------------------------------------------
192 deallocate( this%Ic2f )
193 deallocate( this%Ic2f_emap )
194 deallocate( this%CoarseLocalMesh_tileIDlist )
195 deallocate( this%CoarseLocalMesh_lcdomIDlist )
196 return
module FElib / Element / line
module FElib / Mesh / Local, Base
module FElib / Mesh / Hierarchy base
subroutine, public meshhierarchy_construct_pmg_mat1d(mat1d, np_i, np_o)
Construct a 1D p-multigrid matrix used for transfer between different p-levels.
integer, parameter, public mesh_hierarchy_type_pmg
Type ID of mesh hierarchy: p-MG.
integer, parameter, public mesh_hierarchy_hmg_finest_level
Finest level index in h-MG.
subroutine, public meshhierarchybase_init(this, p_level_num, h_level_num)
Initialize a base object for mesh hierarchy.
integer, parameter, public mesh_hierarchy_type_hmg
Type ID of mesh hierarchy: h-MG.
subroutine, public meshhierarchylocalmgdatabase_final(this)
Finalize a base object to manage local multigrid data for mesh hierarchy.
subroutine, public meshhierarchybase_final(this)
Finalize a base object for mesh hierarchy.
integer, parameter, public mesh_hierarchy_pmg_finest_level
Finest level index in p-MG.
subroutine, public meshhierarchylocalmgdatabase_init(this, lcmesh)
Initialize a base object to manage local multigrid data for mesh hierarchy.
Module common / Polynomial.
real(rp) function, dimension(nord), public polynomial_gengausslegendreptintweight(nord)
A function to calculate the Gauss-Legendre (GL) weights.
real(rp) function, dimension(size(x), nord+1), public polynomial_genlagrangepoly(nord, x_lgl, x)
A function to obtain the Lagrange basis functions related to the Gauss-Legendre-Lobatto (GLL) points.
real(rp) function, dimension(nord), public polynomial_gengausslegendrept(nord)
A function to calculate the Gauss-Legendre (GL) points.
Derived type representing a line element.
Derived type to manage a local computational domain (base type)
Base type to manage local mesh data for multigrid.