-
Notifications
You must be signed in to change notification settings - Fork 38
/
quadrature_mod.f90
1980 lines (1980 loc) · 60 KB
/
quadrature_mod.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
module quadrature_mod
!
use module_kind_types
!
implicit none
!
private
!
public :: find_valid_geometries
public :: init_geom_quadrature_rules
public :: init_face_quadrature_rules
public :: quadrature_memory_usage
!
! element_type : derived type that stores the location of the solution points
! and their respective quadrature weights within the standard
! region of a given cell geometry.
!
type, public :: element_type
real(wp), allocatable :: pts(:,:)
real(wp), allocatable :: wts(:)
end type element_type
!
! std_elem : Array giving the location of the solution points and their
! respective quadrature weights for all combinations of cell
! geometry and cell order that are possible in the current
! simulation
!
! For a given elemental geometry, this_geom,
! and its order, this_order :
!
! std_elem(this_geom,this_order)%pts(l,k) : The location of the solution
! point 'k' in the direction 'l' of
! the local coordinate system
! within the standard region of the
! current element geometry.
!
! std_elem(this_geom,this_order)%wts(k) :
! The quadrature weight of the solution point 'k' within
! the standard region of the current element geometry.
!
type(element_type), public, save, target, allocatable :: std_elem(:,:)
!
! solpts_edge : pointer to the 'n_order' 1D edge solution points
!
!real(wp), public, protected, pointer, contiguous :: solpts_edge(:) => null()
real(wp), public, protected, pointer :: solpts_edge(:) => null()
!
! face_elem : Array giving the location of the flux points and their
! respective quadrature weights for all combinations of cell
! geometry and cell order that are possible in the current
! simulation
!
! For a given face geometry, this_geom,
! and its order, this_order :
!
! face_elem(this_geom,this_order)%pts(l,k) :
! The location of the flux point 'k' in the direction
! 'l' of the local coordinate system within the
! standard region of the current face geometry.
!
! face_elem(this_geom,this_order)%wts(k) :
! The quadrature weight of the flux point 'k' within
! the standard region of the current face geometry.
!
type(element_type), public, save, target, allocatable :: face_elem(:,:)
!
!
logical(lk), public, protected, save :: geom_is_used(Geom_Min:Geom_Max)
!
interface get_triangle_weights_at_solpts
module procedure get_triangle_weights_at_solpts_DP
#ifndef DISABLE_QP
module procedure get_triangle_weights_at_solpts_QP
#endif
end interface get_triangle_weights_at_solpts
!
contains
!
!###############################################################################
!
subroutine find_valid_geometries()
!
!.. Use Statements ..
use geovar, only : cell_geom,cell_order
use order_mod, only : n_min_geom,n_max_geom,q_order
use order_mod, only : geom_solpts,geom_flxpts
use order_mod, only : maxpts,maxSP,maxFP,maxQP,maxGP
use order_mod, only : o_order,maxOP
use order_mod, only : e_order,maxEP
!
!.. Local Scalars ..
integer :: nc,ne,no,this_geom
!
continue
!
! Initialize geom_is_used to false
!
geom_is_used = fals
!
! Loop through the geometries and mark which ones are explicitly used
!
do this_geom = Geom_Min,Geom_Max
geom_is_used(this_geom) = any(cell_geom == this_geom)
end do
!
! Now go back and mark any lower dimension geometries needed by
! those geometries already marked (e.g., Geom_Edge needed by Geom_Quad)
!
! Mark Geom_Quad as used if any 3D elements with quad faces are used
!
if (any( geom_is_used([Geom_Pyra,Geom_Pris,Geom_Hexa]) )) then
geom_is_used(Geom_Quad) = true
end if
!
! Mark Geom_Tria as used if any 3D elements with triangle faces are used
!
if (any( geom_is_used([Geom_Tetr,Geom_Pyra,Geom_Pris]) )) then
geom_is_used(Geom_Tria) = true
end if
!
! Mark Geom_Edge as used if any 2D elements are used
! NOTE: This should always be true for 2D or 3D
!
if (any( geom_is_used([Geom_Tria,Geom_Quad]) )) then
geom_is_used(Geom_Edge) = true
end if
!
! Find the minimum and maximum geometry types
!
n_min_geom = minval( intseq(Geom_Min,Geom_Max) , mask=geom_is_used )
n_max_geom = maxval( intseq(Geom_Min,Geom_Max) , mask=geom_is_used )
!
! While we are here, find the maximum number of points in any cell
!
maxSP = 1
maxFP = 1
maxQP = 1
maxGP = 1
maxOP = 1
maxEP = 1
!
do nc = 1,size(cell_geom)
!
maxSP = max( maxSP , geom_solpts(cell_geom(nc),cell_order(nc)) )
maxQP = max( maxQP , geom_solpts(cell_geom(nc),q_order) )
!
maxFP = max( maxFP , geom_flxpts(cell_geom(nc),cell_order(nc)) )
maxGP = max( maxGP , geom_flxpts(cell_geom(nc),q_order) )
!
end do
!
if (o_order > 0) then
do nc = 1,size(cell_geom)
no = max(cell_order(nc),o_order)
maxOP = max( maxOP , geom_solpts(cell_geom(nc),no) )
end do
else
maxOP = maxSP
end if
!
if (e_order > 0) then
do nc = 1,size(cell_geom)
ne = max(cell_order(nc),e_order)
maxEP = max( maxEP , geom_solpts(cell_geom(nc),ne) )
end do
else
maxEP = maxSP
end if
!
maxpts = max( maxSP , maxQP , maxFP , maxGP , maxOP , maxEP )
!
end subroutine find_valid_geometries
!
!###############################################################################
!
subroutine init_geom_quadrature_rules()
!
!.. Use Statements ..
use order_mod, only : n_order,geom_solpts
use order_mod, only : n_min_geom,n_max_geom
use order_mod, only : n_min_order,n_max_order
use ovar, only : loc_solution_pts
use ovar, only : loc_triangle_pts
!
!.. Local Scalars ..
integer :: n,npts,ndim,ierr
integer :: this_geom,this_order
character(len=100) :: array_name
!
!.. Local Pointers ..
type(element_type), pointer :: this_elem
type(element_type), pointer :: edge_elem
type(element_type), pointer :: tria_elem
!
!.. Local Parameters ..
character(len=*), parameter :: pname = "init_geom_quadrature_rules"
!
continue
!
!call dump_solpts
!
! Initialize this_elem to disassociated
!
this_elem => null()
edge_elem => null()
tria_elem => null()
!
! Allocate the std_elem array
!
allocate ( std_elem(Geom_Min:Geom_Max,n_min_order:n_max_order) , &
stat=ierr , errmsg=error_message )
call alloc_error(pname,"std_elem",1,__LINE__,__FILE__,ierr,error_message)
!
! Loop through all the possible orders and get the quadrature rules
! for the most basic geometries that are used (Geom_Edge and Geom_Tria).
! We need to do this before all other geometry types because the
! remaining geometries are dependent on these quadrature rules.
! NOTE: The pts array within the type element_type is only needed for these
! two geometries (maybe tetrahedra as well) so they will be the only
! ones in which this array will be allocated and created.
!
this_geom = Geom_Edge
!
basic_geom_loop: do n = 1,2
!
basic_order_loop: do this_order = n_min_order,n_max_order
!
! Assign the pointer 'this_elem' to std_elem(this_geom,this_order)
! to simplify the remaining code in this loop and make it more legible
!
this_elem => std_elem(this_geom,this_order)
!
! Spatial dimension of the current geometry
! NOTE: Make sure that ndim is at minimum 1, primarily for Geom_Node
!
ndim = max( 1 , geom_dimen(this_geom) )
!
! Number of solution points for the current geometry/order combination
!
npts = geom_solpts(this_geom,this_order)
!
! Allocate the wts component of the current geometry/order combination
!
allocate ( this_elem%wts(1:npts) , stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(this_geom),this_order,"wts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Allocate the pts component of the current geometry/order combination
!
allocate ( this_elem%pts(1:ndim,1:npts) , &
stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(this_geom),this_order,"pts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Fill in the solution points and quadrature weights
! for an edge with the current order
!
if (this_geom == Geom_Edge) then
this_elem = get_edge_quadrature(this_order,loc_solution_pts)
else if (this_geom == Geom_Tria) then
this_elem = get_tria_quadrature(this_order,loc_triangle_pts)
end if
!
! Disassociate this_elem before continuing to the next loop combo
!
if (associated(this_elem)) this_elem => null()
!
end do basic_order_loop
!
! Change this_geom to Geom_Tria so the second pass through
! basic_order_loop works on triangle geometry
!
this_geom = Geom_Tria
!
if (.not. geom_is_used(this_geom)) exit basic_geom_loop
!
end do basic_geom_loop
!
! Loop through all the possible combinations of cell geometry and order
! and get the quadrature rules for each one
!
order_loop: do this_order = n_min_order,n_max_order
!
! Assign pointers to the edge and triangle elements of the std_elem
! array in order to simplify the remaining code in this loop and
! make it more legible.
!
edge_elem => std_elem(Geom_Edge,this_order)
tria_elem => std_elem(Geom_Tria,this_order)
!
geom_loop: do this_geom = n_min_geom,n_max_geom
!
! Cycle to the next geometry if the current one is:
! 1. not used
! 2. an edge or triangle since these have already been done
! 3. not valid
!
if (.not. geom_is_used(this_geom)) cycle geom_loop
if (any(this_geom == [Geom_Edge,Geom_Tria])) cycle geom_loop
if (all(this_geom /= Geom_Valid)) cycle geom_loop
!
!
! Assign the pointer 'this_elem' to std_elem(this_geom,this_order)
! to simplify the remaining code in this loop and make it more legible
!
this_elem => std_elem(this_geom,this_order)
!
! Spatial dimension of the current geometry
! NOTE: Make sure that ndim is at minimum 1, primarily for Geom_Node
!
ndim = max( 1 , geom_dimen(this_geom) )
!
! Number of solution points for the current geometry/order combination
!
npts = geom_solpts(this_geom,this_order)
!
! Allocate the wts component of the current geometry/order combination
!
allocate ( this_elem%wts(1:npts) , stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(this_geom),this_order,"wts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Allocate the pts component of the current geometry/order combination
!
allocate ( this_elem%pts(1:ndim,1:npts) , &
stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(this_geom),this_order,"pts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Fill in the quadrature points and weights for the
! current geometry/order combination
!
select case (this_geom)
case (Geom_Node)
!
this_elem%wts = one
!
case (Geom_Quad)
!
this_elem = get_quad_quadrature(edge_elem)
!
case (Geom_Tetr)
!
write (error_message,3) "Geom_Tetr"
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__,error_message)
this_elem = get_tetr_quadrature(this_order)
!
case (Geom_Pyra)
!
write (error_message,3) "Geom_Pyra"
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__,error_message)
this_elem = get_pyra_quadrature(this_order)
!
case (Geom_Pris)
!
write (error_message,3) "Geom_Pris"
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__,error_message)
this_elem = get_pris_quadrature(this_order)
!
case (Geom_Hexa)
!
this_elem = get_hexa_quadrature(edge_elem)
!
case default
!
write (error_message,2)
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__,error_message)
!
end select
!
! Disassociate the pointer 'this_elem' before
! continuing to the next geometry
!
if (associated(this_elem)) this_elem => null()
!
end do geom_loop
!
! Disassociate the pointers 'edge_elem' and 'tria_elem' before
! continuing to the next order
!
if (associated(edge_elem)) edge_elem => null()
if (associated(tria_elem)) tria_elem => null()
!
end do order_loop
!
! Before we leave, assign the pointer solpts_edge to its target
!
solpts_edge => std_elem(Geom_Edge,n_order)%pts(1,:)
!
! Format Statements
!
1 format ("std_elem(",a,",",i0,")%",a)
2 format (" A grid cell of an unknown geometry type was found!")
3 format (" A grid cell of geometry type '",a,"' was encountered while", &
" trying to compute the quadrature rules for each geometry type.", &
" This geometry type is currently invalid because it has not", &
" yet been fully implemented.")
!
end subroutine init_geom_quadrature_rules
!
!###############################################################################
!
subroutine init_face_quadrature_rules()
!
!.. Use Statements ..
use order_mod, only : geom_solpts
use order_mod, only : n_min_order,n_max_order
use ovar, only : loc_flux_pts
use ovar, only : loc_triangle_pts
!
!.. Local Scalars ..
integer :: n,npts,ndim,ierr
integer :: gmin,gmax,this_order
logical(lk) :: there_are_quad_faces
logical(lk) :: there_are_tria_faces
character(len=100) :: array_name
!
!.. Local Pointers ..
type(element_type), pointer :: this_elem
type(element_type), pointer :: edge_elem
!
!.. Local Parameters ..
character(len=*), parameter :: pname = "init_face_quadrature_rules"
!
continue
!
! Initialize this_elem to disassociated
!
this_elem => null()
edge_elem => null()
!
! Determine if there are any of the geometries used for this simulation
! are 3D to see if we need to find the quadrature rules for 2D faces.
!
gmin = Geom_Edge
gmax = Geom_Edge
!
there_are_tria_faces = fals
there_are_quad_faces = fals
!
if (any(geom_is_used(Geom_3D))) then
gmax = maxval( Geom_2D , mask=geom_is_used(Geom_2D) )
there_are_tria_faces = geom_is_used(Geom_Tria)
there_are_quad_faces = geom_is_used(Geom_Quad)
end if
!
! Allocate the face_elem array
!
allocate ( face_elem(gmin:gmax,n_min_order:n_max_order) , &
stat=ierr , errmsg=error_message )
call alloc_error(pname,"face_elem",1,__LINE__,__FILE__,ierr,error_message)
!
! Loop through all the possible orders and get the edge quadrature rules.
!
edge_loop: do this_order = n_min_order,n_max_order
!
! Assign the pointer 'this_elem' to face_elem(Geom_Edge,this_order)
! to simplify the remaining code in this loop and make it more legible
!
this_elem => face_elem(Geom_Edge,this_order)
!
! Spatial dimension of the current geometry
! NOTE: Make sure that ndim is at minimum 1, primarily for Geom_Node
!
ndim = max( 1 , geom_dimen(Geom_Edge) )
!
! Number of solution points for the current geometry/order combination
!
npts = geom_solpts(Geom_Edge,this_order)
!
! Allocate the wts component of the current geometry/order combination
!
allocate ( this_elem%wts(1:npts) , stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(Geom_Edge),this_order,"wts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Allocate the pts component of the current geometry/order combination
!
allocate ( this_elem%pts(1:ndim,1:npts) , stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(Geom_Edge),this_order,"pts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Fill in the solution points and quadrature weights
! for an edge with the current order
!
this_elem = get_edge_quadrature(this_order,loc_flux_pts)
!
! Disassociate this_elem before continuing to the next loop combo
!
if (associated(this_elem)) this_elem => null()
!
end do edge_loop
!
! Loop through all the possible orders and get the triangle quadrature rules
! if there are any triangle faces exist for this simulation
!
if (there_are_tria_faces) then
!
tria_loop: do this_order = n_min_order,n_max_order
!
! Assign the pointer 'this_elem' to face_elem(Geom_Tria,this_order)
! to simplify the remaining code in this loop and make it more legible
!
this_elem => face_elem(Geom_Tria,this_order)
!
! Spatial dimension of the current geometry
! NOTE: Make sure that ndim is at minimum 1, primarily for Geom_Node
!
ndim = max( 1 , geom_dimen(Geom_Tria) )
!
! Number of solution points for the current geometry/order combination
!
npts = geom_solpts(Geom_Tria,this_order)
!
! Allocate the wts component of the current geometry/order combination
!
allocate ( this_elem%wts(1:npts) , stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(Geom_Tria),this_order,"wts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Allocate the pts component of the current geometry/order combination
!
allocate ( this_elem%pts(1:ndim,1:npts) , &
stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(Geom_Tria),this_order,"pts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Fill in the solution points and quadrature weights
! for a triangle face with the current order
!
this_elem = get_tria_quadrature(this_order,loc_triangle_pts)
!
! Disassociate this_elem before continuing to the next loop combo
!
if (associated(this_elem)) this_elem => null()
!
end do tria_loop
!
end if
!
! Loop through all the possible orders and get the quad quadrature rules
! if there are any quad faces exist for this simulation
!
if (there_are_quad_faces) then
!
quad_loop: do this_order = n_min_order,n_max_order
!
! Assign a pointer to the edge element of the face_elem array in order
! to simplify the remaining code in this loop and make it more legible.
!
edge_elem => face_elem(Geom_Edge,this_order)
!
! Assign the pointer 'this_elem' to face_elem(Geom_Quad,this_order)
! to simplify the remaining code in this loop and make it more legible
!
this_elem => face_elem(Geom_Quad,this_order)
!
! Spatial dimension of the current geometry
! NOTE: Make sure that ndim is at minimum 1, primarily for Geom_Node
!
ndim = max( 1 , geom_dimen(Geom_Quad) )
!
! Number of solution points for the current geometry/order combination
!
npts = geom_solpts(Geom_Quad,this_order)
!
! Allocate the wts component of the current geometry/order combination
!
allocate ( this_elem%wts(1:npts) , stat=ierr , errmsg=error_message )
write (array_name,1) Geom_Name(Geom_Quad),this_order,"wts"
call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!!
!! Allocate the pts component of the current geometry/order combination
!!
!allocate ( this_elem%pts(1:ndim,1:npts) , &
! stat=ierr , errmsg=error_message )
!write (array_name,1) Geom_Name(Geom_Quad),this_order,"pts"
!call alloc_error(pname,array_name,1,__LINE__,__FILE__,ierr,error_message)
!
! Fill in the solution points and quadrature weights
! for a quad face with the current order
!
this_elem = get_quad_quadrature(edge_elem)
!
! Disassociate this_elem before continuing to the next loop combo
!
if (associated(this_elem)) this_elem => null()
if (associated(edge_elem)) edge_elem => null()
!
end do quad_loop
!
end if
!
! Format Statements
!
1 format ("face_elem(",a,",",i0,")%",a)
!
end subroutine init_face_quadrature_rules
!
!###############################################################################
!
pure function get_quadrature_wts(this_geom,this_order) result(return_value)
!
!.. Formal Arguments ..
integer, intent(in) :: this_geom
integer, intent(in) :: this_order
!
!.. Function Result ..
real(wp), allocatable :: return_value(:)
!
!.. Local Scalars ..
integer :: i,ierr
!
continue
!
! NEED TO FIGURE OUT WHAT DO IF QUADRATURE POINTS ARE NOT THE SAME AS THOSE
! USED TO COMPUTE THE INFORMATION STORED IN THE STD_ELEM ARRAY.
!
allocate ( return_value(1:this_order+1) , stat=ierr )
!
return_value = one/real(this_order+1,kind=wp)
!
end function get_quadrature_wts
!
!###############################################################################
!
pure function get_edge_quadrature(n,location) result(return_value)
!
use order_mod, only : geom_solpts
use polynomial_mod, only : nodes_legendre_gauss
use polynomial_mod, only : nodes_legendre_gauss_lobatto
use polynomial_mod, only : weights_legendre_gauss
use polynomial_mod, only : weights_legendre_gauss_lobatto
!
integer, intent(in) :: n
integer, intent(in) :: location
!
type(element_type) :: return_value
!
integer :: ndim,npts,ierr
!
real(qp), allocatable :: pts(:)
real(qp), allocatable :: wts(:)
real(qp), allocatable :: val_at_pts(:)
!
continue
!
ndim = geom_dimen(Geom_Edge)
npts = geom_solpts(Geom_Edge,n)
!
allocate ( pts(1:npts) , source=qzero , stat=ierr )
allocate ( wts(1:npts) , source=qzero , stat=ierr )
allocate ( val_at_pts(1:npts) , source=qzero , stat=ierr )
!
select case (location)
!
case (Legendre_Gauss)
!
! Edge quadrature using Legendre Gauss nodes
!
call nodes_legendre_gauss(npts,pts,val_at_pts)
call weights_legendre_gauss(npts,pts,val_at_pts,wts)
!
case (Legendre_Gauss_Lobatto)
!
! Edge quadrature using Legendre Gauss Lobatto nodes
!
call nodes_legendre_gauss_lobatto(n,pts,val_at_pts)
call weights_legendre_gauss_lobatto(n,val_at_pts,wts)
!
case default
!
! Default to Legendre Gauss points
!
call nodes_legendre_gauss(npts,pts,val_at_pts)
call weights_legendre_gauss(npts,pts,val_at_pts,wts)
!
end select
!
deallocate ( val_at_pts , stat=ierr )
!
allocate ( return_value%pts(1:ndim,1:npts) , source=zero , stat=ierr )
allocate ( return_value%wts(1:npts) , source=zero , stat=ierr )
!
return_value%pts(1,:) = chop( pts )
return_value%wts = chop( wts )
!
deallocate ( pts , stat=ierr )
deallocate ( wts , stat=ierr )
!
end function get_edge_quadrature
!
!###############################################################################
!
pure function get_tria_quadrature(n,location) result(return_value)
!
use order_mod, only : geom_solpts
use triangle_mod, only : TriNodes2D_AlphaOptimized
use triangle_mod, only : TriNodes2D_BarycentricLobatto
!
integer, intent(in) :: n
integer, intent(in) :: location
!
type(element_type) :: return_value
!
integer :: ndim,npts,ierr
!
real(qp), allocatable :: pts(:,:)
real(qp), allocatable :: wts(:)
!
continue
!
ndim = geom_dimen(Geom_Tria)
npts = geom_solpts(Geom_Tria,n)
!
allocate ( pts(1:ndim,1:npts) , source=qzero , stat=ierr )
allocate ( wts(1:npts) , source=qzero , stat=ierr )
!
select case (location)
!
case (AlphaOptimized_TriPoints)
!
! Alpha optimized triangle quadrature from Hesthaven and Warburton
!
pts = TriNodes2D_AlphaOptimized(n,qzero)
!
case (BarycentricLobatto_TriPoints)
!
! 1D Lobatto quadrature extrapolated to a barycentric triangle
! coordinate system
!
pts = TriNodes2D_BarycentricLobatto(n,qzero)
!
case default
!
! Default to the barycentric Lobatto quadrature
!
pts = TriNodes2D_BarycentricLobatto(n,qzero)
!
end select
!
! The method for computing the triangle quadrature weights is
! independent of the method for getting the point locations
!
wts = get_triangle_weights_at_solpts(pts)
!
allocate ( return_value%pts(1:ndim,1:npts) , source=zero , stat=ierr )
allocate ( return_value%wts(1:npts) , source=zero , stat=ierr )
!
return_value%pts = chop( pts )
return_value%wts = chop( wts )
!
deallocate ( pts , stat=ierr )
deallocate ( wts , stat=ierr )
!
end function get_tria_quadrature
!
!###############################################################################
!
pure function get_quad_quadrature(edge_elem) result(return_value)
!
use order_mod, only : geom_solpts
!
type(element_type), intent(in) :: edge_elem
!
type(element_type) :: return_value
!
integer :: i,j,l,n,ndim,npts,ierr
!
real(qp), allocatable :: pts(:,:)
real(qp), allocatable :: wts(:)
!
continue
!
n = size(edge_elem%wts) - 1
!
ndim = geom_dimen(Geom_Quad)
npts = geom_solpts(Geom_Quad,n)
!
! Compute the tensor product of the 1D solution points
!
allocate ( pts(1:ndim,1:npts) , source=qzero , stat=ierr )
!
l = 0
do j = 1,size(edge_elem%pts,dim=2)
do i = 1,size(edge_elem%pts,dim=2)
l = l + 1
pts(1,l) = real( edge_elem%pts(1,i) , kind=qp )
pts(2,l) = real( edge_elem%pts(1,j) , kind=qp )
end do
end do
!
allocate ( return_value%pts(1:ndim,1:npts) , source=zero , stat=ierr )
!
return_value%pts = chop( pts )
!
deallocate ( pts , stat=ierr )
!
! Compute the tensor product of the 1D weights
!
allocate ( wts(1:npts) , source=qzero , stat=ierr )
!
l = 0
do j = 1,size(edge_elem%wts)
do i = 1,size(edge_elem%wts)
l = l + 1
wts(l) = real( edge_elem%wts(i) , kind=qp ) * &
real( edge_elem%wts(j) , kind=qp )
end do
end do
!
allocate ( return_value%wts(1:npts) , source=zero , stat=ierr )
!
return_value%wts = chop( wts )
!
deallocate ( wts , stat=ierr )
!
end function get_quad_quadrature
!
!###############################################################################
!
pure function get_tetr_quadrature(n) result(return_value)
!
use order_mod, only : geom_solpts
!
integer, intent(in) :: n
!
type(element_type) :: return_value
!
integer :: ndim,npts,ierr
!
continue
!
ndim = geom_dimen(Geom_Tetr)
npts = geom_solpts(Geom_Tetr,n)
!
allocate ( return_value%pts(1:ndim,1:npts) , source=zero , stat=ierr )
allocate ( return_value%wts(1:npts) , source=zero , stat=ierr )
!
return_value%wts = one / real(npts,kind=wp)
!
end function get_tetr_quadrature
!
!###############################################################################
!
pure function get_pyra_quadrature(n) result(return_value)
!
use order_mod, only : geom_solpts
!
integer, intent(in) :: n
!
type(element_type) :: return_value
!
integer :: ndim,npts,ierr
!
continue
!
ndim = geom_dimen(Geom_Pyra)
npts = geom_solpts(Geom_Pyra,n)
!
allocate ( return_value%pts(1:ndim,1:npts) , source=zero , stat=ierr )
allocate ( return_value%wts(1:npts) , source=zero , stat=ierr )
!
return_value%wts = one / real(npts,kind=wp)
!
end function get_pyra_quadrature
!
!###############################################################################
!
pure function get_pris_quadrature(n) result(return_value)
!
use order_mod, only : geom_solpts
!
integer, intent(in) :: n
!
type(element_type) :: return_value
!
integer :: ndim,npts,ierr
!
continue
!
ndim = geom_dimen(Geom_Pris)
npts = geom_solpts(Geom_Pris,n)
!
allocate ( return_value%pts(1:ndim,1:npts) , source=zero , stat=ierr )
allocate ( return_value%wts(1:npts) , source=zero , stat=ierr )
!
return_value%wts = one / real(npts,kind=wp)
!
end function get_pris_quadrature
!
!###############################################################################
!
pure function get_hexa_quadrature(edge_elem) result(return_value)
!
use order_mod, only : geom_solpts
!
type(element_type), intent(in) :: edge_elem
!
type(element_type) :: return_value
!
integer :: i,j,k,l,n,ndim,npts,ierr
!
real(qp), allocatable :: pts(:,:)
real(qp), allocatable :: wts(:)
!
continue
!
n = size(edge_elem%wts) - 1
!
ndim = geom_dimen(Geom_Hexa)
npts = geom_solpts(Geom_Hexa,n)
!
! Compute the tensor product of the 1D solution points
!
allocate ( pts(1:ndim,1:npts) , source=qzero , stat=ierr )
!
l = 0
do k = 1,size(edge_elem%pts,dim=2)
do j = 1,size(edge_elem%pts,dim=2)
do i = 1,size(edge_elem%pts,dim=2)
l = l + 1
pts(1,l) = real( edge_elem%pts(1,i) , kind=qp )
pts(2,l) = real( edge_elem%pts(1,j) , kind=qp )
pts(3,l) = real( edge_elem%pts(1,k) , kind=qp )
end do
end do
end do
!
allocate ( return_value%pts(1:ndim,1:npts) , source=zero , stat=ierr )
!
return_value%pts = chop( pts )
!
deallocate ( pts , stat=ierr )
!
! Compute the tensor product of the 1D weights
!
allocate ( wts(1:npts) , source=qzero , stat=ierr )
!
l = 0
do k = 1,size(edge_elem%wts)
do j = 1,size(edge_elem%wts)
do i = 1,size(edge_elem%wts)
l = l + 1
wts(l) = real( edge_elem%wts(i) , kind=qp ) * &
real( edge_elem%wts(j) , kind=qp ) * &
real( edge_elem%wts(k) , kind=qp )
end do
end do
end do
!
allocate ( return_value%wts(1:npts) , source=zero , stat=ierr )
!
return_value%wts = chop( wts )
!
deallocate ( wts , stat=ierr )
!
end function get_hexa_quadrature
!
!###############################################################################
!
pure function get_triangle_weights_at_solpts_DP(rs) result(return_value)
!
! NOTE : This seems to fail for large n_order (>15)
!
use polynomial_mod, only : nodes_legendre_gauss
use polynomial_mod, only : weights_legendre_gauss
!
real(dp), dimension(:,:), intent(in) :: rs
!
real(dp), dimension(1:size(rs,2)) :: return_value
!
integer :: i,j,k,n,m,np
integer :: nspts,nfpts
real(dp) :: g,h,x,y
!
integer, parameter :: nquad = 20
!
real(dp), dimension(1:nquad) :: xi
real(dp), dimension(1:nquad) :: dxi
real(dp), dimension(1:nquad) :: weights
real(dp), dimension(1:size(rs,2),1:size(rs,2)) :: V
!
integer, parameter :: lp = dp
!
real(lp), parameter :: zero = 0.0_lp
real(lp), parameter :: half = 0.5_lp
real(lp), parameter :: one = 1.0_lp
!
continue
!
! On entry, r and s need to be defined on the interval [0,1]
!
nspts = size(rs,2)
nfpts = np2n(nspts) + 1
!
! Compute the coefficients of the Vandermonde matrix for
! the Lagrange polynomials using monomial basis functions
!
do n = 1,nspts