Commit 914f97b4 authored by sfritschi's avatar sfritschi
Browse files

Changed initialization of Vec

parent 19a183b8
......@@ -46,13 +46,9 @@ PetscErrorCode solve(const PetscScalar *data, const PetscInt *col_indices,
// Assemble Vec on root rank
if (rank == root) {
PetscInt *ix = (PetscInt *) malloc(n_rows * sizeof(PetscInt));
for (PetscInt i = 0; i < n_rows; ++i) {
ix[i] = i;
ierr = VecSetValue(bn, i, rhs[i], INSERT_VALUES); CHKERRQ(ierr);
}
ierr = VecSetValues(bn, n_rows, ix, &rhs[0], INSERT_VALUES); CHKERRQ(ierr);
// cleanup
free(ix);
}
ierr = VecAssemblyBegin(bn); CHKERRQ(ierr);
ierr = VecAssemblyEnd(bn); CHKERRQ(ierr);
......@@ -99,8 +95,9 @@ PetscErrorCode solve(const PetscScalar *data, const PetscInt *col_indices,
// DEBUGGING: Monitor iteration number/convergence
PetscInt its;
ierr = KSPGetIterationNumber(ksp,&its); CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD, "Iterations %d\n", its); CHKERRQ(ierr);
ierr = KSPGetIterationNumber(ksp, &its); CHKERRQ(ierr);
PetscPrintf(PETSC_COMM_WORLD, "Iterations %d\n", its);
const char *convergence_reason;
ierr = KSPGetConvergedReasonString(ksp, &convergence_reason); CHKERRQ(ierr);
PetscPrintf(PETSC_COMM_WORLD, "Reason: %s\n", convergence_reason);
......@@ -111,6 +108,7 @@ PetscErrorCode solve(const PetscScalar *data, const PetscInt *col_indices,
// Initialize displacements
if (rank == root) {
displs = (PetscMPIInt *) malloc(size * sizeof(PetscMPIInt));
PetscMPIInt sum = 0;
for (PetscMPIInt i = 0; i < size; ++i) {
displs[i] = sum;
......
Supports Markdown
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