1 // GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege
2 //
3 // See the LICENSE.txt file for license information. Please report all
4 // issues on https://gitlab.onelab.info/getdp/getdp/issues.
5
6 #include <math.h>
7 #include "Gauss.h"
8 #include "Gauss_Quadrangle.h"
9 #include "Message.h"
10 #include "MallocUtils.h"
11
12 /* Classic Gauss Integration over a quadrangle */
13
Gauss_Quadrangle(int Nbr_Points,int Num,double * u,double * v,double * w,double * wght)14 void Gauss_Quadrangle (int Nbr_Points, int Num,
15 double *u, double *v, double *w, double *wght)
16 {
17 switch (Nbr_Points) {
18 case 1 : *u= xq1 [Num] ; *v= yq1 [Num] ; *w= 0. ; *wght= pq1 [Num] ; break ;
19 case 3 : *u= xq3 [Num] ; *v= yq3 [Num] ; *w= 0. ; *wght= pq3 [Num] ; break ;
20 case 4 : *u= xq4 [Num] ; *v= yq4 [Num] ; *w= 0. ; *wght= pq4 [Num] ; break ;
21 case 7 : *u= xq7 [Num] ; *v= yq7 [Num] ; *w= 0. ; *wght= pq7 [Num] ; break ;
22 default :
23 Message::Error("Wrong number of Gauss points for Quadrangle: "
24 "valid choices: 1, 3, 4, 7");
25 break;
26 }
27 }
28
29 /* Gauss-Legendre scheme to integrate over a quadrangle */
30
31 static int glq[MAX_LINE_POINTS] = {-1};
32 static double *glxq[MAX_LINE_POINTS], *glyq[MAX_LINE_POINTS], *glpq[MAX_LINE_POINTS];
33
GaussLegendre_Quadrangle(int Nbr_Points,int Num,double * u,double * v,double * w,double * wght)34 void GaussLegendre_Quadrangle(int Nbr_Points, int Num,
35 double *u, double *v, double *w, double *wght)
36 {
37 int i, j, index = 0, nb;
38 double pt1, pt2, wt1, wt2, dum;
39
40 nb = (int)sqrt((double)Nbr_Points);
41
42 if(nb * nb != Nbr_Points || nb > MAX_LINE_POINTS){
43 Message::Error("Number of points should be n^2 with n in [1,%d]", MAX_LINE_POINTS) ;
44 return;
45 }
46
47 if(glq[0] < 0) for(i = 0; i < MAX_LINE_POINTS; i++) glq[i] = 0;
48
49 if(!glq[nb - 1]){
50 Message::Info("Computing GaussLegendre %dX%d for Quadrangle", nb, nb);
51 glxq[nb - 1] = (double*)Malloc(Nbr_Points * sizeof(double));
52 glyq[nb - 1] = (double*)Malloc(Nbr_Points * sizeof(double));
53 glpq[nb - 1] = (double*)Malloc(Nbr_Points * sizeof(double));
54 for(i = 0; i < nb; i++) {
55 Gauss_Line(nb, i, &pt1, &dum, &dum, &wt1);
56 for(j = 0; j < nb; j++) {
57 Gauss_Line(nb, j, &pt2, &dum, &dum, &wt2);
58 glxq[nb - 1][index] = pt1;
59 glyq[nb - 1][index] = pt2;
60 glpq[nb - 1][index++] = wt1*wt2;
61 }
62 }
63 glq[nb - 1] = 1;
64 }
65
66 *u = glxq[nb - 1][Num] ; *v = glyq[nb - 1][Num] ; *w = 0. ; *wght = glpq[nb - 1][Num] ;
67 }
68
69 /* Gauss Integration over a quadrangle with a 1/R singularity over node (-1,-1,0) */
70
GaussSingularR_Quadrangle(int Nbr_Points,int Num,double * u,double * v,double * w,double * wght)71 void GaussSingularR_Quadrangle(int Nbr_Points, int Num,
72 double *u, double *v, double *w, double *wght)
73 {
74 switch (Nbr_Points) {
75 case 1 : *u= xqs1 [Num] ; *v= yqs1 [Num] ; *w= 0. ; *wght= pqs1 [Num] ; break ;
76 case 3 : *u= xqs3 [Num] ; *v= yqs3 [Num] ; *w= 0. ; *wght= pqs3 [Num] ; break ;
77 case 4 : *u= xqs4 [Num] ; *v= yqs4 [Num] ; *w= 0. ; *wght= pqs4 [Num] ; break ;
78 default :
79 Message::Error("Wrong number of (modified) Gauss Points for Quadrangle: "
80 "valid choices: 1, 3, 4");
81 break;
82 }
83 }
84