On Mar 6, 2013, at 2:18 PM, Matthew Knepley <knepley at gmail.com> wrote:

> On Wed, Mar 6, 2013 at 2:54 PM, Richard Tran Mills <rtm at eecs.utk.edu> 
> wrote:
> Hi Folks,
> 
> I am adding some pointers to scatter contexts within the internal "data" 
> struct for DMShell, e.g. the 'gtol' and 'ltog' members in
> 
> typedef struct  {
>   Vec Xglobal;
>   Vec Xlocal;
>   Mat A;
>   VecScatter *gtol;
>   VecScatter *ltog;
> } DM_Shell;
> 
> First question: When in DMCreate_Shell we do
> 
> ierr     = PetscNewLog(dm,DM_Shell,&shell);CHKERRQ(ierr);
> 
> will this guarantee that gtol and ltog are set to NULL, or do I need to 
> explicitly set these somewhere?  I see that the allocated memory is zeroed 
> but I'm not sure how NULL might actually be represented in memory.
> 
> Yes, they will be NULL.
>  
> I have also added some new functions like 
> DMShellDefaultGlobalToLocalBegin()/End(), and in DMCreate_Shell I do 
> 
>   dm->ops->globaltolocalbegin = DMShellDefaultGlobalToLocalBegin;
>   dm->ops->globaltolocalend   = DMShellDefaultGlobalToLocalEnd;
> 
   Bad names. Since they are not user functions they should have an underscore 
in them and specification of implementation after the underscore. Perhaps  
DMGlobalToLocalBegin_Shell_Default?

    Check out the PETSc developers manual style guide (which is now chapter one 
so people actually read it :-)) Section 1.1 and 1.2 
http://www.mcs.anl.gov/petsc/developers/developers.pdf


   Barry



> The user can set different routines via DMShellSetGlobalToLocalBegin()/End(), 
> but if the user only sets the gtol and ltog scatter contexts, then the 
> default routines will perform the appropriate scatter operations.
> 
> Second question: What is the proper "PETSc way" to throw an error if gtol is 
> NULL and tell the user that DMShellDefaultGlobalToLocalBegin() cannot be used 
> without first setting the scatter context via 
> DMShellSetGlobalToLocalVecScatter()?
> 
> SETERRQ(comm, PETSC_ERR_ARG_WRONGSTATE, "DMShellDefaultGlobalToLocalBegin() 
> cannot be used without first setting the scatter context via 
> DMShellSetGlobalToLocalVecScatter()");
> 
>    Matt
>  
> Thanks,
> Richard
> 
> 
> 
> -- 
> Richard Tran Mills, Ph.D.
> Computational Earth Scientist      | Joint Assistant Professor
> Hydrogeochemical Dynamics Team     | EECS and Earth & Planetary Sciences
> Oak Ridge National Laboratory      | University of Tennessee, Knoxville
> E-mail: 
> rmills at ornl.gov  V: 865-241-3198 http://climate.ornl.gov/~rmills
> 
> 
> 
> -- 
> 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

Reply via email to