Changeset 13410
- Timestamp:
- 09/20/12 16:39:15 (12 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Container/Vertices.cpp
r12459 r13410 38 38 39 39 /*Numerics management*/ 40 /*FUNCTION Vertices::Distribute Dofs{{{*/41 void Vertices::Distribute Dofs(int numberofobjects,int numberofdofsperobject){40 /*FUNCTION Vertices::DistributePids{{{*/ 41 void Vertices::DistributePids(int numberofobjects){ 42 42 43 43 extern int num_procs; … … 45 45 46 46 int i; 47 int dofcount=0;48 int * alldofcount=NULL;49 int * truedofs=NULL;50 int * alltruedofs=NULL;47 int pidcount = 0; 48 int *allpidcount = NULL; 49 int *truepids = NULL; 50 int *alltruepids = NULL; 51 51 52 /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/52 /*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/ 53 53 for (i=0;i<this->Size();i++){ 54 54 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); 55 vertex->Distribute Dofs(&dofcount);55 vertex->DistributePids(&pidcount); 56 56 } 57 57 58 /* Now every object has distributed dofs, but locally, and with a dofcount starting from59 * 0. This means the dofs between all the cpus are not unique. We now offset the dofs of eache60 * cpus by the total last dofs of the previus cpu, starting from 0.61 * First: bet number of dofs for each cpu*/62 all dofcount=xNew<int>(num_procs);58 /* Now every object has distributed pids, but locally, and with a pid count starting from 59 * 0. This means the pids between all the cpus are not unique. We now offset the pids of each 60 * cpus by the total last pids of the previus cpu, starting from 0. 61 * First: get number of pids for each cpu*/ 62 allpidcount=xNew<int>(num_procs); 63 63 #ifdef _HAVE_MPI_ 64 MPI_Gather(& dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);65 MPI_Bcast(all dofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);64 MPI_Gather(&pidcount,1,MPI_INT,allpidcount,1,MPI_INT,0,MPI_COMM_WORLD); 65 MPI_Bcast(allpidcount,num_procs,MPI_INT,0,MPI_COMM_WORLD); 66 66 #else 67 all dofcount[0]=dofcount;67 allpidcount[0]=pidcount; 68 68 #endif 69 69 70 /* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/71 dofcount=0;70 /* Every cpu should start its own pid count at the end of the pidcount from cpu-1*/ 71 pidcount=0; 72 72 if(my_rank!=0){ 73 73 for(i=0;i<my_rank;i++){ 74 dofcount+=alldofcount[i];74 pidcount+=allpidcount[i]; 75 75 } 76 76 } 77 77 for (i=0;i<this->Size();i++){ 78 78 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); 79 vertex->Offset Dofs(dofcount);79 vertex->OffsetPids(pidcount); 80 80 } 81 81 82 82 /* Finally, remember that cpus may have skipped some objects, because they were clones. For every 83 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked83 * object that is not a clone, tell them to show their pids, so that later on, they can get picked 84 84 * up by their clones: */ 85 true dofs =xNewZeroInit<int>(numberofobjects*numberofdofsperobject);86 alltrue dofs=xNewZeroInit<int>(numberofobjects*numberofdofsperobject);85 truepids =xNewZeroInit<int>(numberofobjects); 86 alltruepids=xNewZeroInit<int>(numberofobjects); 87 87 for (i=0;i<this->Size();i++){ 88 88 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); 89 vertex->ShowTrue Dofs(truedofs);89 vertex->ShowTruePids(truepids); 90 90 } 91 91 #ifdef _HAVE_MPI_ 92 MPI_Allreduce((void*)true dofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD);92 MPI_Allreduce((void*)truepids,(void*)alltruepids,numberofobjects,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 93 93 #else 94 for(i=0;i<numberofobjects *numberofdofsperobject;i++)alltruedofs[i]=truedofs[i];94 for(i=0;i<numberofobjects;i++)alltruepids[i]=truepids[i]; 95 95 #endif 96 96 97 /* Now every cpu knows the true dofs of everyone else that is not a clone*/98 for 97 /* Now every cpu knows the true pids of everyone else that is not a clone*/ 98 for(i=0;i<this->Size();i++){ 99 99 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); 100 vertex->UpdateClone Dofs(alltruedofs);100 vertex->UpdateClonePids(alltruepids); 101 101 } 102 102 103 103 /* Free ressources: */ 104 xDelete<int>(all dofcount);105 xDelete<int>(true dofs);106 xDelete<int>(alltrue dofs);104 xDelete<int>(allpidcount); 105 xDelete<int>(truepids); 106 xDelete<int>(alltruepids); 107 107 } 108 108 /*}}}*/ -
issm/trunk-jpl/src/c/Container/Vertices.h
r12365 r13410 19 19 public: 20 20 21 /*constructors, destructors: {{{*/21 /*constructors, destructors:*/ 22 22 Vertices(); 23 23 ~Vertices(); 24 /*}}}*/ 25 /*numerics: {{{*/26 void Distribute Dofs(int numberofnodes,int numdofspernode);24 25 /*numerics:*/ 26 void DistributePids(int numberofnodes); 27 27 void FlagClones(int numberofnodes); 28 28 int NumberOfVertices(void); 29 29 void Ranks(int* ranks); 30 /*}}}*/31 32 30 }; 33 31 -
issm/trunk-jpl/src/c/classes/objects/Elements/Penta.cpp
r13216 r13410 815 815 } 816 816 /*}}}*/ 817 /*FUNCTION Penta::Get DofList1{{{*/818 void Penta::Get DofList1(int* doflist){817 /*FUNCTION Penta::GetVertexPidList {{{*/ 818 void Penta::GetVertexPidList(int* doflist){ 819 819 820 820 int i; 821 for(i=0;i<6;i++) doflist[i]=nodes[i]->GetDofList1(); 821 for(i=0;i<6;i++) doflist[i]=nodes[i]->GetVertexPid(); 822 823 } 824 /*}}}*/ 825 /*FUNCTION Penta::GetVertexSidList{{{*/ 826 void Penta::GetVertexSidList(int* sidlist){ 827 828 int i; 829 for(i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetVertexSid(); 822 830 823 831 } … … 995 1003 * = 4 * mu * eps_eff ^2*/ 996 1004 *phi=4*pow(epsilon_eff,2.0)*viscosity; 997 }998 /*}}}*/999 /*FUNCTION Penta::GetSidList{{{*/1000 void Penta::GetSidList(int* sidlist){1001 1002 int i;1003 for(i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetSidList();1004 1005 1005 } 1006 1006 /*}}}*/ … … 1135 1135 void Penta::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum){ 1136 1136 1137 int doflist1[NUMVERTICES];1137 int vertexpidlist[NUMVERTICES]; 1138 1138 1139 1139 /*Get out if this is not an element input*/ … … 1141 1141 1142 1142 /*Prepare index list*/ 1143 this->Get DofList1(&doflist1[0]);1143 this->GetVertexPidList(&vertexpidlist[0]); 1144 1144 1145 1145 /*Get input (either in element or material)*/ … … 1148 1148 1149 1149 /*We found the enum. Use its values to fill into the vector, using the vertices ids: */ 1150 input->GetVectorFromInputs(vector,& doflist1[0]);1150 input->GetVectorFromInputs(vector,&vertexpidlist[0]); 1151 1151 } 1152 1152 /*}}}*/ … … 1160 1160 } 1161 1161 if(interp==P1Enum){ 1162 int doflist1[NUMVERTICES];1162 int vertexpidlist[NUMVERTICES]; 1163 1163 int connectivity[NUMVERTICES]; 1164 this->Get SidList(&doflist1[0]);1164 this->GetVertexSidList(&vertexpidlist[0]); 1165 1165 this->GetConnectivityList(&connectivity[0]); 1166 elementresult->GetVectorFromResults(vector,& doflist1[0],&connectivity[0],NUMVERTICES);1166 elementresult->GetVectorFromResults(vector,&vertexpidlist[0],&connectivity[0],NUMVERTICES); 1167 1167 } 1168 1168 else if(interp==P0Enum){ … … 1960 1960 /*Get values on the 6 vertices*/ 1961 1961 for (int i=0;i<6;i++){ 1962 values[i]=vector[this->nodes[i]->GetVertex Dof()];1962 values[i]=vector[this->nodes[i]->GetVertexPid()]; 1963 1963 } 1964 1964 … … 4463 4463 void Penta::ControlInputGetGradient(Vector<IssmDouble>* gradient,int enum_type,int control_index){ 4464 4464 4465 int doflist1[NUMVERTICES];4465 int vertexpidlist[NUMVERTICES]; 4466 4466 Input* input=NULL; 4467 4467 … … 4481 4481 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 4482 4482 4483 GradientIndexing(& doflist1[0],control_index);4484 ((ControlInput*)input)->GetGradient(gradient,& doflist1[0]);4483 GradientIndexing(&vertexpidlist[0],control_index); 4484 ((ControlInput*)input)->GetGradient(gradient,&vertexpidlist[0]); 4485 4485 4486 4486 }/*}}}*/ … … 4507 4507 void Penta::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){ 4508 4508 4509 int doflist1[NUMVERTICES];4509 int vertexpidlist[NUMVERTICES]; 4510 4510 IssmDouble grad_list[NUMVERTICES]; 4511 4511 Input* grad_input=NULL; … … 4524 4524 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 4525 4525 4526 GradientIndexing(& doflist1[0],control_index);4527 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[ doflist1[i]];4526 GradientIndexing(&vertexpidlist[0],control_index); 4527 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]]; 4528 4528 grad_input=new PentaP1Input(GradientEnum,grad_list); 4529 4529 ((ControlInput*)input)->SetGradient(grad_input); … … 4802 4802 /*get gradient indices*/ 4803 4803 for(int i=0;i<NUMVERTICES;i++){ 4804 indexing[i]=num_controls*this->nodes[i]->GetVertex Dof() + control_index;4804 indexing[i]=num_controls*this->nodes[i]->GetVertexPid() + control_index; 4805 4805 } 4806 4806 … … 4915 4915 int i,j,ig; 4916 4916 int analysis_type; 4917 int doflist1[NUMVERTICES];4917 int vertexpidlist[NUMVERTICES]; 4918 4918 IssmDouble vx,vy,lambda,mu,alpha_complement,Jdet; 4919 4919 IssmDouble bed,thickness,Neff,drag; … … 4932 4932 /*Retrieve all inputs and parameters*/ 4933 4933 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 4934 GradientIndexing(& doflist1[0],control_index);4934 GradientIndexing(&vertexpidlist[0],control_index); 4935 4935 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 4936 4936 for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j]; … … 4974 4974 } 4975 4975 } 4976 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);4976 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 4977 4977 4978 4978 /*Clean up and return*/ … … 4986 4986 int i,j,ig; 4987 4987 int analysis_type; 4988 int doflist1[NUMVERTICES];4988 int vertexpidlist[NUMVERTICES]; 4989 4989 IssmDouble bed,thickness,Neff; 4990 4990 IssmDouble lambda,mu,xi,Jdet,vx,vy,vz; … … 5007 5007 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 5008 5008 for(i=0;i<NUMVERTICES2D;i++) for(j=0;j<2;j++) xyz_list_tria[i][j]=xyz_list[i][j]; 5009 GradientIndexing(& doflist1[0],control_index);5009 GradientIndexing(&vertexpidlist[0],control_index); 5010 5010 Input* drag_input =inputs->GetInput(FrictionCoefficientEnum); _assert_(drag_input); 5011 5011 Input* vx_input =inputs->GetInput(VxEnum); _assert_(vx_input); … … 5067 5067 } 5068 5068 5069 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);5069 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 5070 5070 5071 5071 delete friction; … … 5494 5494 void Penta::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){ 5495 5495 5496 int doflist1[NUMVERTICES];5496 int vertexpidlist[NUMVERTICES]; 5497 5497 5498 5498 /*Get out if this is not an element input*/ … … 5500 5500 5501 5501 /*Prepare index list*/ 5502 GradientIndexing(& doflist1[0],control_index);5502 GradientIndexing(&vertexpidlist[0],control_index); 5503 5503 5504 5504 /*Get input (either in element or material)*/ … … 5511 5511 } 5512 5512 5513 ((ControlInput*)input)->GetVectorFromInputs(vector,& doflist1[0],data);5513 ((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data); 5514 5514 } 5515 5515 /*}}}*/ … … 5518 5518 5519 5519 IssmDouble values[NUMVERTICES]; 5520 int doflist1[NUMVERTICES];5520 int vertexpidlist[NUMVERTICES]; 5521 5521 Input *input = NULL; 5522 5522 Input *new_input = NULL; … … 5526 5526 5527 5527 /*Prepare index list*/ 5528 GradientIndexing(& doflist1[0],control_index);5528 GradientIndexing(&vertexpidlist[0],control_index); 5529 5529 5530 5530 /*Get values on vertices*/ 5531 5531 for (int i=0;i<NUMVERTICES;i++){ 5532 values[i]=vector[ doflist1[i]];5532 values[i]=vector[vertexpidlist[i]]; 5533 5533 } 5534 5534 new_input = new PentaP1Input(control_enum,values); … … 5569 5569 /*Get values on the 6 vertices*/ 5570 5570 for (i=0;i<6;i++){ 5571 values[i]=vector[this->nodes[i]->Get SidList()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!)5571 values[i]=vector[this->nodes[i]->GetVertexSid()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!) 5572 5572 } 5573 5573 … … 5689 5689 /*create input values: */ 5690 5690 for(i=0;i<6;i++){ 5691 row=this->nodes[i]->Get SidList();5691 row=this->nodes[i]->GetVertexSid(); 5692 5692 values[i]=(IssmDouble)matrix[ncols*row+t]; 5693 5693 } -
issm/trunk-jpl/src/c/classes/objects/Elements/Penta.h
r13216 r13410 174 174 ElementVector* CreatePVectorSlope(void); 175 175 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 176 void Get DofList1(int* doflist);177 void Get SidList(int* sidlist);176 void GetVertexPidList(int* doflist); 177 void GetVertexSidList(int* sidlist); 178 178 void GetConnectivityList(int* connectivity); 179 179 int GetElementType(void); -
issm/trunk-jpl/src/c/classes/objects/Elements/Tria.cpp
r13216 r13410 140 140 141 141 /*Figure out the average for this element: */ 142 this->Get SidList(&offsetsid[0]);143 this->Get DofList1(&offsetdof[0]);142 this->GetVertexSidList(&offsetsid[0]); 143 this->GetVertexPidList(&offsetdof[0]); 144 144 mean=0; 145 145 for(i=0;i<NUMVERTICES;i++){ … … 1055 1055 } 1056 1056 /*}}}*/ 1057 /*FUNCTION Tria::GetDofList1 {{{*/1058 void Tria::GetDofList1(int* doflist){1059 1060 int i;1061 for(i=0;i<3;i++) doflist[i]=nodes[i]->GetDofList1();1062 1063 }1064 /*}}}*/1065 1057 /*FUNCTION Tria::GetElementType {{{*/ 1066 1058 int Tria::GetElementType(){ … … 1180 1172 } 1181 1173 /*}}}*/ 1182 /*FUNCTION Tria::GetSidList {{{*/ 1183 void Tria::GetSidList(int* sidlist){ 1184 for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetSidList(); 1174 /*FUNCTION Tria::GetVertexPidList {{{*/ 1175 void Tria::GetVertexPidList(int* doflist){ 1176 1177 int i; 1178 for(i=0;i<3;i++) doflist[i]=nodes[i]->GetVertexPid(); 1179 1180 } 1181 /*}}}*/ 1182 /*FUNCTION Tria::GetVertexSidList {{{*/ 1183 void Tria::GetVertexSidList(int* sidlist){ 1184 for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->GetVertexSid(); 1185 1185 } 1186 1186 /*}}}*/ … … 1243 1243 void Tria::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum){ 1244 1244 1245 int doflist1[NUMVERTICES];1245 int vertexpidlist[NUMVERTICES]; 1246 1246 1247 1247 /*Get out if this is not an element input*/ … … 1249 1249 1250 1250 /*Prepare index list*/ 1251 this->Get DofList1(&doflist1[0]);1251 this->GetVertexPidList(&vertexpidlist[0]); 1252 1252 1253 1253 /*Get input (either in element or material)*/ … … 1256 1256 1257 1257 /*We found the enum. Use its values to fill into the vector, using the vertices ids: */ 1258 input->GetVectorFromInputs(vector,& doflist1[0]);1258 input->GetVectorFromInputs(vector,&vertexpidlist[0]); 1259 1259 } 1260 1260 /*}}}*/ … … 1268 1268 } 1269 1269 if(interp==P1Enum){ 1270 int doflist1[NUMVERTICES];1270 int vertexpidlist[NUMVERTICES]; 1271 1271 int connectivity[NUMVERTICES]; 1272 this->Get SidList(&doflist1[0]);1272 this->GetVertexSidList(&vertexpidlist[0]); 1273 1273 this->GetConnectivityList(&connectivity[0]); 1274 elementresult->GetVectorFromResults(vector,& doflist1[0],&connectivity[0],NUMVERTICES);1274 elementresult->GetVectorFromResults(vector,&vertexpidlist[0],&connectivity[0],NUMVERTICES); 1275 1275 } 1276 1276 else if(interp==P0Enum){ … … 1687 1687 /*Get values on the 3 vertices*/ 1688 1688 for (int i=0;i<3;i++){ 1689 values[i]=vector[this->nodes[i]->GetVertex Dof()];1689 values[i]=vector[this->nodes[i]->GetVertexPid()]; 1690 1690 } 1691 1691 … … 3432 3432 void Tria::ControlInputGetGradient(Vector<IssmDouble>* gradient,int enum_type,int control_index){ 3433 3433 3434 int doflist1[NUMVERTICES];3434 int vertexpidlist[NUMVERTICES]; 3435 3435 Input* input=NULL; 3436 3436 … … 3444 3444 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 3445 3445 3446 GradientIndexing(& doflist1[0],control_index);3447 ((ControlInput*)input)->GetGradient(gradient,& doflist1[0]);3446 GradientIndexing(&vertexpidlist[0],control_index); 3447 ((ControlInput*)input)->GetGradient(gradient,&vertexpidlist[0]); 3448 3448 3449 3449 }/*}}}*/ … … 3467 3467 void Tria::ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){ 3468 3468 3469 int doflist1[NUMVERTICES];3469 int vertexpidlist[NUMVERTICES]; 3470 3470 IssmDouble grad_list[NUMVERTICES]; 3471 3471 Input* grad_input=NULL; … … 3481 3481 if (input->ObjectEnum()!=ControlInputEnum) _error_("Input " << EnumToStringx(enum_type) << " is not a ControlInput"); 3482 3482 3483 GradientIndexing(& doflist1[0],control_index);3484 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[ doflist1[i]];3483 GradientIndexing(&vertexpidlist[0],control_index); 3484 for(int i=0;i<NUMVERTICES;i++) grad_list[i]=gradient[vertexpidlist[i]]; 3485 3485 grad_input=new TriaP1Input(GradientEnum,grad_list); 3486 3486 … … 3556 3556 3557 3557 int i,ig; 3558 int doflist1[NUMVERTICES];3558 int vertexpidlist[NUMVERTICES]; 3559 3559 IssmDouble Jdet,weight; 3560 3560 IssmDouble xyz_list[NUMVERTICES][3]; … … 3566 3566 /*Retrieve all inputs we will be needing: */ 3567 3567 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3568 GradientIndexing(& doflist1[0],control_index);3568 GradientIndexing(&vertexpidlist[0],control_index); 3569 3569 Input* rheologyb_input=material->inputs->GetInput(MaterialsRheologyBbarEnum); _assert_(rheologyb_input); 3570 3570 Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); … … 3586 3586 for (i=0;i<NUMVERTICES;i++) grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]); 3587 3587 } 3588 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3588 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3589 3589 3590 3590 /*Clean up and return*/ … … 3596 3596 3597 3597 int i,ig; 3598 int doflist1[NUMVERTICES];3598 int vertexpidlist[NUMVERTICES]; 3599 3599 IssmDouble Jdet,weight; 3600 3600 IssmDouble xyz_list[NUMVERTICES][3]; … … 3606 3606 /*Retrieve all inputs we will be needing: */ 3607 3607 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3608 GradientIndexing(& doflist1[0],control_index);3608 GradientIndexing(&vertexpidlist[0],control_index); 3609 3609 Input* rheologyz_input=material->inputs->GetInput(MaterialsRheologyZbarEnum); _assert_(rheologyz_input); 3610 3610 Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); … … 3626 3626 for (i=0;i<NUMVERTICES;i++) grade_g[i]+=-weight*Jdet*gauss->weight*(dbasis[0][i]*dk[0]+dbasis[1][i]*dk[1]); 3627 3627 } 3628 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3628 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3629 3629 3630 3630 /*Clean up and return*/ … … 3751 3751 int i,ig; 3752 3752 int analysis_type; 3753 int doflist1[NUMVERTICES];3753 int vertexpidlist[NUMVERTICES]; 3754 3754 int connectivity[NUMVERTICES]; 3755 3755 IssmDouble vx,vy,lambda,mu,alpha_complement,Jdet; … … 3769 3769 parameters->FindParam(&analysis_type,AnalysisTypeEnum); 3770 3770 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3771 GradientIndexing(& doflist1[0],control_index);3771 GradientIndexing(&vertexpidlist[0],control_index); 3772 3772 this->GetConnectivityList(&connectivity[0]); 3773 3773 … … 3827 3827 /*End Analytical gradient*/ 3828 3828 3829 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3829 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3830 3830 3831 3831 /*Clean up and return*/ … … 3838 3838 3839 3839 int i,ig; 3840 int doflist1[NUMVERTICES];3840 int vertexpidlist[NUMVERTICES]; 3841 3841 IssmDouble Jdet,weight; 3842 3842 IssmDouble xyz_list[NUMVERTICES][3]; … … 3849 3849 if(IsFloating())return; 3850 3850 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3851 GradientIndexing(& doflist1[0],control_index);3851 GradientIndexing(&vertexpidlist[0],control_index); 3852 3852 Input* dragcoefficient_input=inputs->GetInput(FrictionCoefficientEnum); _assert_(dragcoefficient_input); 3853 3853 Input* weights_input=inputs->GetInput(InversionCostFunctionsCoefficientsEnum); _assert_(weights_input); … … 3872 3872 } 3873 3873 } 3874 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3874 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3875 3875 3876 3876 /*Clean up and return*/ … … 3882 3882 3883 3883 /*Intermediaries*/ 3884 int doflist1[NUMVERTICES];3884 int vertexpidlist[NUMVERTICES]; 3885 3885 IssmDouble lambda[NUMVERTICES]; 3886 3886 IssmDouble gradient_g[NUMVERTICES]; 3887 3887 3888 3888 /*Compute Gradient*/ 3889 GradientIndexing(& doflist1[0],control_index);3889 GradientIndexing(&vertexpidlist[0],control_index); 3890 3890 GetInputListOnVertices(&lambda[0],AdjointEnum); 3891 3891 for(int i=0;i<NUMVERTICES;i++) gradient_g[i]=-lambda[i]; 3892 3892 3893 gradient->SetValues(NUMVERTICES, doflist1,gradient_g,INS_VAL);3893 gradient->SetValues(NUMVERTICES,vertexpidlist,gradient_g,INS_VAL); 3894 3894 } 3895 3895 /*}}}*/ … … 3899 3899 /*Intermediaries*/ 3900 3900 int i,ig; 3901 int doflist1[NUMVERTICES];3901 int vertexpidlist[NUMVERTICES]; 3902 3902 IssmDouble thickness,Jdet; 3903 3903 IssmDouble basis[3]; … … 3909 3909 /* Get node coordinates and dof list: */ 3910 3910 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3911 GradientIndexing(& doflist1[0],control_index);3911 GradientIndexing(&vertexpidlist[0],control_index); 3912 3912 3913 3913 /*Retrieve all inputs we will be needing: */ … … 3931 3931 } 3932 3932 3933 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3933 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3934 3934 3935 3935 /*Clean up and return*/ … … 3942 3942 /*Intermediaries*/ 3943 3943 int i,ig; 3944 int doflist1[NUMVERTICES];3944 int vertexpidlist[NUMVERTICES]; 3945 3945 IssmDouble thickness,Jdet; 3946 3946 IssmDouble basis[3]; … … 3952 3952 /* Get node coordinates and dof list: */ 3953 3953 GetVerticesCoordinates(&xyz_list[0][0], nodes, NUMVERTICES); 3954 GradientIndexing(& doflist1[0],control_index);3954 GradientIndexing(&vertexpidlist[0],control_index); 3955 3955 3956 3956 /*Retrieve all inputs we will be needing: */ … … 3973 3973 for(i=0;i<NUMVERTICES;i++) grade_g[i]+=thickness*Dlambda[1]*Jdet*gauss->weight*basis[i]; 3974 3974 } 3975 gradient->SetValues(NUMVERTICES, doflist1,grade_g,ADD_VAL);3975 gradient->SetValues(NUMVERTICES,vertexpidlist,grade_g,ADD_VAL); 3976 3976 3977 3977 /*Clean up and return*/ … … 3988 3988 /*get gradient indices*/ 3989 3989 for(int i=0;i<NUMVERTICES;i++){ 3990 indexing[i]=num_controls*this->nodes[i]->GetVertex Dof() + control_index;3990 indexing[i]=num_controls*this->nodes[i]->GetVertexPid() + control_index; 3991 3991 } 3992 3992 … … 5205 5205 void Tria::GetVectorFromControlInputs(Vector<IssmDouble>* vector,int control_enum,int control_index,const char* data){ 5206 5206 5207 int doflist1[NUMVERTICES];5207 int vertexpidlist[NUMVERTICES]; 5208 5208 Input *input=NULL; 5209 5209 … … 5212 5212 5213 5213 /*Prepare index list*/ 5214 GradientIndexing(& doflist1[0],control_index);5214 GradientIndexing(&vertexpidlist[0],control_index); 5215 5215 5216 5216 /*Get input (either in element or material)*/ … … 5227 5227 } 5228 5228 5229 ((ControlInput*)input)->GetVectorFromInputs(vector,& doflist1[0],data);5229 ((ControlInput*)input)->GetVectorFromInputs(vector,&vertexpidlist[0],data); 5230 5230 } 5231 5231 /*}}}*/ … … 5234 5234 5235 5235 IssmDouble values[NUMVERTICES]; 5236 int doflist1[NUMVERTICES];5236 int vertexpidlist[NUMVERTICES]; 5237 5237 Input *input = NULL; 5238 5238 Input *new_input = NULL; … … 5242 5242 5243 5243 /*Prepare index list*/ 5244 GradientIndexing(& doflist1[0],control_index);5244 GradientIndexing(&vertexpidlist[0],control_index); 5245 5245 5246 5246 /*Get values on vertices*/ 5247 5247 for (int i=0;i<NUMVERTICES;i++){ 5248 values[i]=vector[ doflist1[i]];5248 values[i]=vector[vertexpidlist[i]]; 5249 5249 } 5250 5250 new_input = new TriaP1Input(control_enum,values); … … 5556 5556 /*Get values on the 3 vertices*/ 5557 5557 for (i=0;i<3;i++){ 5558 values[i]=vector[this->nodes[i]->Get SidList()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!)5558 values[i]=vector[this->nodes[i]->GetVertexSidList()]; //careful, vector of values here is not parallel distributed, but serial distributed (from a serial Dakota core!) 5559 5559 } 5560 5560 … … 5662 5662 /*create input values: */ 5663 5663 for(i=0;i<3;i++){ 5664 row=this->nodes[i]->Get SidList();5664 row=this->nodes[i]->GetVertexSidList(); 5665 5665 values[i]=(IssmDouble)matrix[ncols*row+t]; 5666 5666 } -
issm/trunk-jpl/src/c/classes/objects/Elements/Tria.h
r13216 r13410 190 190 int GetElementType(void); 191 191 void GetDofList(int** pdoflist,int approximation_enum,int setenum); 192 void Get DofList1(int* doflist);193 void Get SidList(int* sidlist);192 void GetVertexPidList(int* doflist); 193 void GetVertexSidList(int* sidlist); 194 194 void GetConnectivityList(int* connectivity); 195 195 void GetInputListOnVertices(IssmDouble* pvalue,int enumtype); -
issm/trunk-jpl/src/c/classes/objects/Materials/Matdamageice.cpp
r13216 r13410 210 210 /*Prepare index list*/ 211 211 int doflist1[3]; 212 for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertex Dof();212 for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertexPid(); 213 213 214 214 /*Get input (either in element or material)*/ … … 640 640 case TriaEnum: { 641 641 IssmDouble values[3]; 642 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertex Dof()];642 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexPid()]; 643 643 this->inputs->AddInput(new TriaP1Input(name,values)); 644 644 return; … … 682 682 case TriaEnum: { 683 683 IssmDouble values[3]; 684 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->Get SidList()]; //use sid list, to index into serial oriented vector684 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexSid()]; //use sid list, to index into serial oriented vector 685 685 this->inputs->AddInput(new TriaP1Input(name,values)); 686 686 /*Special case for rheology B in 2D: Pourave land for this solution{{{*/ -
issm/trunk-jpl/src/c/classes/objects/Materials/Matice.cpp
r13216 r13410 190 190 /*Prepare index list*/ 191 191 int doflist1[3]; 192 for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertex Dof();192 for(int i=0;i<3;i++) doflist1[i]=((Tria*)element)->nodes[i]->GetVertexPid(); 193 193 194 194 /*Get input (either in element or material)*/ … … 560 560 case TriaEnum: { 561 561 IssmDouble values[3]; 562 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertex Dof()];562 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexPid()]; 563 563 this->inputs->AddInput(new TriaP1Input(name,values)); 564 564 return; … … 602 602 case TriaEnum: { 603 603 IssmDouble values[3]; 604 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->Get SidList()]; //use sid list, toindex into serial oriented vector604 for (int i=0;i<3;i++) values[i]=vector[((Tria*)element)->nodes[i]->GetVertexSid()]; //index into serial oriented vector 605 605 this->inputs->AddInput(new TriaP1Input(name,values)); 606 606 /*Special case for rheology B in 2D: Pourave land for this solution{{{*/ -
issm/trunk-jpl/src/c/classes/objects/Node.cpp
r13315 r13410 234 234 235 235 } /*}}}*/ 236 /*FUNCTION Node::GetDofList1{{{*/237 int Node::GetDofList1(void){238 239 Vertex* vertex=NULL;240 241 vertex=(Vertex*)this->hvertex->delivers();242 243 return vertex->dof;244 }245 /*}}}*/246 236 /*FUNCTION Node::GetDofList{{{*/ 247 237 void Node::GetDofList(int* outdoflist,int approximation_enum,int setenum){ … … 304 294 else _error_("set of enum type " << EnumToStringx(setenum) << " not supported yet!"); 305 295 } 306 }307 /*}}}*/308 /*FUNCTION Node::GetSidList{{{*/309 int Node::GetSidList(void){310 311 Vertex* vertex=NULL;312 313 vertex=(Vertex*)this->hvertex->delivers();314 315 return vertex->sid;316 296 } 317 297 /*}}}*/ … … 427 407 } 428 408 /*}}}*/ 429 /*FUNCTION Node::GetVertex Dof{{{*/430 int Node::GetVertex Dof(void){409 /*FUNCTION Node::GetVertexPid{{{*/ 410 int Node::GetVertexPid(void){ 431 411 432 412 Vertex* vertex=NULL; 433 413 434 414 vertex=(Vertex*)hvertex->delivers(); 435 return vertex->dof; 415 return vertex->pid; 416 } 417 /*}}}*/ 418 /*FUNCTION Node::GetVertexSid{{{*/ 419 int Node::GetVertexSid(void){ 420 421 Vertex* vertex=NULL; 422 423 vertex=(Vertex*)this->hvertex->delivers(); 424 425 return vertex->sid; 436 426 } 437 427 /*}}}*/ … … 446 436 /*}}}*/ 447 437 #endif 448 /*FUNCTION Node::SetVertexDof {{{*/449 void Node::SetVertexDof(int in_dof){450 451 Vertex* vertex=NULL;452 453 vertex=(Vertex*)hvertex->delivers();454 vertex->dof=in_dof;455 456 }457 /*}}}*/458 438 /*FUNCTION Node::InAnalysis{{{*/ 459 439 bool Node::InAnalysis(int in_analysis_type){ … … 887 867 /*}}}*/ 888 868 889 /* DofObjectroutines:*/869 /* indexing routines:*/ 890 870 /*FUNCTION Node::DistributeDofs{{{*/ 891 871 void Node::DistributeDofs(int* pdofcount,int setenum){ … … 935 915 } 936 916 /*}}}*/ 937 /*FUNCTION Node::Off _setDofs{{{*/917 /*FUNCTION Node::OffsetDofs{{{*/ 938 918 void Node::OffsetDofs(int dofcount,int setenum){ 939 919 -
issm/trunk-jpl/src/c/classes/objects/Node.h
r13216 r13410 67 67 void SetCurrentConfiguration(DataSet* nodes,Vertices* vertices); 68 68 int Sid(void); 69 int GetVertexDof(void);70 int GetVertexId(void);71 69 #ifdef _HAVE_DIAGNOSTIC_ 72 70 void GetCoordinateSystem(IssmDouble* coord_system_out); 73 71 #endif 74 void SetVertexDof(int in_dof);75 72 bool InAnalysis(int analysis_type); 76 73 int GetApproximation(); … … 86 83 void GetDofList(int* poutdoflist,int approximation_enum,int setenum); 87 84 void GetLocalDofList(int* poutdoflist,int approximation_enum,int setenum); 88 int GetDofList1(void); 89 int GetSidList(void); 85 int GetVertexId(void); 86 int GetVertexPid(void); 87 int GetVertexSid(void); 90 88 IssmDouble GetX(); 91 89 IssmDouble GetY(); -
issm/trunk-jpl/src/c/classes/objects/Vertex.cpp
r13216 r13410 49 49 this->id=vertex_id; 50 50 this->sid=vertex_sid; 51 this->pid=UNDEF; 51 52 this->x=vertex_x; 52 53 this->y=vertex_y; … … 54 55 this->sigma=vertex_sigma; 55 56 this->connectivity=vertex_connectivity; 56 this->dof=UNDEF;57 57 58 58 return; … … 67 67 _printLine_(" id: " << id); 68 68 _printLine_(" sid: " << sid); 69 _printLine_(" pid: " << pid); 69 70 _printLine_(" x: " << x); 70 71 _printLine_(" y: " << y); … … 72 73 _printLine_(" sigma: " << sigma); 73 74 _printLine_(" connectivity: " << connectivity); 74 _printLine_(" dof: " << dof);75 75 _printLine_(" clone: " << clone); 76 76 … … 107 107 /*}}}*/ 108 108 109 /* DofObject routines: */110 /*FUNCTION Vertex::DistributeDofs{{{*/111 void Vertex::DistributeDofs(int* pdofcount){112 113 int i;114 extern int my_rank;115 int dofcount;116 117 dofcount=*pdofcount;118 119 if(this->clone){120 /*This vertex is a clone! Don't distribute dofs, it will get them from another cpu!*/121 return;122 }123 124 /*This vertex should distribute his dof, go ahead: */125 this->dof=dofcount;126 dofcount++;127 128 /*Assign output pointers: */129 *pdofcount=dofcount;130 131 }132 /*}}}*/133 /*FUNCTION Vertex::OffsetDofs{{{*/134 void Vertex::OffsetDofs(int dofcount){135 136 int i;137 extern int my_rank;138 139 if(this->clone){140 /*This vertex is a clone, don't offset the dofs!: */141 return;142 }143 144 /*This vertex should offset his dof, go ahead: */145 this->dof+=dofcount;146 }147 /*}}}*/148 /*FUNCTION Vertex::ShowTrueDofs{{{*/149 void Vertex::ShowTrueDofs(int* truedofs){150 151 int j;152 extern int my_rank;153 154 /*Are we a clone? : */155 if(this->clone)return;156 157 /*Ok, we are not a clone, just plug our dof into truedofs: */158 truedofs[this->id-1]=this->dof;159 160 }161 /*}}}*/162 /*FUNCTION Vertex::UpdateCloneDofs{{{*/163 void Vertex::UpdateCloneDofs(int* alltruedofs){164 165 int j;166 extern int my_rank;167 168 /*If we are not a clone, don't update, we already have dofs!: */169 if(this->clone==0)return;170 171 /*Ok, we are a clone node, but we did not create the dof for this vertex172 * Therefore, our dof is garbage right now. Go pick it up in the alltruedofs: */173 this->dof=alltruedofs[id-1];174 }175 /*}}}*/176 /*FUNCTION Vertex::SetClone {{{*/177 void Vertex::SetClone(int* minranks){178 179 extern int my_rank;180 181 if (minranks[id-1]==my_rank){182 this->clone=0;183 }184 else{185 /*!there is a cpu with lower rank that has the same vertex,186 therefore, I am a clone*/187 this->clone=1;188 }189 190 }191 /*}}}*/192 193 109 /*Vertex management: */ 194 110 /*FUNCTION Vertex::Connectivity{{{*/ … … 209 125 /*sigma remains constant. z=bed+sigma*thickness*/ 210 126 oldz = this->z; 211 newz = bed[this-> dof]+sigma*thickness[this->dof];127 newz = bed[this->pid]+sigma*thickness[this->pid]; 212 128 velz = (newz-oldz)/dt; 213 129 this->z = newz; 214 130 215 131 /*put vz in vector*/ 216 vz->SetValue(this-> dof,velz,INS_VAL);132 vz->SetValue(this->pid,velz,INS_VAL); 217 133 } 218 134 /*}}}*/ 135 /*FUNCTION Vertex::DistributePids{{{*/ 136 void Vertex::DistributePids(int* ppidcount){ 137 138 /*retrieve current pid*/ 139 int pidcount=*ppidcount; 140 141 /*This vertex is a clone! Don't distribute pids, it will get them from another cpu!*/ 142 if(this->clone) return; 143 144 /*This vertex should distribute its pid*/ 145 this->pid=pidcount; 146 pidcount++; 147 148 /*Assign output pointers: */ 149 *ppidcount=pidcount; 150 } 151 /*}}}*/ 152 /*FUNCTION Vertex::OffsetPids{{{*/ 153 void Vertex::OffsetPids(int pidcount){ 154 155 /*This vertex is a clone, don't offset the pids*/ 156 if(this->clone) return; 157 158 /*This vertex should offset his pid, go ahead: */ 159 this->pid+=pidcount; 160 } 161 /*}}}*/ 162 /*FUNCTION Vertex::ShowTruePids{{{*/ 163 void Vertex::ShowTruePids(int* truepids){ 164 165 /*Are we a clone? : */ 166 if(this->clone)return; 167 168 /*Ok, we are not a clone, just plug our pid into truepids: */ 169 truepids[this->sid]=this->pid; 170 } 171 /*}}}*/ 172 /*FUNCTION Vertex::UpdateClonePids{{{*/ 173 void Vertex::UpdateClonePids(int* alltruepids){ 174 175 /*If we are not a clone, don't update, we already have pids: */ 176 if(!this->clone)return; 177 178 /*Ok, we are a clone node, but we did not create the pid for this vertex 179 * Therefore, our pid is garbage right now. Go pick it up in the alltruepids: */ 180 this->pid=alltruepids[this->pid]; 181 } 182 /*}}}*/ 183 /*FUNCTION Vertex::SetClone {{{*/ 184 void Vertex::SetClone(int* minranks){ 185 186 extern int my_rank; 187 188 if (minranks[this->sid]==my_rank){ 189 this->clone=false; 190 } 191 else{ 192 /*!there is a cpu with lower rank that has the same vertex, 193 therefore, I am a clone*/ 194 this->clone=true; 195 } 196 197 } 198 /*}}}*/ 199 -
issm/trunk-jpl/src/c/classes/objects/Vertex.h
r13216 r13410 22 22 23 23 public: 24 25 int id; 26 int sid; //sid for "serial" id, ie the rank of this vertex in the vertices dataset, if the dataset was serial on 1 cpu. 24 bool clone; 25 int id; // random index 26 int sid; // "serial" id (rank of this vertex if the dataset was on 1 cpu) 27 int pid; // "parallel" id 27 28 IssmDouble x; 28 29 IssmDouble y; 29 30 IssmDouble z; 30 IssmDouble sigma; //sigma coordinate: (z-bed)/thickness 31 int connectivity; //number of vertices connected to this vertex 32 33 /*dof management: */ 34 int clone; 35 int dof; //dof to recover values in a vertex indexed vector 31 IssmDouble sigma; //sigma coordinate: (z-bed)/thickness 32 int connectivity; //number of vertices connected to this vertex 36 33 37 34 /*Vertex constructors, destructors {{{*/ … … 50 47 Object* copy(); 51 48 /*}}}*/ 52 /*DofObject routines {{{*/ 53 void DistributeDofs(int* pdofcount); 54 void OffsetDofs(int dofcount); 55 void ShowTrueDofs(int* borderdofs); 56 void UpdateCloneDofs(int* allborderdofs); 57 void SetClone(int* minranks); 58 /*}}}*/ 59 /*Vertex management: {{{*/ 49 /*Vertex management:*/ 60 50 int Sid(void); 61 51 int Connectivity(void); 62 52 void UpdatePosition(Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed); 63 /*}}}*/ 53 void DistributePids(int* ppidcount); 54 void OffsetPids(int pidcount); 55 void ShowTruePids(int* borderpids); 56 void UpdateClonePids(int* allborderpids); 57 void SetClone(int* minranks); 64 58 }; 65 59 #endif /* _VERTEX_H */ -
issm/trunk-jpl/src/c/modules/VerticesDofx/VerticesDofx.cpp
r6232 r13410 11 11 void VerticesDofx( Vertices* vertices, Parameters* parameters) { 12 12 13 int i;14 15 int found=0;16 extern int num_procs;17 extern int my_rank;18 19 13 /*intermediary: */ 20 14 int numberofvertices; … … 23 17 numberofvertices=vertices->NumberOfVertices(); 24 18 25 /*Ensure that only for each cpu, the partition border vertices only will be taken into account once 26 * across the cluster. To do so, we flag all the clone vertices: */ 19 /*Ensure that only for each cpu, the partition border vertices only will be 20 * taken into account once across the cluster. To do so, we flag all the 21 * clone vertices: */ 27 22 vertices->FlagClones(numberofvertices); 28 23 29 /*Go through all vertices and distribute 1 dof at a time. When a vertex has already been distributed his dof on a cpu, 30 * all other cpus with the same vertex cannot distribute it anymore. Use clone field to be sure of that: */ 31 vertices->DistributeDofs(numberofvertices,1); //only 1 dof per vertex. 24 /*Go through all vertices and distribute pids*/ 25 vertices->DistributePids(numberofvertices); 32 26 33 27 }
Note:
See TracChangeset
for help on using the changeset viewer.