FE-Project
All Classes Namespaces Files Functions Variables Pages
scale_mesh_base1d.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
9#include "scaleFElib.h"
11
12 !-----------------------------------------------------------------------------
13 !
14 !++ used modules
15 !
16 use scale_precision
17
18 use scale_localmesh_1d, only: &
20
21 use scale_mesh_base, only: meshbase, &
24
27
28 !-----------------------------------------------------------------------------
29 implicit none
30 private
31
32 !-----------------------------------------------------------------------------
33 !
34 !++ Public type & procedure
35 !
36 type, abstract, public, extends(meshbase) :: meshbase1d
37 type(localmesh1d), allocatable :: lcmesh_list(:)
38 class(elementbase1d), pointer :: refelem1d
39
40 integer, public :: neg
41 integer, public :: nprc
42 real(rp), public :: xmin_gl, xmax_gl
43 real(rp), public, allocatable :: fx(:)
44 contains
45 procedure(meshbase1d_generate), deferred :: generate
46 procedure :: getlocalmesh => meshbase1d_get_localmesh
47 end type meshbase1d
48
49 interface
50 subroutine meshbase1d_generate(this)
51 import meshbase1d
52 class(meshbase1d), intent(inout), target :: this
53 end subroutine meshbase1d_generate
54 end interface
55
58
59 !-----------------------------------------------------------------------------
60 !
61 !++ Public parameters & variables
62 !
63 integer, public :: meshbase1d_dimtype_num = 2
64 integer, public :: meshbase1d_dimtypeid_x = 1
65 integer, public :: meshbase1d_dimtypeid_xt = 2
66
67 !-----------------------------------------------------------------------------
68 !
69 !++ Private procedure
70 !
71
72 !-----------------------------------------------------------------------------
73 !
74 !++ Private parameters & variables
75 !
76
77contains
78!OCL SERIAL
79 subroutine meshbase1d_init( this, &
80 NeG, &
81 dom_xmin, dom_xmax, &
82 refElem, NLocalMeshPerPrc, &
83 nprocs, myrank, FX )
84
85 implicit none
86
87 class(meshbase1d), intent(inout) :: this
88 integer, intent(in) :: neg
89 real(rp), intent(in) :: dom_xmin
90 real(rp), intent(in) :: dom_xmax
91 class(elementbase1d), intent(in), target :: refelem
92 integer, intent(in) :: nlocalmeshperprc
93 integer, intent(in), optional :: nprocs
94 integer, intent(in), optional :: myrank
95 real(rp), intent(in), optional :: fx(neg+1)
96
97 integer :: n
98 integer :: k
99 real(rp) :: dx
100 !-----------------------------------------------------------------------------
101
102 this%NeG = neg
103
104 this%xmin_gl = dom_xmin
105 this%xmax_gl = dom_xmax
106
107 !- Fx
108 allocate( this%FX(neg+1) )
109 if ( present(fx) ) then
110 this%FX(:) = fx(:)
111 else
112 this%FX(1 ) = dom_xmin
113 this%FX(neg+1) = dom_xmax
114 dx = (dom_xmax - dom_xmin) / dble(neg)
115 do k=2, neg
116 this%FX(k) = this%FX(k-1) + dx
117 end do
118 end if
119
120 this%refElem1D => refelem
121 call meshbase_init( this, &
122 meshbase1d_dimtype_num, refelem, &
123 nlocalmeshperprc, 2, &
124 nprocs )
125
126 this%Nprc = this%PRC_NUM
127
128 allocate( this%lcmesh_list(this%LOCAL_MESH_NUM) )
129 do n=1, this%LOCAL_MESH_NUM
130 call localmesh1d_init( this%lcmesh_list(n), n, refelem, myrank )
131 end do
132
133 call this%SetDimInfo( meshbase1d_dimtypeid_x, "x", "m", "X-coordinate" )
134 call this%SetDimInfo( meshbase1d_dimtypeid_xt, "xt", "m", "X-coordinate" )
135
136 return
137 end subroutine meshbase1d_init
138
139!OCL SERIAL
140 subroutine meshbase1d_final( this )
141 implicit none
142 class(meshbase1d), intent(inout) :: this
143
144 integer :: n
145 !-----------------------------------------------------------------------------
146
147 if ( allocated ( this%lcmesh_list ) ) then
148 do n=1, this%LOCAL_MESH_NUM
149 call localmesh1d_final( this%lcmesh_list(n), this%isGenerated )
150 end do
151
152 deallocate( this%lcmesh_list )
153 end if
154
155 call meshbase_final(this)
156
157 return
158 end subroutine meshbase1d_final
159
160!OCL SERIAL
161 subroutine meshbase1d_get_localmesh( this, id, ptr_lcmesh )
163 implicit none
164
165 class(meshbase1d), target, intent(in) :: this
166 integer, intent(in) :: id
167 class(localmeshbase), pointer, intent(out) :: ptr_lcmesh
168 !-------------------------------------------------------------
169
170 ptr_lcmesh => this%lcmesh_list(id)
171 return
172 end subroutine meshbase1d_get_localmesh
173
174!OCL SERIAL
175 subroutine meshbase1d_setgeometricinfo( lcmesh )
176 implicit none
177
178 type(localmesh1d), intent(inout) :: lcmesh
179
180 class(elementbase1d), pointer :: refelem
181 integer :: ke
182 integer :: f
183 integer :: i
184
185 integer :: node_ids(lcmesh%refelem%nv)
186 real(rp) :: vx(lcmesh%refelem%nv)
187 real(rp) :: xr(lcmesh%refelem%np)
188 real(dp) :: escale(1,1,lcmesh%refelem%np)
189 integer :: fmask(lcmesh%refelem%nfptot)
190 integer :: fid(lcmesh%refelem1d%nfp,lcmesh%refelem1d%nfaces)
191
192 !-----------------------------------------------------------------------------
193
194 call meshbase_setgeometricinfo(lcmesh, 1)
195 refelem => lcmesh%refElem1D
196
197 fmask(:) = reshape(refelem%Fmask, shape(fmask))
198 do f=1, refelem%Nfaces
199 do i=1, refelem%Nfp
200 fid(i,f) = i + (f-1)*refelem%Nfp
201 end do
202 end do
203
204 do ke=1, lcmesh%Ne
205 node_ids(:) = lcmesh%EToV(ke,:)
206 vx(:) = lcmesh%pos_ev(node_ids(:),1)
207 lcmesh%pos_en(:,ke,1) = vx(1) + 0.5_rp*(refelem%x1(:) + 1.0_rp)*(vx(2) - vx(1))
208
209 xr(:) = 0.5_rp*(vx(2) - vx(1)) !matmul(refElem%Dr,mesh%x(:,n))
210
211 lcmesh%J(:,ke) = xr
212 lcmesh%Escale(:,ke,1,1) = 1.0_rp/lcmesh%J(:,ke)
213
214 !* Face
215
216 !
217 !mesh%fx(:,n) = mesh%x(fmask(:),n)
218 !mesh%fy(:,n) = mesh%y(fmask(:),n)
219
220 ! Calculate normal vectors
221 lcmesh%normal_fn(fid(:,1),ke,1) = - 1.0_rp
222 lcmesh%normal_fn(fid(:,2),ke,1) = + 1.0_rp
223 lcmesh%sJ(:,ke) = 1.0_rp
224 lcmesh%Fscale(:,ke) = lcmesh%sJ(:,ke)/lcmesh%J(fmask(:),ke)
225 lcmesh%Gsqrt(:,ke) = 1.0_rp
226 end do
227
228 return
229 end subroutine meshbase1d_setgeometricinfo
230
231!OCL SERIAL
232 subroutine meshbase1d_assigndomid( this, &
233 tileID_table, panelID_table, &
234 pi_table )
235
236 use scale_meshutil_1d, only: &
238 implicit none
239
240 class(meshbase1d), intent(inout) :: this
241 integer, intent(out) :: tileid_table(this%local_mesh_num, this%prc_num)
242 integer, intent(out) :: panelid_table(this%local_mesh_num*this%prc_num)
243 integer, intent(out) :: pi_table(this%local_mesh_num*this%prc_num)
244
245 integer :: n
246 integer :: p
247 integer :: tileid
248 !-----------------------------------------------------------------------------
249
251 panelid_table, pi_table, & ! (out)
252 this%tileID_globalMap, this%tileFaceID_globalMap, this%tilePanelID_globalMap, & ! (out)
253 this%LOCAL_MESH_NUM_global ) ! (in)
254
255 do p=1, this%PRC_NUM
256 do n=1, this%LOCAL_MESH_NUM
257 tileid = n + (p-1)*this%LOCAL_MESH_NUM
258
259 tileid_table(n,p) = tileid
260 this%tileID_global2localMap(tileid) = n
261 this%PRCRank_globalMap(tileid) = p - 1
262 end do
263 end do
264
265 return
266 end subroutine meshbase1d_assigndomid
267
268!OCL SERIAL
269 subroutine meshbase1d_setuplocaldom( lcmesh, &
270 tileID, panelID, &
271 i, Nprc, &
272 dom_xmin, dom_xmax, &
273 Ne, FX )
274
275 use scale_meshutil_1d, only: &
280
282 implicit none
283
284 type(localmesh1d), intent(inout) :: lcmesh
285 integer, intent(in) :: tileid
286 integer, intent(in) :: panelid
287 integer, intent(in) :: i
288 integer, intent(in) :: nprc
289 real(rp) :: dom_xmin, dom_xmax
290 integer, intent(in) ::ne
291 real(rp), intent(in) :: fx(ne*nprc+1)
292
293 class(elementbase1d), pointer :: elem
294 real(rp) :: delx
295 real(rp) :: fx_lc(ne+1)
296 !-----------------------------------------------------------------------------
297
298 elem => lcmesh%refElem1D
299 lcmesh%tileID = tileid
300 lcmesh%panelID = panelid
301
302 !--
303
304 lcmesh%Ne = ne
305 lcmesh%Nv = ne + 1
306 lcmesh%NeS = 1
307 lcmesh%NeE = lcmesh%Ne
308 lcmesh%NeA = lcmesh%Ne + 2
309
310 !delx = (dom_xmax - dom_xmin)/dble(Nprc)
311 fx_lc(:) = fx((i-1)*ne+1:i*ne)
312 lcmesh%xmin = fx_lc(1)
313 lcmesh%xmax = fx_lc(ne+1)
314
315 allocate(lcmesh%pos_ev(lcmesh%Nv,1))
316 allocate( lcmesh%EToV(lcmesh%Ne,2) )
317 allocate( lcmesh%EToE(lcmesh%Ne,elem%Nfaces) )
318 allocate( lcmesh%EToF(lcmesh%Ne,elem%Nfaces) )
319 allocate( lcmesh%BCType(lcmesh%refElem%Nfaces,lcmesh%Ne) )
320 allocate( lcmesh%VMapM(elem%NfpTot, lcmesh%Ne) )
321 allocate( lcmesh%VMapP(elem%NfpTot, lcmesh%Ne) )
322 allocate( lcmesh%MapM(elem%NfpTot, lcmesh%Ne) )
323 allocate( lcmesh%MapP(elem%NfpTot, lcmesh%Ne) )
324
325 lcmesh%BCType(:,:) = bctype_interior
326
327 !----
328
329 call meshutil1d_genlinedomain( lcmesh%pos_ev, lcmesh%EToV, & ! (out)
330 lcmesh%Ne, lcmesh%xmin, lcmesh%xmax, fx=fx_lc ) ! (in)
331
332
333 !---
334 call meshbase1d_setgeometricinfo( lcmesh )
335
336 !---
337
338 call meshutil1d_genconnectivity( lcmesh%EToE, lcmesh%EToF, & ! (out)
339 & lcmesh%EToV, lcmesh%Ne, elem%Nfaces ) ! (in)
340
341 !---
342 call meshutil1d_buildinteriormap( lcmesh%VmapM, lcmesh%VMapP, lcmesh%MapM, lcmesh%MapP, &
343 & lcmesh%pos_en, lcmesh%pos_ev, lcmesh%EToE, lcmesh%EtoF, lcmesh%EtoV, &
344 & elem%Fmask, lcmesh%Ne, elem%Np, elem%Nfp, elem%Nfaces, lcmesh%Nv )
345
346 call meshutil1d_genpatchboundarymap( lcmesh%VMapB, lcmesh%MapB, lcmesh%VMapP, &
347 & lcmesh%pos_en, lcmesh%xmin, lcmesh%xmax, &
348 & elem%Fmask, lcmesh%Ne, elem%Np, elem%Nfp, elem%Nfaces, lcmesh%Nv)
349
350 return
351 end subroutine meshbase1d_setuplocaldom
352
353end module scale_mesh_base1d
module FElib / Element / Base
module FElib / Element / line
module FElib / Mesh / Local 1D
subroutine, public localmesh1d_final(this, is_generated)
subroutine, public localmesh1d_init(this, lcdomid, refelem, myrank)
module FElib / Mesh / Local, Base
integer, parameter, public bctype_interior
module FElib / Mesh / Base 1D
integer, public meshbase1d_dimtype_num
subroutine, public meshbase1d_init(this, neg, dom_xmin, dom_xmax, refelem, nlocalmeshperprc, nprocs, myrank, fx)
subroutine, public meshbase1d_final(this)
integer, public meshbase1d_dimtypeid_x
subroutine, public meshbase1d_assigndomid(this, tileid_table, panelid_table, pi_table)
subroutine, public meshbase1d_setgeometricinfo(lcmesh)
integer, public meshbase1d_dimtypeid_xt
subroutine, public meshbase1d_setuplocaldom(lcmesh, tileid, panelid, i, nprc, dom_xmin, dom_xmax, ne, fx)
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)
module FElib / Mesh / utility for 1D mesh
subroutine, public meshutil1d_buildinteriormap(vmapm, vmapp, mapm, mapp, pos_en, pos_ev, etoe, etof, etov, fmask, ne, np, nfp, nfaces, nv)
subroutine, public meshutil1d_genconnectivity(etoe, etof, etov, ne, nfaces)
subroutine, public meshutil1d_genpatchboundarymap(vmapb, mapb, vmapp, pos_en, xmin, xmax, fmask, ne, np, nfp, nfaces, nv)
subroutine, public meshutil1d_buildglobalmap(panelid_table, pi_table, tileid_map, tilefaceid_map, tilepanelid_map, ntile)
subroutine, public meshutil1d_genlinedomain(pos_v, etov, ke_x, xmin, xmax, fx)