Re: [petsc-users] Petsc Draw to pixmap

2015-12-03 Thread Matthew Knepley
On Thu, Dec 3, 2015 at 2:06 AM, Sean Dettrick 
wrote:

>
> No, it is my fault, when I was unable to download from afterstep.org
> earlier I didn’t realize that it was probably my work firewall blocking
> me.  Thus sending me on a wild goose chase with macports and home-brew and
> github version, which didn’t compile.
>
> But now I’ve tried to follow your advice, and have a new problem.
>
> I installed Afterimage from your suggested site, with suggested X lib
> flags:
>
>./configure --x-includes=/opt/X11/include -x-libraries=/opt/X11/lib
>

Did you check that it worked? Configure can (semi-)silently turn things off.

  Thanks,

Matt


>make
>make install
>
> No errors.  Then re-configured and built petsc:
>
>export PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1
>export PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage
>   ./configure --with-afterimage --download-hdf5 --download-mpich
> --PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage
> --PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1
>make PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1
> PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage all
>
> No errors.  Then try to run an example with image output:
>
>cd src/dm/examples/tutorials/
>make ex5
>./ex5
>./ex5 -draw_save test.png
>
> The example generates the error you mentioned, which it didn’t before
> installing afterimage:
>
> X Error of failed request:  BadValue (integer parameter out of range for
> operation)
>   Major opcode of failed request:  1 (X_CreateWindow)
>   Value in failed request:  0x40
>   Serial number of failed request:  7
>   Current serial number in output stream:  14
>
> Browsing through configure.log, it seems that petsc is using the same X11
> library.
>
> Did I miss something?
>
> Thanks!
> Sean
>
>
> On Dec 2, 2015, at 11:10 PM, Barry Smith  wrote:
>
>
>  I am such an idiot. No I did build it from source I forgot the comment in
> afterimage.py
>
>  After image is available from
> http://www.afterstep.org/afterimage/getcode.php
> #
> #  It is used by the PetscDrawSetSave() routine to save X windows graphics
> to files
> #
> #  If installing on an Apple make sure to read the details on
> PetscDrawSetSave manual
> #  page before installing
> #
>
> from that page I found
>
> If X windows generates an error message about X_CreateWindow() failing
> then Afterimage was installed without X windows. Reinstall Afterimage using
> the
>   ./configure flags --x-includes=/pathtoXincludes
> --x-libraries=/pathtoXlibraries   For example under Mac OS X Mountain Lion
> --x-includes=/opt/X11/include -x-libraries=/opt/X11/lib
>
> Did you try all this stuff?
>
>  Barry
>
>
> On Dec 3, 2015, at 1:00 AM, Sean Dettrick 
> wrote:
>
> Hi Barry,
>
> Thanks for the amazingly fast reply.  I installed home-brew but then was
> unable to find afterstep available as a package.  The closest thing I could
> find was asterm (after step terminal emulator.  Do you remember if you
> installed it from a canonical repo?
>
> I did find afterstep on github, but had trouble installing it on the mac.
>
> Meanwhile, a colleague has given me a python script, so I’ll probably use
> that instead for now.
>
> Thanks again,
> Sean
>
> On Dec 2, 2015, at 1:45 PM, Barry Smith  wrote:
>
>
> Sean,
>
> I have never been able to build from that source either.
>
> I used homebrew to install it and its worked for several years.
>
> I also tried to see if one could pull the image from the X pixel map and
> it looked like a huge project (the pixmap stuff is not as trivial as one
> would think it would be) so I gave up on that and started using afterimage
> (which essentially does all the for you).
>
> Barry
>
> On Dec 2, 2015, at 3:39 PM, Sean Dettrick 
> wrote:
>
> Hi,
>
> I’d like to have petsc draw output to a pixmap, but have been unable to
> install afterstep on my Mac.  Direct download of the tar files from
> http://www.afterstep.org/afterimage/getcode.php failed, as did cvs
> checkout.  It seems the target sites may not exist at present.
>
> Is there another way to install afterstep?
>
> Alternatively, is there a way to manually redirect the X11 output using
> something like XCreatePixmap?
>
> Thanks!
> Sean Dettrick
>
>
>
>
>
>


-- 
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


Re: [petsc-users] Petsc Draw to pixmap

2015-12-03 Thread Sean Dettrick

No, it is my fault, when I was unable to download from 
afterstep.org earlier I didn’t realize that it was 
probably my work firewall blocking me.  Thus sending me on a wild goose chase 
with macports and home-brew and github version, which didn’t compile.

But now I’ve tried to follow your advice, and have a new problem.

I installed Afterimage from your suggested site, with suggested X lib flags:

   ./configure --x-includes=/opt/X11/include -x-libraries=/opt/X11/lib
   make
   make install

No errors.  Then re-configured and built petsc:

   export PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1
   export PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage
  ./configure --with-afterimage --download-hdf5 --download-mpich 
--PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage 
--PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1
   make PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1 
PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage all

No errors.  Then try to run an example with image output:

   cd src/dm/examples/tutorials/
   make ex5
   ./ex5
   ./ex5 -draw_save test.png

The example generates the error you mentioned, which it didn’t before 
installing afterimage:

X Error of failed request:  BadValue (integer parameter out of range for 
operation)
  Major opcode of failed request:  1 (X_CreateWindow)
  Value in failed request:  0x40
  Serial number of failed request:  7
  Current serial number in output stream:  14

Browsing through configure.log, it seems that petsc is using the same X11 
library.

Did I miss something?

Thanks!
Sean


On Dec 2, 2015, at 11:10 PM, Barry Smith 
> wrote:


 I am such an idiot. No I did build it from source I forgot the comment in 
afterimage.py

 After image is available from http://www.afterstep.org/afterimage/getcode.php
#
#  It is used by the PetscDrawSetSave() routine to save X windows graphics to 
files
#
#  If installing on an Apple make sure to read the details on PetscDrawSetSave 
manual
#  page before installing
#

from that page I found

If X windows generates an error message about X_CreateWindow() failing then 
Afterimage was installed without X windows. Reinstall Afterimage using the
  ./configure flags --x-includes=/pathtoXincludes 
--x-libraries=/pathtoXlibraries   For example under Mac OS X Mountain Lion 
--x-includes=/opt/X11/include -x-libraries=/opt/X11/lib

Did you try all this stuff?

 Barry


On Dec 3, 2015, at 1:00 AM, Sean Dettrick 
> wrote:

Hi Barry,

Thanks for the amazingly fast reply.  I installed home-brew but then was unable 
to find afterstep available as a package.  The closest thing I could find was 
asterm (after step terminal emulator.  Do you remember if you installed it from 
a canonical repo?

I did find afterstep on github, but had trouble installing it on the mac.

Meanwhile, a colleague has given me a python script, so I’ll probably use that 
instead for now.

Thanks again,
Sean

On Dec 2, 2015, at 1:45 PM, Barry Smith 
> wrote:


Sean,

I have never been able to build from that source either.

I used homebrew to install it and its worked for several years.

I also tried to see if one could pull the image from the X pixel map and it 
looked like a huge project (the pixmap stuff is not as trivial as one would 
think it would be) so I gave up on that and started using afterimage (which 
essentially does all the for you).

Barry

On Dec 2, 2015, at 3:39 PM, Sean Dettrick 
> wrote:

Hi,

I’d like to have petsc draw output to a pixmap, but have been unable to install 
afterstep on my Mac.  Direct download of the tar files from 
http://www.afterstep.org/afterimage/getcode.php failed, as did cvs checkout.  
It seems the target sites may not exist at present.

Is there another way to install afterstep?

Alternatively, is there a way to manually redirect the X11 output using 
something like XCreatePixmap?

Thanks!
Sean Dettrick






Re: [petsc-users] Petsc Draw to pixmap

2015-12-03 Thread Barry Smith

> On Dec 3, 2015, at 5:54 AM, Matthew Knepley  wrote:
> 
> On Thu, Dec 3, 2015 at 2:06 AM, Sean Dettrick  
> wrote:
> 
> No, it is my fault, when I was unable to download from afterstep.org earlier 
> I didn’t realize that it was probably my work firewall blocking me.  Thus 
> sending me on a wild goose chase with macports and home-brew and github 
> version, which didn’t compile.
> 
> But now I’ve tried to follow your advice, and have a new problem.
> 
> I installed Afterimage from your suggested site, with suggested X lib flags:
> 
>./configure --x-includes=/opt/X11/include -x-libraries=/opt/X11/lib
> 
> Did you check that it worked? Configure can (semi-)silently turn things off.

   Yes, I think Matt is right. This is the error message you get if afterimage 
was installed without X. Check through all the logs and build stuff of 
afterimage. 

  Barry

> 
>   Thanks,
> 
> Matt
>  
>make
>make install
> 
> No errors.  Then re-configured and built petsc:
> 
>export PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1
>export PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage
>   ./configure --with-afterimage --download-hdf5 --download-mpich 
> --PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage 
> --PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1 
>make PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1 
> PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage all
> 
> No errors.  Then try to run an example with image output:
> 
>cd src/dm/examples/tutorials/
>make ex5
>./ex5
>./ex5 -draw_save test.png
> 
> The example generates the error you mentioned, which it didn’t before 
> installing afterimage:
> 
> X Error of failed request:  BadValue (integer parameter out of range for 
> operation)
>   Major opcode of failed request:  1 (X_CreateWindow)
>   Value in failed request:  0x40
>   Serial number of failed request:  7
>   Current serial number in output stream:  14
> 
> Browsing through configure.log, it seems that petsc is using the same X11 
> library.
> 
> Did I miss something?
> 
> Thanks!
> Sean
> 
> 
>> On Dec 2, 2015, at 11:10 PM, Barry Smith  wrote:
>> 
>> 
>>  I am such an idiot. No I did build it from source I forgot the comment in 
>> afterimage.py 
>> 
>>  After image is available from 
>> http://www.afterstep.org/afterimage/getcode.php
>> #
>> #  It is used by the PetscDrawSetSave() routine to save X windows graphics 
>> to files
>> #
>> #  If installing on an Apple make sure to read the details on 
>> PetscDrawSetSave manual
>> #  page before installing
>> #
>> 
>> from that page I found
>> 
>> If X windows generates an error message about X_CreateWindow() failing then 
>> Afterimage was installed without X windows. Reinstall Afterimage using the
>>   ./configure flags --x-includes=/pathtoXincludes 
>> --x-libraries=/pathtoXlibraries   For example under Mac OS X Mountain Lion 
>> --x-includes=/opt/X11/include -x-libraries=/opt/X11/lib
>> 
>> Did you try all this stuff?
>> 
>>  Barry
>> 
>> 
>>> On Dec 3, 2015, at 1:00 AM, Sean Dettrick  
>>> wrote:
>>> 
>>> Hi Barry,
>>> 
>>> Thanks for the amazingly fast reply.  I installed home-brew but then was 
>>> unable to find afterstep available as a package.  The closest thing I could 
>>> find was asterm (after step terminal emulator.  Do you remember if you 
>>> installed it from a canonical repo? 
>>> 
>>> I did find afterstep on github, but had trouble installing it on the mac.
>>> 
>>> Meanwhile, a colleague has given me a python script, so I’ll probably use 
>>> that instead for now. 
>>> 
>>> Thanks again,
>>> Sean
>>> 
 On Dec 2, 2015, at 1:45 PM, Barry Smith  wrote:
 
 
 Sean,
 
 I have never been able to build from that source either. 
 
 I used homebrew to install it and its worked for several years.
 
 I also tried to see if one could pull the image from the X pixel map and 
 it looked like a huge project (the pixmap stuff is not as trivial as one 
 would think it would be) so I gave up on that and started using afterimage 
 (which essentially does all the for you).
 
 Barry
 
> On Dec 2, 2015, at 3:39 PM, Sean Dettrick  
> wrote:
> 
> Hi,
> 
> I’d like to have petsc draw output to a pixmap, but have been unable to 
> install afterstep on my Mac.  Direct download of the tar files from 
> http://www.afterstep.org/afterimage/getcode.php failed, as did cvs 
> checkout.  It seems the target sites may not exist at present.
> 
> Is there another way to install afterstep?
> 
> Alternatively, is there a way to manually redirect the X11 output using 
> something like XCreatePixmap?
> 
> Thanks!
> Sean Dettrick
 
>>> 
>> 
> 
> 
> 
> 
> -- 
> What most experimenters take for granted before they begin their experiments 
> is infinitely more interesting than any results to 

[petsc-users] Fwd: Issues with the Variational Inequality solver

2015-12-03 Thread Justin Chang
Sorry forgot to hit reply all

-- Forwarded message --
From: Justin Chang 
Date: Thu, Dec 3, 2015 at 2:40 PM
Subject: Re: [petsc-users] Issues with the Variational Inequality solver
To: Matthew Knepley 


Matt, for these problems I set an upper bound of 10, so I am not sure
that's related to the problem at hand. However, that is the *next* issue I
will bring up if this current one is resolved ;)

Another thing I found out...

The five case studies I listed used no preconditioner. When I use the
jacobi preconditioner, the Newton and VI solutions are identical.

Whereas these problems now fail:

with Newton:

Case 0:

psiA: 6.297272e-01

psiC: 1.705043e-08

k: 2.00

cA: 6.297272e-01

cB: 4.616557e-16

cC: 1.705043e-08

Case 1:

psiA: 7.570078e-01

psiC: 1.754758e-08

k: 2.00

cA: 7.570078e-01

cB: 4.067561e-16

cC: 1.754758e-08

with VI:

Case 0:

psiA: 6.297272e-01

psiC: 1.705043e-08

k: 2.00

cA: -7.684746e-17

cB: 5.362599e-09

cC: 4.616557e-16

Case 1:

psiA: 7.570078e-01

psiC: 1.754758e-08

k: 2.00

cA: 3.781787e-16

cB: 1.152521e-08

cC: 4.067561e-16

For the first set of problems, Jacobi works but no preconditioner fails.
For the second set of problems, Jacobi fails but no preconditioner works.

??

Justin

On Thu, Dec 3, 2015 at 2:26 PM, Matthew Knepley  wrote:

> On Thu, Dec 3, 2015 at 3:00 PM, Justin Chang  wrote:
>
>> Thanks Barry,
>>
>> Next issue:
>>
>
> Barry, when Justin described this problem to me, it sounded like there
> might be a bug in the active set method which
> put in the lower value when it was supposed to be the upper value.
>
>Matt
>
>
>> Consider the following problem:
>>
>> psiA = cA - 2*cB (1a)
>> psiC = cC + 2*cB(1b)
>> cC^2 = k*cA^2*cB  (1c)
>>
>> where psiA, psiC, and k are given. If I solve these five problems using
>> the standard Newton method:
>>
>> Case 0:
>>
>> psiA: 9.400282e-01
>>
>> psiC: 6.045961e-09
>>
>> k: 2.00
>>
>> cA: 9.400282e-01
>>
>> cB: 1.555428e-16
>>
>> cC: 6.045961e-09
>>
>> Case 1:
>>
>> psiA: 8.472901e-01
>>
>> psiC: 7.425271e-09
>>
>> k: 2.00
>>
>> cA: 8.472901e-01
>>
>> cB: 2.602870e-16
>>
>> cC: 7.425270e-09
>>
>> Case 2:
>>
>> psiA: 8.337199e-01
>>
>> psiC: 7.831614e-09
>>
>> k: 2.00
>>
>> cA: 8.337199e-01
>>
>> cB: 2.942675e-16
>>
>> cC: 7.831613e-09
>>
>> Case 3:
>>
>> psiA: 8.268140e-01
>>
>> psiC: 7.912911e-09
>>
>> k: 2.00
>>
>> cA: 8.268140e-01
>>
>> cB: 3.029178e-16
>>
>> cC: 7.912910e-09
>>
>> Case 4:
>>
>> psiA: 9.852477e-01
>>
>> psiC: 7.992223e-09
>>
>> k: 2.00
>>
>> cA: 9.852477e-01
>>
>> cB: 2.593282e-16
>>
>> cC: 7.99e-09
>>
>> These solutions are "correct", that is if I plug the c's back into
>> equations (1a)-(1b), i get the original psi's.
>>
>> Now suppose I use the Variational Inequality such that cA/B/C >= 0, I
>> would expect to get the exact same solution (since the c's would be
>> non-negative regardless). But instead I get these solutions:
>>
>> Case 0:
>>
>> psiA: 9.400282e-01
>>
>> psiC: 6.045961e-09
>>
>> k: 2.00
>>
>> cA: 1.318866e-16
>>
>> cB: 3.097570e-08
>>
>> cC: 6.045961e-09
>>
>> Case 1:
>>
>> psiA: 8.472901e-01
>>
>> psiC: 7.425271e-09
>>
>> k: 2.00
>>
>> cA: 4.624944e-17
>>
>> cB: 3.015792e-08
>>
>> cC: 7.425271e-09
>>
>> Case 2:
>>
>> psiA: 8.337199e-01
>>
>> psiC: 7.831614e-09
>>
>> k: 2.00
>>
>> cA: 1.733276e-16
>>
>> cB: 3.079856e-08
>>
>> cC: 7.831614e-09
>>
>> Case 3:
>>
>> psiA: 8.268140e-01
>>
>> psiC: 7.912911e-09
>>
>> k: 2.00
>>
>> cA: 1.721078e-16
>>
>> cB: 3.061785e-08
>>
>> cC: 7.912911e-09
>>
>> Case 4:
>>
>> psiA: 9.852477e-01
>>
>> psiC: 7.992223e-09
>>
>> k: 2.00
>>
>> cA: 2.666770e-16
>>
>> cB: 4.610822e-08
>>
>> cC: 7.992223e-09
>>
>> Basically, the cA's shoot down to zero and the cB's are slightly greater
>> than zero. When I plug the c's into equations (1a) - (1b), I do not get the
>> correct solution at all. I would expect discrepancies if my c's were
>> originally negative, but for these five problems, shouldn't VI give the
>> same answer as the Newton's method?
>>
>> Attached is the petsc4py code, the two input files containing psiA and
>> psiC, and the outputs from '-snes_monitor -snes_view
>> -ksp_monitor_true_residual'. Run as:
>>
>> python testVI.py testA testC 2 <0/1>
>>
>> where 0 is Newton, 1 is VI.
>>
>> Know what's going on here?
>>
>> Thanks,
>> Justin
>>
>> On Wed, Dec 2, 2015 at 1:36 PM, Barry Smith  wrote:
>>
>>>
>>> > On Dec 2, 2015, at 1:56 PM, Justin Chang  wrote:
>>> >
>>> > Barry,
>>> >
>>> > So I do not believe there is any problem with the ISEqual() per se,
>>> because what I am doing is I am solving 5151 different VI problem using the
>>> same SNES/KSP/PC/Mat. That is, I am not "resetting" these data structures
>>> once I am done with one problem and move on to the next. If I ran each case
>>> individually, I get no error; the error comes when I run these 

Re: [petsc-users] Issues with the Variational Inequality solver

2015-12-03 Thread Barry Smith

> On Dec 3, 2015, at 3:59 PM, Justin Chang  wrote:
> 
> Sorry forgot to hit reply all 
> 
> -- Forwarded message --
> From: Justin Chang 
> Date: Thu, Dec 3, 2015 at 2:40 PM
> Subject: Re: [petsc-users] Issues with the Variational Inequality solver
> To: Matthew Knepley 
> 
> 
> Matt, for these problems I set an upper bound of 10, so I am not sure that's 
> related to the problem at hand. However, that is the *next* issue I will 
> bring up if this current one is resolved ;)
> 
> Another thing I found out...
> 
> The five case studies I listed used no preconditioner. When I use the jacobi 
> preconditioner, the Newton and VI solutions are identical.
> 
> Whereas these problems now fail:
> 
> with Newton:
> Case 0:
>   psiA: 6.297272e-01
>   psiC: 1.705043e-08
>   k: 2.00
>   cA: 6.297272e-01
>   cB: 4.616557e-16
>   cC: 1.705043e-08
> Case 1:
>   psiA: 7.570078e-01
>   psiC: 1.754758e-08
>   k: 2.00
>   cA: 7.570078e-01
>   cB: 4.067561e-16
>   cC: 1.754758e-08
> 
> with VI:
> 
> Case 0:
>   psiA: 6.297272e-01
>   psiC: 1.705043e-08
>   k: 2.00
>   cA: -7.684746e-17
>   cB: 5.362599e-09
>   cC: 4.616557e-16
> Case 1:
>   psiA: 7.570078e-01
>   psiC: 1.754758e-08
>   k: 2.00
>   cA: 3.781787e-16
>   cB: 1.152521e-08
>   cC: 4.067561e-16
> 
> For the first set of problems, Jacobi works but no preconditioner fails.
> For the second set of problems, Jacobi fails but no preconditioner works.

   "Fails" is not very informative. What happens if you use LU? When debugging 
a nonlinear solver always use a direct solver for the linear solver (and make 
sure the direct solver actually worked).


> 
> ??
> 
> Justin
> 
> On Thu, Dec 3, 2015 at 2:26 PM, Matthew Knepley  wrote:
> On Thu, Dec 3, 2015 at 3:00 PM, Justin Chang  wrote:
> Thanks Barry,
> 
> Next issue:
> 
> Barry, when Justin described this problem to me, it sounded like there might 
> be a bug in the active set method which
> put in the lower value when it was supposed to be the upper value.
> 
>Matt
>  
> Consider the following problem:
> 
> psiA = cA - 2*cB (1a)
> psiC = cC + 2*cB(1b)
> cC^2 = k*cA^2*cB  (1c)
> 
> where psiA, psiC, and k are given. If I solve these five problems using the 
> standard Newton method:
> 
> Case 0:
>   psiA: 9.400282e-01
>   psiC: 6.045961e-09
>   k: 2.00
>   cA: 9.400282e-01
>   cB: 1.555428e-16
>   cC: 6.045961e-09
> Case 1:
>   psiA: 8.472901e-01
>   psiC: 7.425271e-09
>   k: 2.00
>   cA: 8.472901e-01
>   cB: 2.602870e-16
>   cC: 7.425270e-09
> Case 2:
>   psiA: 8.337199e-01
>   psiC: 7.831614e-09
>   k: 2.00
>   cA: 8.337199e-01
>   cB: 2.942675e-16
>   cC: 7.831613e-09
> Case 3:
>   psiA: 8.268140e-01
>   psiC: 7.912911e-09
>   k: 2.00
>   cA: 8.268140e-01
>   cB: 3.029178e-16
>   cC: 7.912910e-09
> Case 4:
>   psiA: 9.852477e-01
>   psiC: 7.992223e-09
>   k: 2.00
>   cA: 9.852477e-01
>   cB: 2.593282e-16
>   cC: 7.99e-09
> 
> These solutions are "correct", that is if I plug the c's back into equations 
> (1a)-(1b), i get the original psi's. 
> 
> Now suppose I use the Variational Inequality such that cA/B/C >= 0, I would 
> expect to get the exact same solution (since the c's would be non-negative 
> regardless). But instead I get these solutions:
> 
> Case 0:
>   psiA: 9.400282e-01
>   psiC: 6.045961e-09
>   k: 2.00
>   cA: 1.318866e-16
>   cB: 3.097570e-08
>   cC: 6.045961e-09
> Case 1:
>   psiA: 8.472901e-01
>   psiC: 7.425271e-09
>   k: 2.00
>   cA: 4.624944e-17
>   cB: 3.015792e-08
>   cC: 7.425271e-09
> Case 2:
>   psiA: 8.337199e-01
>   psiC: 7.831614e-09
>   k: 2.00
>   cA: 1.733276e-16
>   cB: 3.079856e-08
>   cC: 7.831614e-09
> Case 3:
>   psiA: 8.268140e-01
>   psiC: 7.912911e-09
>   k: 2.00
>   cA: 1.721078e-16
>   cB: 3.061785e-08
>   cC: 7.912911e-09
> Case 4:
>   psiA: 9.852477e-01
>   psiC: 7.992223e-09
>   k: 2.00
>   cA: 2.666770e-16
>   cB: 4.610822e-08
>   cC: 7.992223e-09
> 
> Basically, the cA's shoot down to zero and the cB's are slightly greater than 
> zero. When I plug the c's into equations (1a) - (1b), I do not get the 
> correct solution at all. I would expect discrepancies if my c's were 
> originally negative, but for these five problems, shouldn't VI give the same 
> answer as the Newton's method?
> 
> Attached is the petsc4py code, the two input files containing psiA and psiC, 
> and the outputs from '-snes_monitor -snes_view -ksp_monitor_true_residual'. 
> Run as:
> 
> python testVI.py testA testC 2 <0/1>
> 
> where 0 is Newton, 1 is VI.
> 
> Know what's going on here? 

Re: [petsc-users] SuperLU convergence problem

2015-12-03 Thread Danyang Su

Hi Hong,

I just checked using ex10 for these matrices and rhs, they all work 
fine. I found something is wrong in my code when using direct solver.  
The second parameter mat in PCFactorGetMatrix(PC pc,Mat *mat) is not 
initialized in my code for SUPERLU or MUMPS.


I will fix this bug, rerun the tests and get back to you later.

Thanks very much,

Danyang

On 15-12-03 01:59 PM, Hong wrote:

Danyang :
Further testing a_flow_check_168.bin,
./ex10 -f0 
/Users/Hong/Downloads/matrix_and_rhs_bin/a_flow_check_168.bin -rhs 
/Users/Hong/Downloads/matrix_and_rhs_bin/x_flow_check_168.bin -pc_type 
lu -pc_factor_mat_solver_package superlu -ksp_monitor_true_residual 
-mat_superlu_conditionnumber

  Recip. condition number = 1.610480e-12
  0 KSP preconditioned resid norm 6.873340313547e+09 true resid norm 
7.295020990196e+03 ||r(i)||/||b|| 1.e+00
  1 KSP preconditioned resid norm 2.051833296449e-02 true resid norm 
2.976859070118e-02 ||r(i)||/||b|| 4.080672384793e-06

Number of iterations =   1
Residual norm 0.0297686

condition number of this matrix = 1/1.610480e-12 = 1.e+12,
i.e., this matrix is ill-conditioned.

Hong


Hi Hong,

The binary format of matrix, rhs and solution can be downloaded
via the link below.

https://www.dropbox.com/s/cl3gfi0s0kjlktf/matrix_and_rhs_bin.tar.gz?dl=0

Thanks,

Danyang


On 15-12-03 10:50 AM, Hong wrote:

Danyang:



To my surprising, solutions from SuperLU at timestep 29 seems
not correct for the first 4 Newton iterations, but the
solutions from iteration solver and MUMPS are correct.

Please find all the matrices, rhs and solutions at timestep
29 via the link below. The data is a bit large so that I just
share it through Dropbox. A piece of matlab code to read
these data and then computer the norm has also been attached.
_https://www.dropbox.com/s/rr8ueysgflmxs7h/results-check.tar.gz?dl=0_


Can you send us matrix in petsc binary format?

e.g., call MatView(M, PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD))
or '-ksp_view_mat binary'

Hong



Below is a summary of the norm from the three solvers at
timestep 29, newton iteration 1 to 5.

Timestep 29
Norm of residual seq 1.661321e-09, superlu 1.657103e+04,
mumps 3.731225e-11
Norm of residual seq 1.753079e-09, superlu 6.675467e+02,
mumps 1.509919e-13
Norm of residual seq 4.914971e-10, superlu 1.236362e-01,
mumps 2.139303e-17
Norm of residual seq 3.532769e-10, superlu 1.304670e-04,
mumps 5.387000e-20
Norm of residual seq 3.885629e-10, superlu 2.754876e-07,
mumps 4.108675e-21

Would anybody please check if SuperLU can solve these
matrices? Another possibility is that something is wrong in
my own code. But so far, I cannot find any problem in my code
since the same code works fine if I using iterative solver or
direct solver MUMPS. But for other cases I have tested,  all
these solvers work fine.

Please let me know if I did not write down the problem clearly.

Thanks,

Danyang











Re: [petsc-users] Petsc Draw to pixmap

2015-12-03 Thread Sean Dettrick

On Dec 3, 2015, at 5:01 AM, Barry Smith 
> wrote:


On Dec 3, 2015, at 5:54 AM, Matthew Knepley 
> wrote:

On Thu, Dec 3, 2015 at 2:06 AM, Sean Dettrick 
> wrote:

No, it is my fault, when I was unable to download from 
afterstep.org earlier I didn’t realize that it was 
probably my work firewall blocking me.  Thus sending me on a wild goose chase 
with macports and home-brew and github version, which didn’t compile.

But now I’ve tried to follow your advice, and have a new problem.

I installed Afterimage from your suggested site, with suggested X lib flags:

  ./configure --x-includes=/opt/X11/include -x-libraries=/opt/X11/lib

Did you check that it worked? Configure can (semi-)silently turn things off.

  Yes, I think Matt is right. This is the error message you get if afterimage 
was installed without X. Check through all the logs and build stuff of 
afterimage.


Thanks!  The thing finally works.  I had to clean everything and do fresh 
installs, but now it is fine.

Summarizing my experience of afterimage on a mac in case anybody else wants to 
do it:

Afterimage on the mac is in theory available via macports as part of the 
afterstep package, but it failed to build on my Mac (Yosemite).  It is not 
available in home-brew.  The current github version of afterimage failed to 
build on my mac.  The version from 
http://www.afterstep.org/afterimage/getcode.php DOES work, configured as:


./configure --x-includes=/opt/X11/include --x-libraries=/opt/X11/lib --with-x
make
make install

Then petsc is configured as:
./configure --with-afterimage --download-hdf5 --download-mpich

The example src/dm/examples/tutorials/ex5.c then works:
./ex5 -draw_save


Cheers,
Sean



 Barry


 Thanks,

   Matt

  make
  make install

No errors.  Then re-configured and built petsc:

  export PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1
  export PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage
 ./configure --with-afterimage --download-hdf5 --download-mpich 
--PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage 
--PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1
  make PETSC_DIR=/Users/sdettrick/libs/petsc-3.6.1 
PETSC_ARCH=mac-gcc-hdf5-mpich-afterimage all

No errors.  Then try to run an example with image output:

  cd src/dm/examples/tutorials/
  make ex5
  ./ex5
  ./ex5 -draw_save test.png

The example generates the error you mentioned, which it didn’t before 
installing afterimage:

X Error of failed request:  BadValue (integer parameter out of range for 
operation)
 Major opcode of failed request:  1 (X_CreateWindow)
 Value in failed request:  0x40
 Serial number of failed request:  7
 Current serial number in output stream:  14

Browsing through configure.log, it seems that petsc is using the same X11 
library.

Did I miss something?

Thanks!
Sean


On Dec 2, 2015, at 11:10 PM, Barry Smith 
> wrote:


I am such an idiot. No I did build it from source I forgot the comment in 
afterimage.py

After image is available from http://www.afterstep.org/afterimage/getcode.php
#
#  It is used by the PetscDrawSetSave() routine to save X windows graphics to 
files
#
#  If installing on an Apple make sure to read the details on PetscDrawSetSave 
manual
#  page before installing
#

from that page I found

If X windows generates an error message about X_CreateWindow() failing then 
Afterimage was installed without X windows. Reinstall Afterimage using the
 ./configure flags --x-includes=/pathtoXincludes 
--x-libraries=/pathtoXlibraries   For example under Mac OS X Mountain Lion 
--x-includes=/opt/X11/include -x-libraries=/opt/X11/lib

Did you try all this stuff?

Barry


On Dec 3, 2015, at 1:00 AM, Sean Dettrick 
> wrote:

Hi Barry,

Thanks for the amazingly fast reply.  I installed home-brew but then was unable 
to find afterstep available as a package.  The closest thing I could find was 
asterm (after step terminal emulator.  Do you remember if you installed it from 
a canonical repo?

I did find afterstep on github, but had trouble installing it on the mac.

Meanwhile, a colleague has given me a python script, so I’ll probably use that 
instead for now.

Thanks again,
Sean

On Dec 2, 2015, at 1:45 PM, Barry Smith 
> wrote:


Sean,

I have never been able to build from that source either.

I used homebrew to install it and its worked for several years.

I also tried to see if one could pull the image from the X pixel map and it 
looked like a huge project (the pixmap stuff is not as trivial as one would 
think it would be) so I gave up on that and started using afterimage (which 
essentially does all the for you).

Barry

On Dec 2, 2015, at 3:39 PM, Sean Dettrick 

Re: [petsc-users] SuperLU convergence problem

2015-12-03 Thread Hong
Danyang :
Further testing a_flow_check_168.bin,
./ex10 -f0 /Users/Hong/Downloads/matrix_and_rhs_bin/a_flow_check_168.bin
-rhs /Users/Hong/Downloads/matrix_and_rhs_bin/x_flow_check_168.bin -pc_type
lu -pc_factor_mat_solver_package superlu -ksp_monitor_true_residual
-mat_superlu_conditionnumber
  Recip. condition number = 1.610480e-12
  0 KSP preconditioned resid norm 6.873340313547e+09 true resid norm
7.295020990196e+03 ||r(i)||/||b|| 1.e+00
  1 KSP preconditioned resid norm 2.051833296449e-02 true resid norm
2.976859070118e-02 ||r(i)||/||b|| 4.080672384793e-06
Number of iterations =   1
Residual norm 0.0297686

condition number of this matrix = 1/1.610480e-12 = 1.e+12,
i.e., this matrix is ill-conditioned.

Hong


Hi Hong,
>
> The binary format of matrix, rhs and solution can be downloaded via the
> link below.
>
> https://www.dropbox.com/s/cl3gfi0s0kjlktf/matrix_and_rhs_bin.tar.gz?dl=0
>
> Thanks,
>
> Danyang
>
>
> On 15-12-03 10:50 AM, Hong wrote:
>
> Danyang:
>
>>
>>
>> To my surprising, solutions from SuperLU at timestep 29 seems not correct
>> for the first 4 Newton iterations, but the solutions from iteration solver
>> and MUMPS are correct.
>>
>> Please find all the matrices, rhs and solutions at timestep 29 via the
>> link below. The data is a bit large so that I just share it through
>> Dropbox. A piece of matlab code to read these data and then computer the
>> norm has also been attached.
>> *https://www.dropbox.com/s/rr8ueysgflmxs7h/results-check.tar.gz?dl=0
>> *
>>
>
> Can you send us matrix in petsc binary format?
>
> e.g., call MatView(M, PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD))
> or '-ksp_view_mat binary'
>
> Hong
>
>>
>>
>> Below is a summary of the norm from the three solvers at timestep 29,
>> newton iteration 1 to 5.
>>
>> Timestep 29
>> Norm of residual seq 1.661321e-09, superlu 1.657103e+04, mumps
>> 3.731225e-11
>> Norm of residual seq 1.753079e-09, superlu 6.675467e+02, mumps
>> 1.509919e-13
>> Norm of residual seq 4.914971e-10, superlu 1.236362e-01, mumps
>> 2.139303e-17
>> Norm of residual seq 3.532769e-10, superlu 1.304670e-04, mumps
>> 5.387000e-20
>> Norm of residual seq 3.885629e-10, superlu 2.754876e-07, mumps
>> 4.108675e-21
>>
>> Would anybody please check if SuperLU can solve these matrices? Another
>> possibility is that something is wrong in my own code. But so far, I cannot
>> find any problem in my code since the same code works fine if I using
>> iterative solver or direct solver MUMPS. But for other cases I have
>> tested,  all these solvers work fine.
>>
>> Please let me know if I did not write down the problem clearly.
>>
>> Thanks,
>>
>> Danyang
>>
>>
>>
>>
>
>


Re: [petsc-users] Issues with the Variational Inequality solver

2015-12-03 Thread Justin Chang
Thanks Barry,

Next issue:

Consider the following problem:

psiA = cA - 2*cB (1a)
psiC = cC + 2*cB(1b)
cC^2 = k*cA^2*cB  (1c)

where psiA, psiC, and k are given. If I solve these five problems using the
standard Newton method:

Case 0:

psiA: 9.400282e-01

psiC: 6.045961e-09

k: 2.00

cA: 9.400282e-01

cB: 1.555428e-16

cC: 6.045961e-09

Case 1:

psiA: 8.472901e-01

psiC: 7.425271e-09

k: 2.00

cA: 8.472901e-01

cB: 2.602870e-16

cC: 7.425270e-09

Case 2:

psiA: 8.337199e-01

psiC: 7.831614e-09

k: 2.00

cA: 8.337199e-01

cB: 2.942675e-16

cC: 7.831613e-09

Case 3:

psiA: 8.268140e-01

psiC: 7.912911e-09

k: 2.00

cA: 8.268140e-01

cB: 3.029178e-16

cC: 7.912910e-09

Case 4:

psiA: 9.852477e-01

psiC: 7.992223e-09

k: 2.00

cA: 9.852477e-01

cB: 2.593282e-16

cC: 7.99e-09

These solutions are "correct", that is if I plug the c's back into
equations (1a)-(1b), i get the original psi's.

Now suppose I use the Variational Inequality such that cA/B/C >= 0, I would
expect to get the exact same solution (since the c's would be non-negative
regardless). But instead I get these solutions:

Case 0:

psiA: 9.400282e-01

psiC: 6.045961e-09

k: 2.00

cA: 1.318866e-16

cB: 3.097570e-08

cC: 6.045961e-09

Case 1:

psiA: 8.472901e-01

psiC: 7.425271e-09

k: 2.00

cA: 4.624944e-17

cB: 3.015792e-08

cC: 7.425271e-09

Case 2:

psiA: 8.337199e-01

psiC: 7.831614e-09

k: 2.00

cA: 1.733276e-16

cB: 3.079856e-08

cC: 7.831614e-09

Case 3:

psiA: 8.268140e-01

psiC: 7.912911e-09

k: 2.00

cA: 1.721078e-16

cB: 3.061785e-08

cC: 7.912911e-09

Case 4:

psiA: 9.852477e-01

psiC: 7.992223e-09

k: 2.00

cA: 2.666770e-16

cB: 4.610822e-08

cC: 7.992223e-09

Basically, the cA's shoot down to zero and the cB's are slightly greater
than zero. When I plug the c's into equations (1a) - (1b), I do not get the
correct solution at all. I would expect discrepancies if my c's were
originally negative, but for these five problems, shouldn't VI give the
same answer as the Newton's method?

Attached is the petsc4py code, the two input files containing psiA and
psiC, and the outputs from '-snes_monitor -snes_view
-ksp_monitor_true_residual'. Run as:

python testVI.py testA testC 2 <0/1>

where 0 is Newton, 1 is VI.

Know what's going on here?

Thanks,
Justin

On Wed, Dec 2, 2015 at 1:36 PM, Barry Smith  wrote:

>
> > On Dec 2, 2015, at 1:56 PM, Justin Chang  wrote:
> >
> > Barry,
> >
> > So I do not believe there is any problem with the ISEqual() per se,
> because what I am doing is I am solving 5151 different VI problem using the
> same SNES/KSP/PC/Mat. That is, I am not "resetting" these data structures
> once I am done with one problem and move on to the next. If I ran each case
> individually, I get no error; the error comes when I run these problems
> sequentially without resetting the SNES after each problem.
> >
> > I haven't run the C debugger or done any of that yet, but could this be
> a plausible explanation for my error?
>
>This is exactly the issue. Independent of VIs if you change the size of
> a problem you pass to SNES you need to call SNESReset() between each call
> of a different sizes.
>
> > Originally I was thinking about creating/destroying SNES for each
> problem but I was wondering if that might affect performance.
>
>Using SNESReset() is the way you should do it. Creating and destroying
> it each time should only be a tiny, immeasurably slower.
>
>   Barry
>
> >
> > Thanks,
> > Justin
> >
> > On Tue, Dec 1, 2015 at 5:58 PM, Barry Smith  wrote:
> >
> > > On Dec 1, 2015, at 5:13 PM, Justin Chang  wrote:
> > >
> > > Hi all,
> > >
> > > So I am running into some issues with the SNESVINEWTONRSLS solver. I
> originally had this done in firedrake, but have ported it to petsc4py.
> Attached is the code as well as the two required input files.
> > >
> > > First issue, when I run the program like this:
> > >
> > > python testVI.py psiA_1 psiB_1 2 1
> > >
> > > I get this error:
> > >
> > > Traceback (most recent call last):
> > >   File "testVI.py", line 103, in 
> > > snes.solve(None,X)
> > >   File "PETSc/SNES.pyx", line 520, in petsc4py.PETSc.SNES.solve
> (src/petsc4py.PETSc.c:169677)
> > > petsc4py.PETSc.Error: error code 60
> > > [0] SNESSolve() line 3992 in
> /Users/justin/Software/petsc/src/snes/interface/snes.c
> > > [0] SNESSolve_VINEWTONRSLS() line 507 in
> /Users/justin/Software/petsc/src/snes/impls/vi/rs/virs.c
> > > [0] KSPSetOperators() line 544 in
> /Users/justin/Software/petsc/src/ksp/ksp/interface/itcreate.c
> > > [0] PCSetOperators() line 1170 in
> /Users/justin/Software/petsc/src/ksp/pc/interface/precon.c
> > > [0] Nonconforming object sizes
> > > [0] Cannot change local size of Amat after use old sizes 2 2 new sizes
> 3 3
> > >
> > > No such error occurred when this was ran in firedrake, though I did
> notice that -snes_view did indicate that some of the iterations 

Re: [petsc-users] SuperLU convergence problem

2015-12-03 Thread Hong
Danyang:
Using petsc/src/ksp/ksp/examples/tutorials/ex10.c,
I tested a_flow_check_168.bin

mpiexec -n 4 ./ex10 -f0
/Users/Hong/Downloads/matrix_and_rhs_bin/a_flow_check_168.bin -rhs
/Users/Hong/Downloads/matrix_and_rhs_bin/x_flow_check_168.bin -pc_type lu
-pc_factor_mat_solver_package superlu_dist
Number of iterations =   1
Residual norm 1.38302e-05

petsc (sequential) and mumps all give residual norm = 1.e-5.

For 169,
mpiexec -n 4 ./ex10 -f0
/Users/Hong/Downloads/matrix_and_rhs_bin/a_flow_check_169.bin -rhs
/Users/Hong/Downloads/matrix_and_rhs_bin/x_flow_check_169.bin -pc_type lu
-pc_factor_mat_solver_package superlu_dist
Number of iterations =   1
Residual norm 6.83854e-10

For 170, 171, 172, I get
mpiexec -n 4 ./ex10 -f0
/Users/Hong/Downloads/matrix_and_rhs_bin/a_flow_check_172.bin -rhs
/Users/Hong/Downloads/matrix_and_rhs_bin/x_flow_check_172.bin -pc_type lu
-pc_factor_mat_solver_package superlu_dist
Number of iterations =   1
  Residual norm < 1.e-12

Can you use this example test these matrices?
I use superlu_dist-v4.1.

Hong

Hi Hong,
>
> The binary format of matrix, rhs and solution can be downloaded via the
> link below.
>
> https://www.dropbox.com/s/cl3gfi0s0kjlktf/matrix_and_rhs_bin.tar.gz?dl=0
>
> Thanks,
>
> Danyang
>
>
> On 15-12-03 10:50 AM, Hong wrote:
>
> Danyang:
>
>>
>>
>> To my surprising, solutions from SuperLU at timestep 29 seems not correct
>> for the first 4 Newton iterations, but the solutions from iteration solver
>> and MUMPS are correct.
>>
>> Please find all the matrices, rhs and solutions at timestep 29 via the
>> link below. The data is a bit large so that I just share it through
>> Dropbox. A piece of matlab code to read these data and then computer the
>> norm has also been attached.
>> *https://www.dropbox.com/s/rr8ueysgflmxs7h/results-check.tar.gz?dl=0
>> *
>>
>
> Can you send us matrix in petsc binary format?
>
> e.g., call MatView(M, PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD))
> or '-ksp_view_mat binary'
>
> Hong
>
>>
>>
>> Below is a summary of the norm from the three solvers at timestep 29,
>> newton iteration 1 to 5.
>>
>> Timestep 29
>> Norm of residual seq 1.661321e-09, superlu 1.657103e+04, mumps
>> 3.731225e-11
>> Norm of residual seq 1.753079e-09, superlu 6.675467e+02, mumps
>> 1.509919e-13
>> Norm of residual seq 4.914971e-10, superlu 1.236362e-01, mumps
>> 2.139303e-17
>> Norm of residual seq 3.532769e-10, superlu 1.304670e-04, mumps
>> 5.387000e-20
>> Norm of residual seq 3.885629e-10, superlu 2.754876e-07, mumps
>> 4.108675e-21
>>
>> Would anybody please check if SuperLU can solve these matrices? Another
>> possibility is that something is wrong in my own code. But so far, I cannot
>> find any problem in my code since the same code works fine if I using
>> iterative solver or direct solver MUMPS. But for other cases I have
>> tested,  all these solvers work fine.
>>
>> Please let me know if I did not write down the problem clearly.
>>
>> Thanks,
>>
>> Danyang
>>
>>
>>
>>
>
>


Re: [petsc-users] SuperLU convergence problem

2015-12-03 Thread Danyang Su

Hi Hong,

The binary format of matrix, rhs and solution can be downloaded via the 
link below.


https://www.dropbox.com/s/cl3gfi0s0kjlktf/matrix_and_rhs_bin.tar.gz?dl=0

Thanks,

Danyang

On 15-12-03 10:50 AM, Hong wrote:

Danyang:



To my surprising, solutions from SuperLU at timestep 29 seems not
correct for the first 4 Newton iterations, but the solutions from
iteration solver and MUMPS are correct.

Please find all the matrices, rhs and solutions at timestep 29 via
the link below. The data is a bit large so that I just share it
through Dropbox. A piece of matlab code to read these data and
then computer the norm has also been attached.
_https://www.dropbox.com/s/rr8ueysgflmxs7h/results-check.tar.gz?dl=0_


Can you send us matrix in petsc binary format?

e.g., call MatView(M, PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD))
or '-ksp_view_mat binary'

Hong



Below is a summary of the norm from the three solvers at timestep
29, newton iteration 1 to 5.

Timestep 29
Norm of residual seq 1.661321e-09, superlu 1.657103e+04, mumps
3.731225e-11
Norm of residual seq 1.753079e-09, superlu 6.675467e+02, mumps
1.509919e-13
Norm of residual seq 4.914971e-10, superlu 1.236362e-01, mumps
2.139303e-17
Norm of residual seq 3.532769e-10, superlu 1.304670e-04, mumps
5.387000e-20
Norm of residual seq 3.885629e-10, superlu 2.754876e-07, mumps
4.108675e-21

Would anybody please check if SuperLU can solve these matrices?
Another possibility is that something is wrong in my own code. But
so far, I cannot find any problem in my code since the same code
works fine if I using iterative solver or direct solver MUMPS. But
for other cases I have tested,  all these solvers work fine.

Please let me know if I did not write down the problem clearly.

Thanks,

Danyang








Re: [petsc-users] SNES function domain error

2015-12-03 Thread Adrian Croucher

hi

On 03/12/15 18:43, Barry Smith wrote:

I absolutely do NOT recommend doing variable switching with SNES. Our 
Newton solvers are not designed with variable switching in mind so you get 
these absurd limitations like needing SNESLINESEARCHBASIC

It would be great if someone who understood variable switching would either 
1) contribute a Newton that supports variable switching to PETSc or 2) enhance 
the current SNESSolve_NewtonLS to support variable switching (I don't know 
which is easier).


I had resigned myself to not being able to use a line search, partly 
because the nonlinear solver in the TOUGH2 simulator (which we've used 
for many years to solve geothermal flow problems with phase changes and 
variable switching) doesn't use one either, and it generally works fine 
without one. Without the line search, SNES is doing much the same thing 
and doesn't seem to be upset by the variable switching either. It's only 
the error handling that's causing trouble.


But also I couldn't really see how a line search could be made to work 
with variable switching. When you switch variables, you're effectively 
doing a discontinuous leap into another part of the solution space. How 
can searching along a line between the old phase conditions and the new 
ones be made to make sense? Are there literature examples where people 
have done it?


Cheers, Adrian

--
Dr Adrian Croucher
Senior Research Fellow
Department of Engineering Science
University of Auckland, New Zealand
email: a.crouc...@auckland.ac.nz
tel: +64 (0)9 923 84611



Re: [petsc-users] SNES function domain error

2015-12-03 Thread Barry Smith

> On Dec 3, 2015, at 6:22 PM, Adrian Croucher  wrote:
> 
> hi
> 
> On 03/12/15 18:43, Barry Smith wrote:
>>I absolutely do NOT recommend doing variable switching with SNES. Our 
>> Newton solvers are not designed with variable switching in mind so you get 
>> these absurd limitations like needing SNESLINESEARCHBASIC
>> 
>>It would be great if someone who understood variable switching would 
>> either 1) contribute a Newton that supports variable switching to PETSc or 
>> 2) enhance the current SNESSolve_NewtonLS to support variable switching (I 
>> don't know which is easier).
> 
> I had resigned myself to not being able to use a line search, partly because 
> the nonlinear solver in the TOUGH2 simulator (which we've used for many years 
> to solve geothermal flow problems with phase changes and variable switching) 
> doesn't use one either, and it generally works fine without one. Without the 
> line search, SNES is doing much the same thing and doesn't seem to be upset 
> by the variable switching either. It's only the error handling that's causing 
> trouble.
> 
> But also I couldn't really see how a line search could be made to work with 
> variable switching. When you switch variables, you're effectively doing a 
> discontinuous leap into another part of the solution space. How can searching 
> along a line between the old phase conditions and the new ones be made to 
> make sense? Are there literature examples where people have done it?

   These are hard questions (at least to me) which is why I've never been able 
to implement a full featured Newton with variable switching. 

   Switching variables between function evaluations in a line search is 
completely nuts which is why I envision a "full featured" Newton with variable 
switching to be somewhat (or a lot) like active set (also called reduced space) 
Newton methods. Basically freeze the variables (not allow switching them) and 
build the Newton correction  including a full line search in a subspace that 
wouldn't violate any "bounds" on the variables. Then after this Newton step you 
decide if certain variables should be switched, and then you do the next full 
featured Newton step. So instead of freely switching variables at each function 
evaluation you only switch them at each "Jacobian" evaluation.

   There is some PETSc code SNESSolve_VINEWTONRSLS that solves nonlinear 
equations with bounds on some or all variables; but in this case there are not 
all the complications of variable switching, basically when variables are on 
the bound you just "turned off" the related equation. So it is possible that it 
is a very special case of what is needed for variable switching.

  Actually if you could provide a simple case of where variable switching is 
using I'd like to try to develop some algorithms, so far when I ask people they 
give me a big messy things with many variables that I could never understand.

   Barry



> 
> Cheers, Adrian
> 
> -- 
> Dr Adrian Croucher
> Senior Research Fellow
> Department of Engineering Science
> University of Auckland, New Zealand
> email: a.crouc...@auckland.ac.nz
> tel: +64 (0)9 923 84611
> 



Re: [petsc-users] SuperLU convergence problem

2015-12-03 Thread Hong
Danyang:

>
>
> To my surprising, solutions from SuperLU at timestep 29 seems not correct
> for the first 4 Newton iterations, but the solutions from iteration solver
> and MUMPS are correct.
>
> Please find all the matrices, rhs and solutions at timestep 29 via the
> link below. The data is a bit large so that I just share it through
> Dropbox. A piece of matlab code to read these data and then computer the
> norm has also been attached.
> *https://www.dropbox.com/s/rr8ueysgflmxs7h/results-check.tar.gz?dl=0
> *
>

Can you send us matrix in petsc binary format?

e.g., call MatView(M, PETSC_VIEWER_BINARY_(PETSC_COMM_WORLD))
or '-ksp_view_mat binary'

Hong

>
>
> Below is a summary of the norm from the three solvers at timestep 29,
> newton iteration 1 to 5.
>
> Timestep 29
> Norm of residual seq 1.661321e-09, superlu 1.657103e+04, mumps
> 3.731225e-11
> Norm of residual seq 1.753079e-09, superlu 6.675467e+02, mumps
> 1.509919e-13
> Norm of residual seq 4.914971e-10, superlu 1.236362e-01, mumps
> 2.139303e-17
> Norm of residual seq 3.532769e-10, superlu 1.304670e-04, mumps
> 5.387000e-20
> Norm of residual seq 3.885629e-10, superlu 2.754876e-07, mumps
> 4.108675e-21
>
> Would anybody please check if SuperLU can solve these matrices? Another
> possibility is that something is wrong in my own code. But so far, I cannot
> find any problem in my code since the same code works fine if I using
> iterative solver or direct solver MUMPS. But for other cases I have
> tested,  all these solvers work fine.
>
> Please let me know if I did not write down the problem clearly.
>
> Thanks,
>
> Danyang
>
>
>
>