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 !> Derived type to manage an information of a mesh dimension
32 type, public :: meshdiminfo
33 character(len=H_SHORT) :: name !< Name of the dimension
34 character(len=H_MID) :: desc !< Description of the dimension
35 character(len=H_SHORT) :: unit !< Unit of the dimension
36 logical :: positive_down !< Flag whether the positive direction is downward (e.g., for vertical dimension)
37 end type meshdiminfo
38
39 !> Base type to manage a computational mesh
40 type, abstract, public :: meshbase
41 integer :: local_mesh_num !< Number of local meshes in each MPI process
42 integer :: prc_num !< Number of MPI processes
43 integer :: local_mesh_num_global !< Total number of local meshes across all MPI processes
44
45 integer, allocatable :: tileid_globalmap(:,:)
46 integer, allocatable :: tilefaceid_globalmap(:,:)
47 integer, allocatable :: tilepanelid_globalmap(:,:)
48 integer, allocatable :: tileid_global2localmap(:)
49 integer, allocatable :: prcrank_globalmap(:)
50
51 class(elementbase), pointer :: refelem !< Pointer to an object with a reference element
52 type(meshdiminfo), allocatable :: diminfo(:) !< Array of information for each dimension
53
54 real(rp) :: dom_vol !< Total volume of the computational domain
55
56 logical :: isgenerated !< Flag whether the mesh is generated
57 contains
58 procedure(meshbase_get_localmesh), deferred :: getlocalmesh
59 procedure :: setdiminfo => meshbase_setdiminfo
60 end type meshbase
61
62 interface
63 subroutine meshbase_get_localmesh( this, id, ptr_lcmesh )
64 import meshbase
65 import localmeshbase
66 class(meshbase), target, intent(in) :: this
67 integer, intent(in) :: id
68 class(localmeshbase), pointer, intent(out) :: ptr_lcmesh
69 end subroutine meshbase_get_localmesh
70 end interface
71
72 public :: meshbase_init
73 public :: meshbase_final
75
76 !-----------------------------------------------------------------------------
77 !
78 !++ Public parameters & variables
79 !
80
81 !-----------------------------------------------------------------------------
82 !
83 !++ Private procedure
84 !
85
86 !-----------------------------------------------------------------------------
87 !
88 !++ Private parameters & variables
89 !
90
91contains
92 !> Initialize an object to manage a computational mesh
93!OCL SERIAL
94 subroutine meshbase_init( this, &
95 ndimtype, refElem, NLocalMeshPerPrc, NsideTile, &
96 nprocs )
97
98 use scale_prc, only: &
99 prc_nprocs
100 implicit none
101
102 class(meshbase), intent(inout) :: this
103 integer, intent(in) :: ndimtype !< Number of DIMTYPE
104 class(elementbase), intent(in), target :: refelem !< An object with a reference element
105 integer, intent(in) :: nlocalmeshperprc !< Number of local meshes in each MPI process
106 integer, intent(in) :: nsidetile !< Number of side tiles
107 integer, intent(in), optional :: nprocs !< MPI processes (if not provided, it will be set to the value from PRC_nprocs)
108
109 integer :: n
110 !-----------------------------------------------------------------------------
111
112 if ( present(nprocs) ) then
113 this%PRC_NUM = nprocs
114 else
115 this%PRC_NUM = prc_nprocs
116 end if
117
118 this%LOCAL_MESH_NUM = nlocalmeshperprc
119 this%LOCAL_MESH_NUM_global = this%PRC_NUM * this%LOCAL_MESH_NUM
120
121 this%refElem => refelem
122
123 allocate( this%tileID_globalMap(nsidetile, this%LOCAL_MESH_NUM_global) )
124 allocate( this%tileFaceID_globalMap(nsidetile, this%LOCAL_MESH_NUM_global) )
125 allocate( this%tilePanelID_globalMap(nsidetile, this%LOCAL_MESH_NUM_global) )
126 allocate( this%tileID_global2localMap(this%LOCAL_MESH_NUM_global) )
127 allocate( this%PRCRank_globalMap(this%LOCAL_MESH_NUM_global) )
128 allocate( this%dimInfo(ndimtype) )
129 !$acc enter data create(this%tileID_globalMap, this%tileFaceID_globalMap, this%tilePanelID_globalMap, &
130 !$acc this%tileID_global2localMap, this%PRCRank_globalMap, this%dimInfo )
131
132 this%isGenerated = .false.
133
134 return
135 end subroutine meshbase_init
136
137 !> Finalize an object to manage a computational mesh
138!OCL SERIAL
139 subroutine meshbase_final( this )
140 implicit none
141 class(meshbase), intent(inout) :: this
142 !-----------------------------------------------------------------------------
143
144 if ( allocated(this%tileID_globalMap) ) then
145 !$acc exit data delete(this%tileID_globalMap, this%tileFaceID_globalMap, this%tilePanelID_globalMap, &
146 !$acc this%tileID_global2localMap, this%PRCRank_globalMap, this%dimInfo)
147 deallocate( this%tileID_globalMap )
148 deallocate( this%tileFaceID_globalMap )
149 deallocate( this%tilePanelID_globalMap )
150 deallocate( this%tileID_global2localMap )
151 deallocate( this%PRCRank_globalMap )
152 deallocate( this%dimInfo )
153 end if
154 return
155 end subroutine meshbase_final
156
157!OCL SERIAL
158 subroutine meshbase_setgeometricinfo( mesh, ndim )
161 implicit none
162
163 class(localmeshbase), intent(inout) :: mesh
164 integer, intent(in) :: ndim
165
166 class(elementbase), pointer :: refelem
167 !-----------------------------------------------------------------------------
168
169 refelem => mesh%refElem
170
171 allocate( mesh%pos_en(refelem%Np,mesh%Ne,ndim) )
172 !allocate( mesh%fx(refElem%Nfaces*refElem%Nfp,mesh%Ne) )
173 !allocate( mesh%fy(refElem%Nfaces*refElem%Nfp,mesh%Ne) )
174 allocate( mesh%normal_fn(refelem%NfpTot,mesh%Ne,ndim) )
175 allocate( mesh%sJ(refelem%NfpTot,mesh%Ne) )
176 allocate( mesh%J(refelem%Np,mesh%Ne) )
177 allocate( mesh%Fscale(refelem%NfpTot,mesh%Ne) )
178 allocate( mesh%Escale(refelem%Np,mesh%Ne,ndim,ndim) )
179 allocate( mesh%Gsqrt(refelem%Np,mesh%NeA) )
180 !$acc enter data create(mesh%pos_en, mesh%normal_fn, mesh%sJ, mesh%J, &
181 !$acc mesh%Fscale, mesh%Escale, mesh%Gsqrt)
182
183 return
184 end subroutine meshbase_setgeometricinfo
185
186!OCL SERIAL
187 subroutine meshbase_setdiminfo( this, &
188 dimID, name, unit, desc, positive_down )
189 implicit none
190 class(meshbase), intent(inout) :: this
191 integer, intent(in) :: dimid
192 character(len=*), intent(in) :: name
193 character(len=*), intent(in) :: unit
194 character(len=*), intent(in) :: desc
195 logical, intent(in), optional :: positive_down
196
197 !-----------------------------------------------
198
199 this%dimInfo(dimid)%name = name
200 this%dimInfo(dimid)%unit = unit
201 this%dimInfo(dimid)%desc = desc
202 if ( present(positive_down) ) then
203 this%dimInfo(dimid)%positive_down = positive_down
204 else
205 this%dimInfo(dimid)%positive_down = .false.
206 end if
207
208 return
209 end subroutine meshbase_setdiminfo
210
211end module scale_mesh_base
module FElib / Element / Base
module FElib / Mesh / Local 3D
module FElib / Mesh / Local, Base
module FElib / Mesh / Base
subroutine, public meshbase_final(this)
Finalize an object to manage a computational mesh.
subroutine, public meshbase_setgeometricinfo(mesh, ndim)
subroutine, public meshbase_init(this, ndimtype, refelem, nlocalmeshperprc, nsidetile, nprocs)
Initialize an object to manage a computational mesh.
Derived type representing a 3D reference element.
Derived type representing an arbitrary finite element.
Derived type to manage a local 3D computational domain.
Derived type to manage a local computational domain (base type)
Base type to manage a computational mesh.
Derived type to manage an information of a mesh dimension.