Thanks for the extra notes Lisandro, I've migrated some of the results of this discussion to the petclaw development wiki here: <a href="https://bitbucket.org/knepley/petclaw/wiki/How_do_I">https://bitbucket.org/knepley/petclaw/wiki/How_do_I</a><div>
<br></div><div>A</div><div><br><div class="gmail_quote">On Sat, Sep 18, 2010 at 8:55 PM, Lisandro Dalcin <span dir="ltr"><<a href="mailto:dalcinl@gmail.com">dalcinl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 18 September 2010 21:01, Aron Ahmadia <<a href="mailto:aron.ahmadia@kaust.edu.sa">aron.ahmadia@kaust.edu.sa</a>> wrote:<br>
> Dear Amal,<br>
> Thanks for the questions. These are great! I think they show a good<br>
> fundamental approach, you are thinking about these problems like a PETSc<br>
> scientist would. I am going to cc petsc-users on the reply in case anybody<br>
> wants to add or comment:<br>
> How to set up a DA for multiple equations in petsc4py or PETSc? (for q)<br>
> The PETSc terminology for the number of equations active at a given node is<br>
> 'degrees of freedom', which as far as I can tell, is a term borrowed from<br>
> finite element analysis of structures, originally referring (in mechanics)<br>
> to the number of potential displacements or rotations that specify an<br>
> element in the system, but in computational science as a way to describe the<br>
> total number of equations in the discretized system (i.e., the number of<br>
> elements in the right-hand side vector). After you have called DACreate,<br>
> you call DASetDof<br>
> (<a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/DA/DASetDof.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/DA/DASetDof.html</a>)<br>
> to set the number of degrees of freedom per vertex.<br>
<br>
</div>In petsc4py, you pass "dof" as a keyword argument to create() method:<br>
<br>
da = PETSc.DA().create((Nx, Ny, Nz), dof=4, ...)<br>
<div class="im"><br>
<br>
> How to deal with boundary conditions where you have special treatment for<br>
> them? In an example we have seen that is done by simply if statements that<br>
> checks if this point is a boundary condition cell, should we do it this way.<br>
> As far as I know, this is the PETSc way, so you do not need to do anything<br>
> differently :o) Later on, when we are tuning for performance, we might<br>
> extract the boundary-handling code from the main for loop, and create index<br>
> sets to represent each of the sections of the array we would like to iterate<br>
> over. If we profile the code and this is a non-significant section, then we<br>
> just leave it.<br>
<br>
</div>And with petsc4py running on parallel, this is a mess to implement. I<br>
still have to found a way to emulate DA Vec arrays, as NumPy arrays<br>
does not support lower bounds in dimensions.<br>
<div class="im"><br>
> When we start incorporating petsc4py structures in clawpack, output is being<br>
> duplicate for each process, is the way to avoid this is by (if statements)<br>
> to determine that everything need to be done once is the responsibility of<br>
> process 0 for instance, or there are other ways to do it?<br>
> PetscPrintf<br>
> (<a href="http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/Sys/PetscPrintf.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/Sys/PetscPrintf.html</a>)<br>
> will do what you want.<br>
<br>
</div>In petsc4py, you can use PETSc.Sys.Print (also look at<br>
PETSc.Sys.syncPrint and PETSc.Sys.syncFlush). PETSc.Sys.Print (and<br>
syncPrint) should be used like print function Python 3, but it<br>
interprets an extra 'comm' kw argument.<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Lisandro Dalcin<br>
---------------<br>
CIMEC (INTEC/CONICET-UNL)<br>
Predio CONICET-Santa Fe<br>
Colectora RN 168 Km 472, Paraje El Pozo<br>
Tel: +54-342-4511594 (ext 1011)<br>
Tel/Fax: +54-342-4511169<br>
</font></blockquote></div><br></div>