Re: [petsc-users] a question about MatSetValue

2020-05-21 Thread Yang Bo (Asst Prof)
I see, it is working now, thanks!

On 21 May 2020, at 6:23 PM, Dave May 
mailto:dave.mayhe...@gmail.com>> wrote:



On Thu 21. May 2020 at 12:17, Yang Bo (Asst Prof) 
mailto:yang...@ntu.edu.sg>> wrote:
Hi Dave,

Yes it is parallel so the preallocation calls are not lowered by the allocation.

I am trying to use MatXAIJSetPreallocation, but not sure how, since the 
following link does not give an example:

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatXAIJSetPreallocation.html

If I have the following matrix:

0 1 2 0
1 0 0 0
2 0 1 3
0 0 3 2

How should I put in the parameters of MatXAIJSetPreallocation?

Please read this page to understand the info required

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html


Compute everything as described above and give the results to 
MatXAIJSetPreallocation(). MatXAIJSetPreallocation() is just a helper function 
to hide all the implementation specific setters.

Thanks
Dave






Thanks!

Cheers,

Yang Bo


On 21 May 2020, at 5:42 PM, Dave May 
mailto:dave.mayhe...@gmail.com>> wrote:



On Thu 21. May 2020 at 10:49, Yang Bo (Asst Prof) 
mailto:yang...@ntu.edu.sg>> wrote:
Hi Dave,

Thank you very much for your reply. That is indeed the problem. I have been 
working with matrices in Slepc but I don’t really understand it. I tried to 
preallocate but it still does not work.

Meaning the number of reported mallocs is still non-zero?
Is the number reported with you preallocation calls lower than what you 
originally saw?

If you look at my code below:

ierr = MatCreate(PETSC_COMM_WORLD,);CHKERRQ(ierr);
ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,h_dim,h_dim);
  // h_dim is the dimension of the square matrix A
ierr = MatSetFromOptions(A);CHKERRQ(ierr);
ierr = MatSetUp(A);CHKERRQ(ierr);
ierr = MatGetOwnershipRange(A,,);CHKERRQ(ierr);

MatSeqAIJSetPreallocation(A,0,nnz);   // I 
try to preallocate here, where nnz is the array containing the number of 
non-zero entries each row

for (int i=0;imailto:dave.mayhe...@gmail.com>> wrote:

-info | grep malloc



CONFIDENTIALITY: This email is intended solely for the person(s) named and may 
be confidential and/or privileged. If you are not the intended recipient, 
please delete it, notify us and do not copy, use, or disclose its contents.
Towards a sustainable earth: Print only when necessary. Thank you.



Re: [petsc-users] a question about MatSetValue

2020-05-21 Thread Yang Bo (Asst Prof)
Hi Dave,

Yes it is parallel so the preallocation calls are not lowered by the allocation.

I am trying to use MatXAIJSetPreallocation, but not sure how, since the 
following link does not give an example:

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatXAIJSetPreallocation.html

If I have the following matrix:

0 1 2 0
1 0 0 0
2 0 1 3
0 0 3 2

How should I put in the parameters of MatXAIJSetPreallocation?

Thanks!

Cheers,

Yang Bo


On 21 May 2020, at 5:42 PM, Dave May 
mailto:dave.mayhe...@gmail.com>> wrote:



On Thu 21. May 2020 at 10:49, Yang Bo (Asst Prof) 
mailto:yang...@ntu.edu.sg>> wrote:
Hi Dave,

Thank you very much for your reply. That is indeed the problem. I have been 
working with matrices in Slepc but I don’t really understand it. I tried to 
preallocate but it still does not work.

Meaning the number of reported mallocs is still non-zero?
Is the number reported with you preallocation calls lower than what you 
originally saw?

If you look at my code below:

ierr = MatCreate(PETSC_COMM_WORLD,);CHKERRQ(ierr);
ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,h_dim,h_dim);
  // h_dim is the dimension of the square matrix A
ierr = MatSetFromOptions(A);CHKERRQ(ierr);
ierr = MatSetUp(A);CHKERRQ(ierr);
ierr = MatGetOwnershipRange(A,,);CHKERRQ(ierr);

MatSeqAIJSetPreallocation(A,0,nnz);   // I 
try to preallocate here, where nnz is the array containing the number of 
non-zero entries each row

for (int i=0;imailto:dave.mayhe...@gmail.com>> wrote:

-info | grep malloc



CONFIDENTIALITY: This email is intended solely for the person(s) named and may 
be confidential and/or privileged. If you are not the intended recipient, 
please delete it, notify us and do not copy, use, or disclose its contents.
Towards a sustainable earth: Print only when necessary. Thank you.



Re: [petsc-users] a question about MatSetValue

2020-05-21 Thread Yang Bo (Asst Prof)
Hi Dave,

Thank you very much for your reply. That is indeed the problem. I have been 
working with matrices in Slepc but I don’t really understand it. I tried to 
preallocate but it still does not work. If you look at my code below:

ierr = MatCreate(PETSC_COMM_WORLD,);CHKERRQ(ierr);
ierr = MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,h_dim,h_dim);
  // h_dim is the dimension of the square matrix A
ierr = MatSetFromOptions(A);CHKERRQ(ierr);
ierr = MatSetUp(A);CHKERRQ(ierr);
ierr = MatGetOwnershipRange(A,,);CHKERRQ(ierr);

MatSeqAIJSetPreallocation(A,0,nnz);   // I 
try to preallocate here, where nnz is the array containing the number of 
non-zero entries each row

for (int i=0;imailto:dave.mayhe...@gmail.com>> wrote:

-info | grep malloc



CONFIDENTIALITY: This email is intended solely for the person(s) named and may 
be confidential and/or privileged. If you are not the intended recipient, 
please delete it, notify us and do not copy, use, or disclose its contents.
Towards a sustainable earth: Print only when necessary. Thank you.


[petsc-users] a question about MatSetValue

2020-05-21 Thread Yang Bo (Asst Prof)
Hi Everyone,

I have a question about adding values to the matrix. The code I have is


for (int i=0;i

[petsc-users] Random initial states of EPSSolve

2020-03-17 Thread Yang Bo (Asst Prof)
Hi everyone,

I am diagonalising a large symmetric real matrix for its null space (highly 
degenerate eigenstates with zero eigenvalues). I am using krylovschur which is 
variational, which is supposed to start with a set of random initial vectors. 
They will eventually converge to random vectors in the null space.

The problem is that if I run the EPSSOLVE with the same set of parameters (e.g. 
-eps_ncv and -eps_mpd), I always get the same eigenstates in the null space. 
This implies that the solver always start the same set of initial “random” 
vectors.

How does petsc generate the initial random vectors for krylovschur? Is there a 
way for me to generate different random initial vectors every time I run the 
diagonalisation (of the same matrix)?

Thanks, and stay safe and healthy!

Cheers,

Yang Bo


CONFIDENTIALITY: This email is intended solely for the person(s) named and may 
be confidential and/or privileged. If you are not the intended recipient, 
please delete it, notify us and do not copy, use, or disclose its contents.
Towards a sustainable earth: Print only when necessary. Thank you.


[petsc-users] ST solver error

2019-08-01 Thread Yang Bo (Asst Prof) via petsc-users
Hi everyone,

I am trying to use the Shift-and-invert spectral transformations for my 
diagonalisation code. While there is no problem running the code with

STSetType(st,STSHIFT);

I receive the following errors when using STSetType(st,STSINVERT):

[0]PETSC ERROR: - Error Message 
--
[0]PETSC ERROR: See 
http://www.mcs.anl.gov/petsc/documentation/linearsolvertable.html for possible 
LU and Cholesky solvers
[0]PETSC ERROR: Could not locate a solver package. Perhaps you must ./configure 
with --download-
[0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for 
trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.10.2, Oct, 09, 2018
[0]PETSC ERROR: ./main on a arch-linux2-c-debug named yangbo-ThinkStation-P720 
by yangbo Thu Aug  1 17:30:34 2019
[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ 
--with-fc=gfortran --download-mpich --download-fblaslapack --with-debugging=0 
COPTFLAGS="-O3 -march=native -mtune=native" CXXOPTFLAGS="-O3 -march=native 
-mtune=native" FOPTFLAGS="-O3 -march=native -mtune=native"
[0]PETSC ERROR: #1 MatGetFactor() line 4415 in 
/home/yangbo/petsc-3.10.2/src/mat/interface/matrix.c
[0]PETSC ERROR: #2 PCSetUp_LU() line 93 in 
/home/yangbo/petsc-3.10.2/src/ksp/pc/impls/factor/lu/lu.c
[0]PETSC ERROR: #3 PCSetUp() line 932 in 
/home/yangbo/petsc-3.10.2/src/ksp/pc/interface/precon.c
[0]PETSC ERROR: #4 KSPSetUp() line 391 in 
/home/yangbo/petsc-3.10.2/src/ksp/ksp/interface/itfunc.c
[0]PETSC ERROR: #5 STSetUp_Cayley() line 192 in 
/home/yangbo/slepc-3.10.1/src/sys/classes/st/impls/cayley/cayley.c
[0]PETSC ERROR: #6 STSetUp() line 271 in 
/home/yangbo/slepc-3.10.1/src/sys/classes/st/interface/stsolve.c
[0]PETSC ERROR: #7 EPSSetUp() line 263 in 
/home/yangbo/slepc-3.10.1/src/eps/interface/epssetup.c
[0]PETSC ERROR: #8 EPSSolve() line 135 in 
/home/yangbo/slepc-3.10.1/src/eps/interface/epssolve.c
[0]PETSC ERROR: #9 main() line 331 in main.cpp
[0]PETSC ERROR: PETSc Option Table entries:
[0]PETSC ERROR: -e 7
[0]PETSC ERROR: -f d
[0]PETSC ERROR: -nev 20
[0]PETSC ERROR: -o 19
[0]PETSC ERROR: End of Error Message ---send entire error 
message to petsc-ma...@mcs.anl.gov--
application called MPI_Abort(MPI_COMM_WORLD, 92) - process 0


May I know if I need to install the solver package for this to work?

Thank you very much!

Best regards,

Yang Bo