/*!\file GaussTria.c * \brief: implementation of the GaussTria object */ /*Include files: {{{1*/ #include "./../objects.h" /*}}}*/ /*GaussTria constructors and destructors:*/ /*FUNCTION GaussTria::GaussTria() {{{1*/ GaussTria::GaussTria(){ numgauss=-1; weights=NULL; coords1=NULL; coords2=NULL; coords3=NULL; weight=UNDEF; coord1=UNDEF; coord2=UNDEF; coord3=UNDEF; } /*}}}*/ /*FUNCTION GaussTria::GaussTria(int order) {{{1*/ GaussTria::GaussTria(int order){ /*Get gauss points*/ GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order); /*Initialize static fields as undefinite*/ weight=UNDEF; coord1=UNDEF; coord2=UNDEF; coord3=UNDEF; } /*}}}*/ /*FUNCTION GaussTria::GaussTria(int index1,int index2,int order) {{{1*/ GaussTria::GaussTria(int index1,int index2,int order){ /*Intermediaties*/ double *seg_coords = NULL; double *seg_weights = NULL; int i,index3; /*Get Segment gauss points*/ numgauss=order; GaussLegendreLinear(&seg_coords,&seg_weights,numgauss); /*Allocate GaussTria fields*/ coords1=(double*)xmalloc(numgauss*sizeof(double)); coords2=(double*)xmalloc(numgauss*sizeof(double)); coords3=(double*)xmalloc(numgauss*sizeof(double)); weights=(double*)xmalloc(numgauss*sizeof(double)); /*Reverse grid1 and 2 if necessary*/ if (index1>index2){ index3=index1; index1=index2; index2=index3; for(i=0;i=0 && ig< numgauss); /*update static arrays*/ weight=weights[ig]; coord1=coords1[ig]; coord2=coords2[ig]; coord3=coords3[ig]; } /*}}}*/ /*FUNCTION GaussTria::GaussVertex{{{1*/ void GaussTria::GaussVertex(int iv){ /*in debugging mode: check that the default constructor has been called*/ ISSMASSERT(numgauss==-1); /*update static arrays*/ switch(iv){ case 0: coord1=1; coord2=0; coord3=0; break; case 1: coord1=0; coord2=1; coord3=0; break; case 2: coord1=0; coord2=0; coord3=1; break; default: ISSMERROR("vertex index should be in [0 2]"); } } /*}}}*/ /*FUNCTION GaussTria::begin{{{1*/ int GaussTria::begin(void){ /*Check that this has been initialized*/ ISSMASSERT(numgauss>0); ISSMASSERT(weights); ISSMASSERT(coords1); ISSMASSERT(coords2); ISSMASSERT(coords3); /*return first gauss index*/ return 0; } /*}}}*/ /*FUNCTION GaussTria::end{{{1*/ int GaussTria::end(void){ /*Check that this has been initialized*/ ISSMASSERT(numgauss>0); ISSMASSERT(weights); ISSMASSERT(coords1); ISSMASSERT(coords2); ISSMASSERT(coords3); /*return last gauss index +1*/ return numgauss; } /*}}}*/