FE-Project
Loading...
Searching...
No Matches
scale_model_meshbase_manager.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> FElib / model framework / mesh manager (base)
3!!
4!! @par Description
5!! A module for managing mesh used in models
6!!
7!! @author Yuta Kawai, Team SCALE
8!!
9!<
10!-------------------------------------------------------------------------------
11#include "scaleFElib.h"
13 !-----------------------------------------------------------------------------
14 !
15 !++ Used modules
16 !
17 use scale_precision
18 use scale_io
19 use scale_prc, only: &
20 prc_abort
21
23 use scale_mesh_base, only: meshbase
27
31
32 use scale_sparsemat, only: sparsemat
33
34 !-----------------------------------------------------------------------------
35 implicit none
36 private
37
38 !-----------------------------------------------------------------------------
39 !
40 !++ Public type & procedures
41 !
42
43 !> Derived type to manage model mesh and spatial operators (base type)
44 type, abstract, public :: modelmeshbase
45 type(sparsemat), allocatable :: doptrmat(:)
46 type(sparsemat), allocatable :: soptrmat(:)
47 type(sparsemat) :: liftoptrmat
48 class(elementoperationbase3d), pointer :: element3d_operation
49
50 integer :: communicator_num
51 contains
52 procedure :: modelmeshbase_init
53 procedure :: modelmeshbase_final
54 procedure :: get_communicatorid => modelmeshbase_get_communicatorid
55 procedure(modelmeshbase_get_modelmesh), public, deferred :: getmodelmesh
56 end type modelmeshbase
57
58 abstract interface
59 subroutine modelmeshbase_get_modelmesh( this, ptr_mesh )
60 import modelmeshbase
61 import meshbase
62 class(modelmeshbase), target, intent(in) :: this
63 class(meshbase), pointer, intent(out) :: ptr_mesh
64 end subroutine modelmeshbase_get_modelmesh
65 end interface
66
67 !> Derived type to manage 1D mesh and spatial operators
68 type, extends(modelmeshbase), public :: modelmeshbase1d
69 class(meshbase1d), pointer :: ptr_mesh
70 contains
71 procedure, public :: modelmeshbase1d_init
72 procedure, public :: modelmeshbase1d_final
73 procedure, public :: getmodelmesh => modelmeshbase1d_get_modelmesh
74 end type modelmeshbase1d
75
76 !> Derived type to manage 2D mesh and spatial operators
77 type, extends(modelmeshbase), public :: modelmeshbase2d
78 class(meshbase2d), pointer :: ptr_mesh
79 contains
80 procedure, public :: modelmeshbase2d_init
81 procedure, public :: modelmeshbase2d_final
82 procedure, public :: getmodelmesh => modelmeshbase2d_get_modelmesh
83 end type modelmeshbase2d
84
85 !> Derived type to manage 3D mesh and spatial operators
86 type, extends(modelmeshbase), abstract, public :: modelmeshbase3d
87 class(meshbase3d), pointer :: ptr_mesh
88 type(elementoperationgeneral) :: element_operation_general
89 class(elementoperationtensorprod3d), allocatable :: element_operation_tensorprod
90 logical :: initialized_element_operation
91 contains
92 procedure, public :: modelmeshbase3d_init
93 procedure, public :: modelmeshbase3d_final
94 procedure, public :: prepairelementoperation => modelmeshbase3d_prepair_elementoperation
95 procedure, public :: getmodelmesh => modelmeshbase3d_get_modelmesh
96 end type modelmeshbase3d
97
98 !-----------------------------------------------------------------------------
99 !
100 !++ Public parameters & variables
101 !
102
103 !-----------------------------------------------------------------------------
104 !
105 !++ Private procedures & variables
106 !
107 !------------------
108
109contains
110!OCL SERIAL
111 subroutine modelmeshbase_init( this, nDim )
112 implicit none
113 class(modelmeshbase), intent(inout) :: this
114 integer, intent(in) :: nDim
115
116 integer :: d
117 !--------------------------------------------
118
119 this%communicator_num = 0
120 allocate( this%SOptrMat(ndim), this%DOptrMat(ndim) )
121
122 return
123 end subroutine modelmeshbase_init
124
125!OCL SERIAL
126 function modelmeshbase_get_communicatorid( this, max_communicator_num ) result(commid)
127 implicit none
128 class(modelmeshbase), intent(inout) :: this
129 integer, intent(in) :: max_communicator_num
130 integer :: commid
131 !--------------------------------------------
132
133 this%communicator_num = this%communicator_num + 1
134 commid = this%communicator_num
135
136 if ( commid > max_communicator_num ) then
137 log_error('ModelMeshBase_get_communicatorID',*) 'The number of communicator exceeds expectation. Check!'
138 call prc_abort
139 end if
140
141 return
142 end function modelmeshbase_get_communicatorid
143
144!OCL SERIAL
145 subroutine modelmeshbase_final( this )
146 implicit none
147 class(modelmeshbase), intent(inout) :: this
148
149 integer :: d
150 !--------------------------------------------
151
152 do d = 1, size(this%DOptrMat)
153 call this%DOptrMat(d)%Final()
154 call this%SOptrMat(d)%Final()
155 end do
156 deallocate( this%SOptrMat, this%DOptrMat )
157
158 call this%LiftOptrMat%Final()
159
160 return
161 end subroutine modelmeshbase_final
162
163 !* 1D *************************************************************
164
165 subroutine modelmeshbase1d_init( this, mesh )
166 implicit none
167 class(modelmeshbase1d), target, intent(inout) :: this
168 class(meshbase1d), target, intent(in) :: mesh
169 !-----------------------------------------------------
170
171 this%ptr_mesh => mesh
172 call this%ModelMeshBase_Init(1)
173
174 return
175 end subroutine modelmeshbase1d_init
176
177!OCL SERIAL
178 subroutine modelmeshbase1d_final( this )
179 implicit none
180 class(modelmeshbase1d), target, intent(inout) :: this
181
182 integer :: d
183 !-----------------------------------------------------
184
185 nullify( this%ptr_mesh )
186 call this%ModelMeshBase_Final()
187
188 return
189 end subroutine modelmeshbase1d_final
190
191!OCL SERIAL
192 subroutine modelmeshbase1d_get_modelmesh( this, ptr_mesh )
193 implicit none
194 class(modelmeshbase1d), target, intent(in) :: this
195 class(meshbase), pointer, intent(out) :: ptr_mesh
196 !-----------------------------------------------------
197
198 ptr_mesh => this%ptr_mesh
199
200 return
201 end subroutine modelmeshbase1d_get_modelmesh
202
203 !* 2D *************************************************************
204
205!OCL SERIAL
206 subroutine modelmeshbase2d_init( this, mesh )
207 implicit none
208 class(modelmeshbase2d), target, intent(inout) :: this
209 class(meshbase2d), target, intent(in) :: mesh
210 !-----------------------------------------------------
211
212 this%ptr_mesh => mesh
213 call this%ModelMeshBase_Init(2)
214
215 return
216 end subroutine modelmeshbase2d_init
217
218!OCL SERIAL
219 subroutine modelmeshbase2d_final( this )
220 implicit none
221 class(modelmeshbase2d), target, intent(inout) :: this
222 !-----------------------------------------------------
223
224 nullify( this%ptr_mesh )
225 call this%ModelMeshBase_Final()
226
227 return
228 end subroutine modelmeshbase2d_final
229
230!OCL SERIAL
231 subroutine modelmeshbase2d_get_modelmesh( this, ptr_mesh )
232 implicit none
233 class(modelmeshbase2d), target, intent(in) :: this
234 class(meshbase), pointer, intent(out) :: ptr_mesh
235 !-----------------------------------------------------
236
237 ptr_mesh => this%ptr_mesh
238 return
239 end subroutine modelmeshbase2d_get_modelmesh
240
241 !* 3D *************************************************************
242
243!OCL SERIAL
244 subroutine modelmeshbase3d_init( this, mesh )
245 implicit none
246 class(modelmeshbase3d), target, intent(inout) :: this
247 class(meshbase3d), target, intent(in) :: mesh
248 !-----------------------------------------------------
249
250 this%ptr_mesh => mesh
251 call this%ModelMeshBase_Init(3)
252
253 this%initialized_element_operation = .false.
254
255 return
256 end subroutine modelmeshbase3d_init
257
258!OCL SERIAL
259 subroutine modelmeshbase3d_final( this )
260 implicit none
261 class(modelmeshbase3d), target, intent(inout) :: this
262 !-----------------------------------------------------
263
264 if ( this%initialized_element_operation ) then
265 call this%element3D_operation%Final()
266 end if
267
268 nullify( this%ptr_mesh )
269 call this%ModelMeshBase_Final()
270
271 return
272 end subroutine modelmeshbase3d_final
273
274!OCL SERIAL
275 subroutine modelmeshbase3d_prepair_elementoperation( this, element_operation_type, &
276 SpMV_storage_format_ )
277 use scale_prc, only: prc_abort
279 implicit none
280 class(modelmeshbase3d), intent(inout), target :: this
281 character(len=*), intent(in), optional :: element_operation_type
282 character(len=*), intent(in), optional :: SpMV_storage_format_
283
284 character(len=H_SHORT) :: element_operation_type_
285 character(len=H_SHORT) :: SpMV_storage_format
286
287 class(elementbase3d), pointer :: elem3D
288 !-----------------------------------------------------
289
290 if ( present(element_operation_type) ) then
291 element_operation_type_ = element_operation_type
292 else
293 element_operation_type_ = "General"
294 end if
295 spmv_storage_format = "ELL"
296 elem3d => this%ptr_mesh%refElem3D
297 call this%DOptrMat(1)%Init( elem3d%Dx1, storage_format=spmv_storage_format )
298 call this%DOptrMat(2)%Init( elem3d%Dx2, storage_format=spmv_storage_format )
299 call this%DOptrMat(3)%Init( elem3d%Dx3, storage_format=spmv_storage_format )
300
301 call this%SOptrMat(1)%Init( elem3d%Sx1, storage_format=spmv_storage_format )
302 call this%SOptrMat(2)%Init( elem3d%Sx2, storage_format=spmv_storage_format )
303 call this%SOptrMat(3)%Init( elem3d%Sx3, storage_format=spmv_storage_format )
304
305 call this%LiftOptrMat%Init( elem3d%Lift, storage_format=spmv_storage_format )
306
307 select case(element_operation_type_)
308 case ("General")
309 call this%element_operation_general%Init( elem3d, this%DOptrMat(1), this%DOptrMat(2), this%DOptrMat(3), this%LiftOptrMat )
310 this%element3D_operation => this%element_operation_general
311 case ("TensorProd3D")
313 this%element_operation_tensorprod ) ! (out)
314 this%element3D_operation => this%element_operation_tensorprod
315 case default
316 log_info("ModelMeshBase3D_prepair_ElementOperation",*) "The specified element_operation_type is not supported. Check!", trim(element_operation_type_)
317 call prc_abort
318 end select
319
320 this%initialized_element_operation = .true.
321
322 return
323 end subroutine modelmeshbase3d_prepair_elementoperation
324
325!OCL SERIAL
326 subroutine modelmeshbase3d_get_modelmesh( this, ptr_mesh )
327 implicit none
328 class(modelmeshbase3d), target, intent(in) :: this
329 class(meshbase), pointer, intent(out) :: ptr_mesh
330 !-----------------------------------------------------
331
332 ptr_mesh => this%ptr_mesh
333 return
334 end subroutine modelmeshbase3d_get_modelmesh
335
module FElib / Element / Base
module FElib / Element / Operation / Base
module FElib / Element / Operation with arbitary elements
module FElib / Element / Operation with 3D tensor product elements
subroutine, public elementoperationtensorprod3d_create(elem3d, obj)
module FElib / Mesh / Base 1D
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
module FElib / Mesh / Base
FElib / model framework / mesh manager (base)
Module common / sparsemat.
Derived type representing a 3D reference element.
Derived type to manage 1D mesh and spatial operators.
Derived type to manage 2D mesh and spatial operators.
Derived type to manage 3D mesh and spatial operators.
Derived type to manage model mesh and spatial operators (base type)
Derived type to manage a sparse matrix.