- Timestamp:
- 01/05/19 22:36:12 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/toolkits/petsc/objects/PetscVec.cpp
r23255 r23602 113 113 _assert_(this->vector); 114 114 VecGetSize(this->vector,pM); 115 116 } 117 /*}}}*/ 118 void PetscVec::GetLocalSize(int* pM){/*{{{*/ 119 120 _assert_(this->vector); 121 VecGetLocalSize(this->vector,pM); 122 123 } 124 /*}}}*/ 115 } 116 /*}}}*/ 117 void PetscVec::GetLocalVector(double** pvector,int** pindices){/*{{{*/ 118 119 _assert_(this->vector); 120 121 /*First, check that vector size is not 0*/ 122 int vector_size; 123 this->GetSize(&vector_size); 124 if(vector_size==0){ 125 *pvector=NULL; 126 *pindices=NULL; 127 return; 128 } 129 130 /*Get Ownership range*/ 131 PetscInt lower_row,upper_row; 132 VecGetOwnershipRange(this->vector,&lower_row,&upper_row); 133 int range=upper_row-lower_row; 134 135 /*return NULL if no range*/ 136 if(range==0){ 137 *pvector=NULL; 138 *pindices=NULL; 139 return; 140 } 141 142 /*Build indices*/ 143 int* indices=xNew<int>(range); 144 for(int i=0;i<range;i++) indices[i]=lower_row+i; 145 /*Get vector*/ 146 IssmDouble* values =xNew<double>(range); 147 VecGetValues(this->vector,range,indices,values); 148 149 *pvector = values; 150 *pindices = indices; 151 } /*}}}*/ 125 152 PetscVec* PetscVec::Duplicate(void){/*{{{*/ 126 153
Note:
See TracChangeset
for help on using the changeset viewer.