Changeset 16387


Ignore:
Timestamp:
10/11/13 11:48:46 (11 years ago)
Author:
Mathieu Morlighem
Message:

CHG: Fixing local coordinate system for flowband model

Location:
issm/trunk-jpl/src/c/classes/Elements
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r16382 r16387  
    21822182}
    21832183/*}}}*/
     2184/*FUNCTION Tria::EdgeOnBedIndex{{{*/
     2185int Tria::EdgeOnBedIndex(void){
     2186
     2187        IssmDouble values[NUMVERTICES];
     2188        int        indices[3][2] = {{1,2},{2,0},{0,1}};
     2189
     2190        /*Retrieve all inputs and parameters*/
     2191        GetInputListOnVertices(&values[0],MeshVertexonbedEnum);
     2192
     2193        for(int i=0;i<3;i++){
     2194                if(values[indices[i][0]] == 1. && values[indices[i][1]] == 1.){
     2195                        return i;
     2196                }
     2197        }
     2198
     2199        _printf_("list of vertices on bed: "<<values[0]<<" "<<values[1]<<" "<<values[2]);
     2200        _error_("Could not find 2 vertices on bed");
     2201}
     2202/*}}}*/
    21842203/*FUNCTION Tria::IsFloating {{{*/
    21852204bool   Tria::IsFloating(){
     
    24082427
    24092428        /*clean-up*/
     2429        delete gauss;
     2430}
     2431/*}}}*/
     2432/*FUNCTION Tria::ResetCoordinateSystem{{{*/
     2433void  Tria::ResetCoordinateSystem(void){
     2434
     2435        int        approximation;
     2436        int        numindices;
     2437        int       *indices = NULL;
     2438        IssmDouble slope;
     2439        IssmDouble xz_plane[6];
     2440
     2441        /*For FS only: we want the CS to be tangential to the bedrock*/
     2442        inputs->GetInputValue(&approximation,ApproximationEnum);
     2443        if(IsFloating() || !HasEdgeOnBed() || approximation!=FSApproximationEnum) return;
     2444
     2445        /*Get number of nodes for velocity only and base*/
     2446        int index = this->EdgeOnBedIndex();
     2447        NodeOnEdgeIndices(&numindices,&indices,index,this->VelocityInterpolation());
     2448
     2449        /*Get inputs*/
     2450        Input* slope_input=inputs->GetInput(BedSlopeXEnum); _assert_(slope_input);
     2451
     2452        /*Loop over basal nodes and update their CS*/
     2453        GaussTria* gauss = new GaussTria();
     2454        for(int i=0;i<numindices;i++){//FIXME
     2455
     2456
     2457                gauss->GaussNode(this->VelocityInterpolation(),indices[i]);
     2458
     2459                slope_input->GetInputValue(&slope,gauss);
     2460
     2461                IssmDouble theta = atan(slope);
     2462
     2463                /*New X axis                  New Z axis*/
     2464                xz_plane[0]=cos(theta);       xz_plane[3]=0.; 
     2465                xz_plane[1]=sin(theta);       xz_plane[4]=0.; 
     2466                xz_plane[2]=0.;               xz_plane[5]=1.;         
     2467
     2468                XZvectorsToCoordinateSystem(&this->nodes[indices[i]]->coord_system[0][0],&xz_plane[0]);
     2469        }
     2470
     2471        /*cleanup*/
     2472        xDelete<int>(indices);
    24102473        delete gauss;
    24112474}
  • issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r16382 r16387  
    8787                bool        HasEdgeOnBed();
    8888                void        EdgeOnBedIndices(int* pindex1,int* pindex);
     89                int         EdgeOnBedIndex();
    8990                bool        IsFloating();
    9091                bool        IsNodeOnShelfFromFlags(IssmDouble* flags);
     
    106107                void        PatchFill(int* pcount, Patch* patch);
    107108                void        PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes);
    108                 void        ResetCoordinateSystem(void){_error_("not implemented yet");};
     109                void        ResetCoordinateSystem(void);
    109110                void          SmbGradients();
    110111                IssmDouble  SurfaceArea(void);
  • issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp

    r16373 r16387  
    10381038}
    10391039/*}}}*/
     1040/*FUNCTION TriaRef::NodeOnEdgeIndices{{{*/
     1041void TriaRef::NodeOnEdgeIndices(int* pnumindices,int** pindices,int index,int finiteelement){
     1042
     1043        /*Output*/
     1044        int  numindices;
     1045        int* indices = NULL;
     1046
     1047        switch(finiteelement){
     1048                case P1Enum: case P1DGEnum: case P1bubbleEnum: case P1bubblecondensedEnum:
     1049                        numindices = 2;
     1050                        indices    = xNew<int>(numindices);
     1051                        switch(index){
     1052                                case 0:
     1053                                        indices[0] = 1;
     1054                                        indices[1] = 2;
     1055                                        break;
     1056                                case 1:
     1057                                        indices[0] = 2;
     1058                                        indices[1] = 0;
     1059                                        break;
     1060                                case 2:
     1061                                        indices[0] = 0;
     1062                                        indices[1] = 1;
     1063                                        break;
     1064                                default:
     1065                                        _error_("Edge index provided ("<<index<<") is not between 0 and 2");
     1066                        }
     1067                        break;
     1068                case P2Enum:
     1069                        numindices = 3;
     1070                        indices    = xNew<int>(numindices);
     1071                        switch(index){
     1072                                case 0:
     1073                                        indices[0] = 1;
     1074                                        indices[1] = 2;
     1075                                        indices[2] = 5;
     1076                                        break;
     1077                                case 1:
     1078                                        indices[0] = 2;
     1079                                        indices[1] = 0;
     1080                                        indices[2] = 3;
     1081                                        break;
     1082                                case 2:
     1083                                        indices[0] = 0;
     1084                                        indices[1] = 1;
     1085                                        indices[2] = 4;
     1086                                        break;
     1087                                default:
     1088                                        _error_("Edge index provided ("<<index<<") is not between 0 and 2");
     1089                        }
     1090                        break;
     1091                default:
     1092                        _error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet");
     1093        }
     1094
     1095        /*Assign output pointer*/
     1096        *pnumindices = numindices;
     1097        *pindices    = indices;
     1098}
     1099/*}}}*/
  • issm/trunk-jpl/src/c/classes/Elements/TriaRef.h

    r16373 r16387  
    5555                void GetInputDerivativeValue(IssmDouble* pp, IssmDouble* plist,IssmDouble* xyz_list, GaussTria* gauss);
    5656
     57                void NodeOnEdgeIndices(int* pnumindices,int** pindices,int index,int finiteelement);
    5758                int  NumberofNodes(void);
    5859                int  NumberofNodes(int finiteelement);
Note: See TracChangeset for help on using the changeset viewer.