FE-Project
Loading...
Searching...
No Matches
scale_meshfield_analysis_numerror.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Data / Statistics / numerical error
3!!
4!! @par Description
5!! This module provides classes to evaluate numerical error for 1D, 2D, and 3D fields
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_ismaster, prc_abort
21 use scale_time_manager, only: &
22 time_nstep
23
24 use scale_element_base, only: &
32 use scale_mesh_base, only: meshbase
39 use scale_meshfield_base, only: &
41
45
46 !-----------------------------------------------------------------------------
47 implicit none
48 private
49
50 !-----------------------------------------------------------------------------
51 !
52 !++ Public type & procedure
53 !
54
55 !- 1D
56
57 !> Derived type for numerical error analysis of 1D field
59 class(meshbase1d), pointer :: mesh1d !< Pointer to an object of 1D mesh
60 procedure(set_data_lc_1d), pointer :: set_data_lc
61 contains
62 procedure :: init_1d => meshfield_analysis_numerror_1d_init
63 generic :: init => init_1d
64 procedure :: evaluate => meshfield_analysis_numerror_1d_evaluate
66 interface
67 subroutine set_data_lc_1d( this_, q, qexact, qexact_intrp, lcmesh, elem1D, intrp_epos, tsec )
68 import rp
69 import elementbase1d
70 import localmesh1d
72 class(meshfieldanalysisnumerror1d), intent(in) :: this_
73 class(localmesh1d), intent(in) :: lcmesh
74 class(elementbase1d), intent(in) :: elem1D
75 real(RP), intent(out) :: q(elem1D%Np,lcmesh%Ne,this_%var_num)
76 real(RP), intent(out) :: qexact(elem1D%Np,lcmesh%Ne,this_%var_num)
77 real(RP), intent(out) :: qexact_intrp(this_%intrp_np,lcmesh%Ne,this_%var_num)
78 real(RP), intent(in) :: intrp_epos(this_%intrp_np,this_%ndim)
79 real(RP), intent(in) :: tsec
80 end subroutine set_data_lc_1d
81 end interface
82
83 !- 2D
84 !> Derived type for numerical error analysis of 2D field
86 class(meshbase2d), pointer :: mesh2d !< Pointer to an object of 2D mesh
87 procedure(set_data_lc_2d), pointer :: set_data_lc
88 contains
89 procedure :: init_2d => meshfield_analysis_numerror_2d_init
90 generic :: init => init_2d
91 procedure :: evaluate => meshfield_analysis_numerror_2d_evaluate
93 interface
94 subroutine set_data_lc_2d( this_, q, qexact, qexact_intrp, lcmesh, elem2D, intrp_epos, tsec )
95 import rp
96 import elementbase2d
97 import localmesh2d
99 class(meshfieldanalysisnumerror2d), intent(in) :: this_
100 class(localmesh2d), intent(in) :: lcmesh
101 class(elementbase2d), intent(in) :: elem2D
102 real(RP), intent(out) :: q(elem2D%Np,lcmesh%Ne,this_%var_num)
103 real(RP), intent(out) :: qexact(elem2D%Np,lcmesh%Ne,this_%var_num)
104 real(RP), intent(out) :: qexact_intrp(this_%intrp_np,lcmesh%Ne,this_%var_num)
105 real(RP), intent(in) :: intrp_epos(this_%intrp_np,this_%ndim)
106 real(RP), intent(in) :: tsec
107 end subroutine set_data_lc_2d
108 end interface
109
110 !- 3D
111 !> Derived type for numerical error analysis of 3D field
113 class(meshbase3d), pointer :: mesh3d !< Pointer to an object of 3D mesh
114 procedure(set_data_lc_3d), pointer :: set_data_lc
115 contains
116 procedure :: init_3d => meshfield_analysis_numerror_3d_init
117 generic :: init => init_3d
118 procedure :: evaluate => meshfield_analysis_numerror_3d_evaluate
120 interface
121 subroutine set_data_lc_3d( this_, q, qexact, qexact_intrp, lcmesh, elem3D, intrp_epos, tsec )
122 import rp
123 import elementbase3d
124 import localmesh3d
126 class(meshfieldanalysisnumerror3d), intent(in) :: this_
127 class(localmesh3d), intent(in) :: lcmesh
128 class(elementbase3d), intent(in) :: elem3D
129 real(RP), intent(out) :: q(elem3D%Np,lcmesh%Ne,this_%var_num)
130 real(RP), intent(out) :: qexact(elem3D%Np,lcmesh%Ne,this_%var_num)
131 real(RP), intent(out) :: qexact_intrp(this_%intrp_np,lcmesh%Ne,this_%var_num)
132 real(RP), intent(in) :: intrp_epos(this_%intrp_np,this_%ndim)
133 real(RP), intent(in) :: tsec
134 end subroutine set_data_lc_3d
135 end interface
136
137 !-----------------------------------------------------------------------------
138 !
139 !++ Public parameters & variables
140 !
141
142 !-----------------------------------------------------------------------------
143 !
144 !++ Private parameters & variables
145 !
146
147 !-----------------------------------------------------------------------------
148 !
149 !++ Private parameters & variables
150 !
151
152contains
153
154!-- 1D --
155
156 !-----------------------------------------------------------------------------
157 !> Initialize a object to evaluate numerical error for 1D field
158!OCL SERIAL
159 subroutine meshfield_analysis_numerror_1d_init( this, &
160 porder_error_check, log_fname_base, log_step_interval, &
161 mesh, refElem1D, &
162 set_data_lc, numerror_analysis_info )
163 implicit none
164 class(meshfieldanalysisnumerror1d), intent(inout) :: this
165 integer, intent(in) :: porder_error_check
166 character(len=*), intent(in) :: log_fname_base
167 integer, intent(in) :: log_step_interval
168 class(meshbase1d), intent(in), target :: mesh
169 type(lineelement), intent(in) :: refElem1D
170 procedure(set_data_lc_1d) :: set_data_lc
171 class(meshfieldanalysisnumerrorinfobase), intent(in), target :: numerror_analysis_info
172 !---------------------------------------------------------------------------
173
174 call this%MeshFieldAnalysisNumerrorBase%Init( &
175 porder_error_check, 1, refelem1d%Np, porder_error_check**1, &
176 log_fname_base, log_step_interval, mesh, numerror_analysis_info )
177
178 this%IntrpMat(:,:) = refelem1d%GenIntGaussLegendreIntrpMat( &
179 this%PolyOrderErrorCheck, & ! (in)
180 this%intw_intrp, this%epos_intrp(:,1) ) ! (out)
181
182 this%mesh1D => mesh
183 this%set_data_lc => set_data_lc
184 return
185 end subroutine meshfield_analysis_numerror_1d_init
186
187!OCL SERIAL
188 subroutine meshfield_analysis_numerror_1d_evaluate( this, &
189 tstep, tsec )
190 implicit none
191 class(meshfieldanalysisnumerror1d), intent(inout) :: this
192 integer, intent(in) :: tstep
193 real(RP), intent(in) :: tsec
194 !---------------------------------------------------------------------------
195
196 call this%Evaluate_base( tstep, tsec, this%mesh1D%dom_vol, evaluate_error_core, calc_covariance_core )
197 return
198 end subroutine meshfield_analysis_numerror_1d_evaluate
199
200!-- 2D --
201
202 !-----------------------------------------------------------------------------
203 !> Initialize a object to evaluate numerical error for 2D field
204!OCL SERIAL
205 subroutine meshfield_analysis_numerror_2d_init( this, &
206 porder_error_check, log_fname_base, log_step_interval, &
207 mesh, refElem2D, &
208 set_data_lc, numerror_analysis_info )
209 implicit none
210 class(meshfieldanalysisnumerror2d), intent(inout) :: this
211 integer, intent(in) :: porder_error_check
212 character(len=*), intent(in) :: log_fname_base
213 integer, intent(in) :: log_step_interval
214 class(meshbase2d), intent(in), target :: mesh
215 type(quadrilateralelement), intent(in) :: refElem2D
216 class(meshfieldanalysisnumerrorinfobase), intent(in), target :: numerror_analysis_info
217 procedure(set_data_lc_2d) :: set_data_lc
218 !---------------------------------------------------------------------------
219
220 call this%MeshFieldAnalysisNumerrorBase%Init( &
221 porder_error_check, 2, refelem2d%Np, porder_error_check**2, &
222 log_fname_base, log_step_interval, mesh, numerror_analysis_info )
223
224 this%IntrpMat(:,:) = refelem2d%GenIntGaussLegendreIntrpMat( &
225 this%PolyOrderErrorCheck, & ! (in)
226 this%intw_intrp, this%epos_intrp(:,1), this%epos_intrp(:,2) ) ! (out)
227
228 this%mesh2D => mesh
229 this%set_data_lc => set_data_lc
230 return
231 end subroutine meshfield_analysis_numerror_2d_init
232
233!OCL SERIAL
234 subroutine meshfield_analysis_numerror_2d_evaluate( this, &
235 tstep, tsec )
236 implicit none
237 class(meshfieldanalysisnumerror2d), intent(inout) :: this
238 integer, intent(in) :: tstep
239 real(RP), intent(in) :: tsec
240 !---------------------------------------------------------------------------
241
242 call this%Evaluate_base( tstep, tsec, this%mesh2D%dom_vol, evaluate_error_core, calc_covariance_core )
243 return
244 end subroutine meshfield_analysis_numerror_2d_evaluate
245
246!-- 3D --
247
248 !-----------------------------------------------------------------------------
249 !> Initialize a object to evaluate numerical error for 3D field
250!OCL SERIAL
251 subroutine meshfield_analysis_numerror_3d_init( this, &
252 porder_error_check, log_fname_base, log_step_interval, &
253 mesh, refElem3D, &
254 set_data_lc, numerror_analysis_info )
255 implicit none
256 class(meshfieldanalysisnumerror3d), intent(inout) :: this
257 integer, intent(in) :: porder_error_check
258 character(len=*), intent(in) :: log_fname_base
259 integer, intent(in) :: log_step_interval
260 class(meshbase3d), intent(in), target :: mesh
261 type(hexahedralelement), intent(in) :: refElem3D
262 class(meshfieldanalysisnumerrorinfobase), intent(in), target :: numerror_analysis_info
263 procedure(set_data_lc_3d) :: set_data_lc
264 !---------------------------------------------------------------------------
265
266 call this%MeshFieldAnalysisNumerrorBase%Init( &
267 porder_error_check, 3, refelem3d%Np, porder_error_check**3, &
268 log_fname_base, log_step_interval, mesh, numerror_analysis_info )
269
270
271 this%IntrpMat(:,:) = refelem3d%GenIntGaussLegendreIntrpMat( &
272 this%PolyOrderErrorCheck, & ! (in)
273 this%intw_intrp, this%epos_intrp(:,1), this%epos_intrp(:,2), this%epos_intrp(:,3) ) ! (out)
274
275 this%mesh3D => mesh
276 this%set_data_lc => set_data_lc
277 return
278 end subroutine meshfield_analysis_numerror_3d_init
279
280!OCL SERIAL
281 subroutine meshfield_analysis_numerror_3d_evaluate( &
282 this, tstep, tsec )
283 implicit none
284 class(meshfieldanalysisnumerror3d), intent(inout) :: this
285 integer, intent(in) :: tstep
286 real(RP), intent(in) :: tsec
287 procedure(set_data_lc_3d) :: set_data_lc
288 !---------------------------------------------------------------------------
289
290 call this%Evaluate_base( tstep, tsec, this%mesh3D%dom_vol, evaluate_error_core, calc_covariance_core )
291 return
292 end subroutine meshfield_analysis_numerror_3d_evaluate
293
294!--- private ---------------------
295
296!OCL SERIAL
297 subroutine evaluate_error_core( base, tsec, &
298 num_error_l1_lc, num_error_l2_lc, num_error_linf_lc, &
299 numsol_mean_lc, exactsol_mean_lc )
300 implicit none
301 class(meshfieldanalysisnumerrorbase), intent(in) :: base
302 real(RP), intent(in) :: tsec
303 real(RP), intent(inout) :: num_error_l1_lc(base%var_num)
304 real(RP), intent(inout) :: num_error_l2_lc(base%var_num)
305 real(RP), intent(inout) :: num_error_linf_lc(base%var_num)
306 real(RP), intent(inout) :: numsol_mean_lc(base%var_num)
307 real(RP), intent(inout) :: exactsol_mean_lc(base%var_num)
308
309 real(RP), allocatable :: q(:,:,:)
310 real(RP), allocatable :: qexact(:,:,:)
311 real(RP), allocatable :: qexact_intrp(:,:,:)
312
313 integer :: lcdomid
314 integer :: Np, Ne
315 class(elementbase), pointer :: elem
316 class(localmeshbase), pointer :: lcmesh
317 !---------------------------------------------------------------------------
318
319 do lcdomid=1, base%mesh%LOCAL_MESH_NUM
320 call prepare_lc_data( base, lcdomid, tsec, & ! (in)
321 q, qexact, qexact_intrp, lcmesh, elem, np, ne ) ! (out)
322
323 call base%Evaluate_error_lc( &
324 num_error_l1_lc, num_error_l2_lc, num_error_linf_lc, &
325 numsol_mean_lc, exactsol_mean_lc, &
326 q, qexact, qexact_intrp, lcmesh, elem )
327
328 deallocate( q, qexact, qexact_intrp )
329 end do
330 return
331 end subroutine evaluate_error_core
332
333!OCL SERIAL
334 subroutine calc_covariance_core( base, tsec,&
335 cov_numsol_numsol_lc, cov_numsol_exactsol_lc, cov_exactsol_exactsol_lc, &
336 numsol_mean, exactsol_mean )
337 implicit none
338 class(meshfieldanalysisnumerrorbase), intent(in) :: base
339 real(RP), intent(in) :: tsec
340 real(RP), intent(inout) :: cov_numsol_numsol_lc(base%var_num)
341 real(RP), intent(inout) :: cov_numsol_exactsol_lc(base%var_num)
342 real(RP), intent(inout) :: cov_exactsol_exactsol_lc(base%var_num)
343 real(RP), intent(in) :: numsol_mean(base%var_num)
344 real(RP), intent(in) :: exactsol_mean(base%var_num)
345
346 real(RP), allocatable :: q(:,:,:)
347 real(RP), allocatable :: qexact(:,:,:)
348 real(RP), allocatable :: qexact_intrp(:,:,:)
349
350 integer :: lcdomid
351 integer :: Np, Ne
352 class(localmeshbase), pointer :: lcmesh
353 class(elementbase), pointer :: elem
354 !---------------------------------------------------------------------------
355
356 do lcdomid=1, base%mesh%LOCAL_MESH_NUM
357 call prepare_lc_data( base, lcdomid, tsec, & ! (in)
358 q, qexact, qexact_intrp, lcmesh, elem, np, ne ) ! (out)
359
360 call base%Evaluate_covariance_lc( &
361 cov_numsol_numsol_lc, cov_numsol_exactsol_lc, cov_exactsol_exactsol_lc, &
362 q, qexact, qexact_intrp, numsol_mean, exactsol_mean, lcmesh, elem )
363
364 deallocate( q, qexact, qexact_intrp )
365 end do
366 return
367 end subroutine calc_covariance_core
368
369!OCL SERIAL
370 subroutine prepare_lc_data( base, lcdomid, tsec, &
371 q, qexact, qexact_intrp, lcmesh, elem, Np, Ne )
372 implicit none
373 class(meshfieldanalysisnumerrorbase), intent(in) :: base
374 integer, intent(in) :: lcdomid
375 real(RP), intent(in) :: tsec
376 real(RP), allocatable, intent(out) :: q(:,:,:)
377 real(RP), allocatable, intent(out) :: qexact(:,:,:)
378 real(RP), allocatable, intent(out) :: qexact_intrp(:,:,:)
379 class(localmeshbase), pointer, intent(out) :: lcmesh
380 class(elementbase), pointer, intent(out) :: elem
381 integer, intent(out) :: Np, Ne
382
383 class(localmesh1d), pointer :: lcmesh1D
384 class(localmesh2d), pointer :: lcmesh2D
385 class(localmesh3d), pointer :: lcmesh3D
386 !-------------------------------------------------------------------
387
388 !- Decide Np/Ne and pointers
389 select type(base)
391 lcmesh1d => base%mesh1D%lcmesh_list(lcdomid)
392 np = lcmesh1d%refElem1D%Np; ne = lcmesh1d%Ne
393 lcmesh => lcmesh1d; elem => lcmesh1d%refElem1D
395 lcmesh2d => base%mesh2D%lcmesh_list(lcdomid)
396 np = lcmesh2d%refElem2D%Np; ne = lcmesh2d%Ne
397 lcmesh => lcmesh2d; elem => lcmesh2d%refElem2D
399 lcmesh3d => base%mesh3D%lcmesh_list(lcdomid)
400 np = lcmesh3d%refElem3D%Np; ne = lcmesh3d%Ne
401 lcmesh => lcmesh3d; elem => lcmesh3d%refElem3D
402 end select
403
404 allocate( q(np,ne,base%var_num) )
405 allocate( qexact(np,ne,base%var_num) )
406 allocate( qexact_intrp(base%intrp_np,ne,base%var_num) )
407
408 !- Fill arrays via set_data_lc
409 select type(base)
411 call base%set_data_lc( q, qexact, qexact_intrp, &
412 lcmesh1d, lcmesh1d%refElem1D, base%epos_intrp, tsec )
414 call base%set_data_lc( q, qexact, qexact_intrp, &
415 lcmesh2d, lcmesh2d%refElem2D, base%epos_intrp, tsec )
417 call base%set_data_lc( q, qexact, qexact_intrp, &
418 lcmesh3d, lcmesh3d%refElem3D, base%epos_intrp, tsec )
419 end select
420 return
421 end subroutine prepare_lc_data
422
module FElib / Element / Base
module FElib / Element / hexahedron
module FElib / Element / line
module FElib / Element / Quadrilateral
module FElib / Mesh / Local 1D
module FElib / Mesh / Local 2D
module FElib / Mesh / Local 3D
module FElib / Mesh / Local, Base
module FElib / Mesh / Base 1D
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
module FElib / Mesh / Base
module FElib / Data / Statistics / numerical error
module FElib / Data / Statistics / numerical error
module FElib / Data / base
Module common / time.
Derived type representing a 1D reference element.
Derived type representing a 2D reference element.
Derived type representing a 3D reference element.
Derived type representing an arbitrary finite element.
Derived type representing a hexahedral element.
Derived type representing a line element.
Derived type representing a quadrilateral element.
Derived type representing a local mesh for 1D domain.
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)
Derived type representing a field with local mesh (base type)
Derived type to manage a computational mesh (base type for 1D domain)
Derived type to manage a computational mesh (base type for 2D domain)
Derived type to manage a computational mesh (base type for 3D domain)
Base type to manage a computational mesh.
Derived type representing a field with 1D mesh.
Derived type representing a field with 2D mesh.
Derived type representing a field with 3D mesh.
Derived type representing a field (base type)