[petsc-users] Question on DMMGSetSNESLocal from snes/example/tutorials/ex19.c

Sun, Hui hus003 at ucsd.edu
Sat May 31 16:38:50 CDT 2014


Thank you Jed for explaining this to me. I tried to compile and run with the following options:
./ex19 -lidvelocity 100 -grashof 1e4 -da_grid_x 32 -da_grid_y 32 -da_refine 2 -snes_monitor_short -snes_converged_reason

1). I use 2 cores and get the following output:
lid velocity = 100, prandtl # = 1, grashof # = 10000
  0 SNES Function norm 1111.93 
  1 SNES Function norm 829.129 
  2 SNES Function norm 532.66 
  3 SNES Function norm 302.926 
  4 SNES Function norm 3.64014 
  5 SNES Function norm 0.0410053 
  6 SNES Function norm 4.57951e-06 
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 6
Number of SNES iterations = 6
Time cost for creating solver context 0.000907183 s, and for solve 25.2764 s.

2). I use 8 cores and get the following output:
lid velocity = 100, prandtl # = 1, grashof # = 10000
  0 SNES Function norm 1111.93 
  1 SNES Function norm 829.049 
  2 SNES Function norm 532.616 
  3 SNES Function norm 303.165 
  4 SNES Function norm 3.93436 
Nonlinear solve did not converge due to DIVERGED_LINEAR_SOLVE iterations 4
Number of SNES iterations = 4
Time cost for creating solver context 0.0244079 s, and for solve 25.0607 s.

First of all, the two runs yields different results. 
Secondly, the time cost comparison doesn't seem to be scaling correctly. 
( I have used petsctime.h to calculate the time cost. )

Do you have any insight of what might be missing? 

-Hui


________________________________________
From: Jed Brown [jed at jedbrown.org]
Sent: Saturday, May 31, 2014 10:52 AM
To: Sun, Hui; petsc-users at mcs.anl.gov
Subject: RE: [petsc-users] Question on DMMGSetSNESLocal from snes/example/tutorials/ex19.c

"Sun, Hui" <hus003 at ucsd.edu> writes:

> Continue this topic. Right now I'm looking at ex19.c from PETSc v3.3
> and v3.4, both containing a user defined function NonlinearGS(SNES,
> Vec, Vec, void*), I'm wondering why the arguments are not passed by
> reference or pointers?

All PETSc objects (like SNES, Vec, etc.) are pointers to private
structures.

  typedef struct _p_Vec *Vec;

You cannot dereference the pointer because the implementation is
private, but it is passed around as a pointer.


More information about the petsc-users mailing list