source: issm/trunk/src/c/objects/Gauss/GaussSeg.cpp@ 5661

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

Added objects/Gauss/GaussSeg

File size: 2.3 KB
RevLine 
[5661]1/*!\file GaussSeg.c
2 * \brief: implementation of the GaussSeg object
3 */
4
5/*Include files: {{{1*/
6#include "./../objects.h"
7/*}}}*/
8
9/*GaussSeg constructors and destructors:*/
10/*FUNCTION GaussSeg::GaussSeg() {{{1*/
11GaussSeg::GaussSeg(){
12
13 numgauss=-1;
14
15 weights=NULL;
16 coords=NULL;
17
18 weight=UNDEF;
19 coord=UNDEF;
20}
21/*}}}*/
22/*FUNCTION GaussSeg::GaussSeg(int order) {{{1*/
23GaussSeg::GaussSeg(int order){
24
25 /*Get gauss points*/
26 numgauss=order;
27 GaussLegendreLinear(&coords,&weights,order);
28
29 /*Initialize static fields as undefinite*/
30 weight=UNDEF;
31 coord=UNDEF;
32
33}
34/*}}}*/
35/*FUNCTION GaussSeg::~GaussSeg(){{{1*/
36GaussSeg::~GaussSeg(){
37 xfree((void**)&weights);
38 xfree((void**)&coords);
39}
40/*}}}*/
41
42/*Methods*/
43/*FUNCTION GaussSeg::Echo{{{1*/
44void GaussSeg::Echo(void){
45
46 printf("GaussSeg:\n");
47 printf(" numgauss: %i\n",numgauss);
48
49 if (weights){
50 printf(" weights = [");
51 for(int i=0;i<numgauss;i++) printf(" %g\n",weights[i]);
52 printf("]\n");
53 }
54 else printf("weights = NULL\n");
55 if (coords){
56 printf(" coords = [");
57 for(int i=0;i<numgauss;i++) printf(" %g\n",coords[i]);
58 printf("]\n");
59 }
60 else printf("coords = NULL\n");
61
62 printf(" weight = %g\n",weight);
63 printf(" coord = %g\n",coord);
64
65}
66/*}}}*/
67/*FUNCTION GaussSeg::GaussCenter{{{1*/
68void GaussSeg::GaussCenter(void){
69
70 /*update static arrays*/
71 coord=0.0;
72
73}
74/*}}}*/
75/*FUNCTION GaussSeg::GaussPoint{{{1*/
76void GaussSeg::GaussPoint(int ig){
77
78 /*Check input in debugging mode*/
79 ISSMASSERT(ig>=0 && ig< numgauss);
80
81 /*update static arrays*/
82 weight=weights[ig];
83 coord=coords[ig];
84
85}
86/*}}}*/
87/*FUNCTION GaussSeg::GaussVertex{{{1*/
88void GaussSeg::GaussVertex(int iv){
89
90 /*in debugging mode: check that the default constructor has been called*/
91 ISSMASSERT(numgauss==-1);
92
93 /*update static arrays*/
94 switch(iv){
95 case 0:
96 coord=-1.0;
97 break;
98 case 1:
99 coord=1.0;
100 break;
101 default:
102 ISSMERROR("vertex index should be in [0 1]");
103
104 }
105
106}
107/*}}}*/
108/*FUNCTION GaussSeg::begin{{{1*/
109int GaussSeg::begin(void){
110
111 /*Check that this has been initialized*/
112 ISSMASSERT(numgauss>0);
113 ISSMASSERT(weights);
114 ISSMASSERT(coords);
115
116 /*return first gauss index*/
117 return 0;
118}
119/*}}}*/
120/*FUNCTION GaussSeg::end{{{1*/
121int GaussSeg::end(void){
122
123 /*Check that this has been initialized*/
124 ISSMASSERT(numgauss>0);
125 ISSMASSERT(weights);
126 ISSMASSERT(coords);
127
128 /*return last gauss index +1*/
129 return numgauss;
130}
131/*}}}*/
Note: See TracBrowser for help on using the repository browser.