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*/
|
---|
11 | GaussSeg::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*/
|
---|
23 | GaussSeg::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*/
|
---|
36 | GaussSeg::~GaussSeg(){
|
---|
37 | xfree((void**)&weights);
|
---|
38 | xfree((void**)&coords);
|
---|
39 | }
|
---|
40 | /*}}}*/
|
---|
41 |
|
---|
42 | /*Methods*/
|
---|
43 | /*FUNCTION GaussSeg::Echo{{{1*/
|
---|
44 | void 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*/
|
---|
68 | void GaussSeg::GaussCenter(void){
|
---|
69 |
|
---|
70 | /*update static arrays*/
|
---|
71 | coord=0.0;
|
---|
72 |
|
---|
73 | }
|
---|
74 | /*}}}*/
|
---|
75 | /*FUNCTION GaussSeg::GaussPoint{{{1*/
|
---|
76 | void 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*/
|
---|
88 | void 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*/
|
---|
109 | int 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*/
|
---|
121 | int 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 | /*}}}*/
|
---|