[petsc-dev] [petsc-maint #146341] Re: Problem Assembling MatCreateAIJ (Parallel Sparse Matrix)
Hesameddin Ilatikhameneh
hilatikh at purdue.edu
Thu Jan 3 17:36:02 CST 2013
I found the source of the problem. I have linked with several libraries including MPICH2. I have removed MPI includes and libs in my Makefile and now it works fine.
Thanks for help.
Hesam
----- Original Message -----
From: "Hesameddin Ilatikhameneh" <hilatikh at purdue.edu>
To: "Barry Smith" <bsmith at mcs.anl.gov>
Cc: "For users of the development version of PETSc" <petsc-dev at mcs.anl.gov>, petsc-maint at mcs.anl.gov
Sent: Thursday, January 3, 2013 4:38:02 PM
Subject: Re: [petsc-dev] [petsc-maint #146341] Re: Problem Assembling MatCreateAIJ (Parallel Sparse Matrix)
Definition of Set:
void Set(const int& i, const int& j, const double & Value)
{
this->Assembled = false;
this->Petsc_Error = MatSetValues(*(this->Petsc_Mat), 1, &i, 1, &j, &Value, INSERT_VALUES);
this->Check_Petsc_Error();
};
Creation of the matrix:
this->Petsc_Error = MatCreateAIJ(this->Get_Communicator(), PETSC_DECIDE, PETSC_DECIDE, Number_Rows,Number_Cols, PETSC_DECIDE, PETSC_NULL, PETSC_DECIDE, PETSC_NULL,this->Petsc_Mat);
this->Check_Petsc_Error();
Thanks
Hesam
----- Original Message -----
From: "Barry Smith" <bsmith at mcs.anl.gov>
To: petsc-maint at mcs.anl.gov, "Hesameddin Ilatikhameneh" <hilatikh at purdue.edu>
Cc: "For users of the development version of PETSc" <petsc-dev at mcs.anl.gov>
Sent: Thursday, January 3, 2013 4:31:20 PM
Subject: Re: [petsc-maint #146341] Re: [petsc-dev] Problem Assembling MatCreateAIJ (Parallel Sparse Matrix)
What is the definition of Set()?
On Jan 3, 2013, at 3:14 PM, Hesameddin Ilatikhameneh <hilatikh at purdue.edu> wrote:
> I have a simple wrapper class around PETSc and trying to set some values from different process disregarding the ownership of rows (which row belong to which process).
>
> // Following example I set A[0][1] = 6.0 in CPU0 and A[2][2] = 3.2 in CPU1; working fine!
>
> PetscInitialize(&argc,&argv,(char *)0,help);
> Petsc_Matrix_Parallel<double>* A = new Petsc_Matrix_Parallel<double>(MPI_COMM_WORLD,4,4, 0,3,3);
> if(Rank==0)
> {
> // Set(Row,Col,Value)
> // A[0][1] = 6.0
> A->Set(0,1,6.0);
> }
> else if (Rank==1)
> {
> // A[2][2] = 3.2
> A->Set(2,2,3.2);
> }
> A->Assemble();
> A->Print();
> PetscFinalize();
>
> However if I change A[2][2] to A[2][0] it gives the error.
>
> else if (Rank==1)
> {
> // A[2][0] = 3.2
> A->Set(2,0,3.2);
> }
>
> Thanks
> Hesam
> ----- Original Message -----
> From: "Matthew Knepley" <petsc-maint at mcs.anl.gov>
> To: "For users of the development version of PETSc" <petsc-dev at mcs.anl.gov>
> Sent: Thursday, January 3, 2013 3:53:41 PM
> Subject: Re: [petsc-dev] Problem Assembling MatCreateAIJ (Parallel Sparse Matrix)
>
>
>
> I don't think I understand what you are doing. Can you send a small example?
>
> Matt
> On Jan 3, 2013 2:51 PM, "Hesameddin Ilatikhameneh" < hilatikh at purdue.edu > wrote:
>
>
> I noticed that the problem occurs when I try to set some of non-local (non-diagonal) matrix elements. i.e. in a 3x3 matrix with 2 cpus, if I try to set non-local diagonal elements it is OK but if I try to set some non-diagonal elements [0][2] or [2][0] it gives the error. It is wired that setting [0][1] or [1][0] is OK too.
>
> I tried CHKERRXX too and got the similar error message (attached below).
>
>
> [0]PETSC ERROR: [1]PETSC ERROR: VecScatterCreateCommon_PtoS() line 2003 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vpscat.c
> [0]PETSC ERROR: VecScatterCreate_PtoS() line 1807 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vpscat.c
> [0]PETSC ERROR: VecScatterCreate() line 1331 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vscat.c
> [0]PETSC ERROR: MatSetUpMultiply_MPIAIJ() line 150 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/impls/aij/mpi/mmaij.c
> [0]PETSC ERROR: MatAssemblyEnd_MPIAIJ() line 702 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/impls/aij/mpi/mpiaij.c
> [0]PETSC ERROR: MatAssemblyEnd() line 4879 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/interface/matrix.c
> VecScatterCreateCommon_PtoS() line 2013 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vpscat.c
> [1]PETSC ERROR: VecScatterCreate_PtoS() line 1807 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vpscat.c
> [1]PETSC ERROR: VecScatterCreate() line 1331 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vscat.c
> [1]PETSC ERROR: MatSetUpMultiply_MPIAIJ() line 150 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/impls/aij/mpi/mmaij.c
> [1]PETSC ERROR: MatAssemblyEnd_MPIAIJ() line 702 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/impls/aij/mpi/mpiaij.c
> [1]PETSC ERROR: MatAssemblyEnd() line 4879 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/interface/matrix.c
>
> Thanks
> Hesam
> ----- Original Message -----
> From: "Matthew Knepley" < petsc-maint at mcs.anl.gov >
> To: "For users of the development version of PETSc" < petsc-dev at mcs.anl.gov >
> Sent: Thursday, January 3, 2013 3:12:28 PM
> Subject: Re: [petsc-dev] Problem Assembling MatCreateAIJ (Parallel Sparse Matrix)
>
>
>
> We cannot see the error message. Use CHKERRXX
>
> Matt
> On Jan 3, 2013 1:11 PM, "Hesameddin Ilatikhameneh" < hilatikh at purdue.edu > wrote:
>
>
> The point is the problem occurs when I'm assembling the matrix and since it is unsuccessful MatView gives error.
> I assemble the matrix:
>
> this->Petsc_Error = MatAssemblyBegin(*(this->Petsc_Mat),MAT_FINAL_ASSEMBLY);
> this->Check_Petsc_Error();
> this->Petsc_Error = MatAssemblyEnd(*(this->Petsc_Mat),MAT_FINAL_ASSEMBLY);
> this->Check_Petsc_Error();
>
> Thanks
> Hesam
> ----- Original Message -----
> From: "Jed Brown" < jedbrown at mcs.anl.gov >
> To: "For users of the development version of PETSc" < petsc-dev at mcs.anl.gov >
> Cc: "petsc-maint" < petsc-maint at mcs.anl.gov >
> Sent: Thursday, January 3, 2013 2:07:40 PM
> Subject: Re: [petsc-dev] Problem Assembling MatCreateAIJ (Parallel Sparse Matrix)
>
>
>
> You have to assemble the matrix, just like the error message says.
> On Jan 3, 2013 1:00 PM, "Hesameddin Ilatikhameneh" < hilatikh at purdue.edu > wrote:
>
>
> Hello,
>
> When I try to assemble a parallel sparse matrix (MatCreateAIJ) I get the following error. But when I try to set the parallel matrix in dense format I don't get any error. I used PETSC_DECIDE for number of local elements and number of local nonzeros and PETSC_NULL for nonzeros array in MatCreateAIJ.
>
>
> [0]PETSC ERROR: [1]PETSC ERROR: VecScatterCreateCommon_PtoS() line 2013 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vpscat.c
> [0]PETSC ERROR: VecScatterCreate_PtoS() line 1807 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vpscat.c
> [0]PETSC ERROR: VecScatterCreate() line 1331 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vscat.c
> [0]PETSC ERROR: MatSetUpMultiply_MPIAIJ() line 150 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/impls/aij/mpi/mmaij.c
> [0]PETSC ERROR: MatAssemblyEnd_MPIAIJ() line 702 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/impls/aij/mpi/mpiaij.c
> [0]PETSC ERROR: MatAssemblyEnd() line 4879 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/interface/matrix.c
> [0]PETSC ERROR: User provided function() line 65 in "unknowndirectory/"/home/Codes/trunk/HSim2/Include/Math/PetscMatrix.h
> VecScatterCreateCommon_PtoS() line 2003 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vpscat.c
> [1]PETSC ERROR: VecScatterCreate_PtoS() line 1807 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vpscat.c
> [1]PETSC ERROR: VecScatterCreate() line 1331 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/vec/vec/utils/vscat.c
> [1]PETSC ERROR: MatSetUpMultiply_MPIAIJ() line 150 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/impls/aij/mpi/mmaij.c
> [1]PETSC ERROR: MatAssemblyEnd_MPIAIJ() line 702 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/impls/aij/mpi/mpiaij.c
> [1]PETSC ERROR: MatAssemblyEnd() line 4879 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/interface/matrix.c
> [1]PETSC ERROR: User provided function() line 65 in "unknowndirectory/"/home/Codes/trunk/HSim2/Include/Math/PetscMatrix.h
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Operation done in wrong order!
> [0]PETSC ERROR: Must call MatAssemblyBegin/End() before viewing matrix!
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 3.3.0, Patch 5, Sat Dec 1 15:10:41 CST 2012
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: ./bin_Ubuntu/HSim2 on a linux-gnu named hesam2-VirtualBox by hesam2 Thu Jan 3 13:44:28 2013
> [0]PETSC ERROR: Libraries linked from /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/linux-gnu-real/lib
> [0]PETSC ERROR: Configure run at Fri Dec 21 08:15:55 2012
> [0]PETSC ERROR: Configure options PETSC_DIR=/home/Codes/trunk/Libs/Petsc/PETSC_Build_Real PETSC_ARCH=linux-gnu-real --with-shared-libraries --download-f-blas-lapack=1 --with-single-library=0 --with-shared-libraries --with-debugging=1 --with-scalar-type=real
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: MatView() line 740 in /home/Codes/trunk/Libs/Petsc/PETSC_Build_Real/src/mat/interface/matrix.c
>
> ================================================================================
>
>
> Many Thanks
> Hesam
>
More information about the petsc-dev
mailing list