Changeset 10104
- Timestamp:
- 10/05/11 07:58:50 (13 years ago)
- Location:
- issm/trunk/src/c/shared/Elements
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/shared/Elements/GetGlobalDofList.cpp
r5908 r10104 7 7 8 8 int i,numdof,count; 9 int ndof_list[numnodes];9 int* ndof_list=NULL; 10 10 int *doflist = NULL; 11 11 12 /*First, figure out size of doflist: */ 13 numdof=0; 14 for(i=0;i<numnodes;i++){ 15 ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum); 16 numdof+=ndof_list[i]; 12 13 if(numnodes){ 14 15 /*Allocate:*/ 16 ndof_list=(int*)xmalloc(numdof*sizeof(int)); 17 18 /*First, figure out size of doflist: */ 19 numdof=0; 20 for(i=0;i<numnodes;i++){ 21 ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum); 22 numdof+=ndof_list[i]; 23 } 24 25 if(numdof){ 26 /*Allocate: */ 27 doflist=(int*)xmalloc(numdof*sizeof(int)); 28 29 /*Populate: */ 30 count=0; 31 for(i=0;i<numnodes;i++){ 32 nodes[i]->GetDofList(&doflist[count],approximation,setenum); 33 count+=ndof_list[i]; 34 } 35 } 36 else doflist=NULL; 17 37 } 18 19 if(numdof){ 20 /*Allocate: */ 21 doflist=(int*)xmalloc(numdof*sizeof(int)); 22 23 /*Populate: */ 24 count=0; 25 for(i=0;i<numnodes;i++){ 26 nodes[i]->GetDofList(&doflist[count],approximation,setenum); 27 count+=ndof_list[i]; 28 } 29 } 30 else doflist=NULL; 38 /*Free ressources:*/ 39 xfree((void**)&ndof_list); 31 40 32 41 return doflist; -
issm/trunk/src/c/shared/Elements/GetLocalDofList.cpp
r5908 r10104 7 7 8 8 int i,j,count,numdof,numgdof; 9 int ndof_list[numnodes];10 int ngdof_list_cumulative[numnodes];9 int* ndof_list=NULL; 10 int* ngdof_list_cumulative=NULL; 11 11 int *doflist = NULL; 12 12 13 /*Get number of dofs per node, and total for this given set*/14 numdof=0;15 numgdof=0;16 for(i=0;i<numnodes;i++){13 if(numnodes){ 14 /*allocate: */ 15 ndof_list=(int*)xmalloc(numnodes*sizeof(int)); 16 ngdof_list_cumulative=(int*)xmalloc(numnodes*sizeof(int)); 17 17 18 /*Cumulative list= number of dofs before node i*/19 ngdof_list_cumulative[i]=numgdof;20 18 21 /*Number of dofs for node i for given set and for the g set*/ 22 ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum); 23 numgdof +=nodes[i]->GetNumberOfDofs(approximation,GsetEnum); 24 numdof +=ndof_list[i]; 19 /*Get number of dofs per node, and total for this given set*/ 20 numdof=0; 21 numgdof=0; 22 for(i=0;i<numnodes;i++){ 23 24 /*Cumulative list= number of dofs before node i*/ 25 ngdof_list_cumulative[i]=numgdof; 26 27 /*Number of dofs for node i for given set and for the g set*/ 28 ndof_list[i]=nodes[i]->GetNumberOfDofs(approximation,setenum); 29 numgdof +=nodes[i]->GetNumberOfDofs(approximation,GsetEnum); 30 numdof +=ndof_list[i]; 31 } 32 33 if(numdof){ 34 /*Allocate: */ 35 doflist=(int*)xmalloc(numdof*sizeof(int)); 36 37 /*Populate: */ 38 count=0; 39 for(i=0;i<numnodes;i++){ 40 nodes[i]->GetLocalDofList(&doflist[count],approximation,setenum); 41 count+=ndof_list[i]; 42 } 43 44 /*We now have something like: [0 1 0 2 1 2]. Offset by gsize, to get something like: [0 1 2 4 6 7]:*/ 45 count=0; 46 for(i=0;i<numnodes;i++){ 47 for(j=0;j<ndof_list[i];j++){ 48 doflist[count+j]+=ngdof_list_cumulative[i]; 49 } 50 count+=ndof_list[i]; 51 } 52 } 53 else doflist=NULL; 25 54 } 26 55 27 if(numdof){ 28 /*Allocate: */ 29 doflist=(int*)xmalloc(numdof*sizeof(int)); 30 31 /*Populate: */ 32 count=0; 33 for(i=0;i<numnodes;i++){ 34 nodes[i]->GetLocalDofList(&doflist[count],approximation,setenum); 35 count+=ndof_list[i]; 36 } 37 38 /*We now have something like: [0 1 0 2 1 2]. Offset by gsize, to get something like: [0 1 2 4 6 7]:*/ 39 count=0; 40 for(i=0;i<numnodes;i++){ 41 for(j=0;j<ndof_list[i];j++){ 42 doflist[count+j]+=ngdof_list_cumulative[i]; 43 } 44 count+=ndof_list[i]; 45 } 46 } 47 else doflist=NULL; 56 /*Free ressources:*/ 57 xfree((void**)&ndof_list); 58 xfree((void**)&ngdof_list_cumulative); 48 59 49 60 /*CLean-up and return*/
Note:
See TracChangeset
for help on using the changeset viewer.