source: issm/oecreview/Archive/14312-15392/ISSM-14778-14779.diff@ 15393

Last change on this file since 15393 was 15393, checked in by Mathieu Morlighem, 12 years ago

NEW: adding Archive/14312-15392 for oecreview

File size: 5.4 KB
  • ../trunk-jpl/src/c/classes/gauss/GaussTria.cpp

     
    9292        xDelete<double>(seg_weights);
    9393}
    9494/*}}}*/
     95/*FUNCTION GaussTria::GaussTria(int index,double r1,double r2,int order) {{{*/
     96GaussTria::GaussTria(int index,IssmDouble r1,IssmDouble r2,bool mainlyfloating,int order){
     97
     98        /*
     99         *  ^
     100         *  |
     101         * 1|\
     102         *  |  \
     103         *  |    \
     104         *  |      \
     105         *  |        \
     106         *  |          \
     107         *  |    +(x,y)  \
     108         *  |              \
     109         *  +---------------+-->
     110         *  0               1
     111         *
     112         */
     113        int         ig;
     114        IssmDouble x,y;
     115        IssmDouble xy_list[3][2];
     116
     117        if(mainlyfloating){
     118                /*Get gauss points*/
     119                GaussLegendreTria(&this->numgauss,&this->coords1,&this->coords2,&this->coords3,&this->weights,order);
     120
     121                xy_list[0][0]=0;  xy_list[0][1]=0;
     122                xy_list[1][0]=r1; xy_list[1][1]=0;
     123                xy_list[2][0]=0;  xy_list[2][1]=r2;
     124
     125                for(ig=0;ig<this->numgauss;ig++){
     126                        x = this->coords1[ig]*xy_list[0][0] + this->coords2[ig]*xy_list[1][0] + this->coords3[ig]*xy_list[2][0];
     127                        y = this->coords1[ig]*xy_list[0][1] + this->coords2[ig]*xy_list[1][1] + this->coords3[ig]*xy_list[2][1];
     128
     129                        switch(index){
     130                                case 0:
     131                                        this->coords1[ig] = 1.-x-y;
     132                                        this->coords2[ig] = x;
     133                                        this->coords3[ig] = y;
     134                                        break;
     135                                case 1:
     136                                        this->coords1[ig] = y;
     137                                        this->coords2[ig] = 1.-x-y;
     138                                        this->coords3[ig] = x;
     139                                        break;
     140                                case 2:
     141                                        this->coords1[ig] = x;
     142                                        this->coords2[ig] = y;
     143                                        this->coords3[ig] = 1.-x-y;
     144                                        break;
     145                                default:
     146                                        _error_("index "<<index<<" not supported yet");
     147                        }
     148                        this->weights[ig] = this->weights[ig]*r1*r2;
     149                }
     150        }
     151        else{
     152                /*Double number of gauss points*/
     153                GaussTria *gauss1    = NULL;
     154                GaussTria *gauss2    = NULL;
     155                gauss1=new GaussTria(order);
     156                gauss2=new GaussTria(order);
     157
     158                xy_list[0][0]=r1; xy_list[0][1]=0;
     159                xy_list[1][0]=0;  xy_list[1][1]=1.;
     160                xy_list[2][0]=0;  xy_list[2][1]=r2;
     161
     162                        //gauss1->Echo();
     163                for(ig=0;ig<gauss1->numgauss;ig++){
     164                        x = gauss1->coords1[ig]*xy_list[0][0] + gauss1->coords2[ig]*xy_list[1][0] + gauss1->coords3[ig]*xy_list[2][0];
     165                        y = gauss1->coords1[ig]*xy_list[0][1] + gauss1->coords2[ig]*xy_list[1][1] + gauss1->coords3[ig]*xy_list[2][1];
     166
     167                        switch(index){
     168                                case 0:
     169                                        gauss1->coords1[ig] = 1.-x-y;
     170                                        gauss1->coords2[ig] = x;
     171                                        gauss1->coords3[ig] = y;
     172                                        break;
     173                                case 1:
     174                                        gauss1->coords1[ig] = y;
     175                                        gauss1->coords2[ig] = 1.-x-y;
     176                                        gauss1->coords3[ig] = x;
     177                                        break;
     178                                case 2:
     179                                        gauss1->coords1[ig] = x;
     180                                        gauss1->coords2[ig] = y;
     181                                        gauss1->coords3[ig] = 1.-x-y;
     182                                        break;
     183                                default:
     184                                        _error_("index "<<index<<" not supported yet");
     185                        }
     186                        gauss1->weights[ig] = gauss1->weights[ig]*r1*(1-r2);
     187                }
     188                        //gauss1->Echo();
     189                xy_list[0][0]=r1; xy_list[0][1]=0;
     190                xy_list[1][0]=1.; xy_list[1][1]=0;
     191                xy_list[2][0]=0;  xy_list[2][1]=1.;
     192
     193                        //gauss2->Echo();
     194                for(ig=0;ig<gauss2->numgauss;ig++){
     195                        x = gauss2->coords1[ig]*xy_list[0][0] + gauss2->coords2[ig]*xy_list[1][0] + gauss2->coords3[ig]*xy_list[2][0];
     196                        y = gauss2->coords1[ig]*xy_list[0][1] + gauss2->coords2[ig]*xy_list[1][1] + gauss2->coords3[ig]*xy_list[2][1];
     197
     198                        switch(index){
     199                                case 0:
     200                                        gauss2->coords1[ig] = 1.-x-y;
     201                                        gauss2->coords2[ig] = x;
     202                                        gauss2->coords3[ig] = y;
     203                                        break;
     204                                case 1:
     205                                        gauss2->coords1[ig] = y;
     206                                        gauss2->coords2[ig] = 1.-x-y;
     207                                        gauss2->coords3[ig] = x;
     208                                        break;
     209                                case 2:
     210                                        gauss2->coords1[ig] = x;
     211                                        gauss2->coords2[ig] = y;
     212                                        gauss2->coords3[ig] = 1.-x-y;
     213                                        break;
     214                                default:
     215                                        _error_("index "<<index<<" not supported yet");
     216                        }
     217                        gauss2->weights[ig] = gauss2->weights[ig]*(1-r1);
     218                }
     219
     220                this->numgauss = gauss1->numgauss + gauss2->numgauss;
     221                this->coords1=xNew<IssmPDouble>(this->numgauss);
     222                this->coords2=xNew<IssmPDouble>(this->numgauss);
     223                this->coords3=xNew<IssmPDouble>(this->numgauss);
     224                this->weights=xNew<IssmPDouble>(this->numgauss);
     225
     226                for(ig=0;ig<gauss1->numgauss;ig++){ // Add the first triangle gauss points
     227                        this->coords1[ig]=gauss1->coords1[ig];
     228                        this->coords2[ig]=gauss1->coords2[ig];
     229                        this->coords3[ig]=gauss1->coords3[ig];
     230                        this->weights[ig]=gauss1->weights[ig];
     231                }
     232                for(ig=0;ig<gauss2->numgauss;ig++){ // Add the second triangle gauss points
     233                        this->coords1[gauss1->numgauss+ig]=gauss2->coords1[ig];
     234                        this->coords2[gauss1->numgauss+ig]=gauss2->coords2[ig];
     235                        this->coords3[gauss1->numgauss+ig]=gauss2->coords3[ig];
     236                        this->weights[gauss1->numgauss+ig]=gauss2->weights[ig];
     237                }
     238
     239                /*Delete gauss points*/
     240                delete gauss1;
     241                delete gauss2;
     242        }
     243
     244        /*Initialize static fields as undefined*/
     245        weight=UNDEF;
     246        coord1=UNDEF;
     247        coord2=UNDEF;
     248        coord3=UNDEF;
     249}
     250/*}}}*/
    95251/*FUNCTION GaussTria::~GaussTria(){{{*/
    96252GaussTria::~GaussTria(){
    97253        xDelete<IssmPDouble>(weights);
  • ../trunk-jpl/src/c/classes/gauss/GaussTria.h

     
    3131                GaussTria();
    3232                GaussTria(int order);
    3333                GaussTria(int index1,int index2,int order);
     34                GaussTria(int index,IssmDouble r1, IssmDouble r2,bool maintlyfloating,int order);
    3435                ~GaussTria();
    3536
    3637                /*Methods*/
Note: See TracBrowser for help on using the repository browser.