[petsc4py] What should be the 'default' communicator?

Lisandro Dalcin dalcinl at gmail.com
Tue Aug 26 08:54:26 CDT 2008


On Tue, Aug 26, 2008 at 10:24 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>   This seems a fundamental stupidity of python. Why can't you make this
> PETSc thing
> be a python class where the default_comm is a property?
>

In general, such approach is not convenient. Modules are tightly
releated to 'import' statements. Modules provide a 'namespace' for all
stuff you put inside them.

Barry, see my current inplementation:


from petsc4py import PETSc

saved_comm = PETSc.Sys.getDefaultComm()
PETSc.Sys.setDefaultComm(PETSc.COMM_SELF)
# do stuff....
PETSc.Sys.setDefaultComm(saved_comm)

Do it looks too bad?. I do not expect this pattern to be used all over
user code. Trying to hack/emulate what you want (using a class
instance) will complicate too much the implementation, and the final
result could be 'unnatural' for end users. For example,

from petsc4py.PETSc import Vec, Mat

is expected to work, but that will not work if 'PETSc' is a class instance.




-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594




More information about the petsc-dev mailing list