Commit 909f8427 authored by Erin Kuci's avatar Erin Kuci

up

parent a6ff64ed
Pipeline #1112 passed with stage
in 49 seconds
......@@ -64,25 +64,34 @@ static void UpdateMatrixRowFromVector(double* myvecvals, int vecsize,
PetscInt row, Mat& Matrix)
{
// Count the number of nonzero elements in the vector:
int numnonzero = 0;
for (int i = 0; i < vecsize; i++){if (myvecvals[i] != 0){numnonzero++;}}
//int numnonzero = 0;
//for (int i = 0; i < vecsize; i++){if (myvecvals[i] != 0){numnonzero++;}}
// Get the adresses and values of the nonzeros:
int nonzeroadresses[numnonzero];
double nonzerovalues[numnonzero];
int index = 0;
//int nonzeroadresses[numnonzero];
//double nonzerovalues[numnonzero];
//int index = 0;
//for (int i = 0; i < vecsize; i++){
// if (myvecvals[i] != 0){
// nonzeroadresses[index] = i;
// nonzerovalues[index] = myvecvals[i];
// index++;
// }
//}
int nonzeroadresses[vecsize];
double nonzerovalues[vecsize];
for (int i = 0; i < vecsize; i++){
if (myvecvals[i] != 0){
nonzeroadresses[index] = i;
nonzerovalues[index] = myvecvals[i];
index++;
}
nonzeroadresses[i] = i;
nonzerovalues[i] = myvecvals[i];
}
// fill the matrix
PetscInt row_vec[1] = {row};
MatSetValues(Matrix,1,row_vec,numnonzero,nonzeroadresses,nonzerovalues,
INSERT_VALUES);
MatSetValues(Matrix,1,row_vec,vecsize,nonzeroadresses,nonzerovalues,
INSERT_VALUES);
// MatSetValues(Matrix,1,row_vec,numnonzero,nonzeroadresses,nonzerovalues,
// INSERT_VALUES);
}
static void AssembleMatrix(const Mat& Matrix)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment