source: issm/trunk/src/c/objects/Gauss/GaussPenta.cpp@ 5641

Last change on this file since 5641 was 5641, checked in by Mathieu Morlighem, 15 years ago

Added GaussPenta

File size: 5.2 KB
Line 
1/*!\file GaussPenta.c
2 * \brief: implementation of the GaussPenta object
3 */
4
5/*Include files: {{{1*/
6#include "./../objects.h"
7/*}}}*/
8
9/*GaussPenta constructors and destructors:*/
10/*FUNCTION GaussPenta::GaussPenta() {{{1*/
11GaussPenta::GaussPenta(){
12
13 numgauss=-1;
14
15 weights=NULL;
16 coords1=NULL;
17 coords2=NULL;
18 coords3=NULL;
19 coords4=NULL;
20
21 weight=UNDEF;
22 coord1=UNDEF;
23 coord2=UNDEF;
24 coord3=UNDEF;
25 coord4=UNDEF;
26}
27/*}}}*/
28/*FUNCTION GaussPenta::GaussPenta(int order_horiz,int order_vert) {{{1*/
29GaussPenta::GaussPenta(int order_horiz,int order_vert){
30
31 /*Intermediaries*/
32 int ighoriz,igvert;
33 int numgauss_horiz;
34 int numgauss_vert;
35 double *coords1_horiz = NULL;
36 double *coords2_horiz = NULL;
37 double *coords3_horiz = NULL;
38 double *weights_horiz = NULL;
39 double *coords_vert = NULL;
40 double *weights_vert = NULL;
41
42 /*Get gauss points*/
43 GaussLegendreTria(&numgauss_horiz,&coords1_horiz,&coords2_horiz,&coords3_horiz,&weights_horiz,order_horiz);
44 GaussLegendreLinear(&coords_vert,&weights_vert,order_vert);
45 numgauss_vert=order_vert;
46
47 /*Allocate GaussPenta fields*/
48 numgauss=numgauss_horiz*numgauss_vert;
49 coords1=(double*)xmalloc(numgauss*sizeof(double));
50 coords2=(double*)xmalloc(numgauss*sizeof(double));
51 coords3=(double*)xmalloc(numgauss*sizeof(double));
52 coords4=(double*)xmalloc(numgauss*sizeof(double));
53 weights=(double*)xmalloc(numgauss*sizeof(double));
54
55 /*Combine Horizontal and vertical points*/
56 for (ighoriz=0; ighoriz<numgauss_horiz; ighoriz++){
57 for (igvert=0; igvert<numgauss_vert; igvert++){
58 coords1[numgauss_vert*ighoriz+igvert]=coords1_horiz[ighoriz];
59 coords2[numgauss_vert*ighoriz+igvert]=coords2_horiz[ighoriz];
60 coords3[numgauss_vert*ighoriz+igvert]=coords3_horiz[ighoriz];
61 coords4[numgauss_vert*ighoriz+igvert]=coords_vert[igvert];
62 weights[numgauss_vert*ighoriz+igvert]=weights_horiz[ighoriz]*weights_vert[igvert];
63 }
64 }
65
66 /*Initialize static fields as undefinite*/
67 weight=UNDEF;
68 coord1=UNDEF;
69 coord2=UNDEF;
70 coord3=UNDEF;
71 coord4=UNDEF;
72
73 /*Clean up*/
74 xfree((void**)&coords1_horiz);
75 xfree((void**)&coords2_horiz);
76 xfree((void**)&coords3_horiz);
77 xfree((void**)&coords_vert);
78 xfree((void**)&weights_horiz);
79 xfree((void**)&weights_vert);
80}
81/*}}}*/
82/*FUNCTION GaussPenta::~GaussPenta(){{{1*/
83GaussPenta::~GaussPenta(){
84 xfree((void**)&weights);
85 xfree((void**)&coords1);
86 xfree((void**)&coords2);
87 xfree((void**)&coords3);
88 xfree((void**)&coords4);
89}
90/*}}}*/
91
92/*Methods*/
93/*FUNCTION GaussPenta::Echo{{{1*/
94void GaussPenta::Echo(void){
95
96 printf("GaussPenta:\n");
97 printf(" numgauss: %i\n",numgauss);
98
99 if (weights){
100 printf(" weights = [");
101 for(int i=0;i<numgauss;i++) printf(" %g\n",weights[i]);
102 printf("]\n");
103 }
104 else printf("weights = NULL\n");
105 if (coords1){
106 printf(" coords1 = [");
107 for(int i=0;i<numgauss;i++) printf(" %g\n",coords1[i]);
108 printf("]\n");
109 }
110 else printf("coords1 = NULL\n");
111 if (coords2){
112 printf(" coords2 = [");
113 for(int i=0;i<numgauss;i++) printf(" %g\n",coords2[i]);
114 printf("]\n");
115 }
116 else printf("coords2 = NULL\n");
117 if (coords3){
118 printf(" coords3 = [");
119 for(int i=0;i<numgauss;i++) printf(" %g\n",coords3[i]);
120 printf("]\n");
121 }
122 else printf("coords3 = NULL\n");
123 if (coords4){
124 printf(" coords4 = [");
125 for(int i=0;i<numgauss;i++) printf(" %g\n",coords4[i]);
126 printf("]\n");
127 }
128 else printf("coords4 = NULL\n");
129
130 printf(" weight = %g\n",weight);
131 printf(" coord1 = %g\n",coord1);
132 printf(" coord2 = %g\n",coord2);
133 printf(" coord3 = %g\n",coord3);
134 printf(" coord4 = %g\n",coord4);
135
136}
137/*}}}*/
138/*FUNCTION GaussPenta::GaussCenter{{{1*/
139void GaussPenta::GaussCenter(void){
140
141 /*update static arrays*/
142 coord1=ONETHIRD;
143 coord2=ONETHIRD;
144 coord3=ONETHIRD;
145 coord4=0.0;
146
147}
148/*}}}*/
149/*FUNCTION GaussPenta::GaussPoint{{{1*/
150void GaussPenta::GaussPoint(int ig){
151
152 /*Check input in debugging mode*/
153 ISSMASSERT(ig>=0 && ig< numgauss);
154
155 /*update static arrays*/
156 weight=weights[ig];
157 coord1=coords1[ig];
158 coord2=coords2[ig];
159 coord3=coords3[ig];
160 coord4=coords4[ig];
161
162}
163/*}}}*/
164/*FUNCTION GaussPenta::GaussVertex{{{1*/
165void GaussPenta::GaussVertex(int iv){
166
167 /*in debugging mode: check that the default constructor has been called*/
168 ISSMASSERT(numgauss==-1);
169
170 /*update static arrays*/
171 switch(iv){
172 case 0:
173 coord1=1; coord2=0; coord3=0; coord4= -1;
174 break;
175 case 1:
176 coord1=0; coord2=1; coord3=0; coord4= -1;
177 break;
178 case 2:
179 coord1=0; coord2=0; coord3=1; coord4= -1;
180 break;
181 case 3:
182 coord1=1; coord2=0; coord3=0; coord4= +1;
183 break;
184 case 4:
185 coord1=0; coord2=1; coord3=0; coord4= +1;
186 break;
187 case 5:
188 coord1=0; coord2=0; coord3=1; coord4= +1;
189 break;
190 default:
191 ISSMERROR("vertex index should be in [0 5]");
192
193 }
194
195}
196/*}}}*/
197/*FUNCTION GaussPenta::begin{{{1*/
198int GaussPenta::begin(void){
199
200 /*Check that this has been initialized*/
201 ISSMASSERT(numgauss>0);
202 ISSMASSERT(weights);
203 ISSMASSERT(coords1);
204 ISSMASSERT(coords2);
205 ISSMASSERT(coords3);
206 ISSMASSERT(coords4);
207
208 /*return first gauss index*/
209 return 0;
210}
211/*}}}*/
212/*FUNCTION GaussPenta::end{{{1*/
213int GaussPenta::end(void){
214
215 /*Check that this has been initialized*/
216 ISSMASSERT(numgauss>0);
217 ISSMASSERT(weights);
218 ISSMASSERT(coords1);
219 ISSMASSERT(coords2);
220 ISSMASSERT(coords3);
221 ISSMASSERT(coords4);
222
223 /*return last gauss index +1*/
224 return numgauss;
225}
226/*}}}*/
Note: See TracBrowser for help on using the repository browser.