Changeset 22778


Ignore:
Timestamp:
05/15/18 13:42:52 (7 years ago)
Author:
seroussi
Message:

NEW: starting to interpolate data between ice and ocean grids

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

Legend:

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

    r20810 r22778  
    3131        this->z            = iomodel->Data("md.mesh.z")[i];
    3232        this->domaintype     = iomodel->domaintype;
     33
     34        this->latitute     = iomodel->Data("md.mesh.lat")[i];
     35        this->longitude    = iomodel->Data("md.mesh.long")[i];
    3336
    3437        switch(iomodel->domaintype){
     
    195198/*}}}*/
    196199int        Vertex::Sid(void){ return sid; }/*{{{*/
    197 /*}}}*/
    198 void       Vertex::ToXYZ(Matrix<IssmDouble>* matrix){/*{{{*/
    199 
    200         IssmDouble xyz[3];
    201         int        indices[3];
    202 
    203         if (this->clone==true) return;
    204 
    205         xyz[0]=x;
    206         xyz[1]=y;
    207         xyz[2]=z;
    208         indices[0]=0;
    209         indices[1]=1;
    210         indices[2]=2;
    211 
    212         matrix->SetValues(1,&sid,3,&indices[0],&xyz[0],INS_VAL);
    213 }
    214200/*}}}*/
    215201void       Vertex::UpdateClonePids(int* alltruepids){/*{{{*/
  • issm/trunk-jpl/src/c/classes/Vertex.h

    r20810 r22778  
    6262                void       ShowTruePids(int* borderpids);
    6363                int        Sid(void);
    64                 void       ToXYZ(Matrix<IssmDouble>* matrix);
    6564                void       UpdateClonePids(int* allborderpids);
    6665                void       UpdatePosition(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed);
  • issm/trunk-jpl/src/c/classes/Vertices.cpp

    r22004 r22778  
    180180}
    181181/*}}}*/
    182 IssmDouble* Vertices::ToXYZ(void){/*{{{*/
    183 
    184         /*intermediary: */
    185         int i;
    186         int my_rank;
    187         int num_vertices;
     182void Vertices::LatLonList(IssmDouble** plat,IssmDouble** plon){/*{{{*/
    188183
    189184        /*output: */
    190         Matrix<IssmDouble>* xyz = NULL;
    191185        IssmDouble* xyz_serial=NULL;
    192186
    193187        /*recover my_rank:*/
    194         my_rank=IssmComm::GetRank();
     188        int my_rank=IssmComm::GetRank();
    195189
    196190        /*First, figure out number of vertices: */
    197         num_vertices=this->NumberOfVertices();
    198 
    199         /*Now, allocate matrix to hold all the vertices x,y and z values: */
    200         xyz= new Matrix<IssmDouble>(num_vertices,3);
     191        int num_vertices=this->NumberOfVertices();
     192
     193        /*Now, allocate vectors*/
     194        Vector<IssmDouble>* lat = new Vector<IssmDouble>(num_vertices);
     195        Vector<IssmDouble>* lon = new Vector<IssmDouble>(num_vertices);
    201196
    202197        /*Go through vertices, and for each vertex, object, report it cpu: */
    203         for(i=0;i<this->Size();i++){
    204 
    205                 /*let vertex fill matrix: */
    206                 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
    207                 vertex->ToXYZ(xyz);
     198        for(int i=0;i<this->Size();i++){
     199                Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
     200                lat->SetValue(vertex->sid,vertex->GetLatitude() ,INS_VAL);
     201                lon->SetValue(vertex->sid,vertex->GetLongitude(),INS_VAL);
    208202        }
    209203
    210204        /*Assemble:*/
    211         xyz->Assemble();
     205        lat->Assemble();
     206        lon->Assemble();
    212207
    213208        /*gather on cpu 0: */
    214         xyz_serial=xyz->ToSerial();
    215 
     209        IssmDouble* lat_serial=lat->ToMPISerial();
     210        IssmDouble* lon_serial=lon->ToMPISerial();
     211
     212        printf("lat_serial %g %g %g \n",lat_serial[0],lat_serial[2], lat_serial[799]);
    216213        /*free ressources: */
    217         delete xyz;
    218         if(my_rank!=0)delete xyz_serial;
    219 
    220         /*return matrix: */
    221         return xyz_serial;
    222 }
    223 /*}}}*/
     214        *plat = lat_serial;
     215        *plon = lon_serial;
     216        //delete lat;
     217        //delete lon;
     218}
     219/*}}}*/
  • issm/trunk-jpl/src/c/classes/Vertices.h

    r15067 r22778  
    2525                int   NumberOfVertices(void);
    2626                void  Ranks(int* ranks);
    27                 IssmDouble* ToXYZ(void);
     27                void LatLonList(IssmDouble** lat,IssmDouble** lon);
    2828};
    2929
  • issm/trunk-jpl/src/c/cores/transient_core.cpp

    r22711 r22778  
    9393                tomitgcmcomm=parcom->GetParameterValue();
    9494                if(my_rank==0){
     95                        /*Recover fixed parameters and store them*/
    9596                        ISSM_MPI_Send(&coupling_time,1,ISSM_MPI_DOUBLE,0,10001000,tomitgcmcomm);
    9697                        ISSM_MPI_Recv(&oceangridnxsize,1,ISSM_MPI_INT,0,10001003,tomitgcmcomm,&status);
     
    102103                        oceangridy = xNew<IssmDouble>(oceangridnxsize*oceangridnysize);
    103104                        ISSM_MPI_Recv(oceangridy,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001006,tomitgcmcomm,&status);
    104 
     105                        femmodel->parameters->SetParam(oceangridx,oceangridnxsize*oceangridnysize,OceanGridXEnum);
     106                        femmodel->parameters->SetParam(oceangridy,oceangridnxsize*oceangridnysize,OceanGridYEnum);
     107
     108                        /*Exchange varying parameters for the initialization*/
    105109                        ISSM_MPI_Send(&time,1,ISSM_MPI_DOUBLE,0,10001001,tomitgcmcomm);
    106110                        ISSM_MPI_Recv(&oceantime,1,ISSM_MPI_DOUBLE,0,10001002,tomitgcmcomm,&status);
     
    162166                femmodel->parameters->SetParam(save_results,SaveResultsEnum);
    163167
    164                 if(isoceancoupling){ {{{
     168                if(isoceancoupling){ /*{{{*/
    165169                        if(VerboseSolution()) _printf0_("   ocean coupling: exchanging information\n");
    166170                        int my_rank;
    167                         int oceangridnxsize,oceangridnysize;
     171                        int oceangridnxsize,oceangridnysize,ngrids_ocean;
    168172                        IssmDouble *oceanmelt;
    169173                        IssmDouble *icebase;
     174                        IssmDouble *oceangridx;
     175                        IssmDouble *oceangridy;
    170176                        IssmDouble oceantime;
    171177                        ISSM_MPI_Comm tomitgcmcomm;
     
    180186                                ISSM_MPI_Recv(&oceantime,1,ISSM_MPI_DOUBLE,0,10001002,tomitgcmcomm,&status);
    181187                                if((oceantime - time > 0.1*yts) & (oceantime - time < -0.1*yts)) _error_("Ocean and ice time are starting to diverge");
     188
     189                                /*Recover inputs needed*/
    182190                                femmodel->parameters->FindParam(&oceangridnxsize,OceanGridNxEnum);
    183191                                femmodel->parameters->FindParam(&oceangridnysize,OceanGridNyEnum);
    184                                 oceanmelt = xNew<IssmDouble>(oceangridnxsize*oceangridnysize);
    185                                 ISSM_MPI_Recv(oceanmelt,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001007,tomitgcmcomm,&status);
    186                                 icebase = xNew<IssmDouble>(oceangridnxsize*oceangridnysize);
     192                                femmodel->parameters->FindParam(&oceangridx,&ngrids_ocean,OceanGridXEnum);
     193                                femmodel->parameters->FindParam(&oceangridy,&ngrids_ocean,OceanGridYEnum);
     194
     195                                /*Exchange information*/
     196                                oceanmelt = xNew<IssmDouble>(ngrids_ocean);
     197                                ISSM_MPI_Recv(oceanmelt,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001007,tomitgcmcomm,&status);
     198                                icebase = xNew<IssmDouble>(ngrids_ocean);
    187199                                for(int i=0;i<oceangridnxsize;i++){
    188200                                        for(int j=0;j<oceangridnysize;j++){
     
    190202                                        }
    191203                                }
    192                                 ISSM_MPI_Send(icebase,oceangridnxsize*oceangridnysize,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm);
     204                                ISSM_MPI_Send(icebase,ngrids_ocean,ISSM_MPI_DOUBLE,0,10001008,tomitgcmcomm);
     205
     206                                /*Interpolate melt onto mesh*/
     207                                IssmDouble* x_ice = NULL;
     208                                IssmDouble* y_ice = NULL;
     209                                IssmDouble* lat_ice = NULL;
     210                                IssmDouble* lon_ice = NULL;
     211                                IssmDouble* z_ice = NULL;
     212                                IssmDouble* melt_mesh = NULL;
     213                                int*        index_ice= NULL;
     214                                int*        index_ocean = NULL;
     215                                int         nels_ocean;
     216                                int         ngrids_ice=femmodel->vertices->NumberOfVertices();
     217                                lat_ice= xNew<IssmDouble>(ngrids_ice);
     218                                lon_ice= xNew<IssmDouble>(ngrids_ice);
     219                                melt_mesh= xNew<IssmDouble>(ngrids_ice);
     220                                femmodel->GetMesh(femmodel->vertices,femmodel->elements,&x_ice,&y_ice,&z_ice,&index_ice);
     221                                BamgTriangulatex(&index_ocean,&nels_ocean,oceangridx,oceangridy,ngrids_ocean);
     222                                femmodel->vertices->LatLonList(&lat_ice,&lon_ice);
     223                                InterpFromMeshToMesh2dx(&melt_mesh,index_ocean,oceangridx,oceangridy,ngrids_ocean,nels_ocean,
     224                                                        oceanmelt,ngrids_ocean,1,
     225                                                        lat_ice,lon_ice,ngrids_ice,NULL);           /*FIXME: may be wrong: y=lat x=lon*/
     226                                InputUpdateFromVectorx(femmodel,melt_mesh,BasalforcingsFloatingiceMeltingRateEnum,VertexSIdEnum);
     227                                xDelete<IssmDouble>(lat_ice);
     228                                xDelete<IssmDouble>(lon_ice);
     229                                xDelete<IssmDouble>(x_ice);
     230                                xDelete<IssmDouble>(y_ice);
     231                                xDelete<IssmDouble>(z_ice);
     232                                xDelete<IssmDouble>(melt_mesh);
     233                                xDelete<int>(index_ice);
     234                                xDelete<IssmDouble>(oceangridx);
     235                                xDelete<IssmDouble>(oceangridy);
    193236                                xDelete<IssmDouble>(oceanmelt);
    194237                                xDelete<IssmDouble>(icebase);
    195238                        }
    196239                }
    197                 }}}
     240                /*}}}*/
    198241
    199242                if(isthermal && domaintype==Domain3DEnum){
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp

    r22647 r22778  
    1616        bool dakota_analysis;
    1717        bool adolc_analysis;
     18        bool isoceancoupling;
    1819        int nnat,dummy;
    1920        int* nature=NULL;
     
    2425        iomodel->FindConstant(&materials_type,"md.materials.type");
    2526        iomodel->FindConstant(&adolc_analysis,"md.autodiff.isautodiff");
     27        iomodel->FindConstant(&isoceancoupling,"md.transient.isoceancoupling");
    2628
    2729        /*Did we already create the elements? : */
     
    232234        if (iomodel->domaintype == Domain3DsurfaceEnum) iomodel->FetchData(3,"md.mesh.lat","md.mesh.long","md.mesh.r");
    233235        else iomodel->FetchDataToInput(elements,"md.mesh.scale_factor",MeshScaleFactorEnum,1.);
     236        if (isoceancoupling) iomodel->FetchData(2,"md.mesh.lat","md.mesh.long");
    234237       
    235238        CreateNumberNodeToElementConnectivity(iomodel,solution_type);
     
    242245        iomodel->DeleteData(6,"md.mesh.x","md.mesh.y","md.mesh.z","md.geometry.base","md.geometry.thickness","md.mask.ice_levelset");
    243246        if (iomodel->domaintype == Domain3DsurfaceEnum) iomodel->DeleteData(3,"md.mesh.lat","md.mesh.long","md.mesh.r");
     247        if (isoceancoupling) iomodel->DeleteData(2,"md.mesh.lat","md.mesh.long");
    244248}
Note: See TracChangeset for help on using the changeset viewer.