Changeset 17704


Ignore:
Timestamp:
04/09/14 19:18:18 (11 years ago)
Author:
hongjuy
Message:

CHG: Assign 1 or -1 for vertices not on bed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp

    r17641 r17704  
    6464        IssmDouble*  serial_vertexfloating = NULL;
    6565        IssmDouble*  phi                   = NULL;
     66        int index;
     67        int* dof=NULL;
     68        IssmDouble* xyz_list=NULL;
    6669
    6770        /*Initialize vector with number of vertices*/
    68         int numberofvertices=vertices->NumberOfVertices();
    69         vertexgrounded=new Vector<IssmDouble>(numberofvertices);
    70         vertexfloating=new Vector<IssmDouble>(numberofvertices);
    71         phi           =xNew<IssmDouble>(numberofvertices);
     71        int numberofvertices            = vertices->NumberOfVertices();
     72        vertexgrounded                  = new Vector<IssmDouble>(numberofvertices);
     73        vertexfloating                  = new Vector<IssmDouble>(numberofvertices);
     74        phi                             = xNew<IssmDouble>(numberofvertices);
     75        IssmDouble x[numberofvertices];
     76       
     77        /*Get x coordinate for each vertex*/
     78        for(int i = 0;i<elements->Size();i++){
     79                Element* element = dynamic_cast<Element*>(elements->GetObjectByOffset(i));
     80                element->GetVerticesCoordinates(&xyz_list);
     81                element->GetDofList(&dof,FSvelocityEnum,GsetEnum);     
     82                for (int j=0;j<3;j++)   x[dof[j]]=xyz_list[3*j];
     83        }
    7284
    7385        /*Fill vector vertices_potentially_floating: */
    74         for(int i=0;i<elements->Size();i++){
     86        for(int i = 0;i<elements->Size();i++){
    7587                Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
    7688                element->FSContactMigration(vertexgrounded,vertexfloating);
     
    8092        vertexgrounded->Assemble();
    8193        vertexfloating->Assemble();
    82         serial_vertexgrounded=vertexgrounded->ToMPISerial();
    83         serial_vertexfloating=vertexfloating->ToMPISerial();
    84 
    85         for(int i=0;i<numberofvertices;i++){
     94        serial_vertexgrounded = vertexgrounded->ToMPISerial();
     95        serial_vertexfloating = vertexfloating->ToMPISerial();
     96
     97        /*find vertex on GL */
     98        for(int i = 0;i<numberofvertices;i++){
    8699                if(serial_vertexgrounded[i]==1. && serial_vertexfloating[i]==1.){
    87                         phi[i]=0.;
    88                 }
    89                 else if(serial_vertexgrounded[i]==1.){
    90                         phi[i]=1.;
    91                 }
    92                 else if(serial_vertexfloating[i]==1.){
    93                         phi[i]=-1.;
    94                 }
    95                 else{
    96                         _error_("not supported (vertexfloating="<<serial_vertexfloating[i]<<" vertexgrounded="<<serial_vertexgrounded[i]<<")");
     100                        phi[i] = 0.;
     101                        index  = i;
     102                }
     103        }
     104
     105        /*assign value for phi, grounded if >0*/
     106        for(int i = 0;i<numberofvertices;i++){
     107                if (x[i] < x[index]) {
     108                        phi[i] = 1.;
     109                }
     110                else if (x[i] > x[index]) {
     111                        phi[i] = -1.;
     112                }
     113                else if (x[i]==x[index]) {
     114                        phi[i] = 0;
    97115                }
    98116        }
Note: See TracChangeset for help on using the changeset viewer.