Changeset 27813


Ignore:
Timestamp:
06/30/23 13:31:24 (21 months ago)
Author:
seroussi
Message:

NEW: added function to get list of x and y coordinates

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

Legend:

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

    r27459 r27813  
    173173        delete lat;
    174174        delete lon;
     175}
     176/*}}}*/
     177void Vertices::XYList(IssmDouble** pxcoords,IssmDouble** pycoords){/*{{{*/
     178
     179        /*output: */
     180        IssmDouble* xyz_serial=NULL;
     181
     182        /*recover my_rank:*/
     183        int my_rank=IssmComm::GetRank();
     184
     185        /*First, figure out number of vertices: */
     186        int num_vertices=this->NumberOfVertices();
     187
     188        /*Now, allocate vectors*/
     189        Vector<IssmDouble>* xlist = new Vector<IssmDouble>(num_vertices);
     190        Vector<IssmDouble>* ylist = new Vector<IssmDouble>(num_vertices);
     191
     192        /*Go through vertices, and for each vertex, object, report it cpu: */
     193        for(Object* & object : this->objects){
     194      Vertex* vertex = xDynamicCast<Vertex*>(object);
     195                xlist->SetValue(vertex->sid,vertex->GetX() ,INS_VAL);
     196                ylist->SetValue(vertex->sid,vertex->GetY(),INS_VAL);
     197        }
     198
     199        /*Assemble:*/
     200        xlist->Assemble();
     201        ylist->Assemble();
     202
     203        /*gather on cpu 0: */
     204        IssmDouble* x_serial=xlist->ToMPISerial();
     205        IssmDouble* y_serial=ylist->ToMPISerial();
     206
     207        /*Free resources: */
     208        *pxcoords = x_serial;
     209        *pycoords = y_serial;
     210        delete xlist;
     211        delete ylist;
    175212}
    176213/*}}}*/
  • issm/trunk-jpl/src/c/classes/Vertices.h

    r25508 r27813  
    3939                int   NumberOfVerticesLocalAll(void);
    4040                void  LatLonList(IssmDouble** lat,IssmDouble** lon);
     41                void  XYList(IssmDouble** pxcoords,IssmDouble** pycoords);
    4142};
    4243
Note: See TracChangeset for help on using the changeset viewer.