FE-Project
Loading...
Searching...
No Matches
scale_meshfield_filter_operation_2d.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Data / Filter operation 2D
3!!
4!! @par Description
5!! This module provides classes to apply filter operations to MeshField data
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: prc_abort
20
26
27 use scale_meshfield_base, only: &
30 use scale_mesh_rectdom2d, only: &
34 use scale_meshfieldcomm_base, only: &
36
48
49 !-----------------------------------------------------------------------------
50 implicit none
51 private
52
53 !-----------------------------------------------------------------------------
54 !
55 !++ Public type & procedure
56 !
57
58 !> Derived type to represent filter operation for 2D mesh field
60 type(meshfieldcommrectdom2d) :: vars_comm
61 contains
63 procedure :: final => meshfieldfilteroperation2d_final
64 procedure :: apply => meshfieldfilteroperation2d_apply_filter
66
67 !-----------------------------------------------------------------------------
68 !
69 !++ Public parameters & variables
70 !
71
72 !-----------------------------------------------------------------------------
73 !
74 !++ Private type & procedure
75 !
76 private :: extract_tmp2d
77
78 !-----------------------------------------------------------------------------
79 !
80 !++ Private parameters & variables
81 !
82
83contains
84 !> Initialize an object to represent filter operation for 2D mesh field
85!OCL SERIAL
87 FilterOptrType, &
88 FilterShape, FilterWidthFac, &
89 Nnode_h1D_reconst, &
90 sfield_num, hvfield_num, htensorfield_num, &
91 mesh2D )
92 implicit none
93 class(meshfieldfilteroperation2d), intent(inout) :: this
94 class(meshbase2d), intent(in) :: mesh2D
95 character(*), intent(in) :: FilterOptrType
96 character(*), intent(in) :: FilterShape
97 real(RP), intent(in) :: FilterWidthFac
98 integer, intent(in) :: Nnode_h1D_reconst
99 integer, intent(in) :: sfield_num
100 integer, intent(in) :: hvfield_num
101 integer, intent(in) :: htensorfield_num
102 !------------------------------------------
103
104 call meshfieldfilteroperationbase_init( this, mesh2d%refElem2D%Nfp, &
105 filteroptrtype, filtershape, filterwidthfac, &
106 nnode_h1d_reconst )
107
108 select type(mesh2d)
109 class is (meshrectdom2d)
110 call this%vars_comm%Init( sfield_num, hvfield_num, htensorfield_num, mesh2d, &
111 halosize_1d=this%hHaloSize )
112 class default
113 log_info('MeshFieldFilterOperation2D_Init',*) "Unsupported mesh type is specified. Check!"
114 call prc_abort
115 end select
116 return
118
119 !> Finalize an object to represent filter operation for 2D mesh field
120!OCL SERIAL
121 subroutine meshfieldfilteroperation2d_final( this )
122 implicit none
123 class(meshfieldfilteroperation2d), intent(inout) :: this
124 !------------------------------------------
126 call this%vars_comm%Final()
127 return
128 end subroutine meshfieldfilteroperation2d_final
129
130 !> Apply filter operation to 2D mesh field data
131!OCL serial
132 subroutine meshfieldfilteroperation2d_apply_filter( this, q_list, &
133 mesh2D )
134 implicit none
135 class(meshfieldfilteroperation2d), intent(inout) :: this
136 type(meshfield2d), intent(inout), target :: q_list(this%vars_comm%field_num_tot)
137 class(meshbase2d), intent(in), target :: mesh2D
138
139 class(localmesh2d), pointer :: lmesh2D
140 class(elementbase2d), pointer :: elem2D
141 real(RP), allocatable :: tmp2D(:,:,:)
142
143 integer :: iv
144 integer :: n
145 type(meshfieldcontainer) :: comm_vars_list(this%vars_comm%field_num_tot)
146 !-----------------------------------------------------
147
148 do iv=1, this%vars_comm%field_num_tot
149 comm_vars_list(iv)%field2d => q_list(iv)
150 end do
151 call this%vars_comm%Put(comm_vars_list, 1)
152 call this%vars_comm%Exchange()
153 call this%vars_comm%Get(comm_vars_list, 1)
154
155 do n=1, mesh2d%LOCAL_MESH_NUM
156 lmesh2d => mesh2d%lcmesh_list(n)
157 elem2d => lmesh2d%refElem2D
158 allocate( tmp2d(-this%hHaloSize+1:elem2d%Nfp+this%hHaloSize,-this%hHaloSize+1:elem2d%Nfp+this%hHaloSize,lmesh2d%Ne) )
159
160 do iv=1, this%vars_comm%field_num_tot
161 call extract_tmp2d( tmp2d, &
162 q_list(iv)%local(n)%val, q_list(iv)%local(n)%val, lmesh2d, elem2d, lmesh2d%VMapP, this%hHaloSize, 0 )
163
164 select case (this%operator_type)
166 call apply_filter1d_x( q_list(iv)%local(n)%val, &
167 tmp2d, this%FilterMat_h1D, elem2d%Nfp, elem2d%Nfp, 1, lmesh2d%Ne, lmesh2d%NeA, elem2d%Nfp )
169 call apply_reconst1d_x( q_list(iv)%local(n)%val, &
170 tmp2d, this%Minv_Ml_tr, this%Minv_Mc_tr, this%Minv_Mr_tr, this%IntrpMat, elem2d%Nfp, elem2d%Nfp, 1, lmesh2d%Ne, this%Nnode_h1D_reconst, lmesh2d )
172 call apply_reconst1d_x_2( q_list(iv)%local(n)%val, &
173 tmp2d, this%Ml_tr, this%Mc_tr, this%Mr_tr, elem2d%Nfp, elem2d%Nfp, 1, lmesh2d%Ne, this%Nnode_h1D_reconst, lmesh2d )
174 end select
175
176 end do
177 deallocate( tmp2d )
178 end do
179
180 call this%vars_comm%Put(comm_vars_list, 1)
181 call this%vars_comm%Exchange()
182 call this%vars_comm%Get(comm_vars_list, 1)
183
184 do n=1, mesh2d%LOCAL_MESH_NUM
185 lmesh2d => mesh2d%lcmesh_list(n)
186 elem2d => lmesh2d%refElem2D
187 allocate( tmp2d(-this%hHaloSize+1:elem2d%Nfp+this%hHaloSize,-this%hHaloSize+1:elem2d%Nfp+this%hHaloSize,lmesh2d%Ne) )
188
189 do iv=1, this%vars_comm%field_num_tot
190 call extract_tmp2d( tmp2d, &
191 q_list(iv)%local(n)%val, q_list(iv)%local(n)%val, lmesh2d, elem2d, lmesh2d%VMapP, this%hHaloSize, 1 )
192
193 select case (this%operator_type)
195 call apply_filter1d_y( q_list(iv)%local(n)%val, &
196 tmp2d, this%FilterMat_h1D, elem2d%Nfp, elem2d%Nfp, 1, lmesh2d%Ne, lmesh2d%NeA, elem2d%Nfp )
198 call apply_reconst1d_y( q_list(iv)%local(n)%val, &
199 tmp2d, this%Minv_Ml_tr, this%Minv_Mc_tr, this%Minv_Mr_tr, this%IntrpMat, elem2d%Nfp, elem2d%Nfp, 1, lmesh2d%Ne, this%Nnode_h1D_reconst, lmesh2d )
201 call apply_reconst1d_y_2( q_list(iv)%local(n)%val, &
202 tmp2d, this%Ml_tr, this%Mc_tr, this%Mr_tr, elem2d%Nfp, elem2d%Nfp, 1, lmesh2d%Ne, this%Nnode_h1D_reconst, lmesh2d )
203 end select
204
205 end do
206 deallocate( tmp2d )
207 end do
208
209 return
210 end subroutine meshfieldfilteroperation2d_apply_filter
211
212!- Private -----------------------
213
214!OCL SERIAL
215 subroutine extract_tmp2d( tmp2D, q0, q0_, lmesh2D, elem2D, vmapP, hHaloSize, x_or_y )
216 implicit none
217 class(localmesh2d), intent(in) :: lmesh2D
218 class(elementbase2d), intent(in) :: elem2D
219 integer, intent(in) :: hHaloSize
220 real(RP), intent(out) :: tmp2D(-hHaloSize+1:elem2D%Nfp+hHaloSize,-hHaloSize+1:elem2D%Nfp+hHaloSize,lmesh2D%Ne)
221 real(RP), intent(in) :: q0(elem2D%Np*lmesh2D%NeA)
222 real(RP), intent(in) :: q0_(elem2D%Nfp,elem2D%Nfp,lmesh2D%NeA)
223 integer, intent(in) :: vmapP(elem2D%NfpTot,lmesh2D%Ne)
224 integer, intent(in) :: x_or_y !< x: 0, y: 1
225
226 integer :: ke, ke_h, ke_x, ke_y, px, py, ph, i, f
227 integer :: fso, fs, fe
228 integer :: iP(elem2D%Nfp)
229 real(RP) :: halo_h(elem2D%Nfp,hHaloSize,max(lmesh2D%NeX,lmesh2D%NeY),4)
230 integer :: Neh_f(4)
231 integer :: Neh_os(4)
232 !------------------------------
233
234 neh_f(:) = (/ lmesh2d%NeX, lmesh2d%NeY, lmesh2d%NeX, lmesh2d%NeY /)
235 neh_os(1) = 0
236 do f=2, 4
237 neh_os(f) = neh_os(f-1) + neh_f(f-1)
238 end do
239
240 !$omp parallel private(ke, ke_x, ke_y, ke_h, i, px, py, ph, fso, fs, fe, iP, f)
241
242 !$omp do
243 do f=1, 4
244 do ke_h=1, neh_f(f)
245 fso = lmesh2d%Ne * elem2d%Np &
246 + elem2d%Nfp*hhalosize * ( neh_os(f) + (ke_h-1) )
247
248 do ph=1, hhalosize
249 fs = fso + 1 + (ph-1)*elem2d%Nfp
250 fe = fso + elem2d%Nfp - 1
251 halo_h(:,ph,ke_h,f) = q0(fs:fe)
252 end do
253 end do
254 end do
255
256 !$omp do collapse(2)
257 do ke_y=1, lmesh2d%NeY
258 do ke_x=1, lmesh2d%NeX
259 ke = ke_x + (ke_y-1) * lmesh2d%NeX
260
261 do py=1, elem2d%Nfp
262 do px=1, elem2d%Nfp
263 tmp2d(px,py,ke) = q0_(px,py,ke)
264 end do
265 end do
266
267 if ( x_or_y == 1 ) then ! y-direction
268 ! Face 1
269 fso = 0
270 fs = fso + 1; fe = fs + elem2d%Nfp - 1
271 ip(:) = vmapp(fs:fe,ke)
272 if ( ip(1) <= lmesh2d%Ne * elem2d%Np ) then
273 do ph=1, hhalosize
274 tmp2d(1:elem2d%Nfp,-ph+1,ke) = q0(ip(:) - (ph-1)*elem2d%Nfp)
275 end do
276 else
277 do ph=1, hhalosize
278 tmp2d(1:elem2d%Nfp,-ph+1,ke) = halo_h(:,ph,ke_x,1)
279 end do
280 end if
281
282 ! Face 3
283 fso = 2 * elem2d%Nfp
284 fs = fso + 1; fe = fs + elem2d%Nfp - 1
285 ip(:) = vmapp(fs:fe,ke)
286 if ( ip(1) <= lmesh2d%Ne * elem2d%Np ) then
287 do ph=1, hhalosize
288 tmp2d(1:elem2d%Nfp,ph+elem2d%Nfp,ke) = q0(ip(:) + (ph-1)*elem2d%Nfp)
289 end do
290 else
291 do ph=1, hhalosize
292 tmp2d(1:elem2d%Nfp,ph+elem2d%Nfp,ke) = halo_h(:,ph,ke_x,3)
293 end do
294 end if
295 else if ( x_or_y == 0 ) then ! x-direction
296 ! Face 2
297 fso = elem2d%Nfp
298 fs = fso + 1; fe = fs + elem2d%Nfp - 1
299 ip(:) = vmapp(fs:fe,ke)
300 if ( ip(1) <= lmesh2d%Ne * elem2d%Np ) then
301 do ph=1, hhalosize
302 tmp2d(ph+elem2d%Nfp,1:elem2d%Nfp,ke) = q0(ip(:) + (ph-1))
303 end do
304 else
305 do ph=1, hhalosize
306 tmp2d(ph+elem2d%Nfp,1:elem2d%Nfp,ke) = halo_h(:,ph,ke_y,2)
307 end do
308 end if
309
310 ! Face 4
311 fso = 3 * elem2d%Nfp
312 fs = fso + 1; fe = fs + elem2d%Nfp - 1
313 ip(:) = vmapp(fs:fe,ke)
314 if ( ip(1) <= lmesh2d%Ne * elem2d%Np ) then
315 do ph=1, hhalosize
316 tmp2d(-ph+1,1:elem2d%Nfp,ke) = q0(ip(:) - (ph-1))
317 end do
318 else
319 do ph=1, hhalosize
320 tmp2d(-ph+1,1:elem2d%Nfp,ke) = halo_h(:,ph,ke_y,4)
321 end do
322 end if
323 end if
324 end do
325 end do
326
327 !$omp end parallel
328 return
329 end subroutine extract_tmp2d
module FElib / Element / Base
module FElib / Element/ ModalFilter
module FElib / Mesh / Local 2D
module FElib / Mesh / Local, Base
module FElib / Mesh / Base 2D
module FElib / Mesh / Rectangle 2D domain
module FElib / Data / base
module FElib / Data / Filter operation 2D
subroutine meshfieldfilteroperation2d_init(this, filteroptrtype, filtershape, filterwidthfac, nnode_h1d_reconst, sfield_num, hvfield_num, htensorfield_num, mesh2d)
Initialize an object to represent filter operation for 2D mesh field.
module FElib / Data / Filter operation base
subroutine, public meshfieldfilteroperationbase_apply_filter1d_y(q, q0, filter1d, npx, npy, npz, ne, nea, nnode_h1d)
subroutine, public meshfieldfilteroperationbase_apply_filter1d_x(q, q0, filter1d, npx, npy, npz, ne, nea, nnode_h1d)
subroutine, public meshfieldfilteroperationbase_apply_reconst1d_y_2(q, q0, minv_ml_tr, minv_mc_tr, minv_mr_tr, npx, npy, npz, ne, npy_reconst, lmesh)
subroutine, public meshfieldfilteroperationbase_apply_reconst1d_x_2(q, q0, minv_ml_tr, minv_mc_tr, minv_mr_tr, npx, npy, npz, ne, npx_reconst, lmesh)
subroutine, public meshfieldfilteroperationbase_apply_reconst1d_y(q, q0, minv_ml_tr, minv_mc_tr, minv_mr_tr, intrpmat, npx, npy, npz, ne, npy_reconst, lmesh)
subroutine, public meshfieldfilteroperationbase_init(this, nnode_h1d, filteroptrtype, filtershape, filterwidthfac, nnode_h1d_reconst, nnode_h1d_gl, if_r)
subroutine, public meshfieldfilteroperationbase_apply_reconst1d_x(q, q0, minv_ml_tr, minv_mc_tr, minv_mr_tr, intrpmat, npx, npy, npz, ne, npx_reconst, lmesh)
module FElib / Data / Communication base
module FElib / Data / Communication 2D rectangle domain
Derived type representing a 2D reference element.
Derived type representing a 3D reference element.
Derived type representing a modal filter.
Derived type representing a local mesh for 2D domain.
Derived type to manage a local computational domain (base type)
Derived type representing a field with local mesh (base type)
Derived type to manage a computational mesh (base type for 2D domain)
Derived type to manage a rectangular 2D computational domain.
Derived type representing a field with 2D mesh.
Derived type to represent filter operation for 2D mesh field.
Container to save a pointer of MeshField(1D, 2D, 3D) object.
Base derived type to manage data communication with 2D rectangle domain.