Skip to content

Commit

Permalink
Bugfix for MatSetUp.
Browse files Browse the repository at this point in the history
  • Loading branch information
rioyokota@gmail.com committed Aug 1, 2012
1 parent 0024c52 commit 057cc28
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions 2d/matmult.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ PetscErrorCode mysubmat(Mat mat,PetscInt n,const IS irow[],const IS icol[],MatRe
idx[i] = i;
}
}
ierr = MatSetUp((*submat)[id]);CHKERRQ(ierr);
ierr = MatSetValues((*submat)[id],cluster->npbufferi,idx,cluster->npbufferi,idx,A,INSERT_VALUES);CHKERRQ(ierr);
ierr = MatAssemblyBegin((*submat)[id],MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
ierr = MatAssemblyEnd((*submat)[id],MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
Expand Down
1 change: 1 addition & 0 deletions 2d/matmultgpu.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ PetscErrorCode mysubmat(Mat mat,PetscInt n,const IS irow[],const IS icol[],MatRe
idx[i] = i;
}
}
ierr = MatSetUp((*submat)[id]);CHKERRQ(ierr);
ierr = MatSetValues((*submat)[id],cluster->npbufferi,idx,cluster->npbufferi,idx,A,INSERT_VALUES);CHKERRQ(ierr);
ierr = MatAssemblyBegin((*submat)[id],MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
ierr = MatAssemblyEnd((*submat)[id],MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
Expand Down
4 changes: 3 additions & 1 deletion 2d/rbf_interpolation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,16 @@ PetscErrorCode rbf_interpolation(Vec xi, Vec yi, Vec gi, Vec wi,
ierr = MatSetType(M,MATSHELL);CHKERRQ(ierr);
ierr = MatSetFromOptions(M);CHKERRQ(ierr);
ierr = MatShellSetOperation(M,MATOP_MULT, (void (*)(void)) mymatmult);
ierr = MatView(M,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = MatShellSetContext(M,&both);CHKERRQ(ierr);
ierr = MatSetUp(M);CHKERRQ(ierr);
ierr = MatView(M,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = MatCreate(PETSC_COMM_WORLD,&P);CHKERRQ(ierr);
ierr = MatSetSizes(P,particle.nilocal,particle.nilocal,PETSC_DETERMINE,PETSC_DETERMINE);CHKERRQ(ierr);
ierr = MatSetType(P,MATSHELL);CHKERRQ(ierr);
ierr = MatSetFromOptions(P);CHKERRQ(ierr);
ierr = MatShellSetOperation(P,MATOP_GET_SUBMATRICES, (void (*)(void)) mysubmat);
ierr = MatShellSetContext(P,&both);CHKERRQ(ierr);
ierr = MatSetUp(P);CHKERRQ(ierr);

ierr = VecGetArray(particle.xi,&particle.xil);CHKERRQ(ierr);
ierr = VecGetArray(particle.yi,&particle.yil);CHKERRQ(ierr);
Expand Down
1 change: 1 addition & 0 deletions 3d/matmult.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ PetscErrorCode mysubmat(Mat mat,PetscInt n,const IS irow[],const IS icol[],MatRe
idx[i] = i;
}
}
ierr = MatSetUp((*submat)[id]);CHKERRQ(ierr);
ierr = MatSetValues((*submat)[id],cluster->npbufferi,idx,cluster->npbufferi,idx,A,INSERT_VALUES);CHKERRQ(ierr);
ierr = MatAssemblyBegin((*submat)[id],MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
ierr = MatAssemblyEnd((*submat)[id],MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
Expand Down
1 change: 1 addition & 0 deletions 3d/matmultgpu.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ PetscErrorCode mysubmat(Mat mat,PetscInt n,const IS irow[],const IS icol[],MatRe
idx[i] = i;
}
}
ierr = MatSetUp((*submat)[id]);CHKERRQ(ierr);
ierr = MatSetValues((*submat)[id],cluster->npbufferi,idx,cluster->npbufferi,idx,A,INSERT_VALUES);CHKERRQ(ierr);
ierr = MatAssemblyBegin((*submat)[id],MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
ierr = MatAssemblyEnd((*submat)[id],MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
Expand Down
4 changes: 3 additions & 1 deletion 3d/rbf_interpolation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,16 @@ PetscErrorCode rbf_interpolation(Vec xi, Vec yi, Vec zi, Vec gi, Vec wi,
ierr = MatSetType(M,MATSHELL);CHKERRQ(ierr);
ierr = MatSetFromOptions(M);CHKERRQ(ierr);
ierr = MatShellSetOperation(M,MATOP_MULT, (void (*)(void)) mymatmult);
ierr = MatView(M,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = MatShellSetContext(M,&both);CHKERRQ(ierr);
ierr = MatSetUp(M);CHKERRQ(ierr);
ierr = MatView(M,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = MatCreate(PETSC_COMM_WORLD,&P);CHKERRQ(ierr);
ierr = MatSetSizes(P,particle.nilocal,particle.nilocal,PETSC_DETERMINE,PETSC_DETERMINE);CHKERRQ(ierr);
ierr = MatSetType(P,MATSHELL);CHKERRQ(ierr);
ierr = MatSetFromOptions(P);CHKERRQ(ierr);
ierr = MatShellSetOperation(P,MATOP_GET_SUBMATRICES, (void (*)(void)) mysubmat);
ierr = MatShellSetContext(P,&both);CHKERRQ(ierr);
ierr = MatSetUp(P);CHKERRQ(ierr);

ierr = VecGetArray(particle.xi,&particle.xil);CHKERRQ(ierr);
ierr = VecGetArray(particle.yi,&particle.yil);CHKERRQ(ierr);
Expand Down

0 comments on commit 057cc28

Please sign in to comment.