Changeset 3463
- Timestamp:
- 04/08/10 09:48:24 (15 years ago)
- Location:
- issm/trunk/src/c
- Files:
-
- 1 added
- 43 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/DataSet/DataSet.cpp
r3454 r3463 947 947 /*}}}*/ 948 948 /*FUNCTION DataSet::DistributeDofs{{{1*/ 949 void DataSet::DistributeDofs(int numberofnodes,int numdofspernode){ 950 951 int dofcount=0; 952 int dofcount1=0; 953 int* alldofcount=NULL; 954 int* alldofcount1=NULL; 955 int* borderdofs=NULL; 956 int* borderdofs1=NULL; 957 int* allborderdofs=NULL; 958 int* allborderdofs1=NULL; 959 int i; 960 vector<Object*>::iterator object; 961 Node* node=NULL; 949 void DataSet::DistributeDofs(int numberofobjects,int numberofdofsperobject){ 962 950 963 951 extern int num_procs; 964 952 extern int my_rank; 965 953 966 dofcount=0; 967 for ( object=objects.begin() ; object < objects.end(); object++ ){ 968 969 /*Check this is a node: */ 970 if((*object)->Enum()==NodeEnum()){ 971 972 node=(Node*)(*object); 973 974 /*Ok, this object is a node, ask it to distribute dofs, and update the dofcount: */ 975 node->DistributeDofs(&dofcount,&dofcount1); 976 977 } 978 } 979 980 /*Ok, now every node has distributed dofs, but locally, and with a dof count starting from 954 int i; 955 956 int dofcount=0; 957 int* alldofcount=NULL; 958 int* truedofs=NULL; 959 int* alltruedofs=NULL; 960 vector<Object*>::iterator object; 961 DofObject* dofobject=NULL; 962 963 /*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject: */ 964 for ( object=objects.begin() ; object < objects.end(); object++ ){ 965 966 dofobject=(DofObject*)(*object); 967 dofobject->DistributeDofs(&dofcount); 968 969 970 } 971 972 /*Ok, now every object has distributed dofs, but locally, and with a dof count starting from 981 973 *0. This means the dofs between all the cpus are not synchronized! We need to synchronize all 982 *dof on all cpus, and use those to update the dofs of every node: */974 *dof on all cpus, and use those to update the dofs of every object: */ 983 975 984 976 alldofcount=(int*)xmalloc(num_procs*sizeof(int)); … … 986 978 MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD); 987 979 988 alldofcount1=(int*)xmalloc(num_procs*sizeof(int));989 MPI_Gather(&dofcount1,1,MPI_INT,alldofcount1,1,MPI_INT,0,MPI_COMM_WORLD);990 MPI_Bcast(alldofcount1,num_procs,MPI_INT,0,MPI_COMM_WORLD);991 992 980 /*Ok, now every cpu should start its own dof count at the end of the dofcount 993 981 * from cpu-1. : */ 994 982 dofcount=0; 995 dofcount1=0;996 983 if(my_rank==0){ 997 984 dofcount=0; 998 dofcount1=0;999 985 } 1000 986 else{ 1001 987 for(i=0;i<my_rank;i++){ 1002 988 dofcount+=alldofcount[i]; 1003 dofcount1+=alldofcount1[i];1004 989 } 1005 990 } … … 1009 994 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1010 995 1011 /*Check this is a node: */ 1012 if((*object)->Enum()==NodeEnum()){ 1013 1014 node=(Node*)(*object); 1015 1016 /*Ok, this object is a node, ask it to update his dofs: */ 1017 node->UpdateDofs(dofcount,dofcount1); 1018 1019 } 1020 } 1021 1022 /*Finally, remember that cpus may have skipped some nodes, when these nodes were 1023 * clones: */ 1024 borderdofs=(int*)xcalloc(numberofnodes*numdofspernode,sizeof(int)); 1025 allborderdofs=(int*)xcalloc(numberofnodes*numdofspernode,sizeof(int)); 1026 borderdofs1=(int*)xcalloc(numberofnodes*3,sizeof(int)); 1027 allborderdofs1=(int*)xcalloc(numberofnodes*3,sizeof(int)); 1028 1029 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1030 1031 /*Check this is a node: */ 1032 if((*object)->Enum()==NodeEnum()){ 1033 1034 node=(Node*)(*object); 1035 1036 /*Ok, let this object show its border dofs, if is is a border dof: */ 1037 node->ShowBorderDofs(borderdofs,borderdofs1); 1038 1039 } 1040 } 1041 MPI_Allreduce ( (void*)borderdofs,(void*)allborderdofs,numberofnodes*numdofspernode,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 1042 MPI_Allreduce ( (void*)borderdofs1,(void*)allborderdofs1,numberofnodes*3,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 1043 1044 /*Ok, now every cpu knows everyone else's border node dofs, update the border dofs accordingly: */ 1045 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1046 1047 /*Check this is a node: */ 1048 if((*object)->Enum()==NodeEnum()){ 1049 1050 node=(Node*)(*object); 1051 1052 /*Ok, this object is a node, ask it to update his dofs: */ 1053 node->UpdateBorderDofs(allborderdofs,allborderdofs1); 1054 1055 } 1056 } 1057 996 dofobject=(DofObject*)(*object); 997 dofobject->OffsetDofs(dofcount); 998 999 } 1000 1001 /*Finally, remember that cpus may have skipped some objects, because they were clones. For every 1002 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 1003 * up by their clones: */ 1004 truedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int)); 1005 alltruedofs=(int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int)); 1006 1007 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1008 1009 /*Ok, let this object show its true dofs, if is is a true dof: */ 1010 dofobject=(DofObject*)(*object); 1011 dofobject->ShowTrueDofs(truedofs); 1012 } 1013 1014 MPI_Allreduce ( (void*)truedofs,(void*)alltruedofs,numberofobjects*numberofdofsperobject,MPI_INT,MPI_MAX,MPI_COMM_WORLD); 1015 1016 /*Ok, now every cpu knows the true dofs of everyone else that is not a clone. Let the clones recover those true dofs: */ 1017 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1018 1019 dofobject=(DofObject*)(*object); 1020 dofobject->UpdateCloneDofs(alltruedofs); 1021 1022 } 1058 1023 1059 1024 /* Free ressources: */ 1060 1025 xfree((void**)&alldofcount); 1061 xfree((void**)&borderdofs); 1062 xfree((void**)&allborderdofs); 1063 xfree((void**)&alldofcount1); 1064 xfree((void**)&borderdofs1); 1065 xfree((void**)&allborderdofs1); 1066 1067 return; 1026 xfree((void**)&truedofs); 1027 xfree((void**)&alltruedofs); 1068 1028 1069 1029 } … … 1157 1117 1158 1118 vector<Object*>::iterator object; 1119 DofObject* dofobject=NULL; 1159 1120 1160 1121 /*Allocate ranks: */ … … 1188 1149 for ( object=objects.begin() ; object < objects.end(); object++ ){ 1189 1150 1190 /*Check this is a vertex: */ 1191 if((*object)->Enum()==NodeEnum()){ 1192 1193 /*For this object, decide whether it is a clone: */ 1194 (*object)->SetClone(minranks); 1195 1196 } 1151 /*For this object, decide whether it is a clone: */ 1152 dofobject=(DofObject*)(*object); 1153 dofobject->SetClone(minranks); 1197 1154 } 1198 1155 -
issm/trunk/src/c/Dofx/Dofx.cpp
r3417 r3463 48 48 nodes->FlagClones(numberofnodes); 49 49 50 /*Go through all nodes, and build degree of freedom lists. Eachnode gets a fixed number of dofs. When51 *a node has already been distributed dofs on one cpu, all other cpus with the samenode cannot distribute it50 /*Go through all vertices and nodes, and build degree of freedom lists. Each vertex/node gets a fixed number of dofs. When 51 *a vertex/node has already been distributed dofs on one cpu, all other cpus with the same vertex/node cannot distribute it 52 52 *anymore. Use clone field to be sure of that: */ 53 vertices->DistributeDofs(numberofvertices,1); //only 1 dof per vertex. 53 54 nodes->DistributeDofs(numberofnodes,numberofdofspernode); 54 55 -
issm/trunk/src/c/objects/DofIndexing.cpp
r3420 r3463 24 24 int i; 25 25 this->numberofdofs=UNDEF; 26 this->partitionborder=UNDEF; 27 this->clone=UNDEF; 26 this->clone=0; 28 27 29 28 for (i=0;i<MAXDOFSPERNODE;i++){ … … 38 37 /*}}}*/ 39 38 /*FUNCTION DofIndexing constructor {{{1*/ 40 DofIndexing::DofIndexing(int in_numberofdofs, int in_partitionborder){ 41 42 this->Init(in_numberofdofs,in_partitionborder); 39 DofIndexing::DofIndexing(int in_numberofdofs){ 40 this->Init(in_numberofdofs); 43 41 } 44 42 /*}}}*/ 45 43 /*FUNCTION DofIndexing Init: used by constructor {{{1*/ 46 void DofIndexing::Init(int in_numberofdofs , int in_partitionborder){44 void DofIndexing::Init(int in_numberofdofs){ 47 45 48 46 int i; 49 47 this->numberofdofs=in_numberofdofs; 50 this->partitionborder=in_partitionborder; 51 this->clone=UNDEF; 48 this->clone=0; 52 49 53 50 for (i=0;i<MAXDOFSPERNODE;i++){ … … 66 63 int i; 67 64 this->numberofdofs=in->numberofdofs; 68 this->partitionborder=in->partitionborder;69 65 this->clone=in->clone; 70 66 … … 101 97 /*marshall DofIndexing data: */ 102 98 memcpy(marshalled_dataset,&numberofdofs,sizeof(numberofdofs));marshalled_dataset+=sizeof(numberofdofs); 103 memcpy(marshalled_dataset,&partitionborder,sizeof(partitionborder));marshalled_dataset+=sizeof(partitionborder);104 99 memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone); 105 100 memcpy(marshalled_dataset,&m_set,sizeof(m_set));marshalled_dataset+=sizeof(m_set); … … 117 112 118 113 return sizeof(numberofdofs)+ 119 sizeof(partitionborder)+120 114 sizeof(clone)+ 121 115 sizeof(m_set)+ … … 139 133 140 134 memcpy(&numberofdofs,marshalled_dataset,sizeof(numberofdofs));marshalled_dataset+=sizeof(numberofdofs); 141 memcpy(&partitionborder,marshalled_dataset,sizeof(partitionborder));marshalled_dataset+=sizeof(partitionborder);142 135 memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone); 143 136 memcpy(&m_set,marshalled_dataset,sizeof(m_set));marshalled_dataset+=sizeof(m_set); … … 159 152 printf("DofIndexing:\n"); 160 153 printf(" numberofdofs: %i\n",numberofdofs); 161 printf(" partitionborder: %i\n",partitionborder);162 154 printf(" clone: %i\n",clone); 163 155 } … … 170 162 printf("DofIndexing:\n"); 171 163 printf(" numberofdofs: %i\n",numberofdofs); 172 printf(" partitionborder: %i\n",partitionborder);173 164 printf(" clone: %i\n",clone); 174 165 -
issm/trunk/src/c/objects/DofIndexing.h
r3420 r3463 15 15 16 16 /*partitioning: */ 17 int partitionborder; /*! during parallel partitioning, does this grid belong to a partition border?*/ 18 int clone; /*!this nodes is one the partition border, and is cloned*/ 17 int clone; //this node is replicated from another one 19 18 20 19 /*boundary conditions sets: */ … … 28 27 29 28 DofIndexing(); 30 DofIndexing(int numberofdofs , int partitionborder);31 void Init(int numberofdofs , int partitionborder);29 DofIndexing(int numberofdofs); 30 void Init(int numberofdofs); 32 31 DofIndexing(DofIndexing* properties); 33 32 ~DofIndexing(); -
issm/trunk/src/c/objects/DofVec.cpp
r3454 r3463 418 418 return vector; 419 419 } 420 /*FUNCTION DofVec::SetClone {{{1*/421 void DofVec::SetClone(int* minranks){422 423 ISSMERROR("not implemented yet");424 }425 /*}}}1*/ -
issm/trunk/src/c/objects/DofVec.h
r3454 r3463 45 45 int MyRank(); 46 46 int Size(); 47 void SetClone(int* minranks);48 47 49 48 -
issm/trunk/src/c/objects/Element.h
r3454 r3463 21 21 virtual int MyRank()=0; 22 22 virtual void Marshall(char** pmarshalled_dataset)=0; 23 virtual void SetClone(int* minranks)=0;24 23 virtual int MarshallSize()=0; 25 24 virtual char* GetName()=0; -
issm/trunk/src/c/objects/FemModel.cpp
r3454 r3463 225 225 Mat FemModel::get_Gmn(void){return Gmn;} 226 226 /*}}}*/ 227 /*FUNCTION FemModel::FemModel {{{1*/228 void FemModel::SetClone(int* minranks){229 230 ISSMERROR("not implemented yet");231 }232 /*}}}1*/ -
issm/trunk/src/c/objects/FemModel.h
r3454 r3463 55 55 int Enum(); 56 56 Object* copy(); 57 void SetClone(int* minranks);58 57 59 58 int FindParam(double* pscalar,char* name); -
issm/trunk/src/c/objects/Icefront.cpp
r3454 r3463 1478 1478 } 1479 1479 /*}}}*/ 1480 /*FUNCTION Icefront::SetClone {{{1*/1481 void Icefront::SetClone(int* minranks){1482 1483 ISSMERROR("not implemented yet");1484 }1485 /*}}}1*/1486 1480 /*FUNCTION Icefront UpdateFromInputs {{{1*/ 1487 1481 void Icefront::UpdateFromInputs(void* vinputs){ -
issm/trunk/src/c/objects/Icefront.h
r3454 r3463 69 69 int MarshallSize(); 70 70 int MyRank(); 71 void SetClone(int* minranks);72 71 73 72 /*}}}*/ -
issm/trunk/src/c/objects/Input.cpp
r3454 r3463 301 301 } 302 302 /*}}}*/ 303 /*FUNCTION Input::SetClone {{{1*/304 void Input::SetClone(int* minranks){305 306 ISSMERROR("not implemented yet");307 }308 /*}}}1*/ -
issm/trunk/src/c/objects/Input.h
r3454 r3463 39 39 40 40 Object* copy(); 41 void SetClone(int* minranks);42 41 43 42 /*fill virtual routines: */ -
issm/trunk/src/c/objects/Load.h
r3454 r3463 32 32 virtual void PenaltyCreateKMatrix(Mat Kgg,void* inputs,double kmax,int analysis_type,int sub_analysis_type)=0; 33 33 virtual void PenaltyCreatePVector(Vec pg,void* inputs,double kmax,int analysis_type,int sub_analysis_type)=0; 34 virtual void SetClone(int* minranks)=0;35 34 36 35 int Enum(); -
issm/trunk/src/c/objects/Material.h
r3454 r3463 21 21 virtual int MyRank()=0; 22 22 virtual void Marshall(char** pmarshalled_dataset)=0; 23 virtual void SetClone(int* minranks)=0;24 23 virtual int MarshallSize()=0; 25 24 virtual char* GetName()=0; -
issm/trunk/src/c/objects/Matice.cpp
r3454 r3463 441 441 } 442 442 /*}}}*/ 443 //*FUNCTION Matice::SetClone {{{1*/444 void Matice::SetClone(int* minranks){445 446 ISSMERROR("not implemented yet");447 }448 /*}}}1*/449 -
issm/trunk/src/c/objects/Matice.h
r3454 r3463 44 44 double GetB(); 45 45 double GetN(); 46 void SetClone(int* minranks);47 46 48 47 }; -
issm/trunk/src/c/objects/Matpar.cpp
r3454 r3463 289 289 } 290 290 /*}}}1*/ 291 /*FUNCTION Matpar::SetClone {{{1*/292 void Matpar::SetClone(int* minranks){293 294 ISSMERROR("not implemented yet");295 }296 /*}}}1*/ -
issm/trunk/src/c/objects/Matpar.h
r3454 r3463 57 57 double GetMeltingPoint(); 58 58 Object* copy(); 59 void SetClone(int* minranks);60 59 61 60 }; -
issm/trunk/src/c/objects/Node.cpp
r3451 r3463 29 29 /*}}}*/ 30 30 /*FUNCTION Node constructor {{{2*/ 31 Node::Node(int node_id,int node_vertex_id, int node_upper_node_id, int node_ partitionborder,int node_numdofs, NodeProperties* node_properties):32 indexing(node_numdofs ,node_partitionborder),31 Node::Node(int node_id,int node_vertex_id, int node_upper_node_id, int node_numdofs, NodeProperties* node_properties): 32 indexing(node_numdofs), 33 33 properties(node_properties), 34 34 hvertex(&node_vertex_id,1), … … 58 58 59 59 int numdofs; 60 int partitionborder;61 60 int vertex_id; 62 61 int upper_node_id; … … 67 66 /*indexing:*/ 68 67 DistributeNumDofs(&numdofs,iomodel->analysis_type,iomodel->sub_analysis_type); //number of dofs per node 69 if(iomodel->my_bordervertices[i]) partitionborder=1; else partitionborder=0;//is this node on a partition border? 70 71 this->indexing.Init(numdofs,partitionborder); 68 69 this->indexing.Init(numdofs); 72 70 73 71 /*properties: */ … … 163 161 164 162 int numdofs; 165 int partitionborder;166 163 int vertex_id; 167 164 int upper_node_id; … … 172 169 /*indexing:*/ 173 170 DistributeNumDofs(&numdofs,iomodel->analysis_type,iomodel->sub_analysis_type); //number of dofs per node 174 if(iomodel->my_bordervertices[i])partitionborder=1; else partitionborder=0;//is this node on a partition border? 175 176 this->indexing.Init(numdofs,partitionborder); 171 172 this->indexing.Init(numdofs); 177 173 178 174 /*properties (come from vertex number i): */ … … 459 455 460 456 461 }462 /*}}}*/463 /*FUNCTION Node DistributeDofs{{{2*/464 void Node::DistributeDofs(int* pdofcount,int* pdofcount1){465 466 int i;467 extern int my_rank;468 int dofcount;469 int dofcount1;470 471 dofcount=*pdofcount;472 dofcount1=*pdofcount1;473 474 if(indexing.clone){475 /*This node is a clone! Don't distribute dofs, it will get them from another cpu!*/476 return;477 }478 479 /*This node should distribute dofs, go ahead: */480 for(i=0;i<this->indexing.numberofdofs;i++){481 indexing.doflist[i]=dofcount+i;482 }483 dofcount+=this->indexing.numberofdofs;484 485 SetVertexDof(dofcount1);486 dofcount1+=1;487 488 /*Assign output pointers: */489 *pdofcount=dofcount;490 *pdofcount1=dofcount1;491 492 return;493 457 } 494 458 /*}}}*/ … … 851 815 } 852 816 /*}}}*/ 817 /*FUNCTION Node UpdateFromInputs {{{2*/ 818 void Node::UpdateFromInputs(void* vinputs){ 819 820 ISSMERROR("not used yet!"); 821 822 } 823 /*}}}*/ 824 /*}}}*/ 825 /* DofObject routines: {{{1* 826 /*FUNCTION Node DistributeDofs{{{2*/ 827 void Node::DistributeDofs(int* pdofcount){ 828 829 int i; 830 extern int my_rank; 831 int dofcount; 832 833 dofcount=*pdofcount; 834 835 if(indexing.clone){ 836 /*This node is a clone! Don't distribute dofs, it will get them from another cpu!*/ 837 return; 838 } 839 840 /*This node should distribute dofs, go ahead: */ 841 for(i=0;i<this->indexing.numberofdofs;i++){ 842 indexing.doflist[i]=dofcount+i; 843 } 844 dofcount+=this->indexing.numberofdofs; 845 846 /*Assign output pointers: */ 847 *pdofcount=dofcount; 848 849 } 850 /*}}}*/ 851 /*FUNCTION Node OffsetDofs{{{2*/ 852 void Node::OffsetDofs(int dofcount){ 853 854 int i; 855 extern int my_rank; 856 857 if(indexing.clone){ 858 /*This node is a clone, don't offset the dofs!: */ 859 return; 860 } 861 862 /*This node should offset the dofs, go ahead: */ 863 for(i=0;i<this->indexing.numberofdofs;i++){ 864 indexing.doflist[i]+=dofcount; 865 } 866 } 867 /*}}}*/ 868 /*FUNCTION Node ShowTrueDofs{{{2*/ 869 void Node::ShowTrueDofs(int* truedofs){ 870 871 int j; 872 extern int my_rank; 873 874 /*Are we a clone? : */ 875 if(indexing.clone)return; 876 877 /*Ok, we are not a clone, just plug our dofs into truedofs: */ 878 for(j=0;j<this->indexing.numberofdofs;j++){ 879 *(truedofs+this->indexing.numberofdofs*(id-1)+j)=indexing.doflist[j]; 880 } 881 882 } 883 /*}}}*/ 884 /*FUNCTION Node UpdateCloneDofs{{{2*/ 885 void Node::UpdateCloneDofs(int* alltruedofs){ 886 887 int j; 888 extern int my_rank; 889 890 /*If we are not a clone, don't update, we already have dofs!: */ 891 if(indexing.clone==0)return; 892 893 /*Ok, we are a clone node, but we did not create the dofs for this node. 894 * Therefore, our doflist is garbage right now. Go pick it up in the alltruedofs: */ 895 for(j=0;j<this->indexing.numberofdofs;j++){ 896 indexing.doflist[j]=*(alltruedofs+this->indexing.numberofdofs*(id-1)+j); 897 } 898 } 899 /*}}}*/ 853 900 /*FUNCTION Node SetClone {{{2*/ 854 901 void Node::SetClone(int* minranks){ … … 867 914 } 868 915 /*}}}*/ 869 /*FUNCTION Node ShowBorderDofs{{{2*/ 870 void Node::ShowBorderDofs(int* borderdofs,int* borderdofs1){ 871 872 int j; 873 extern int my_rank; 874 875 /*Is this node on the partition border? */ 876 if(!indexing.partitionborder)return; 877 878 /*Are we the cpu that created this node's dof list? */ 879 if(indexing.clone)return; 880 881 /*Ok, we are on the partition border, and we did create the 882 * dofs for this node, plug the doflist into borderdofs: */ 883 for(j=0;j<this->indexing.numberofdofs;j++){ 884 *(borderdofs+this->indexing.numberofdofs*(id-1)+j)=indexing.doflist[j]; 885 } 886 *(borderdofs1+(id-1)+0)=this->GetVertexDof(); 887 888 return; 889 } 890 /*}}}*/ 891 /*FUNCTION Node UpdateBorderDofs{{{2*/ 892 void Node::UpdateBorderDofs(int* allborderdofs,int* allborderdofs1){ 893 894 int j; 895 extern int my_rank; 896 897 /*Is this node on the partition border? */ 898 if(!indexing.partitionborder)return; 899 900 /*Are we the cpu that created this node's dof list? */ 901 if(indexing.clone==0)return; 902 903 /*Ok, we are on the partition border, but we did not create 904 * the dofs for this node. Therefore, our doflist is garbage right 905 * now. Go pick it up in the allborderdofs: */ 906 for(j=0;j<this->indexing.numberofdofs;j++){ 907 indexing.doflist[j]=*(allborderdofs+this->indexing.numberofdofs*(id-1)+j); 908 } 909 this->SetVertexDof(*(allborderdofs1+(id-1)+0)); 910 return; 911 } 912 /*}}}*/ 913 /*FUNCTION Node UpdateDofs{{{2*/ 914 void Node::UpdateDofs(int dofcount,int dofcount1){ 915 916 int i; 917 extern int my_rank; 918 919 if(indexing.clone){ 920 /*This node is a clone, don't update the dofs!: */ 921 return; 922 } 923 924 /*This node should update the dofs, go ahead: */ 925 for(i=0;i<this->indexing.numberofdofs;i++){ 926 indexing.doflist[i]+=dofcount; 927 } 928 this->SetVertexDof(this->GetVertexDof()+dofcount1); 929 930 return; 931 } 932 /*}}}*/ 933 /*FUNCTION Node UpdateFromInputs {{{2*/ 934 void Node::UpdateFromInputs(void* vinputs){ 935 936 ISSMERROR("not used yet!"); 937 938 } 939 /*}}}*/ 940 /*}}}*/ 916 /*}}}*/ -
issm/trunk/src/c/objects/Node.h
r3451 r3463 14 14 class NodeProperties; 15 15 class Node; 16 class DofObject; 16 17 17 18 #include "./Object.h" 19 #include "./DofObject.h" 18 20 #include "../DataSet/DataSet.h" 19 21 #include "./Hook.h" … … 24 26 #include "../ModelProcessorx/IoModel.h" 25 27 26 class Node: public Object {28 class Node: public Object,public DofObject{ 27 29 28 30 private: … … 40 42 /*FUNCTION constructors, destructors {{{1*/ 41 43 Node(); 42 Node(int id,int vertex_id, int upper_node_id, int partitionborder,intnumberofdofs, NodeProperties* node_properties);44 Node(int id,int vertex_id, int upper_node_id, int numberofdofs, NodeProperties* node_properties); 43 45 Node(int id,DofIndexing* indexing, NodeProperties* properties, Hook* vertex, Hook* upper_node); 44 46 Node(int i, IoModel* iomodel); … … 61 63 /*}}}*/ 62 64 /*FUNCTION numerical routines {{{1*/ 63 void DistributeDofs(int* pdofcount,int* pdofcount1);64 void UpdateDofs(int dofcount,int dofcount1);65 void ShowBorderDofs(int* borderdofs,int* borderdofs1);66 void UpdateBorderDofs(int* allborderdofs,int* allborderdofs1);67 65 void CreatePartition(Vec partition); 68 void SetClone(int* minranks);69 66 int GetNumberOfDofs(); 70 67 int IsClone(); … … 93 90 void FieldExtrude(Vec field,double* field_serial,char* field_name); 94 91 /*}}}*/ 92 /*FUNCTION DofObject routines {{{1*/ 93 void DistributeDofs(int* pdofcount); 94 void OffsetDofs(int dofcount); 95 void ShowTrueDofs(int* borderdofs); 96 void UpdateCloneDofs(int* allborderdofs); 97 void SetClone(int* minranks); 98 /*}}}*/ 95 99 }; 96 100 -
issm/trunk/src/c/objects/Numericalflux.cpp
r3454 r3463 751 751 } 752 752 /*}}}*/ 753 /*FUNCTION Numericalflux::SetClone {{{1*/754 void Numericalflux::SetClone(int* minranks){755 756 ISSMERROR("not implemented yet");757 }758 /*}}}1*/ -
issm/trunk/src/c/objects/Numericalflux.h
r3454 r3463 48 48 int Enum(); 49 49 int GetId(); 50 void SetClone(int* minranks);51 50 void GetJacobianDeterminant(double* pJdet,double xyz_list[4][3], double gauss_coord); 52 51 void GetNodalFunctions(double* l1l4, double gauss_coord); -
issm/trunk/src/c/objects/Numpar.cpp
r3454 r3463 245 245 } 246 246 /*}}}*/ 247 /*FUNCTION Numpar::SetClone {{{1*/248 void Numpar::SetClone(int* minranks){249 250 ISSMERROR("not implemented yet");251 }252 /*}}}1*/ -
issm/trunk/src/c/objects/Numpar.h
r3454 r3463 43 43 int Enum(); 44 44 Object* copy(); 45 void SetClone(int* minranks);46 45 47 46 void Configure(void* pparametersin); -
issm/trunk/src/c/objects/Object.h
r3454 r3463 25 25 virtual void Demarshall(char** pmarshalled_dataset)=0; 26 26 virtual int Enum()=0; 27 virtual void SetClone(int* minranks)=0;28 27 virtual Object* copy()=0; 29 28 29 30 30 }; 31 31 #endif -
issm/trunk/src/c/objects/Param.cpp
r3454 r3463 724 724 } 725 725 /*}}}*/ 726 /*FUNCTION Param::SetClone {{{1*/727 void Param::SetClone(int* minranks){728 729 ISSMERROR("not implemented yet");730 }731 /*}}}1*/ -
issm/trunk/src/c/objects/Param.h
r3454 r3463 45 45 void Demarshall(char** pmarshalled_dataset); 46 46 int Enum(); 47 void SetClone(int* minranks);48 47 49 48 void SetDouble(double value); -
issm/trunk/src/c/objects/Pengrid.cpp
r3454 r3463 636 636 } 637 637 /*}}}1*/ 638 /*FUNCTION Pengrid::SetClone {{{1*/639 void Pengrid::SetClone(int* minranks){640 641 ISSMERROR("not implemented yet");642 }643 /*}}}1*/644 638 /*FUNCTION Pengrid::UpdateFromInputs {{{1*/ 645 639 void Pengrid::UpdateFromInputs(void* inputs){ -
issm/trunk/src/c/objects/Pengrid.h
r3454 r3463 65 65 void PenaltyConstrain(int* punstable,void* inputs,int analysis_type,int sub_analysis_type); 66 66 void PenaltyConstrainThermal(int* punstable,void* inputs,int analysis_type,int sub_analysis_type); 67 void SetClone(int* minranks);68 67 69 68 }; -
issm/trunk/src/c/objects/Penpair.cpp
r3454 r3463 234 234 } 235 235 /*}}}1*/ 236 /*FUNCTION Penpair::SetClone {{{1*/237 void Penpair::SetClone(int* minranks){238 239 ISSMERROR("not implemented yet");240 }241 /*}}}1*/ -
issm/trunk/src/c/objects/Penpair.h
r3454 r3463 48 48 void PenaltyCreatePVector(Vec pg,void* inputs,double kmax,int analysis_type,int sub_analysis_type); 49 49 Object* copy(); 50 void SetClone(int* minranks);51 50 52 51 }; -
issm/trunk/src/c/objects/Result.cpp
r3454 r3463 291 291 } 292 292 /*}}}1*/ 293 /*FUNCTION Result::SetClone {{{1*/294 void Result::SetClone(int* minranks){295 296 ISSMERROR("not implemented yet");297 }298 /*}}}1*/ -
issm/trunk/src/c/objects/Result.h
r3454 r3463 41 41 int Enum(); 42 42 Object* copy(); 43 void SetClone(int* minranks);44 43 45 44 double GetTime(); -
issm/trunk/src/c/objects/Rgb.cpp
r3454 r3463 165 165 } 166 166 /*}}}1*/ 167 /*FUNCTION Rgb::SetClone {{{1*/168 void Rgb::SetClone(int* minranks){169 170 ISSMERROR("not implemented yet");171 }172 /*}}}1*/ -
issm/trunk/src/c/objects/Rgb.h
r3454 r3463 32 32 int GetId(); 33 33 int MyRank(); 34 void SetClone(int* minranks);35 34 36 35 /*non virtual: */ -
issm/trunk/src/c/objects/Riftfront.cpp
r3454 r3463 909 909 } 910 910 /*}}}1*/ 911 /*FUNCTION Riftfront::SetClone {{{1*/912 void Riftfront::SetClone(int* minranks){913 914 ISSMERROR("not implemented yet");915 }916 /*}}}1*/917 911 /*FUNCTION Riftfront::UpdateFromInputs {{{1*/ 918 912 void Riftfront::UpdateFromInputs(void* vinputs){ -
issm/trunk/src/c/objects/Riftfront.h
r3454 r3463 77 77 int MarshallSize(); 78 78 int MyRank(); 79 void SetClone(int* minranks);80 79 81 80 /*}}}*/ -
issm/trunk/src/c/objects/SolPar.h
r3454 r3463 37 37 int Enum(); 38 38 Object* copy(); 39 void SetClone(int* minranks);40 39 41 40 /*functionality: */ -
issm/trunk/src/c/objects/Spc.cpp
r3454 r3463 164 164 } 165 165 /*}}}1*/ 166 /*FUNCTION Spc::SetClone {{{1*/167 void Spc::SetClone(int* minranks){168 169 ISSMERROR("not implemented yet");170 }171 /*}}}1*/ -
issm/trunk/src/c/objects/Spc.h
r3454 r3463 37 37 double GetValue(); 38 38 Object* copy(); 39 void SetClone(int* minranks);40 39 41 40 }; -
issm/trunk/src/c/objects/Vertex.cpp
r3454 r3463 20 20 /*}}}*/ 21 21 22 /*Object constructors and destructor */23 /*FUNCTION Vertex default constructor {{{ 1*/22 /*Object constructors and destructor{{{1*/ 23 /*FUNCTION Vertex default constructor {{{2*/ 24 24 Vertex::Vertex(){ 25 25 return; 26 26 } 27 27 /*}}}*/ 28 /*FUNCTION Vertex constructor {{{ 1*/29 Vertex::Vertex(int tria_id, double tria_x, double tria_y, double tria_z, double tria_sigma , int partitionborder){30 this->Init(tria_id, tria_x, tria_y, tria_z, tria_sigma , partitionborder);31 } 32 /*}}}*/ 33 /*FUNCTION Vertex init, used by constructor {{{ 1*/34 void Vertex::Init(int tria_id, double tria_x, double tria_y, double tria_z, double tria_sigma , int partitionborder){28 /*FUNCTION Vertex constructor {{{2*/ 29 Vertex::Vertex(int tria_id, double tria_x, double tria_y, double tria_z, double tria_sigma){ 30 this->Init(tria_id, tria_x, tria_y, tria_z, tria_sigma); 31 } 32 /*}}}*/ 33 /*FUNCTION Vertex init, used by constructor {{{2*/ 34 void Vertex::Init(int tria_id, double tria_x, double tria_y, double tria_z, double tria_sigma){ 35 35 36 36 /*all the initialization has been done by the initializer, just fill in the id: */ … … 45 45 } 46 46 /*}}}*/ 47 /*FUNCTION Vertex constructor from iomodel{{{ 1*/47 /*FUNCTION Vertex constructor from iomodel{{{2*/ 48 48 Vertex::Vertex(int i, IoModel* iomodel){ 49 49 50 int partitionborder; 51 52 /*is this vertex on a partition border? */ 53 if(iomodel->my_bordervertices[i])partitionborder=1; 54 else partitionborder=0; 55 56 this->Init(i+1, iomodel->x[i],iomodel->y[i],iomodel->z[i],(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i]),partitionborder); 57 58 } 59 /*}}}*/ 60 /*FUNCTION Vertex destructor {{{1*/ 50 this->Init(i+1, iomodel->x[i],iomodel->y[i],iomodel->z[i],(iomodel->z[i]-iomodel->bed[i])/(iomodel->thickness[i])); 51 52 } 53 /*}}}*/ 54 /*FUNCTION Vertex destructor {{{2*/ 61 55 Vertex::~Vertex(){ 62 56 return; 63 57 } 64 58 /*}}}*/ 65 66 /*Object management */67 /*FUNCTION copy {{{ 1*/59 /*}}}*/ 60 /*Object management {{{1*/ 61 /*FUNCTION copy {{{2*/ 68 62 Object* Vertex::copy() { 69 63 … … 72 66 } 73 67 /*}}}*/ 74 /*FUNCTION DeepEcho{{{ 1*/68 /*FUNCTION DeepEcho{{{2*/ 75 69 76 70 void Vertex::DeepEcho(void){ … … 78 72 } 79 73 /*}}}*/ 80 /*FUNCTION Demarshall {{{ 1*/74 /*FUNCTION Demarshall {{{2*/ 81 75 void Vertex::Demarshall(char** pmarshalled_dataset){ 82 76 … … 96 90 memcpy(&sigma,marshalled_dataset,sizeof(sigma));marshalled_dataset+=sizeof(sigma); 97 91 memcpy(&dof,marshalled_dataset,sizeof(dof));marshalled_dataset+=sizeof(dof); 98 memcpy(&partitionborder,marshalled_dataset,sizeof(partitionborder));marshalled_dataset+=sizeof(partitionborder);99 92 memcpy(&clone,marshalled_dataset,sizeof(clone));marshalled_dataset+=sizeof(clone); 100 93 … … 104 97 } 105 98 /*}}}*/ 106 /*FUNCTION Echo{{{ 1*/99 /*FUNCTION Echo{{{2*/ 107 100 108 101 void Vertex::Echo(void){ … … 115 108 printf(" sigma: %g\n",sigma); 116 109 printf(" dof: %g\n",dof); 117 printf(" partitionborder: %g\n",partitionborder);118 110 printf(" clone: %g\n",clone); 119 111 … … 121 113 } 122 114 /*}}}*/ 123 /*FUNCTION Enum {{{ 1*/115 /*FUNCTION Enum {{{2*/ 124 116 int Vertex::Enum(void){ 125 117 … … 128 120 } 129 121 /*}}}*/ 130 /*FUNCTION GetId{{{ 1*/122 /*FUNCTION GetId{{{2*/ 131 123 int Vertex::GetId(void){ return id; } 132 124 /*}}}*/ 133 /*FUNCTION GetName{{{ 1*/125 /*FUNCTION GetName{{{2*/ 134 126 char* Vertex::GetName(void){ 135 127 return "node"; 136 128 } 137 129 /*}}}*/ 138 /*FUNCTION Marshall {{{ 1*/130 /*FUNCTION Marshall {{{2*/ 139 131 void Vertex::Marshall(char** pmarshalled_dataset){ 140 132 … … 158 150 memcpy(marshalled_dataset,&sigma,sizeof(sigma));marshalled_dataset+=sizeof(sigma); 159 151 memcpy(marshalled_dataset,&dof,sizeof(dof));marshalled_dataset+=sizeof(dof); 160 memcpy(marshalled_dataset,&partitionborder,sizeof(partitionborder));marshalled_dataset+=sizeof(partitionborder);161 152 memcpy(marshalled_dataset,&clone,sizeof(clone));marshalled_dataset+=sizeof(clone); 162 153 … … 165 156 } 166 157 /*}}}*/ 167 /*FUNCTION MarshallSize {{{ 1*/158 /*FUNCTION MarshallSize {{{2*/ 168 159 int Vertex::MarshallSize(){ 169 160 … … 174 165 sizeof(sigma)+ 175 166 sizeof(dof)+ 176 sizeof(partitionborder)+177 167 sizeof(clone)+ 178 168 +sizeof(int); //sizeof(int) for enum type 179 169 } 180 170 /*}}}*/ 181 /*FUNCTION MyRank {{{ 1*/171 /*FUNCTION MyRank {{{2*/ 182 172 int Vertex::MyRank(void){ 183 173 extern int my_rank; … … 185 175 } 186 176 /*}}}*/ 187 /*FUNCTION SetClone {{{1*/ 177 /*FUNCTION UpdateFromDakota {{{2*/ 178 void Vertex::UpdateFromDakota(void* vinputs){ 179 180 ISSMERROR("not supported yet!"); 181 182 } 183 /*}}}*/ 184 /*FUNCTION UpdateFromInputs {{{2*/ 185 void Vertex::UpdateFromInputs(void* vinputs){ 186 187 ParameterInputs* inputs=NULL; 188 Vertex* vertex=NULL; 189 int dof[1]={0}; 190 double coord[3]; 191 192 vertex=this; 193 194 coord[0]=this->x; coord[1]=this->y; coord[2]=this->z; 195 196 /*Recover parameter inputs: */ 197 inputs=(ParameterInputs*)vinputs; 198 199 /*Update internal data if inputs holds new values: */ 200 inputs->Recover("x",&coord[0],1,dof,1,(void**)&vertex); 201 inputs->Recover("y",&coord[1],1,dof,1,(void**)&vertex); 202 inputs->Recover("z",&coord[2],1,dof,1,(void**)&vertex); 203 204 ISSMERROR("not supported yet!"); 205 206 } 207 /*}}}*/ 208 /*FUNCTION UpdateVertexPosition {{{2*/ 209 void Vertex::UpdatePosition(double* thickness,double* bed){ 210 211 /*sigma remains constant. z=bed+sigma*thickness*/ 212 this->z=bed[dof]+sigma*thickness[this->dof]; 213 214 } 215 /*}}}*/ 216 /*}}}*/ 217 /* DofObject routines: {{{1* 218 /*FUNCTION Vertex DistributeDofs{{{2*/ 219 void Vertex::DistributeDofs(int* pdofcount){ 220 221 int i; 222 extern int my_rank; 223 int dofcount; 224 225 dofcount=*pdofcount; 226 227 if(this->clone){ 228 /*This vertex is a clone! Don't distribute dofs, it will get them from another cpu!*/ 229 return; 230 } 231 232 /*This vertex should distribute his dof, go ahead: */ 233 this->dof=dofcount; 234 dofcount++; 235 236 /*Assign output pointers: */ 237 *pdofcount=dofcount; 238 239 } 240 /*}}}*/ 241 /*FUNCTION Vertex OffsetDofs{{{2*/ 242 void Vertex::OffsetDofs(int dofcount){ 243 244 int i; 245 extern int my_rank; 246 247 if(this->clone){ 248 /*This vertex is a clone, don't offset the dofs!: */ 249 return; 250 } 251 252 /*This vertex should offset his dof, go ahead: */ 253 this->dof+=dofcount; 254 } 255 /*}}}*/ 256 /*FUNCTION Vertex ShowTrueDofs{{{2*/ 257 void Vertex::ShowTrueDofs(int* truedofs){ 258 259 int j; 260 extern int my_rank; 261 262 /*Are we a clone? : */ 263 if(this->clone)return; 264 265 /*Ok, we are not a clone, just plug our dof into truedofs: */ 266 truedofs[this->id-1]=this->dof; 267 268 } 269 /*}}}*/ 270 /*FUNCTION Vertex UpdateCloneDofs{{{2*/ 271 void Vertex::UpdateCloneDofs(int* alltruedofs){ 272 273 int j; 274 extern int my_rank; 275 276 /*If we are not a clone, don't update, we already have dofs!: */ 277 if(this->clone==0)return; 278 279 /*Ok, we are a clone node, but we did not create the dof for this vertex 280 * Therefore, our dof is garbage right now. Go pick it up in the alltruedofs: */ 281 this->dof=alltruedofs[id-1]; 282 } 283 /*}}}*/ 284 /*FUNCTION Vertex SetClone {{{2*/ 188 285 void Vertex::SetClone(int* minranks){ 189 286 … … 194 291 } 195 292 else{ 196 /*!there is a cpu with lower rank that has the same node,293 /*!there is a cpu with lower rank that has the same vertex, 197 294 therefore, I am a clone*/ 198 295 this->clone=1; … … 201 298 } 202 299 /*}}}*/ 203 /*FUNCTION UpdateFromDakota {{{1*/ 204 void Vertex::UpdateFromDakota(void* vinputs){ 205 206 ISSMERROR("not supported yet!"); 207 208 } 209 /*}}}*/ 210 /*FUNCTION UpdateFromInputs {{{1*/ 211 void Vertex::UpdateFromInputs(void* vinputs){ 212 213 ParameterInputs* inputs=NULL; 214 Vertex* vertex=NULL; 215 int dof[1]={0}; 216 double coord[3]; 217 218 vertex=this; 219 220 coord[0]=this->x; coord[1]=this->y; coord[2]=this->z; 221 222 /*Recover parameter inputs: */ 223 inputs=(ParameterInputs*)vinputs; 224 225 /*Update internal data if inputs holds new values: */ 226 inputs->Recover("x",&coord[0],1,dof,1,(void**)&vertex); 227 inputs->Recover("y",&coord[1],1,dof,1,(void**)&vertex); 228 inputs->Recover("z",&coord[2],1,dof,1,(void**)&vertex); 229 230 ISSMERROR("not supported yet!"); 231 232 } 233 /*}}}*/ 234 /*FUNCTION UpdateVertexPosition {{{1*/ 235 void Vertex::UpdatePosition(double* thickness,double* bed){ 236 237 /*sigma remains constant. z=bed+sigma*thickness*/ 238 this->z=bed[dof]+sigma*thickness[this->dof]; 239 240 } 241 /*}}}*/ 300 /*}}}*/ -
issm/trunk/src/c/objects/Vertex.h
r3454 r3463 6 6 #define _VERTEX_H_ 7 7 8 class Object; 9 class DofObject; 10 8 11 #include "../ModelProcessorx/IoModel.h" 9 12 #include "./Object.h" 13 #include "./DofObject.h" 10 14 11 class Vertex: public Object {15 class Vertex: public Object,public DofObject{ 12 16 13 17 public: … … 20 24 21 25 /*dof management: */ 22 int partitionborder;23 26 int clone; 24 27 int dof; //dof to recover values in a vertex indexed vector … … 26 29 /*FUNCTION constructors, destructors {{{1*/ 27 30 Vertex(); 28 Vertex(int id, double x, double y, double z, double sigma ,int partitionborder);29 void Init(int id, double x, double y, double z, double sigma ,int partitionborder);31 Vertex(int id, double x, double y, double z, double sigma); 32 void Init(int id, double x, double y, double z, double sigma); 30 33 Vertex(int i, IoModel* iomodel); 31 34 ~Vertex(); … … 42 45 int MarshallSize(); 43 46 int MyRank(); 44 void SetClone(int* minranks);45 47 void UpdateFromDakota(void* vinputs); 46 48 void UpdateFromInputs(void* vinputs); … … 49 51 50 52 /*}}}*/ 53 /*FUNCTION DofObject routines {{{1*/ 54 void DistributeDofs(int* pdofcount); 55 void OffsetDofs(int dofcount); 56 void ShowTrueDofs(int* borderdofs); 57 void UpdateCloneDofs(int* allborderdofs); 58 void SetClone(int* minranks); 59 /*}}}*/ 51 60 52 61 };
Note:
See TracChangeset
for help on using the changeset viewer.