FE-Project
Loading...
Searching...
No Matches
scale_localmesh_3d.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Mesh / Local 3D
3!!
4!! @par Description
5!! Module to manage 3D local mesh 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_localmesh_base, only: &
21
22 !-----------------------------------------------------------------------------
23 implicit none
24 private
25
26 !-----------------------------------------------------------------------------
27 !
28 !++ Public type & procedure
29 !
30
31 !> Derived type to manage a local 3D computational domain
32 type, extends(localmeshbase), public :: localmesh3d
33
34 type(elementbase3d), pointer :: refelem3d !< Pointer to a object of 3D reference element
35 real(rp) :: xmin !< Minimum x-coordinate value of the local computational domain
36 real(rp) :: xmax !< Maximum x-coordinate value of the local computational domain
37 real(rp) :: ymin !< Minimum y-coordinate value of the local computational domain
38 real(rp) :: ymax !< Maximum y-coordinate value of the local computational domain
39 real(rp) :: zmin !< Minimum z-coordinate value of the local computational domain
40 real(rp) :: zmax !< Maximum z-coordinate value of the local computational domain
41
42 integer :: nex !< Number of finite elements for the x-direction in the local computational domain
43 integer :: ney !< Number of finite elements for the y-direction in the local computational domain
44 integer :: nez !< Number of finite elements for the z-direction in the local computational domain
45 integer :: ne2d !< NeX * NeY
46 integer :: ne2da !< NeX * NeY + halo size
47
48 real(rp), allocatable :: sz(:,:)
49 real(rp), allocatable :: zs(:,:)
50 real(rp), allocatable :: gi3(:,:,:) !< The contravariant component of metric tensor with vertical general coordinate
51 real(rp), allocatable :: gsqrth(:,:) !< The Jacobian of horizontal transformation in the computational coordinate
52 real(rp), allocatable :: zlev(:,:) !< z-coordinates (actual level)
53 real(rp), allocatable :: gam(:,:) !< Factor for approximation with spherical shell domain (= r/a)
54
55 class(localmesh2d), pointer :: lcmesh2d !< Pointer to an object to manage 2D local computational domain
56 real(rp), allocatable :: lon2d(:,:) !< Longitude coordinate with 2D mesh
57 real(rp), allocatable :: lat2d(:,:) !< Latitude coordinate with 2D mesh
58
59 integer, allocatable :: emap3dto2d(:) !< Array to map 3D element ID to 2D element ID
60 contains
61 procedure :: setlocalmesh2d => localmesh3d_setlocalmesh2d
62 procedure :: getvmapz1d => localmesh3d_getvmapz1d
63 procedure :: getvmapz3d => localmesh3d_getvmapz3d
64 end type localmesh3d
65
67
68 !-----------------------------------------------------------------------------
69 !
70 !++ Public parameters & variables
71 !
72
73 !-----------------------------------------------------------------------------
74 !
75 !++ Private procedure
76 !
77
78 !-----------------------------------------------------------------------------
79 !
80 !++ Private parameters & variables
81 !
82
83contains
84!> Initialize an object to manage a 3D local computational domain
85!OCL SERIAL
86 subroutine localmesh3d_init( this, &
87 lcdomID, refElem, myrank )
88 implicit none
89
90 class(localmesh3d), intent(inout) :: this
91 integer, intent(in) :: lcdomid
92 class(elementbase3d), intent(in), target :: refelem
93 integer, intent(in), optional :: myrank
94 !-------------------------------------------------
95
96 this%refElem3D => refelem
97 nullify( this%lcmesh2D )
98
99 call localmeshbase_init( this, lcdomid, refelem, 3, myrank )
100 !$acc enter data copyin(this)
101 return
102 end subroutine localmesh3d_init
103
104!> Finalize an object to manage a 3D local computational domain
105!OCL SERIAL
106 subroutine localmesh3d_final( this, is_generated )
107 implicit none
108 type(localmesh3d), intent(inout) :: this
109 logical, intent(in) :: is_generated
110 !-------------------------------------------------
111
112 call localmeshbase_final( this, is_generated )
113 if (is_generated) then
114 !$acc exit data delete(this%G_ij, this%GIJ)
115 deallocate( this%G_ij, this%GIJ )
116 !$acc exit data delete( this%Sz, this%zS, this%GI3, this%GsqrtH, this%zlev, this%gam, this%lon2D, this%lat2D, this%EMap3Dto2D )
117 deallocate( this%zS, this%Sz )
118 deallocate( this%GI3, this%GsqrtH )
119 deallocate( this%zlev )
120 deallocate( this%gam )
121 deallocate( this%lon2D, this%lat2D )
122 deallocate( this%EMap3Dto2D )
123 end if
124 !$acc exit data delete(this)
125
126 return
127 end subroutine localmesh3d_final
128
129!> Set a pointer to an object to mange 2D local computational domain
130!OCL SERIAL
131 subroutine localmesh3d_setlocalmesh2d( this, lcmesh2D )
132 implicit none
133 class(localmesh3d), intent(inout) :: this
134 class(localmesh2d), intent(in), target :: lcmesh2d
135 !-------------------------------------------------
136
137 this%lcmesh2D => lcmesh2d
138 return
139 end subroutine localmesh3d_setlocalmesh2d
140
141!> Get arrays for vertical mapping node index with vertical element boundary to that with DG data
142!OCL SERIAL
143 subroutine localmesh3d_getvmapz1d( this, vmapM, vmapP )
144
145 implicit none
146 class(localmesh3d), intent(in), target :: this
147 integer, intent(out) :: vmapm(this%refelem3d%nfptot,this%nez)
148 integer, intent(out) :: vmapp(this%refelem3d%nfptot,this%nez)
149
150 integer :: ke_z
151 integer :: f
152 integer :: vs, ve
153
154 class(elementbase3d), pointer :: elem
155 !------------------------------
156
157 elem => this%refElem3D
158
159 do ke_z=1, this%NeZ
160 do f=1, elem%Nfaces_h
161 vs = 1 + (f-1)*elem%Nfp_h
162 ve = vs + elem%Nfp_h - 1
163 vmapm(vs:ve,ke_z) = elem%Fmask_h(:,f) + (ke_z-1)*elem%Np
164 end do
165 do f=1, elem%Nfaces_v
166 vs = elem%Nfp_h*elem%Nfaces_h + 1 + (f-1)*elem%Nfp_v
167 ve = vs + elem%Nfp_v - 1
168 vmapm(vs:ve,ke_z) = elem%Fmask_v(:,f) + (ke_z-1)*elem%Np
169 end do
170 vmapp(:,ke_z) = vmapm(:,ke_z)
171 end do
172
173 do ke_z=1, this%NeZ
174 vs = elem%Nfp_h*elem%Nfaces_h + 1
175 ve = vs + elem%Nfp_v - 1
176 if (ke_z > 1) &
177 vmapp(vs:ve,ke_z) = elem%Fmask_v(:,2) + (ke_z-2)*elem%Np
178
179 vs = elem%Nfp_h*elem%Nfaces_h + elem%Nfp_v + 1
180 ve = vs + elem%Nfp_v - 1
181 if (ke_z < this%NeZ) &
182 vmapp(vs:ve,ke_z) = elem%Fmask_v(:,1) + ke_z*elem%Np
183 end do
184
185 return
186 end subroutine localmesh3d_getvmapz1d
187
188!> Get arrays for vertical mapping node index with vertical element boundary to that with DG data
189!OCL SERIAL
190 subroutine localmesh3d_getvmapz3d( this, vmapM, vmapP )
191
192 implicit none
193 class(localmesh3d), intent(in), target :: this
194 integer, intent(out) :: vmapm(this%refelem3d%nfptot,this%ne)
195 integer, intent(out) :: vmapp(this%refelem3d%nfptot,this%ne)
196
197 integer :: ke, ke_xy, ke_z
198 integer :: ke_neigh
199 integer :: f
200 integer :: vs, ve
201
202 class(elementbase3d), pointer :: elem
203 !------------------------------
204
205 elem => this%refElem3D
206
207 !$omp parallel do collapse(2) private(ke,ke_xy,ke_z,ke_neigh,f,vs,ve)
208 do ke_z=1, this%NeZ
209 do ke_xy=1, this%NeX * this%NeY
210 ke = ke_xy + (ke_z-1) * this%NeX * this%NeY
211
212 do f=1, elem%Nfaces_h
213 vs = 1 + (f-1)*elem%Nfp_h
214 ve = vs + elem%Nfp_h - 1
215 vmapm(vs:ve,ke) = elem%Fmask_h(:,f) + (ke-1)*elem%Np
216 end do
217 do f=1, elem%Nfaces_v
218 vs = elem%Nfp_h*elem%Nfaces_h + 1 + (f-1)*elem%Nfp_v
219 ve = vs + elem%Nfp_v - 1
220 vmapm(vs:ve,ke) = elem%Fmask_v(:,f) + (ke-1)*elem%Np
221 end do
222 vmapp(:,ke) = vmapm(:,ke)
223
224 !--
225 vs = elem%Nfp_h*elem%Nfaces_h + 1
226 ve = vs + elem%Nfp_v - 1
227 if (ke_z > 1) then
228 ke_neigh = ke_xy + (ke_z-2) * this%NeX * this%NeY
229 vmapp(vs:ve,ke) = elem%Fmask_v(:,2) + (ke_neigh-1)*elem%Np
230 end if
231 vs = elem%Nfp_h*elem%Nfaces_h + elem%Nfp_v + 1
232 ve = vs + elem%Nfp_v - 1
233 if (ke_z < this%NeZ) then
234 ke_neigh = ke_xy + ke_z * this%NeX * this%NeY
235 vmapp(vs:ve,ke) = elem%Fmask_v(:,1) + (ke_neigh-1)*elem%Np
236 end if
237 end do
238 end do
239
240 return
241 end subroutine localmesh3d_getvmapz3d
242
243end module scale_localmesh_3d
module FElib / Element / Base
module FElib / Mesh / Local 2D
module FElib / Mesh / Local 3D
subroutine, public localmesh3d_final(this, is_generated)
Finalize an object to manage a 3D local computational domain.
subroutine, public localmesh3d_init(this, lcdomid, refelem, myrank)
Initialize an object to manage a 3D local computational domain.
module FElib / Mesh / Local, Base
subroutine, public localmeshbase_final(this, is_generated)
Finalize an object to manage a local computational mesh.
subroutine, public localmeshbase_init(this, lcdomid, refelem, ndim, myrank)
Setup an object to manage a local computational mesh.
Derived type representing a 3D reference element.
Derived type representing an arbitrary finite element.
Derived type representing a local mesh for 2D domain.
Derived type to manage a local 3D computational domain.
Derived type to manage a local computational domain (base type)