Changeset 26143
- Timestamp:
- 03/23/21 17:35:35 (4 years ago)
- Location:
- issm/trunk-jpl/src/c/classes/matrix
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.h
r26131 r26143 19 19 class ElementMatrix{ 20 20 21 private: 22 int *gglobaldoflist; 23 int *fglobaldoflist; 24 int *sglobaldoflist; 25 int fsize; 26 int ssize; 27 21 28 public: 22 23 int nrows; 24 int fsize; 25 int ssize; 26 IssmDouble* values; 27 28 int* gglobaldoflist; 29 int* fglobaldoflist; 30 int* sglobaldoflist; 29 int nrows; 30 IssmDouble *values; 31 31 32 32 /*ElementMatrix constructors, destructors*/ -
issm/trunk-jpl/src/c/classes/matrix/ElementVector.cpp
r26131 r26143 21 21 22 22 this->nrows=0; 23 this->fsize=0;24 23 this->values=NULL; 25 24 this->fglobaldoflist=NULL; … … 28 27 /*}}}*/ 29 28 ElementVector::ElementVector(ElementVector* pe1, ElementVector* pe2){/*{{{*/ 30 31 /*intermediaries*/32 int i,j;33 int gsize,fsize;34 29 35 30 /*If one of the two matrix is NULL, we copy the other one*/ … … 50 45 51 46 /*1: Get the new numbering of pe2 and get size of the new matrix*/ 52 gsize=pe1->nrows;53 for(i =0;i<pe2->nrows;i++){47 int gsize=pe1->nrows; 48 for(int i=0;i<pe2->nrows;i++){ 54 49 bool found=false; 55 for( j=0;j<pe1->nrows;j++){50 for(int j=0;j<pe1->nrows;j++){ 56 51 if(pe2->gglobaldoflist[i]==pe1->gglobaldoflist[j]){ 57 52 found=true; P[i]=j; break; … … 70 65 this->fglobaldoflist=xNew<int>(this->nrows); 71 66 this->values=xNewZeroInit<IssmDouble>(this->nrows); 72 for(i =0;i<pe1->nrows;i++){67 for(int i=0;i<pe1->nrows;i++){ 73 68 this->values[i] += pe1->values[i]; 74 69 this->gglobaldoflist[i]=pe1->gglobaldoflist[i]; 75 70 this->fglobaldoflist[i]=pe1->fglobaldoflist[i]; 76 71 } 77 for(i =0;i<pe2->nrows;i++){72 for(int i=0;i<pe2->nrows;i++){ 78 73 this->values[P[i]] += pe2->values[i]; 79 74 this->gglobaldoflist[P[i]]=pe2->gglobaldoflist[i]; … … 81 76 } 82 77 83 /*Fset*/84 this->fsize=0;85 for(i=0;i<this->nrows;i++) if(this->fglobaldoflist[i]>=0) this->fsize++;86 87 78 /*clean-up*/ 88 79 xDelete<int>(P); … … 111 102 this->values=xNewZeroInit<IssmDouble>(this->nrows); 112 103 113 /* glist*/104 /*dof list*/ 114 105 this->gglobaldoflist=GetGlobalDofList(nodes,numnodes,GsetEnum,approximation); 115 116 /*Get fsize*/117 this->fsize=GetNumberOfDofs(nodes,numnodes,FsetEnum,approximation);118 106 this->fglobaldoflist=GetGlobalDofList(nodes,numnodes,FsetEnum,approximation); 119 107 } … … 132 120 this->CheckConsistency(); 133 121 134 if(this->fsize){ 122 /*Get size of Fset*/ 123 int fsize = 0; for(int i=0;i<this->nrows;i++) if(this->fglobaldoflist[i]>=0) fsize++; 124 125 if(fsize){ 135 126 pf->SetValues(this->nrows,this->fglobaldoflist,this->values,ADD_VAL); 136 127 } … … 155 146 _printf_("Element Vector echo:\n"); 156 147 _printf_(" nrows: " << nrows << "\n"); 157 _printf_(" fsize: " << fsize << "\n");158 148 _printf_(" values:\n"); 159 149 for(i=0;i<nrows;i++) _printf_(setw(4) << right << i << ": " << setw(10) << values[i] << "\n"); … … 164 154 165 155 _printf_(" fglobaldoflist (" << fglobaldoflist << "): "); 166 if(fglobaldoflist) for(i=0;i< fsize;i++) _printf_(" " << fglobaldoflist[i] );156 if(fglobaldoflist) for(i=0;i<nrows;i++) _printf_(" " << fglobaldoflist[i] ); 167 157 _printf_(" \n"); 168 158 } … … 173 163 174 164 this->nrows =pe->nrows; 175 this->fsize =pe->fsize;176 165 177 166 this->values=xNew<IssmDouble>(this->nrows); … … 187 176 void ElementVector::InsertIntoGlobal(Vector<IssmDouble>* pf){/*{{{*/ 188 177 189 if(this->fsize){ 178 /*Get size of Fset*/ 179 int fsize = 0; for(int i=0;i<this->nrows;i++) if(this->fglobaldoflist[i]>=0) fsize++; 180 181 if(fsize){ 190 182 /*add local values into global vector, using the fglobaldoflist: */ 191 183 pf->SetValues(this->nrows,this->fglobaldoflist,this->values,INS_VAL); … … 196 188 void ElementVector::SetValue(IssmDouble scalar){/*{{{*/ 197 189 198 int i; 199 200 for(i=0;i<this->nrows;i++)this->values[i]=scalar; 190 for(int i=0;i<this->nrows;i++)this->values[i]=scalar; 201 191 202 192 } -
issm/trunk-jpl/src/c/classes/matrix/ElementVector.h
r26131 r26143 20 20 class ElementVector{ 21 21 22 private: 23 int *gglobaldoflist; 24 int *fglobaldoflist; 25 22 26 public: 23 27 int nrows; 24 int fsize;25 28 IssmDouble *values; 26 int *gglobaldoflist;27 int *fglobaldoflist;28 29 29 30 /*ElementVector constructors, destructors*/
Note:
See TracChangeset
for help on using the changeset viewer.