Changeset 202
- Timestamp:
- 05/04/09 10:34:57 (16 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/DataSet/DataSet.cpp
r100 r202 146 146 } 147 147 148 int DataSet::DeleteObject(int id){ 149 150 return 0; 148 int DataSet::DeleteObject(Object* object){ 149 150 vector<Object*>::iterator iterator; 151 152 iterator = find(objects.begin(), objects.end(),object); 153 154 objects.erase(iterator); 155 151 156 } 152 157 … … 293 298 } 294 299 300 Object* DataSet::FindParamObject(char* name){ 301 302 /*Go through a dataset, and find a Param* object 303 *which parameter name is "name" : */ 304 305 vector<Object*>::iterator object; 306 Param* param=NULL; 307 308 for ( object=objects.begin() ; object < objects.end(); object++ ){ 309 310 /*Find param type objects: */ 311 if((*object)->Enum()==ParamEnum()){ 312 313 /*Ok, this object is a parameter, recover it and ask which name it has: */ 314 param=(Param*)(*object); 315 316 if (strcmp(param->GetParameterName(),name)==0){ 317 /*Ok, this is the one! Return the object: */ 318 return (*object); 319 } 320 } 321 } 322 return NULL; 323 } 324 325 295 326 void DataSet::NodeRank(int* ranks){ 296 327 … … 324 355 325 356 int dofcount=0; 357 int dofcount1=0; 326 358 int* alldofcount=NULL; 359 int* alldofcount1=NULL; 327 360 int* borderdofs=NULL; 361 int* borderdofs1=NULL; 328 362 int* allborderdofs=NULL; 363 int* allborderdofs1=NULL; 329 364 int i; 330 365 vector<Object*>::iterator object; … … 343 378 344 379 /*Ok, this object is a node, ask it to distribute dofs, and update the dofcount: */ 345 node->DistributeDofs(&dofcount );380 node->DistributeDofs(&dofcount,&dofcount1); 346 381 347 382 } … … 356 391 MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD); 357 392 393 alldofcount1=(int*)xmalloc(num_procs*sizeof(int)); 394 MPI_Gather(&dofcount1,1,MPI_INT,alldofcount1,1,MPI_INT,0,MPI_COMM_WORLD); 395 MPI_Bcast(alldofcount1,num_procs,MPI_INT,0,MPI_COMM_WORLD); 396 358 397 /*Ok, now every cpu should start its own dof count at the end of the dofcount 359 398 * from cpu-1. : */ 360 399 dofcount=0; 400 dofcount1=0; 361 401 if(my_rank==0){ 362 402 dofcount=0; 403 dofcount1=0; 363 404 } 364 405 else{ 365 406 for(i=0;i<my_rank;i++){ 366 407 dofcount+=alldofcount[i]; 408 dofcount1+=alldofcount1[i]; 367 409 } 368 410 } … … 378 420 379 421 /*Ok, this object is a node, ask it to update his dofs: */ 380 node->UpdateDofs(dofcount );422 node->UpdateDofs(dofcount,dofcount1); 381 423 382 424 } … … 387 429 borderdofs=(int*)xcalloc(numberofnodes*numdofspernode,sizeof(int)); 388 430 allborderdofs=(int*)xcalloc(numberofnodes*numdofspernode,sizeof(int)); 431 borderdofs1=(int*)xcalloc(numberofnodes*3,sizeof(int)); 432 allborderdofs1=(int*)xcalloc(numberofnodes*3,sizeof(int)); 433 389 434 for ( object=objects.begin() ; object < objects.end(); object++ ){ 390 435 … … 395 440 396 441 /*Ok, let this object show its border dofs, if is is a border dof: */ 397 node->ShowBorderDofs(borderdofs );442 node->ShowBorderDofs(borderdofs,borderdofs1); 398 443 399 444 } 400 445 } 401 446 MPI_Allreduce ( (void*)borderdofs,(void*)allborderdofs,numberofnodes*numdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 447 MPI_Allreduce ( (void*)borderdofs1,(void*)allborderdofs1,numberofnodes*3,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 402 448 403 449 /*Ok, now every cpu knows everyone else's border node dofs, update the border dofs accordingly: */ … … 410 456 411 457 /*Ok, this object is a node, ask it to update his dofs: */ 412 node->UpdateBorderDofs(allborderdofs );458 node->UpdateBorderDofs(allborderdofs,allborderdofs1); 413 459 414 460 } … … 420 466 xfree((void**)&borderdofs); 421 467 xfree((void**)&allborderdofs); 468 xfree((void**)&alldofcount1); 469 xfree((void**)&borderdofs1); 470 xfree((void**)&allborderdofs1); 471 422 472 return; 423 473 … … 433 483 434 484 /*Create partition vector: */ 435 partition=NewVec(numberofnodes *numdofspernode);436 437 /*Go through all nodes, and ask each node to plug its doflist in485 partition=NewVec(numberofnodes); 486 487 /*Go through all nodes, and ask each node to plug its 1D doflist in 438 488 * partition. The location where each node plugs its doflist into 439 * partition is determined by its (id-1)*numdofspernode (ie, serial 440 * organisation of the dofs). 489 * partition is determined by its (id-1)*3 (ie, serial * organisation of the dofs). 441 490 */ 442 491 -
issm/trunk/src/c/DataSet/DataSet.h
r100 r202 45 45 int Size(); 46 46 int FindParam(void* pvalue, char* name); 47 Object* FindParamObject(char* name); 47 48 void NodeRank(int* ranks); 48 49 void DistributeDofs(int numberofnodes,int numdofspernode); … … 76 77 void Misfit(double* pJ, double* u_g,double* u_g_obs,ParameterInputs* inputs,int analysis_type); 77 78 void VelocityExtrude(Vec ug,double* ug_serial); 79 int DeleteObject(Object* object); 78 80 79 81 -
issm/trunk/src/c/ModelProcessorx/Control/CreateParametersControl.cpp
r117 r202 25 25 double* optscal=NULL; 26 26 double* maxiter=NULL; 27 double* control_parameter=NULL; 27 Vec control_parameter=NULL; 28 Vec vx_obs=NULL; 29 Vec vy_obs=NULL; 28 30 29 31 /*Get counter : */ … … 98 100 99 101 /*Get vx_obs, vy_obs, and the parameter value: */ 100 ModelFetchData((void**)& model->vx_obs,NULL,NULL,model_handle,"vx_obs","Matrix","Mat");101 ModelFetchData((void**)& model->vy_obs,NULL,NULL,model_handle,"vy_obs","Matrix","Mat");102 ModelFetchData((void**)&control_parameter,NULL,NULL,model_handle,model->control_type," Matrix","Mat");102 ModelFetchData((void**)&vx_obs,NULL,NULL,model_handle,"vx_obs","Vector",NULL); 103 ModelFetchData((void**)&vy_obs,NULL,NULL,model_handle,"vy_obs","Vector",NULL); 104 ModelFetchData((void**)&control_parameter,NULL,NULL,model_handle,model->control_type,"Vector",NULL); 103 105 104 for(i=0;i<model->numberofnodes;i++)model->vx_obs[i]=model->vx_obs[i]/model->yts;105 for(i=0;i<model->numberofnodes;i++)model->vy_obs[i]=model->vy_obs[i]/model->yts;106 VecScale(vx_obs,1.0/model->yts); 107 VecScale(vy_obs,1.0/model->yts); 106 108 107 109 count++; 108 param= new Param(count,"vx_obs", DOUBLEVEC);109 param->Set DoubleVec(model->vx_obs,model->numberofnodes);110 param= new Param(count,"vx_obs",PETSCVEC); 111 param->SetVec(vx_obs); 110 112 parameters->AddObject(param); 111 113 112 114 count++; 113 param= new Param(count,"vy_obs", DOUBLEVEC);114 param->Set DoubleVec(model->vy_obs,model->numberofnodes);115 param= new Param(count,"vy_obs",PETSCVEC); 116 param->SetVec(vy_obs); 115 117 parameters->AddObject(param); 116 118 117 119 count++; 118 param= new Param(count,"control_parameter", DOUBLEVEC);119 param->Set DoubleVec(control_parameter,model->numberofnodes);120 param= new Param(count,"control_parameter",PETSCVEC); 121 param->SetVec(control_parameter); 120 122 parameters->AddObject(param); 121 123 122 xfree((void**)&model->vx_obs);123 xfree((void**)&model->vy_obs);124 xfree((void**)&control_parameter);124 VecFree(&vx_obs); 125 VecFree(&vy_obs); 126 VecFree(&control_parameter); 125 127 126 128 -
issm/trunk/src/c/ModelProcessorx/CreateParameters.cpp
r117 r202 27 27 double* maxiter=NULL; 28 28 double* control_parameter=NULL; 29 30 29 Vec vx=NULL; 30 Vec vy=NULL; 31 Vec vz=NULL; 31 32 32 33 /*Initialize dataset: */ … … 168 169 param->SetInteger(numberofdofspernode); 169 170 parameters->AddObject(param); 170 171 171 172 172 /*Deal with control parameters: */ … … 175 175 } 176 176 177 /*Diagnostic: */ 178 /*Get vx and vy: */ 179 ModelFetchData((void**)&vx,NULL,NULL,model_handle,"vx","Vector",NULL); 180 ModelFetchData((void**)&vy,NULL,NULL,model_handle,"vy","Vector",NULL); 181 ModelFetchData((void**)&vz,NULL,NULL,model_handle,"vz","Vector",NULL); 182 183 if(vx)VecScale(vx,1.0/model->yts); 184 if(vy)VecScale(vy,1.0/model->yts); 185 if(vz)VecScale(vz,1.0/model->yts); 186 187 count++; 188 param= new Param(count,"vx",PETSCVEC); 189 param->SetVec(vx); 190 parameters->AddObject(param); 191 192 count++; 193 param= new Param(count,"vy",PETSCVEC); 194 param->SetVec(vy); 195 parameters->AddObject(param); 196 197 count++; 198 param= new Param(count,"vz",PETSCVEC); 199 param->SetVec(vz); 200 parameters->AddObject(param); 201 202 VecFree(&vx); 203 VecFree(&vy); 204 VecFree(&vz); 205 177 206 /*All our datasets are already ordered by ids. Set presort flag so that later on, when sorting is requested on these 178 207 * datasets, it will not be redone: */ -
issm/trunk/src/c/ProcessParamsx/ProcessParamsx.cpp
r59 r202 19 19 double* partition=NULL; 20 20 Param* param=NULL; 21 22 /*diagnostic: */ 23 Vec vec_vx=NULL; 24 Vec vec_vy=NULL; 25 Vec vec_vz=NULL; 26 27 double* vx=NULL; 28 double* vy=NULL; 29 double* vz=NULL; 30 31 double* u_g=NULL; 32 33 /*control: */ 34 Vec vec_vx_obs=NULL; 35 Vec vec_vy_obs=NULL; 36 Vec vec_control_parameter=NULL; 37 21 38 double* vx_obs=NULL; 22 39 double* vy_obs=NULL; 23 40 double* control_parameter=NULL; 41 42 double* u_g_obs=NULL; 43 double* p_g=NULL; 44 45 46 /*diverse: */ 24 47 int numberofnodes; 25 48 int analysis_type; 26 49 int count; 27 50 28 /*new parameters: */29 double* u_g_obs=NULL;30 double* p_g=NULL;31 32 51 parameters->FindParam((void*)&analysis_type,"analysis_type"); 33 52 count=parameters->Size(); 53 54 parameters->FindParam((void*)&numberofnodes,"numberofnodes"); 55 56 /*First serialize partition vector: */ 57 VecToMPISerial(&partition,part); 58 59 60 if ( (analysis_type==ControlAnalysisEnum()) || 61 (analysis_type==DiagnosticHorizAnalysisEnum()) || 62 (analysis_type==DiagnosticVertAnalysisEnum()) || 63 (analysis_type==DiagnosticStokesAnalysisEnum()) 64 ){ 65 66 parameters->FindParam((void*)&vec_vx,"vx"); 67 parameters->FindParam((void*)&vec_vy,"vy"); 68 parameters->FindParam((void*)&vec_vz,"vz"); 69 70 if(vec_vx)VecToMPISerial(&vx,vec_vx); 71 if(vec_vy)VecToMPISerial(&vy,vec_vy); 72 if(vec_vz)VecToMPISerial(&vz,vec_vz); 73 74 u_g=(double*)xcalloc(numberofnodes*3,sizeof(double)); 75 76 if(vx){ 77 for(i=0;i<numberofnodes;i++){ 78 u_g[(int)(3*partition[i]+0)]=vx[i]; 79 } 80 } 81 82 if(vy){ 83 for(i=0;i<numberofnodes;i++){ 84 u_g[(int)(3*partition[i]+1)]=vy[i]; 85 } 86 } 87 88 if(vz){ 89 for(i=0;i<numberofnodes;i++){ 90 u_g[(int)(3*partition[i]+2)]=vz[i]; 91 } 92 } 93 94 95 /*Now, create new parameters: */ 96 count++; 97 param= new Param(count,"u_g",DOUBLEVEC); 98 param->SetDoubleVec(u_g,3*numberofnodes); 99 parameters->AddObject(param); 100 101 /*erase old parameters: */ 102 param=(Param*)parameters->FindParamObject("vx"); 103 parameters->DeleteObject((Object*)param); 104 105 param=(Param*)parameters->FindParamObject("vy"); 106 parameters->DeleteObject((Object*)param); 107 108 param=(Param*)parameters->FindParamObject("vz"); 109 parameters->DeleteObject((Object*)param); 110 111 } 112 34 113 35 114 if(analysis_type==ControlAnalysisEnum()){ 36 115 37 /*First serialize partition vector: */ 38 VecToMPISerial(&partition,part); 39 40 parameters->FindParam((void*)&vx_obs,"vx_obs"); 41 parameters->FindParam((void*)&vy_obs,"vy_obs"); 42 parameters->FindParam((void*)&control_parameter,"control_parameter"); 43 parameters->FindParam((void*)&numberofnodes,"numberofnodes"); 116 parameters->FindParam((void*)&vec_vx_obs,"vx_obs"); 117 parameters->FindParam((void*)&vec_vy_obs,"vy_obs"); 118 parameters->FindParam((void*)&vec_control_parameter,"control_parameter"); 44 119 45 120 /*Now, from vx_obs and vy_obs, build u_g_obs, correctly partitioned: */ 121 VecToMPISerial(&vx_obs,vec_vx_obs); 122 VecToMPISerial(&vy_obs,vec_vy_obs); 123 VecToMPISerial(&control_parameter,vec_control_parameter); 124 46 125 u_g_obs=(double*)xcalloc(numberofnodes*2,sizeof(double)); 47 126 p_g=(double*)xcalloc(numberofnodes*2,sizeof(double)); 48 127 49 128 for(i=0;i<numberofnodes;i++){ 50 u_g_obs[(int)( partition[2*i+0])]=vx_obs[i];51 u_g_obs[(int)( partition[2*i+1])]=vy_obs[i];52 p_g[(int)( partition[2*i+0])]=control_parameter[i];129 u_g_obs[(int)(2*partition[i]+0)]=vx_obs[i]; 130 u_g_obs[(int)(2*partition[i]+1)]=vy_obs[i]; 131 p_g[(int)(2*partition[i]+0)]=control_parameter[i]; 53 132 } 54 133 … … 61 140 count++; 62 141 param= new Param(count,"p_g",DOUBLEVEC); 63 param->SetDoubleVec(p_g, 2*numberofnodes);142 param->SetDoubleVec(p_g,numberofnodes); 64 143 parameters->AddObject(param); 144 145 /*erase old parameter: */ 146 param=(Param*)parameters->FindParamObject("vx_obs"); 147 parameters->DeleteObject((Object*)param); 148 149 param=(Param*)parameters->FindParamObject("vy_obs"); 150 parameters->DeleteObject((Object*)param); 151 152 param=(Param*)parameters->FindParamObject("control_parameter"); 153 parameters->DeleteObject((Object*)param); 154 65 155 } 66 156 67 157 xfree((void**)&partition); 158 159 xfree((void**)&vx); 160 xfree((void**)&vy); 161 xfree((void**)&vz); 162 VecFree(&vec_vx); 163 VecFree(&vec_vy); 164 VecFree(&vec_vz); 165 xfree((void**)&u_g); 166 68 167 xfree((void**)&vx_obs); 69 168 xfree((void**)&vy_obs); 169 VecFree(&vec_vx_obs); 170 VecFree(&vec_vy_obs); 171 VecFree(&vec_control_parameter); 70 172 xfree((void**)&control_parameter); 71 173 xfree((void**)&u_g_obs); 72 174 xfree((void**)&p_g); 175 73 176 } -
issm/trunk/src/c/objects/Node.cpp
r137 r202 73 73 printf("%i|",doflist[i]); 74 74 } 75 printf(" doflist1:|"); 76 printf("%i|",doflist1[1]); 75 77 printf("\n"); 76 78 … … 109 111 memcpy(marshalled_dataset,&onsurface,sizeof(onsurface));marshalled_dataset+=sizeof(onsurface); 110 112 memcpy(marshalled_dataset,&doflist,sizeof(doflist));marshalled_dataset+=sizeof(doflist); 113 memcpy(marshalled_dataset,&doflist1,sizeof(doflist1));marshalled_dataset+=sizeof(doflist1); 111 114 memcpy(marshalled_dataset,&mset,sizeof(mset));marshalled_dataset+=sizeof(mset); 112 115 memcpy(marshalled_dataset,&nset,sizeof(nset));marshalled_dataset+=sizeof(nset); … … 131 134 sizeof(onsurface)+ 132 135 sizeof(doflist)+ 136 sizeof(doflist1)+ 133 137 sizeof(mset)+ 134 138 sizeof(nset)+ … … 164 168 memcpy(&onsurface,marshalled_dataset,sizeof(onsurface));marshalled_dataset+=sizeof(onsurface); 165 169 memcpy(&doflist,marshalled_dataset,sizeof(doflist));marshalled_dataset+=sizeof(doflist); 170 memcpy(&doflist1,marshalled_dataset,sizeof(doflist1));marshalled_dataset+=sizeof(doflist1); 166 171 memcpy(&mset,marshalled_dataset,sizeof(mset));marshalled_dataset+=sizeof(mset); 167 172 memcpy(&nset,marshalled_dataset,sizeof(nset));marshalled_dataset+=sizeof(nset); … … 193 198 } 194 199 195 void Node::DistributeDofs(int* pdofcount ){200 void Node::DistributeDofs(int* pdofcount,int* pdofcount1){ 196 201 197 202 int i; 198 203 extern int my_rank; 199 204 int dofcount; 205 int dofcount1; 200 206 201 207 dofcount=*pdofcount; 208 dofcount1=*pdofcount1; 202 209 203 210 if(clone){ … … 212 219 dofcount+=numberofdofs; 213 220 221 doflist1[0]=dofcount1; 222 dofcount1+=1; 223 214 224 /*Assign output pointers: */ 215 225 *pdofcount=dofcount; 226 *pdofcount1=dofcount1; 216 227 217 228 return; 218 229 } 219 230 220 void Node::UpdateDofs(int dofcount ){231 void Node::UpdateDofs(int dofcount,int dofcount1){ 221 232 222 233 int i; … … 232 243 doflist[i]+=dofcount; 233 244 } 245 doflist1[0]+=dofcount1; 234 246 235 247 return; 236 248 } 237 249 238 void Node::ShowBorderDofs(int* borderdofs ){250 void Node::ShowBorderDofs(int* borderdofs,int* borderdofs1){ 239 251 240 252 int j; … … 252 264 *(borderdofs+numberofdofs*(id-1)+j)=doflist[j]; 253 265 } 254 255 return; 256 } 257 258 void Node::UpdateBorderDofs(int* allborderdofs){ 266 *(borderdofs1+(id-1)+0)=doflist1[0]; 267 268 return; 269 } 270 271 void Node::UpdateBorderDofs(int* allborderdofs,int* allborderdofs1){ 259 272 260 273 int j; … … 272 285 for(j=0;j<numberofdofs;j++){ 273 286 doflist[j]=*(allborderdofs+numberofdofs*(id-1)+j); 274 } 287 } 288 doflist1[0]=*(allborderdofs1+(id-1)+0); 275 289 return; 276 290 } 277 291 void Node::CreatePartition(Vec partition){ 278 292 279 int i; 280 int* idxm=NULL; 281 double* values=NULL; 282 283 idxm=(int*)xmalloc(numberofdofs*sizeof(int)); 284 values=(double*)xmalloc(numberofdofs*sizeof(double)); 285 286 for(i=0;i<numberofdofs;i++)idxm[i]=(id-1)*numberofdofs+i; 287 for(i=0;i<numberofdofs;i++)values[i]=(double)doflist[i]; 288 289 VecSetValues(partition,numberofdofs,idxm,values,INSERT_VALUES); 290 291 xfree((void**)&idxm); 292 xfree((void**)&values); 293 294 return; 295 } 296 void Node::DistributeNumDofs(int* numdofspernode,int analysis_type){return;} 297 293 int idxm; 294 double value; 295 296 idxm=(id-1); 297 value=(double)doflist1[0]; 298 299 VecSetValues(partition,1,&idxm,&value,INSERT_VALUES); 300 301 return; 302 } 298 303 299 304 void Node::SetClone(int* minranks){ -
issm/trunk/src/c/objects/Node.h
r95 r202 36 36 37 37 /*data that is post processed : */ 38 int doflist[MAXDOFSPERNODE]; 38 int doflist[MAXDOFSPERNODE]; //dof list on which we solve 39 int doflist1[1]; //1d dof list to recover input parameters 39 40 40 41 public: … … 52 53 int GetId(void); 53 54 int MyRank(void); 54 void DistributeDofs(int* pdofcount );55 void UpdateDofs(int dofcount );56 void ShowBorderDofs(int* borderdofs );57 void UpdateBorderDofs(int* allborderdofs );55 void DistributeDofs(int* pdofcount,int* pdofcount1); 56 void UpdateDofs(int dofcount,int dofcount1); 57 void ShowBorderDofs(int* borderdofs,int* borderdofs1); 58 void UpdateBorderDofs(int* allborderdofs,int* allborderdofs1); 58 59 void CreatePartition(Vec partition); 59 void DistributeNumDofs(int* numdofspernode,int analysis_type);60 60 void SetClone(int* minranks); 61 61 int GetNumberOfDofs(); -
issm/trunk/src/c/objects/Param.cpp
r1 r202 37 37 38 38 Param::~Param(){ 39 return; 39 40 switch(type){ 41 42 case STRING: 43 break; 44 45 case INTEGER: 46 break; 47 48 case DOUBLE: 49 break; 50 51 case DOUBLEVEC: 52 xfree((void**)&doublevec); 53 break; 54 55 case DOUBLEMAT: 56 xfree((void**)&doublemat); 57 break; 58 59 case PETSCVEC: 60 VecFree(&vec); 61 break; 62 63 case PETSCMAT: 64 MatFree(&mat); 65 break; 66 67 default: 68 throw ErrorException(__FUNCT__,exprintf("%s%i","unknow parameter type ",type)); 69 } 40 70 } 41 71 … … 139 169 140 170 case PETSCVEC: 141 VecGetSize(vec,&M); 142 VecToMPISerial(&serial_vec,vec); 143 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 144 memcpy(marshalled_dataset,serial_vec,M*sizeof(double));marshalled_dataset+=(M*sizeof(double)); 145 xfree((void**)&serial_vec); 171 if(vec){ 172 VecGetSize(vec,&M); 173 VecToMPISerial(&serial_vec,vec); 174 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 175 memcpy(marshalled_dataset,serial_vec,M*sizeof(double));marshalled_dataset+=(M*sizeof(double)); 176 xfree((void**)&serial_vec); 177 } 178 else{ 179 M=0; 180 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 181 } 146 182 break; 147 183 148 184 case PETSCMAT: 149 MatGetSize(mat,&M,&N); 150 MatToSerial(&serial_mat,mat); 151 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 152 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 153 memcpy(marshalled_dataset,serial_mat,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double)); 154 xfree((void**)&serial_mat); 185 if(mat){ 186 MatGetSize(mat,&M,&N); 187 MatToSerial(&serial_mat,mat); 188 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 189 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 190 memcpy(marshalled_dataset,serial_mat,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double)); 191 xfree((void**)&serial_mat); 192 } 193 else{ 194 M=0; 195 N=0; 196 memcpy(marshalled_dataset,&M,sizeof(M));marshalled_dataset+=sizeof(M); 197 memcpy(marshalled_dataset,&N,sizeof(N));marshalled_dataset+=sizeof(N); 198 } 155 199 break; 156 200 … … 263 307 case PETSCVEC: 264 308 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M); 265 serial_vec=(double*)xmalloc(M*sizeof(double)); 266 memcpy(serial_vec,marshalled_dataset,M*sizeof(double));marshalled_dataset+=(M*sizeof(double)); 267 268 vec=NewVec(M); 269 idxm=(int*)xmalloc(M*sizeof(int)); 270 for(i=0;i<M;i++)idxm[i]=i; 271 VecSetValues(vec,M,idxm,serial_vec,INSERT_VALUES); 272 273 VecAssemblyBegin(vec); 274 VecAssemblyEnd(vec); 275 276 xfree((void**)&serial_vec); 277 xfree((void**)&idxm); 309 if(M){ 310 serial_vec=(double*)xmalloc(M*sizeof(double)); 311 memcpy(serial_vec,marshalled_dataset,M*sizeof(double));marshalled_dataset+=(M*sizeof(double)); 312 313 vec=NewVec(M); 314 idxm=(int*)xmalloc(M*sizeof(int)); 315 for(i=0;i<M;i++)idxm[i]=i; 316 VecSetValues(vec,M,idxm,serial_vec,INSERT_VALUES); 317 318 VecAssemblyBegin(vec); 319 VecAssemblyEnd(vec); 320 321 xfree((void**)&serial_vec); 322 xfree((void**)&idxm); 323 } 324 else{ 325 vec=NULL; 326 } 278 327 break; 279 328 … … 281 330 memcpy(&M,marshalled_dataset,sizeof(M));marshalled_dataset+=sizeof(M); 282 331 memcpy(&N,marshalled_dataset,sizeof(N));marshalled_dataset+=sizeof(N); 283 serial_mat=(double*)xmalloc(M*N*sizeof(double)); 284 memcpy(serial_mat,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double)); 285 mat=NewMat(M,N,&sparsity,NULL,NULL); 286 idxm=(int*)xmalloc(M*sizeof(int)); 287 idxn=(int*)xmalloc(N*sizeof(int)); 288 for(i=0;i<M;i++)idxm[i]=i; 289 for(i=0;i<N;i++)idxn[i]=i; 290 MatSetValues(mat,M,idxm,N,idxn,serial_mat,INSERT_VALUES); 291 MatAssemblyBegin(mat,MAT_FINAL_ASSEMBLY); 292 MatAssemblyEnd(mat,MAT_FINAL_ASSEMBLY); 293 294 xfree((void**)&serial_mat); 295 xfree((void**)&idxm); 296 xfree((void**)&idxn); 332 if(M!=0 && N!=0){ 333 serial_mat=(double*)xmalloc(M*N*sizeof(double)); 334 memcpy(serial_mat,marshalled_dataset,M*N*sizeof(double));marshalled_dataset+=(M*N*sizeof(double)); 335 mat=NewMat(M,N,&sparsity,NULL,NULL); 336 idxm=(int*)xmalloc(M*sizeof(int)); 337 idxn=(int*)xmalloc(N*sizeof(int)); 338 for(i=0;i<M;i++)idxm[i]=i; 339 for(i=0;i<N;i++)idxn[i]=i; 340 MatSetValues(mat,M,idxm,N,idxn,serial_mat,INSERT_VALUES); 341 MatAssemblyBegin(mat,MAT_FINAL_ASSEMBLY); 342 MatAssemblyEnd(mat,MAT_FINAL_ASSEMBLY); 343 344 xfree((void**)&serial_mat); 345 xfree((void**)&idxm); 346 xfree((void**)&idxn); 347 } 348 else{ 349 mat=NULL; 350 } 297 351 break; 298 352 … … 350 404 Vec* pvec=(Vec*)pvalue; 351 405 Vec outvec=NULL; 352 VecDuplicate(vec,&outvec); 353 VecCopy(vec,outvec); 406 if(vec){ 407 VecDuplicate(vec,&outvec); 408 VecCopy(vec,outvec); 409 } 354 410 *pvec=outvec; 355 411 } … … 357 413 Mat* pmat=(Mat*)pvalue; 358 414 Mat outmat=NULL; 359 MatDuplicate(mat,MAT_COPY_VALUES,&outmat); 415 if(mat){ 416 MatDuplicate(mat,MAT_COPY_VALUES,&outmat); 417 } 360 418 *pmat=outmat; 361 419 } … … 424 482 425 483 } 484 485 #undef __FUNCT__ 486 #define __FUNCT__ "SetVec" 487 void Param::SetVec(Vec value){ 488 489 if(value){ 490 VecDuplicate(value,&vec); 491 VecCopy(value,vec); 492 VecGetSize(value,&M); 493 N=1; 494 } 495 else{ 496 vec=NULL; 497 M=0; 498 N=0; 499 } 500 501 } -
issm/trunk/src/c/objects/Param.h
r1 r202 46 46 void SetDouble(double value); 47 47 void SetDoubleVec(double* value,int size); 48 void SetVec(Vec value); 48 49 void SetInteger(int value); 49 50 void SetString(char* value); -
issm/trunk/src/c/objects/Tria.cpp
r177 r202 663 663 GetParameterValue(&alpha2, &alpha2_list[0],gauss_l1l2l3); 664 664 665 DL_scalar=alpha2*gauss_weight*Jdet; 665 if (velocity_param){ 666 DL_scalar=alpha2*gauss_weight*Jdet; 667 } 668 else{ 669 DL_scalar=0; 670 } 671 666 672 for (i=0;i<2;i++){ 667 673 DL[i][i]=DL_scalar; … … 916 922 B_param=ParameterInputsRecover(inputs,"B"); 917 923 if(temperature_average_param){ 918 temperature_average-0;919 924 for(i=0;i<3;i++) temperature_average+=temperature_average_param[doflist[i*numberofdofspernode+0]]; 920 925 temperature_average=temperature_average/3.0; … … 2122 2127 &Ke_gg_gaussian[0][0],0); 2123 2128 2124 2125 2129 /* Add the Ke_gg_gaussian, and optionally Ke_gg_drag_gaussian onto Ke_gg: */ 2126 2130 for( i=0; i<numdofs; i++) for(j=0;j<numdofs;j++) Ke_gg[i][j]+=Ke_gg_gaussian[i][j]; … … 2352 2356 /*Get bed slope: */ 2353 2357 GetParameterDerivativeValue(&slope[0], &b[0],&xyz_list[0][0], gauss_l1l2l3); 2354 dbdx= -slope[0];2355 dbdy= -slope[1];2358 dbdx=slope[0]; 2359 dbdy=slope[1]; 2356 2360 2357 2361 /* Get Jacobian determinant: */ -
issm/trunk/src/m/classes/public/setelementstype.m
r106 r202 119 119 deadgrids(find(md.gridonbed))=0; %grids from elements on bed are not dead 120 120 md.deadgrids=deadgrids; 121 122 %figure out solution types 123 md.ishutter=any(md.elements_type(:,1)==hutterenum()); 124 md.ismacayealpattyn=any(md.elements_type(:,1)==macayealenum() | md.elements_type(:,1)==pattynenum() ); 125 md.isstokes=any(md.elements_type(:,2)); 126 121 127 end -
issm/trunk/src/m/solutions/cielo/CreateFemModel.m
r105 r202 13 13 disp(' generating degrees of freedom...'); 14 14 [m.nodes,m.part,m.tpart]=Dof(m.elements,m.nodes,parameters); 15 15 16 16 disp(' generating single point constraints...'); 17 17 [m.nodes,m.yg]=SpcNodes(m.nodes,m.constraints); … … 31 31 disp(' configuring element and loads...'); 32 32 [m.elements,m.loads,m.nodes] = ConfigureObjects( m.elements, m.loads, m.nodes, m.materials); 33 33 34 34 disp(' processing parameters...'); 35 35 parameters= ProcessParams(parameters,m.part); -
issm/trunk/src/m/solutions/cielo/diagnostic.m
r163 r202 18 18 md.dof=m_dh.nodesets.fsize; %biggest dof number 19 19 20 %initialize inputs 21 if strcmp(md.analysis_type,'diagnostic_stokes'), 22 inputs.velocity=m_dh.parameters.u_g; 23 else 24 inputs.velocity=zeros(2*m_dh.parameters.numberofnodes,1); 25 inputs.velocity(1:2:end)=m_dh.parameters.u_g(1:3:end); 26 inputs.velocity(2:2:end)=m_dh.parameters.u_g(2:3:end); 27 end 28 20 29 %Get horizontal solution. 21 30 disp(sprintf('\n%s',['computing horizontal velocities...'])); 22 23 %plug existing velocity in inputs24 if ~isnan(md.vx) & ~isnan(md.vy),25 indx=m_dh.part(1:2:end);26 indy=m_dh.part(2:2:end);27 velocity=zeros(m_dh.nodesets.gsize,1);28 velocity(indx)=md.vx/md.yts;29 velocity(indy)=md.vy/md.yts;30 inputs=struct('velocity',velocity);31 else32 inputs={};33 end34 31 35 32 u_g=diagnostic_core_nonlinear(m_dh,inputs); -
issm/trunk/src/m/solutions/cielo/diagnostic_core_nonlinear.m
r133 r202 11 11 count=1; 12 12 converged=0; 13 13 14 [velocity_param velocity_is_present]=recover_input(inputs,'velocity'); 14 15 if velocity_is_present … … 18 19 end 19 20 soln(count).u_f=[]; 20 21 21 22 22 if m.parameters.debug, … … 74 74 % Figure out if convergence is reached. 75 75 if(count>=3 | velocity_is_present), 76 dug=soln(count).u_g-soln(count-1).u_g; nduinf=norm(dug,inf)*m.parameters.yts; ndu=norm(dug,2); nu=norm(soln(count-1).u_g,2); 76 dug=soln(count).u_g-soln(count-1).u_g; 77 nduinf=norm(dug,inf)*m.parameters.yts; 78 ndu=norm(dug,2); 79 nu=norm(soln(count-1).u_g,2); 77 80 78 81 %Relative criterion -
issm/trunk/src/m/solutions/ice/diagnostic.m
r34 r202 17 17 %Create fem structure (input of diagnostic3d) 18 18 fem=struct(); 19 19 20 %Figure out which type of elements are present 20 [fem.ishutter,fem.ismacayealpattyn,fem.isstokes]=DiagnosticSolutionType(md.elements_type); 21 fem.ishutter=ishutter; 22 fem.ismacayealpattyn=ismacayealpattyn; 23 fem.isstokes=isstokes; 21 24 22 25 if strcmpi(md.type,'2d'), -
issm/trunk/src/mex/ModelProcessor/ModelProcessor.cpp
r117 r202 36 36 /*Create constraints: */ 37 37 CreateConstraints(&constraints,model,MODEL); 38 38 39 39 /*Create loads: */ 40 40 CreateLoads(&loads,model,MODEL); 41 41 42 42 /*Create parameters: */ 43 43 44 CreateParameters(¶meters,model,MODEL); 44 45
Note:
See TracChangeset
for help on using the changeset viewer.