Changeset 16447


Ignore:
Timestamp:
10/17/13 15:22:40 (11 years ago)
Author:
Mathieu Morlighem
Message:

NEW: fixing Updatevertex position for 2d vertical meshes

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

Legend:

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

    r16442 r16447  
    369369int  FemModel::UpdateVertexPositionsx(void){ /*{{{*/
    370370
    371         Vector<IssmDouble> *vz        = NULL;
    372         IssmDouble         *thickness = NULL;
    373         IssmDouble         *bed       = NULL;
     371        IssmDouble         *surface = NULL;
     372        IssmDouble         *bed     = NULL;
    374373
    375374        /*get vertex vectors for bed and thickness: */
    376         GetVectorFromInputsx(&thickness,this, ThicknessEnum,VertexEnum);
    377         GetVectorFromInputsx(&bed      ,this, BedEnum,      VertexEnum);
     375        GetVectorFromInputsx(&surface  ,this, SurfaceEnum,VertexEnum);
     376        GetVectorFromInputsx(&bed      ,this, BedEnum,    VertexEnum);
    378377
    379378        /*Allocate vector*/
    380         vz=new Vector<IssmDouble>(vertices->NumberOfVertices());
     379        Vector<IssmDouble> *vx=new Vector<IssmDouble>(vertices->NumberOfVertices());
     380        Vector<IssmDouble> *vy=new Vector<IssmDouble>(vertices->NumberOfVertices());
     381        Vector<IssmDouble> *vz=new Vector<IssmDouble>(vertices->NumberOfVertices());
    381382
    382383        /*Update verices new geometry: */
    383384        for(int i=0;i<vertices->Size();i++){
    384385                Vertex* vertex=(Vertex*)vertices->GetObjectByOffset(i);
    385                 vertex->UpdatePosition(vz,parameters,thickness,bed);
     386                vertex->UpdatePosition(vx,vy,vz,parameters,surface,bed);
    386387        }
    387388
    388389        /*Assemble mesh velocity*/
     390        vx->Assemble();
     391        vy->Assemble();
    389392        vz->Assemble();
    390393
    391394        /*Update element inputs*/
     395        InputUpdateFromVectorx(this,vx,VxMeshEnum,VertexPIdEnum);
     396        InputUpdateFromVectorx(this,vy,VyMeshEnum,VertexPIdEnum);
    392397        InputUpdateFromVectorx(this,vz,VzMeshEnum,VertexPIdEnum);
    393398
    394399        /*Free ressources:*/
     400        delete vx;
     401        delete vy;
    395402        delete vz;
    396403        xDelete<IssmDouble>(bed);
    397         xDelete<IssmDouble>(thickness);
     404        xDelete<IssmDouble>(surface);
    398405        return 1;
    399406}
  • issm/trunk-jpl/src/c/classes/Vertex.cpp

    r16446 r16447  
    3232        this->y            = iomodel->Data(MeshYEnum)[i];
    3333        this->z            = iomodel->Data(MeshZEnum)[i];
     34        this->meshtype     = iomodel->meshtype;
    3435
    3536        _assert_(iomodel->Data(BedEnum) && iomodel->Data(ThicknessEnum) && iomodel->numbernodetoelementconnectivity);
    36         this->sigma        = (iomodel->Data(MeshZEnum)[i]-iomodel->Data(BedEnum)[i])/(iomodel->Data(ThicknessEnum)[i]);
     37        switch(iomodel->meshtype){
     38                case Mesh3DEnum:
     39                case Mesh2DhorizontalEnum:
     40                        this->sigma = (iomodel->Data(MeshZEnum)[i]-iomodel->Data(BedEnum)[i])/(iomodel->Data(ThicknessEnum)[i]);
     41                        break;
     42                case Mesh2DverticalEnum:
     43                        this->sigma = (iomodel->Data(MeshYEnum)[i]-iomodel->Data(BedEnum)[i])/(iomodel->Data(ThicknessEnum)[i]);
     44                        break;
     45        }
     46
    3747        this->connectivity = iomodel->numbernodetoelementconnectivity[i];
    3848
     
    112122/*}}}*/
    113123/*FUNCTION Vertex::UpdatePosition {{{*/
    114 void  Vertex::UpdatePosition(Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed){
    115 
    116         IssmDouble oldz,newz;
    117         IssmDouble dt,velz;
     124void  Vertex::UpdatePosition(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* surface,IssmDouble* bed){
     125
     126        IssmDouble oldy,newy,vely;
     127        IssmDouble oldz,newz,velz;
     128        IssmDouble dt;
    118129
    119130        /*Get time stepping*/
     
    121132
    122133        /*sigma remains constant. z=bed+sigma*thickness*/
    123         oldz = this->z;
    124         newz = bed[this->pid]+sigma*thickness[this->pid];
    125         velz = (newz-oldz)/dt;
    126         this->z = newz;
    127 
    128         /*put vz in vector*/
    129         vz->SetValue(this->pid,velz,INS_VAL);
     134        if(this->meshtype==Mesh2DverticalEnum){
     135                oldy = this->y;
     136                newy = bed[this->pid]+sigma*(surface[this->pid] - bed[this->pid]);
     137                vely = (newy-oldy)/dt;
     138                this->y = newy;
     139                vy->SetValue(this->pid,vely,INS_VAL);
     140        }
     141        else{
     142                oldz = this->z;
     143                newz = bed[this->pid]+sigma*(surface[this->pid] - bed[this->pid]);
     144                velz = (newz-oldz)/dt;
     145                this->z = newz;
     146                vz->SetValue(this->pid,velz,INS_VAL);
     147        }
    130148}
    131149/*}}}*/
  • issm/trunk-jpl/src/c/classes/Vertex.h

    r16446 r16447  
    2121        public:
    2222                bool       clone;
     23                int        meshtype;
    2324                int        id;           // random index
    2425                int        sid;          // "serial" id (rank of this vertex if the dataset was on 1 cpu)
     
    4950                IssmDouble GetY(void);
    5051                IssmDouble GetZ(void);
    51                 void       UpdatePosition(Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed);
     52                void       UpdatePosition(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed);
    5253                void       DistributePids(int* ppidcount);
    5354                void       OffsetPids(int pidcount);
Note: See TracChangeset for help on using the changeset viewer.