Changeset 3947
- Timestamp:
- 05/26/10 09:30:24 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp
r3828 r3947 161 161 case NodeOnIceShelfEnum : return "NodeOnIceShelf"; 162 162 case NodeOnSurfaceEnum : return "NodeOnSurface"; 163 case NumberNodeToElementConnectivityEnum : return "NumberNodeToElementConnectivity"; 163 164 case PenaltyOffsetEnum : return "PenaltyOffset"; 164 165 case PflagEnum : return "Pflag"; -
issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
r3938 r3947 188 188 NodeOnIceShelfEnum, 189 189 NodeOnSurfaceEnum, 190 NumberNodeToElementConnectivityEnum, 190 191 PenaltyOffsetEnum, 191 192 PflagEnum, -
issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp
r3828 r3947 159 159 else if (strcmp(name,"NodeOnIceShelf")==0) return NodeOnIceShelfEnum; 160 160 else if (strcmp(name,"NodeOnSurface")==0) return NodeOnSurfaceEnum; 161 else if (strcmp(name,"NumberNodeToElementConnectivity")==0) return NumberNodeToElementConnectivityEnum; 161 162 else if (strcmp(name,"PenaltyOffset")==0) return PenaltyOffsetEnum; 162 163 else if (strcmp(name,"Pflag")==0) return PflagEnum; -
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHutter/CreateElementsNodesAndMaterialsDiagnosticHutter.cpp
r3913 r3947 50 50 IoModelFetchData(&iomodel->rheology_B,NULL,NULL,iomodel_handle,"rheology_B"); 51 51 IoModelFetchData(&iomodel->rheology_n,NULL,NULL,iomodel_handle,"rheology_n"); 52 IoModelFetchData(&iomodel->elements_type,NULL,NULL,iomodel_handle,"elements_type"); 53 IoModelFetchData(&iomodel->elementonbed,NULL,NULL,iomodel_handle,"elementonbed"); 54 IoModelFetchData(&iomodel->elementonsurface,NULL,NULL,iomodel_handle,"elementonsurface"); 55 IoModelFetchData(&iomodel->elementonwater,NULL,NULL,iomodel_handle,"elementonwater"); 56 IoModelFetchData(&iomodel->elements,NULL,NULL,iomodel_handle,"elements"); 57 IoModelFetchData(&iomodel->upperelements,NULL,NULL,iomodel_handle,"upperelements"); 58 IoModelFetchData(&iomodel->lowerelements,NULL,NULL,iomodel_handle,"lowerelements"); 52 59 53 60 /*2d mesh: */ 54 61 if (strcmp(iomodel->meshtype,"2d")==0){ 55 62 56 for (i=0;i<iomodel->numberof vertices;i++){63 for (i=0;i<iomodel->numberofelements;i++){ 57 64 58 if(iomodel->my_ vertices[i]){65 if(iomodel->my_elements[i]){ 59 66 60 /*Create and add penta element to elements dataset: */ 61 elements->AddObject(new Sing(i+1,i,iomodel)); 67 if (*(iomodel->elements_type+2*i+0)==HutterFormulationEnum){ //create only Hutter elements 62 68 63 /*Create and add material property to materials dataset: */64 materials->AddObject(new Matice(i+1,i,iomodel,1));69 /*Create and add penta element to elements dataset: */ 70 elements->AddObject(new Tria(i+1,i,iomodel)); 65 71 72 /*Create and add material property to materials dataset: */ 73 materials->AddObject(new Matice(i+1,i,iomodel,3)); 74 } 66 75 } 67 68 76 } //for (i=0;i<iomodel->numberofvertices;i++) 69 77 } //if (strcmp(iomodel->meshtype,"2d")==0) 70 78 else{ 71 79 72 for (i=0;i<iomodel->numberof vertices;i++){80 for (i=0;i<iomodel->numberofelements;i++){ 73 81 74 if(iomodel->my_vertices[i]){ 75 if(iomodel->gridonhutter[i]){ 76 if(!iomodel->gridonsurface[i]){ 82 if(iomodel->my_elements[i]){ 77 83 78 /*Create and add penta element to elements dataset: */ 79 elements->AddObject(new Beam(i+1,i,iomodel)); 84 if (*(iomodel->elements_type+2*i+0)==HutterFormulationEnum){ //create only Hutter elements 80 85 81 /*Create and add material property to materials dataset: */82 materials->AddObject(new Matice(i+1,i,iomodel,2));86 /*Create and add penta element to elements dataset: */ 87 elements->AddObject(new Penta(i+1,i,iomodel)); 83 88 84 } 89 90 /*Create and add material property to materials dataset: */ 91 materials->AddObject(new Matice(i+1,i,iomodel,6)); 92 85 93 } 86 94 } 87 95 88 } //for (i=0;i<iomodel->numberof vertices;i++)96 } //for (i=0;i<iomodel->numberofelements;i++) 89 97 90 98 } //if (strcmp(iomodel->meshtype,"2d")==0) … … 92 100 /*Free data: */ 93 101 xfree((void**)&iomodel->elements); 102 xfree((void**)&iomodel->elementonbed); 103 xfree((void**)&iomodel->elementonsurface); 104 xfree((void**)&iomodel->elements_type); 94 105 xfree((void**)&iomodel->gridonhutter); 95 106 xfree((void**)&iomodel->thickness); 96 107 xfree((void**)&iomodel->surface); 97 108 xfree((void**)&iomodel->bed); 98 xfree((void**)&iomodel->gridonsurface); 109 xfree((void**)&iomodel->gridonbed); 110 xfree((void**)&iomodel->elementonwater); 99 111 xfree((void**)&iomodel->uppernodes); 100 112 xfree((void**)&iomodel->drag_coefficient); 101 113 xfree((void**)&iomodel->rheology_B); 102 114 xfree((void**)&iomodel->rheology_n); 115 xfree((void**)&iomodel->upperelements); 116 xfree((void**)&iomodel->lowerelements); 103 117 104 118 /*Add new constrant material property to materials, at the end: */ 105 119 if (strcmp(iomodel->meshtype,"2d")==0){ 106 materials->AddObject(new Matpar(iomodel->numberof vertices+1,iomodel)); //put it at the end of the materials120 materials->AddObject(new Matpar(iomodel->numberofelements+1,iomodel)); //put it at the end of the materials 107 121 } 108 122 else{ 109 materials->AddObject(new Matpar(iomodel->numberof vertices2d*(iomodel->numlayers-1)+1,iomodel)); //put it at the end of the materials123 materials->AddObject(new Matpar(iomodel->numberofelements+1,iomodel)); //put it at the end of the materials 110 124 } 111 125 … … 125 139 IoModelFetchData(&iomodel->gridonicesheet,NULL,NULL,iomodel_handle,"gridonicesheet"); 126 140 IoModelFetchData(&iomodel->gridoniceshelf,NULL,NULL,iomodel_handle,"gridoniceshelf"); 141 IoModelFetchData(&iomodel->elements,NULL,NULL,iomodel_handle,"elements"); 142 CreateNumberNodeToElementConnectivity(iomodel); 127 143 128 144 for (i=0;i<iomodel->numberofvertices;i++){ … … 153 169 xfree((void**)&iomodel->gridonicesheet); 154 170 xfree((void**)&iomodel->gridoniceshelf); 171 xfree((void**)&iomodel->elements); 172 xfree((void**)&iomodel->numbernodetoelementconnectivity); 155 173 156 174 /*All our datasets are already order by ids. Set presort flag so that later on, when sorting is requested on these -
issm/trunk/src/c/objects/Elements/Beam.cpp
r3944 r3947 414 414 int numberofdofspernode; 415 415 bool onbed; 416 417 416 bool onsurface; 417 int connectivity[2]; 418 double one0,one1; 419 420 /*dynamic objects pointed to by hooks: */ 421 Node** nodes=NULL; 422 423 /*recover objects from hooks: */ 424 nodes=(Node**)hnodes.deliverp(); 425 426 connectivity[0]=nodes[0]->GetConnectivity(); 427 connectivity[1]=nodes[1]->GetConnectivity(); 428 429 one0=1/(double)connectivity[0]; 430 one1=1/(double)connectivity[1]; 418 431 inputs->GetParameterValue(&onbed,ElementOnBedEnum); 432 inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum); 419 433 420 434 GetDofList(&doflist[0],&numberofdofspernode); 421 435 422 436 if (onbed){ 423 Ke_gg[0][0]=1; 424 Ke_gg[1][1]=1; 425 Ke_gg[2][0]=-1; 426 Ke_gg[2][2]=1; 427 Ke_gg[3][1]=-1; 428 Ke_gg[3][3]=1; 429 } 430 else{ 431 Ke_gg[2][0]=-1; 432 Ke_gg[2][2]=1; 433 Ke_gg[3][1]=-1; 434 Ke_gg[3][3]=1; 437 Ke_gg[0][0]=one0; 438 Ke_gg[1][1]=one0; 439 Ke_gg[2][0]=-2*one1; 440 Ke_gg[2][2]=2*one1; 441 Ke_gg[3][1]=-2*one1; 442 Ke_gg[3][3]=2*one1; 443 } 444 else if (onsurface){ 445 Ke_gg[2][0]=-one1; 446 Ke_gg[2][2]=one1; 447 Ke_gg[3][1]=-one1; 448 Ke_gg[3][3]=one1; 449 } 450 else{ //node is on two horizontal layers and beams include the values only once, so the have to use half of the connectivity 451 Ke_gg[2][0]=-2*one1; 452 Ke_gg[2][2]=2*one1; 453 Ke_gg[3][1]=-2*one1; 454 Ke_gg[3][3]=2*one1; 435 455 } 436 456 … … 495 515 496 516 bool onbed; 517 bool onsurface; 518 int connectivity[2]; 497 519 498 520 /*dynamic objects pointed to by hooks: */ … … 511 533 /*recover some inputs: */ 512 534 inputs->GetParameterValue(&onbed,ElementOnBedEnum); 535 inputs->GetParameterValue(&onsurface,ElementOnSurfaceEnum); 513 536 514 537 /*recover parameters: */ … … 524 547 inputs->GetParameterValue(&thickness,&gauss1[0],ThicknessEnum); 525 548 549 connectivity[0]=nodes[0]->GetConnectivity(); 550 connectivity[1]=nodes[1]->GetConnectivity(); 551 526 552 //Get all element grid data: 527 553 GetVerticesCoordinates(&xyz_list[0][0], nodes, numgrids); … … 551 577 GetJacobianDeterminant(&Jdet, &z_list[0],gauss_coord); 552 578 553 for(j=0;j<NDOF2;j++){ 554 pe_g_gaussian[NDOF2+j]=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss_weight; 579 /*Add contribution*/ 580 if (onsurface){ 581 for(j=0;j<NDOF2;j++){ 582 pe_g_gaussian[NDOF2+j]=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss_weight/(double)connectivity[1]; 583 } 584 } 585 else{//connectivity is too large, should take only half on it 586 for(j=0;j<NDOF2;j++){ 587 pe_g_gaussian[NDOF2+j]=constant_part*pow((surface-z_g)/B,n)*slope[j]*Jdet*gauss_weight*2/(double)connectivity[1]; 588 } 555 589 } 556 590 … … 570 604 571 605 //Add to pe: 572 pe_g[0]+=ub ;573 pe_g[1]+=vb ;606 pe_g[0]+=ub/(double)connectivity[0]; 607 pe_g[1]+=vb/(double)connectivity[0]; 574 608 } 575 609 -
issm/trunk/src/c/objects/Elements/Penta.cpp
r3946 r3947 53 53 54 54 /*hooks: */ 55 ISSMASSERT(iomodel->elements); 55 56 for(i=0;i<6;i++){ //go recover node ids, needed to initialize the node hook. 56 57 penta_node_ids[i]=(int)*(iomodel->elements+6*index+i); //ids for vertices are in the elements array from Matlab … … 59 60 penta_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object 60 61 62 ISSMASSERT(iomodel->upperelements); 61 63 if isnan(iomodel->upperelements[index]){ 62 64 penta_elements_ids[0]=this->id; //upper penta is the same penta … … 65 67 penta_elements_ids[0]=(int)(iomodel->upperelements[index]); 66 68 } 69 ISSMASSERT(iomodel->lowerelements); 67 70 if isnan(iomodel->lowerelements[index]){ 68 71 penta_elements_ids[1]=this->id; //lower penta is the same penta … … 71 74 penta_elements_ids[1]=(int)(iomodel->lowerelements[index]); 72 75 } 73 74 76 this->InitHookNodes(penta_node_ids); this->nodes=NULL; 75 77 this->InitHookMatice(penta_matice_id);this->matice=NULL; … … 79 81 //intialize inputs, and add as many inputs per element as requested: 80 82 this->inputs=new Inputs(); 81 82 83 if (iomodel->thickness) { 83 84 for(i=0;i<6;i++)nodeinputs[i]=iomodel->thickness[penta_node_ids[i]-1]; … … 125 126 this->inputs->AddInput(new PentaVertexInput(DhDtEnum,nodeinputs)); 126 127 } 127 128 128 /*vx,vy and vz: */ 129 129 if (iomodel->vx) { … … 178 178 this->inputs->AddInput(new PentaVertexInput(VzOldEnum,nodeinputs)); 179 179 } 180 181 180 if (iomodel->elementoniceshelf) this->inputs->AddInput(new BoolInput(ElementOnIceShelfEnum,(IssmBool)iomodel->elementoniceshelf[index])); 182 181 if (iomodel->elementonbed) this->inputs->AddInput(new BoolInput(ElementOnBedEnum,(IssmBool)iomodel->elementonbed[index])); … … 250 249 /*point parameters to real dataset: */ 251 250 this->parameters=parametersin; 252 253 251 } 254 252 /*}}}*/ … … 330 328 name==SurfaceEnum || 331 329 name==BedEnum || 330 name==SurfaceSlopexEnum || 331 name==SurfaceSlopeyEnum || 332 332 name==MeltingRateEnum || 333 333 name==AccumulationRateEnum || -
issm/trunk/src/c/objects/Elements/Sing.cpp
r3944 r3947 333 333 int doflist[numdofs]; 334 334 int numberofdofspernode; 335 int connectivity; 336 337 /*dynamic objects pointed to by hooks: */ 338 Node** nodes=NULL; 339 340 /*recover objects from hooks: */ 341 nodes=(Node**)hnodes.delivers(); 342 343 /*Find connectivity of the node and divide Ke_gg by this connectivity*/ 344 connectivity=nodes[0]->GetConnectivity(); 345 Ke_gg[0][0]=1/(double)connectivity; 346 Ke_gg[1][1]=1/(double)connectivity; 335 347 336 348 GetDofList(&doflist[0],&numberofdofspernode); … … 374 386 double rho_ice,gravity,n,B; 375 387 double thickness; 388 int connectivity; 376 389 377 390 /*dynamic objects pointed to by hooks: */ 378 Node** node =NULL;391 Node** nodes=NULL; 379 392 Matpar* matpar=NULL; 380 393 Matice* matice=NULL; 381 394 382 395 /*recover objects from hooks: */ 383 node =(Node**)hnodes.deliverp();396 nodes=(Node**)hnodes.deliverp(); 384 397 matpar=(Matpar*)hmatpar.delivers(); 385 398 matice=(Matice*)hmatice.delivers(); … … 389 402 390 403 GetDofList(&doflist[0],&numberofdofspernode); 404 405 //Get connectivity of the node 406 connectivity=nodes[0]->GetConnectivity(); 391 407 392 408 //compute slope2 … … 406 422 constant_part=-2*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2)); 407 423 408 pe_g[0]= ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0];409 pe_g[1]= vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1];424 pe_g[0]=(ub-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[0])/(double)connectivity; 425 pe_g[1]=(vb-2.0*pow(rho_ice*gravity,n)*pow(slope2,((n-1)/2.0))*pow(thickness,n)/(pow(B,n)*(n+1))*slope[1])/(double)connectivity; 410 426 411 427 VecSetValues(pg,numdofs,doflist,(const double*)pe_g,ADD_VALUES); 412 413 428 414 429 } -
issm/trunk/src/c/objects/Node.cpp
r3858 r3947 165 165 if (iomodel->gridoniceshelf) this->inputs->AddInput(new BoolInput(NodeOnIceShelfEnum,(IssmBool)iomodel->gridoniceshelf[i])); 166 166 if (iomodel->gridonicesheet) this->inputs->AddInput(new BoolInput(NodeOnIceSheetEnum,(IssmBool)iomodel->gridonicesheet[i])); 167 NumberNodeToElementConnectivityEnum; 168 if (iomodel->numbernodetoelementconnectivity) this->inputs->AddInput(new IntInput(NumberNodeToElementConnectivityEnum,iomodel->numbernodetoelementconnectivity[i])); 167 169 168 170 } … … 771 773 } 772 774 /*}}}*/ 775 /*FUNCTION Node::GetConnectivity {{{2*/ 776 int Node::GetConnectivity(){ 777 int connectivity; 778 779 /*recover parameters: */ 780 inputs->GetParameterValue(&connectivity,NumberNodeToElementConnectivityEnum); 781 782 return connectivity; 783 } 784 /*}}}*/ 773 785 /*FUNCTION Node::GetNumberOfDofs{{{2*/ 774 786 int Node::GetNumberOfDofs(){ -
issm/trunk/src/c/objects/Node.h
r3858 r3947 70 70 int GetDof(int dofindex); 71 71 void CreateVecSets(Vec pv_g,Vec pv_m,Vec pv_n,Vec pv_f,Vec pv_s); 72 int GetConnectivity(); 72 73 void GetDofList(int* outdoflist,int* pnumberofdofspernode); 73 74 int GetDofList1(void);
Note:
See TracChangeset
for help on using the changeset viewer.