source: issm/trunk/src/c/objects/Gauss/GaussTria.cpp@ 5630

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

Added GaussVertex method of GaussTria, very useful

File size: 3.4 KB
Line 
1/*!\file GaussTria.c
2 * \brief: implementation of the GaussTria object
3 */
4
5/*Include files: {{{1*/
6#include "./../objects.h"
7/*}}}*/
8
9/*GaussTria constructors and destructors:*/
10/*FUNCTION GaussTria::GaussTria() {{{1*/
11GaussTria::GaussTria(){
12
13 numgauss=-1;
14
15 weights=NULL;
16 coords1=NULL;
17 coords2=NULL;
18 coords3=NULL;
19
20 weight=UNDEF;
21 coord1=UNDEF;
22 coord2=UNDEF;
23 coord3=UNDEF;
24}
25/*}}}*/
26/*FUNCTION GaussTria::GaussTria(int order) {{{1*/
27GaussTria::GaussTria(int order){
28
29 /*Get gauss points*/
30 GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
31
32 /*Initialize static fields as undefinite*/
33 weight=UNDEF;
34 coord1=UNDEF;
35 coord2=UNDEF;
36 coord3=UNDEF;
37
38}
39/*}}}*/
40/*FUNCTION GaussTria::GaussTria(int order,int node1,int node2) {{{1*/
41GaussTria::GaussTria(int order,int node1,int node2){
42
43 ISSMERROR("not implemented yet");
44
45 /*Get gauss points*/
46 GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
47
48 /*Initialize static fields as undefinite*/
49 weight=UNDEF;
50 coord1=UNDEF;
51 coord2=UNDEF;
52 coord3=UNDEF;
53
54}
55/*}}}*/
56/*FUNCTION GaussTria::~GaussTria(){{{1*/
57GaussTria::~GaussTria(){
58 xfree((void**)&weights);
59 xfree((void**)&coords1);
60 xfree((void**)&coords2);
61 xfree((void**)&coords3);
62}
63/*}}}*/
64
65/*Methods*/
66/*FUNCTION GaussTria::Echo{{{1*/
67void GaussTria::Echo(void){
68
69 printf("GaussTria:\n");
70 printf(" numgauss: %i\n",numgauss);
71
72 if (weights){
73 printf(" weights = [");
74 for(int i=0;i<numgauss;i++) printf(" %g\n",weights[i]);
75 printf("]\n");
76 }
77 else printf("weights = NULL\n");
78 if (coords1){
79 printf(" coords1 = [");
80 for(int i=0;i<numgauss;i++) printf(" %g\n",coords1[i]);
81 printf("]\n");
82 }
83 else printf("coords1 = NULL\n");
84 if (coords2){
85 printf(" coords2 = [");
86 for(int i=0;i<numgauss;i++) printf(" %g\n",coords2[i]);
87 printf("]\n");
88 }
89 else printf("coords2 = NULL\n");
90 if (coords3){
91 printf(" coords3 = [");
92 for(int i=0;i<numgauss;i++) printf(" %g\n",coords3[i]);
93 printf("]\n");
94 }
95 else printf("coords3 = NULL\n");
96
97 printf(" weight = %g\n",weight);
98 printf(" coord1 = %g\n",coord1);
99 printf(" coord2 = %g\n",coord2);
100 printf(" coord3 = %g\n",coord3);
101
102}
103/*}}}*/
104/*FUNCTION GaussTria::GaussPoint{{{1*/
105void GaussTria::GaussPoint(int ig){
106
107 /*Check input in debugging mode*/
108 ISSMASSERT(ig>=0 && ig< numgauss);
109
110 /*update static arrays*/
111 weight=weights[ig];
112 coord1=coords1[ig];
113 coord2=coords2[ig];
114 coord3=coords3[ig];
115
116}
117/*}}}*/
118/*FUNCTION GaussTria::GaussVertex{{{1*/
119void GaussTria::GaussVertex(int iv){
120
121 /*in debugging mode: check that the default constructor has been called*/
122 ISSMASSERT(numgauss==-1);
123
124 /*update static arrays*/
125 switch(iv){
126 case 0:
127 coord1=1; coord2=0; coord3=0;
128 break;
129 case 1:
130 coord1=0; coord2=1; coord3=0;
131 break;
132 case 2:
133 coord1=0; coord2=0; coord3=1;
134 break;
135 default:
136 ISSMERROR("vertex index should be in [0 2]");
137
138 }
139
140}
141/*}}}*/
142/*FUNCTION GaussTria::begin{{{1*/
143int GaussTria::begin(void){
144
145 /*Check that this has been initialized*/
146 ISSMASSERT(numgauss>0);
147 ISSMASSERT(weights);
148 ISSMASSERT(coords1);
149 ISSMASSERT(coords2);
150 ISSMASSERT(coords3);
151
152 /*return first gauss index*/
153 return 0;
154}
155/*}}}*/
156/*FUNCTION GaussTria::end{{{1*/
157int GaussTria::end(void){
158
159 /*Check that this has been initialized*/
160 ISSMASSERT(numgauss>0);
161 ISSMASSERT(weights);
162 ISSMASSERT(coords1);
163 ISSMASSERT(coords2);
164 ISSMASSERT(coords3);
165
166 /*return last gauss index +1*/
167 return numgauss;
168}
169/*}}}*/
Note: See TracBrowser for help on using the repository browser.