Changeset 16762


Ignore:
Timestamp:
11/14/13 12:15:52 (11 years ago)
Author:
Mathieu Morlighem
Message:

BUG: fixed issues for higher order elements and trying to get Tiling HO SSA to work

Location:
issm/trunk-jpl/src/c
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp

    r16756 r16762  
    947947                        return;
    948948                case L1L2ApproximationEnum:
    949                         InputUpdateFromSolutionHO(solution,element);
     949                        InputUpdateFromSolutionSSA(solution,element);
    950950                        return;
    951                 case SSAHOApproximationEnum: case HOFSApproximationEnum: case SSAFSApproximationEnum:
    952                         /*the elements around will create the solution*/
     951                case SSAHOApproximationEnum:
     952                        InputUpdateFromSolutionSSAHO(solution,element);
     953                        return;
     954                case HOFSApproximationEnum:
     955                        _error_("not implemented yet");
     956                case SSAFSApproximationEnum:
     957                        _error_("not implemented yet");
    953958                        return;
    954959                default:
     
    975980        switch(meshtype){
    976981                case Mesh2DhorizontalEnum:
    977                         element->GetInputListOnNodes(thickness,ThicknessEnum);
     982                        element->GetInputListOnVertices(thickness,ThicknessEnum);
    978983                        for(i=0;i<numvertices;i++) pressure[i]=rho_ice*g*thickness[i];
    979984                        break;
    980985                case Mesh3DEnum:
    981986                        element->GetVerticesCoordinates(&xyz_list);
    982                         element->GetInputListOnNodes(surface,SurfaceEnum);
     987                        element->GetInputListOnVertices(surface,SurfaceEnum);
    983988                        for(i=0;i<numvertices;i++) pressure[i]=rho_ice*g*(surface[i]-xyz_list[i*3+2]);
    984989                        break;
     
    9961001                        break;
    9971002                case Mesh3DEnum:
    998                         if(!element->IsOnBed()) return;
     1003                        if(!element->IsOnBed()){xDelete<IssmDouble>(xyz_list); return;}
    9991004                        basalelement=element->SpawnBasalElement();
    10001005                        break;
     
    12251230        xDelete<int>(cs_list);
    12261231}/*}}}*/
     1232void StressbalanceAnalysis::InputUpdateFromSolutionSSAHO(IssmDouble* solution,Element* element){/*{{{*/
     1233
     1234        int         i,meshtype;
     1235        IssmDouble  rho_ice,g;
     1236        int*        SSAdoflist = NULL;
     1237        int*        HOdoflist  = NULL;
     1238        IssmDouble* xyz_list   = NULL;
     1239
     1240        /*we have to add results of this element for HO and results from the element
     1241         * at base for SSA, so we need to have the pointer toward the basal element*/
     1242        Element* basalelement=element->GetBasalElement();
     1243        if(basalelement->ObjectEnum()!=PentaEnum){
     1244                _error_("Coupling not supported for "<<EnumToStringx(basalelement->ObjectEnum()));
     1245        }
     1246
     1247        /*Fetch number of nodes and dof for this finite element*/
     1248        int numnodes = element->GetNumberOfNodes();
     1249        int numdof   = numnodes*2;
     1250        int numdof2d = numnodes;/*FIXME: only works for Penta*/
     1251
     1252        /*Fetch dof list and allocate solution vectors*/
     1253        basalelement->GetDofList(&SSAdoflist,SSAApproximationEnum,GsetEnum);
     1254        element->GetDofList(     &HOdoflist, HOApproximationEnum, GsetEnum);
     1255        IssmDouble* HOvalues  = xNew<IssmDouble>(numdof);
     1256        IssmDouble* SSAvalues = xNew<IssmDouble>(numdof);
     1257        IssmDouble* vx        = xNew<IssmDouble>(numnodes);
     1258        IssmDouble* vy        = xNew<IssmDouble>(numnodes);
     1259        IssmDouble* vz        = xNew<IssmDouble>(numnodes);
     1260        IssmDouble* vel       = xNew<IssmDouble>(numnodes);
     1261        IssmDouble* pressure  = xNew<IssmDouble>(numnodes);
     1262        IssmDouble* surface   = xNew<IssmDouble>(numnodes);
     1263
     1264        /*Use the dof list to index into the solution vector: */
     1265        for(i=0;i<numdof2d;i++){
     1266                HOvalues[i]  = solution[HOdoflist[i]];
     1267                SSAvalues[i] = solution[SSAdoflist[i]];
     1268        }
     1269        for(i=numdof2d;i<numdof;i++){
     1270                HOvalues[i]  = solution[HOdoflist[i]];
     1271                SSAvalues[i] = SSAvalues[i-numdof2d];
     1272        }
     1273
     1274        /*Transform solution in Cartesian Space*/
     1275        basalelement->TransformSolutionCoord(SSAvalues,XYEnum);
     1276        element->TransformSolutionCoord(HOvalues,XYEnum);
     1277
     1278        /*Ok, we have vx and vy in values, fill in vx and vy arrays: */
     1279        for(i=0;i<numnodes;i++){
     1280                vx[i]=SSAvalues[i*2+0]+HOvalues[i*2+0];
     1281                vy[i]=SSAvalues[i*2+1]+HOvalues[i*2+1];
     1282
     1283                /*Check solution*/
     1284                if(xIsNan<IssmDouble>(vx[i])) _error_("NaN found in solution vector");
     1285                if(xIsNan<IssmDouble>(vy[i])) _error_("NaN found in solution vector");
     1286        }
     1287
     1288        /*Get Vz and compute vel*/
     1289        element->GetInputListOnNodes(&vz[0],VzEnum,0.);
     1290        for(i=0;i<numnodes;i++) vel[i]=sqrt(vx[i]*vx[i] + vy[i]*vy[i] + vz[i]*vz[i]);
     1291
     1292        /*For pressure: we have not computed pressure in this analysis, for this element. We are in 2D,
     1293         *so the pressure is just the pressure at the bedrock: */
     1294        rho_ice = element->GetMaterialParameter(MaterialsRhoIceEnum);
     1295        g       = element->GetMaterialParameter(ConstantsGEnum);
     1296        element->GetVerticesCoordinates(&xyz_list);
     1297        element->GetInputListOnNodes(&surface[0],SurfaceEnum);
     1298        for(i=0;i<numnodes;i++) pressure[i]=rho_ice*g*(surface[i]-xyz_list[i*3+2]);
     1299
     1300        /*Now, we have to move the previous Vx and Vy inputs  to old
     1301         * status, otherwise, we'll wipe them off: */
     1302        element->InputChangeName(VxEnum,VxPicardEnum);
     1303        element->InputChangeName(VyEnum,VyPicardEnum);
     1304        element->InputChangeName(PressureEnum,PressurePicardEnum);
     1305
     1306        /*Add vx and vy as inputs to the tria element: */
     1307        element->AddInput(VxEnum,vx,P1Enum);
     1308        element->AddInput(VyEnum,vy,P1Enum);
     1309        element->AddBasalInput(VelEnum,vel,P1Enum);
     1310        element->AddBasalInput(PressureEnum,pressure,P1Enum);
     1311
     1312        /*Free ressources:*/
     1313        xDelete<IssmDouble>(surface);
     1314        xDelete<IssmDouble>(pressure);
     1315        xDelete<IssmDouble>(vel);
     1316        xDelete<IssmDouble>(vz);
     1317        xDelete<IssmDouble>(vy);
     1318        xDelete<IssmDouble>(vx);
     1319        xDelete<IssmDouble>(xyz_list);
     1320        xDelete<IssmDouble>(SSAvalues);
     1321        xDelete<IssmDouble>(HOvalues);
     1322        xDelete<int>(SSAdoflist);
     1323        xDelete<int>(HOdoflist);
     1324}/*}}}*/
  • TabularUnified issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.h

    r16727 r16762  
    2525                void InputUpdateFromSolutionHO(IssmDouble* solution,Element* element);
    2626                void InputUpdateFromSolutionSSA(IssmDouble* solution,Element* element);
     27                void InputUpdateFromSolutionSSAHO(IssmDouble* solution,Element* element);
    2728};
    2829#endif
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/Element.h

    r16761 r16762  
    5353                virtual void   TransformSolutionCoord(IssmDouble* values,int transformenum)=0;
    5454                virtual void   TransformSolutionCoord(IssmDouble* values,int* transformenum_list)=0;
     55                virtual Element* GetBasalElement(void)=0;
    5556                virtual void    GetDofList(int** pdoflist,int approximation_enum,int setenum)=0;
    5657                virtual void    GetDofListVelocity(int** pdoflist,int setenum)=0;
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r16754 r16762  
    10291029/*}}}*/
    10301030/*FUNCTION Penta::GetBasalElement{{{*/
    1031 Penta* Penta::GetBasalElement(void){
     1031Element* Penta::GetBasalElement(void){
    10321032
    10331033        /*Output*/
     
    52155215       
    52165216        /*get basal element, needed for basal watercolumn*/
    5217         pentabase=this->GetBasalElement();
     5217        pentabase=(Penta*)this->GetBasalElement();
    52185218       
    52195219        this->GetInputListOnVertices(&enthalpy[0],EnthalpyEnum);
     
    69886988
    69896989        /*Find penta on bed as HO must be coupled to the dofs on the bed: */
    6990         Penta* pentabase=GetBasalElement();
     6990        Penta* pentabase=(Penta*)GetBasalElement();
    69916991        Tria*  tria=pentabase->SpawnTria(0); //lower face is 0, upper face is 1.
    69926992
     
    71837183
    71847184        /*Find penta on bed as FS must be coupled to the dofs on the bed: */
    7185         Penta* pentabase=GetBasalElement();
     7185        Penta* pentabase=(Penta*)GetBasalElement();
    71867186        Tria* tria=pentabase->SpawnTria(0); //lower face is 0, upper face is 1.
    71877187
     
    76187618
    76197619        /*Find penta on bed as this is a SSA elements: */
    7620         pentabase=GetBasalElement();
     7620        pentabase=(Penta*)GetBasalElement();
    76217621        tria=pentabase->SpawnTria(0); //lower face is 0, upper face is 1.
    76227622
     
    77707770
    77717771        /*Find penta on bed as this is a SSA elements: */
    7772         pentabase=GetBasalElement();
     7772        pentabase=(Penta*)GetBasalElement();
    77737773        tria=pentabase->SpawnTria(0); //lower face is 0, upper face is 1.
    77747774
     
    99829982        /*OK, we have to add results of this element for HO
    99839983         * and results from the penta at base for SSA. Now recover results*/
    9984         penta=GetBasalElement();
     9984        penta=(Penta*)GetBasalElement();
    99859985
    99869986        /*Get dof listof this element (HO dofs) and of the penta at base (SSA dofs): */
     
    1007510075        /*OK, we have to add results of this element for SSA
    1007610076         * and results from the penta at base for SSA. Now recover results*/
    10077         penta=GetBasalElement();
     10077        penta=(Penta*)GetBasalElement();
    1007810078
    1007910079        /*Get dof listof this element (SSA dofs) and of the penta at base (SSA dofs): */
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/Penta.h

    r16761 r16762  
    8585                void   Delta18oParameterization(void);
    8686                void   EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure);
     87                Element* GetBasalElement(void);
    8788                void     GetDofList(int** pdoflist,int approximation_enum,int setenum);
    8889                void     GetDofListVelocity(int** pdoflist,int setenum);
     
    228229                void           GetZeroLevelsetCoordinates(IssmDouble* xyz_zero,IssmDouble xyz_list[6][3],int levelsetenum);
    229230                Penta*         GetLowerElement(void);
    230                 Penta*         GetBasalElement(void);
    231231                void           InputChangeName(int input_enum, int enum_type_old);
    232232                void             InputExtrude(int enum_type,int object_type);
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/Seg.h

    r16761 r16762  
    8787                void        FindParam(IssmDouble* pvalue,int paramenum);
    8888                int         FiniteElement(void);
     89                Element*    GetBasalElement(void){_error_("not implemented yet");};
    8990                void        GetDofList(int** pdoflist,int approximation_enum,int setenum){_error_("not implemented yet");};
    9091                void        GetDofListVelocity(int** pdoflist,int setenum){_error_("not implemented yet");};
  • TabularUnified issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r16761 r16762  
    8383                void        FindParam(IssmDouble* pvalue,int paramenum);
    8484                int         FiniteElement(void);
     85                Element*    GetBasalElement(void){_error_("not implemented yet");};
    8586                void          GetDofList(int** pdoflist,int approximation_enum,int setenum);
    8687                void          GetDofListVelocity(int** pdoflist,int setenum);
Note: See TracChangeset for help on using the changeset viewer.