FE-Project
Loading...
Searching...
No Matches
scale_mesh_base.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Mesh / Base
3!!
4!! @par Description
5!! Base module to manage meshes for element-based methods
6!!
7!! @author Yuta Kawai, Team SCALE
8!<
9#include "scaleFElib.h"
11
12 !-----------------------------------------------------------------------------
13 !
14 !++ used modules
15 !
16 use scale_precision
17 use scale_io
18
21
22 !-----------------------------------------------------------------------------
23 implicit none
24 private
25
26 !-----------------------------------------------------------------------------
27 !
28 !++ Public type & procedure
29 !
30
31 type, public :: meshdiminfo
32 character(len=H_SHORT) :: name
33 character(len=H_MID) :: desc
34 character(len=H_SHORT) :: unit
35 logical :: positive_down
36 end type meshdiminfo
37
38 type, abstract, public :: meshbase
39 integer :: local_mesh_num
40 integer :: prc_num
41 integer :: local_mesh_num_global
42
43 integer, allocatable :: tileid_globalmap(:,:)
44 integer, allocatable :: tilefaceid_globalmap(:,:)
45 integer, allocatable :: tilepanelid_globalmap(:,:)
46 integer, allocatable :: tileid_global2localmap(:)
47 integer, allocatable :: prcrank_globalmap(:)
48
49 class(elementbase), pointer :: refelem
50 type(meshdiminfo), allocatable :: diminfo(:)
51
52 real(rp) :: dom_vol
53
54 logical :: isgenerated
55 contains
56 procedure(meshbase_get_localmesh), deferred :: getlocalmesh
57 procedure :: setdiminfo => meshbase_setdiminfo
58 end type meshbase
59
60 interface
61 subroutine meshbase_get_localmesh( this, id, ptr_lcmesh )
62 import meshbase
63 import localmeshbase
64 class(meshbase), target, intent(in) :: this
65 integer, intent(in) :: id
66 class(localmeshbase), pointer, intent(out) :: ptr_lcmesh
67 end subroutine meshbase_get_localmesh
68 end interface
69
70 public :: meshbase_init
71 public :: meshbase_final
73
74 !-----------------------------------------------------------------------------
75 !
76 !++ Public parameters & variables
77 !
78
79 !-----------------------------------------------------------------------------
80 !
81 !++ Private procedure
82 !
83
84 !-----------------------------------------------------------------------------
85 !
86 !++ Private parameters & variables
87 !
88
89contains
90!OCL SERIAL
91 subroutine meshbase_init( this, &
92 ndimtype, refElem, NLocalMeshPerPrc, NsideTile, &
93 nprocs )
94
95 use scale_prc, only: &
96 prc_nprocs
97 implicit none
98
99 class(meshbase), intent(inout) :: this
100 integer, intent(in) :: ndimtype
101 class(elementbase), intent(in), target :: refelem
102 integer, intent(in) :: nlocalmeshperprc
103 integer, intent(in) :: nsidetile
104 integer, intent(in), optional :: nprocs
105
106 integer :: n
107 !-----------------------------------------------------------------------------
108
109 if ( present(nprocs) ) then
110 this%PRC_NUM = nprocs
111 else
112 this%PRC_NUM = prc_nprocs
113 end if
114
115 this%LOCAL_MESH_NUM = nlocalmeshperprc
116 this%LOCAL_MESH_NUM_global = this%PRC_NUM * this%LOCAL_MESH_NUM
117
118 this%refElem => refelem
119
120 allocate( this%tileID_globalMap(nsidetile, this%LOCAL_MESH_NUM_global) )
121 allocate( this%tileFaceID_globalMap(nsidetile, this%LOCAL_MESH_NUM_global) )
122 allocate( this%tilePanelID_globalMap(nsidetile, this%LOCAL_MESH_NUM_global) )
123 allocate( this%tileID_global2localMap(this%LOCAL_MESH_NUM_global) )
124 allocate( this%PRCRank_globalMap(this%LOCAL_MESH_NUM_global) )
125 allocate( this%dimInfo(ndimtype) )
126
127 this%isGenerated = .false.
128
129 return
130 end subroutine meshbase_init
131
132!OCL SERIAL
133 subroutine meshbase_final( this )
134 implicit none
135 class(meshbase), intent(inout) :: this
136 !-----------------------------------------------------------------------------
137
138 if ( allocated(this%tileID_globalMap) ) then
139 deallocate( this%tileID_globalMap )
140 deallocate( this%tileFaceID_globalMap )
141 deallocate( this%tilePanelID_globalMap )
142 deallocate( this%tileID_global2localMap )
143 deallocate( this%PRCRank_globalMap )
144 deallocate( this%dimInfo )
145 end if
146
147 return
148 end subroutine meshbase_final
149
150!OCL SERIAL
151 subroutine meshbase_setgeometricinfo( mesh, ndim )
152 implicit none
153
154 class(localmeshbase), intent(inout) :: mesh
155 integer, intent(in) :: ndim
156
157 class(elementbase), pointer :: refelem
158 !-----------------------------------------------------------------------------
159
160 refelem => mesh%refElem
161
162 allocate( mesh%pos_en(refelem%Np,mesh%Ne,ndim) )
163 !allocate( mesh%fx(refElem%Nfaces*refElem%Nfp,mesh%Ne) )
164 !allocate( mesh%fy(refElem%Nfaces*refElem%Nfp,mesh%Ne) )
165 allocate( mesh%normal_fn(refelem%NfpTot,mesh%Ne,ndim) )
166 allocate( mesh%sJ(refelem%NfpTot,mesh%Ne) )
167 allocate( mesh%J(refelem%Np,mesh%Ne) )
168 allocate( mesh%Fscale(refelem%NfpTot,mesh%Ne) )
169 allocate( mesh%Escale(refelem%Np,mesh%Ne,ndim,ndim) )
170 allocate( mesh%Gsqrt(refelem%Np,mesh%Ne) )
171 allocate( mesh%G_ij(refelem%Np,mesh%Ne, ndim,ndim) )
172 allocate( mesh%GIJ (refelem%Np,mesh%Ne, ndim,ndim) )
173
174 return
175 end subroutine meshbase_setgeometricinfo
176
177!OCL SERIAL
178 subroutine meshbase_setdiminfo( this, &
179 dimID, name, unit, desc, positive_down )
180 implicit none
181 class(meshbase), intent(inout) :: this
182 integer, intent(in) :: dimid
183 character(len=*), intent(in) :: name
184 character(len=*), intent(in) :: unit
185 character(len=*), intent(in) :: desc
186 logical, intent(in), optional :: positive_down
187
188 !-----------------------------------------------
189
190 this%dimInfo(dimid)%name = name
191 this%dimInfo(dimid)%unit = unit
192 this%dimInfo(dimid)%desc = desc
193 if ( present(positive_down) ) then
194 this%dimInfo(dimid)%positive_down = positive_down
195 else
196 this%dimInfo(dimid)%positive_down = .false.
197 end if
198
199 return
200 end subroutine meshbase_setdiminfo
201
202end module scale_mesh_base
module FElib / Element / Base
module FElib / Mesh / Local, Base
module FElib / Mesh / Base
subroutine, public meshbase_final(this)
subroutine, public meshbase_setgeometricinfo(mesh, ndim)
subroutine, public meshbase_init(this, ndimtype, refelem, nlocalmeshperprc, nsidetile, nprocs)
Derived type representing an arbitrary finite element.
Derived type to manage a local computational domain (base type)