Ignore:
Timestamp:
06/07/17 10:50:54 (8 years ago)
Author:
Eric.Larour
Message:

CHG: merged branch back to trunk-jpl 21754.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-larour-NatGeoScience2016/src/c/analyses/ExtrapolationAnalysis.cpp

    r20690 r21759  
    8484
    8585        /*Intermediaries */
    86         int     dim, domaintype, extrapolationcase;
    87         int     i,row,col,stabilization;
    88         bool    extrapolatebydiffusion;
    89         IssmDouble Jdet,D_scalar,h;
    90         IssmDouble norm_dlsf;
    91         IssmDouble hx,hy,hz,kappa;
    92         IssmDouble*     xyz_list = NULL;
    93         Element*                workelement=NULL;
     86        bool          extrapolatebydiffusion = true;
     87        int           dim, domaintype, extrapolationcase;
     88        int           i,row,col,stabilization;
     89        IssmDouble  Jdet,D_scalar,h;
     90        IssmDouble  norm_dlsf;
     91        IssmDouble  hx,hy,hz,kappa;
     92        IssmDouble *xyz_list    = NULL;
     93        Element    *workelement = NULL;
    9494
    9595        /*Get problem case*/
     
    102102                case 1: case 2: case 3: workelement=element; break;
    103103        }
     104
    104105        /* get extrapolation dimension */
    105106        workelement->FindParam(&domaintype,DomainTypeEnum);
    106107        switch(domaintype){
    107                 case Domain2DverticalEnum: dim=1; break;
     108                case Domain2DverticalEnum:   dim=1; break;
    108109                case Domain2DhorizontalEnum: dim=2; break;
    109                 case Domain3DEnum: dim=3; break;
     110                case Domain3DEnum:           dim=3; break;
     111      default: _error_("not supported yet");
    110112        }
    111113
     
    117119        IssmDouble*    B      = xNew<IssmDouble>(dim*numnodes);
    118120        IssmDouble*    Bprime = xNew<IssmDouble>(dim*numnodes);
    119         IssmDouble*             D         = xNew<IssmDouble>(dim*dim);
    120         IssmDouble*             dlsf = xNew<IssmDouble>(dim);
    121         IssmDouble*             normal= xNew<IssmDouble>(dim);
     121        IssmDouble*             dlsf   = xNew<IssmDouble>(dim);
     122        IssmDouble*             normal = xNew<IssmDouble>(dim);
     123   IssmDouble*          D           = xNewZeroInit<IssmDouble>(dim*dim);
    122124
    123125        /*Retrieve all inputs and parameters*/
     
    126128        workelement->GetVerticesCoordinates(&xyz_list);
    127129
     130        /* In 3d we are going to extrude using horizontal diffusion. Since the layers are 3d,
     131         * we change the geometry of the element to make it flat. That way, the diffusion is
     132         * handled along the layers
     133         */
     134        if(element->ObjectEnum()==PentaEnum){
     135                for(i=0;i<3;i++) xyz_list[3*i+2] = 0.;
     136                for(i=3;i<6;i++) xyz_list[3*i+2] = 1.;
     137        }
     138
    128139        /* Start  looping on the number of gaussian points: */
    129140        Gauss* gauss=workelement->NewGauss(2);
    130         for(int ig=gauss->begin();ig<gauss->end();ig++){/*{{{*/
     141        for(int ig=gauss->begin();ig<gauss->end();ig++){
    131142                gauss->GaussPoint(ig);
    132143
     
    137148                D_scalar=gauss->weight*Jdet;
    138149
    139                 extrapolatebydiffusion=true;
    140150                if(extrapolatebydiffusion){
    141                         /* diffuse values outward */
    142                         for(row=0;row<dim;row++)
    143                                 for(col=0;col<dim;col++)
    144                                         if(row==col && row<2) //extrapolate only in xy-plane
    145                                                 D[row*dim+col] = D_scalar;
    146                                         else
    147                                                 D[row*dim+col] = 0.;
     151
     152                        /* diffuse values outward only along the xy-plane*/
     153         for(int i=0;i<2;i++) D[i*dim+i] = D_scalar;
    148154
    149155                        TripleMultiply(Bprime,dim,numnodes,1,
     
    180186                                                &Ke->values[0],1);
    181187
    182                         /* stabilization *//*{{{*/
     188                        /* stabilization */
    183189                        /* do not use streamline upwinding for extrapolation: it yields oscillating results due to diffusion along normal direction, but none across */
    184190                        stabilization=1;
     
    200206                                                        &Ke->values[0],1);
    201207                        }
    202                         /*}}}*/
    203208                }
    204         }/*}}}*/
     209        }
    205210
    206211        /*Clean up and return*/
     
    217222}/*}}}*/
    218223ElementVector* ExtrapolationAnalysis::CreatePVector(Element* element){/*{{{*/
    219 
    220         /*Intermediaries */
    221         Element* workelement=NULL;
    222 
    223         /*Get problem dimension*/
    224         int extrapolationcase=GetExtrapolationCase(element);
    225         switch(extrapolationcase){
    226                 case 0:
    227                         if(!element->IsOnBase()) return NULL;
    228                         workelement = element->SpawnBasalElement();
    229                         break;
    230                 case 1: case 2: case 3: workelement=element; break;
    231         }
    232 
    233         /*Fetch number of nodes */
    234         int numnodes = workelement->GetNumberOfNodes();
    235 
    236         /*Initialize Element vector*/
    237         ElementVector* pe = workelement->NewElementVector();
    238         for(int i=0;i<numnodes;i++)
    239                 pe->values[i]=0.;
    240 
    241         if(extrapolationcase==0){workelement->DeleteMaterials(); delete workelement;};
    242         return pe;
     224        return NULL;
     225
    243226}/*}}}*/
    244227void           ExtrapolationAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss, int dim){/*{{{*/
     
    326309        int domaintype, extrapolationvariable;
    327310        int extrapolationcase;
     311
    328312        element->FindParam(&domaintype,DomainTypeEnum);
    329313        switch(domaintype){
    330                 case Domain2DverticalEnum: extrapolationcase=0; break;
    331                 case Domain2DhorizontalEnum: extrapolationcase=1;break;
    332                 case Domain3DEnum:  
     314                case Domain2DverticalEnum:   extrapolationcase=0; break;
     315                case Domain2DhorizontalEnum: extrapolationcase=1; break;
     316                case Domain3DEnum:
    333317                        element->FindParam(&extrapolationvariable, ExtrapolationVariableEnum);
    334                         if(extrapolationvariable==ThicknessEnum) extrapolationcase=2; // scalar fields that are constant along z-axis
    335                         else extrapolationcase=3; // scalar fields that vary along z-axis
     318                        if(extrapolationvariable==ThicknessEnum){
     319            extrapolationcase=2; // scalar fields that are constant along z-axis
     320         }
     321                        else{
     322            extrapolationcase=3; // scalar fields that vary along z-axis
     323         }
    336324                        break;
    337325        }
Note: See TracChangeset for help on using the changeset viewer.