From cmay at phys.ethz.ch Mon Feb 1 16:02:12 2010 From: cmay at phys.ethz.ch (Christian May) Date: Mon, 1 Feb 2010 23:02:12 +0100 (CET) Subject: [petsc-users] where is PCREDISTRIBUTE? In-Reply-To: References: Message-ID: Ok, now it works. Thanks for the quick fix, Barry. Christian > Sorry, there was an error in the case when the preconditioner was >rebuilt with the same nonzero pattern, an internal matrix was >mistakenly freed early. > > Drop the attached src/ksp/ps/impls/redistribute.c and run make in >that directory and it should run correctly. > > Barry > >On Jan 31, 2010, at 7:10 AM, Christian May wrote: > >> Thanks, Matt. The preconditioner is now available, but when I invoke >> it with >> >> -ksp_type preonly -pc_type redistribute -redistribute_ksp_type cg - >> redistribute_pc_type bjacobi -redistribute_sub_pc_type icc >> >> I get the following error: >> >> [0]PETSC ERROR: --------------------- Error Message >> ------------------------------------ >> [0]PETSC ERROR: Invalid argument! >> [0]PETSC ERROR: Wrong type of object: Parameter # 5! >> [0]PETSC ERROR: >> ------------------------------------------------------------------------ >> [0]PETSC ERROR: Petsc Development HG revision: >> cec5db6729c23bbdb9cc80092ac1dc4ccc7e9069 HG Date: Fri Jan 29 >> 22:04:34 2010 -0600 >> [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: ./SPsolver2D-petsc on a linux-gnu named a6256.hpc- >> net.ethz.ch by cmay Sun Jan 31 11:10:52 2010 >> [0]PETSC ERROR: Libraries linked from /cluster/work/phys/cmay/petsc/ >> lib >> [0]PETSC ERROR: Configure run at Sat Jan 30 11:48:43 2010 >> [0]PETSC ERROR: Configure options --prefix=/cluster/work/phys/cmay/ >> petsc/ --with-c++-support --with-precision=double --with-sha >> red=0 --download-superlu_dist=1 --with-superlu_dist --with-parmetis- >> lib="[/cluster/work/phys/cmay/petsc/petsc-3.0.0-p3/external >> packages/ParMetis-3.1.1/libparmetis.a,/cluster/work/phys/cmay/petsc/ >> petsc-3.0.0-p3/externalpackages/ParMetis-3.1.1/libmetis.a]" >> --with-parmetis-include=/cluster/work/phys/cmay/petsc/petsc-3.0.0-p3/ >> externalpackages/ParMetis-3.1.1/ --with-x=0 --with-mpi-di >> r=/cluster/apps/openmpi/1.2.7/x86_64/intel/ --with-fc=0 --download-c- >> blas-lapack=yes >> [0]PETSC ERROR: >> ------------------------------------------------------------------------ >> [0]PETSC ERROR: MatGetSubMatrix() line 6519 in src/mat/interface/ >> matrix.c >> >> >> Thanks >> Christian >> >> >>> Yes, you will need petsc-dev. Note that we will release 3.1 in just >>> a few >>> weeks. >>> >>> Thanks, >>> >>> Matt >>> >>> On Sat, Jan 30, 2010 at 4:57 AM, Christian May >> wrote: >>> >>>> Hi everybody, >>>> >>>> I want to use the redistribute preconditioner to keep a matrix >> symmetric as >>>> explained in the FAQ. However, the source is not contained in my >> up-to-date >>>> installation of petsc-3.0.0-p10. Is this intended? >>>> Do I have to install the development version or how can I obtain >>>> this >>>> additional preconditioner? >>>> >>>> Thanks >>>> Christian >>>> >>>> >>> >>> >-------------- next part -------------- >A non-text attachment was scrubbed... >Name: redistribute.c >Type: application/octet-stream >Size: 14112 bytes >Desc: not available >URL: From vyan2000 at gmail.com Mon Feb 1 16:14:36 2010 From: vyan2000 at gmail.com (Ryan Yan) Date: Mon, 1 Feb 2010 17:14:36 -0500 Subject: [petsc-users] How to find a good initial guess for a BVP In-Reply-To: References: <878wblqgy6.fsf@59A2.org> Message-ID: Hi all, I just realized that I do need to work with the implicit form of the DAE. For instance, if I need to add a following tendency term "rho(x)*x' ": rho* x' = - f(t,x)) My question is: > In order to solve the above system by dmmg, is it suffice to multiply the line p380-384 in snes/examples/tutorials/ex27.c, namely, multiply a "rho(x)" term to each of the right hand side of the line p380-384? Or is there invisible barrier that I should beware of. Thank you very much, Yan On Tue, Jan 26, 2010 at 11:27 AM, Ryan Yan wrote: > Hi Jed, > Thank you very much for the suggestion and providing the reference and > examples. > > I have tried the grid sequencing, but with little luck on that. > > I will try the approach 1 for the explicit form of the conservation system. > > > Yan > > > > On Tue, Jan 26, 2010 at 5:49 AM, Jed Brown wrote: > >> On Mon, 25 Jan 2010 22:03:57 -0500, Ryan Yan wrote: >> > I am solving a nonlinear BVP(steady-states) extracted from a >> time-dependent >> > problem by setting d/dt=0. >> >> Globalization of steady-state problems is notoriously difficult, it's >> very likely that you will need to perform a continuation, of which there >> are at least two kinds to consider. >> >> 1. Pseudotransient continuation, I like this paper >> >> http://www.cs.odu.edu/~keyes/papers/ptc03.pdf >> >> which explains snes/examples/tutorials/ex27.c. >> >> This can be done with TSPSEUDO, but not currently for differential >> algebraic systems. If you would like it to work with DAEs, or ODEs >> written in implicit form (f(t,x,x')=0 instead of x' = f(t,x)), let me >> know and I'll add such support to PETSc-dev. >> >> 2. Grid sequencing: solve the problem on coarser grids to get an initial >> guess on the finer grids. If you use DMMG, this is -dmmg_grid_sequence. >> >> > So, do I have to solve the time-dependent problem after a long time >> stepping >> > to get a steady solution? Or is there any better way of finding a good >> > initial guess? >> >> Pseudotransient continuation is somewhat like this, but does it in a >> clever and adaptive way. >> >> Jed >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59a2.org Mon Feb 1 16:26:45 2010 From: jed at 59a2.org (Jed Brown) Date: Mon, 01 Feb 2010 23:26:45 +0100 Subject: [petsc-users] How to find a good initial guess for a BVP In-Reply-To: References: <878wblqgy6.fsf@59A2.org> Message-ID: <874om01tju.fsf@59A2.org> On Mon, 1 Feb 2010 17:14:36 -0500, Ryan Yan wrote: > Hi all, > I just realized that I do need to work with the implicit form of the DAE. > For instance, if I need to add a following tendency term "rho(x)*x' ": > > rho* x' = - f(t,x)) > > My question is: > > > In order to solve the above system by dmmg, is it suffice to multiply the > line p380-384 in snes/examples/tutorials/ex27.c, namely, multiply a "rho(x)" > term to each of the right hand side of the line p380-384? Or is there > invisible barrier that I should beware of. That looks right. If you are assembling a Jacobian, remember to differentiate this term with respect to BOTH x and x'. Jed From Z.Sheng at tudelft.nl Tue Feb 2 04:00:44 2010 From: Z.Sheng at tudelft.nl (Zhifeng Sheng - EWI) Date: Tue, 2 Feb 2010 11:00:44 +0100 Subject: [petsc-users] Compile Petsc in visual studio 2003 with /MD option References: <878wblqgy6.fsf@59A2.org> Message-ID: <947C04CD618D16429440FED56EAE47BA06B311@SRV564.tudelft.net> Dear all I followed the Petsc installation instructions under windows and it works fine. But I have a problem with the /MT option. This option is set for Petsc build and also for the blas-c-lapack. We could modify the compiling option of the petsc package but not for the blas-c-lapack. It seems that the option is hard wired into the "win32fe" tool. Does anyone know how I can change the option from /MT to /MD? Thanks and best regards Zhifeng -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.witkowski at tu-dresden.de Tue Feb 2 06:05:54 2010 From: thomas.witkowski at tu-dresden.de (Thomas Witkowski) Date: Tue, 02 Feb 2010 13:05:54 +0100 Subject: [petsc-users] Termination criteria for solving linear system Message-ID: <4B681522.7030706@tu-dresden.de> In my computations I use "bicg" preconditioned by "bjacobi" with an absolute tolerance of 1^e-8 as termination criteria. After PETSc has computed the solution, the code computes the residual. It is usually in the magnitude of 1^-13. I'm not really sure what happens here. Is it, because PETSc checks the preconditioned residual? If so, is there a way to tune the termination criteria to the true residual? I would like to save some computational time, since I do not need to solve the system with this high precision. Regards, Thomas From buerg at kit.edu Tue Feb 2 06:30:25 2010 From: buerg at kit.edu (=?ISO-8859-1?Q?Markus_B=FCrg?=) Date: Tue, 02 Feb 2010 13:30:25 +0100 Subject: [petsc-users] Termination criteria for solving linear system In-Reply-To: <4B681522.7030706@tu-dresden.de> References: <4B681522.7030706@tu-dresden.de> Message-ID: <4B681AE1.1080703@kit.edu> Hello Thomas, the precision of the solver does not correspond to the precision of the solution for your problem. If you do not want such a small residual in your problem, you have to reduce the number of degrees of freedom. Best Regards, Markus Am 02.02.10 13:05, schrieb Thomas Witkowski: > In my computations I use "bicg" preconditioned by "bjacobi" with an > absolute tolerance of 1^e-8 as termination criteria. After PETSc has > computed the solution, the code computes the residual. It is usually > in the magnitude of 1^-13. I'm not really sure what happens here. Is > it, because PETSc checks the preconditioned residual? If so, is there > a way to tune the termination criteria to the true residual? I would > like to save some computational time, since I do not need to solve the > system with this high precision. > > Regards, > > Thomas > From thomas.witkowski at tu-dresden.de Tue Feb 2 06:41:23 2010 From: thomas.witkowski at tu-dresden.de (Thomas Witkowski) Date: Tue, 02 Feb 2010 13:41:23 +0100 Subject: [petsc-users] Termination criteria for solving linear system In-Reply-To: <4B681AE1.1080703@kit.edu> References: <4B681522.7030706@tu-dresden.de> <4B681AE1.1080703@kit.edu> Message-ID: <4B681D73.5010702@tu-dresden.de> Hallo Markus, I just want to reduce the precision of the solution of the system of linear equations! To do this it is not required (and in my simulations also not possible) to reduce the number of degrees of freedom. It is a question of how to define the solver parameters to cancel the solution process at the right moment. Regards, Thomas Markus B?rg wrote: > Hello Thomas, > > the precision of the solver does not correspond to the precision of > the solution for your problem. If you do not want such a small > residual in your problem, you have to reduce the number of degrees of > freedom. > > Best Regards, > Markus > > > > Am 02.02.10 13:05, schrieb Thomas Witkowski: >> In my computations I use "bicg" preconditioned by "bjacobi" with an >> absolute tolerance of 1^e-8 as termination criteria. After PETSc has >> computed the solution, the code computes the residual. It is usually >> in the magnitude of 1^-13. I'm not really sure what happens here. Is >> it, because PETSc checks the preconditioned residual? If so, is there >> a way to tune the termination criteria to the true residual? I would >> like to save some computational time, since I do not need to solve >> the system with this high precision. >> >> Regards, >> >> Thomas >> > From jed at 59A2.org Tue Feb 2 06:55:22 2010 From: jed at 59A2.org (Jed Brown) Date: Tue, 02 Feb 2010 13:55:22 +0100 Subject: [petsc-users] Termination criteria for solving linear system In-Reply-To: <4B681D73.5010702@tu-dresden.de> References: <4B681522.7030706@tu-dresden.de> <4B681AE1.1080703@kit.edu> <4B681D73.5010702@tu-dresden.de> Message-ID: <87y6jbztj9.fsf@59A2.org> On Tue, 02 Feb 2010 13:41:23 +0100, Thomas Witkowski wrote: > Hallo Markus, > > I just want to reduce the precision of the solution of the system of > linear equations! To do this it is not required (and in my simulations > also not possible) to reduce the number of degrees of freedom. It is a > question of how to define the solver parameters to cancel the solution > process at the right moment. First, run with -ksp_monitor_true_residual This shows both preconditioned and unpreconditioned residuals. There are two commonly used tolerances, relative and absolute. If your problem is well-scaled, the relative tolerance is the one that is most likely to terminate the iteration. Run with -ksp_converged_reason to see why it converged. With this information, you can decide which tolerance to use (e.g. -ksp_rtol 1e-3 -ksp_atol 1e-6). Also, some KSPs support different norm types, you can set these with -ksp_norm_type. Jed From buerg at kit.edu Tue Feb 2 07:01:16 2010 From: buerg at kit.edu (=?ISO-8859-1?Q?Markus_B=FCrg?=) Date: Tue, 02 Feb 2010 14:01:16 +0100 Subject: [petsc-users] Termination criteria for solving linear system In-Reply-To: <4B681D73.5010702@tu-dresden.de> References: <4B681522.7030706@tu-dresden.de> <4B681AE1.1080703@kit.edu> <4B681D73.5010702@tu-dresden.de> Message-ID: <4B68221C.6000109@kit.edu> Hello Thomas, I do not think that you can say this a priori, because you cannot predict how much "gain" the iteration step will produce. You can try to reduce the solver precision further, but then it can happen that the precision of your solution explodes. Best Regards, Markus Am 02.02.10 13:41, schrieb Thomas Witkowski: > Hallo Markus, > > I just want to reduce the precision of the solution of the system of > linear equations! To do this it is not required (and in my simulations > also not possible) to reduce the number of degrees of freedom. It is a > question of how to define the solver parameters to cancel the solution > process at the right moment. > > Regards, > > Thomas > > Markus B?rg wrote: >> Hello Thomas, >> >> the precision of the solver does not correspond to the precision of >> the solution for your problem. If you do not want such a small >> residual in your problem, you have to reduce the number of degrees of >> freedom. >> >> Best Regards, >> Markus >> >> >> >> Am 02.02.10 13:05, schrieb Thomas Witkowski: >>> In my computations I use "bicg" preconditioned by "bjacobi" with an >>> absolute tolerance of 1^e-8 as termination criteria. After PETSc has >>> computed the solution, the code computes the residual. It is usually >>> in the magnitude of 1^-13. I'm not really sure what happens here. Is >>> it, because PETSc checks the preconditioned residual? If so, is >>> there a way to tune the termination criteria to the true residual? I >>> would like to save some computational time, since I do not need to >>> solve the system with this high precision. >>> >>> Regards, >>> >>> Thomas >>> >> > > From ilyasy at chalmers.se Tue Feb 2 09:18:59 2010 From: ilyasy at chalmers.se (ilyas yilmaz) Date: Tue, 2 Feb 2010 16:18:59 +0100 (CET) Subject: [petsc-users] changing DAs matrix and coefficients ordering Message-ID: <4407.129.16.197.202.1265123939.squirrel@webmail.chalmers.se> Hi, As far as I understand, DAs create matrix structure which is based on natural ordering of mesh, ie., (i,j) cell(0,0) --> 0th row of DA matrix cell(1,0) --> 1st row of DA matrix cell(2,0) --> 2nd row of DA matrix and so on and for coefficients : (i,j-1) (i-1,j) (i,j) (i+1,j) (i,j+1) My question is : ---------------- I need such a matrix stucture for my application that (i,j) cell(0,0) --> 0th row of DA matrix cell(0,1) --> 1st row of DA matrix cell(0,2) --> 2nd row of DA matrix and so on and for coefficients : (i-1,j) (i,j-1) (i,j) (i,j+1) (i+1,j) How can I tell this DAs? Note: To simplify and to stay away from processor ordering issue, I assume that I am running DAs code on 1 cpu. Thank you for providing PETSc library and for your help. Regards, Ilyas From balay at mcs.anl.gov Tue Feb 2 09:20:53 2010 From: balay at mcs.anl.gov (Satish Balay) Date: Tue, 2 Feb 2010 09:20:53 -0600 (CST) Subject: [petsc-users] Compile Petsc in visual studio 2003 with /MD option In-Reply-To: <947C04CD618D16429440FED56EAE47BA06B311@SRV564.tudelft.net> References: <878wblqgy6.fsf@59A2.org> <947C04CD618D16429440FED56EAE47BA06B311@SRV564.tudelft.net> Message-ID: Please do not cross post to multiple lists. If you have installation issues - send the relavent configure.log to petsc-maint at mcs.anl.gov You should be able to specify 'CFLAGS=-MT' option to configure and both PETSc and f2cblaslapack should use it. [assuimg you are using --with-mpi=0] Satish On Tue, 2 Feb 2010, Zhifeng Sheng - EWI wrote: > Dear all > > I followed the Petsc installation instructions under windows and it works fine. But I have a problem with the /MT option. This option is set for Petsc build and also for the blas-c-lapack. We could modify the compiling option of the petsc package but not for the blas-c-lapack. It seems that the option is hard wired into the "win32fe" tool. Does anyone know how I can change the option from /MT to /MD? > > > Thanks and best regards > Zhifeng > From balay at mcs.anl.gov Tue Feb 2 09:27:33 2010 From: balay at mcs.anl.gov (Satish Balay) Date: Tue, 2 Feb 2010 09:27:33 -0600 (CST) Subject: [petsc-users] Mesh class (fwd) Message-ID: ---------- Forwarded message ---------- Date: Tue, 2 Feb 2010 15:15:20 +0000 From: "Denner, Fabian" To: "petsc-users-bounces at mcs.anl.gov" Subject: Mesh class Hi everybody, are there any examples available, demonstrating the use of the mesh class for an unstructured mesh? Best regards, Fabian From knepley at gmail.com Tue Feb 2 09:29:06 2010 From: knepley at gmail.com (Matthew Knepley) Date: Tue, 2 Feb 2010 09:29:06 -0600 Subject: [petsc-users] changing DAs matrix and coefficients ordering In-Reply-To: <4407.129.16.197.202.1265123939.squirrel@webmail.chalmers.se> References: <4407.129.16.197.202.1265123939.squirrel@webmail.chalmers.se> Message-ID: Not sure what you are asking. Why not just think of the grid as being transposed? Something has to be numbered first. If you had a more sophisticated change, I would recommend using an AO to renumber the matrix. This is what happens when you go from PETSc ordering to Natural ordering. Matt On Tue, Feb 2, 2010 at 9:18 AM, ilyas yilmaz wrote: > > Hi, > > As far as I understand, DAs create matrix structure which is based on > natural ordering of mesh, ie., > > (i,j) > cell(0,0) --> 0th row of DA matrix > cell(1,0) --> 1st row of DA matrix > cell(2,0) --> 2nd row of DA matrix and so on > > and for coefficients : (i,j-1) (i-1,j) (i,j) (i+1,j) (i,j+1) > > My question is : > ---------------- > I need such a matrix stucture for my application that > > (i,j) > cell(0,0) --> 0th row of DA matrix > cell(0,1) --> 1st row of DA matrix > cell(0,2) --> 2nd row of DA matrix and so on > > and for coefficients : (i-1,j) (i,j-1) (i,j) (i,j+1) (i+1,j) > > How can I tell this DAs? > > Note: > To simplify and to stay away from processor ordering issue, > I assume that I am running DAs code on 1 cpu. > > > Thank you for providing PETSc library and for your help. > > Regards, > Ilyas > > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From u.tabak at tudelft.nl Tue Feb 2 09:39:03 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Tue, 02 Feb 2010 16:39:03 +0100 Subject: [petsc-users] Mesh class (fwd) In-Reply-To: References: Message-ID: <4B684717.2050103@tudelft.nl> Satish Balay wrote: > > ---------- Forwarded message ---------- > Date: Tue, 2 Feb 2010 15:15:20 +0000 > From: "Denner, Fabian" > To: "petsc-users-bounces at mcs.anl.gov" > Subject: Mesh class > > Hi everybody, > > are there any examples available, demonstrating the use of the mesh class for an unstructured mesh? > > Hi, There was an example of a mesh class in Barton&Nackman, Scientific C++, I am not sure if that helps or not but they were using that on an unstructured grid in the book(a very simple example), when I checked that some time ago in the library. HTH, Umut From jed at 59A2.org Tue Feb 2 09:49:32 2010 From: jed at 59A2.org (Jed Brown) Date: Tue, 02 Feb 2010 16:49:32 +0100 Subject: [petsc-users] changing DAs matrix and coefficients ordering In-Reply-To: <4407.129.16.197.202.1265123939.squirrel@webmail.chalmers.se> References: <4407.129.16.197.202.1265123939.squirrel@webmail.chalmers.se> Message-ID: <87bpg7wsc3.fsf@59A2.org> On Tue, 2 Feb 2010 16:18:59 +0100 (CET), "ilyas yilmaz" wrote: > How can I tell this DAs? You can do this by just transposing the meanings of X,Y,Z in the DA creation and info routines. I do this frequently for problems where the "Z" direction has physical significance in that it represents tighter coupling than other spatial directions (therefore it should correspond to PETSc's "X" direction). For all but the most trivial cases, it's worth creating a couple wrappers so that your code can use the meanings consistently. Jed From balay at mcs.anl.gov Tue Feb 2 09:51:09 2010 From: balay at mcs.anl.gov (Satish Balay) Date: Tue, 2 Feb 2010 09:51:09 -0600 (CST) Subject: [petsc-users] Compile Petsc in visual studio 2003 with /MD option In-Reply-To: References: <878wblqgy6.fsf@59A2.org> <947C04CD618D16429440FED56EAE47BA06B311@SRV564.tudelft.net> Message-ID: I just did a build petsc petsc-3.0.0 with VC6 with: ./configure --with-mpi=0 --download-c-blas-lapack=1 CFLAGS=-MT --with-fc=0 PETSC_ARCH=cygwin-ms-mt and the build went fine. If you are having issues - you might want to delete PETSC_DIR/PETSC_ARCH and restart. [and if you still have issues - send configure.log, make.log & test.log from PETSC_DIR/PETSC_ARCH/conf to petsc-maint] Satish On Tue, 2 Feb 2010, Satish Balay wrote: > Please do not cross post to multiple lists. > > If you have installation issues - send the relavent configure.log to > petsc-maint at mcs.anl.gov > > You should be able to specify 'CFLAGS=-MT' option to configure and > both PETSc and f2cblaslapack should use it. [assuimg you are using > --with-mpi=0] > > Satish > > On Tue, 2 Feb 2010, Zhifeng Sheng - EWI wrote: > > > Dear all > > > > I followed the Petsc installation instructions under windows and it works fine. But I have a problem with the /MT option. This option is set for Petsc build and also for the blas-c-lapack. We could modify the compiling option of the petsc package but not for the blas-c-lapack. It seems that the option is hard wired into the "win32fe" tool. Does anyone know how I can change the option from /MT to /MD? > > > > > > Thanks and best regards > > Zhifeng > > > > From u.tabak at tudelft.nl Tue Feb 2 10:23:43 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Tue, 02 Feb 2010 17:23:43 +0100 Subject: [petsc-users] successive linear solves Message-ID: <4B68518F.10304@tudelft.nl> Dear all, I was trying to solve two linear systems in the same ksp context while setting the operators with KSPSetOperators. But I am getting a Memory corruption error. What I try to do is to set two linear operators and rhs vectors and get the solutions, say for solA, xa, (Ka-lambs*Ma)*xa = -lambs*KsaT*modeS (I extract lambs from a vector of eigenvalues and modeS from a matrix of eigenvectors) and for solS, xs (Ks-lamba*Ms)*xs = -Ksa*modeP (similarly lamba is extracted from a vector and the modeP also from a matrix of vectors as columns) I am using MatDuplicate functions to update the operator matrices at each iteration, there is not a problem in the first solve, at least no errors, but on the second one I am getting the Memory corruption error mentioned above. Also one more question is on where to use KSPSetFromOptions on the iterations. If I use KSPSetFromOptions on the same iteration twice(before solve)I get the same error from this function(this was not also reasonable to me). Section of the code is below(a bit crappy however should give the idea on what I tried to do). I am sure this is a simple problem but could not find the reason. KSP ksp; KSPCreate(PETSC_COMM_WORLD, &ksp); for(int j=0; j!=nR; j++) { //KSPCreate(PETSC_COMM_WORLD, &kspA); // duplicate the matrix MatDuplicate(Ka, MAT_COPY_VALUES, &OpA); // MatAXPY(OpA, -eSolverS.getRoot(j), Ma, SAME_NONZERO_PATTERN); MatGetColumnVector(eigVecsStr, modeS, j); // create the rhs for the operation MatMult(KsaT, modeS, rhsA); VecScale(rhsA, -eSolverS.getRoot(j)); cout << "Solving the linear system for pressure side corrections" << endl; KSPSetOperators(ksp, OpA, OpA, DIFFERENT_NONZERO_PATTERN); //KSPGetPC(kspA, &pcA); //PCSetType(pcA, PCJACOBI); //KSPSetTolerances(ksp, 1e-7, PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT); //KSPSetFromOptions(kspA); // solve KSPSolve(ksp,rhsA,solA); corA.assignSubVector(solA, 1, ra, j); // MatDuplicate(Ks, MAT_COPY_VALUES, &OpS); MatAXPY(OpS, -eSolverA.getRoot(j), Ms, SAME_NONZERO_PATTERN); MatGetColumnVector(eigVecsAco, modeA, j); // create the rhs for the operation MatMult(Ksa, modeA, rhsS); VecScale(rhsS, -1.0); cout << "Solving the linear system for structure side corrections" << endl; //KSPCreate(PETSC_COMM_WORLD, &kspS); KSPSetOperators(ksp, OpS, OpS, DIFFERENT_NONZERO_PATTERN); //KSPGetPC(kspS, &pcS); //PCSetType(pcS, PCJACOBI); //KSPSetTolerances(kspS, 1e-7, PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT); //KSPSetFromOptions(kspS); // solve KSPSolve(ksp,rhsS,solS); //int r,m; //VecGetSize(rhsS, &r); //VecGetSize(solS, &m); //cout << r << " " << m << endl; corS.assignSubVector(solS, 1, rs, j); cout << "Solved the linear system for structure corrections" << endl; } corA.finalize(); corS.finalize(); Best, Umut From Z.Sheng at tudelft.nl Tue Feb 2 10:27:16 2010 From: Z.Sheng at tudelft.nl (Zhifeng Sheng - EWI) Date: Tue, 2 Feb 2010 17:27:16 +0100 Subject: [petsc-users] Compile Petsc in visual studio 2003 with /MD option References: <878wblqgy6.fsf@59A2.org><947C04CD618D16429440FED56EAE47BA06B311@SRV564.tudelft.net> Message-ID: <947C04CD618D16429440FED56EAE47BA06B312@SRV564.tudelft.net> Thanks, this works. Best regards Zhifeng -----Original Message----- From: petsc-users-bounces at mcs.anl.gov on behalf of Satish Balay Sent: Tue 2-2-2010 16:51 To: PETSc users list Subject: Re: [petsc-users] Compile Petsc in visual studio 2003 with /MD option I just did a build petsc petsc-3.0.0 with VC6 with: ./configure --with-mpi=0 --download-c-blas-lapack=1 CFLAGS=-MT --with-fc=0 PETSC_ARCH=cygwin-ms-mt and the build went fine. If you are having issues - you might want to delete PETSC_DIR/PETSC_ARCH and restart. [and if you still have issues - send configure.log, make.log & test.log from PETSC_DIR/PETSC_ARCH/conf to petsc-maint] Satish On Tue, 2 Feb 2010, Satish Balay wrote: > Please do not cross post to multiple lists. > > If you have installation issues - send the relavent configure.log to > petsc-maint at mcs.anl.gov > > You should be able to specify 'CFLAGS=-MT' option to configure and > both PETSc and f2cblaslapack should use it. [assuimg you are using > --with-mpi=0] > > Satish > > On Tue, 2 Feb 2010, Zhifeng Sheng - EWI wrote: > > > Dear all > > > > I followed the Petsc installation instructions under windows and it works fine. But I have a problem with the /MT option. This option is set for Petsc build and also for the blas-c-lapack. We could modify the compiling option of the petsc package but not for the blas-c-lapack. It seems that the option is hard wired into the "win32fe" tool. Does anyone know how I can change the option from /MT to /MD? > > > > > > Thanks and best regards > > Zhifeng > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From knepley at gmail.com Tue Feb 2 10:31:00 2010 From: knepley at gmail.com (Matthew Knepley) Date: Tue, 2 Feb 2010 10:31:00 -0600 Subject: [petsc-users] successive linear solves In-Reply-To: <4B68518F.10304@tudelft.nl> References: <4B68518F.10304@tudelft.nl> Message-ID: On Tue, Feb 2, 2010 at 10:23 AM, Umut Tabak wrote: > Dear all, > > I was trying to solve two linear systems in the same ksp context while > setting the operators with KSPSetOperators. But I am getting a Memory > corruption error. What I try to do is to set two linear operators and rhs > vectors and get the solutions, say > > for solA, xa, > > (Ka-lambs*Ma)*xa = -lambs*KsaT*modeS (I extract lambs from a vector of > eigenvalues and modeS from a matrix of eigenvectors) > > and for solS, xs > > (Ks-lamba*Ms)*xs = -Ksa*modeP (similarly lamba is extracted from a vector > and the modeP also from a matrix of vectors as columns) > > I am using MatDuplicate functions to update the operator matrices at each > iteration, there is not a problem in the first solve, at least no errors, > but on the second one I am getting the Memory corruption error mentioned > above. Also one more question is on where to use KSPSetFromOptions on the > iterations. If I use KSPSetFromOptions on the same iteration twice(before > solve)I get the same error from this function(this was not also reasonable > to me). Section of the code is below(a bit crappy however should give the > idea on what I tried to do). I am sure this is a simple problem but could > not find the reason. > 0) ALWAYS send the entire error message 1) ALWAYS check all the return values from the PETSc functions 2) When you get memory corruption, run with valgrind (as it says in the error message) 3) Solving twice does not produce problems. Matt > KSP ksp; > KSPCreate(PETSC_COMM_WORLD, &ksp); > for(int j=0; j!=nR; j++) > { > //KSPCreate(PETSC_COMM_WORLD, &kspA); > // duplicate the matrix > MatDuplicate(Ka, MAT_COPY_VALUES, &OpA); > // > MatAXPY(OpA, -eSolverS.getRoot(j), Ma, SAME_NONZERO_PATTERN); > MatGetColumnVector(eigVecsStr, modeS, j); > // create the rhs for the operation > MatMult(KsaT, modeS, rhsA); > VecScale(rhsA, -eSolverS.getRoot(j)); > cout << "Solving the linear system for pressure side corrections" << > endl; > KSPSetOperators(ksp, OpA, OpA, DIFFERENT_NONZERO_PATTERN); > //KSPGetPC(kspA, &pcA); > //PCSetType(pcA, PCJACOBI); > //KSPSetTolerances(ksp, 1e-7, > PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT); > //KSPSetFromOptions(kspA); > // solve > KSPSolve(ksp,rhsA,solA); > corA.assignSubVector(solA, 1, ra, j); > // > MatDuplicate(Ks, MAT_COPY_VALUES, &OpS); > MatAXPY(OpS, -eSolverA.getRoot(j), Ms, SAME_NONZERO_PATTERN); > MatGetColumnVector(eigVecsAco, modeA, j); > // create the rhs for the operation > MatMult(Ksa, modeA, rhsS); > VecScale(rhsS, -1.0); > cout << "Solving the linear system for structure side corrections" << > endl; > //KSPCreate(PETSC_COMM_WORLD, &kspS); > KSPSetOperators(ksp, OpS, OpS, DIFFERENT_NONZERO_PATTERN); > //KSPGetPC(kspS, &pcS); > //PCSetType(pcS, PCJACOBI); > //KSPSetTolerances(kspS, 1e-7, > PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT); > //KSPSetFromOptions(kspS); > // solve > KSPSolve(ksp,rhsS,solS); > //int r,m; > //VecGetSize(rhsS, &r); > //VecGetSize(solS, &m); > //cout << r << " " << m << endl; > corS.assignSubVector(solS, 1, rs, j); > cout << "Solved the linear system for structure corrections" << endl; > } > corA.finalize(); corS.finalize(); > > Best, > Umut > > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilyasy at chalmers.se Tue Feb 2 10:36:34 2010 From: ilyasy at chalmers.se (ilyas yilmaz) Date: Tue, 2 Feb 2010 17:36:34 +0100 (CET) Subject: [petsc-users] changing DAs matrix and coefficients ordering In-Reply-To: <87bpg7wsc3.fsf@59A2.org> References: <4407.129.16.197.202.1265123939.squirrel@webmail.chalmers.se> <87bpg7wsc3.fsf@59A2.org> Message-ID: <4872.129.16.197.202.1265128594.squirrel@webmail.chalmers.se> Hi, Thank you Jed and Matthew for answering me. > On Tue, 2 Feb 2010 16:18:59 +0100 (CET), "ilyas yilmaz" > wrote: >> How can I tell this DAs? > > You can do this by just transposing the meanings of X,Y,Z in the DA > creation and info routines. I have actually tried it before, but I failed. I guess I am missing something. Could you please explain me how to do this on a simple DAs example? Thank you. > I do this frequently for problems where the "Z" direction has physical > significance in that it represents tighter coupling than other spatial > directions (therefore it should correspond to PETSc's "X" direction). > > For all but the most trivial cases, it's worth creating a couple > wrappers so that your code can use the meanings consistently. > > Jed > Regards, Ilyas. From jed at 59A2.org Tue Feb 2 11:10:50 2010 From: jed at 59A2.org (Jed Brown) Date: Tue, 02 Feb 2010 18:10:50 +0100 Subject: [petsc-users] changing DAs matrix and coefficients ordering In-Reply-To: <4872.129.16.197.202.1265128594.squirrel@webmail.chalmers.se> References: <4407.129.16.197.202.1265123939.squirrel@webmail.chalmers.se> <87bpg7wsc3.fsf@59A2.org> <4872.129.16.197.202.1265128594.squirrel@webmail.chalmers.se> Message-ID: <877hqvwokl.fsf@59A2.org> On Tue, 2 Feb 2010 17:36:34 +0100 (CET), "ilyas yilmaz" wrote: > I have actually tried it before, but I failed. I guess I am missing > something. Could you please explain me how to do this on a simple DAs > example? Suppose you have an M by N region that you want to index as x[i][j] with i in [0..M) and j in [0..N). DACreate2d(comm,DA_NOPERIODIC,DA_STENCIL_BOX,N,M,n,m,dof,s,ly,lx,&da); then something like PetscErrorCode FormFunction(DA da,Vec X,Vec F,void *ctx) { Node **x,**f; PetscInt i,j,xs,ys,xm,ym,mx,my; ... DAGetInfo(da,0, &my,&mx,0, 0,0,0, 0,0,0,0); hx = Lx / mx; hy = Ly / my; DAGetCorners(da,&ys,&xs,0,&ym,&xm,0); DAVecGetArray(da,X,&x); DAVecGetArray(da,F,&f); for (i=xs; i References: <4B681522.7030706@tu-dresden.de> <4B681AE1.1080703@kit.edu> <4B681D73.5010702@tu-dresden.de> <87y6jbztj9.fsf@59A2.org> Message-ID: <1EDE12F9-1060-4D44-825F-7DAA46243659@mcs.anl.gov> On Feb 2, 2010, at 6:55 AM, Jed Brown wrote: > On Tue, 02 Feb 2010 13:41:23 +0100, Thomas Witkowski > wrote: >> Hallo Markus, >> >> I just want to reduce the precision of the solution of the system of >> linear equations! To do this it is not required (and in my >> simulations >> also not possible) to reduce the number of degrees of freedom. It >> is a >> question of how to define the solver parameters to cancel the >> solution >> process at the right moment. > > First, run with -ksp_monitor_true_residual > > This shows both preconditioned and unpreconditioned residuals. There > are two commonly used tolerances, relative and absolute. If your > problem is well-scaled, the relative tolerance is the one that is most > likely to terminate the iteration. Run with -ksp_converged_reason to > see why it converged. With this information, you can decide which > tolerance to use (e.g. -ksp_rtol 1e-3 -ksp_atol 1e-6). Also, some > KSPs > support different norm types, you can set these with -ksp_norm_type. Specifically for the BiCG in PETSc you can use -ksp_norm_type unpreconditioned and it will use the unpreconditioned residual norm for the convergence test. Barry > Jed From u.tabak at tudelft.nl Tue Feb 2 17:00:56 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Wed, 03 Feb 2010 00:00:56 +0100 Subject: [petsc-users] error check in C++ constructor Message-ID: <4B68AEA8.80603@tudelft.nl> Dear all, I was looking at some code C++ constructor code where some PETSc Vec's are created in the constructor, the problem/question is that constructor does not have a return type and CHKERRQ is a replacement for a macro code which returns a value, that is the error code. I guess, the safest bet to check for errors in a constructor is to compare the return value from PETSc functions with 0 and issue an error message from the constructor, is this reasoning right? Best regards, Umut From knepley at gmail.com Tue Feb 2 17:08:11 2010 From: knepley at gmail.com (Matthew Knepley) Date: Tue, 2 Feb 2010 17:08:11 -0600 Subject: [petsc-users] error check in C++ constructor In-Reply-To: <4B68AEA8.80603@tudelft.nl> References: <4B68AEA8.80603@tudelft.nl> Message-ID: You can use CHKERRXX(). Matt On Tue, Feb 2, 2010 at 5:00 PM, Umut Tabak wrote: > Dear all, > > I was looking at some code C++ constructor code where some PETSc Vec's are > created in the constructor, the problem/question is that constructor does > not have a return type and CHKERRQ is a replacement for a macro code which > returns a value, that is the error code. > > I guess, the safest bet to check for errors in a constructor is to compare > the return value from PETSc functions with 0 and issue an error message from > the constructor, is this reasoning right? > > Best regards, > Umut > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From u.tabak at tudelft.nl Tue Feb 2 17:13:48 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Wed, 03 Feb 2010 00:13:48 +0100 Subject: [petsc-users] error check in C++ constructor In-Reply-To: References: <4B68AEA8.80603@tudelft.nl> Message-ID: <4B68B1AC.4050501@tudelft.nl> Matthew Knepley wrote: > You can use CHKERRXX(). > Thanks, it solved the problem, just curious, is this documented? I checked the PETSc System routines page but only CHKERRQ is there. Umut From thomas.witkowski at tu-dresden.de Wed Feb 3 06:01:49 2010 From: thomas.witkowski at tu-dresden.de (Thomas Witkowski) Date: Wed, 03 Feb 2010 13:01:49 +0100 Subject: [petsc-users] Termination criteria for solving linear system In-Reply-To: <1EDE12F9-1060-4D44-825F-7DAA46243659@mcs.anl.gov> References: <4B681522.7030706@tu-dresden.de> <4B681AE1.1080703@kit.edu> <4B681D73.5010702@tu-dresden.de> <87y6jbztj9.fsf@59A2.org> <1EDE12F9-1060-4D44-825F-7DAA46243659@mcs.anl.gov> Message-ID: <4B6965AD.1000608@tu-dresden.de> Barry Smith wrote: > > On Feb 2, 2010, at 6:55 AM, Jed Brown wrote: > >> On Tue, 02 Feb 2010 13:41:23 +0100, Thomas Witkowski >> wrote: >>> Hallo Markus, >>> >>> I just want to reduce the precision of the solution of the system of >>> linear equations! To do this it is not required (and in my simulations >>> also not possible) to reduce the number of degrees of freedom. It is a >>> question of how to define the solver parameters to cancel the solution >>> process at the right moment. >> >> First, run with -ksp_monitor_true_residual >> >> This shows both preconditioned and unpreconditioned residuals. There >> are two commonly used tolerances, relative and absolute. If your >> problem is well-scaled, the relative tolerance is the one that is most >> likely to terminate the iteration. Run with -ksp_converged_reason to >> see why it converged. With this information, you can decide which >> tolerance to use (e.g. -ksp_rtol 1e-3 -ksp_atol 1e-6). Also, some KSPs >> support different norm types, you can set these with -ksp_norm_type. > > Specifically for the BiCG in PETSc you can use -ksp_norm_type > unpreconditioned and it will use the unpreconditioned residual norm > for the convergence test. Thanks, thats exactly what I've searched for! Thomas > > Barry > >> Jed > > > From vyan2000 at gmail.com Wed Feb 3 22:58:59 2010 From: vyan2000 at gmail.com (Ryan Yan) Date: Wed, 3 Feb 2010 23:58:59 -0500 Subject: [petsc-users] A Question about Vec Message-ID: Hi all, Can someone help me to understand the "Vec"? My question is: in the following piece of code, will "a" be changed, if "b" is changed by the subroutine "SNESComputeFunction"? I did see that both a and b are both pointers to an object. Vec a = b; Vec c; initalize c; SNESComputeFunction(snes, c, b); If the answer is yes, then I guess what is modified is actually "*b" in the above code, is that right? BTW, I am wondering is there any explicit way that one can compare two variables in the instance above in PETSc , especially when the content of the object is rich. Thanks you very much, Yan -------------- next part -------------- An HTML attachment was scrubbed... URL: From balay at mcs.anl.gov Wed Feb 3 23:24:11 2010 From: balay at mcs.anl.gov (Satish Balay) Date: Wed, 3 Feb 2010 23:24:11 -0600 (CST) Subject: [petsc-users] A Question about Vec In-Reply-To: References: Message-ID: On Wed, 3 Feb 2010, Ryan Yan wrote: > Hi all, > Can someone help me to understand the "Vec"? > > My question is: in the following piece of code, will "a" be changed, if "b" > is changed by the subroutine "SNESComputeFunction"? I did see that both a > and b are both pointers to an object. Yes - all petsc datatypes [Vec,Mat etc..] are pointers to [opaque] objects. > > Vec a = b; So you can make copy of this pointer - and use it aswell. > Vec c; > > initalize c; > SNESComputeFunction(snes, c, b); > > If the answer is yes, then I guess what is modified is actually "*b" in the > above code, is that right? yes - the object [refered by this pointer] is modified. > BTW, I am wondering is there any explicit way that one can compare two > variables in the instance above in PETSc , especially when the content of > the object is rich. In the above case - if you are carrying multiple copies of pointers arround - you just check the pointers. [ a == b] The alternative is having multiple objects. Vec a, b VecDuplicate(a,&b) VecCopy(a,b) VecEqual(a,b,flag) Here 'a','b' are different vecs - so if a is modified - it has no relation to values of 'b' Satish From vyan2000 at gmail.com Thu Feb 4 09:10:36 2010 From: vyan2000 at gmail.com (Ryan Yan) Date: Thu, 4 Feb 2010 10:10:36 -0500 Subject: [petsc-users] A Question about Vec In-Reply-To: References: Message-ID: Hi Satish, Thank you very much for the crystal clear explanation. Yan On Thu, Feb 4, 2010 at 12:24 AM, Satish Balay wrote: > On Wed, 3 Feb 2010, Ryan Yan wrote: > > > Hi all, > > Can someone help me to understand the "Vec"? > > > > My question is: in the following piece of code, will "a" be changed, if > "b" > > is changed by the subroutine "SNESComputeFunction"? I did see that both a > > and b are both pointers to an object. > > Yes - all petsc datatypes [Vec,Mat etc..] are pointers to [opaque] objects. > > > > > Vec a = b; > > So you can make copy of this pointer - and use it aswell. > > > Vec c; > > > > initalize c; > > SNESComputeFunction(snes, c, b); > > > > If the answer is yes, then I guess what is modified is actually "*b" in > the > > above code, is that right? > > yes - the object [refered by this pointer] is modified. > > > BTW, I am wondering is there any explicit way that one can compare two > > variables in the instance above in PETSc , especially when the content of > > the object is rich. > > In the above case - if you are carrying multiple copies of pointers > arround - you just check the pointers. [ a == b] > > The alternative is having multiple objects. > > Vec a, b > > > > > VecDuplicate(a,&b) > VecCopy(a,b) > VecEqual(a,b,flag) > > Here 'a','b' are different vecs - so if a is modified - it has no relation > to values of 'b' > > Satish > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59A2.org Thu Feb 4 09:31:03 2010 From: jed at 59A2.org (Jed Brown) Date: Thu, 04 Feb 2010 16:31:03 +0100 Subject: [petsc-users] Open-MX: a low-latency alternative to IP over 1 and 10 Gigabit Ethernet Message-ID: <87d40lhvbc.fsf@59A2.org> This may be interesting to those solving with relatively small subdomains on ethernet clusters. Open-MX is an open source implementation of the Myrinet Express (MX) protocol which operates over generic ethernet hardware. It is a driver for Linux (>= 2.6.15) and does not interfere with IP traffic. It works with the native MX backend of several MPI implementations including Open MPI and MPICH2. The big feature for PETSc users is that compared to TCP/IP, it offers 30% lower latency over GigE and half the latency with 25-30% higher bandwidth over 10 GigE. This could make a big difference for those observing poor scalability on ethernet clusters. In particular, if -log_summary shows a lot of time in events like VecDot, VecNorm, and VecScatterEnd. More info here: http://open-mx.org Jed From ilyasy at chalmers.se Thu Feb 4 13:38:43 2010 From: ilyasy at chalmers.se (ilyas yilmaz) Date: Thu, 4 Feb 2010 20:38:43 +0100 (CET) Subject: [petsc-users] changing DAs matrix and coefficients ordering In-Reply-To: <877hqvwokl.fsf@59A2.org> References: <4407.129.16.197.202.1265123939.squirrel@webmail.chalmers.se> <87bpg7wsc3.fsf@59A2.org> <4872.129.16.197.202.1265128594.squirrel@webmail.chalmers.se> <877hqvwokl.fsf@59A2.org> Message-ID: <1197.193.11.222.28.1265312323.squirrel@webmail.chalmers.se> Thank you Jed, Now, it is working. Ilyas. > On Tue, 2 Feb 2010 17:36:34 +0100 (CET), "ilyas yilmaz" > wrote: >> I have actually tried it before, but I failed. I guess I am missing >> something. Could you please explain me how to do this on a simple DAs >> example? > > Suppose you have an M by N region that you want to index as x[i][j] with > i in [0..M) and j in [0..N). > > DACreate2d(comm,DA_NOPERIODIC,DA_STENCIL_BOX,N,M,n,m,dof,s,ly,lx,&da); > > then something like > > PetscErrorCode FormFunction(DA da,Vec X,Vec F,void *ctx) { > Node **x,**f; > PetscInt i,j,xs,ys,xm,ym,mx,my; > ... > DAGetInfo(da,0, &my,&mx,0, 0,0,0, 0,0,0,0); > hx = Lx / mx; > hy = Ly / my; > DAGetCorners(da,&ys,&xs,0,&ym,&xm,0); > DAVecGetArray(da,X,&x); > DAVecGetArray(da,F,&f); > for (i=xs; i for (j=ys; j f[i][j].u = -x[i-1][j].u -x[i][j-1].u + 4*x[i][j].u - x[i][j+1].u > - x[i+1][j].u; > ... > > > If you're still confused and want a working example, PETSc-dev has > > http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/src/snes/examples/tutorials/ex48.c.html > > but it is overly complex to demonstrate this point since it manages both > a 2D and 3D DA with compatible layouts. > > Jed > From av.nova at gmail.com Fri Feb 5 17:03:02 2010 From: av.nova at gmail.com (NovA) Date: Sat, 6 Feb 2010 02:03:02 +0300 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ Message-ID: Hi everybody! I'm looking for the best way to distribute MPIBAIJ matrix among several processors. For example, I have square matrix 3x3 of blocks 4x4 each (i.e. 12x12 values) and need to distribute it among 2 processors. The generic way of creating such a matrix would be: Mat A; MatCreate(comm, &A); MatSetSizes(A, loc_rows,12, 12,12); MatSetType(A, MATMPIBAIJ); What is the optimal value for loc_rows here? Can I use PETSC_DECIDE for it? I suppose this will lead to division by 6 rows per processor, which is not consistent with block size. How MatMPIBAIJSetPreallocation(A,4,...) will deal with it? Most likely, I have to manually set loc_rows to 8 and 4 according to the processor rank. But probably I miss some more clean way, when PETSc really decides. :) Thanks in advance for any comments. Regards! Andrey From knepley at gmail.com Fri Feb 5 17:07:16 2010 From: knepley at gmail.com (Matthew Knepley) Date: Fri, 5 Feb 2010 17:07:16 -0600 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: References: Message-ID: 1) It will distribute block rows, so you will get 8 and 4 as you want 2) Warning: This is an incredibly small problem. Using 2 processors might not show any speedup at all. Matt On Fri, Feb 5, 2010 at 5:03 PM, NovA wrote: > Hi everybody! > > I'm looking for the best way to distribute MPIBAIJ matrix among > several processors. > > For example, I have square matrix 3x3 of blocks 4x4 each (i.e. 12x12 > values) and need to distribute it among 2 processors. The generic way > of creating such a matrix would be: > Mat A; > MatCreate(comm, &A); > MatSetSizes(A, loc_rows,12, 12,12); > MatSetType(A, MATMPIBAIJ); > > What is the optimal value for loc_rows here? > > Can I use PETSC_DECIDE for it? I suppose this will lead to division by > 6 rows per processor, which is not consistent with block size. How > MatMPIBAIJSetPreallocation(A,4,...) will deal with it? > > Most likely, I have to manually set loc_rows to 8 and 4 according to > the processor rank. But probably I miss some more clean way, when > PETSc really decides. :) > > Thanks in advance for any comments. > > Regards! > Andrey > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From av.nova at gmail.com Fri Feb 5 17:28:05 2010 From: av.nova at gmail.com (NovA) Date: Sat, 6 Feb 2010 02:28:05 +0300 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: References: Message-ID: Thanks for the quick response! 2010/2/6 Matthew Knepley : > 1) It will distribute block rows, so you will get 8 and 4 as you want How can it distribute in such a way, if it doesn't know block size yet? Let's continue the example: MatCreate(comm, &A); MatSetSizes(A, PETSC_DECIDE,12, 12,12); MatSetType(A, MATMPIBAIJ); MatGetOwnershipRange(A, &rowS, &rowE); Then loop local rows from rowS/4 to rowE/4 to preallocate storage using MatMPIBAIJSetPreallocation(A,4,...) What will be the rowS and rowE here? I think they can be not divisible by 4 (block size)... > > 2) Warning: This is an incredibly small problem. Using 2 processors > ??? might not show any speedup at all. Sure! It's just an example. I suppose it'll be much slower on two processors actually. Regards! Andrey > > ? Matt > > On Fri, Feb 5, 2010 at 5:03 PM, NovA wrote: >> >> Hi everybody! >> >> I'm looking for the best way to distribute MPIBAIJ matrix among >> several processors. >> >> For example, I have square matrix 3x3 of blocks 4x4 each (i.e. 12x12 >> values) and need to distribute it among 2 processors. The generic way >> of creating such a matrix would be: >> ?Mat A; >> ?MatCreate(comm, &A); >> ?MatSetSizes(A, loc_rows,12, 12,12); >> ?MatSetType(A, MATMPIBAIJ); >> >> What is the optimal value for loc_rows here? >> >> Can I use PETSC_DECIDE for it? I suppose this will lead to division by >> 6 rows per processor, which is not consistent with block size. How >> MatMPIBAIJSetPreallocation(A,4,...) will deal with it? >> >> Most likely, I have to manually set loc_rows to 8 and 4 according to >> the processor rank. But probably I miss some more clean way, when >> PETSc really decides. :) >> >> Thanks in advance for any comments. >> >> Regards! >> ?Andrey > > > > -- > 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 > From knepley at gmail.com Fri Feb 5 17:32:04 2010 From: knepley at gmail.com (Matthew Knepley) Date: Fri, 5 Feb 2010 17:32:04 -0600 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: References: Message-ID: On Fri, Feb 5, 2010 at 5:28 PM, NovA wrote: > Thanks for the quick response! > > 2010/2/6 Matthew Knepley : > > 1) It will distribute block rows, so you will get 8 and 4 as you want > > How can it distribute in such a way, if it doesn't know block size yet? > Let's continue the example: > MatCreate(comm, &A); > MatSetSizes(A, PETSC_DECIDE,12, 12,12); > MatSetType(A, MATMPIBAIJ); > MatGetOwnershipRange(A, &rowS, &rowE); > Then loop local rows from rowS/4 to rowE/4 to preallocate storage > using MatMPIBAIJSetPreallocation(A,4,...) > > What will be the rowS and rowE here? I think they can be not divisible > by 4 (block size)... > You have to set the block size. Matt > > > > 2) Warning: This is an incredibly small problem. Using 2 processors > > might not show any speedup at all. > Sure! It's just an example. I suppose it'll be much slower on two > processors actually. > > > Regards! > Andrey > > > > > Matt > > > > On Fri, Feb 5, 2010 at 5:03 PM, NovA wrote: > >> > >> Hi everybody! > >> > >> I'm looking for the best way to distribute MPIBAIJ matrix among > >> several processors. > >> > >> For example, I have square matrix 3x3 of blocks 4x4 each (i.e. 12x12 > >> values) and need to distribute it among 2 processors. The generic way > >> of creating such a matrix would be: > >> Mat A; > >> MatCreate(comm, &A); > >> MatSetSizes(A, loc_rows,12, 12,12); > >> MatSetType(A, MATMPIBAIJ); > >> > >> What is the optimal value for loc_rows here? > >> > >> Can I use PETSC_DECIDE for it? I suppose this will lead to division by > >> 6 rows per processor, which is not consistent with block size. How > >> MatMPIBAIJSetPreallocation(A,4,...) will deal with it? > >> > >> Most likely, I have to manually set loc_rows to 8 and 4 according to > >> the processor rank. But probably I miss some more clean way, when > >> PETSc really decides. :) > >> > >> Thanks in advance for any comments. > >> > >> Regards! > >> Andrey > > > > > > > > -- > > 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 > > > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From bsmith at mcs.anl.gov Fri Feb 5 17:37:57 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Fri, 5 Feb 2010 17:37:57 -0600 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: References: Message-ID: <8070993F-A6A2-4D82-B296-CAA2E3915E2B@mcs.anl.gov> On Feb 5, 2010, at 5:28 PM, NovA wrote: > Thanks for the quick response! > > 2010/2/6 Matthew Knepley : >> 1) It will distribute block rows, so you will get 8 and 4 as you want > > How can it distribute in such a way, if it doesn't know block size > yet? > Let's continue the example: > MatCreate(comm, &A); > MatSetSizes(A, PETSC_DECIDE,12, 12,12); ^^^^^^ This is wrong! Look at the manual page for MatCreateMPIBAIJ() for information on the meaning of this. > MatSetType(A, MATMPIBAIJ); > MatGetOwnershipRange(A, &rowS, &rowE); > Then loop local rows from rowS/4 to rowE/4 to preallocate storage > using MatMPIBAIJSetPreallocation(A,4,...) You cannot do it this way. You cannot call MatGetOwnershipRange() before setting the preallocation. You can either, 1) figure out yourself the local sizes you want to use, then just call MatCreateMPIBAIJ() with all the information (or call MatCreate(), MatSetType(), MatSetSizes(), MatMPIBAIJSetPreallocation()) or 2) Use PetscMap (see manual page for PetscMapInitialize) to see how PETSc would decompose the rows and then use that information to do 1). Barry In petsc-dev PetscMap has been changed to PetscLayout, see PetscLayoutCreate(). > > What will be the rowS and rowE here? I think they can be not divisible > by 4 (block size)... > > >> >> 2) Warning: This is an incredibly small problem. Using 2 processors >> might not show any speedup at all. > Sure! It's just an example. I suppose it'll be much slower on two > processors actually. > > > Regards! > Andrey > >> >> Matt >> >> On Fri, Feb 5, 2010 at 5:03 PM, NovA wrote: >>> >>> Hi everybody! >>> >>> I'm looking for the best way to distribute MPIBAIJ matrix among >>> several processors. >>> >>> For example, I have square matrix 3x3 of blocks 4x4 each (i.e. 12x12 >>> values) and need to distribute it among 2 processors. The generic >>> way >>> of creating such a matrix would be: >>> Mat A; >>> MatCreate(comm, &A); >>> MatSetSizes(A, loc_rows,12, 12,12); >>> MatSetType(A, MATMPIBAIJ); >>> >>> What is the optimal value for loc_rows here? >>> >>> Can I use PETSC_DECIDE for it? I suppose this will lead to >>> division by >>> 6 rows per processor, which is not consistent with block size. How >>> MatMPIBAIJSetPreallocation(A,4,...) will deal with it? >>> >>> Most likely, I have to manually set loc_rows to 8 and 4 according to >>> the processor rank. But probably I miss some more clean way, when >>> PETSc really decides. :) >>> >>> Thanks in advance for any comments. >>> >>> Regards! >>> Andrey >> >> >> >> -- >> 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 >> From av.nova at gmail.com Fri Feb 5 18:17:28 2010 From: av.nova at gmail.com (NovA) Date: Sat, 6 Feb 2010 03:17:28 +0300 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: <8070993F-A6A2-4D82-B296-CAA2E3915E2B@mcs.anl.gov> References: <8070993F-A6A2-4D82-B296-CAA2E3915E2B@mcs.anl.gov> Message-ID: 2010/2/6 Barry Smith : > > On Feb 5, 2010, at 5:28 PM, NovA wrote: > >> Thanks for the quick response! >> >> 2010/2/6 Matthew Knepley : >>> >>> 1) It will distribute block rows, so you will get 8 and 4 as you want >> >> How can it distribute in such a way, if it doesn't know block size yet? >> Let's continue the example: >> ?MatCreate(comm, &A); >> ?MatSetSizes(A, PETSC_DECIDE,12, 12,12); > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^^^^^^ > ? ? ? ? ? ? ? ? ? ? ? ? ? ?This is wrong! Look at the manual page for > MatCreateMPIBAIJ() for information on the meaning of this. Sorry, but I can't find any additional info on this at http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIBAIJ.html and around. I could just expect that those sizes mean number of blocks not individual values, but can't find any confirmation... >> ?MatSetType(A, MATMPIBAIJ); >> ?MatGetOwnershipRange(A, &rowS, &rowE); >> ?Then loop local rows from rowS/4 to rowE/4 to preallocate storage >> using MatMPIBAIJSetPreallocation(A,4,...) > > ? You cannot do it this way. You cannot call MatGetOwnershipRange() before > setting the preallocation. Oh, ok. This applies to BAIJ, right? For AIJ this works, so I thought it should for BAIJ either. > > ? You can either, > > 1) figure out yourself the local sizes you want to use, then just call > MatCreateMPIBAIJ() with all the information (or call MatCreate(), > MatSetType(), MatSetSizes(), MatMPIBAIJSetPreallocation()) or > 2) Use PetscMap (see manual page for PetscMapInitialize) to see how PETSc > would decompose the rows and then use that information to do 1). Thanks for the tip. I'll try to sort it out. Best wishes, Andrey > > ? Barry > > In petsc-dev PetscMap has been changed to PetscLayout, see > PetscLayoutCreate(). >> >> What will be the rowS and rowE here? I think they can be not divisible >> by 4 (block size)... >> >> >>> >>> 2) Warning: This is an incredibly small problem. Using 2 processors >>> ? ?might not show any speedup at all. >> >> Sure! It's just an example. I suppose it'll be much slower on two >> processors actually. >> >> >> Regards! >> ?Andrey >> >>> >>> ?Matt >>> >>> On Fri, Feb 5, 2010 at 5:03 PM, NovA wrote: >>>> >>>> Hi everybody! >>>> >>>> I'm looking for the best way to distribute MPIBAIJ matrix among >>>> several processors. >>>> >>>> For example, I have square matrix 3x3 of blocks 4x4 each (i.e. 12x12 >>>> values) and need to distribute it among 2 processors. The generic way >>>> of creating such a matrix would be: >>>> ?Mat A; >>>> ?MatCreate(comm, &A); >>>> ?MatSetSizes(A, loc_rows,12, 12,12); >>>> ?MatSetType(A, MATMPIBAIJ); >>>> >>>> What is the optimal value for loc_rows here? >>>> >>>> Can I use PETSC_DECIDE for it? I suppose this will lead to division by >>>> 6 rows per processor, which is not consistent with block size. How >>>> MatMPIBAIJSetPreallocation(A,4,...) will deal with it? >>>> >>>> Most likely, I have to manually set loc_rows to 8 and 4 according to >>>> the processor rank. But probably I miss some more clean way, when >>>> PETSc really decides. :) >>>> >>>> Thanks in advance for any comments. >>>> >>>> Regards! >>>> ?Andrey >>> >>> >>> >>> -- >>> 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 >>> > > From knepley at gmail.com Fri Feb 5 18:31:05 2010 From: knepley at gmail.com (Matthew Knepley) Date: Fri, 5 Feb 2010 18:31:05 -0600 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: References: <8070993F-A6A2-4D82-B296-CAA2E3915E2B@mcs.anl.gov> Message-ID: On Fri, Feb 5, 2010 at 6:17 PM, NovA wrote: > 2010/2/6 Barry Smith : > > > > On Feb 5, 2010, at 5:28 PM, NovA wrote: > > > >> Thanks for the quick response! > >> > >> 2010/2/6 Matthew Knepley : > >>> > >>> 1) It will distribute block rows, so you will get 8 and 4 as you want > >> > >> How can it distribute in such a way, if it doesn't know block size yet? > >> Let's continue the example: > >> MatCreate(comm, &A); > >> MatSetSizes(A, PETSC_DECIDE,12, 12,12); > > > > ^^^^^^ > > This is wrong! Look at the manual page for > > MatCreateMPIBAIJ() for information on the meaning of this. > > Sorry, but I can't find any additional info on this at > > http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIBAIJ.html > and around. I could just expect that those sizes mean number of blocks > not individual values, but can't find any confirmation... > >From the page: It says m,n,M,N are "rows" and the values in d_nz,o_nz are "blocks". > >> MatSetType(A, MATMPIBAIJ); > >> MatGetOwnershipRange(A, &rowS, &rowE); > >> Then loop local rows from rowS/4 to rowE/4 to preallocate storage > >> using MatMPIBAIJSetPreallocation(A,4,...) > > > > You cannot do it this way. You cannot call MatGetOwnershipRange() > before > > setting the preallocation. > > Oh, ok. This applies to BAIJ, right? For AIJ this works, so I thought > it should for BAIJ either. > This is not correct for AIJ either. Matt > > > > You can either, > > > > 1) figure out yourself the local sizes you want to use, then just call > > MatCreateMPIBAIJ() with all the information (or call MatCreate(), > > MatSetType(), MatSetSizes(), MatMPIBAIJSetPreallocation()) or > > 2) Use PetscMap (see manual page for PetscMapInitialize) to see how PETSc > > would decompose the rows and then use that information to do 1). > > Thanks for the tip. I'll try to sort it out. > > Best wishes, > Andrey > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From av.nova at gmail.com Fri Feb 5 18:46:07 2010 From: av.nova at gmail.com (NovA) Date: Sat, 6 Feb 2010 03:46:07 +0300 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: References: <8070993F-A6A2-4D82-B296-CAA2E3915E2B@mcs.anl.gov> Message-ID: 2010/2/6 Matthew Knepley : > On Fri, Feb 5, 2010 at 6:17 PM, NovA wrote: >> >> 2010/2/6 Barry Smith : >> > >> > On Feb 5, 2010, at 5:28 PM, NovA wrote: >> > >> >> Thanks for the quick response! >> >> >> >> 2010/2/6 Matthew Knepley : >> >>> >> >>> 1) It will distribute block rows, so you will get 8 and 4 as you want >> >> >> >> How can it distribute in such a way, if it doesn't know block size yet? >> >> Let's continue the example: >> >> ?MatCreate(comm, &A); >> >> ?MatSetSizes(A, PETSC_DECIDE,12, 12,12); >> > >> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^^^^^^ >> > ? ? ? ? ? ? ? ? ? ? ? ? ? ?This is wrong! Look at the manual page for >> > MatCreateMPIBAIJ() for information on the meaning of this. >> >> Sorry, but I can't find any additional info on this at >> >> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIBAIJ.html >> and around. I could just expect that those sizes mean number of blocks >> not individual values, but can't find any confirmation... > > From the page: It says m,n,M,N are "rows" and the values in d_nz,o_nz are > "blocks". Yep, sure. And how is this concerns the line MatSetSizes(A, /*m*/PETSC_DECIDE,/*n*/12, /*M*/12, /*N*/12) ? Here we need not specify noznzero pattern. Am I wrong? Thanks! Andrey >> >> >> ?MatSetType(A, MATMPIBAIJ); >> >> ?MatGetOwnershipRange(A, &rowS, &rowE); >> >> ?Then loop local rows from rowS/4 to rowE/4 to preallocate storage >> >> using MatMPIBAIJSetPreallocation(A,4,...) >> > >> > ? You cannot do it this way. You cannot call MatGetOwnershipRange() >> > before >> > setting the preallocation. >> >> Oh, ok. This applies to BAIJ, right? For AIJ this works, so I thought >> it should for BAIJ either. > > This is not correct for AIJ either. > > ?? Matt > >> >> > >> > ? You can either, >> > >> > 1) figure out yourself the local sizes you want to use, then just call >> > MatCreateMPIBAIJ() with all the information (or call MatCreate(), >> > MatSetType(), MatSetSizes(), MatMPIBAIJSetPreallocation()) or >> > 2) Use PetscMap (see manual page for PetscMapInitialize) to see how >> > PETSc >> > would decompose the rows and then use that information to do 1). >> >> Thanks for the tip. I'll try to sort it out. >> >> Best wishes, >> ? ?Andrey > > -- > 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 > From bsmith at mcs.anl.gov Fri Feb 5 20:08:37 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Fri, 5 Feb 2010 20:08:37 -0600 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: References: <8070993F-A6A2-4D82-B296-CAA2E3915E2B@mcs.anl.gov> Message-ID: On Feb 5, 2010, at 6:46 PM, NovA wrote: > 2010/2/6 Matthew Knepley : >> On Fri, Feb 5, 2010 at 6:17 PM, NovA wrote: >>> >>> 2010/2/6 Barry Smith : >>>> >>>> On Feb 5, 2010, at 5:28 PM, NovA wrote: >>>> >>>>> Thanks for the quick response! >>>>> >>>>> 2010/2/6 Matthew Knepley : >>>>>> >>>>>> 1) It will distribute block rows, so you will get 8 and 4 as >>>>>> you want >>>>> >>>>> How can it distribute in such a way, if it doesn't know block >>>>> size yet? >>>>> Let's continue the example: >>>>> MatCreate(comm, &A); >>>>> MatSetSizes(A, PETSC_DECIDE,12, 12,12); >>>> >>>> >>>> ^^^^^^ >>>> This is wrong! Look at the manual page >>>> for >>>> MatCreateMPIBAIJ() for information on the meaning of this. >>> >>> Sorry, but I can't find any additional info on this at >>> >>> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIBAIJ.html >>> and around. I could just expect that those sizes mean number of >>> blocks >>> not individual values, but can't find any confirmation... >> >> From the page: It says m,n,M,N are "rows" and the values in >> d_nz,o_nz are >> "blocks". > Yep, sure. And how is this concerns the line > MatSetSizes(A, /*m*/PETSC_DECIDE,/*n*/12, /*M*/12, /*N*/12) ? n is the number of "owned" columns it is NOT the same as the total number of columns. If you read the manual page for MatCreateMPIBAIJ you will see the example that discusses what n is. n - number of local columns (or PETSC_DECIDE to have calculated if N is given) This value should be the same as the local size used in creating the x vector for the matrix-vector product y = Ax. Barry > > Here we need not specify noznzero pattern. Am I wrong? > > Thanks! > Andrey > >>> >>>>> MatSetType(A, MATMPIBAIJ); >>>>> MatGetOwnershipRange(A, &rowS, &rowE); >>>>> Then loop local rows from rowS/4 to rowE/4 to preallocate storage >>>>> using MatMPIBAIJSetPreallocation(A,4,...) >>>> >>>> You cannot do it this way. You cannot call MatGetOwnershipRange() >>>> before >>>> setting the preallocation. >>> >>> Oh, ok. This applies to BAIJ, right? For AIJ this works, so I >>> thought >>> it should for BAIJ either. >> >> This is not correct for AIJ either. >> >> Matt >> >>> >>>> >>>> You can either, >>>> >>>> 1) figure out yourself the local sizes you want to use, then just >>>> call >>>> MatCreateMPIBAIJ() with all the information (or call MatCreate(), >>>> MatSetType(), MatSetSizes(), MatMPIBAIJSetPreallocation()) or >>>> 2) Use PetscMap (see manual page for PetscMapInitialize) to see how >>>> PETSc >>>> would decompose the rows and then use that information to do 1). >>> >>> Thanks for the tip. I'll try to sort it out. >>> >>> Best wishes, >>> Andrey >> >> -- >> 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 >> From av.nova at gmail.com Sat Feb 6 03:56:39 2010 From: av.nova at gmail.com (NovA) Date: Sat, 6 Feb 2010 12:56:39 +0300 Subject: [petsc-users] MatSetSizes for MATMPIBAIJ In-Reply-To: References: <8070993F-A6A2-4D82-B296-CAA2E3915E2B@mcs.anl.gov> Message-ID: 2010/2/6 Barry Smith : > > On Feb 5, 2010, at 6:46 PM, NovA wrote: > >> 2010/2/6 Matthew Knepley : >>> >>> On Fri, Feb 5, 2010 at 6:17 PM, NovA wrote: >>>> >>>> 2010/2/6 Barry Smith : >>>>> >>>>> On Feb 5, 2010, at 5:28 PM, NovA wrote: >>>>> >>>>>> Thanks for the quick response! >>>>>> >>>>>> 2010/2/6 Matthew Knepley : >>>>>>> >>>>>>> 1) It will distribute block rows, so you will get 8 and 4 as you want >>>>>> >>>>>> How can it distribute in such a way, if it doesn't know block size >>>>>> yet? >>>>>> Let's continue the example: >>>>>> ?MatCreate(comm, &A); >>>>>> ?MatSetSizes(A, PETSC_DECIDE,12, 12,12); >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^^^^^^ >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? This is wrong! Look at the manual page for >>>>> MatCreateMPIBAIJ() for information on the meaning of this. >>>> >>>> Sorry, but I can't find any additional info on this at >>>> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIBAIJ.html >>>> and around. I could just expect that those sizes mean number of blocks >>>> not individual values, but can't find any confirmation... >>> >>> From the page: It says m,n,M,N are "rows" and the values in d_nz,o_nz are >>> "blocks". >> >> Yep, sure. And how is this concerns the line >> ?MatSetSizes(A, /*m*/PETSC_DECIDE,/*n*/12, /*M*/12, /*N*/12) ? > > n is the number of "owned" columns it is NOT the same as the total number > of columns. If you read the manual page for MatCreateMPIBAIJ you will see > the example that discusses what n is. > > n - number of local columns (or PETSC_DECIDE to have calculated if N is given) > This value should be the same as the local size used in creating the x > vector for the matrix-vector product y = Ax. Oh, I thought that you pointed me to wrong M & N values... As for n value, this was always ambiguous for me. On the one hand, it is said in the examples and manual that "all PETSc parallel matrix formats are partitioned by contiguous chunks of rows across the processors" and we use MatGetOwnershipRange returning just rows, i.e. n = N. On the other hand n "is the local size used in creating the x vector for y = Ax", i.e. n != N... For myself I decided to use first assumption n = N as starting point in the hope to sort it out later. As you see, I'm rather novice user yet. So sorry for stupid questions :). I'll much appreciate any explanation. Thanks! Andrey > Barry > From xy2102 at columbia.edu Mon Feb 8 14:40:45 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Mon, 08 Feb 2010 15:40:45 -0500 Subject: [petsc-users] could I update the user-defined parameters after each linear iteration? Message-ID: <20100208154045.2goqqe87ogkkck0o@cubmail.cc.columbia.edu> Dear all, KSPSolve() is called through the following, #0 KSPSolve (ksp=0x899cf20, b=0x8987a70, x=0x89f9990) at itfunc.c:299 #1 0x08069e0c in SNES_KSPSolve (snes=0x89958c0, ksp=0x899cf20, b=0x8987a70, x=0x89f9990) at snes.c:2931 #2 0x08085639 in SNESSolve_LS (snes=0x89958c0) at ls.c:191 #3 0x08065074 in SNESSolve (snes=0x89958c0, b=0x0, x=0x8988e30) at snes.c:2242 #4 0x0807ebf9 in DMMGSolveSNES (dmmg=0x89aad90, level=0) at damgsnes.c:510 #5 0x080780f1 in DMMGSolve (dmmg=0x89aad90) at damg.c:313 #6 0x0804d577 in Solve (dmmg=0x89aad90) at twmgvggtnivexc.c:247 #7 0x0804cea4 in main (argc=-2080374784, argv=0x1) at twmgvggtnivexc.c:191 Is there any way I can update the user-defined parameters inside after each linear iteration is done? Thanks a lot! -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From knepley at gmail.com Mon Feb 8 14:44:44 2010 From: knepley at gmail.com (Matthew Knepley) Date: Mon, 8 Feb 2010 14:44:44 -0600 Subject: [petsc-users] could I update the user-defined parameters after each linear iteration? In-Reply-To: <20100208154045.2goqqe87ogkkck0o@cubmail.cc.columbia.edu> References: <20100208154045.2goqqe87ogkkck0o@cubmail.cc.columbia.edu> Message-ID: DMMGGetSNES() and SNESGetKSP() Matt On Mon, Feb 8, 2010 at 2:40 PM, (Rebecca) Xuefei YUAN wrote: > Dear all, > > KSPSolve() is called through the following, > #0 KSPSolve (ksp=0x899cf20, b=0x8987a70, x=0x89f9990) at itfunc.c:299 > #1 0x08069e0c in SNES_KSPSolve (snes=0x89958c0, ksp=0x899cf20, > b=0x8987a70, x=0x89f9990) at snes.c:2931 > #2 0x08085639 in SNESSolve_LS (snes=0x89958c0) at ls.c:191 > #3 0x08065074 in SNESSolve (snes=0x89958c0, b=0x0, x=0x8988e30) at > snes.c:2242 > #4 0x0807ebf9 in DMMGSolveSNES (dmmg=0x89aad90, level=0) at damgsnes.c:510 > #5 0x080780f1 in DMMGSolve (dmmg=0x89aad90) at damg.c:313 > #6 0x0804d577 in Solve (dmmg=0x89aad90) at twmgvggtnivexc.c:247 > #7 0x0804cea4 in main (argc=-2080374784, argv=0x1) at twmgvggtnivexc.c:191 > > Is there any way I can update the user-defined parameters inside after each > linear iteration is done? > > Thanks a lot! > > -- > (Rebecca) Xuefei YUAN > Department of Applied Physics and Applied Mathematics > Columbia University > Tel:917-399-8032 > www.columbia.edu/~xy2102 > > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From xy2102 at columbia.edu Mon Feb 8 14:45:51 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Mon, 08 Feb 2010 15:45:51 -0500 Subject: [petsc-users] could I update the user-defined parameters after each linear iteration? In-Reply-To: References: <20100208154045.2goqqe87ogkkck0o@cubmail.cc.columbia.edu> Message-ID: <20100208154551.8smj0ow34s0osssg@cubmail.cc.columbia.edu> Dear Matt, Thanks! R Quoting Matthew Knepley : > DMMGGetSNES() and SNESGetKSP() > > Matt > > On Mon, Feb 8, 2010 at 2:40 PM, (Rebecca) Xuefei YUAN > wrote: > >> Dear all, >> >> KSPSolve() is called through the following, >> #0 KSPSolve (ksp=0x899cf20, b=0x8987a70, x=0x89f9990) at itfunc.c:299 >> #1 0x08069e0c in SNES_KSPSolve (snes=0x89958c0, ksp=0x899cf20, >> b=0x8987a70, x=0x89f9990) at snes.c:2931 >> #2 0x08085639 in SNESSolve_LS (snes=0x89958c0) at ls.c:191 >> #3 0x08065074 in SNESSolve (snes=0x89958c0, b=0x0, x=0x8988e30) at >> snes.c:2242 >> #4 0x0807ebf9 in DMMGSolveSNES (dmmg=0x89aad90, level=0) at damgsnes.c:510 >> #5 0x080780f1 in DMMGSolve (dmmg=0x89aad90) at damg.c:313 >> #6 0x0804d577 in Solve (dmmg=0x89aad90) at twmgvggtnivexc.c:247 >> #7 0x0804cea4 in main (argc=-2080374784, argv=0x1) at twmgvggtnivexc.c:191 >> >> Is there any way I can update the user-defined parameters inside after each >> linear iteration is done? >> >> Thanks a lot! >> >> -- >> (Rebecca) Xuefei YUAN >> Department of Applied Physics and Applied Mathematics >> Columbia University >> Tel:917-399-8032 >> www.columbia.edu/~xy2102 >> >> > > > -- > 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 > -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From xy2102 at columbia.edu Mon Feb 8 15:13:53 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Mon, 08 Feb 2010 16:13:53 -0500 Subject: [petsc-users] What is the difference between these two approaches? Message-ID: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> Dear all, I do have an PDE-constrained optimization problem: F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1) F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = 0 (2) where phi(x,y) is defined at each grid point and c is a scalar parameter that satisfying the equation (2). I have two pieces of codes to solve them by different approaches. The first approach is to use DMComposite() to manage unknowns and solve F1&F2 at the same time, and it calls DMMGSolve() once. The second approach is to solve F1 with a guess c for some number(i.e. 1) times of nonlinear and linear iteration, and then update c from F2. Solve F1 again with updated c till some conditions satisfied, for example, if (cres<1e-10){CONTINUE=PETSC_FALSE;} // update on c if (functionNorm<1e-10){CONTINUE=PETSC_FALSE;}//residual function norm if (reason>0){CONTINUE=PETSC_FALSE;}//snes_converged_reason if (totalNumberOfNonlinearIterations>50){CONTINUE=PETSC_FALSE;} In this approach, DMMGSolve() was called more than once. Although these two approaches convergence, the results are quite different. My understanding is that a) approach one updates c in each linear iteration, but approach two updates c only after several (i.e. 1) nonlinear iterations. ierr = DMMGSolve(dmmg);CHKERRQ(ierr); parameters->c = parameters->integration/area; b) the results from two approaches should be the same or very close to each other but due to some reasons, they are not. c) three different examples are tested by these two approaches, two are good, but one is bad. The bad one is different from the other two because the solution has large gradient at some points. d) the shortcoming of approach one is PETSc has not ready for assemble a Jacobian for object DMComposite, so the second approach is able to write an analytic Jacobian. Any thoughts about how to debug or compare these two approaches is appreciate!~ Thanks a ton! Rebecca -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From knepley at gmail.com Mon Feb 8 15:17:29 2010 From: knepley at gmail.com (Matthew Knepley) Date: Mon, 8 Feb 2010 15:17:29 -0600 Subject: [petsc-users] What is the difference between these two approaches? In-Reply-To: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> References: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> Message-ID: I am confused by b). If they both converge, how can the answers be different? Matt On Mon, Feb 8, 2010 at 3:13 PM, (Rebecca) Xuefei YUAN wrote: > Dear all, > > I do have an PDE-constrained optimization problem: > > F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1) > F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = 0 (2) > > where phi(x,y) is defined at each grid point and c is a scalar parameter > that satisfying the equation (2). > > I have two pieces of codes to solve them by different approaches. > > The first approach is to use DMComposite() to manage unknowns and solve > F1&F2 at the same time, and it calls DMMGSolve() once. > > The second approach is to solve F1 with a guess c for some number(i.e. 1) > times of nonlinear and linear iteration, and then update c from F2. Solve F1 > again with updated c till some conditions satisfied, for example, > > if (cres<1e-10){CONTINUE=PETSC_FALSE;} // update on c > if (functionNorm<1e-10){CONTINUE=PETSC_FALSE;}//residual function norm > if (reason>0){CONTINUE=PETSC_FALSE;}//snes_converged_reason > if (totalNumberOfNonlinearIterations>50){CONTINUE=PETSC_FALSE;} > > In this approach, DMMGSolve() was called more than once. > > Although these two approaches convergence, the results are quite different. > > My understanding is that > a) approach one updates c in each linear iteration, but approach two > updates c > only after several (i.e. 1) nonlinear iterations. > > ierr = DMMGSolve(dmmg);CHKERRQ(ierr); > parameters->c = parameters->integration/area; > > b) the results from two approaches should be the same or very close to each > other but due to some reasons, they are not. > > c) three different examples are tested by these two approaches, two are > good, but one is bad. The bad one is different from the other two because > the solution has large gradient at some points. > > d) the shortcoming of approach one is PETSc has not ready for assemble a > Jacobian for object DMComposite, so the second approach is able to write an > analytic Jacobian. > > Any thoughts about how to debug or compare these two approaches is > appreciate!~ > > > Thanks a ton! > > Rebecca > > > > > > -- > (Rebecca) Xuefei YUAN > Department of Applied Physics and Applied Mathematics > Columbia University > Tel:917-399-8032 > www.columbia.edu/~xy2102 > > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From xy2102 at columbia.edu Mon Feb 8 15:24:28 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Mon, 08 Feb 2010 16:24:28 -0500 Subject: [petsc-users] What is the difference between these two approaches? In-Reply-To: References: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> Message-ID: <20100208162428.iyy2r612oswo88k4@cubmail.cc.columbia.edu> That is also confusing me when running this bad example. The good examples have matched solutions, but this bad one does not. I do not know what is wrong and where is the difference coming from? Quoting Matthew Knepley : > I am confused by b). If they both converge, how can the answers be > different? > > Matt > > On Mon, Feb 8, 2010 at 3:13 PM, (Rebecca) Xuefei YUAN > wrote: > >> Dear all, >> >> I do have an PDE-constrained optimization problem: >> >> F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1) >> F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = 0 (2) >> >> where phi(x,y) is defined at each grid point and c is a scalar parameter >> that satisfying the equation (2). >> >> I have two pieces of codes to solve them by different approaches. >> >> The first approach is to use DMComposite() to manage unknowns and solve >> F1&F2 at the same time, and it calls DMMGSolve() once. >> >> The second approach is to solve F1 with a guess c for some number(i.e. 1) >> times of nonlinear and linear iteration, and then update c from F2. Solve F1 >> again with updated c till some conditions satisfied, for example, >> >> if (cres<1e-10){CONTINUE=PETSC_FALSE;} // update on c >> if (functionNorm<1e-10){CONTINUE=PETSC_FALSE;}//residual function norm >> if (reason>0){CONTINUE=PETSC_FALSE;}//snes_converged_reason >> if (totalNumberOfNonlinearIterations>50){CONTINUE=PETSC_FALSE;} >> >> In this approach, DMMGSolve() was called more than once. >> >> Although these two approaches convergence, the results are quite different. >> >> My understanding is that >> a) approach one updates c in each linear iteration, but approach two >> updates c >> only after several (i.e. 1) nonlinear iterations. >> >> ierr = DMMGSolve(dmmg);CHKERRQ(ierr); >> parameters->c = parameters->integration/area; >> >> b) the results from two approaches should be the same or very close to each >> other but due to some reasons, they are not. >> >> c) three different examples are tested by these two approaches, two are >> good, but one is bad. The bad one is different from the other two because >> the solution has large gradient at some points. >> >> d) the shortcoming of approach one is PETSc has not ready for assemble a >> Jacobian for object DMComposite, so the second approach is able to write an >> analytic Jacobian. >> >> Any thoughts about how to debug or compare these two approaches is >> appreciate!~ >> >> >> Thanks a ton! >> >> Rebecca >> >> >> >> >> >> -- >> (Rebecca) Xuefei YUAN >> Department of Applied Physics and Applied Mathematics >> Columbia University >> Tel:917-399-8032 >> www.columbia.edu/~xy2102 >> >> > > > -- > 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 > -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From bsmith at mcs.anl.gov Mon Feb 8 15:26:46 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Mon, 8 Feb 2010 15:26:46 -0600 Subject: [petsc-users] What is the difference between these two approaches? In-Reply-To: <20100208162428.iyy2r612oswo88k4@cubmail.cc.columbia.edu> References: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> <20100208162428.iyy2r612oswo88k4@cubmail.cc.columbia.edu> Message-ID: <57B9AD70-0112-4A51-8D38-FE32B4396702@mcs.anl.gov> If both on converging then there is something wrong with your function evaluation code for one or both of the two approaches. Or perhaps Newton is not actually converging and so you are getting an unconverged (wrong) solution. Make sure you always call SNESGetConvergedReason() to insure the nonlinear equations are actually be solved. Barry On Feb 8, 2010, at 3:24 PM, (Rebecca) Xuefei YUAN wrote: > That is also confusing me when running this bad example. The good > examples have matched solutions, but this bad one does not. I do not > know what is wrong and where is the difference coming from? > > > > > Quoting Matthew Knepley : > >> I am confused by b). If they both converge, how can the answers be >> different? >> >> Matt >> >> On Mon, Feb 8, 2010 at 3:13 PM, (Rebecca) Xuefei YUAN >> wrote: >> >>> Dear all, >>> >>> I do have an PDE-constrained optimization problem: >>> >>> F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1) >>> F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = >>> 0 (2) >>> >>> where phi(x,y) is defined at each grid point and c is a scalar >>> parameter >>> that satisfying the equation (2). >>> >>> I have two pieces of codes to solve them by different approaches. >>> >>> The first approach is to use DMComposite() to manage unknowns and >>> solve >>> F1&F2 at the same time, and it calls DMMGSolve() once. >>> >>> The second approach is to solve F1 with a guess c for some >>> number(i.e. 1) >>> times of nonlinear and linear iteration, and then update c from >>> F2. Solve F1 >>> again with updated c till some conditions satisfied, for example, >>> >>> if (cres<1e-10){CONTINUE=PETSC_FALSE;} // update on c >>> if (functionNorm<1e-10){CONTINUE=PETSC_FALSE;}//residual function >>> norm >>> if (reason>0){CONTINUE=PETSC_FALSE;}//snes_converged_reason >>> if (totalNumberOfNonlinearIterations>50){CONTINUE=PETSC_FALSE;} >>> >>> In this approach, DMMGSolve() was called more than once. >>> >>> Although these two approaches convergence, the results are quite >>> different. >>> >>> My understanding is that >>> a) approach one updates c in each linear iteration, but approach two >>> updates c >>> only after several (i.e. 1) nonlinear iterations. >>> >>> ierr = DMMGSolve(dmmg);CHKERRQ(ierr); >>> parameters->c = parameters->integration/area; >>> >>> b) the results from two approaches should be the same or very >>> close to each >>> other but due to some reasons, they are not. >>> >>> c) three different examples are tested by these two approaches, >>> two are >>> good, but one is bad. The bad one is different from the other two >>> because >>> the solution has large gradient at some points. >>> >>> d) the shortcoming of approach one is PETSc has not ready for >>> assemble a >>> Jacobian for object DMComposite, so the second approach is able to >>> write an >>> analytic Jacobian. >>> >>> Any thoughts about how to debug or compare these two approaches is >>> appreciate!~ >>> >>> >>> Thanks a ton! >>> >>> Rebecca >>> >>> >>> >>> >>> >>> -- >>> (Rebecca) Xuefei YUAN >>> Department of Applied Physics and Applied Mathematics >>> Columbia University >>> Tel:917-399-8032 >>> www.columbia.edu/~xy2102 >>> >>> >> >> >> -- >> 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 >> > > > > -- > (Rebecca) Xuefei YUAN > Department of Applied Physics and Applied Mathematics > Columbia University > Tel:917-399-8032 > www.columbia.edu/~xy2102 > From jed at 59A2.org Mon Feb 8 15:31:02 2010 From: jed at 59A2.org (Jed Brown) Date: Mon, 08 Feb 2010 22:31:02 +0100 Subject: [petsc-users] What is the difference between these two approaches? In-Reply-To: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> References: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> Message-ID: <87ljf3tnxl.fsf@59A2.org> On Mon, 08 Feb 2010 16:13:53 -0500, "(Rebecca) Xuefei YUAN" wrote: > Dear all, > > I do have an PDE-constrained optimization problem: > > F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1) > F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = 0 (2) > > where phi(x,y) is defined at each grid point and c is a scalar > parameter that satisfying the equation (2). Is c the only parameter you are optimizing? What does your system look like in "minimize functional subject to PDE" form? > I have two pieces of codes to solve them by different approaches. > > The first approach is to use DMComposite() to manage unknowns and > solve F1&F2 at the same time, and it calls DMMGSolve() once. > > The second approach is to solve F1 with a guess c for some number(i.e. > 1) times of nonlinear and linear iteration, and then update c from F2. > Solve F1 again with updated c till some conditions satisfied, for > example, Perhaps the iteration has stagnated or found a different local minimum? Have you compared the objective functions? > d) the shortcoming of approach one is PETSc has not ready for assemble > a Jacobian for object DMComposite, so the second approach is able to > write an analytic Jacobian. Does DMCompositeGetMatrix() not work for you? Jed From keita at cray.com Tue Feb 9 11:39:04 2010 From: keita at cray.com (Keita Teranishi) Date: Tue, 9 Feb 2010 11:39:04 -0600 Subject: [petsc-users] hypre-2.6b Message-ID: <5D6E0DF460ACF34C88644E1EA91DCD0D041A48BD@CFEXMBX.americas.cray.com> Hi, I have just heard a new release of hypre-2.6b. Will PETSc support this new version? Thanks, ================================ Keita Teranishi Scientific Library Group Cray, Inc. keita at cray.com ================================ -------------- next part -------------- An HTML attachment was scrubbed... URL: From xy2102 at columbia.edu Tue Feb 9 12:21:22 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Tue, 09 Feb 2010 13:21:22 -0500 Subject: [petsc-users] What could be the reason for a convergence history like this one? Message-ID: <20100209132122.cdvunfbi80swg08g@cubmail.cc.columbia.edu> Hi, The SNES convergence history shows the residual increases or stop decreasing starting at some iteration. I ran two different cases for the same code, and the history looks similar, what could be wrong with the code? Thanks very much! Case 1: 0 SNES Function norm 9.593111354483e-01 1 SNES Function norm 1.233321371555e-01 2 SNES Function norm 2.926382110614e-02 3 SNES Function norm 2.091318748212e-02 4 SNES Function norm 1.047907743570e-02 5 SNES Function norm 4.462043675959e-03 6 SNES Function norm 1.851050848655e-03 7 SNES Function norm 4.417550480988e-04 8 SNES Function norm 1.736388356513e-04 9 SNES Function norm 6.300414578098e-05 10 SNES Function norm 1.929829710585e-05 11 SNES Function norm 1.506367625001e-05 12 SNES Function norm 1.480567720594e-05 13 SNES Function norm 1.470754287980e-05 14 SNES Function norm 1.461728595512e-05 15 SNES Function norm 1.453616609384e-05 16 SNES Function norm 1.441040320141e-05 17 SNES Function norm 1.402352953635e-05 18 SNES Function norm 1.343005745899e-05 19 SNES Function norm 1.328043697395e-05 20 SNES Function norm 1.327501784736e-05 21 SNES Function norm 1.327431008405e-05 22 SNES Function norm 1.327343169426e-05 23 SNES Function norm 1.327273768560e-05 24 SNES Function norm 1.327185496127e-05 25 SNES Function norm 1.327119625499e-05 26 SNES Function norm 1.327071509157e-05 27 SNES Function norm 1.327038695378e-05 28 SNES Function norm 1.326990549326e-05 29 SNES Function norm 1.326917602672e-05 30 SNES Function norm 1.326830723835e-05 31 SNES Function norm 1.326796002362e-05 32 SNES Function norm 1.326777827731e-05 33 SNES Function norm 1.326755622116e-05 34 SNES Function norm 1.326732752144e-05 35 SNES Function norm 1.326698050145e-05 36 SNES Function norm 1.326640877572e-05 37 SNES Function norm 1.326587074902e-05 38 SNES Function norm 1.326573931166e-05 39 SNES Function norm 1.326564241601e-05 40 SNES Function norm 1.326548432075e-05 41 SNES Function norm 1.326531590041e-05 42 SNES Function norm 1.326531590043e-05 43 SNES Function norm 1.326531590045e-05 44 SNES Function norm 1.326531590044e-05 45 SNES Function norm 1.326531590044e-05 46 SNES Function norm 1.326531590043e-05 47 SNES Function norm 1.326531590045e-05 48 SNES Function norm 1.326531590044e-05 49 SNES Function norm 1.326531590046e-05 50 SNES Function norm 1.326531590046e-05 Nonlinear solve did not converge due to DIVERGED_MAX_IT case 2: 0 SNES Function norm 1.489006328086e+00 1 SNES Function norm 1.044141602147e-01 2 SNES Function norm 2.662563646189e-02 3 SNES Function norm 5.764005178654e-03 4 SNES Function norm 2.493444656346e-03 5 SNES Function norm 5.180475798178e-04 6 SNES Function norm 4.166251801170e-04 7 SNES Function norm 3.066582000814e-04 8 SNES Function norm 2.189666367666e-04 9 SNES Function norm 1.354684191244e-04 10 SNES Function norm 1.287520392923e-04 11 SNES Function norm 1.286080621054e-04 12 SNES Function norm 1.285437650356e-04 13 SNES Function norm 1.284168806812e-04 14 SNES Function norm 1.283833115348e-04 15 SNES Function norm 1.283700090330e-04 16 SNES Function norm 1.283691578788e-04 17 SNES Function norm 1.283486627334e-04 18 SNES Function norm 1.283349991927e-04 19 SNES Function norm 1.283332060308e-04 20 SNES Function norm 1.283026682165e-04 21 SNES Function norm 1.282981662835e-04 22 SNES Function norm 1.282944044720e-04 23 SNES Function norm 1.282831861627e-04 24 SNES Function norm 1.282754274487e-04 25 SNES Function norm 1.282754274487e-04 26 SNES Function norm 1.282754274487e-04 27 SNES Function norm 1.282754274487e-04 28 SNES Function norm 1.282754274487e-04 29 SNES Function norm 1.282754274487e-04 30 SNES Function norm 1.282754274487e-04 31 SNES Function norm 1.282754274487e-04 32 SNES Function norm 1.282754274487e-04 33 SNES Function norm 1.282754274487e-04 34 SNES Function norm 1.282754274487e-04 35 SNES Function norm 1.282754274487e-04 36 SNES Function norm 1.282754274487e-04 37 SNES Function norm 1.282754274487e-04 38 SNES Function norm 1.282754274487e-04 39 SNES Function norm 1.282754274487e-04 40 SNES Function norm 1.282754274487e-04 41 SNES Function norm 1.282754274487e-04 42 SNES Function norm 1.282754274487e-04 43 SNES Function norm 1.282754274487e-04 44 SNES Function norm 1.282754274487e-04 45 SNES Function norm 1.282754274487e-04 46 SNES Function norm 1.282754274487e-04 47 SNES Function norm 1.282754274487e-04 48 SNES Function norm 1.282754274487e-04 49 SNES Function norm 1.282754274487e-04 50 SNES Function norm 1.282754274487e-04 Thanks a lot! -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From knepley at gmail.com Tue Feb 9 12:25:39 2010 From: knepley at gmail.com (Matthew Knepley) Date: Tue, 9 Feb 2010 12:25:39 -0600 Subject: [petsc-users] What could be the reason for a convergence history like this one? In-Reply-To: <20100209132122.cdvunfbi80swg08g@cubmail.cc.columbia.edu> References: <20100209132122.cdvunfbi80swg08g@cubmail.cc.columbia.edu> Message-ID: Did you try checking your Jacobian using -snes_mf? Matt On Tue, Feb 9, 2010 at 12:21 PM, (Rebecca) Xuefei YUAN wrote: > Hi, > > The SNES convergence history shows the residual increases or stop > decreasing starting at some iteration. I ran two different cases for the > same code, and the history looks similar, what could be wrong with the code? > > Thanks very much! > > Case 1: > 0 SNES Function norm 9.593111354483e-01 > 1 SNES Function norm 1.233321371555e-01 > 2 SNES Function norm 2.926382110614e-02 > 3 SNES Function norm 2.091318748212e-02 > 4 SNES Function norm 1.047907743570e-02 > 5 SNES Function norm 4.462043675959e-03 > 6 SNES Function norm 1.851050848655e-03 > 7 SNES Function norm 4.417550480988e-04 > 8 SNES Function norm 1.736388356513e-04 > 9 SNES Function norm 6.300414578098e-05 > 10 SNES Function norm 1.929829710585e-05 > 11 SNES Function norm 1.506367625001e-05 > 12 SNES Function norm 1.480567720594e-05 > 13 SNES Function norm 1.470754287980e-05 > 14 SNES Function norm 1.461728595512e-05 > 15 SNES Function norm 1.453616609384e-05 > 16 SNES Function norm 1.441040320141e-05 > 17 SNES Function norm 1.402352953635e-05 > 18 SNES Function norm 1.343005745899e-05 > 19 SNES Function norm 1.328043697395e-05 > 20 SNES Function norm 1.327501784736e-05 > 21 SNES Function norm 1.327431008405e-05 > 22 SNES Function norm 1.327343169426e-05 > 23 SNES Function norm 1.327273768560e-05 > 24 SNES Function norm 1.327185496127e-05 > 25 SNES Function norm 1.327119625499e-05 > 26 SNES Function norm 1.327071509157e-05 > 27 SNES Function norm 1.327038695378e-05 > 28 SNES Function norm 1.326990549326e-05 > 29 SNES Function norm 1.326917602672e-05 > 30 SNES Function norm 1.326830723835e-05 > 31 SNES Function norm 1.326796002362e-05 > 32 SNES Function norm 1.326777827731e-05 > 33 SNES Function norm 1.326755622116e-05 > 34 SNES Function norm 1.326732752144e-05 > 35 SNES Function norm 1.326698050145e-05 > 36 SNES Function norm 1.326640877572e-05 > 37 SNES Function norm 1.326587074902e-05 > 38 SNES Function norm 1.326573931166e-05 > 39 SNES Function norm 1.326564241601e-05 > 40 SNES Function norm 1.326548432075e-05 > 41 SNES Function norm 1.326531590041e-05 > 42 SNES Function norm 1.326531590043e-05 > 43 SNES Function norm 1.326531590045e-05 > 44 SNES Function norm 1.326531590044e-05 > 45 SNES Function norm 1.326531590044e-05 > 46 SNES Function norm 1.326531590043e-05 > 47 SNES Function norm 1.326531590045e-05 > 48 SNES Function norm 1.326531590044e-05 > 49 SNES Function norm 1.326531590046e-05 > 50 SNES Function norm 1.326531590046e-05 > Nonlinear solve did not converge due to DIVERGED_MAX_IT > > case 2: > 0 SNES Function norm 1.489006328086e+00 > 1 SNES Function norm 1.044141602147e-01 > 2 SNES Function norm 2.662563646189e-02 > 3 SNES Function norm 5.764005178654e-03 > 4 SNES Function norm 2.493444656346e-03 > 5 SNES Function norm 5.180475798178e-04 > 6 SNES Function norm 4.166251801170e-04 > 7 SNES Function norm 3.066582000814e-04 > 8 SNES Function norm 2.189666367666e-04 > 9 SNES Function norm 1.354684191244e-04 > 10 SNES Function norm 1.287520392923e-04 > 11 SNES Function norm 1.286080621054e-04 > 12 SNES Function norm 1.285437650356e-04 > 13 SNES Function norm 1.284168806812e-04 > 14 SNES Function norm 1.283833115348e-04 > 15 SNES Function norm 1.283700090330e-04 > 16 SNES Function norm 1.283691578788e-04 > 17 SNES Function norm 1.283486627334e-04 > 18 SNES Function norm 1.283349991927e-04 > 19 SNES Function norm 1.283332060308e-04 > 20 SNES Function norm 1.283026682165e-04 > 21 SNES Function norm 1.282981662835e-04 > 22 SNES Function norm 1.282944044720e-04 > 23 SNES Function norm 1.282831861627e-04 > 24 SNES Function norm 1.282754274487e-04 > 25 SNES Function norm 1.282754274487e-04 > 26 SNES Function norm 1.282754274487e-04 > 27 SNES Function norm 1.282754274487e-04 > 28 SNES Function norm 1.282754274487e-04 > 29 SNES Function norm 1.282754274487e-04 > 30 SNES Function norm 1.282754274487e-04 > 31 SNES Function norm 1.282754274487e-04 > 32 SNES Function norm 1.282754274487e-04 > 33 SNES Function norm 1.282754274487e-04 > 34 SNES Function norm 1.282754274487e-04 > 35 SNES Function norm 1.282754274487e-04 > 36 SNES Function norm 1.282754274487e-04 > 37 SNES Function norm 1.282754274487e-04 > 38 SNES Function norm 1.282754274487e-04 > 39 SNES Function norm 1.282754274487e-04 > 40 SNES Function norm 1.282754274487e-04 > 41 SNES Function norm 1.282754274487e-04 > 42 SNES Function norm 1.282754274487e-04 > 43 SNES Function norm 1.282754274487e-04 > 44 SNES Function norm 1.282754274487e-04 > 45 SNES Function norm 1.282754274487e-04 > 46 SNES Function norm 1.282754274487e-04 > 47 SNES Function norm 1.282754274487e-04 > 48 SNES Function norm 1.282754274487e-04 > 49 SNES Function norm 1.282754274487e-04 > 50 SNES Function norm 1.282754274487e-04 > > Thanks a lot! > > -- > (Rebecca) Xuefei YUAN > Department of Applied Physics and Applied Mathematics > Columbia University > Tel:917-399-8032 > www.columbia.edu/~xy2102 > > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59A2.org Tue Feb 9 12:27:58 2010 From: jed at 59A2.org (Jed Brown) Date: Tue, 09 Feb 2010 19:27:58 +0100 Subject: [petsc-users] What could be the reason for a convergence history like this one? In-Reply-To: <20100209132122.cdvunfbi80swg08g@cubmail.cc.columbia.edu> References: <20100209132122.cdvunfbi80swg08g@cubmail.cc.columbia.edu> Message-ID: <87wrymqn69.fsf@59A2.org> On Tue, 09 Feb 2010 13:21:22 -0500, "(Rebecca) Xuefei YUAN" wrote: > Hi, > > The SNES convergence history shows the residual increases or stop > decreasing starting at some iteration. I ran two different cases for > the same code, and the history looks similar, what could be wrong with > the code? Perhaps a wrong or low-accuracy Jacobian? Are you using an analytic Jacobian? Does the history change if you tighten the linear solve tolerance? If the system is very ill-conditioned, you might only be able to converge this far. Jed From xy2102 at columbia.edu Tue Feb 9 12:29:57 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Tue, 09 Feb 2010 13:29:57 -0500 Subject: [petsc-users] What is the difference between these two approaches? In-Reply-To: <57B9AD70-0112-4A51-8D38-FE32B4396702@mcs.anl.gov> References: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> <20100208162428.iyy2r612oswo88k4@cubmail.cc.columbia.edu> <57B9AD70-0112-4A51-8D38-FE32B4396702@mcs.anl.gov> Message-ID: <20100209132957.h6wydfuirggck4sc@cubmail.cc.columbia.edu> Dear Barry, Yes, I checked the convergence reason by -snes_converged_reason in the option file, however, the residual's behavior looks it starts to decrease, and at some point, it stops to decrease for some case, it starts to increase for some other case. If I set -snes_rtol to be a bigger number, it convergences due to this rtol. For example, -snes_rtol 1e-4, then 0 SNES Function norm 1.489006328086e+00 1 SNES Function norm 1.044141602147e-01 2 SNES Function norm 2.662563646189e-02 3 SNES Function norm 5.764005178654e-03 4 SNES Function norm 2.493444656346e-03 5 SNES Function norm 5.180475798178e-04 6 SNES Function norm 4.166251801170e-04 7 SNES Function norm 3.066582000814e-04 8 SNES Function norm 2.189666367666e-04 9 SNES Function norm 1.354684191244e-04 Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE However, if increase -snes_rtol 1e-5, then 0 SNES Function norm 1.489006328086e+00 1 SNES Function norm 1.044141602147e-01 2 SNES Function norm 2.662563646189e-02 3 SNES Function norm 5.764005178654e-03 4 SNES Function norm 2.493444656346e-03 5 SNES Function norm 5.180475798178e-04 6 SNES Function norm 4.166251801170e-04 7 SNES Function norm 3.066582000814e-04 8 SNES Function norm 2.189666367666e-04 9 SNES Function norm 1.354684191244e-04 10 SNES Function norm 1.287520392923e-04 11 SNES Function norm 1.286080621054e-04 12 SNES Function norm 1.285437650356e-04 13 SNES Function norm 1.284168806812e-04 14 SNES Function norm 1.283833115348e-04 15 SNES Function norm 1.283700090330e-04 16 SNES Function norm 1.283691578788e-04 17 SNES Function norm 1.283486627334e-04 18 SNES Function norm 1.283349991927e-04 19 SNES Function norm 1.283332060308e-04 20 SNES Function norm 1.283026682165e-04 21 SNES Function norm 1.282981662835e-04 22 SNES Function norm 1.282944044720e-04 23 SNES Function norm 1.282831861627e-04 24 SNES Function norm 1.282754274487e-04 25 SNES Function norm 1.282754274487e-04 26 SNES Function norm 1.282754274487e-04 27 SNES Function norm 1.282754274487e-04 28 SNES Function norm 1.282754274487e-04 29 SNES Function norm 1.282754274487e-04 30 SNES Function norm 1.282754274487e-04 31 SNES Function norm 1.282754274487e-04 32 SNES Function norm 1.282754274487e-04 33 SNES Function norm 1.282754274487e-04 34 SNES Function norm 1.282754274487e-04 35 SNES Function norm 1.282754274487e-04 36 SNES Function norm 1.282754274487e-04 37 SNES Function norm 1.282754274487e-04 38 SNES Function norm 1.282754274487e-04 39 SNES Function norm 1.282754274487e-04 40 SNES Function norm 1.282754274487e-04 41 SNES Function norm 1.282754274487e-04 42 SNES Function norm 1.282754274487e-04 43 SNES Function norm 1.282754274487e-04 44 SNES Function norm 1.282754274487e-04 45 SNES Function norm 1.282754274487e-04 46 SNES Function norm 1.282754274487e-04 47 SNES Function norm 1.282754274487e-04 48 SNES Function norm 1.282754274487e-04 49 SNES Function norm 1.282754274487e-04 50 SNES Function norm 1.282754274487e-04 Nonlinear solve did not converge due to DIVERGED_MAX_IT The other set of code (the latter approach of updating parameter c after each Newton iteration) convergences according to the function norm, i.e., I set the function norm less then 1e-9 to be the stop condition for the iteration, the residual history looks like:(with -snes_max_it 1 and -ksp_max_it 1): 0 SNES Function norm 7.717021407156e-02 1 SNES Function norm 6.111417737487e-02 0 SNES Function norm 3.733238293683e-02 1 SNES Function norm 8.377847092603e-03 0 SNES Function norm 8.296990448940e-03 1 SNES Function norm 5.550720142243e-03 0 SNES Function norm 5.548075287497e-03 1 SNES Function norm 4.362188843062e-03 0 SNES Function norm 4.432680688316e-03 1 SNES Function norm 3.690367229854e-03 0 SNES Function norm 3.744073313319e-03 1 SNES Function norm 3.172374307619e-03 0 SNES Function norm 3.228692603156e-03 1 SNES Function norm 2.768491914917e-03 0 SNES Function norm 2.805475765372e-03 1 SNES Function norm 2.443058872604e-03 0 SNES Function norm 2.478166623393e-03 1 SNES Function norm 2.177390149448e-03 0 SNES Function norm 2.202793639982e-03 1 SNES Function norm 1.945388110780e-03 0 SNES Function norm 1.967623718733e-03 1 SNES Function norm 1.768354048299e-03 0 SNES Function norm 1.785161018750e-03 1 SNES Function norm 1.589282214337e-03 0 SNES Function norm 1.604233657428e-03 1 SNES Function norm 1.463109964867e-03 0 SNES Function norm 1.473621854115e-03 1 SNES Function norm 1.317683163196e-03 0 SNES Function norm 1.328244229217e-03 1 SNES Function norm 1.215003775725e-03 0 SNES Function norm 1.221493864986e-03 1 SNES Function norm 1.096103543280e-03 0 SNES Function norm 1.103290905401e-03 1 SNES Function norm 1.005123217409e-03 0 SNES Function norm 1.009213742284e-03 1 SNES Function norm 9.155541951786e-04 0 SNES Function norm 9.201532654579e-04 1 SNES Function norm 8.375621763232e-04 0 SNES Function norm 8.403223094472e-04 1 SNES Function norm 7.740512468428e-04 0 SNES Function norm 7.770309975336e-04 1 SNES Function norm 7.108767243888e-04 0 SNES Function norm 7.129961739179e-04 1 SNES Function norm 6.627822760985e-04 0 SNES Function norm 6.647704113358e-04 1 SNES Function norm 6.102764040974e-04 0 SNES Function norm 6.120878163655e-04 1 SNES Function norm 5.699965969158e-04 0 SNES Function norm 5.713568735112e-04 1 SNES Function norm 5.238319694499e-04 0 SNES Function norm 5.254267350528e-04 1 SNES Function norm 4.876335564413e-04 0 SNES Function norm 4.885813237453e-04 1 SNES Function norm 4.455349473812e-04 0 SNES Function norm 4.469016403610e-04 1 SNES Function norm 4.120292273962e-04 0 SNES Function norm 4.126963740317e-04 1 SNES Function norm 3.730935892417e-04 0 SNES Function norm 3.742035921654e-04 1 SNES Function norm 3.420872251073e-04 0 SNES Function norm 3.425616644714e-04 1 SNES Function norm 3.059197813915e-04 0 SNES Function norm 3.067544839203e-04 1 SNES Function norm 2.774938815805e-04 0 SNES Function norm 2.778376919811e-04 1 SNES Function norm 2.442552475791e-04 0 SNES Function norm 2.448004016612e-04 1 SNES Function norm 2.184761633902e-04 0 SNES Function norm 2.187330876710e-04 1 SNES Function norm 1.900832109865e-04 0 SNES Function norm 1.903976431705e-04 1 SNES Function norm 1.677037933375e-04 0 SNES Function norm 1.679017264216e-04 1 SNES Function norm 1.467922092287e-04 0 SNES Function norm 1.470523475274e-04 1 SNES Function norm 1.292017110780e-04 0 SNES Function norm 1.293538618528e-04 1 SNES Function norm 1.156400554749e-04 0 SNES Function norm 1.158835481497e-04 1 SNES Function norm 1.032479618658e-04 0 SNES Function norm 1.033618371681e-04 1 SNES Function norm 9.462170461214e-05 0 SNES Function norm 9.481016246011e-05 1 SNES Function norm 8.604985727215e-05 0 SNES Function norm 8.614114308797e-05 1 SNES Function norm 7.993983293367e-05 0 SNES Function norm 8.008092682120e-05 1 SNES Function norm 7.342117051587e-05 0 SNES Function norm 7.350619633433e-05 1 SNES Function norm 6.862434880733e-05 0 SNES Function norm 6.873247656567e-05 1 SNES Function norm 6.319354549414e-05 0 SNES Function norm 6.328188603651e-05 1 SNES Function norm 5.903764019463e-05 0 SNES Function norm 5.912157652582e-05 1 SNES Function norm 5.416427286073e-05 0 SNES Function norm 5.425641264091e-05 1 SNES Function norm 5.029527375088e-05 0 SNES Function norm 5.035948681832e-05 1 SNES Function norm 4.581169399883e-05 0 SNES Function norm 4.589868067016e-05 1 SNES Function norm 4.214311333883e-05 0 SNES Function norm 4.219046237102e-05 1 SNES Function norm 3.815294777386e-05 0 SNES Function norm 3.822539926375e-05 1 SNES Function norm 3.480343288836e-05 0 SNES Function norm 3.483833519265e-05 1 SNES Function norm 3.142421956990e-05 0 SNES Function norm 3.148153758297e-05 1 SNES Function norm 2.853812371563e-05 0 SNES Function norm 2.856622223078e-05 1 SNES Function norm 2.580597673185e-05 0 SNES Function norm 2.585080224147e-05 1 SNES Function norm 2.343181094997e-05 0 SNES Function norm 2.345661769786e-05 1 SNES Function norm 2.129192093527e-05 0 SNES Function norm 2.132678741107e-05 1 SNES Function norm 1.936620692664e-05 0 SNES Function norm 1.938876254006e-05 1 SNES Function norm 1.774407873346e-05 0 SNES Function norm 1.777159702038e-05 1 SNES Function norm 1.619616581487e-05 0 SNES Function norm 1.621660773371e-05 1 SNES Function norm 1.500307362210e-05 0 SNES Function norm 1.502516240372e-05 1 SNES Function norm 1.377015977907e-05 0 SNES Function norm 1.378907926176e-05 1 SNES Function norm 1.286144826667e-05 0 SNES Function norm 1.287902603249e-05 1 SNES Function norm 1.184092829687e-05 0 SNES Function norm 1.185929534223e-05 1 SNES Function norm 1.108533648387e-05 0 SNES Function norm 1.109921082013e-05 1 SNES Function norm 1.017627166789e-05 0 SNES Function norm 1.019464063203e-05 1 SNES Function norm 9.483105761759e-06 0 SNES Function norm 9.494189662930e-06 1 SNES Function norm 8.620574747139e-06 0 SNES Function norm 8.638437484416e-06 1 SNES Function norm 7.938611071339e-06 0 SNES Function norm 7.947641807035e-06 1 SNES Function norm 7.119414178340e-06 0 SNES Function norm 7.134948452805e-06 1 SNES Function norm 6.448591686742e-06 0 SNES Function norm 6.455968088393e-06 1 SNES Function norm 5.740879455308e-06 0 SNES Function norm 5.752400340404e-06 1 SNES Function norm 5.139183976720e-06 0 SNES Function norm 5.145019054494e-06 1 SNES Function norm 4.603796908518e-06 0 SNES Function norm 4.611764520665e-06 1 SNES Function norm 4.127148087825e-06 0 SNES Function norm 4.131642100973e-06 1 SNES Function norm 3.748254813472e-06 0 SNES Function norm 3.754172511054e-06 1 SNES Function norm 3.393357883197e-06 0 SNES Function norm 3.397020453407e-06 1 SNES Function norm 3.122863568921e-06 0 SNES Function norm 3.127643288444e-06 1 SNES Function norm 2.856268473436e-06 0 SNES Function norm 2.859601467528e-06 1 SNES Function norm 2.652256663270e-06 0 SNES Function norm 2.656159693713e-06 1 SNES Function norm 2.441913463343e-06 0 SNES Function norm 2.445150284738e-06 1 SNES Function norm 2.278344482242e-06 0 SNES Function norm 2.281486712130e-06 1 SNES Function norm 2.103029318045e-06 0 SNES Function norm 2.106211386567e-06 1 SNES Function norm 1.964331371156e-06 0 SNES Function norm 1.966849759503e-06 1 SNES Function norm 1.810696243204e-06 0 SNES Function norm 1.813785966515e-06 1 SNES Function norm 1.687354052170e-06 0 SNES Function norm 1.689386040768e-06 1 SNES Function norm 1.547482290888e-06 0 SNES Function norm 1.550386298970e-06 1 SNES Function norm 1.433822659267e-06 0 SNES Function norm 1.435480702989e-06 1 SNES Function norm 1.304555798094e-06 0 SNES Function norm 1.307111860772e-06 1 SNES Function norm 1.198046210916e-06 0 SNES Function norm 1.199411732087e-06 1 SNES Function norm 1.081422595634e-06 0 SNES Function norm 1.083449028051e-06 1 SNES Function norm 9.830968831830e-07 0 SNES Function norm 9.842234251113e-07 1 SNES Function norm 8.855086519428e-07 0 SNES Function norm 8.869842518810e-07 1 SNES Function norm 7.998731801674e-07 0 SNES Function norm 8.007990235925e-07 1 SNES Function norm 7.261195998741e-07 0 SNES Function norm 7.272386389219e-07 1 SNES Function norm 6.574742981359e-07 0 SNES Function norm 6.582469160706e-07 1 SNES Function norm 6.046480447427e-07 0 SNES Function norm 6.055573171444e-07 1 SNES Function norm 5.521066971361e-07 0 SNES Function norm 5.527888427820e-07 1 SNES Function norm 5.131591511130e-07 0 SNES Function norm 5.138950161970e-07 1 SNES Function norm 4.719916657893e-07 0 SNES Function norm 4.726374514023e-07 1 SNES Function norm 4.410501843165e-07 0 SNES Function norm 4.416397978779e-07 1 SNES Function norm 4.066796284857e-07 0 SNES Function norm 4.073201314750e-07 1 SNES Function norm 3.800588432508e-07 0 SNES Function norm 3.805341734658e-07 1 SNES Function norm 3.494803569141e-07 0 SNES Function norm 3.501194890697e-07 1 SNES Function norm 3.250809122116e-07 0 SNES Function norm 3.254677908094e-07 1 SNES Function norm 2.968453459532e-07 0 SNES Function norm 2.974534491508e-07 1 SNES Function norm 2.737284114974e-07 0 SNES Function norm 2.740438823187e-07 1 SNES Function norm 2.478456871489e-07 0 SNES Function norm 2.483645693917e-07 1 SNES Function norm 2.261452863210e-07 0 SNES Function norm 2.264003858477e-07 1 SNES Function norm 2.037375639177e-07 0 SNES Function norm 2.041250205393e-07 1 SNES Function norm 1.844336993973e-07 0 SNES Function norm 1.846388464984e-07 1 SNES Function norm 1.665561229407e-07 0 SNES Function norm 1.668317015767e-07 1 SNES Function norm 1.506074213941e-07 0 SNES Function norm 1.507759225050e-07 1 SNES Function norm 1.371509852846e-07 0 SNES Function norm 1.373607632193e-07 1 SNES Function norm 1.246350412183e-07 0 SNES Function norm 1.247799653796e-07 1 SNES Function norm 1.146317945607e-07 0 SNES Function norm 1.148014097677e-07 1 SNES Function norm 1.048970461324e-07 0 SNES Function norm 1.050273062955e-07 1 SNES Function norm 9.728994148805e-08 0 SNES Function norm 9.742878188548e-08 1 SNES Function norm 8.953149842139e-08 0 SNES Function norm 8.965265435783e-08 1 SNES Function norm 8.349355443445e-08 0 SNES Function norm 8.360692993720e-08 1 SNES Function norm 7.704171483543e-08 0 SNES Function norm 7.715744371062e-08 1 SNES Function norm 7.198648220355e-08 0 SNES Function norm 7.207905483442e-08 1 SNES Function norm 6.635311896719e-08 0 SNES Function norm 6.646499679894e-08 1 SNES Function norm 6.187810314215e-08 0 SNES Function norm 6.195398983492e-08 1 SNES Function norm 5.674875032243e-08 0 SNES Function norm 5.685486601093e-08 1 SNES Function norm 5.259944647671e-08 0 SNES Function norm 5.266190700744e-08 1 SNES Function norm 4.785449692104e-08 0 SNES Function norm 4.794837111572e-08 1 SNES Function norm 4.393045881356e-08 0 SNES Function norm 4.398179420191e-08 1 SNES Function norm 3.968091389600e-08 0 SNES Function norm 3.975482816426e-08 1 SNES Function norm 3.606342738908e-08 0 SNES Function norm 3.610526397501e-08 1 SNES Function norm 3.255782266572e-08 0 SNES Function norm 3.261156160535e-08 1 SNES Function norm 2.945105435165e-08 0 SNES Function norm 2.948506400165e-08 1 SNES Function norm 2.679623999374e-08 0 SNES Function norm 2.683697251398e-08 1 SNES Function norm 2.432172702302e-08 0 SNES Function norm 2.435014022093e-08 1 SNES Function norm 2.237476284926e-08 0 SNES Function norm 2.240761160898e-08 1 SNES Function norm 2.046076378161e-08 0 SNES Function norm 2.048590336946e-08 1 SNES Function norm 1.899524939086e-08 0 SNES Function norm 1.902205828524e-08 1 SNES Function norm 1.748029937398e-08 0 SNES Function norm 1.750388519879e-08 1 SNES Function norm 1.631350242595e-08 0 SNES Function norm 1.633531042890e-08 1 SNES Function norm 1.505288235008e-08 0 SNES Function norm 1.507584733947e-08 1 SNES Function norm 1.406371795784e-08 0 SNES Function norm 1.408147204135e-08 1 SNES Function norm 1.295795371266e-08 0 SNES Function norm 1.298044339805e-08 1 SNES Function norm 1.207172419139e-08 0 SNES Function norm 1.208623562537e-08 1 SNES Function norm 1.106461098693e-08 0 SNES Function norm 1.108589395563e-08 1 SNES Function norm 1.024093176467e-08 0 SNES Function norm 1.025282405427e-08 1 SNES Function norm 9.317154310806e-09 0 SNES Function norm 9.335705617465e-09 1 SNES Function norm 8.546378037366e-09 0 SNES Function norm 8.556114445692e-09 1 SNES Function norm 7.727731739813e-09 0 SNES Function norm 7.742145917713e-09 1 SNES Function norm 7.028362105076e-09 0 SNES Function norm 7.036321531561e-09 1 SNES Function norm 6.351075907560e-09 0 SNES Function norm 6.361474639652e-09 1 SNES Function norm 5.753600250314e-09 0 SNES Function norm 5.760151521862e-09 1 SNES Function norm 5.230710679558e-09 0 SNES Function norm 5.238484540351e-09 1 SNES Function norm 4.749699735905e-09 0 SNES Function norm 4.755217760576e-09 1 SNES Function norm 4.359624605577e-09 0 SNES Function norm 4.365869441452e-09 1 SNES Function norm 3.983041709191e-09 0 SNES Function norm 3.987871881819e-09 1 SNES Function norm 3.689365356157e-09 0 SNES Function norm 3.694508917556e-09 1 SNES Function norm 3.391304202711e-09 0 SNES Function norm 3.395725403389e-09 1 SNES Function norm 3.160907020838e-09 0 SNES Function norm 3.165126817268e-09 1 SNES Function norm 2.915632749525e-09 0 SNES Function norm 2.919833945934e-09 1 SNES Function norm 2.724266923173e-09 0 SNES Function norm 2.727713954716e-09 1 SNES Function norm 2.512048579425e-09 0 SNES Function norm 2.516107605158e-09 1 SNES Function norm 2.343538962473e-09 0 SNES Function norm 2.346358391243e-09 1 SNES Function norm 2.151715111446e-09 0 SNES Function norm 2.155564435535e-09 1 SNES Function norm 1.996270578628e-09 0 SNES Function norm 1.998582174740e-09 1 SNES Function norm 1.819648863872e-09 0 SNES Function norm 1.823054306503e-09 1 SNES Function norm 1.673366366984e-09 0 SNES Function norm 1.675257113041e-09 1 SNES Function norm 1.514690811552e-09 0 SNES Function norm 1.517365667098e-09 1 SNES Function norm 1.379822600175e-09 0 SNES Function norm 1.381356081290e-09 1 SNES Function norm 1.246754128122e-09 0 SNES Function norm 1.248653847053e-09 1 SNES Function norm 1.129672110055e-09 0 SNES Function norm 1.130910768553e-09 1 SNES Function norm 1.026516150323e-09 0 SNES Function norm 1.027895524425e-09 1 SNES Function norm 9.316425819832e-10 0 SNES Function norm 9.326629072544e-10 1 SNES Function norm 8.549121471438e-10 The initial residual is different in first approach and second approach because the first approach has another scalar residual function F2 besides F1, and the second approach only have one residual function F1. What could be wrong with the first approach history? Thanks a lot! Rebecca Quoting Barry Smith : > > If both on converging then there is something wrong with your > function evaluation code for one or both of the two approaches. Or > perhaps Newton is not actually converging and so you are getting an > unconverged (wrong) solution. Make sure you always call > SNESGetConvergedReason() to insure the nonlinear equations are actually > be solved. > > > Barry > > On Feb 8, 2010, at 3:24 PM, (Rebecca) Xuefei YUAN wrote: > >> That is also confusing me when running this bad example. The good >> examples have matched solutions, but this bad one does not. I do >> not know what is wrong and where is the difference coming from? >> >> >> >> >> Quoting Matthew Knepley : >> >>> I am confused by b). If they both converge, how can the answers be >>> different? >>> >>> Matt >>> >>> On Mon, Feb 8, 2010 at 3:13 PM, (Rebecca) Xuefei YUAN >>> wrote: >>> >>>> Dear all, >>>> >>>> I do have an PDE-constrained optimization problem: >>>> >>>> F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1) >>>> F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = 0 (2) >>>> >>>> where phi(x,y) is defined at each grid point and c is a scalar parameter >>>> that satisfying the equation (2). >>>> >>>> I have two pieces of codes to solve them by different approaches. >>>> >>>> The first approach is to use DMComposite() to manage unknowns and solve >>>> F1&F2 at the same time, and it calls DMMGSolve() once. >>>> >>>> The second approach is to solve F1 with a guess c for some number(i.e. 1) >>>> times of nonlinear and linear iteration, and then update c from >>>> F2. Solve F1 >>>> again with updated c till some conditions satisfied, for example, >>>> >>>> if (cres<1e-10){CONTINUE=PETSC_FALSE;} // update on c >>>> if (functionNorm<1e-10){CONTINUE=PETSC_FALSE;}//residual function norm >>>> if (reason>0){CONTINUE=PETSC_FALSE;}//snes_converged_reason >>>> if (totalNumberOfNonlinearIterations>50){CONTINUE=PETSC_FALSE;} >>>> >>>> In this approach, DMMGSolve() was called more than once. >>>> >>>> Although these two approaches convergence, the results are quite >>>> different. >>>> >>>> My understanding is that >>>> a) approach one updates c in each linear iteration, but approach two >>>> updates c >>>> only after several (i.e. 1) nonlinear iterations. >>>> >>>> ierr = DMMGSolve(dmmg);CHKERRQ(ierr); >>>> parameters->c = parameters->integration/area; >>>> >>>> b) the results from two approaches should be the same or very >>>> close to each >>>> other but due to some reasons, they are not. >>>> >>>> c) three different examples are tested by these two approaches, two are >>>> good, but one is bad. The bad one is different from the other two because >>>> the solution has large gradient at some points. >>>> >>>> d) the shortcoming of approach one is PETSc has not ready for assemble a >>>> Jacobian for object DMComposite, so the second approach is able >>>> to write an >>>> analytic Jacobian. >>>> >>>> Any thoughts about how to debug or compare these two approaches is >>>> appreciate!~ >>>> >>>> >>>> Thanks a ton! >>>> >>>> Rebecca >>>> >>>> >>>> >>>> >>>> >>>> -- >>>> (Rebecca) Xuefei YUAN >>>> Department of Applied Physics and Applied Mathematics >>>> Columbia University >>>> Tel:917-399-8032 >>>> www.columbia.edu/~xy2102 >>>> >>>> >>> >>> >>> -- >>> 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 >>> >> >> >> >> -- >> (Rebecca) Xuefei YUAN >> Department of Applied Physics and Applied Mathematics >> Columbia University >> Tel:917-399-8032 >> www.columbia.edu/~xy2102 >> -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From xy2102 at columbia.edu Tue Feb 9 12:39:25 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Tue, 09 Feb 2010 13:39:25 -0500 Subject: [petsc-users] What could be the reason for a convergence history like this one? In-Reply-To: References: <20100209132122.cdvunfbi80swg08g@cubmail.cc.columbia.edu> Message-ID: <20100209133925.5rhl3p3lcs8wwko4@cubmail.cc.columbia.edu> Dear Matt, There is no analytic Jacobian in this code, and the history in the last thread was from -snes_mf(50 SNES Function norm 1.282754274487e-04). if I change this -snes_mf to -dmmg_jacobian_mf_fd(50 SNES Function norm 1.251867110549e-04), it seems could go farther, but after some iterations, the residual stops decreasing and becomes increasing again: 0 SNES Function norm 1.489006328086e+00 1 SNES Function norm 1.043276646550e-01 2 SNES Function norm 2.647531016073e-02 3 SNES Function norm 5.726158789720e-03 4 SNES Function norm 2.497853960325e-03 5 SNES Function norm 5.178505521812e-04 6 SNES Function norm 4.161124880646e-04 7 SNES Function norm 3.063079764249e-04 8 SNES Function norm 2.216203245831e-04 9 SNES Function norm 1.346446389755e-04 10 SNES Function norm 1.298929693823e-04 11 SNES Function norm 1.296352502362e-04 12 SNES Function norm 1.294010890218e-04 13 SNES Function norm 1.293158188978e-04 14 SNES Function norm 1.292537899035e-04 15 SNES Function norm 1.291882769093e-04 16 SNES Function norm 1.290900941440e-04 17 SNES Function norm 1.290650500805e-04 18 SNES Function norm 1.290064396106e-04 19 SNES Function norm 1.288121780049e-04 20 SNES Function norm 1.286415872476e-04 21 SNES Function norm 1.285583242966e-04 22 SNES Function norm 1.284369816260e-04 23 SNES Function norm 1.283315973569e-04 24 SNES Function norm 1.279868505371e-04 25 SNES Function norm 1.275988479887e-04 26 SNES Function norm 1.274802192747e-04 27 SNES Function norm 1.273256834679e-04 28 SNES Function norm 1.272894071688e-04 29 SNES Function norm 1.272080215426e-04 30 SNES Function norm 1.271850575230e-04 31 SNES Function norm 1.271715499728e-04 32 SNES Function norm 1.270966212068e-04 33 SNES Function norm 1.270621146091e-04 34 SNES Function norm 1.269027315361e-04 35 SNES Function norm 1.267506000983e-04 36 SNES Function norm 1.266693862935e-04 37 SNES Function norm 1.265241359123e-04 38 SNES Function norm 1.264402076307e-04 39 SNES Function norm 1.263630732412e-04 40 SNES Function norm 1.263228374417e-04 41 SNES Function norm 1.262265153181e-04 42 SNES Function norm 1.261886787880e-04 43 SNES Function norm 1.261879329103e-04 44 SNES Function norm 1.261838619067e-04 45 SNES Function norm 1.261818759514e-04 46 SNES Function norm 1.261810379326e-04 47 SNES Function norm 1.261795964495e-04 48 SNES Function norm 1.261780785438e-04 49 SNES Function norm 1.261775208833e-04 50 SNES Function norm 1.261774151048e-04 Nonlinear solve did not converge due to DIVERGED_MAX_IT rebecca at YuanWork:~/linux/code/twoway/twmgvggt/test/comp_oreggt6_twmgvggtnivex$ ./oreggt6.exe -options_file option_oreggt6 -loadbin 0 SNES Function norm 1.261774151048e-04 1 SNES Function norm 1.261771432171e-04 2 SNES Function norm 1.261763069424e-04 3 SNES Function norm 1.261720612263e-04 4 SNES Function norm 1.261404001592e-04 5 SNES Function norm 1.260149619260e-04 6 SNES Function norm 1.256432398293e-04 7 SNES Function norm 1.253451015765e-04 8 SNES Function norm 1.253182414538e-04 9 SNES Function norm 1.252819131702e-04 10 SNES Function norm 1.252738755369e-04 11 SNES Function norm 1.252632764516e-04 12 SNES Function norm 1.252566042921e-04 13 SNES Function norm 1.252526838492e-04 14 SNES Function norm 1.252485483438e-04 15 SNES Function norm 1.252449709435e-04 16 SNES Function norm 1.252416675394e-04 17 SNES Function norm 1.252362756882e-04 18 SNES Function norm 1.252324330089e-04 19 SNES Function norm 1.251957972997e-04 20 SNES Function norm 1.251926714223e-04 21 SNES Function norm 1.251912297445e-04 22 SNES Function norm 1.251910026775e-04 23 SNES Function norm 1.251903079400e-04 24 SNES Function norm 1.251897130474e-04 25 SNES Function norm 1.251890057526e-04 26 SNES Function norm 1.251886739317e-04 27 SNES Function norm 1.251886214966e-04 28 SNES Function norm 1.251883802081e-04 29 SNES Function norm 1.251883374146e-04 30 SNES Function norm 1.251880140622e-04 31 SNES Function norm 1.251876765348e-04 32 SNES Function norm 1.251876758034e-04 33 SNES Function norm 1.251875904308e-04 34 SNES Function norm 1.251874566739e-04 35 SNES Function norm 1.251867963213e-04 36 SNES Function norm 1.251867110525e-04 37 SNES Function norm 1.251867110526e-04 38 SNES Function norm 1.251867110526e-04 39 SNES Function norm 1.251867110526e-04 40 SNES Function norm 1.251867110527e-04 41 SNES Function norm 1.251867110527e-04 42 SNES Function norm 1.251867110527e-04 43 SNES Function norm 1.251867110528e-04 44 SNES Function norm 1.251867110528e-04 45 SNES Function norm 1.251867110528e-04 46 SNES Function norm 1.251867110529e-04 47 SNES Function norm 1.251867110529e-04 48 SNES Function norm 1.251867110530e-04 49 SNES Function norm 1.251867110530e-04 50 SNES Function norm 1.251867110530e-04 Nonlinear solve did not converge due to DIVERGED_MAX_IT rebecca at YuanWork:~/linux/code/twoway/twmgvggt/test/comp_oreggt6_twmgvggtnivex$ ./oreggt6.exe -options_file option_oreggt6 -loadbin 0 SNES Function norm 1.251867110530e-04 1 SNES Function norm 1.251867110531e-04 2 SNES Function norm 1.251867110531e-04 3 SNES Function norm 1.251867110532e-04 4 SNES Function norm 1.251867110532e-04 5 SNES Function norm 1.251867110532e-04 6 SNES Function norm 1.251867110533e-04 7 SNES Function norm 1.251867110533e-04 8 SNES Function norm 1.251867110534e-04 9 SNES Function norm 1.251867110533e-04 10 SNES Function norm 1.251867110534e-04 11 SNES Function norm 1.251867110534e-04 12 SNES Function norm 1.251867110535e-04 13 SNES Function norm 1.251867110535e-04 14 SNES Function norm 1.251867110536e-04 15 SNES Function norm 1.251867110536e-04 16 SNES Function norm 1.251867110536e-04 17 SNES Function norm 1.251867110537e-04 18 SNES Function norm 1.251867110537e-04 19 SNES Function norm 1.251867110538e-04 20 SNES Function norm 1.251867110538e-04 21 SNES Function norm 1.251867110539e-04 22 SNES Function norm 1.251867110539e-04 23 SNES Function norm 1.251867110539e-04 24 SNES Function norm 1.251867110539e-04 25 SNES Function norm 1.251867110540e-04 26 SNES Function norm 1.251867110540e-04 27 SNES Function norm 1.251867110541e-04 28 SNES Function norm 1.251867110541e-04 29 SNES Function norm 1.251867110541e-04 30 SNES Function norm 1.251867110541e-04 31 SNES Function norm 1.251867110542e-04 32 SNES Function norm 1.251867110542e-04 33 SNES Function norm 1.251867110543e-04 34 SNES Function norm 1.251867110543e-04 35 SNES Function norm 1.251867110544e-04 36 SNES Function norm 1.251867110544e-04 37 SNES Function norm 1.251867110545e-04 38 SNES Function norm 1.251867110545e-04 39 SNES Function norm 1.251867110545e-04 40 SNES Function norm 1.251867110546e-04 41 SNES Function norm 1.251867110546e-04 42 SNES Function norm 1.251867110546e-04 43 SNES Function norm 1.251867110547e-04 44 SNES Function norm 1.251867110547e-04 45 SNES Function norm 1.251867110548e-04 46 SNES Function norm 1.251867110548e-04 47 SNES Function norm 1.251867110548e-04 48 SNES Function norm 1.251867110548e-04 49 SNES Function norm 1.251867110549e-04 50 SNES Function norm 1.251867110549e-04 Nonlinear solve did not converge due to DIVERGED_MAX_IT Quoting Matthew Knepley : > Did you try checking your Jacobian using -snes_mf? > > Matt > > On Tue, Feb 9, 2010 at 12:21 PM, (Rebecca) Xuefei YUAN > wrote: > >> Hi, >> >> The SNES convergence history shows the residual increases or stop >> decreasing starting at some iteration. I ran two different cases for the >> same code, and the history looks similar, what could be wrong with the code? >> >> Thanks very much! >> >> Case 1: >> 0 SNES Function norm 9.593111354483e-01 >> 1 SNES Function norm 1.233321371555e-01 >> 2 SNES Function norm 2.926382110614e-02 >> 3 SNES Function norm 2.091318748212e-02 >> 4 SNES Function norm 1.047907743570e-02 >> 5 SNES Function norm 4.462043675959e-03 >> 6 SNES Function norm 1.851050848655e-03 >> 7 SNES Function norm 4.417550480988e-04 >> 8 SNES Function norm 1.736388356513e-04 >> 9 SNES Function norm 6.300414578098e-05 >> 10 SNES Function norm 1.929829710585e-05 >> 11 SNES Function norm 1.506367625001e-05 >> 12 SNES Function norm 1.480567720594e-05 >> 13 SNES Function norm 1.470754287980e-05 >> 14 SNES Function norm 1.461728595512e-05 >> 15 SNES Function norm 1.453616609384e-05 >> 16 SNES Function norm 1.441040320141e-05 >> 17 SNES Function norm 1.402352953635e-05 >> 18 SNES Function norm 1.343005745899e-05 >> 19 SNES Function norm 1.328043697395e-05 >> 20 SNES Function norm 1.327501784736e-05 >> 21 SNES Function norm 1.327431008405e-05 >> 22 SNES Function norm 1.327343169426e-05 >> 23 SNES Function norm 1.327273768560e-05 >> 24 SNES Function norm 1.327185496127e-05 >> 25 SNES Function norm 1.327119625499e-05 >> 26 SNES Function norm 1.327071509157e-05 >> 27 SNES Function norm 1.327038695378e-05 >> 28 SNES Function norm 1.326990549326e-05 >> 29 SNES Function norm 1.326917602672e-05 >> 30 SNES Function norm 1.326830723835e-05 >> 31 SNES Function norm 1.326796002362e-05 >> 32 SNES Function norm 1.326777827731e-05 >> 33 SNES Function norm 1.326755622116e-05 >> 34 SNES Function norm 1.326732752144e-05 >> 35 SNES Function norm 1.326698050145e-05 >> 36 SNES Function norm 1.326640877572e-05 >> 37 SNES Function norm 1.326587074902e-05 >> 38 SNES Function norm 1.326573931166e-05 >> 39 SNES Function norm 1.326564241601e-05 >> 40 SNES Function norm 1.326548432075e-05 >> 41 SNES Function norm 1.326531590041e-05 >> 42 SNES Function norm 1.326531590043e-05 >> 43 SNES Function norm 1.326531590045e-05 >> 44 SNES Function norm 1.326531590044e-05 >> 45 SNES Function norm 1.326531590044e-05 >> 46 SNES Function norm 1.326531590043e-05 >> 47 SNES Function norm 1.326531590045e-05 >> 48 SNES Function norm 1.326531590044e-05 >> 49 SNES Function norm 1.326531590046e-05 >> 50 SNES Function norm 1.326531590046e-05 >> Nonlinear solve did not converge due to DIVERGED_MAX_IT >> >> case 2: >> 0 SNES Function norm 1.489006328086e+00 >> 1 SNES Function norm 1.044141602147e-01 >> 2 SNES Function norm 2.662563646189e-02 >> 3 SNES Function norm 5.764005178654e-03 >> 4 SNES Function norm 2.493444656346e-03 >> 5 SNES Function norm 5.180475798178e-04 >> 6 SNES Function norm 4.166251801170e-04 >> 7 SNES Function norm 3.066582000814e-04 >> 8 SNES Function norm 2.189666367666e-04 >> 9 SNES Function norm 1.354684191244e-04 >> 10 SNES Function norm 1.287520392923e-04 >> 11 SNES Function norm 1.286080621054e-04 >> 12 SNES Function norm 1.285437650356e-04 >> 13 SNES Function norm 1.284168806812e-04 >> 14 SNES Function norm 1.283833115348e-04 >> 15 SNES Function norm 1.283700090330e-04 >> 16 SNES Function norm 1.283691578788e-04 >> 17 SNES Function norm 1.283486627334e-04 >> 18 SNES Function norm 1.283349991927e-04 >> 19 SNES Function norm 1.283332060308e-04 >> 20 SNES Function norm 1.283026682165e-04 >> 21 SNES Function norm 1.282981662835e-04 >> 22 SNES Function norm 1.282944044720e-04 >> 23 SNES Function norm 1.282831861627e-04 >> 24 SNES Function norm 1.282754274487e-04 >> 25 SNES Function norm 1.282754274487e-04 >> 26 SNES Function norm 1.282754274487e-04 >> 27 SNES Function norm 1.282754274487e-04 >> 28 SNES Function norm 1.282754274487e-04 >> 29 SNES Function norm 1.282754274487e-04 >> 30 SNES Function norm 1.282754274487e-04 >> 31 SNES Function norm 1.282754274487e-04 >> 32 SNES Function norm 1.282754274487e-04 >> 33 SNES Function norm 1.282754274487e-04 >> 34 SNES Function norm 1.282754274487e-04 >> 35 SNES Function norm 1.282754274487e-04 >> 36 SNES Function norm 1.282754274487e-04 >> 37 SNES Function norm 1.282754274487e-04 >> 38 SNES Function norm 1.282754274487e-04 >> 39 SNES Function norm 1.282754274487e-04 >> 40 SNES Function norm 1.282754274487e-04 >> 41 SNES Function norm 1.282754274487e-04 >> 42 SNES Function norm 1.282754274487e-04 >> 43 SNES Function norm 1.282754274487e-04 >> 44 SNES Function norm 1.282754274487e-04 >> 45 SNES Function norm 1.282754274487e-04 >> 46 SNES Function norm 1.282754274487e-04 >> 47 SNES Function norm 1.282754274487e-04 >> 48 SNES Function norm 1.282754274487e-04 >> 49 SNES Function norm 1.282754274487e-04 >> 50 SNES Function norm 1.282754274487e-04 >> >> Thanks a lot! >> >> -- >> (Rebecca) Xuefei YUAN >> Department of Applied Physics and Applied Mathematics >> Columbia University >> Tel:917-399-8032 >> www.columbia.edu/~xy2102 >> >> > > > -- > 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 > -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From xy2102 at columbia.edu Tue Feb 9 12:56:52 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Tue, 09 Feb 2010 13:56:52 -0500 Subject: [petsc-users] What is the difference between these two approaches? In-Reply-To: <87ljf3tnxl.fsf@59A2.org> References: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> <87ljf3tnxl.fsf@59A2.org> Message-ID: <20100209135652.antvy78ug0gwg88k@cubmail.cc.columbia.edu> Dear Jed, 'Perhaps a wrong or low-accuracy Jacobian? Are you using an analytic Jacobian? Does the history change if you tighten the linear solve tolerance? If the system is very ill-conditioned, you might only be able to converge this far.' There is no analytic Jacobian for this code(approach 1), so I ran with -snes_mf or -dmmg_jacobian_mf_fd options. Both give me similar behaviors of residual history. The problem is solved via approach 2, and the residual is able to go down as small as 1e-10. >> Dear all, >> >> I do have an PDE-constrained optimization problem: >> >> F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1) >> F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = 0 (2) >> >> where phi(x,y) is defined at each grid point and c is a scalar >> parameter that satisfying the equation (2). > > Is c the only parameter you are optimizing? What does your system look > like in "minimize functional subject to PDE" form? Yes, c is the only parameter. The "optimizing" shows up here because there is a parameter c in F1, and c satisfies F2. Actually I am solving F1 and need F2 to be satisfied, thus I can solve F1&F2 as in approach 1(in this case, F2 is not strictly satisfied) together or solve F1 first and then get c from F2 as in approach 2(in this case, F2 is strictly satisfied). >> I have two pieces of codes to solve them by different approaches. >> >> The first approach is to use DMComposite() to manage unknowns and >> solve F1&F2 at the same time, and it calls DMMGSolve() once. >> >> The second approach is to solve F1 with a guess c for some number(i.e. >> 1) times of nonlinear and linear iteration, and then update c from F2. >> Solve F1 again with updated c till some conditions satisfied, for >> example, > Perhaps the iteration has stagnated or found a different local minimum? Have you compared the objective functions? I thought about Null space for the problem. Because in approach 2, a constant vector is a null space of the solution, so I add ierr = DMMGSetNullSpace(dmmg, PETSC_TRUE, 0, PETSC_NULL);CHKERRQ(ierr); but for approach 1, I wrote a CreateNullSpace() as in ierr = DMMGSetNullSpace(dmmg, PETSC_FALSE, 1, CreateNullSpace);CHKERRQ(ierr); Will this be the source of difference? >> d) the shortcoming of approach one is PETSc has not ready for assemble >> a Jacobian for object DMComposite, so the second approach is able to >> write an analytic Jacobian. > > Does DMCompositeGetMatrix() not work for you? I tried DMCompositeGetMatrix() last July, the conversations are: Hi, I am working on an optimization problem, in which I would like to assemble a Jacobian matrix. Thus DMMGSetSNES(dmmg,FormFunction,FormJacobian) is called. In damgsnes.c:637, in calling DMGetMatrix(), it calls DMCompositeGetMatrix() where the temp matrix Atmp has been freed before it passes any information to J at pack.c:1722 and 1774. So after calling DMGetMatrix() in DMMGSetSNES, the stencil of the dmmg[i]->B has unchanged, i.e., (gdb) p dmmg[0]->B->stencil $107 = {dim = 0, dims = {0, 0, 0, 0}, starts = {0, 0, 0, 0}, noc = PETSC_FALSE} (gdb) where #0 DMMGSetSNES (dmmg=0x8856208, function=0x804c84f , jacobian=0x8052932 ) at damgsnes.c:641 #1 0x0804c246 in main (argc=Cannot access memory at address 0x0 ) at tworeggt.c:126 I compare this with http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/src/snes/examples/tutorials/ex18.c.html and it shows that the stencil has been carried out and passed to dmmg[0]->B as follows: (gdb) p dmmg[i]->B->stencil $80 = {dim = 2, dims = {5, 5, 1, 0}, starts = {0, 0, 0, 0}, noc = PETSC_TRUE} (gdb) where #0 DMMGSetSNES (dmmg=0x884b530, function=0x804c364 , jacobian=0x804d34d ) at damgsnes.c:642 #1 0x0804b969 in main (argc=Cannot access memory at address 0x2 ) at ex18.c:100 Because of this missing stencil of Jacobian matrix, I get the error code as follows: Program received signal SIGSEGV, Segmentation fault. 0x082447c2 in ISLocalToGlobalMappingApply (mapping=0x0, N=1, in=0xbff8f250, out=0xbff8ce14) at /home/rebecca/soft/petsc-3.0.0-p1/include/petscis.h:129 129 PetscInt i,*idx = mapping->indices,Nmax = mapping->n; (gdb) where #0 0x082447c2 in ISLocalToGlobalMappingApply (mapping=0x0, N=1, in=0xbff8f250, out=0xbff8ce14) at /home/rebecca/soft/petsc-3.0.0-p1/include/petscis.h:129 #1 0x0824440c in MatSetValuesLocal (mat=0x88825e8, nrow=1, irow=0xbff8f250, ncol=4, icol=0xbff8ee50, y=0xbff8f628, addv=INSERT_VALUES) at matrix.c:1583 #2 0x08240aae in MatSetValuesStencil (mat=0x88825e8, m=1, idxm=0xbff8f6b8, n=4, idxn=0xbff8f4b4, v=0xbff8f628, addv=INSERT_VALUES) at matrix.c:1099 #3 0x08053835 in FormJacobian (snes=0x8874700, X=0x8856778, J=0x88747d0, B=0x88747d4, flg=0xbff8f8d4, ptr=0x8856338) at tworeggt.c:937 #4 0x0805a5cf in DMMGComputeJacobian_Multigrid (snes=0x8874700, X=0x8856778, J=0x88747d0, B=0x88747d4, flag=0xbff8f8d4, ptr=0x8856208) at damgsnes.c:60 #5 0x0806b18a in SNESComputeJacobian (snes=0x8874700, X=0x8856778, A=0x88747d0, B=0x88747d4, flg=0xbff8f8d4) at snes.c:1111 #6 0x08084945 in SNESSolve_LS (snes=0x8874700) at ls.c:189 #7 0x08073198 in SNESSolve (snes=0x8874700, b=0x0, x=0x8856778) at snes.c:2221 #8 0x0805d5f9 in DMMGSolveSNES (dmmg=0x8856208, level=0) at damgsnes.c:510 #9 0x08056e38 in DMMGSolve (dmmg=0x8856208) at damg.c:372 #10 0x0804c3fe in main (argc=128, argv=0xbff90c04) at tworeggt.c:131 I think there might be a bug in DMCompositeGetMatrix(). And Barry said something about it as 'You cannot use the stencil operations to put values into a "composite matrix". The numbering of rows and columns of the composite matrix reflect all the different variables (unknowns) sp do not match what they are for a single component.' I did not quite get it at that time... Thanks so much! Rebecca > Jed > > -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From balay at mcs.anl.gov Tue Feb 9 13:02:03 2010 From: balay at mcs.anl.gov (Satish Balay) Date: Tue, 9 Feb 2010 13:02:03 -0600 (CST) Subject: [petsc-users] hypre-2.6b In-Reply-To: <5D6E0DF460ACF34C88644E1EA91DCD0D041A48BD@CFEXMBX.americas.cray.com> References: <5D6E0DF460ACF34C88644E1EA91DCD0D041A48BD@CFEXMBX.americas.cray.com> Message-ID: ok - updating petsc-dev [looks like replacing the tarball is sufficient] Satish On Tue, 9 Feb 2010, Keita Teranishi wrote: > Hi, > > I have just heard a new release of hypre-2.6b. Will PETSc support this new version? > > Thanks, > ================================ > Keita Teranishi > Scientific Library Group > Cray, Inc. > keita at cray.com > ================================ > > From xy2102 at columbia.edu Wed Feb 10 14:35:14 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Wed, 10 Feb 2010 15:35:14 -0500 Subject: [petsc-users] -snes_type test shows differences Message-ID: <20100210153514.en2nri9us4w04co4@cubmail.cc.columbia.edu> Hi,all, I was writing analytic Jacobian to my FormJacobian(). However, I found that there are quite big differences between finite difference Jacobian and hand coded Jacobian. To simply the problem, assume that I am solving a very simple equation as the residual function has the form of F = fxx*fyy - g. Where f is the unknown, g is the given r.h.s. The discretization scheme is the central difference, and therefore, in my FormFunction, fgrid[j][i].disp = ( + ihx1hy1*(grid[j][i+1].disp + grid[j][i-1].disp - 2*grid[j][i].disp)*(grid[j+1][i].disp + grid[j-1][i].disp - 2*grid[j][i].disp) ); for the interior points. The crosponding Jacobian has the form value[0] = 0.0; value[2] = 0.0; value[6] = 0.0; value[8] = 0.0; value[1] = ihx1hy1*(grid[j][i+1].disp + grid[j][i-1].disp - 2*grid[j][i].disp); value[3] = ihx1hy1*(grid[j+1][i].disp + grid[j-1][i].disp - 2*grid[j][i].disp); value[4] = -2*ihx1hy1*(grid[j][i+1].disp + grid[j][i-1].disp + grid[j+1][i].disp + grid[j-1][i].disp - 4*grid[j][i].disp); value[5] = ihx1hy1*(grid[j+1][i].disp + grid[j-1][i].disp - 2*grid[j][i].disp); value[7] = ihx1hy1*(grid[j][i+1].disp + grid[j][i-1].disp - 2*grid[j][i].disp); where {4} is the center point, {0,2,6,8} are corner pts and {1,3,5,7} are star pts, i.e, from left top to right bottom, the order is 0,1,2,3,...,7,8. The difference between finite difference Jac and hand coded Jac happens at value[4] where it is a nonlinear term (grid[j][i].disp) in the residual function. I test with -snes_type test -snes_test_display with different grid sizes as ratios and norms below. Differences and ratios increase as grid sizes increase. Did I have the hand coded Jacobian wrong? When grid size is 5x7: Norm of matrix ratio 1.58364e-05 difference 0.000322729 Norm of matrix ratio 2.57168e-05 difference 0.000162665 Norm of matrix ratio 2.57168e-05 difference 0.000162665 When grid size is 15x17: Norm of matrix ratio 0.000725401 difference 0.0385688 Norm of matrix ratio 0.00169032 difference 0.0185166 Norm of matrix ratio 0.00169032 difference 0.0185166 When grid size is 25x27: Norm of matrix ratio 0.00349658 difference 0.313173 Norm of matrix ratio 0.0105296 difference 0.148911 Norm of matrix ratio 0.0105296 difference 0.148911 When grid size is 35x37: Norm of matrix ratio 0.00969703 difference 1.22697 Norm of matrix ratio 0.0347181 difference 0.580945 Norm of matrix ratio 0.0347181 difference 0.580945 When grid size is 45x47: Norm of matrix ratio 0.0206974 difference 3.38781 Norm of matrix ratio 0.0843389 difference 1.60022 Norm of matrix ratio 0.0843389 difference 1.60022 Thanks very much! Rebecca From jed at 59A2.org Wed Feb 10 14:41:01 2010 From: jed at 59A2.org (Jed Brown) Date: Wed, 10 Feb 2010 21:41:01 +0100 Subject: [petsc-users] -snes_type test shows differences In-Reply-To: <20100210153514.en2nri9us4w04co4@cubmail.cc.columbia.edu> References: <20100210153514.en2nri9us4w04co4@cubmail.cc.columbia.edu> Message-ID: <87iqa4g6xu.fsf@59A2.org> On Wed, 10 Feb 2010 15:35:14 -0500, "(Rebecca) Xuefei YUAN" wrote: > Hi,all, > > I was writing analytic Jacobian to my FormJacobian(). However, I found > that there are quite big differences between finite difference > Jacobian and hand coded Jacobian. To simply the problem, assume that I > am solving a very simple equation as the residual function has the > form of > F = fxx*fyy - g. > Where f is the unknown, g is the given r.h.s. It looks like you have coded the Picard linearization. You want the Newton linearization J(f)h = fxx*hyy + hxx*fyy Jed From xy2102 at columbia.edu Wed Feb 10 14:48:57 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Wed, 10 Feb 2010 15:48:57 -0500 Subject: [petsc-users] -snes_type test shows differences In-Reply-To: <87iqa4g6xu.fsf@59A2.org> References: <20100210153514.en2nri9us4w04co4@cubmail.cc.columbia.edu> <87iqa4g6xu.fsf@59A2.org> Message-ID: <20100210154857.hqr56gexgkokc8o0@cubmail.cc.columbia.edu> Dear Jed, What if my F has the form(the full version): F(f) = fxx+fyy+fxx*fyy-fxy*fxy-g = 0, how should my Newton iteration look like? J(f)h = -F(f) = -(fxx+fyy+fxx*hyy+fyy*hxx-fxy*hxy-fxy*hxy-g)? I know h is the update, but what are hxx,hyy? Any more references on this? Thanks a lot! Rebecca Quoting Jed Brown : > On Wed, 10 Feb 2010 15:35:14 -0500, "(Rebecca) Xuefei YUAN" > wrote: >> Hi,all, >> >> I was writing analytic Jacobian to my FormJacobian(). However, I found >> that there are quite big differences between finite difference >> Jacobian and hand coded Jacobian. To simply the problem, assume that I >> am solving a very simple equation as the residual function has the >> form of >> F = fxx*fyy - g. >> Where f is the unknown, g is the given r.h.s. > > It looks like you have coded the Picard linearization. You want the > Newton linearization > > J(f)h = fxx*hyy + hxx*fyy > > Jed > > -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From jed at 59A2.org Wed Feb 10 16:11:14 2010 From: jed at 59A2.org (Jed Brown) Date: Wed, 10 Feb 2010 23:11:14 +0100 Subject: [petsc-users] -snes_type test shows differences In-Reply-To: <20100210154857.hqr56gexgkokc8o0@cubmail.cc.columbia.edu> References: <20100210153514.en2nri9us4w04co4@cubmail.cc.columbia.edu> <87iqa4g6xu.fsf@59A2.org> <20100210154857.hqr56gexgkokc8o0@cubmail.cc.columbia.edu> Message-ID: <87hbpog2rh.fsf@59A2.org> First, sorry for my off-hand comment. Looking at your code more carefully, it looks like you have the correct Newton linearization. Did you paste everything from the source? I assume the indexing is correct since you say it's only the diagonal value that's wrong. On Wed, 10 Feb 2010 15:48:57 -0500, "(Rebecca) Xuefei YUAN" wrote: > Dear Jed, > > What if my F has the form(the full version): > > F(f) = fxx+fyy+fxx*fyy-fxy*fxy-g = 0, > > how should my Newton iteration look like? > > J(f)h = -F(f) = -(fxx+fyy+fxx*hyy+fyy*hxx-fxy*hxy-fxy*hxy-g)? > > I know h is the update, but what are hxx,hyy? Those are derivatives of the update (which specify where things end up in your stencil). I find this quite error-prone to do by hand [1], but symbolic algebra can do it very well. As a simple example, name your points North, South, East, West, Center (N,S,E,W,C). Then the discretization for the original function looks like from sympy import * from sympy.abc import * # defines the 1-letter symbols NW,NE,SW,SE = symbols('NW','NE','SW','SE') # define symbols for the corner points fxx = (E+W-2*C)/h**2 fyy = (N+S-2*C)/h**2 fxy = ((NW-NE)/(2*h) - (SW-SE)/(2*h))/(2*h) F = (fxx + fyy + fxx*fyy - fxy*fxy) * h**2 # Final h**2 is just scaling Now you can get your Jacobian with [simplify(diff(F,sym)) for sym in [NW,N,NE,W,C,E,SW,S,SE]] which produces [(NE + SW - NW - SE)/(8*h**2), (E + W - 2*C + h**2)/h**2, (NW + SE - NE - SW)/(8*h**2), (N + S - 2*C + h**2)/h**2, (-2*E - 2*N - 2*S - 2*W + 8*C - 4*h**2)/h**2, (N + S - 2*C + h**2)/h**2, (NW + SE - NE - SW)/(8*h**2), (E + W - 2*C + h**2)/h**2, (NE + SW - NW - SE)/(8*h**2)] You can get sympy to actually write the C code by defining symbols as NW,N = symbols(['x[j+1][i-1].field','x[j+1][i].field']) # ... and using sympy.ccode(diff(F,sym)) to format the output. Since the Python code is so short, I often just paste it into the C code as a comment to make it easier to change the physics later. If you don't trust the compiler's CSE, you can get efficient representations using sympy.cse (in principle, more transformations are possible in the symbolic world). http://sympy.org Of course Maple/Mathematica/Maxima can also do this, but sympy is lightweight and free. I hope this helps. Jed [1] Error-prone for finite-difference methods. I think it's usually worth doing by hand for Galerkin methods because it can be done entirely in the continuum setting and gives you insight about the problem. From xy2102 at columbia.edu Wed Feb 10 18:04:05 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Wed, 10 Feb 2010 19:04:05 -0500 Subject: [petsc-users] -snes_type test shows differences In-Reply-To: <87hbpog2rh.fsf@59A2.org> References: <20100210153514.en2nri9us4w04co4@cubmail.cc.columbia.edu> <87iqa4g6xu.fsf@59A2.org> <20100210154857.hqr56gexgkokc8o0@cubmail.cc.columbia.edu> <87hbpog2rh.fsf@59A2.org> Message-ID: <20100210190405.er841aj80scsg8gw@cubmail.cc.columbia.edu> Dear Jed, Yes, I paste everything from the code, and it is only the value[4]([j,i]) wrong in the Jacobian. I tried several different initials for f, but I always had such differences at the same point. I doubt my analytic term for value[4] first, but I double checked and still cannot figure out what is wrong. Thanks very much for your kind reply! Cheers, Rebecca Quoting Jed Brown : > First, sorry for my off-hand comment. Looking at your code more > carefully, it looks like you have the correct Newton linearization. Did > you paste everything from the source? I assume the indexing is correct > since you say it's only the diagonal value that's wrong. > > On Wed, 10 Feb 2010 15:48:57 -0500, "(Rebecca) Xuefei YUAN" > wrote: >> Dear Jed, >> >> What if my F has the form(the full version): >> >> F(f) = fxx+fyy+fxx*fyy-fxy*fxy-g = 0, >> >> how should my Newton iteration look like? >> >> J(f)h = -F(f) = -(fxx+fyy+fxx*hyy+fyy*hxx-fxy*hxy-fxy*hxy-g)? >> >> I know h is the update, but what are hxx,hyy? > > Those are derivatives of the update (which specify where things end up > in your stencil). I find this quite error-prone to do by hand [1], but > symbolic algebra can do it very well. As a simple example, name your > points North, South, East, West, Center (N,S,E,W,C). Then the > discretization for the original function looks like > > from sympy import * > from sympy.abc import * # defines the 1-letter symbols > NW,NE,SW,SE = symbols('NW','NE','SW','SE') # define symbols for > the corner points > fxx = (E+W-2*C)/h**2 > fyy = (N+S-2*C)/h**2 > fxy = ((NW-NE)/(2*h) - (SW-SE)/(2*h))/(2*h) > F = (fxx + fyy + fxx*fyy - fxy*fxy) * h**2 # Final h**2 is just scaling > > Now you can get your Jacobian with > > [simplify(diff(F,sym)) for sym in [NW,N,NE,W,C,E,SW,S,SE]] > > which produces > > [(NE + SW - NW - SE)/(8*h**2), > (E + W - 2*C + h**2)/h**2, > (NW + SE - NE - SW)/(8*h**2), > (N + S - 2*C + h**2)/h**2, > (-2*E - 2*N - 2*S - 2*W + 8*C - 4*h**2)/h**2, > (N + S - 2*C + h**2)/h**2, > (NW + SE - NE - SW)/(8*h**2), > (E + W - 2*C + h**2)/h**2, > (NE + SW - NW - SE)/(8*h**2)] > > > You can get sympy to actually write the C code by defining symbols as > > NW,N = symbols(['x[j+1][i-1].field','x[j+1][i].field']) # ... > > and using sympy.ccode(diff(F,sym)) to format the output. Since the > Python code is so short, I often just paste it into the C code as a > comment to make it easier to change the physics later. If you don't > trust the compiler's CSE, you can get efficient representations using > sympy.cse (in principle, more transformations are possible in the > symbolic world). > > http://sympy.org > > Of course Maple/Mathematica/Maxima can also do this, but sympy is > lightweight and free. > > I hope this helps. > > > Jed > > [1] Error-prone for finite-difference methods. I think it's usually > worth doing by hand for Galerkin methods because it can be done entirely > in the continuum setting and gives you insight about the problem. > > -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From xy2102 at columbia.edu Wed Feb 10 20:41:47 2010 From: xy2102 at columbia.edu ((Rebecca) Xuefei YUAN) Date: Wed, 10 Feb 2010 21:41:47 -0500 Subject: [petsc-users] What is the difference between these two approaches? In-Reply-To: <87ljf3tnxl.fsf@59A2.org> References: <20100208161353.kcbs2utg84cs48w4@cubmail.cc.columbia.edu> <87ljf3tnxl.fsf@59A2.org> Message-ID: <20100210214147.49x0lwuc8wc8o040@cubmail.cc.columbia.edu> Dear all, FYI, a bug was found. But I am still working the analytic Jacobian for DMComposite(). Thanks so much! Rebecca Quoting Jed Brown : > On Mon, 08 Feb 2010 16:13:53 -0500, "(Rebecca) Xuefei YUAN" > wrote: >> Dear all, >> >> I do have an PDE-constrained optimization problem: >> >> F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1) >> F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = 0 (2) >> >> where phi(x,y) is defined at each grid point and c is a scalar >> parameter that satisfying the equation (2). > > Is c the only parameter you are optimizing? What does your system look > like in "minimize functional subject to PDE" form? > >> I have two pieces of codes to solve them by different approaches. >> >> The first approach is to use DMComposite() to manage unknowns and >> solve F1&F2 at the same time, and it calls DMMGSolve() once. >> >> The second approach is to solve F1 with a guess c for some number(i.e. >> 1) times of nonlinear and linear iteration, and then update c from F2. >> Solve F1 again with updated c till some conditions satisfied, for >> example, > > Perhaps the iteration has stagnated or found a different local minimum? > Have you compared the objective functions? > >> d) the shortcoming of approach one is PETSc has not ready for assemble >> a Jacobian for object DMComposite, so the second approach is able to >> write an analytic Jacobian. > > Does DMCompositeGetMatrix() not work for you? > > Jed > > -- (Rebecca) Xuefei YUAN Department of Applied Physics and Applied Mathematics Columbia University Tel:917-399-8032 www.columbia.edu/~xy2102 From fischej at umich.edu Thu Feb 11 10:01:00 2010 From: fischej at umich.edu (John-Michael Fischer) Date: Thu, 11 Feb 2010 11:01:00 -0500 Subject: [petsc-users] MatElemDiv Message-ID: <97A249D7-395C-4D17-BC8F-EDE8C0910AB6@umich.edu> This seems like a silly question, but is there a reason I cannot find a function for MatrixElementWiseDivide that would accept two matricies, M1 and M2 and perform element wise division? I can go through the process of getting local rows on each proc, doing the element by element division, etc... but it just seems like a perfect candidate for a built-in. Thanks John-Michael Fischer University of Michigan Nuclear Engineering and Radiological Sciences From knepley at gmail.com Thu Feb 11 10:06:59 2010 From: knepley at gmail.com (Matthew Knepley) Date: Thu, 11 Feb 2010 10:06:59 -0600 Subject: [petsc-users] MatElemDiv In-Reply-To: <97A249D7-395C-4D17-BC8F-EDE8C0910AB6@umich.edu> References: <97A249D7-395C-4D17-BC8F-EDE8C0910AB6@umich.edu> Message-ID: On Thu, Feb 11, 2010 at 10:01 AM, John-Michael Fischer wrote: > This seems like a silly question, but is there a reason I cannot find a > function for MatrixElementWiseDivide that would accept two matricies, M1 and > M2 and perform element wise division? > > I can go through the process of getting local rows on each proc, doing the > element by element division, etc... but it just seems like a perfect > candidate for a built-in. > We do not have any Mat element-wise functions, since with sparse matrices this might be ill-defined with different non-zero patterns, as well as slow since the result might have a third nonzero pattern. Matt > Thanks > John-Michael Fischer > University of Michigan > Nuclear Engineering and Radiological Sciences -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From torres.pedrozpk at gmail.com Thu Feb 11 12:33:58 2010 From: torres.pedrozpk at gmail.com (Pedro Torres) Date: Thu, 11 Feb 2010 16:33:58 -0200 Subject: [petsc-users] Question about Vec/MatSetLocalToGlobalMapping Message-ID: Hi, How can I check if a mapping is already set in a Vec/Mat object??. I try the following, if(!A->mapping)MatSetLocalToGlobalMapping(A,map); but I get this error error: invalid use of incomplete type ?struct _p_Mat? error: forward declaration of ?struct _p_Mat? Thanks in advance Pedro Torres -------------- next part -------------- An HTML attachment was scrubbed... URL: From knepley at gmail.com Thu Feb 11 12:36:11 2010 From: knepley at gmail.com (Matthew Knepley) Date: Thu, 11 Feb 2010 12:36:11 -0600 Subject: [petsc-users] Question about Vec/MatSetLocalToGlobalMapping In-Reply-To: References: Message-ID: We should add a 'get'. For now, include 'private/matimpl.h' Matt On Thu, Feb 11, 2010 at 12:33 PM, Pedro Torres wrote: > Hi, > > How can I check if a mapping is already set in a Vec/Mat object??. I try > the following, > > if(!A->mapping)MatSetLocalToGlobalMapping(A,map); > > but I get this error > error: invalid use of incomplete type ?struct _p_Mat? > error: forward declaration of ?struct _p_Mat? > > Thanks in advance > > Pedro Torres > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From torres.pedrozpk at gmail.com Thu Feb 11 12:41:53 2010 From: torres.pedrozpk at gmail.com (Pedro Torres) Date: Thu, 11 Feb 2010 16:41:53 -0200 Subject: [petsc-users] Question about Vec/MatSetLocalToGlobalMapping In-Reply-To: References: Message-ID: Thanks Matt. Best Regards Pedro 2010/2/11 Matthew Knepley > We should add a 'get'. For now, include 'private/matimpl.h' > > Matt > > > On Thu, Feb 11, 2010 at 12:33 PM, Pedro Torres wrote: > >> Hi, >> >> How can I check if a mapping is already set in a Vec/Mat object??. I try >> the following, >> >> if(!A->mapping)MatSetLocalToGlobalMapping(A,map); >> >> but I get this error >> error: invalid use of incomplete type ?struct _p_Mat? >> error: forward declaration of ?struct _p_Mat? >> >> Thanks in advance >> >> Pedro Torres >> > > > > -- > 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 > -- Samuel Goldwyn - "I don't think anyone should write their autobiography until after they're dead." -------------- next part -------------- An HTML attachment was scrubbed... URL: From bsmith at mcs.anl.gov Thu Feb 11 13:36:27 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Thu, 11 Feb 2010 13:36:27 -0600 Subject: [petsc-users] MatElemDiv In-Reply-To: References: <97A249D7-395C-4D17-BC8F-EDE8C0910AB6@umich.edu> Message-ID: <92A81FC5-4F65-4AC9-A25B-615F867FF06D@mcs.anl.gov> If you "know" that the two matrices have the same nonzero pattern you can do this efficiently with a call to MatGetArray() on each matrix. Barry On Feb 11, 2010, at 10:06 AM, Matthew Knepley wrote: > On Thu, Feb 11, 2010 at 10:01 AM, John-Michael Fischer > wrote: > This seems like a silly question, but is there a reason I cannot > find a function for MatrixElementWiseDivide that would accept two > matricies, M1 and M2 and perform element wise division? > > I can go through the process of getting local rows on each proc, > doing the element by element division, etc... but it just seems like > a perfect candidate for a built-in. > > We do not have any Mat element-wise functions, since with sparse > matrices this might > be ill-defined with different non-zero patterns, as well as slow > since the result might have > a third nonzero pattern. > > Matt > > Thanks > John-Michael Fischer > University of Michigan > Nuclear Engineering and Radiological Sciences > > > > -- > 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 From fischej at umich.edu Mon Feb 15 09:44:16 2010 From: fischej at umich.edu (John-Michael Fischer) Date: Mon, 15 Feb 2010 10:44:16 -0500 Subject: [petsc-users] MatElemDiv In-Reply-To: <92A81FC5-4F65-4AC9-A25B-615F867FF06D@mcs.anl.gov> References: <97A249D7-395C-4D17-BC8F-EDE8C0910AB6@umich.edu> <92A81FC5-4F65-4AC9-A25B-615F867FF06D@mcs.anl.gov> Message-ID: <8DCC9411-97A2-4796-9BEE-C80BEED9D401@umich.edu> On the documentation page for MatGetArray() it says the result is, understandably, dependent on matrix structure. My question is if I'm using an MPI Mat then will MatGetArray get the local array on each proc, or will it assemble the whole array? Thank you, John-Michael Fischer On Feb 11, 2010, at 2:36 PM, Barry Smith wrote: > > If you "know" that the two matrices have the same nonzero pattern you can do this efficiently with a call to MatGetArray() on each matrix. > > Barry > > On Feb 11, 2010, at 10:06 AM, Matthew Knepley wrote: > >> On Thu, Feb 11, 2010 at 10:01 AM, John-Michael Fischer wrote: >> This seems like a silly question, but is there a reason I cannot find a function for MatrixElementWiseDivide that would accept two matricies, M1 and M2 and perform element wise division? >> >> I can go through the process of getting local rows on each proc, doing the element by element division, etc... but it just seems like a perfect candidate for a built-in. >> >> We do not have any Mat element-wise functions, since with sparse matrices this might >> be ill-defined with different non-zero patterns, as well as slow since the result might have >> a third nonzero pattern. >> >> Matt >> >> Thanks >> John-Michael Fischer >> University of Michigan >> Nuclear Engineering and Radiological Sciences >> >> >> >> -- >> 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 > > > From craig-tanis at utc.edu Mon Feb 15 11:45:21 2010 From: craig-tanis at utc.edu (Craig Tanis) Date: Mon, 15 Feb 2010 12:45:21 -0500 Subject: [petsc-users] parallel ILU Message-ID: Hi, I'm trying to get ILU(k) preconditioning to work with an MPIBAIJ matrix. It appears that I need to use an MPIAIJ matrix and that I also need to build petsc with the blocksolve95 interface (though some google searches suggest that this was removed in Petsc 2?). 1) Should I be able to replace a call to MatCreateMPIBAIJ with a sequence of MatCreateMPIAIJ and MatSetBlockSize? 2) Is blocksolve95 still necessary, and if so where can one download it? It appears to have moved from it's original location on the mcs.anl.gov site. It is possible to do ILU-k preconditioning on an MPI matrix, right? Thanks! Craig Tanis From knepley at gmail.com Mon Feb 15 12:45:42 2010 From: knepley at gmail.com (Matt Knepley) Date: Mon, 15 Feb 2010 10:45:42 -0800 Subject: [petsc-users] parallel ILU In-Reply-To: References: Message-ID: ILU(k) was never in Blocksolve, just ilu(0). Also, Blocksolve is no longer supported. You can try Euclid from the Hypre package at LLNL. Configure can download Hypre for you. Matt From the phone On Feb 15, 2010, at 9:45 AM, Craig Tanis wrote: > Hi, > I'm trying to get ILU(k) preconditioning to work with an MPIBAIJ > matrix. It appears that I need to use an MPIAIJ matrix and that I > also need to build petsc with the blocksolve95 interface (though > some google searches suggest that this was removed in Petsc 2?). > > 1) Should I be able to replace a call to MatCreateMPIBAIJ with a > sequence of MatCreateMPIAIJ and MatSetBlockSize? > > 2) Is blocksolve95 still necessary, and if so where can one download > it? It appears to have moved from it's original location on the mcs.anl.gov > site. > > It is possible to do ILU-k preconditioning on an MPI matrix, right? > > Thanks! > Craig Tanis > From knepley at gmail.com Mon Feb 15 16:36:39 2010 From: knepley at gmail.com (Matthew Knepley) Date: Mon, 15 Feb 2010 16:36:39 -0600 Subject: [petsc-users] MatElemDiv In-Reply-To: <8DCC9411-97A2-4796-9BEE-C80BEED9D401@umich.edu> References: <97A249D7-395C-4D17-BC8F-EDE8C0910AB6@umich.edu> <92A81FC5-4F65-4AC9-A25B-615F867FF06D@mcs.anl.gov> <8DCC9411-97A2-4796-9BEE-C80BEED9D401@umich.edu> Message-ID: You get the local piece. Matt On Mon, Feb 15, 2010 at 9:44 AM, John-Michael Fischer wrote: > On the documentation page for MatGetArray() it says the result is, > understandably, dependent on matrix structure. > My question is if I'm using an MPI Mat then will MatGetArray get the local > array on each proc, or will it assemble the whole array? > > Thank you, > John-Michael Fischer > > On Feb 11, 2010, at 2:36 PM, Barry Smith wrote: > > > > > If you "know" that the two matrices have the same nonzero pattern you > can do this efficiently with a call to MatGetArray() on each matrix. > > > > Barry > > > > On Feb 11, 2010, at 10:06 AM, Matthew Knepley wrote: > > > >> On Thu, Feb 11, 2010 at 10:01 AM, John-Michael Fischer < > fischej at umich.edu> wrote: > >> This seems like a silly question, but is there a reason I cannot find a > function for MatrixElementWiseDivide that would accept two matricies, M1 and > M2 and perform element wise division? > >> > >> I can go through the process of getting local rows on each proc, doing > the element by element division, etc... but it just seems like a perfect > candidate for a built-in. > >> > >> We do not have any Mat element-wise functions, since with sparse > matrices this might > >> be ill-defined with different non-zero patterns, as well as slow since > the result might have > >> a third nonzero pattern. > >> > >> Matt > >> > >> Thanks > >> John-Michael Fischer > >> University of Michigan > >> Nuclear Engineering and Radiological Sciences > >> > >> > >> > >> -- > >> 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 > > > > > > > > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From u.tabak at tudelft.nl Tue Feb 16 03:13:17 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Tue, 16 Feb 2010 10:13:17 +0100 Subject: [petsc-users] linear system solution for slightly changing operator matrix Message-ID: <4B7A61AD.4030902@tudelft.nl> Dear all, My question is not directly related to PETSc usage, however since I use PETSc to test my ideas. I wanted to ask here. I believe there are many numerical experts in this group from whom I can get some advice on linear system solutions. In brief, I was working on an iterative correction algorithm for coupled vibroacoustics in the last months, at each iteration I have to update an operator matrix and rhs vectors and solve this system for corrections, x. More specifically the system is(there are two systems like this but they are built on the same idea: to solve linear systems for correction vectors, x) (A - y * B) x = y * C * v where y and v are the eigenvalues and eigenvectors coming from an eigenvalue problem,respectively, and updated at each iteration to end up with new correction vectors x(and say x' for the other linear system). A, B are sparse symmetric matrices, C is not symmetric but pretty sparse. I try to solve these systems iteratively, by cg in PETSc with the some preconditioners, for the moment icc gave the best results for my problem. However, I realized that the eigenvalues which affect the build up of the operator matrix,(A - y * B), namely y values, do not change too much from one iteration to another(Of course after 1 or 2 iterations, they start oscillating around more or less the same values that is what I call they do not change too much). The question is that can this little change(s) be handy to be able to use some information from the previous linear system solutions? If yes, how should I advance to make these linear solves faster? Any directions/pointers are appreciated. Best regards, Umut From jroman at dsic.upv.es Tue Feb 16 03:37:22 2010 From: jroman at dsic.upv.es (Jose E. Roman) Date: Tue, 16 Feb 2010 10:37:22 +0100 Subject: [petsc-users] linear system solution for slightly changing operator matrix In-Reply-To: <4B7A61AD.4030902@tudelft.nl> References: <4B7A61AD.4030902@tudelft.nl> Message-ID: <71C6861C-08B3-477E-A4E2-D4AE51C95E6B@dsic.upv.es> On 16/02/2010, Umut Tabak wrote: > Dear all, > > My question is not directly related to PETSc usage, however since I > use PETSc to test my ideas. I wanted to ask here. > > I believe there are many numerical experts in this group from whom I > can get some advice on linear system solutions. In brief, I was > working on an iterative correction algorithm for coupled > vibroacoustics in the last months, at each iteration I have to > update an operator matrix and rhs vectors and solve this system for > corrections, x. > > More specifically the system is(there are two systems like this but > they are built on the same idea: to solve linear systems for > correction vectors, x) > > (A - y * B) x = y * C * v > > where y and v are the eigenvalues and eigenvectors coming from an > eigenvalue problem,respectively, and updated at each iteration to > end up with new correction vectors x(and say x' for the other linear > system). A, B are sparse symmetric matrices, C is not symmetric but > pretty sparse. > > I try to solve these systems iteratively, by cg in PETSc with the > some preconditioners, for the moment icc gave the best results for > my problem. > > However, I realized that the eigenvalues which affect the build > up of the operator matrix,(A - y * B), namely y values, do not > change too much from one iteration to another(Of course after 1 or 2 > iterations, they start oscillating around more or less the same > values that is what I call they do not change too much). The > question is that can this little change(s) be handy to be able to > use some information from the previous linear system solutions? If > yes, how should I advance to make these linear solves faster? > > Any directions/pointers are appreciated. > > Best regards, > > Umut Although there is no guarantee of improvement, you can try using KSPSetInitialGuessNonzero and setting x to be the solution computed by the previous KSPSolve. Jose From jed at 59A2.org Tue Feb 16 09:19:19 2010 From: jed at 59A2.org (Jed Brown) Date: Tue, 16 Feb 2010 08:19:19 -0700 Subject: [petsc-users] parallel ILU In-Reply-To: References: Message-ID: <87fx51i4y0.fsf@59A2.org> On Mon, 15 Feb 2010 12:45:21 -0500, Craig Tanis wrote: > It is possible to do ILU-k preconditioning on an MPI matrix, right? Note that ILU (regardless of fill) scales very poorly, so it really only makes sense on a small number of cores, and even then, only if you can't find anything else that works. As Matt says, build with Hypre, then -pc_type hypre -pc_hypre_type euclid -pc_hypre_euclid_levels k Jed From bsmith at mcs.anl.gov Tue Feb 16 13:22:05 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Tue, 16 Feb 2010 13:22:05 -0600 Subject: [petsc-users] MatElemDiv In-Reply-To: References: <97A249D7-395C-4D17-BC8F-EDE8C0910AB6@umich.edu> <92A81FC5-4F65-4AC9-A25B-615F867FF06D@mcs.anl.gov> <8DCC9411-97A2-4796-9BEE-C80BEED9D401@umich.edu> Message-ID: <9F20FE7D-04B2-4A87-8A94-A0B2E4657290@mcs.anl.gov> On Feb 15, 2010, at 4:36 PM, Matthew Knepley wrote: > You get the local piece. > > Matt But note that sparse matrices may have more than one "piece", for example AIJ, BAIJ and SBAIJ sparse matrices have two parts (see the manual pages for creating them for the definition of the two parts). Thus you need to actually call the MatGetArray() on each part. Something like #include "src/mat/impls/aij/mpi/mpiaij.h" Mat A; Mat_MPIAIJ *a = (Mat_MPIAIJ*) A->data; PetscScalar *d,*o; ierr = MatGetArray(a->A,&d); ierr = MatGetArray(a->B,&o); gives you access to the two parts of the matrix A. Barry > > On Mon, Feb 15, 2010 at 9:44 AM, John-Michael Fischer > wrote: > On the documentation page for MatGetArray() it says the result is, > understandably, dependent on matrix structure. > My question is if I'm using an MPI Mat then will MatGetArray get the > local array on each proc, or will it assemble the whole array? > > Thank you, > John-Michael Fischer > > On Feb 11, 2010, at 2:36 PM, Barry Smith wrote: > > > > > If you "know" that the two matrices have the same nonzero pattern > you can do this efficiently with a call to MatGetArray() on each > matrix. > > > > Barry > > > > On Feb 11, 2010, at 10:06 AM, Matthew Knepley wrote: > > > >> On Thu, Feb 11, 2010 at 10:01 AM, John-Michael Fischer > wrote: > >> This seems like a silly question, but is there a reason I cannot > find a function for MatrixElementWiseDivide that would accept two > matricies, M1 and M2 and perform element wise division? > >> > >> I can go through the process of getting local rows on each proc, > doing the element by element division, etc... but it just seems like > a perfect candidate for a built-in. > >> > >> We do not have any Mat element-wise functions, since with sparse > matrices this might > >> be ill-defined with different non-zero patterns, as well as slow > since the result might have > >> a third nonzero pattern. > >> > >> Matt > >> > >> Thanks > >> John-Michael Fischer > >> University of Michigan > >> Nuclear Engineering and Radiological Sciences > >> > >> > >> > >> -- > >> 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 > > > > > > > > > > > -- > 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 From bsmith at mcs.anl.gov Tue Feb 16 13:27:23 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Tue, 16 Feb 2010 13:27:23 -0600 Subject: [petsc-users] parallel ILU In-Reply-To: <87fx51i4y0.fsf@59A2.org> References: <87fx51i4y0.fsf@59A2.org> Message-ID: On Feb 16, 2010, at 9:19 AM, Jed Brown wrote: > On Mon, 15 Feb 2010 12:45:21 -0500, Craig Tanis tanis at utc.edu> wrote: >> It is possible to do ILU-k preconditioning on an MPI matrix, right? > > Note that ILU (regardless of fill) scales very poorly, so it really > only > makes sense on a small number of cores, and even then, only if you > can't > find anything else that works. As Matt says, build with Hypre, then > > -pc_type hypre -pc_hypre_type euclid -pc_hypre_euclid_levels k > > Jed Also note that there is no support for BAIJ matrices. It is only a "scalar" ILU, not one that works on little blocks. Barry From craig-tanis at utc.edu Tue Feb 16 13:46:22 2010 From: craig-tanis at utc.edu (Craig Tanis) Date: Tue, 16 Feb 2010 14:46:22 -0500 Subject: [petsc-users] parallel ILU In-Reply-To: References: <87fx51i4y0.fsf@59A2.org> Message-ID: <2C55B610-B29F-416B-A689-B27BB5FAE1EC@utc.edu> >> On Mon, 15 Feb 2010 12:45:21 -0500, Craig Tanis wrote: >>> It is possible to do ILU-k preconditioning on an MPI matrix, right? >> >> Note that ILU (regardless of fill) scales very poorly, so it really only >> makes sense on a small number of cores, and even then, only if you can't >> find anything else that works. As Matt says, build with Hypre, then >> >> -pc_type hypre -pc_hypre_type euclid -pc_hypre_euclid_levels k >> >> Jed > > Also note that there is no support for BAIJ matrices. It is only a "scalar" ILU, not one that works on little blocks. > > Barry > could you clarify this? i'm running the euclid preconditioner on a mpibaij matrix, and I get no errors or warnings. a ksp_view verifies that things are configured as expected. thanks craig From bsmith at mcs.anl.gov Tue Feb 16 13:51:49 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Tue, 16 Feb 2010 13:51:49 -0600 Subject: [petsc-users] parallel ILU In-Reply-To: <2C55B610-B29F-416B-A689-B27BB5FAE1EC@utc.edu> References: <87fx51i4y0.fsf@59A2.org> <2C55B610-B29F-416B-A689-B27BB5FAE1EC@utc.edu> Message-ID: <87839893-8B95-4E55-BEE4-AC47012AAD6F@mcs.anl.gov> On Feb 16, 2010, at 1:46 PM, Craig Tanis wrote: >>> On Mon, 15 Feb 2010 12:45:21 -0500, Craig Tanis >> tanis at utc.edu> wrote: >>>> It is possible to do ILU-k preconditioning on an MPI matrix, right? >>> >>> Note that ILU (regardless of fill) scales very poorly, so it >>> really only >>> makes sense on a small number of cores, and even then, only if you >>> can't >>> find anything else that works. As Matt says, build with Hypre, then >>> >>> -pc_type hypre -pc_hypre_type euclid -pc_hypre_euclid_levels k >>> >>> Jed >> >> Also note that there is no support for BAIJ matrices. It is only a >> "scalar" ILU, not one that works on little blocks. >> >> Barry >> > > > could you clarify this? i'm running the euclid preconditioner on a > mpibaij matrix, and I get no errors or warnings. a ksp_view > verifies that things are configured as expected. > > thanks > craig As the matrix is passed to hypre it is passed as a AIJ matrix without a block size. This is because hypre has no concept of a BAIJ matrix. So yes, your PETSc part of the code is using a BAIJ matrix but hypre is doing a scalar ILU without a block size. Barry From craig-tanis at utc.edu Tue Feb 16 15:02:01 2010 From: craig-tanis at utc.edu (Craig Tanis) Date: Tue, 16 Feb 2010 16:02:01 -0500 Subject: [petsc-users] parallel ILU In-Reply-To: <87839893-8B95-4E55-BEE4-AC47012AAD6F@mcs.anl.gov> References: <87fx51i4y0.fsf@59A2.org> <2C55B610-B29F-416B-A689-B27BB5FAE1EC@utc.edu> <87839893-8B95-4E55-BEE4-AC47012AAD6F@mcs.anl.gov> Message-ID: On Feb 16, 2010, at 2:51 > As the matrix is passed to hypre it is passed as a AIJ matrix without a block size. This is because hypre has no concept of a BAIJ matrix. So yes, your PETSc part of the code is using a BAIJ matrix but hypre is doing a scalar ILU without a block size. > Thanks for the clarification.Is there much overhead in this conversion? Would I be better off working with a AIJ matrix in the "driver code"? -craig From bsmith at mcs.anl.gov Tue Feb 16 15:06:03 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Tue, 16 Feb 2010 15:06:03 -0600 Subject: [petsc-users] parallel ILU In-Reply-To: References: <87fx51i4y0.fsf@59A2.org> <2C55B610-B29F-416B-A689-B27BB5FAE1EC@utc.edu> <87839893-8B95-4E55-BEE4-AC47012AAD6F@mcs.anl.gov> Message-ID: I would stick to the BAIJ, since that will give you better performance in the non-hypre part of the code, while the hypre part has the same performance because it does not "know" about BAIJ. The conversion cost is in my experience very small relative to the computation times. Barry On Feb 16, 2010, at 3:02 PM, Craig Tanis wrote: > > On Feb 16, 2010, at 2:51 >> As the matrix is passed to hypre it is passed as a AIJ matrix >> without a block size. This is because hypre has no concept of a >> BAIJ matrix. So yes, your PETSc part of the code is using a BAIJ >> matrix but hypre is doing a scalar ILU without a block size. >> > > Thanks for the clarification.Is there much overhead in this > conversion? Would I be better off working with a AIJ matrix in the > "driver code"? > > -craig From s.kramer at imperial.ac.uk Wed Feb 17 11:55:51 2010 From: s.kramer at imperial.ac.uk (Stephan Kramer) Date: Wed, 17 Feb 2010 17:55:51 +0000 Subject: [petsc-users] bug in fortran interface KSPBuildSolution Message-ID: <4B7C2DA7.3030002@imperial.ac.uk> Hi all, Just a small bug I came across in calling KSPBuildSolution from fortran. I was calling it in the following way: call KSPBuildSolution(ksp, x, PETSC_NULL_OBJECT, ierr) i.e. I'm asking it to copy it in my vector x. However as the *V argument (the second vector) gets passed on unchecked in kspbuildsolution_() in itfuncf.c to kspbuildsolution(), it gets passed the address of PETSC_NULL_OBJECT (somewhere in the fortran common block) and thinks I've passed it a proper pointer to a vector, and copies the address of x also into PETSC_NULL_OBJECT, i.e. it clobbers PETSC_NULL_OBJECT in fortran. Obvious solution for me was to provide it an arbitrary second vector y instead of PETSC_NULL_OBJECT, but it took me a while before realizing my crash later on was due to my PETSC_NULL_OBJECT no longer being zero. Cheers Stephan From bsmith at mcs.anl.gov Wed Feb 17 14:18:19 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Wed, 17 Feb 2010 14:18:19 -0600 Subject: [petsc-users] bug in fortran interface KSPBuildSolution In-Reply-To: <4B7C2DA7.3030002@imperial.ac.uk> References: <4B7C2DA7.3030002@imperial.ac.uk> Message-ID: Stephan, Thanks for reporting that problem. Unfortunately for handling null objects from Fortran we need to manually write the Fortran stubs and we had never written them for this function. I have updated petsc- dev to handle this properly by providing the manually written stub. Thanks again, Barry On Feb 17, 2010, at 11:55 AM, Stephan Kramer wrote: > Hi all, > > Just a small bug I came across in calling KSPBuildSolution from > fortran. I was calling it in the following way: > > call KSPBuildSolution(ksp, x, PETSC_NULL_OBJECT, ierr) > > i.e. I'm asking it to copy it in my vector x. However as the *V > argument (the second vector) gets passed on unchecked in > kspbuildsolution_() in itfuncf.c to kspbuildsolution(), > it gets passed the address of PETSC_NULL_OBJECT (somewhere in the > fortran common block) and thinks I've passed it a proper pointer to > a vector, > and copies the address of x also into PETSC_NULL_OBJECT, i.e. it > clobbers PETSC_NULL_OBJECT in fortran. Obvious solution for me was > to provide it an arbitrary second vector y instead of > PETSC_NULL_OBJECT, but it took me a while before realizing my crash > later on was due to my PETSC_NULL_OBJECT no longer being zero. > > Cheers > Stephan From hxie at umn.edu Thu Feb 18 13:40:50 2010 From: hxie at umn.edu (hxie at umn.edu) Date: 18 Feb 2010 13:40:50 -0600 Subject: [petsc-users] ilut preconditioner In-Reply-To: References: Message-ID: Hi, Is the ilut preconditioner included in Petsc? If so, could you show me how to use it with command line options? Thanks. Bests, Hui From knepley at gmail.com Thu Feb 18 13:49:55 2010 From: knepley at gmail.com (Matthew Knepley) Date: Thu, 18 Feb 2010 11:49:55 -0800 Subject: [petsc-users] ilut preconditioner In-Reply-To: References: Message-ID: No. There is one in Hypre. Matt On Thu, Feb 18, 2010 at 11:40 AM, wrote: > Hi, > > Is the ilut preconditioner included in Petsc? If so, could you show me how > to use it with command line options? Thanks. > > Bests, > Hui > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From art.fountain at gmail.com Thu Feb 18 14:35:58 2010 From: art.fountain at gmail.com (Arturo Fountain) Date: Thu, 18 Feb 2010 13:35:58 -0700 Subject: [petsc-users] Output portability, binary, HDF5, ascii Message-ID: <11f24ad01002181235x7f5eb9a7s5168339f04427e7d@mail.gmail.com> Greetings: I've been using the PETSc libraries for a few weeks now and am very impressed with the software. Great work folks! I'm writing with an issue I've been unable to work around. I'd like to save output and import it into an external program (hdfview or matlab, for example). Vectors are no problem to output but as mentioned at https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2010-January/005796.html, this is not possible in PETSc for matrices. Furthermore: "It won't buy you any speed, disk space, or portability." Certainly the PETSc binary format works fine for PETSc I/O but I am unable to find anything to convert between this format and any other. I'm most concerned with portability; I would like to utilize external visualization packages. Is it standard practice to simply use ASCII output? I can certainly do that but for larger problems size will certainly become an impending issue.... Thanks in advance for any help you can offer, Arturo From art.fountain at gmail.com Thu Feb 18 14:42:54 2010 From: art.fountain at gmail.com (Arturo Fountain) Date: Thu, 18 Feb 2010 13:42:54 -0700 Subject: [petsc-users] Slight typo Message-ID: <11f24ad01002181242n1f9601f1vbbd442141c96245a@mail.gmail.com> Greetings: Wanted to mention a (very) small typo in the PETSc distribution/documentation. At ${PETSC_DIR}/docs/manualpages/Viewer/PetscViewerHDF5Open.html in the section: " Output Parameter hd5v -PetscViewer for HDF5 i " I believe that 'hd5v' should be 'hdf5v" At least this is the case with 3.0.0-p11. I understand the documentation is automatically-generated from the source code, but I've been unable to locate the exact source. Hope this slight contribution improves the documentation even slightly. Cheers! Arturo From bsmith at mcs.anl.gov Thu Feb 18 15:10:43 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Thu, 18 Feb 2010 15:10:43 -0600 Subject: [petsc-users] Output portability, binary, HDF5, ascii In-Reply-To: <11f24ad01002181235x7f5eb9a7s5168339f04427e7d@mail.gmail.com> References: <11f24ad01002181235x7f5eb9a7s5168339f04427e7d@mail.gmail.com> Message-ID: <10541D64-D95C-43D9-9997-D0ACEE3C011E@mcs.anl.gov> On Feb 18, 2010, at 2:35 PM, Arturo Fountain wrote: > Greetings: > > I've been using the PETSc libraries for a few weeks now and am very > impressed with the software. Great work folks! > > I'm writing with an issue I've been unable to work around. I'd like to > save output and import it into an external program (hdfview or matlab, > for example). Vectors are no problem to output but as mentioned at > https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2010-January/005796.html > , > this is not possible in PETSc for matrices. This is an indirect way of doing but since PETSc can dump vectors and sparse matrices in PETSc format rapidly and they can be read into Matlab rapidly, could you then use Matlab's HDF5 capability to write then into any HDF5 format you like? I realize this is not ideal, but it is just a single extra postprocessing step. You could also write your own PETSc object viewers that wrote to HDF5, for sparse matrices, but I think it is easy just to dump to Matlab and have it save it in the format you want. ASCII is just SO slow for large data sets I think it is impractical. Barry > Furthermore: "It won't buy > you any speed, disk space, or portability." > > Certainly the PETSc binary format works fine for PETSc I/O but I am > unable to find anything to convert between this format and any other. > I'm most concerned with portability; I would like to utilize external > visualization packages. Is it standard practice to simply use ASCII > output? I can certainly do that but for larger problems size will > certainly become an impending issue.... > > Thanks in advance for any help you can offer, > > Arturo From bsmith at mcs.anl.gov Thu Feb 18 15:11:17 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Thu, 18 Feb 2010 15:11:17 -0600 Subject: [petsc-users] Slight typo In-Reply-To: <11f24ad01002181242n1f9601f1vbbd442141c96245a@mail.gmail.com> References: <11f24ad01002181242n1f9601f1vbbd442141c96245a@mail.gmail.com> Message-ID: <12A644D7-6C83-4181-9AF3-447C1613D1AA@mcs.anl.gov> Thanks Barry On Feb 18, 2010, at 2:42 PM, Arturo Fountain wrote: > PetscViewerHDF5Open From dalcinl at gmail.com Thu Feb 18 15:36:33 2010 From: dalcinl at gmail.com (Lisandro Dalcin) Date: Thu, 18 Feb 2010 18:36:33 -0300 Subject: [petsc-users] Output portability, binary, HDF5, ascii In-Reply-To: <10541D64-D95C-43D9-9997-D0ACEE3C011E@mcs.anl.gov> References: <11f24ad01002181235x7f5eb9a7s5168339f04427e7d@mail.gmail.com> <10541D64-D95C-43D9-9997-D0ACEE3C011E@mcs.anl.gov> Message-ID: On 18 February 2010 18:10, Barry Smith wrote: > > On Feb 18, 2010, at 2:35 PM, Arturo Fountain wrote: > >> Greetings: >> >> I've been using the PETSc libraries for a few weeks now and am very >> impressed with the software. Great work folks! >> >> I'm writing with an issue I've been unable to work around. I'd like to >> save output and import it into an external program (hdfview or matlab, >> for example). Vectors are no problem to output but as mentioned at >> >> https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2010-January/005796.html, >> this is not possible in PETSc for matrices. > > > ? ?This is an indirect way of doing but since PETSc can dump vectors and > sparse matrices in PETSc format rapidly and they can be read into Matlab > rapidly, could you then use Matlab's HDF5 capability to write then into any > HDF5 format you like? I realize this is not ideal, but it is just a single > extra postprocessing step. > > ? ?You could also write your own PETSc object viewers that wrote to HDF5, > for sparse matrices, but I think it is easy just to dump to Matlab and have > it save it in the format you want. > > ? ?ASCII is just SO slow for large data sets I think it is impractical. > > ? Barry > > > >> Furthermore: "It won't buy >> you any speed, disk space, or portability." >> >> Certainly the PETSc binary format works fine for PETSc I/O but I am >> unable to find anything to convert between this format and any other. >> I'm most concerned with portability; I would like to utilize external >> visualization packages. Is it standard practice to simply use ASCII >> output? I can certainly do that but for larger problems size will >> certainly become an impending issue.... >> >> Thanks in advance for any help you can offer, >> >> Arturo > > OTOH, PETSc binary format is extremely easy to read... for example, feed the attached Python script with a PETSc binary file, and you will see the sparse matrix line by line in your console: $ python matio.py matrix.dat try this with a small matrix, as printing a big matrix can take forever. However, the readmat() function should perform extremely well, all the actual IO is done in C, thanks to numpy, Of course, you can do anything you want with the I, J, V numpy arrays, like using any HDF5 Python wrapper to generate an hdf5 file... -- Lisandro Dalcin --------------- Centro Internacional de M?todos Computacionales en Ingenier?a (CIMEC) Instituto de Desarrollo Tecnol?gico para la Industria Qu?mica (INTEC) Consejo Nacional de Investigaciones Cient?ficas y T?cnicas (CONICET) PTLC - G?emes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 -------------- next part -------------- A non-text attachment was scrubbed... Name: matio.py Type: text/x-python Size: 991 bytes Desc: not available URL: From art.fountain at gmail.com Thu Feb 18 15:39:28 2010 From: art.fountain at gmail.com (Arturo Fountain) Date: Thu, 18 Feb 2010 14:39:28 -0700 Subject: [petsc-users] Functions in bin/matlab Message-ID: <11f24ad01002181339r72ba4e22rc90f1cd4a6a0e0a4@mail.gmail.com> Greetings: I've been working with the scripts in $PETSC_DIR}/bin/matlab/ and had a slight problem getting them to work: I believe the script PetscReadBinaryMatlab.m is missing an 'f' at the very beginning (the script begins with 'unction' instead of 'function'). Other than that the scripts seem to work fine. Thanks, Arturo From art.fountain at gmail.com Thu Feb 18 15:58:56 2010 From: art.fountain at gmail.com (Arturo Fountain) Date: Thu, 18 Feb 2010 14:58:56 -0700 Subject: [petsc-users] Output portability, binary, HDF5, ascii In-Reply-To: <10541D64-D95C-43D9-9997-D0ACEE3C011E@mcs.anl.gov> References: <11f24ad01002181235x7f5eb9a7s5168339f04427e7d@mail.gmail.com> <10541D64-D95C-43D9-9997-D0ACEE3C011E@mcs.anl.gov> Message-ID: <11f24ad01002181358q44cc37c8x161906c6a9ac131@mail.gmail.com> Aha. Thanks for the head's up; I was unaware the Matlab could read PETSc matrices; they certainly do not advertise this fact (at least for our semi-ancient version 7.5.0) which is a shame! For a 'real' application I would never want to use such an intermediate step, but I only want to do so to create pictures for use in papers. Thanks again for the help, Arturo On Thu, Feb 18, 2010 at 2:10 PM, Barry Smith wrote: > > On Feb 18, 2010, at 2:35 PM, Arturo Fountain wrote: > >> Greetings: >> >> I've been using the PETSc libraries for a few weeks now and am very >> impressed with the software. Great work folks! >> >> I'm writing with an issue I've been unable to work around. I'd like to >> save output and import it into an external program (hdfview or matlab, >> for example). Vectors are no problem to output but as mentioned at >> >> https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2010-January/005796.html, >> this is not possible in PETSc for matrices. > > > ? ?This is an indirect way of doing but since PETSc can dump vectors and > sparse matrices in PETSc format rapidly and they can be read into Matlab > rapidly, could you then use Matlab's HDF5 capability to write then into any > HDF5 format you like? I realize this is not ideal, but it is just a single > extra postprocessing step. > > ? ?You could also write your own PETSc object viewers that wrote to HDF5, > for sparse matrices, but I think it is easy just to dump to Matlab and have > it save it in the format you want. > > ? ?ASCII is just SO slow for large data sets I think it is impractical. > > ? Barry > > > >> Furthermore: "It won't buy >> you any speed, disk space, or portability." >> >> Certainly the PETSc binary format works fine for PETSc I/O but I am >> unable to find anything to convert between this format and any other. >> I'm most concerned with portability; I would like to utilize external >> visualization packages. Is it standard practice to simply use ASCII >> output? I can certainly do that but for larger problems size will >> certainly become an impending issue.... >> >> Thanks in advance for any help you can offer, >> >> Arturo > > From art.fountain at gmail.com Thu Feb 18 16:03:08 2010 From: art.fountain at gmail.com (Arturo Fountain) Date: Thu, 18 Feb 2010 15:03:08 -0700 Subject: [petsc-users] Output portability, binary, HDF5, ascii In-Reply-To: References: <11f24ad01002181235x7f5eb9a7s5168339f04427e7d@mail.gmail.com> <10541D64-D95C-43D9-9997-D0ACEE3C011E@mcs.anl.gov> Message-ID: <11f24ad01002181403x34b252d6ndf5ffc370aba8ff8@mail.gmail.com> I'll certainly look into this. Numpy does seem to be a very portable format and may solve many of my problems. Thanks for the script and the heads up! Arturo On Thu, Feb 18, 2010 at 2:36 PM, Lisandro Dalcin wrote: > On 18 February 2010 18:10, Barry Smith wrote: >> >> On Feb 18, 2010, at 2:35 PM, Arturo Fountain wrote: >> >>> Greetings: >>> >>> I've been using the PETSc libraries for a few weeks now and am very >>> impressed with the software. Great work folks! >>> >>> I'm writing with an issue I've been unable to work around. I'd like to >>> save output and import it into an external program (hdfview or matlab, >>> for example). Vectors are no problem to output but as mentioned at >>> >>> https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2010-January/005796.html, >>> this is not possible in PETSc for matrices. >> >> >> ? ?This is an indirect way of doing but since PETSc can dump vectors and >> sparse matrices in PETSc format rapidly and they can be read into Matlab >> rapidly, could you then use Matlab's HDF5 capability to write then into any >> HDF5 format you like? I realize this is not ideal, but it is just a single >> extra postprocessing step. >> >> ? ?You could also write your own PETSc object viewers that wrote to HDF5, >> for sparse matrices, but I think it is easy just to dump to Matlab and have >> it save it in the format you want. >> >> ? ?ASCII is just SO slow for large data sets I think it is impractical. >> >> ? Barry >> >> >> >>> Furthermore: "It won't buy >>> you any speed, disk space, or portability." >>> >>> Certainly the PETSc binary format works fine for PETSc I/O but I am >>> unable to find anything to convert between this format and any other. >>> I'm most concerned with portability; I would like to utilize external >>> visualization packages. Is it standard practice to simply use ASCII >>> output? I can certainly do that but for larger problems size will >>> certainly become an impending issue.... >>> >>> Thanks in advance for any help you can offer, >>> >>> Arturo >> >> > > OTOH, PETSc binary format is extremely easy to read... for example, > feed the attached Python script with a PETSc binary file, and you will > see the sparse matrix line by line in your console: > > $ python matio.py matrix.dat > > try this with a small matrix, as printing a big matrix can take > forever. However, the readmat() function should perform extremely > well, all the actual IO is done in C, thanks to numpy, > > > Of course, you can do anything you want with the I, J, V numpy arrays, > like using any HDF5 Python wrapper to generate an hdf5 file... > > -- > Lisandro Dalcin > --------------- > Centro Internacional de M?todos Computacionales en Ingenier?a (CIMEC) > Instituto de Desarrollo Tecnol?gico para la Industria Qu?mica (INTEC) > Consejo Nacional de Investigaciones Cient?ficas y T?cnicas (CONICET) > PTLC - G?emes 3450, (3000) Santa Fe, Argentina > Tel/Fax: +54-(0)342-451.1594 > From bsmith at mcs.anl.gov Thu Feb 18 16:07:31 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Thu, 18 Feb 2010 16:07:31 -0600 Subject: [petsc-users] Output portability, binary, HDF5, ascii In-Reply-To: <11f24ad01002181358q44cc37c8x161906c6a9ac131@mail.gmail.com> References: <11f24ad01002181235x7f5eb9a7s5168339f04427e7d@mail.gmail.com> <10541D64-D95C-43D9-9997-D0ACEE3C011E@mcs.anl.gov> <11f24ad01002181358q44cc37c8x161906c6a9ac131@mail.gmail.com> Message-ID: <6E9A9F58-3FA7-40D1-9A31-4BD98D857DD4@mcs.anl.gov> On Feb 18, 2010, at 3:58 PM, Arturo Fountain wrote: > Aha. Thanks for the head's up; I was unaware the Matlab could read > PETSc matrices; they certainly do not advertise this fact (at least > for our semi-ancient version 7.5.0) which is a shame! it is in bin/matlab/PetscBinaryRead() Barry > > For a 'real' application I would never want to use such an > intermediate step, but I only want to do so to create pictures for use > in papers. > > Thanks again for the help, > > Arturo > > On Thu, Feb 18, 2010 at 2:10 PM, Barry Smith > wrote: >> >> On Feb 18, 2010, at 2:35 PM, Arturo Fountain wrote: >> >>> Greetings: >>> >>> I've been using the PETSc libraries for a few weeks now and am very >>> impressed with the software. Great work folks! >>> >>> I'm writing with an issue I've been unable to work around. I'd >>> like to >>> save output and import it into an external program (hdfview or >>> matlab, >>> for example). Vectors are no problem to output but as mentioned at >>> >>> https://lists.mcs.anl.gov/mailman/htdig/petsc-users/2010-January/005796.html >>> , >>> this is not possible in PETSc for matrices. >> >> >> This is an indirect way of doing but since PETSc can dump >> vectors and >> sparse matrices in PETSc format rapidly and they can be read into >> Matlab >> rapidly, could you then use Matlab's HDF5 capability to write then >> into any >> HDF5 format you like? I realize this is not ideal, but it is just a >> single >> extra postprocessing step. >> >> You could also write your own PETSc object viewers that wrote to >> HDF5, >> for sparse matrices, but I think it is easy just to dump to Matlab >> and have >> it save it in the format you want. >> >> ASCII is just SO slow for large data sets I think it is >> impractical. >> >> Barry >> >> >> >>> Furthermore: "It won't buy >>> you any speed, disk space, or portability." >>> >>> Certainly the PETSc binary format works fine for PETSc I/O but I am >>> unable to find anything to convert between this format and any >>> other. >>> I'm most concerned with portability; I would like to utilize >>> external >>> visualization packages. Is it standard practice to simply use ASCII >>> output? I can certainly do that but for larger problems size will >>> certainly become an impending issue.... >>> >>> Thanks in advance for any help you can offer, >>> >>> Arturo >> >> From hxie at umn.edu Fri Feb 19 15:51:28 2010 From: hxie at umn.edu (hxie at umn.edu) Date: 19 Feb 2010 15:51:28 -0600 Subject: [petsc-users] amg from hypre In-Reply-To: References: Message-ID: Hi, It takes about 8min to solve my problem using the default solver in PETSc and 14min using pilut from hypre. But it takes 132min to get the result if using the option "-pc_type hypre -pc_hypre_type boomeramg -ksp_type gmres". Should I change the default options for amg? Any suggestions are welcome. Hui From recrusader at gmail.com Fri Feb 19 15:58:38 2010 From: recrusader at gmail.com (Yujie) Date: Fri, 19 Feb 2010 15:58:38 -0600 Subject: [petsc-users] amg from hypre In-Reply-To: References: Message-ID: <7ff0ee011002191358p75068d50lb8b2e3da3a6371fb@mail.gmail.com> I don't know your specific problem. However, to my experience, ILU preconditioner in Hypre is not good. You can try the preconditioner of sparse approximation inversion if you can. If you use boomeramg, you should read its manual carfully. It looks some tricks inside it. FYI. Regards, Yujie On Fri, Feb 19, 2010 at 3:51 PM, wrote: > Hi, > > It takes about 8min to solve my problem using the default solver in PETSc > and 14min using pilut from hypre. But it takes 132min to get the result if > using the option "-pc_type hypre -pc_hypre_type boomeramg -ksp_type gmres". > Should I change the default options for amg? > Any suggestions are welcome. > > Hui > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59A2.org Fri Feb 19 17:22:39 2010 From: jed at 59A2.org (Jed Brown) Date: Fri, 19 Feb 2010 16:22:39 -0700 Subject: [petsc-users] amg from hypre In-Reply-To: References: Message-ID: <87pr40g69s.fsf@59A2.org> On 19 Feb 2010 15:51:28 -0600, hxie at umn.edu wrote: > Should I change the default options for amg? Nobody can suggest anything unless you tell us something about the problem you are solving. Jed From craig-tanis at utc.edu Sat Feb 20 08:21:54 2010 From: craig-tanis at utc.edu (Craig Tanis) Date: Sat, 20 Feb 2010 09:21:54 -0500 Subject: [petsc-users] choosing a preconditioner In-Reply-To: <87pr40g69s.fsf@59A2.org> References: <87pr40g69s.fsf@59A2.org> Message-ID: > > Nobody can suggest anything unless you tell us something about the > problem you are solving. > This is a related question, and I apologize if it's too OT: I often find myself just trying a bunch of -pc options to see what appears to work best. I understand the concept of preconditioners, and simple ones like ILU, Jacobi,etc are clear enough. I am a bit lost when we start talking about eigenvalue methods or preconditioners that require some knowledge of how the matrix is constructed.. can anybody recommend a resource/book for unraveling the mysteries of preconditioners? thanks, Craig From knepley at gmail.com Sat Feb 20 09:26:56 2010 From: knepley at gmail.com (Matthew Knepley) Date: Sat, 20 Feb 2010 07:26:56 -0800 Subject: [petsc-users] choosing a preconditioner In-Reply-To: References: <87pr40g69s.fsf@59A2.org> Message-ID: The unfortunate part of the word "preconditioner" is that it is about as precise as "justice". All good preconditioners are problem specific. That said, my quick suggestions are: Block box PCs: Yousef Saad's "Iterative Methods etc." is a good overview MG: Bill Brigg's "Multigrid Tutorial" is good, and so is "Multigrid..." by Wesseling Domain Decomp: Widlund and Tosseli's Title I can't remember is good but most really good PCs come from special solutions, linearizations, frozen terms, recognizing strong vs. weak coupling, etc. Matt On Sat, Feb 20, 2010 at 6:21 AM, Craig Tanis wrote: > > > > Nobody can suggest anything unless you tell us something about the > > problem you are solving. > > > > > This is a related question, and I apologize if it's too OT: I often find > myself just trying a bunch of -pc options to see what appears to work best. > I understand the concept of preconditioners, and simple ones like ILU, > Jacobi,etc are clear enough. > > I am a bit lost when we start talking about eigenvalue methods or > preconditioners that require some knowledge of how the matrix is > constructed.. can anybody recommend a resource/book for unraveling the > mysteries of preconditioners? > > thanks, > Craig > > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmills at climate.ornl.gov Sat Feb 20 09:34:01 2010 From: rmills at climate.ornl.gov (Richard Tran Mills) Date: Sat, 20 Feb 2010 10:34:01 -0500 Subject: [petsc-users] choosing a preconditioner In-Reply-To: References: <87pr40g69s.fsf@59A2.org> Message-ID: <4B8000E9.9070301@climate.ornl.gov> For domain decomposition, I'd also recommend Barry's book (co-authored with Bjorstad and Gropp), "Domain Decomposition: Parallel Multilevel Methods for Elliptic Partial Differential Equations". Google it and you'll find a preview in Google Books. --Richard Matthew Knepley wrote: > The unfortunate part of the word "preconditioner" is that it is about as > precise as "justice". > All good preconditioners are problem specific. That said, my quick > suggestions are: > > Block box PCs: Yousef Saad's "Iterative Methods etc." is a good overview > > MG: Bill Brigg's "Multigrid Tutorial" is good, and so is "Multigrid..." > by Wesseling > > Domain Decomp: Widlund and Tosseli's Title I can't remember is good > > but most really good PCs come from special solutions, linearizations, > frozen terms, > recognizing strong vs. weak coupling, etc. > > Matt -- Richard Tran Mills, Ph.D. | E-mail: rmills at climate.ornl.gov Computational Scientist | Phone: (865) 241-3198 Computational Earth Sciences Group | Fax: (865) 574-0405 Oak Ridge National Laboratory | http://climate.ornl.gov/~rmills From jed at 59A2.org Sat Feb 20 11:38:28 2010 From: jed at 59A2.org (Jed Brown) Date: Sat, 20 Feb 2010 10:38:28 -0700 Subject: [petsc-users] choosing a preconditioner In-Reply-To: References: <87pr40g69s.fsf@59A2.org> Message-ID: <87aav3g63v.fsf@59A2.org> On Sat, 20 Feb 2010 07:26:56 -0800, Matthew Knepley wrote: > recognizing strong vs. weak coupling As a starting point with (references to) a bunch of examples, I'd recommend Knoll & Keyes JFNK review http://www.cs.odu.edu/~keyes/papers/jfnk.pdf and whichever "stiff wave" papers are relevant to your subject area. Indefinite problems have a lot in common with stiff wave problems, but can require even more special sauce. A fairly comprehensive reference is Benzi, Golub, and Liesen's 2005 Acta Numerica review "Numerical solution of saddle point problems", for incompressible flow specifically, see Elman et al's 2008 "A taxonomy and comparison of parallel block multi-level preconditioners for the incompressible Navier-Stokes equations". Jed From recrusader at gmail.com Sun Feb 21 13:48:09 2010 From: recrusader at gmail.com (Yujie) Date: Sun, 21 Feb 2010 13:48:09 -0600 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <4AE873D0.9030401@59A2.org> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> Message-ID: <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> Hi, Jeb It looks MatGetRow() only can get the nonzero row values for sparse matrix. It is not suitable for A./B if there are different formats between A and B. Thanks. Regards, Yujie On Wed, Oct 28, 2009 at 10:39 AM, Jed Brown wrote: > abhyshr at mcs.anl.gov wrote: > > If A and B are vectors, then you can use VecPointwiseMult for A.*B and > VecPointwiseDivide for A./B. > > For matrices,pointwise multiplication and division functions are not > provided in Petsc. One possible way to do > > A.*B and A./B for matrices is to loop through the columns of the > matrices,call MatGetColumnVector for each column of matrix A,B > > and then call VecPointwiseMult/VecPointwiseDivide. > > This would be very inefficient because it produces dense output and > PETSc matrices are row-aligned. I would suggest using MatGetRow which > is much faster and preserves sparsity. > > Jed > > > > > Shri > > > > ----- Original Message ----- > > From: "Yujie" > > To: "PETSc users list" > > Sent: Wednesday, October 28, 2009 10:21:34 AM GMT -06:00 US/Canada > Central > > Subject: Does PETSc have some functions like A.*B, A./B in Matlab? > > > > Dear PETSc Developers, > > > > Does PETSc provide some functions, like A.*B, A./B in Matlab? Thanks a > lot. > > > > Regards, > > Yujie > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59A2.org Sun Feb 21 14:17:21 2010 From: jed at 59A2.org (Jed Brown) Date: Sun, 21 Feb 2010 13:17:21 -0700 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> Message-ID: <87sk8ue432.fsf@59A2.org> On Sun, 21 Feb 2010 13:48:09 -0600, Yujie wrote: > Hi, Jeb > > It looks MatGetRow() only can get the nonzero row values for sparse matrix. > It is not suitable for A./B if there are different formats between A and B. Of course, but note that B must have at least all the nonzeros of A, otherwise you divide by 0. If you really need to do A./B where A was not preallocated to match B (it is a strict subset), then MatDuplicate B (call it C), loop over rows inserting rows of A into C, then perform the division with MatGetArray B and C (you'll have to work with the off-diagonal blocks separately in parallel). But you would be *much* better off to find a way to assemble the matrix you want rather than these other matrices with inequivalent nonzero patterns. Jed From recrusader at gmail.com Sun Feb 21 14:19:48 2010 From: recrusader at gmail.com (Yujie) Date: Sun, 21 Feb 2010 14:19:48 -0600 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <87sk8ue432.fsf@59A2.org> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> Message-ID: <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> It is not only for A./B. If one wants to do A.*B, it is not necessary to guarantee the nonzeros of B. Generally, I think MatGetValues() will be good choice although you need to judge whether the entries are zero when doing A./B. Yujie On Sun, Feb 21, 2010 at 2:17 PM, Jed Brown wrote: > On Sun, 21 Feb 2010 13:48:09 -0600, Yujie wrote: > > Hi, Jeb > > > > It looks MatGetRow() only can get the nonzero row values for sparse > matrix. > > It is not suitable for A./B if there are different formats between A and > B. > > Of course, but note that B must have at least all the nonzeros of A, > otherwise you divide by 0. If you really need to do A./B where A was > not preallocated to match B (it is a strict subset), then MatDuplicate B > (call it C), loop over rows inserting rows of A into C, then perform the > division with MatGetArray B and C (you'll have to work with the > off-diagonal blocks separately in parallel). > > But you would be *much* better off to find a way to assemble the matrix > you want rather than these other matrices with inequivalent nonzero > patterns. > > Jed > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59a2.org Sun Feb 21 14:29:27 2010 From: jed at 59a2.org (Jed Brown) Date: Sun, 21 Feb 2010 13:29:27 -0700 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> Message-ID: <87r5oee3iw.fsf@59A2.org> On Sun, 21 Feb 2010 14:19:48 -0600, Yujie wrote: > It is not only for A./B. If one wants to do A.*B, it is not necessary to > guarantee the nonzeros of B. Generally, I think MatGetValues() will be good > choice although you need to judge whether the entries are zero when doing > A./B. MatGetValues requires you to know the nonzero pattern of B (or in the case of .*, the union of the nonzeros of A and B). What problem are you trying to solve where you need to do this operation? Perhaps we can suggest a better way. Jed From recrusader at gmail.com Sun Feb 21 14:33:23 2010 From: recrusader at gmail.com (Yujie) Date: Sun, 21 Feb 2010 14:33:23 -0600 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <87r5oee3iw.fsf@59A2.org> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> Message-ID: <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> Thanks very much, Jed. I have a vector (V) and a matrix (A), I want to do Row_i_A.*V or Row_i_A./V (Row_i_A are the rows of A). However, V has different format with the rows of A. If I use MatGetValues(), I don't care whether there are zero entries in A when I extract a row of A. MatGetValues() will fill the entries with zero if the entries are zero in sparse matrix. The problem is I need to be careful when doing Row_i_A./V. Regards, Yujie On Sun, Feb 21, 2010 at 2:29 PM, Jed Brown wrote: > On Sun, 21 Feb 2010 14:19:48 -0600, Yujie wrote: > > It is not only for A./B. If one wants to do A.*B, it is not necessary to > > guarantee the nonzeros of B. Generally, I think MatGetValues() will be > good > > choice although you need to judge whether the entries are zero when doing > > A./B. > > MatGetValues requires you to know the nonzero pattern of B (or in the > case of .*, the union of the nonzeros of A and B). What problem are you > trying to solve where you need to do this operation? Perhaps we can > suggest a better way. > > Jed > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59a2.org Sun Feb 21 14:41:57 2010 From: jed at 59a2.org (Jed Brown) Date: Sun, 21 Feb 2010 13:41:57 -0700 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> Message-ID: <87pr3ye2y2.fsf@59A2.org> On Sun, 21 Feb 2010 14:33:23 -0600, Yujie wrote: > Thanks very much, Jed. > I have a vector (V) and a matrix (A), > I want to do Row_i_A.*V or Row_i_A./V (Row_i_A are the rows of A). However, > V has different format with the rows of A. You need to do this for a small number of rows (values of i), or for many? Since vectors are dense, and since MatGetValues only provides the local part, this is not scalable. What is the problem you are trying to solve with this algebraic manipulation? There is probably a scalable way to formulate the higher-level objective to avoid these shenanigans. Jed From recrusader at gmail.com Sun Feb 21 14:44:55 2010 From: recrusader at gmail.com (Yujie) Date: Sun, 21 Feb 2010 14:44:55 -0600 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <87pr3ye2y2.fsf@59A2.org> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> <87pr3ye2y2.fsf@59A2.org> Message-ID: <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> I need do it for many. Actually, we don't consider a vector. Generally, if A is dense matrix (nonzero entries) and B is sparse matrix, MatGetRow() doesn't work when doing A.*B or A./B directly, right? Thanks a lot. Regards, Yujie On Sun, Feb 21, 2010 at 2:41 PM, Jed Brown wrote: > On Sun, 21 Feb 2010 14:33:23 -0600, Yujie wrote: > > Thanks very much, Jed. > > I have a vector (V) and a matrix (A), > > I want to do Row_i_A.*V or Row_i_A./V (Row_i_A are the rows of A). > However, > > V has different format with the rows of A. > > You need to do this for a small number of rows (values of i), or for > many? Since vectors are dense, and since MatGetValues only provides the > local part, this is not scalable. > > What is the problem you are trying to solve with this algebraic > manipulation? There is probably a scalable way to formulate the > higher-level objective to avoid these shenanigans. > > Jed > -------------- next part -------------- An HTML attachment was scrubbed... URL: From recrusader at gmail.com Sun Feb 21 14:50:40 2010 From: recrusader at gmail.com (Yujie) Date: Sun, 21 Feb 2010 14:50:40 -0600 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> <87pr3ye2y2.fsf@59A2.org> <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> Message-ID: <7ff0ee011002211250o77eb2dbbga0465dedafb6e6d8@mail.gmail.com> Sorry, I made a mistake, it should be A is sparse matrix and B is dense matrix. Yujie On Sun, Feb 21, 2010 at 2:44 PM, Yujie wrote: > I need do it for many. Actually, we don't consider a vector. Generally, if > A is dense matrix (nonzero entries) and B is sparse matrix, MatGetRow() > doesn't work when doing A.*B or A./B directly, right? > Thanks a lot. > > Regards, > Yujie > > > On Sun, Feb 21, 2010 at 2:41 PM, Jed Brown wrote: > >> On Sun, 21 Feb 2010 14:33:23 -0600, Yujie wrote: >> > Thanks very much, Jed. >> > I have a vector (V) and a matrix (A), >> > I want to do Row_i_A.*V or Row_i_A./V (Row_i_A are the rows of A). >> However, >> > V has different format with the rows of A. >> >> You need to do this for a small number of rows (values of i), or for >> many? Since vectors are dense, and since MatGetValues only provides the >> local part, this is not scalable. >> >> What is the problem you are trying to solve with this algebraic >> manipulation? There is probably a scalable way to formulate the >> higher-level objective to avoid these shenanigans. >> >> Jed >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59a2.org Sun Feb 21 14:54:22 2010 From: jed at 59a2.org (Jed Brown) Date: Sun, 21 Feb 2010 13:54:22 -0700 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> <87pr3ye2y2.fsf@59A2.org> <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> Message-ID: <87ocjie2dd.fsf@59A2.org> On Sun, 21 Feb 2010 14:44:55 -0600, Yujie wrote: > I need do it for many. Actually, we don't consider a vector. Generally, if A > is dense matrix (nonzero entries) and B is sparse matrix, MatGetRow() > doesn't work when doing A.*B or A./B directly, right? You can call MatGetRow with all column indices, you have to do something special about dividing by zero. But we're getting caught up in algebraic shenanigans again. What problem are you trying to solve? Why do you have a dense matrix and why do you think you need to perform A./B? Jed From recrusader at gmail.com Sun Feb 21 14:58:39 2010 From: recrusader at gmail.com (Yujie) Date: Sun, 21 Feb 2010 14:58:39 -0600 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <87ocjie2dd.fsf@59A2.org> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> <87pr3ye2y2.fsf@59A2.org> <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> <87ocjie2dd.fsf@59A2.org> Message-ID: <7ff0ee011002211258v1c0dd233vd2e1ca291bed99e@mail.gmail.com> At the beginning, I was just thinking whether PETSc has some similar operations with Matlab like A./B or A.*B. To my understanding, PETSc realizes a parallel operation version of Matlab regarding matrix computations. Thanks, Yujie On Sun, Feb 21, 2010 at 2:54 PM, Jed Brown wrote: > On Sun, 21 Feb 2010 14:44:55 -0600, Yujie wrote: > > I need do it for many. Actually, we don't consider a vector. Generally, > if A > > is dense matrix (nonzero entries) and B is sparse matrix, MatGetRow() > > doesn't work when doing A.*B or A./B directly, right? > > You can call MatGetRow with all column indices, you have to do something > special about dividing by zero. > > But we're getting caught up in algebraic shenanigans again. What > problem are you trying to solve? Why do you have a dense matrix and why > do you think you need to perform A./B? > > Jed > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bsmith at mcs.anl.gov Sun Feb 21 15:03:18 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Sun, 21 Feb 2010 15:03:18 -0600 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <7ff0ee011002211258v1c0dd233vd2e1ca291bed99e@mail.gmail.com> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> <87pr3ye2y2.fsf@59A2.org> <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> <87ocjie2dd.fsf@59A2.org> <7ff0ee011002211258v1c0dd233vd2e1ca291bed99e@mail.gmail.com> Message-ID: PETSc is not a parallel Matlab. You can now purchase a parallel Matlab from the Mathworks company if you want. We have no interest in competing with Matlab. PETSc is specialized to the parallel solution of PDEs and related problems, it is not a general purpose package like Matlab and hence does not have much of the functionality of Matlab. Barry On Feb 21, 2010, at 2:58 PM, Yujie wrote: > At the beginning, I was just thinking whether PETSc has some similar > operations with Matlab like A./B or A.*B. To my understanding, PETSc > realizes a parallel operation version of Matlab regarding matrix > computations. > > Thanks, > Yujie > > On Sun, Feb 21, 2010 at 2:54 PM, Jed Brown wrote: > On Sun, 21 Feb 2010 14:44:55 -0600, Yujie > wrote: > > I need do it for many. Actually, we don't consider a vector. > Generally, if A > > is dense matrix (nonzero entries) and B is sparse matrix, > MatGetRow() > > doesn't work when doing A.*B or A./B directly, right? > > You can call MatGetRow with all column indices, you have to do > something > special about dividing by zero. > > But we're getting caught up in algebraic shenanigans again. What > problem are you trying to solve? Why do you have a dense matrix and > why > do you think you need to perform A./B? > > Jed > From jed at 59a2.org Sun Feb 21 15:07:59 2010 From: jed at 59a2.org (Jed Brown) Date: Sun, 21 Feb 2010 14:07:59 -0700 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <7ff0ee011002211258v1c0dd233vd2e1ca291bed99e@mail.gmail.com> References: <27590708.40941256746112955.JavaMail.root@zimbra> <4AE873D0.9030401@59A2.org> <7ff0ee011002211148m40e35635icb4ae2027ddc722e@mail.gmail.com> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> <87pr3ye2y2.fsf@59A2.org> <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> <87ocjie2dd.fsf@59A2.org> <7ff0ee011002211258v1c0dd233vd2e1ca291bed99e@mail.gmail.com> Message-ID: <87mxz2e1qo.fsf@59A2.org> On Sun, 21 Feb 2010 14:58:39 -0600, Yujie wrote: > At the beginning, I was just thinking whether PETSc has some similar > operations with Matlab like A./B or A.*B. To my understanding, PETSc > realizes a parallel operation version of Matlab regarding matrix > computations. Some operations are best avoided when working with sparse matrices in parallel. There is almost always a way to formulate the problem so that it can be solved in a scalable way, and PETSc prefers this approach to literally translating all Matlab-style operations regardless of efficiency. Jed From recrusader at gmail.com Sun Feb 21 15:09:50 2010 From: recrusader at gmail.com (Yujie) Date: Sun, 21 Feb 2010 15:09:50 -0600 Subject: [petsc-users] Does PETSc have some functions like A.*B, A./B in Matlab? In-Reply-To: <87mxz2e1qo.fsf@59A2.org> References: <27590708.40941256746112955.JavaMail.root@zimbra> <87sk8ue432.fsf@59A2.org> <7ff0ee011002211219p406125b7teb04146c58982217@mail.gmail.com> <87r5oee3iw.fsf@59A2.org> <7ff0ee011002211233p59c33014u93fd4a6a3587c9a@mail.gmail.com> <87pr3ye2y2.fsf@59A2.org> <7ff0ee011002211244p6ec14070g4055ec25972abdcc@mail.gmail.com> <87ocjie2dd.fsf@59A2.org> <7ff0ee011002211258v1c0dd233vd2e1ca291bed99e@mail.gmail.com> <87mxz2e1qo.fsf@59A2.org> Message-ID: <7ff0ee011002211309w1e98ee0dp54dcd0a81a3a8435@mail.gmail.com> Thank you very much for your explanation, Jed and Barry. Regards, Yujie On Sun, Feb 21, 2010 at 3:07 PM, Jed Brown wrote: > On Sun, 21 Feb 2010 14:58:39 -0600, Yujie wrote: > > At the beginning, I was just thinking whether PETSc has some similar > > operations with Matlab like A./B or A.*B. To my understanding, PETSc > > realizes a parallel operation version of Matlab regarding matrix > > computations. > > Some operations are best avoided when working with sparse matrices in > parallel. There is almost always a way to formulate the problem so that > it can be solved in a scalable way, and PETSc prefers this approach to > literally translating all Matlab-style operations regardless of > efficiency. > > Jed > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.mayhem23 at gmail.com Sun Feb 21 15:25:55 2010 From: dave.mayhem23 at gmail.com (Dave May) Date: Sun, 21 Feb 2010 22:25:55 +0100 Subject: [petsc-users] DAGetMatrix() Message-ID: <956373f1002211325m67c7c671h1077c822758af71b@mail.gmail.com> Hello, I have a question about the usage of DAGetMatrix(). Is there any possibility that the matrix preallocation and the indices returned from DAGetGlobalIndices() are incompatible with each other? To clarify my question, I use DAGetMatrix() with a DA created with the lx,ly,lz (local nodes sizes) specified. The resulting DA is used to represent a Q1 finite element mesh. I then use values return from DAGetGlobalIndices() to define the equation number for each dof associated with each element. In the past I've used this approach in parallel without any problems matrix preallocation issues, but I've never specified lx,ly,lz before. What I see now is that for certain grid resolutions and element combinations, -info reports that additional non-zeros are having to be allocated. Is my function to compute the element node relationship screwed, or is there an assumption about when and where DAGetMatrix() is valid. I suspect the former, but looking through the numbers I cannot see any problems. Cheers, Dave From knepley at gmail.com Sun Feb 21 20:26:15 2010 From: knepley at gmail.com (Matthew Knepley) Date: Sun, 21 Feb 2010 18:26:15 -0800 Subject: [petsc-users] DAGetMatrix() In-Reply-To: <956373f1002211325m67c7c671h1077c822758af71b@mail.gmail.com> References: <956373f1002211325m67c7c671h1077c822758af71b@mail.gmail.com> Message-ID: I would turn on the ERR_ON_ALLOCATION option and then do your MatSetValues(). That way the exact location of the allocation is clear. MAybe this will expose the bug. Matt On Sun, Feb 21, 2010 at 1:25 PM, Dave May wrote: > Hello, > I have a question about the usage of DAGetMatrix(). > Is there any possibility that the matrix preallocation and the indices > returned from DAGetGlobalIndices() are incompatible with each other? > > To clarify my question, I use DAGetMatrix() with a DA created with the > lx,ly,lz (local nodes sizes) specified. The resulting DA is used to > represent a Q1 finite element mesh. I then use values return from > DAGetGlobalIndices() to define the equation number for each dof > associated with each element. In the past I've used this approach in > parallel without any problems matrix preallocation issues, but I've > never specified lx,ly,lz before. > > What I see now is that for certain grid resolutions and element > combinations, -info reports that additional non-zeros are having to be > allocated. > > Is my function to compute the element node relationship screwed, or is > there an assumption about when and where DAGetMatrix() is valid. I > suspect the former, but looking through the numbers I cannot see any > problems. > > > Cheers, > Dave > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From Z.Sheng at tudelft.nl Mon Feb 22 03:00:18 2010 From: Z.Sheng at tudelft.nl (Zhifeng Sheng - EWI) Date: Mon, 22 Feb 2010 10:00:18 +0100 Subject: [petsc-users] multiplication with sparse vector ? References: <956373f1002211325m67c7c671h1077c822758af71b@mail.gmail.com> Message-ID: <947C04CD618D16429440FED56EAE47BA06B335@SRV564.tudelft.net> Dear all I would like to multiply a matrix with a vector that has only a few zeros, and I wonder if petsc would take this into account and skip all the unnecessary computation with zeros? Thanks and best regards Zhifeng -------------- next part -------------- An HTML attachment was scrubbed... URL: From knepley at gmail.com Mon Feb 22 06:47:51 2010 From: knepley at gmail.com (Matthew Knepley) Date: Mon, 22 Feb 2010 04:47:51 -0800 Subject: [petsc-users] multiplication with sparse vector ? In-Reply-To: <947C04CD618D16429440FED56EAE47BA06B335@SRV564.tudelft.net> References: <956373f1002211325m67c7c671h1077c822758af71b@mail.gmail.com> <947C04CD618D16429440FED56EAE47BA06B335@SRV564.tudelft.net> Message-ID: PETSc does not do this. You would have to be very sparse to beat BLAS, and then the algorithms change drastically. Matt On Mon, Feb 22, 2010 at 1:00 AM, Zhifeng Sheng - EWI wrote: > Dear all > > I would like to multiply a matrix with a vector that has only a few zeros, > and I wonder if petsc would take this into account and skip all the > unnecessary computation with zeros? > > Thanks and best regards > Zhifeng > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From craig-tanis at utc.edu Mon Feb 22 07:50:34 2010 From: craig-tanis at utc.edu (Craig Tanis) Date: Mon, 22 Feb 2010 08:50:34 -0500 Subject: [petsc-users] choosing a preconditioner In-Reply-To: <87aav3g63v.fsf@59A2.org> References: <87pr40g69s.fsf@59A2.org> <87aav3g63v.fsf@59A2.org> Message-ID: thanks to all of you for the suggestions! -craig On Feb 20, 2010, at 12:38 PM, Jed Brown wrote: > On Sat, 20 Feb 2010 07:26:56 -0800, Matthew Knepley wrote: >> recognizing strong vs. weak coupling > > As a starting point with (references to) a bunch of examples, I'd > recommend Knoll & Keyes JFNK review > > http://www.cs.odu.edu/~keyes/papers/jfnk.pdf > > and whichever "stiff wave" papers are relevant to your subject area. > Indefinite problems have a lot in common with stiff wave problems, but > can require even more special sauce. A fairly comprehensive reference > is Benzi, Golub, and Liesen's 2005 Acta Numerica review "Numerical > solution of saddle point problems", for incompressible flow > specifically, see Elman et al's 2008 "A taxonomy and comparison of > parallel block multi-level preconditioners for the incompressible > Navier-Stokes equations". > > Jed > From hxie at umn.edu Mon Feb 22 10:23:58 2010 From: hxie at umn.edu (hxie at umn.edu) Date: 22 Feb 2010 10:23:58 -0600 Subject: [petsc-users] read command line options from a file In-Reply-To: References: Message-ID: Hi, I'd like to put the command line options into a file and let the PETSc read it. Any example for this? Thanks. Hui From knepley at gmail.com Mon Feb 22 10:24:53 2010 From: knepley at gmail.com (Matthew Knepley) Date: Mon, 22 Feb 2010 10:24:53 -0600 Subject: [petsc-users] read command line options from a file In-Reply-To: References: Message-ID: You just put them in a file: -option1 val1 -option2 val2 Matt On Mon, Feb 22, 2010 at 10:23 AM, wrote: > Hi, > > I'd like to put the command line options into a file and let the PETSc read > it. Any example for this? Thanks. > > Hui > -- 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From F.Cruz at bristol.ac.uk Mon Feb 22 10:38:35 2010 From: F.Cruz at bristol.ac.uk (Felipe Cruz) Date: Mon, 22 Feb 2010 17:38:35 +0100 Subject: [petsc-users] read command line options from a file In-Reply-To: References: Message-ID: <96C39A3E-8C7B-4060-9F4C-1A2C8104BFFF@bristol.ac.uk> There is a petsc function for that, see here: http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-3.0.0/docs/manualpages/Sys/PetscOptionsInsertFile.html The format of the file is what Matt said. Felipe On 22 Feb 2010, at 17:24, Matthew Knepley wrote: > You just put them in a file: > > -option1 val1 > -option2 val2 > > Matt > > On Mon, Feb 22, 2010 at 10:23 AM, wrote: > Hi, > > I'd like to put the command line options into a file and let the > PETSc read it. Any example for this? Thanks. > > Hui > > > > -- > 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 ---------------------------------------------------- Felipe Cruz PhD student Applied Mathematics Department of Mathematics University of Bristol Bristol BS8 1TW, UK ---------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From christian.klettner at ucl.ac.uk Tue Feb 23 04:04:46 2010 From: christian.klettner at ucl.ac.uk (Christian Klettner) Date: Tue, 23 Feb 2010 10:04:46 -0000 Subject: [petsc-users] default preconditioner Message-ID: <8ad67eacd7b465fea3ac3a82021800cf.squirrel@www.squirrelmail.ucl.ac.uk> Dear PETSc, What is the default preconditioner (if i do not explicitly set one)? Best regards, Christian From jed at 59A2.org Tue Feb 23 04:20:46 2010 From: jed at 59A2.org (Jed Brown) Date: Tue, 23 Feb 2010 11:20:46 +0100 Subject: [petsc-users] default preconditioner In-Reply-To: <8ad67eacd7b465fea3ac3a82021800cf.squirrel@www.squirrelmail.ucl.ac.uk> References: <8ad67eacd7b465fea3ac3a82021800cf.squirrel@www.squirrelmail.ucl.ac.uk> Message-ID: <87635o6yo1.fsf@59A2.org> On Tue, 23 Feb 2010 10:04:46 -0000, "Christian Klettner" wrote: > Dear PETSc, > What is the default preconditioner (if i do not explicitly set one)? Short answer: Run with -ksp_view. Long answer: ILU(0) in serial and block Jacobi with ILU(0) on subdomains in parallel, unless using DMMG in which case it is full multigrid with the above on each level (wrapped in a single GMRES iteration) and a redundant coarse level solve. Jed From christian.klettner at ucl.ac.uk Tue Feb 23 06:11:19 2010 From: christian.klettner at ucl.ac.uk (Christian Klettner) Date: Tue, 23 Feb 2010 12:11:19 -0000 Subject: [petsc-users] default preconditioner In-Reply-To: <8ad67eacd7b465fea3ac3a82021800cf.squirrel@www.squirrelmail.ucl.ac.uk> References: <8ad67eacd7b465fea3ac3a82021800cf.squirrel@www.squirrelmail.ucl.ac.uk> Message-ID: <7d872691b6cdd346dcb92eed1e26782c.squirrel@www.squirrelmail.ucl.ac.uk> Thanks Jed. > Dear PETSc, > What is the default preconditioner (if i do not explicitly set one)? > Best regards, > Christian > > From stephen.wornom at sophia.inria.fr Tue Feb 23 07:11:23 2010 From: stephen.wornom at sophia.inria.fr (Stephen Wornom) Date: Tue, 23 Feb 2010 14:11:23 +0100 Subject: [petsc-users] default preconditioner In-Reply-To: <7d872691b6cdd346dcb92eed1e26782c.squirrel@www.squirrelmail.ucl.ac.uk> References: <8ad67eacd7b465fea3ac3a82021800cf.squirrel@www.squirrelmail.ucl.ac.uk> <7d872691b6cdd346dcb92eed1e26782c.squirrel@www.squirrelmail.ucl.ac.uk> Message-ID: <4B83D3FB.80903@sophia.inria.fr> Christian Klettner wrote: > Thanks Jed. > > >> Dear PETSc, >> What is the default preconditioner (if i do not explicitly set one)? >> Best regards, >> Christian >> >> >> > > > Apparently Jed gave you the answer in a non-list e-mail. For the list users, please let the list know for what you are thanking Jed. Stephen -- stephen.wornom at sophia.inria.fr 2004 route des lucioles - BP93 Sophia Antipolis 06902 CEDEX Tel: 04 92 38 50 54 Fax: 04 97 15 53 51 -------------- next part -------------- A non-text attachment was scrubbed... Name: stephen_wornom.vcf Type: text/x-vcard Size: 160 bytes Desc: not available URL: From jed at 59A2.org Tue Feb 23 07:16:26 2010 From: jed at 59A2.org (Jed Brown) Date: Tue, 23 Feb 2010 14:16:26 +0100 Subject: [petsc-users] default preconditioner In-Reply-To: <4B83D3FB.80903@sophia.inria.fr> References: <8ad67eacd7b465fea3ac3a82021800cf.squirrel@www.squirrelmail.ucl.ac.uk> <7d872691b6cdd346dcb92eed1e26782c.squirrel@www.squirrelmail.ucl.ac.uk> <4B83D3FB.80903@sophia.inria.fr> Message-ID: <87ljek5byt.fsf@59A2.org> On Tue, 23 Feb 2010 14:11:23 +0100, Stephen Wornom wrote: > Apparently Jed gave you the answer in a non-list e-mail. For the list > users, please let the list know for what you are thanking Jed. I don't know why you would have not received it. http://lists.mcs.anl.gov/pipermail/petsc-users/2010-February/005969.html Jed From jed at 59A2.org Tue Feb 23 07:31:52 2010 From: jed at 59A2.org (Jed Brown) Date: Tue, 23 Feb 2010 14:31:52 +0100 Subject: [petsc-users] default preconditioner In-Reply-To: <87ljek5byt.fsf@59A2.org> References: <8ad67eacd7b465fea3ac3a82021800cf.squirrel@www.squirrelmail.ucl.ac.uk> <7d872691b6cdd346dcb92eed1e26782c.squirrel@www.squirrelmail.ucl.ac.uk> <4B83D3FB.80903@sophia.inria.fr> <87ljek5byt.fsf@59A2.org> Message-ID: <87k4u45b93.fsf@59A2.org> One further caveat is that known symmetric systems (either because you have set MAT_SYMMETRIC, or the matrix format is SBAIJ) are treated with ICC(0), bjacobi/ICC(0), and Cholesky inside the redundant solve in FMG. Note that this is probably not what you want if you have a symmetric indefinite system. Jed From u.tabak at tudelft.nl Thu Feb 25 02:13:53 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Thu, 25 Feb 2010 09:13:53 +0100 Subject: [petsc-users] external solvers Message-ID: <4B863141.30300@tudelft.nl> Dear all, I was trying to use some external solvers interfaced to PETSc however I am experiencing some problems in the solution process. First of all, my matrices are ill-conditioned and if I do not use -pc_factor_shift_nonzero or -pc_factor_shift_positive_definite, I can not solve the systems, with these command line options, solution phase goes fine(However I could not understand what these options are really doing, adding some entries to the diagonal, the operator matrix is changed and some kind of other operations are used to back I suppose, keeping this in mind, could not the same shifting applied for iterative methods as well to make the system better conditioned, excuse me if this question is too naive and lacking theoretical background). If I try to use the same options with some external solvers by the command line option, for example mumps, spooles, superlu with -pc_factor_mat_solver_package mumps, I can not get the right solution. What might be going wrong or ,highly probably, what could be the mistake I am doing? Best regards, Umut From jed at 59A2.org Thu Feb 25 06:10:36 2010 From: jed at 59A2.org (Jed Brown) Date: Thu, 25 Feb 2010 13:10:36 +0100 Subject: [petsc-users] external solvers In-Reply-To: <4B863141.30300@tudelft.nl> References: <4B863141.30300@tudelft.nl> Message-ID: <87635ltt1f.fsf@59A2.org> On Thu, 25 Feb 2010 09:13:53 +0100, Umut Tabak wrote: > I was trying to use some external solvers interfaced to PETSc however I > am experiencing some problems in the solution process. First of all, my > matrices are ill-conditioned and if I do not use > -pc_factor_shift_nonzero or -pc_factor_shift_positive_definite, I can > not solve the systems, with these command line options, solution phase > goes fine(However I could not understand what these options are really > doing, adding some entries to the diagonal, Note that shifting changes the matrix so you should always check residuals, and wrap it in an iterative method when you are getting the wrong solution due to the shift. > If I try to use the same options with some external solvers by the > command line option, for example mumps, spooles, superlu with > -pc_factor_mat_solver_package mumps, I can not get the right solution. Is the matrix actually singular or just very ill conditioned? See the -mat_mumps_icntl_* options (look at the MUMPS user's manual for details). SuperLU has a similar option, and both have "iterative refinement", which might help. Finally, depending on your application, it may be possible to reformulate your problem to have better conditioning. Jed From u.tabak at tudelft.nl Thu Feb 25 07:19:17 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Thu, 25 Feb 2010 14:19:17 +0100 Subject: [petsc-users] external solvers In-Reply-To: <87635ltt1f.fsf@59A2.org> References: <4B863141.30300@tudelft.nl> <87635ltt1f.fsf@59A2.org> Message-ID: <4B8678D5.9000801@tudelft.nl> > Note that shifting changes the matrix so you should always check > residuals, and wrap it in an iterative method when you are getting the > wrong solution due to the shift. > > Dear Jed, Thanks for the swift reply. I am not sure I understood this, my main problem was due to the badly conditioned matrices where the convergence was really too slow for the iterative methods, cg especially. Then I just came up with a paper where they are comparing some iterative methods and direct solvers from HSL(namely, MA57) similar to the ones I have, extracted from commercial FE codes where the conditioning of the matrices are on the order of 10e8 or larger for shell type elements(besides I also need shell type elements in my computations for the moment), but my matrices are worser in condition numbers in comparison to the ones that they extracted. A bit of technical detail. After I saw these shifting options, -pc_factor_shift_nonzero or -pc_factor_shift_positive_definite, in the trouble shooting, I wondered why this kind of shift can not be applied to make the systems better conditioned, namely, adding on the diagonal ( A +alpha * I )x = b in that paper they give references to Manteuffel's two papers, when I saw that name also in the manual pages, a ring belt so that was the story if similar things could be applied or not, I have not checked those papers on incomplete cholesky factorization yet though. This is what I mean, you transform the system to another one, but how to recover back to the original problem? On paper I am checking how these kinds of tricks might work, but I guess, like applying a preconditioner to a matrix, that is not possible. Your explanation above is not clear to me yet. > Is the matrix actually singular or just very ill conditioned? See the > -mat_mumps_icntl_* options (look at the MUMPS user's manual for > details). SuperLU has a similar option, and both have "iterative > refinement", which might help. Finally, depending on your application, > it may be possible to reformulate your problem to have better > conditioning. > > Matrices are pretty badly conditioned. Moreover one is singular but to form an operator matrix. I am subtracting another scaled matrix from the singular one. As of, Operator = Sing_Mat - alpha * Another_Mat ; (alpha is large btw, on the order of e5) where Another_Mat is also badly conditioned but in theory this should not be singular, can be badly conditioned still though. Thanks for the pointers. Best Umut From jed at 59A2.org Thu Feb 25 07:47:20 2010 From: jed at 59A2.org (Jed Brown) Date: Thu, 25 Feb 2010 14:47:20 +0100 Subject: [petsc-users] external solvers In-Reply-To: <4B8678D5.9000801@tudelft.nl> References: <4B863141.30300@tudelft.nl> <87635ltt1f.fsf@59A2.org> <4B8678D5.9000801@tudelft.nl> Message-ID: <874ol5tok7.fsf@59A2.org> On Thu, 25 Feb 2010 14:19:17 +0100, Umut Tabak wrote: > I am not sure I understood this, my main problem was due to the badly > conditioned matrices where the convergence was really too slow for the > iterative methods, cg especially. I misunderstood since you were trying direct solvers like MUMPS (which many people run under -ksp_type preonly). > ( A +alpha * I )x = b [snip] > This is what I mean, you transform the system to another one, but how to > recover back to the original problem? Normally this shift is only applied as needed within the preconditioner. So you have L*L' ~= A+D where D is diagonal (but not usually a multiple of the identity). Since the iterative method still uses A, you should still converge to the correct answer, but it may be slow if D ended up being large. One interesting idea that Barry suggested a while back is to do a first-order Taylor expansion of inv(A) in terms of inv(A+D), something like A^{-1} = (A+D-D)^{-1} (A+D) (A+D)^{-1} = [(A+D)^{-1} (A+D-D)]^{-1} (A+D)^{-1} = [I - (A+D)^{-1} D]^{-1} (A+D)^{-1} ~= [I + (A+D)^{-1} D] (A+D)^{-1} I haven't tried this, but I'd like to hear if it helps. > Matrices are pretty badly conditioned. Moreover one is singular but to > form an operator matrix. I am subtracting another scaled matrix from the > singular one. As of, > > Operator = Sing_Mat - alpha * Another_Mat ; (alpha is large btw, on the > order of e5) Is this producing negative eigenvalues? CG and (incomplete) Cholesky assume that the system is positive definite, if your system is indefinite, then you will have to investigate other options. Jed From u.tabak at tudelft.nl Thu Feb 25 07:53:33 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Thu, 25 Feb 2010 14:53:33 +0100 Subject: [petsc-users] external solvers In-Reply-To: <874ol5tok7.fsf@59A2.org> References: <4B863141.30300@tudelft.nl> <87635ltt1f.fsf@59A2.org> <4B8678D5.9000801@tudelft.nl> <874ol5tok7.fsf@59A2.org> Message-ID: <4B8680DD.5010509@tudelft.nl> Jed Brown wrote: > I misunderstood since you were trying direct solvers like MUMPS (which > many people run under -ksp_type preonly). > > Dear Jed, Thanks first of all. I gave a try to direct solvers just to see how they are performing... > Normally this shift is only applied as needed within the preconditioner. > So you have L*L' ~= A+D where D is diagonal (but not usually a multiple > of the identity). Since the iterative method still uses A, you should > still converge to the correct answer, but it may be slow if D ended up > being large. One interesting idea that Barry suggested a while back is > to do a first-order Taylor expansion of inv(A) in terms of inv(A+D), > something like > > A^{-1} = (A+D-D)^{-1} (A+D) (A+D)^{-1} > = [(A+D)^{-1} (A+D-D)]^{-1} (A+D)^{-1} > = [I - (A+D)^{-1} D]^{-1} (A+D)^{-1} > ~= [I + (A+D)^{-1} D] (A+D)^{-1} > > I haven't tried this, but I'd like to hear if it helps. > > An interesting idea, worth trying, and let the list know about that. That is clear now, the shift is used for the preconditioner. > > Is this producing negative eigenvalues? CG and (incomplete) Cholesky > assume that the system is positive definite, if your system is > indefinite, then you will have to investigate other options. > Unfortunately, in some kind of iteration loop where I update the operator matrix and rhs, sometimes eigenvalues might be negative the first ones, which screws up things... I am pretty happy that experts are around ;) Best regards, Umut From bsmith at mcs.anl.gov Thu Feb 25 08:24:19 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Thu, 25 Feb 2010 08:24:19 -0600 Subject: [petsc-users] external solvers In-Reply-To: <4B8678D5.9000801@tudelft.nl> References: <4B863141.30300@tudelft.nl> <87635ltt1f.fsf@59A2.org> <4B8678D5.9000801@tudelft.nl> Message-ID: On Feb 25, 2010, at 7:19 AM, Umut Tabak wrote: > >> Note that shifting changes the matrix so you should always check >> residuals, and wrap it in an iterative method when you are getting >> the >> wrong solution due to the shift. >> >> > Dear Jed, > Thanks for the swift reply. > > I am not sure I understood this, my main problem was due to the > badly conditioned matrices where the convergence was really too slow > for the iterative methods, cg especially. Then I just came up with a > paper where they are comparing some iterative methods and direct > solvers from HSL(namely, MA57) similar to the ones I have, extracted > from commercial FE codes where the conditioning of the matrices are > on the order of 10e8 or larger for shell type elements(besides I > also need shell type elements in my computations for the moment), General purpose iterative methods are likely to be useless for this type of problem. How large are the problems you wish to solve? If less then a few million I'd stick to direct methods like MUMPS. Barry > but my matrices are worser in condition numbers in comparison to the > ones that they extracted. A bit of technical detail. > > After I saw these shifting options, -pc_factor_shift_nonzero or - > pc_factor_shift_positive_definite, in the trouble shooting, I > wondered why this kind of shift can not be applied to make the > systems better conditioned, namely, adding on the diagonal > > ( A +alpha * I )x = b > > in that paper they give references to Manteuffel's two papers, when > I saw that name also in the manual pages, a ring belt so that was > the story if similar things could be applied or not, I have not > checked those papers on incomplete cholesky factorization yet though. > > This is what I mean, you transform the system to another one, but > how to recover back to the original problem? On paper I am checking > how these kinds of tricks might work, but I guess, like applying a > preconditioner to a matrix, that is not possible. Your explanation > above is not clear to me yet. > >> Is the matrix actually singular or just very ill conditioned? See >> the >> -mat_mumps_icntl_* options (look at the MUMPS user's manual for >> details). SuperLU has a similar option, and both have "iterative >> refinement", which might help. Finally, depending on your >> application, >> it may be possible to reformulate your problem to have better >> conditioning. >> >> > Matrices are pretty badly conditioned. Moreover one is singular but > to form an operator matrix. I am subtracting another scaled matrix > from the singular one. As of, > > Operator = Sing_Mat - alpha * Another_Mat ; (alpha is large btw, on > the order of e5) > > where Another_Mat is also badly conditioned but in theory this > should not be singular, can be badly conditioned still though. > > Thanks for the pointers. > > Best Umut From u.tabak at tudelft.nl Thu Feb 25 08:34:06 2010 From: u.tabak at tudelft.nl (Umut Tabak) Date: Thu, 25 Feb 2010 15:34:06 +0100 Subject: [petsc-users] external solvers In-Reply-To: References: <4B863141.30300@tudelft.nl> <87635ltt1f.fsf@59A2.org> <4B8678D5.9000801@tudelft.nl> Message-ID: <4B868A5E.9000601@tudelft.nl> Barry Smith wrote: > General purpose iterative methods are likely to be useless for this > type of problem. How large are the problems you wish to solve? If less > then a few million I'd stick to direct methods like MUMPS. Say, 5e4 to 1e5. This is also the conclusion, I got from the tests and extensive reading I have done in the last days. The only hope was to be able to espace from the factorizations by using iterative methods. Simple MATLAB type tests were giving pretty promising results for a method that I was trying to develop(with the backslash, expensive however). And it was an idea whether there can be improvement with iterative methods and preconditioning or not(being aware of the facts about the conditioning issues), Thanks again. Best regards, Umut From hzhang at mcs.anl.gov Thu Feb 25 09:12:50 2010 From: hzhang at mcs.anl.gov (Hong Zhang) Date: Thu, 25 Feb 2010 09:12:50 -0600 Subject: [petsc-users] external solvers In-Reply-To: <4B868A5E.9000601@tudelft.nl> References: <4B863141.30300@tudelft.nl> <87635ltt1f.fsf@59A2.org> <4B8678D5.9000801@tudelft.nl> <4B868A5E.9000601@tudelft.nl> Message-ID: Umut: >> General purpose iterative methods are likely to be useless for >> this type of problem. How large are the problems you wish to solve? >> If less then a few million I'd stick to direct methods like MUMPS. > Say, 5e4 to 1e5. Sequential mumps can handle 1e4, depends on sparse structure of matrix factors. Parallel mumps should be able to process 1e5. > > This is also the conclusion, I got from the tests and extensive > reading I have done in the last days. The only hope was to be able > to espace from the factorizations by using iterative methods. Factorization is expensive. But when your matrix is very ill- conditioned, iterative methods simply do not converge, or "useless for this type of problem" as Barry mentioned. > > Simple MATLAB type tests were giving pretty promising results for a > method that I was trying to develop(with the backslash, expensive > however). "\" in Matlab means director solver. It is expensive, but works. > And it was an idea whether there can be improvement with iterative > methods and preconditioning or not(being aware of the facts about > the conditioning issues), Thanks again. Again, for very ill-conditioned problems, only expensive direct solvers work. Hong From torres.pedrozpk at gmail.com Thu Feb 25 10:16:56 2010 From: torres.pedrozpk at gmail.com (Pedro Torres) Date: Thu, 25 Feb 2010 13:16:56 -0300 Subject: [petsc-users] Push Back in Vector Message-ID: Hello, There is function that work with Vector object similar to push_back() in STL?. If not, which is the best way to deal with this?. Thanks in advance!. Pedro Torres -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59A2.org Thu Feb 25 10:23:27 2010 From: jed at 59A2.org (Jed Brown) Date: Thu, 25 Feb 2010 17:23:27 +0100 Subject: [petsc-users] Push Back in Vector In-Reply-To: References: Message-ID: <873a0pthc0.fsf@59A2.org> On Thu, 25 Feb 2010 13:16:56 -0300, Pedro Torres wrote: > Hello, > > There is function that work with Vector object similar to push_back() in > STL?. If not, which is the best way to deal with this?. What are you trying to do? Vec is not a stack, queue, or dynamically sized list-like structure, you have to decide what size it is (and it's parallel layout) before using it. Jed From torres.pedrozpk at gmail.com Thu Feb 25 10:37:21 2010 From: torres.pedrozpk at gmail.com (Pedro Torres) Date: Thu, 25 Feb 2010 13:37:21 -0300 Subject: [petsc-users] Push Back in Vector In-Reply-To: <873a0pthc0.fsf@59A2.org> References: <873a0pthc0.fsf@59A2.org> Message-ID: 2010/2/25 Jed Brown > On Thu, 25 Feb 2010 13:16:56 -0300, Pedro Torres < > torres.pedrozpk at gmail.com> wrote: > > Hello, > > > > There is function that work with Vector object similar to push_back() in > > STL?. If not, which is the best way to deal with this?. > > What are you trying to do? Vec is not a stack, queue, or dynamically > sized list-like structure, you have to decide what size it is (and it's > parallel layout) before using it. > Well, in my case I have a sequential vector and I'm trying to append one element at the end of the array, without the need of destroy this. So, if I can't, the procedure would be: - Get the array of the old vector - Create a new vector with size+1 - copy old array in the new array and append the element, - destroy old vector There is a better way? Thanks a lot! Pedro > > Jed > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59A2.org Thu Feb 25 10:45:18 2010 From: jed at 59A2.org (Jed Brown) Date: Thu, 25 Feb 2010 17:45:18 +0100 Subject: [petsc-users] Push Back in Vector In-Reply-To: References: <873a0pthc0.fsf@59A2.org> Message-ID: <871vg9tgbl.fsf@59A2.org> On Thu, 25 Feb 2010 13:37:21 -0300, Pedro Torres wrote: > Well, in my case I have a sequential vector and I'm trying to append one > element at the end of the array, without the need of destroy this. PETSc Vec doesn't work this way. Use whatever data structure you like to put this thing together, then give it to PETSc once you know what you have. > - Create a new vector with size+1 > - copy old array in the new array and append the element, This is what dynamically sized array containers (e.g. std::vector) do internally, but they guess at how much extra will be needed (usually increasing the allocated size by a geometric factor). (When I asked what you are trying to do, I was looking for a higher level description of what you wanted to achieve, and why you thought appending to a Vec was a desirable thing.) Jed From recrusader at gmail.com Thu Feb 25 11:07:47 2010 From: recrusader at gmail.com (Yujie) Date: Thu, 25 Feb 2010 11:07:47 -0600 Subject: [petsc-users] Could you add MatRealPart() and MatImaginaryPart( ) with SEQ- and MPI-Dense for me? Message-ID: <7ff0ee011002250907k6cf2c0f2u8742d4a500eaf3ff@mail.gmail.com> Hi, PETSc Developers, I am trying to use MatRealPart() and MatImaginaryPart( ) with SEQ and MPI Dense. However, there is not corresponding functions for them. Whether can you add it currently? Thanks a lot. Regards, Yujie -------------- next part -------------- An HTML attachment was scrubbed... URL: From rlchen2008 at 163.com Thu Feb 25 11:08:34 2010 From: rlchen2008 at 163.com (rlchen2008) Date: Fri, 26 Feb 2010 01:08:34 +0800 (CST) Subject: [petsc-users] How to zeros all entries of a set of columns of a matrix In-Reply-To: References: Message-ID: Dear all, Who can tell me how to zero all entries of a set of COLUMNS of a matrix and let all diagonals of eliminated COLUMNS be 1.0? Thanks! Rongliang -------------- next part -------------- An HTML attachment was scrubbed... URL: From hzhang at mcs.anl.gov Thu Feb 25 11:39:38 2010 From: hzhang at mcs.anl.gov (Hong Zhang) Date: Thu, 25 Feb 2010 11:39:38 -0600 Subject: [petsc-users] Could you add MatRealPart() and MatImaginaryPart( ) with SEQ- and MPI-Dense for me? In-Reply-To: <7ff0ee011002250907k6cf2c0f2u8742d4a500eaf3ff@mail.gmail.com> References: <7ff0ee011002250907k6cf2c0f2u8742d4a500eaf3ff@mail.gmail.com> Message-ID: <215BAA1D-4102-4D55-A89B-D0874884E92B@mcs.anl.gov> On Feb 25, 2010, at 11:07 AM, Yujie wrote: > Hi, PETSc Developers, > > I am trying to use MatRealPart() and MatImaginaryPart( ) with SEQ > and MPI Dense. However, there is not corresponding functions for > them. Whether can you add it currently? Thanks a lot. PetscRealPart() and PetscImaginaryPart(). Hong From recrusader at gmail.com Thu Feb 25 11:53:07 2010 From: recrusader at gmail.com (Yujie) Date: Thu, 25 Feb 2010 11:53:07 -0600 Subject: [petsc-users] Could you add MatRealPart() and MatImaginaryPart( ) with SEQ- and MPI-Dense for me? In-Reply-To: <215BAA1D-4102-4D55-A89B-D0874884E92B@mcs.anl.gov> References: <7ff0ee011002250907k6cf2c0f2u8742d4a500eaf3ff@mail.gmail.com> <215BAA1D-4102-4D55-A89B-D0874884E92B@mcs.anl.gov> Message-ID: <7ff0ee011002250953v77b270efm7d149851b524dc9f@mail.gmail.com> Dear Hong, Thank you very much for your reply. I mean that there are not relevant functions in PETSc. If you guys don't have plan to add them, I will do it by myself. Thanks a lot. Regards, Yujie On Thu, Feb 25, 2010 at 11:39 AM, Hong Zhang wrote: > > On Feb 25, 2010, at 11:07 AM, Yujie wrote: > > Hi, PETSc Developers, >> >> I am trying to use MatRealPart() and MatImaginaryPart( ) with SEQ and MPI >> Dense. However, there is not corresponding functions for them. Whether can >> you add it currently? Thanks a lot. >> > > PetscRealPart() and PetscImaginaryPart(). > > Hong > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59A2.org Thu Feb 25 12:00:50 2010 From: jed at 59A2.org (Jed Brown) Date: Thu, 25 Feb 2010 19:00:50 +0100 Subject: [petsc-users] Could you add MatRealPart() and MatImaginaryPart( ) with SEQ- and MPI-Dense for me? In-Reply-To: <7ff0ee011002250953v77b270efm7d149851b524dc9f@mail.gmail.com> References: <7ff0ee011002250907k6cf2c0f2u8742d4a500eaf3ff@mail.gmail.com> <215BAA1D-4102-4D55-A89B-D0874884E92B@mcs.anl.gov> <7ff0ee011002250953v77b270efm7d149851b524dc9f@mail.gmail.com> Message-ID: <87zl2xry99.fsf@59A2.org> On Thu, 25 Feb 2010 11:53:07 -0600, Yujie wrote: > Dear Hong, > > Thank you very much for your reply. I mean that there are not relevant > functions in PETSc. If you guys don't have plan to add them, I will do it by > myself. Thanks a lot. These (and MatConjugate) would be easy to implement if you are willing to do it. Look at how it is done in, e.g. src/mat/impls/aij/seq/aij.c, then put the same sort of thing into src/mat/impls/dense/seq/dense.c, and send a patch. Jed From bsmith at mcs.anl.gov Thu Feb 25 12:54:13 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Thu, 25 Feb 2010 12:54:13 -0600 Subject: [petsc-users] How to zeros all entries of a set of columns of a matrix In-Reply-To: References: Message-ID: <6374BBC9-1FF0-45EC-B4FE-1121D8200D75@mcs.anl.gov> We get this question a lot so it has its own FAQ. When solving a symmetric system with Dirichlet boundary conditions I can use MatZeroRows() to eliminate the Dirichlet rows but this results in a non-symmetric system. How come there is no MatZeroColumns() to keep the matrix symmetric?

For the default PETSc sparse matrix data structures (parallel and sequential) which are row based, zeroing certain columns is very expensive (it would require either searches or additional data structures). Hence we don't provide this functionality. One can solve Dirichilet boundary condition problems using symmetric methods two ways. (1) Manually call MatGetSubMatrix() to extract your symmetric subproblem or (2) call MatZeroRows() then use the PCREDISTRIBUTE preconditioner to solve the reduced system using symmetric methods. See its manual page.
Does this help you understand the situation? Or are you dealing with a very different situation? Barry On Feb 25, 2010, at 11:08 AM, rlchen2008 wrote: > Dear all, > > Who can tell me how to zero all entries of a set of COLUMNS of a > matrix and let all diagonals of eliminated COLUMNS be 1.0? > Thanks! > > Rongliang > > From recrusader at gmail.com Thu Feb 25 13:59:02 2010 From: recrusader at gmail.com (Yujie) Date: Thu, 25 Feb 2010 11:59:02 -0800 Subject: [petsc-users] Could you add MatRealPart() and MatImaginaryPart( ) with SEQ- and MPI-Dense for me? In-Reply-To: <87wry1rvu9.fsf@59A2.org> References: <7ff0ee011002250907k6cf2c0f2u8742d4a500eaf3ff@mail.gmail.com> <215BAA1D-4102-4D55-A89B-D0874884E92B@mcs.anl.gov> <7ff0ee011002250953v77b270efm7d149851b524dc9f@mail.gmail.com> <87zl2xry99.fsf@59A2.org> <7ff0ee011002251002q44693085qceb68bd669108913@mail.gmail.com> <87y6ihrx42.fsf@59A2.org> <7ff0ee011002251043r6ac5afe3x3206cf38647f1bbc@mail.gmail.com> <87wry1rvu9.fsf@59A2.org> Message-ID: <7ff0ee011002251159t54054686w29c0ce17b8fb7db7@mail.gmail.com> Dear Jed, According to the codes you added, I added them in PETSc 3.0.0p8 I am using. However, when I compile it, I get the following errors "libfast in: /home/yujie/codes/petsc-3.0.0-p8_complex/src/mat/impls/dense/seq/ftn-custom libfast in: /home/yujie/codes/petsc-3.0.0-p8_complex/src/mat/impls/dense/mpi mpidense.c:1583: error: invalid conversion from 'PetscErrorCode (*)(_p_Mat*)' to 'PetscErrorCode (*)(_p_Mat*, _p_Mat*, _p_Mat*)' mpidense.c:1583: error: invalid conversion from 'PetscErrorCode (*)(_p_Mat*)' to 'PetscErrorCode (*)(_p_Mat*, PetscInt, const PetscScalar*)' /usr/bin/ar: mpidense.o: No such file or directory " I use "C++" mode for compilation. In PETsc I am using , the codes are around Line 1583: " /*100*/0, 0, 0, MatConjugate_MPIDense, //by Yujie 0, /*105*/0, MatRealPart_MPIDense, MatImaginaryPart_MPIDense, 0, 0 }; //here is 1583 EXTERN_C_BEGIN #undef __FUNCT__ #define __FUNCT__ "MatMPIDenseSetPreallocation_MPIDense" " Thanks a lot. Regards, Yujie On Thu, Feb 25, 2010 at 10:53 AM, Jed Brown wrote: > On Thu, 25 Feb 2010 12:43:35 -0600, Yujie wrote: > > Dear Jed, > > > > Should You add the judgemnet to the complex number? > > It should be fine. PetscConj, PetscRealPart, PetscImaginaryPart are > defined without PETSC_USE_COMPLEX, and the loop is completely compiled > out at high optimization levels. > > Jed > -------------- next part -------------- An HTML attachment was scrubbed... URL: From recrusader at gmail.com Thu Feb 25 14:06:50 2010 From: recrusader at gmail.com (Yujie) Date: Thu, 25 Feb 2010 14:06:50 -0600 Subject: [petsc-users] Could you add MatRealPart() and MatImaginaryPart( ) with SEQ- and MPI-Dense for me? In-Reply-To: <87y6ihrx42.fsf@59A2.org> References: <7ff0ee011002250907k6cf2c0f2u8742d4a500eaf3ff@mail.gmail.com> <215BAA1D-4102-4D55-A89B-D0874884E92B@mcs.anl.gov> <7ff0ee011002250953v77b270efm7d149851b524dc9f@mail.gmail.com> <87zl2xry99.fsf@59A2.org> <7ff0ee011002251002q44693085qceb68bd669108913@mail.gmail.com> <87y6ihrx42.fsf@59A2.org> Message-ID: <7ff0ee011002251206g72677709n1c2f1c73de6b0cdf@mail.gmail.com> I also compare the position of functions you added in mpidense.c with aij.c. You likely made a mistake. The information is as follows from mpidense.c " 1589 /*99*/ 0, 1590 0, 1591 0, 1592 MatConjugate_MPIDense, 1593 0, 1594 /*104*/0, 1595 MatRealPart_MPIDense, 1596 MatImaginaryPart_MPIDense, 1597 0 1598 }; " from aij.c " 2563: /*100*/MatPtAPNumeric_SeqAIJ_SeqAIJ, 2564: 0, 2565: 0, 2566: MatConjugate_SeqAIJ, 2567: 0, 2568: /*105*/MatSetValuesRow_SeqAIJ, 2569: MatRealPart_SeqAIJ, 2570: MatImaginaryPart_SeqAIJ, 2571: 0, 2572: 0, 2573: /*110*/0, 2574: 0, 2575: MatGetRowMin_SeqAIJ, 2576: 0, 2577: MatMissingDiagonal_SeqAIJ 2578: }; " Thanks, Yujie On Thu, Feb 25, 2010 at 12:25 PM, Jed Brown wrote: > > On Thu, 25 Feb 2010 12:02:54 -0600, Yujie wrote: > > Thanks, Jed. Dense has the same loop for entries with AIJ like > > Never mind, I just put it into petsc-dev > > ?http://petsc.cs.iit.edu/petsc/petsc-dev/rev/326aecc4d312 > > I haven't tested it, so let me know if I messed up. > > Jed From torres.pedrozpk at gmail.com Thu Feb 25 19:50:30 2010 From: torres.pedrozpk at gmail.com (Pedro Torres) Date: Thu, 25 Feb 2010 22:50:30 -0300 Subject: [petsc-users] Push Back in Vector In-Reply-To: <871vg9tgbl.fsf@59A2.org> References: <873a0pthc0.fsf@59A2.org> <871vg9tgbl.fsf@59A2.org> Message-ID: 2010/2/25 Jed Brown > On Thu, 25 Feb 2010 13:37:21 -0300, Pedro Torres < > torres.pedrozpk at gmail.com> wrote: > > Well, in my case I have a sequential vector and I'm trying to append one > > element at the end of the array, without the need of destroy this. > > PETSc Vec doesn't work this way. Use whatever data structure you like > to put this thing together, then give it to PETSc once you know what you > have. > > > - Create a new vector with size+1 > > - copy old array in the new array and append the element, > > This is what dynamically sized array containers (e.g. std::vector) do > internally, but they guess at how much extra will be needed (usually > increasing the allocated size by a geometric factor). > > (When I asked what you are trying to do, I was looking for a higher > level description of what you wanted to achieve, and why you thought > appending to a Vec was a desirable thing.) > The things is that I don't have the final dimension of the vector, because it depends of mesh size, boundary conditions,etc. But I think that I can do the following, - use std::vector - when I get final size, I create a Vec with VecCreateSeqWithArray and Petsc will use the array in std::vector. Is that right? Thanks a lot! Pedro > > Jed > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bsmith at mcs.anl.gov Thu Feb 25 20:18:47 2010 From: bsmith at mcs.anl.gov (Barry Smith) Date: Thu, 25 Feb 2010 20:18:47 -0600 Subject: [petsc-users] Push Back in Vector In-Reply-To: References: <873a0pthc0.fsf@59A2.org> <871vg9tgbl.fsf@59A2.org> Message-ID: <46502102-BF4A-45BE-863D-C8051304C5CE@mcs.anl.gov> On Feb 25, 2010, at 7:50 PM, Pedro Torres wrote: > > > 2010/2/25 Jed Brown > On Thu, 25 Feb 2010 13:37:21 -0300, Pedro Torres > wrote: > > Well, in my case I have a sequential vector and I'm trying to > append one > > element at the end of the array, without the need of destroy this. > > PETSc Vec doesn't work this way. Use whatever data structure you like > to put this thing together, then give it to PETSc once you know what > you > have. > > > - Create a new vector with size+1 > > - copy old array in the new array and append the element, > > This is what dynamically sized array containers (e.g. std::vector) do > internally, but they guess at how much extra will be needed (usually > increasing the allocated size by a geometric factor). > > (When I asked what you are trying to do, I was looking for a higher > level description of what you wanted to achieve, and why you thought > appending to a Vec was a desirable thing.) > > The things is that I don't have the final dimension of the vector, > because it depends of mesh size, boundary conditions,etc. But I > think that I can do the following, > > - use std::vector > - when I get final size, I create a Vec with VecCreateSeqWithArray > and Petsc will use the array in std::vector. You could do this. In general what we do is to "process" the mesh, boundary conditions etc to determine the needed size, set the vector size, then go back and compute the vector/matrix entries. Barry > > Is that right? > > Thanks a lot! > > Pedro > > > Jed > From torres.pedrozpk at gmail.com Thu Feb 25 20:33:06 2010 From: torres.pedrozpk at gmail.com (Pedro Torres) Date: Thu, 25 Feb 2010 23:33:06 -0300 Subject: [petsc-users] Push Back in Vector In-Reply-To: <46502102-BF4A-45BE-863D-C8051304C5CE@mcs.anl.gov> References: <873a0pthc0.fsf@59A2.org> <871vg9tgbl.fsf@59A2.org> <46502102-BF4A-45BE-863D-C8051304C5CE@mcs.anl.gov> Message-ID: Ok, I really apreciate your help. Thanks Jed and Barry. Regards Pedro 2010/2/25 Barry Smith > > On Feb 25, 2010, at 7:50 PM, Pedro Torres wrote: > > >> >> 2010/2/25 Jed Brown >> On Thu, 25 Feb 2010 13:37:21 -0300, Pedro Torres < >> torres.pedrozpk at gmail.com> wrote: >> > Well, in my case I have a sequential vector and I'm trying to append one >> > element at the end of the array, without the need of destroy this. >> >> PETSc Vec doesn't work this way. Use whatever data structure you like >> to put this thing together, then give it to PETSc once you know what you >> have. >> >> > - Create a new vector with size+1 >> > - copy old array in the new array and append the element, >> >> This is what dynamically sized array containers (e.g. std::vector) do >> internally, but they guess at how much extra will be needed (usually >> increasing the allocated size by a geometric factor). >> >> (When I asked what you are trying to do, I was looking for a higher >> level description of what you wanted to achieve, and why you thought >> appending to a Vec was a desirable thing.) >> >> The things is that I don't have the final dimension of the vector, because >> it depends of mesh size, boundary conditions,etc. But I think that I can do >> the following, >> >> - use std::vector >> - when I get final size, I create a Vec with VecCreateSeqWithArray and >> Petsc will use the array in std::vector. >> > > You could do this. In general what we do is to "process" the mesh, > boundary conditions etc to determine the needed size, set the vector size, > then go back and compute the vector/matrix entries. > > Barry > > > >> Is that right? >> >> Thanks a lot! >> >> Pedro >> >> >> Jed >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jed at 59a2.org Fri Feb 26 03:10:08 2010 From: jed at 59a2.org (Jed Brown) Date: Fri, 26 Feb 2010 10:10:08 +0100 Subject: [petsc-users] Could you add MatRealPart() and MatImaginaryPart( ) with SEQ- and MPI-Dense for me? In-Reply-To: <7ff0ee011002251206g72677709n1c2f1c73de6b0cdf@mail.gmail.com> References: <7ff0ee011002250907k6cf2c0f2u8742d4a500eaf3ff@mail.gmail.com> <215BAA1D-4102-4D55-A89B-D0874884E92B@mcs.anl.gov> <7ff0ee011002250953v77b270efm7d149851b524dc9f@mail.gmail.com> <87zl2xry99.fsf@59A2.org> <7ff0ee011002251002q44693085qceb68bd669108913@mail.gmail.com> <87y6ihrx42.fsf@59A2.org> <7ff0ee011002251206g72677709n1c2f1c73de6b0cdf@mail.gmail.com> Message-ID: <87vddks6q7.fsf@59A2.org> Some slots changed from 3.0.0 to petsc-dev, that patch was only meant to apply to petsc-dev. You're welcome to port it back to 3.0.0. Note that the 3.0.1 release will be soon. Jed From jed at 59A2.org Fri Feb 26 03:48:12 2010 From: jed at 59A2.org (Jed Brown) Date: Fri, 26 Feb 2010 10:48:12 +0100 Subject: [petsc-users] How to zeros all entries of a set of columns of a matrix In-Reply-To: <6374BBC9-1FF0-45EC-B4FE-1121D8200D75@mcs.anl.gov> References: <6374BBC9-1FF0-45EC-B4FE-1121D8200D75@mcs.anl.gov> Message-ID: <87tyt4s4yr.fsf@59A2.org> On Thu, 25 Feb 2010 12:54:13 -0600, Barry Smith wrote: > One can solve Dirichilet boundary condition problems > using symmetric methods two ways. (1) Manually call MatGetSubMatrix() > to extract your symmetric subproblem or (2) call MatZeroRows() then > use the PCREDISTRIBUTE preconditioner to solve the reduced system using > symmetric methods. Both of these use extra memory and make it more difficult to reuse data structures if boundary conditions change to or from Dirichlet as the simulation proceeds. It's quite easy during assembly to just not put values into columns that you don't want values in. This is done by applying the same selection process to the column indices as the row indices. I usually do something like (using Matlab-ish notation for subvectors) in F(X): Xd = X; Xd(Dirichlet) = known # put the known values in the Dirichlet slots F = Physics(Xd) # evaluate physics with the correct Dirichlet values F(Dirichlet) = scale*(X(Dirichlet) - known) # residual in Dirichlet slots which implies a symmetric Jacobian (since F(All-Dirichlet) is independent of X(Dirichlet)), so in J(X) we have: Xd = X; Xd(Dirichlet) = known; J(All-Dirichlet,All-Dirichlet) = Physics'(Xd) # don't assemble into Dirichlet rows or columns J(Dirichlet,Dirichlet) = scale # put this on the diagonal You can choose scale=1, but it is usually better (mostly with geometric multigrid) to scale by local viscosity or whatever your analogue is. Jed