Re: [petsc-users] STFILTER in slepc

2018-10-10 Thread Matthew Knepley
On Wed, Oct 10, 2018 at 8:41 PM Moritz Cygorek  wrote:

> Thank you very much. Apparently, I've misunderstood what the filter
> actually does. I thought about the much simpler process, where you
> diagonalize
>
>
> -(A- tau*I)^2 +offset*I
>
>
> where tau is my target an offset is large enough so that the global
> maximum is reached for eigenvalues around tau.
>

Is this different from -eps_target_magnitude?

  Thanks,

Matt


> Then you look for the largest eigenvalue of the modified problem and
> either calculate the Ritz value of the original matrix or calculate back
> from the eigenvalues of the modified problem.
>
>
> Now, it looks to me like -st_type filter activates something like the
> package FILTLAN.
>
>
> I guess I can define a MatShell to do the thing I intended in the first
> place.
>
> But, I guess, this is a common thing, so I am wondering whether it is
> already implemented somewhere and I just didn't find it in the
> documentation.  Can you say something about this?
>
>
> Regards,
>
> Moritz
>
>
>
>
> --
> *From:* Jose E. Roman 
> *Sent:* Wednesday, October 10, 2018 3:48 PM
> *To:* Moritz Cygorek
> *Cc:* petsc-users@mcs.anl.gov
> *Subject:* Re: [petsc-users] STFILTER in slepc
>
> This type of method requires a very high degree polynomial; suggest using
> degree=100 at least (this is the default value), but larger values may be
> necessary. Also, for this particular filter the "range" must be
> approximately equal to the numerical range; if you have no clue where your
> first and last eigenvalues are, you may use EPSSolve() calls with
> EPS_LARGEST_REAL and EPS_SMALLEST_REAL.
>
> Jose
>
> > El 10 oct 2018, a las 21:10, Moritz Cygorek 
> escribió:
> >
> > Thank you for the fast reply.
> >
> > I've tried running my program (using the defaul Krylov-Schur method for
> sparse MPI matrices) with the additional options:
> >
> > -st_type filter -st_filter_degree 2 -st_filter_interval 2.,2.7
> -st_filter_range -2000,2000
> >
> > and I get the following error message:
> >
> > [0]PETSC ERROR: STFILTER cannot get the filter specified; please adjust
> your filter parameters (e.g. increasing the polynomial degree)
> > 
> > [0]PETSC ERROR: #1 FILTLAN_GetIntervals() line 451 in
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filtlan.c
> > [0]PETSC ERROR: #2 STFilter_FILTLAN_setFilter() line 1016 in
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filtlan.c
> > [0]PETSC ERROR: #3 STSetUp_Filter() line 42 in
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filter.c
> > [0]PETSC ERROR: #4 STSetUp() line 271 in
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/interface/stsolve.c
> > [0]PETSC ERROR: #5 EPSSetUp() line 263 in
> /home/applications/sources/libraries/slepc-3.9.2/src/eps/interface/epssetup.c
> > [0]PETSC ERROR: #6 EPSSolve() line 135 in
> /home/applications/sources/libraries/slepc-3.9.2/src/eps/interface/epssolve.c
> >
> >
> >
> > Do you have a clue what I've missed?
> >
> >
> > Moritz
> >
> >
> > From: Jose E. Roman 
> > Sent: Wednesday, October 10, 2018 2:30 PM
> > To: Moritz Cygorek
> > Cc: petsc-users@mcs.anl.gov
> > Subject: Re: [petsc-users] STFILTER in slepc
> >
> >
> > > El 10 oct 2018, a las 19:54, Moritz Cygorek 
> escribió:
> > >
> > > Hi,
> > >
> > > in the list of changes to SLEPc version 3.8, it is stated that there
> is a preliminary implementation of polynomial filtering using STFILTER.
> > >
> > > Because I am struggling to obtain interior eigenvalues and harmonic
> extraction seems not to be stable enough in my case, I wanted to give it a
> try, but I could not find any documentation yet.
> > >
> > > Does anybody have an example of how to use STFILTER or any
> documentation about it?
> > >
> > > Thanks in advance,
> > > Moritz
> >
> > There are no examples. You just set the type to STFILTER and set some
> parameters such as the interval of interest or the polynomial degree. See
> functions starting with STFilter here:
> http://slepc.upv.es/documentation/current/docs/manualpages/ST/index.html
> >
> > In some problems it works well, but don't expect too much. It is still
> in our to-do list to make it more usable. It will be good to have your
> feedback. If you want, send results to slepc-maint, maybe we can help
> tuning the parameters.
> >
> > Jose
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ 


Re: [petsc-users] STFILTER in slepc

2018-10-10 Thread Moritz Cygorek
Thank you very much. Apparently, I've misunderstood what the filter actually 
does. I thought about the much simpler process, where you diagonalize


-(A- tau*I)^2 +offset*I


where tau is my target an offset is large enough so that the global maximum is 
reached for eigenvalues around tau. Then you look for the largest eigenvalue of 
the modified problem and either calculate the Ritz value of the original matrix 
or calculate back from the eigenvalues of the modified problem.


Now, it looks to me like -st_type filter activates something like the package 
FILTLAN.


I guess I can define a MatShell to do the thing I intended in the first place.

But, I guess, this is a common thing, so I am wondering whether it is already 
implemented somewhere and I just didn't find it in the documentation.  Can you 
say something about this?


Regards,

Moritz




From: Jose E. Roman 
Sent: Wednesday, October 10, 2018 3:48 PM
To: Moritz Cygorek
Cc: petsc-users@mcs.anl.gov
Subject: Re: [petsc-users] STFILTER in slepc

This type of method requires a very high degree polynomial; suggest using 
degree=100 at least (this is the default value), but larger values may be 
necessary. Also, for this particular filter the "range" must be approximately 
equal to the numerical range; if you have no clue where your first and last 
eigenvalues are, you may use EPSSolve() calls with EPS_LARGEST_REAL and 
EPS_SMALLEST_REAL.

Jose

> El 10 oct 2018, a las 21:10, Moritz Cygorek  escribió:
>
> Thank you for the fast reply.
>
> I've tried running my program (using the defaul Krylov-Schur method for 
> sparse MPI matrices) with the additional options:
>
> -st_type filter -st_filter_degree 2 -st_filter_interval 2.,2.7  
> -st_filter_range -2000,2000
>
> and I get the following error message:
>
> [0]PETSC ERROR: STFILTER cannot get the filter specified; please adjust your 
> filter parameters (e.g. increasing the polynomial degree)
> 
> [0]PETSC ERROR: #1 FILTLAN_GetIntervals() line 451 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filtlan.c
> [0]PETSC ERROR: #2 STFilter_FILTLAN_setFilter() line 1016 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filtlan.c
> [0]PETSC ERROR: #3 STSetUp_Filter() line 42 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filter.c
> [0]PETSC ERROR: #4 STSetUp() line 271 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/interface/stsolve.c
> [0]PETSC ERROR: #5 EPSSetUp() line 263 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/eps/interface/epssetup.c
> [0]PETSC ERROR: #6 EPSSolve() line 135 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/eps/interface/epssolve.c
>
>
>
> Do you have a clue what I've missed?
>
>
> Moritz
>
>
> From: Jose E. Roman 
> Sent: Wednesday, October 10, 2018 2:30 PM
> To: Moritz Cygorek
> Cc: petsc-users@mcs.anl.gov
> Subject: Re: [petsc-users] STFILTER in slepc
>
>
> > El 10 oct 2018, a las 19:54, Moritz Cygorek  escribió:
> >
> > Hi,
> >
> > in the list of changes to SLEPc version 3.8, it is stated that there is a 
> > preliminary implementation of polynomial filtering using STFILTER.
> >
> > Because I am struggling to obtain interior eigenvalues and harmonic 
> > extraction seems not to be stable enough in my case, I wanted to give it a 
> > try, but I could not find any documentation yet.
> >
> > Does anybody have an example of how to use STFILTER or any documentation 
> > about it?
> >
> > Thanks in advance,
> > Moritz
>
> There are no examples. You just set the type to STFILTER and set some 
> parameters such as the interval of interest or the polynomial degree. See 
> functions starting with STFilter 
> here:http://slepc.upv.es/documentation/current/docs/manualpages/ST/index.html
>
> In some problems it works well, but don't expect too much. It is still in our 
> to-do list to make it more usable. It will be good to have your feedback. If 
> you want, send results to slepc-maint, maybe we can help tuning the 
> parameters.
>
> Jose



Re: [petsc-users] STFILTER in slepc

2018-10-10 Thread Jose E. Roman
This type of method requires a very high degree polynomial; suggest using 
degree=100 at least (this is the default value), but larger values may be 
necessary. Also, for this particular filter the "range" must be approximately 
equal to the numerical range; if you have no clue where your first and last 
eigenvalues are, you may use EPSSolve() calls with EPS_LARGEST_REAL and 
EPS_SMALLEST_REAL.

Jose

> El 10 oct 2018, a las 21:10, Moritz Cygorek  escribió:
> 
> Thank you for the fast reply. 
> 
> I've tried running my program (using the defaul Krylov-Schur method for 
> sparse MPI matrices) with the additional options:
> 
> -st_type filter -st_filter_degree 2 -st_filter_interval 2.,2.7  
> -st_filter_range -2000,2000
> 
> and I get the following error message:
> 
> [0]PETSC ERROR: STFILTER cannot get the filter specified; please adjust your 
> filter parameters (e.g. increasing the polynomial degree)
> 
> [0]PETSC ERROR: #1 FILTLAN_GetIntervals() line 451 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filtlan.c
> [0]PETSC ERROR: #2 STFilter_FILTLAN_setFilter() line 1016 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filtlan.c
> [0]PETSC ERROR: #3 STSetUp_Filter() line 42 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filter.c
> [0]PETSC ERROR: #4 STSetUp() line 271 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/interface/stsolve.c
> [0]PETSC ERROR: #5 EPSSetUp() line 263 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/eps/interface/epssetup.c
> [0]PETSC ERROR: #6 EPSSolve() line 135 in 
> /home/applications/sources/libraries/slepc-3.9.2/src/eps/interface/epssolve.c
> 
> 
> 
> Do you have a clue what I've missed?
> 
> 
> Moritz
> 
> 
> From: Jose E. Roman 
> Sent: Wednesday, October 10, 2018 2:30 PM
> To: Moritz Cygorek
> Cc: petsc-users@mcs.anl.gov
> Subject: Re: [petsc-users] STFILTER in slepc
>  
> 
> > El 10 oct 2018, a las 19:54, Moritz Cygorek  escribió:
> > 
> > Hi,
> > 
> > in the list of changes to SLEPc version 3.8, it is stated that there is a 
> > preliminary implementation of polynomial filtering using STFILTER. 
> > 
> > Because I am struggling to obtain interior eigenvalues and harmonic 
> > extraction seems not to be stable enough in my case, I wanted to give it a 
> > try, but I could not find any documentation yet.
> > 
> > Does anybody have an example of how to use STFILTER or any documentation 
> > about it?
> > 
> > Thanks in advance,
> > Moritz
> 
> There are no examples. You just set the type to STFILTER and set some 
> parameters such as the interval of interest or the polynomial degree. See 
> functions starting with STFilter 
> here:http://slepc.upv.es/documentation/current/docs/manualpages/ST/index.html
> 
> In some problems it works well, but don't expect too much. It is still in our 
> to-do list to make it more usable. It will be good to have your feedback. If 
> you want, send results to slepc-maint, maybe we can help tuning the 
> parameters.
> 
> Jose



Re: [petsc-users] STFILTER in slepc

2018-10-10 Thread Moritz Cygorek
Thank you for the fast reply.


I've tried running my program (using the defaul Krylov-Schur method for sparse 
MPI matrices) with the additional options:


-st_type filter -st_filter_degree 2 -st_filter_interval 2.,2.7  
-st_filter_range -2000,2000


and I get the following error message:


[0]PETSC ERROR: STFILTER cannot get the filter specified; please adjust your 
filter parameters (e.g. increasing the polynomial degree)


[0]PETSC ERROR: #1 FILTLAN_GetIntervals() line 451 in 
/home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filtlan.c
[0]PETSC ERROR: #2 STFilter_FILTLAN_setFilter() line 1016 in 
/home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filtlan.c
[0]PETSC ERROR: #3 STSetUp_Filter() line 42 in 
/home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/impls/filter/filter.c
[0]PETSC ERROR: #4 STSetUp() line 271 in 
/home/applications/sources/libraries/slepc-3.9.2/src/sys/classes/st/interface/stsolve.c
[0]PETSC ERROR: #5 EPSSetUp() line 263 in 
/home/applications/sources/libraries/slepc-3.9.2/src/eps/interface/epssetup.c
[0]PETSC ERROR: #6 EPSSolve() line 135 in 
/home/applications/sources/libraries/slepc-3.9.2/src/eps/interface/epssolve.c




Do you have a clue what I've missed?



Moritz



From: Jose E. Roman 
Sent: Wednesday, October 10, 2018 2:30 PM
To: Moritz Cygorek
Cc: petsc-users@mcs.anl.gov
Subject: Re: [petsc-users] STFILTER in slepc


> El 10 oct 2018, a las 19:54, Moritz Cygorek  escribió:
>
> Hi,
>
> in the list of changes to SLEPc version 3.8, it is stated that there is a 
> preliminary implementation of polynomial filtering using STFILTER.
>
> Because I am struggling to obtain interior eigenvalues and harmonic 
> extraction seems not to be stable enough in my case, I wanted to give it a 
> try, but I could not find any documentation yet.
>
> Does anybody have an example of how to use STFILTER or any documentation 
> about it?
>
> Thanks in advance,
> Moritz

There are no examples. You just set the type to STFILTER and set some 
parameters such as the interval of interest or the polynomial degree. See 
functions starting with STFilter here: 
http://slepc.upv.es/documentation/current/docs/manualpages/ST/index.html

In some problems it works well, but don't expect too much. It is still in our 
to-do list to make it more usable. It will be good to have your feedback. If 
you want, send results to slepc-maint, maybe we can help tuning the parameters.

Jose



Re: [petsc-users] STFILTER in slepc

2018-10-10 Thread Jose E. Roman


> El 10 oct 2018, a las 19:54, Moritz Cygorek  escribió:
> 
> Hi,
> 
> in the list of changes to SLEPc version 3.8, it is stated that there is a 
> preliminary implementation of polynomial filtering using STFILTER. 
> 
> Because I am struggling to obtain interior eigenvalues and harmonic 
> extraction seems not to be stable enough in my case, I wanted to give it a 
> try, but I could not find any documentation yet.
> 
> Does anybody have an example of how to use STFILTER or any documentation 
> about it?
> 
> Thanks in advance,
> Moritz

There are no examples. You just set the type to STFILTER and set some 
parameters such as the interval of interest or the polynomial degree. See 
functions starting with STFilter here: 
http://slepc.upv.es/documentation/current/docs/manualpages/ST/index.html

In some problems it works well, but don't expect too much. It is still in our 
to-do list to make it more usable. It will be good to have your feedback. If 
you want, send results to slepc-maint, maybe we can help tuning the parameters.

Jose



[petsc-users] STFILTER in slepc

2018-10-10 Thread Moritz Cygorek
Hi,


in the list of changes to SLEPc version 3.8, it is stated that there is a 
preliminary implementation of polynomial filtering using STFILTER.


Because I am struggling to obtain interior eigenvalues and harmonic extraction 
seems not to be stable enough in my case, I wanted to give it a try, but I 
could not find any documentation yet.


Does anybody have an example of how to use STFILTER or any documentation about 
it?


Thanks in advance,

Moritz


Re: [petsc-users] error: ‘DMSetSection’ was not declared in this scope

2018-10-10 Thread Ling Zou
BTW, if I move the source file to:

petsc-3.10.2/src/dm/impls/plex/examples/tutorials


Using the makefile there, it compiles just fine.


Ling


From: petsc-users  on behalf of Ling Zou 

Sent: Wednesday, October 10, 2018 10:35:37 AM
To: PETSc users list
Subject: [petsc-users] error: ‘DMSetSection’ was not declared in this scope


Hi All,


I am starting playing with DMPlex, but get this error:


error: ‘DMSetSection’ was not declared in this scope


However, other DMPlex basic functions work just fine, e.g.,

DMPlexCreateFluentFromFile

DMPlexCheckSymmetry

DMPlexCheckSkeleton

DMPlexCheckFaces

DMPlexGetChart

DMPlexGetHeightStratum


Is this function somewhat special?


PS: I am using cmake, and followed Jed's FindPETSc.cmake at 
https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake


Ling

[https://avatars1.githubusercontent.com/u/3303?s=400=4]

jedbrown/cmake-modules - 
GitHub
github.com
CMake modules for some scientific libraries. Contribute to 
jedbrown/cmake-modules development by creating an account on GitHub.




[petsc-users] error: ‘DMSetSection’ was not declared in this scope

2018-10-10 Thread Ling Zou
Hi All,


I am starting playing with DMPlex, but get this error:


error: ‘DMSetSection’ was not declared in this scope


However, other DMPlex basic functions work just fine, e.g.,

DMPlexCreateFluentFromFile

DMPlexCheckSymmetry

DMPlexCheckSkeleton

DMPlexCheckFaces

DMPlexGetChart

DMPlexGetHeightStratum


Is this function somewhat special?


PS: I am using cmake, and followed Jed's FindPETSc.cmake at 
https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake


Ling

[https://avatars1.githubusercontent.com/u/3303?s=400=4]

jedbrown/cmake-modules - 
GitHub
github.com
CMake modules for some scientific libraries. Contribute to 
jedbrown/cmake-modules development by creating an account on GitHub.




Re: [petsc-users] Problems about Block Jocabi and Matrix-Free Method in SNES

2018-10-10 Thread Matthew Knepley
On Wed, Oct 10, 2018 at 8:50 AM Yingjie Wu  wrote:

> Thank you very much, Matt.
>  I followed your advice and learned some MATMFFD related functions. Since
> I really wanted to use the Matrix-Free method, I learned the few examples
> of this method. I would like to enhance my understanding of the Matrix-Free
> method in PETSc according to my questions about these examples and hope to
> get your answer.
> 1. In the example src/snes/example/tutorials/ex22.c
>
> ..
> 107:   packer->ops->creatematrix = DMCreateMatrix_MF;
>
> 110:   SNESCreate(PETSC_COMM_WORLD,);
> 111:   SNESSetDM(snes,packer);
> 112:   SNESSetFunction(snes,NULL,ComputeFunction,NULL);
> 113:   SNESSetJacobian(snes,NULL, NULL,ComputeJacobian_MF,NULL);
>
> 115:   SNESSetFromOptions(snes);
> ..
> 285: PetscErrorCode DMCreateMatrix_MF(DM packer,Mat *A)
> 286: {
> 288:   Vect;
> 289:   PetscInt   m;
>
> 292:   DMGetGlobalVector(packer,);
> 293:   VecGetLocalSize(t,);
> 294:   DMRestoreGlobalVector(packer,);
> 295:
>  MatCreateMFFD(PETSC_COMM_WORLD,m,m,PETSC_DETERMINE,PETSC_DETERMINE,A);
> 296:   MatSetUp(*A);
> 297:   return(0);
> 298: }
>
> 300: PetscErrorCode ComputeJacobian_MF(SNES snes,Vec x,Mat A,Mat B,void
> *ctx)
> 301: {
>
> 305:   MatMFFDSetFunction(A,(PetscErrorCode
> (*)(void*,Vec,Vec))SNESComputeFunction,snes);
> 306:   MatMFFDSetBase(A,x,NULL);
> 307:   return(0);
> 308: }
>
> Why are the solution vector, Jacobian matrix, and precondition matrix set
> to NULL in SNESSetJacobian? Is it because they are automatically generated
> in SNESSetDM?
>

Yes. This example show how to do it by hand. If you give NULL for your
FormJacobian function, we do it automatically. If you give _mf_operator,
then we do it, but pass through the matrices to your FormJacobian()
function.


> There is no precondition matrix B in ComputeJacobian_MF (Jacobian evaluate
> program). If I want to add my own precondition matrix, then the Assembly
> matrix B in this function, is that right?
> What is the function of MatMFFDSetBase? I read the documentation but
> didn't understand it. What would happen if I removed it?
>

SetBase() provides the initial vector for differencing. This is necessary.


> 2. In the example /src/snes/examples/tutorials/ex14.c
>
> 114:   SNESSetFunction(snes,r,FormFunction,(void*));
>
> 131:   PetscOptionsGetBool(NULL,NULL,"-snes_mf",_free,NULL);
> 132:   PetscOptionsGetBool(NULL,NULL,"-fdcoloring",,NULL);
> 133:   PetscOptionsGetBool(NULL,NULL,"-fdcoloring_ds",_ds,NULL);
> 134:
>  PetscOptionsGetBool(NULL,NULL,"-fdcoloring_local",_coloring,NULL);
> 135:   if (!matrix_free) {
> 136: DMSetMatType(user.da,MATAIJ);
> 137: DMCreateMatrix(user.da,);
> 138: if (coloring) {
> 139:   ISColoring iscoloring;
> 140:   if (!local_coloring) {
> 141: DMCreateColoring(user.da,IS_COLORING_GLOBAL,);
> 142: MatFDColoringCreate(J,iscoloring,);
> 143: MatFDColoringSetFunction(matfdcoloring,(PetscErrorCode
> (*)(void))FormFunction,);
> 144:   } else {
> 145: DMCreateColoring(user.da,IS_COLORING_LOCAL,);
> 146: MatFDColoringCreate(J,iscoloring,);
> 147: MatFDColoringUseDM(J,matfdcoloring);
> 148: MatFDColoringSetFunction(matfdcoloring,(PetscErrorCode
> (*)(void))FormFunctionLocal,);
> 149:   }
> 150:   if (coloring_ds) {
> 151: MatFDColoringSetType(matfdcoloring,MATMFFD_DS);
> 152:   }
> 153:   MatFDColoringSetFromOptions(matfdcoloring);
> 154:   MatFDColoringSetUp(J,iscoloring,matfdcoloring);
> 155:
>  SNESSetJacobian(snes,J,J,SNESComputeJacobianDefaultColor,matfdcoloring);
> 156:   ISColoringDestroy();
> 157: } else {
> 158:   SNESSetJacobian(snes,J,J,FormJacobian,);
> 159: }
> 160:   }
>
> If the command "- snes_mf" is used, the function SNESSetJacobian is not
> called, and the Jacobian matrix type is initialized as MATMFFD. The
> function in SNESSetFunction is used to approximate the matrix vector
> product. Do I understand this correctly?
>

Yes .

  Thanks,

 Matt


> The description of my question may be complicated, but as a beginner, I
> really want to learn something about matrix-free method from the examples,
> and I hope to get your reply.
>
> Thanks,
> Yingjie
>
> Matthew Knepley  于2018年10月9日周二 下午11:34写道:
>
>> On Mon, Oct 8, 2018 at 11:33 PM Yingjie Wu  wrote:
>>
>>> Dear Petsc developer:
>>> Hi,
>>>
>>> I've been studying Petsc recently about Precontioner and Metrix-Free,
>>> and I have some questions that puzzle me.
>>>
>>> 1. I want to test block Jacobi preconditioner, so I chose
>>> /snes/example/tutorial/ex3.c as an example. According to the reference in
>>> the example, the input parameters are:
>>> mpiexec -n 8./ex3 -nox -n 1 -ksp_type fgmres -pc_type bjacobi
>>> -pc_bjacobi_blocks 4 -sub_ksp_type gmres -sub_ksp_max_it 3 -post_setsubksp
>>> -sub_ksp_rtol 1.e-16
>>>
>>
>> You do not care about recursive blocks, so just use
>>
>>   $MPIEXEC -n 8 ./ex3 -nox -n 1 -ksp_type fgmres -pc_type 

Re: [petsc-users] Problems about Block Jocabi and Matrix-Free Method in SNES

2018-10-10 Thread Yingjie Wu
Thank you very much, Matt.
 I followed your advice and learned some MATMFFD related functions. Since I
really wanted to use the Matrix-Free method, I learned the few examples of
this method. I would like to enhance my understanding of the Matrix-Free
method in PETSc according to my questions about these examples and hope to
get your answer.
1. In the example src/snes/example/tutorials/ex22.c

..
107:   packer->ops->creatematrix = DMCreateMatrix_MF;

110:   SNESCreate(PETSC_COMM_WORLD,);
111:   SNESSetDM(snes,packer);
112:   SNESSetFunction(snes,NULL,ComputeFunction,NULL);
113:   SNESSetJacobian(snes,NULL, NULL,ComputeJacobian_MF,NULL);

115:   SNESSetFromOptions(snes);
..
285: PetscErrorCode DMCreateMatrix_MF(DM packer,Mat *A)
286: {
288:   Vect;
289:   PetscInt   m;

292:   DMGetGlobalVector(packer,);
293:   VecGetLocalSize(t,);
294:   DMRestoreGlobalVector(packer,);
295:
 MatCreateMFFD(PETSC_COMM_WORLD,m,m,PETSC_DETERMINE,PETSC_DETERMINE,A);
296:   MatSetUp(*A);
297:   return(0);
298: }

300: PetscErrorCode ComputeJacobian_MF(SNES snes,Vec x,Mat A,Mat B,void
*ctx)
301: {

305:   MatMFFDSetFunction(A,(PetscErrorCode
(*)(void*,Vec,Vec))SNESComputeFunction,snes);
306:   MatMFFDSetBase(A,x,NULL);
307:   return(0);
308: }

Why are the solution vector, Jacobian matrix, and precondition matrix set
to NULL in SNESSetJacobian? Is it because they are automatically generated
in SNESSetDM?
There is no precondition matrix B in ComputeJacobian_MF (Jacobian evaluate
program). If I want to add my own precondition matrix, then the Assembly
matrix B in this function, is that right?
What is the function of MatMFFDSetBase? I read the documentation but didn't
understand it. What would happen if I removed it?

2. In the example /src/snes/examples/tutorials/ex14.c

114:   SNESSetFunction(snes,r,FormFunction,(void*));

131:   PetscOptionsGetBool(NULL,NULL,"-snes_mf",_free,NULL);
132:   PetscOptionsGetBool(NULL,NULL,"-fdcoloring",,NULL);
133:   PetscOptionsGetBool(NULL,NULL,"-fdcoloring_ds",_ds,NULL);
134:
 PetscOptionsGetBool(NULL,NULL,"-fdcoloring_local",_coloring,NULL);
135:   if (!matrix_free) {
136: DMSetMatType(user.da,MATAIJ);
137: DMCreateMatrix(user.da,);
138: if (coloring) {
139:   ISColoring iscoloring;
140:   if (!local_coloring) {
141: DMCreateColoring(user.da,IS_COLORING_GLOBAL,);
142: MatFDColoringCreate(J,iscoloring,);
143: MatFDColoringSetFunction(matfdcoloring,(PetscErrorCode
(*)(void))FormFunction,);
144:   } else {
145: DMCreateColoring(user.da,IS_COLORING_LOCAL,);
146: MatFDColoringCreate(J,iscoloring,);
147: MatFDColoringUseDM(J,matfdcoloring);
148: MatFDColoringSetFunction(matfdcoloring,(PetscErrorCode
(*)(void))FormFunctionLocal,);
149:   }
150:   if (coloring_ds) {
151: MatFDColoringSetType(matfdcoloring,MATMFFD_DS);
152:   }
153:   MatFDColoringSetFromOptions(matfdcoloring);
154:   MatFDColoringSetUp(J,iscoloring,matfdcoloring);
155:
 SNESSetJacobian(snes,J,J,SNESComputeJacobianDefaultColor,matfdcoloring);
156:   ISColoringDestroy();
157: } else {
158:   SNESSetJacobian(snes,J,J,FormJacobian,);
159: }
160:   }

If the command "- snes_mf" is used, the function SNESSetJacobian is not
called, and the Jacobian matrix type is initialized as MATMFFD. The
function in SNESSetFunction is used to approximate the matrix vector
product. Do I understand this correctly?
The description of my question may be complicated, but as a beginner, I
really want to learn something about matrix-free method from the examples,
and I hope to get your reply.

Thanks,
Yingjie

Matthew Knepley  于2018年10月9日周二 下午11:34写道:

> On Mon, Oct 8, 2018 at 11:33 PM Yingjie Wu  wrote:
>
>> Dear Petsc developer:
>> Hi,
>>
>> I've been studying Petsc recently about Precontioner and Metrix-Free, and
>> I have some questions that puzzle me.
>>
>> 1. I want to test block Jacobi preconditioner, so I chose
>> /snes/example/tutorial/ex3.c as an example. According to the reference in
>> the example, the input parameters are:
>> mpiexec -n 8./ex3 -nox -n 1 -ksp_type fgmres -pc_type bjacobi
>> -pc_bjacobi_blocks 4 -sub_ksp_type gmres -sub_ksp_max_it 3 -post_setsubksp
>> -sub_ksp_rtol 1.e-16
>>
>
> You do not care about recursive blocks, so just use
>
>   $MPIEXEC -n 8 ./ex3 -nox -n 1 -ksp_type fgmres -pc_type bjacobi
> -pc_bjacobi_blocks 4 -sub_ksp_type gmres -sub_ksp_max_it 3 -snes_view
> -ksp_view
>
> and I get the attached output.
>
>
>> I want to export each block of KSP and PC information :
>>   -snes_view -ksp_view
>> However, the procedure is wrong and the wrong information is as follows:
>>
>>[0]PETSC ERROR: - Error Message
>> --
>> [0]PETSC ERROR: Arguments must have same communicators
>> [0]PETSC ERROR: Different communicators in the two objects: Argument # 1
>> and 2 flag 3
>> [0]PETSC ERROR: [1]PETSC 

Re: [petsc-users] PETSc/SLEPc: Memory consumption, particularly during solver initialization/solve

2018-10-10 Thread Matthew Knepley
On Wed, Oct 10, 2018 at 3:38 AM Ale Foggia  wrote:

> Jed, Jose and Matthew,
> I've finally managed to make massif (it gives pretty detailed information,
> I like it) work in the correct way in the cluster and I'm able to track
> down the memory consumption, and what's more important (for me), I think
> now I'm able to make a more accurate prediction of the memory I need for a
> particular size of the problem. Thank you very much for all your answers
> and suggestions.
>

Great! Could you tell me in one line what was taking up memory? It always
good to hear about real applications.

  Thanks,

Matt


> El vie., 5 oct. 2018 a las 9:38, Jose E. Roman ()
> escribió:
>
>>
>>
>> > El 4 oct 2018, a las 19:54, Ale Foggia  escribió:
>> >
>> > Jose:
>> > - By each step I mean each of the step of the the program in order to
>> diagonalize the matrix. For me, those are: creation of basis, preallocation
>> of matrix, setting values of matrix, initializing solver,
>> solving/diagonalizing and cleaning. I'm only diagonalizing once.
>> >
>> > - Regarding the information provided by -log_view, it's confusing for
>> me: for example, it reports the creation of Vecs scattered across the
>> various stages that I've set up (with PetscLogStageRegister and
>> PetscLogStagePush/Pop), but almost all the deletions are presented in the
>> "Main Stage". What does that "Main Stage" consider? Why are more deletions
>> in there that creations? It's nor completely for me clear how things are
>> presented there.
>>
>> I guess deletions should match creations. Seems to be related to using
>> stages. Maybe someone from PETSc can give an explanation, but looking at a
>> PETSc example that uses stages (e.g. dm/impls/plex/examples/tests/ex1.c) it
>> seems that some destructions are counted in the main stage while the
>> creation is counted in another stage - I guess it depends on the points
>> where the stages are defined. The sum of creations matches the sum of
>> destroys.
>>
>> >
>> > - Thanks for the suggestion about the solver. Does "faster convergence"
>> for Krylov-Schur mean less memory and less computation, or just less
>> computation?
>> >
>>
>> It should be about the same memory with less iterations.
>>
>> Jose
>>
>>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ 


Re: [petsc-users] PETSc/SLEPc: Memory consumption, particularly during solver initialization/solve

2018-10-10 Thread Ale Foggia
Jed, Jose and Matthew,
I've finally managed to make massif (it gives pretty detailed information,
I like it) work in the correct way in the cluster and I'm able to track
down the memory consumption, and what's more important (for me), I think
now I'm able to make a more accurate prediction of the memory I need for a
particular size of the problem. Thank you very much for all your answers
and suggestions.

El vie., 5 oct. 2018 a las 9:38, Jose E. Roman ()
escribió:

>
>
> > El 4 oct 2018, a las 19:54, Ale Foggia  escribió:
> >
> > Jose:
> > - By each step I mean each of the step of the the program in order to
> diagonalize the matrix. For me, those are: creation of basis, preallocation
> of matrix, setting values of matrix, initializing solver,
> solving/diagonalizing and cleaning. I'm only diagonalizing once.
> >
> > - Regarding the information provided by -log_view, it's confusing for
> me: for example, it reports the creation of Vecs scattered across the
> various stages that I've set up (with PetscLogStageRegister and
> PetscLogStagePush/Pop), but almost all the deletions are presented in the
> "Main Stage". What does that "Main Stage" consider? Why are more deletions
> in there that creations? It's nor completely for me clear how things are
> presented there.
>
> I guess deletions should match creations. Seems to be related to using
> stages. Maybe someone from PETSc can give an explanation, but looking at a
> PETSc example that uses stages (e.g. dm/impls/plex/examples/tests/ex1.c) it
> seems that some destructions are counted in the main stage while the
> creation is counted in another stage - I guess it depends on the points
> where the stages are defined. The sum of creations matches the sum of
> destroys.
>
> >
> > - Thanks for the suggestion about the solver. Does "faster convergence"
> for Krylov-Schur mean less memory and less computation, or just less
> computation?
> >
>
> It should be about the same memory with less iterations.
>
> Jose
>
>