[petsc-users] some questions about PETSc

Lisandro Dalcin dalcinl at gmail.com
Sat Sep 18 19:55:02 CDT 2010


On 18 September 2010 21:01, Aron Ahmadia <aron.ahmadia at kaust.edu.sa> wrote:
> Dear Amal,
> Thanks for the questions.  These are great!  I think they show a good
> fundamental approach, you are thinking about these problems like a PETSc
> scientist would.  I am going to cc petsc-users on the reply in case anybody
> wants to add or comment:
> How to set up a DA for multiple equations in petsc4py or PETSc? (for q)
> The PETSc terminology for the number of equations active at a given node is
> 'degrees of freedom', which as far as I can tell, is a term borrowed from
> finite element analysis of structures, originally referring (in mechanics)
> to the number of potential displacements or rotations that specify an
> element in the system, but in computational science as a way to describe the
> total number of equations in the discretized system (i.e., the number of
> elements in the right-hand side vector).  After you have called DACreate,
> you call DASetDof
> (http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/DA/DASetDof.html)
> to set the number of degrees of freedom per vertex.

In petsc4py, you pass "dof" as a keyword argument to create() method:

da = PETSc.DA().create((Nx, Ny, Nz), dof=4, ...)


> How to deal with boundary conditions where you have special treatment for
> them?  In an example we have seen that is done by simply if statements that
> checks if this point is a boundary condition cell, should we do it this way.
> As far as I know, this is the PETSc way, so you do not need to do anything
> differently :o)  Later on, when we are tuning for performance, we might
> extract the boundary-handling code from the main for loop, and create index
> sets to represent each of the sections of the array we would like to iterate
> over.  If we profile the code and this is a non-significant section, then we
> just leave it.

And with petsc4py running on parallel, this is a mess to implement. I
still have to found a way to emulate DA Vec arrays, as NumPy arrays
does not support lower bounds in dimensions.

> When we start incorporating petsc4py structures in clawpack, output is being
> duplicate for each process, is the way to avoid this is by (if statements)
> to determine that everything need to be done once is the responsibility of
> process 0 for instance, or there are other ways to do it?
> PetscPrintf
> (http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/Sys/PetscPrintf.html)
> will do what you want.

In petsc4py, you can use PETSc.Sys.Print (also look at
PETSc.Sys.syncPrint and PETSc.Sys.syncFlush). PETSc.Sys.Print (and
syncPrint) should be used like print function Python 3, but it
interprets an extra 'comm'  kw argument.



-- 
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169


More information about the petsc-users mailing list