← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Major revision in PyDOLFIN

 

On Wednesday 02 September 2009 23:13:04 Anders Logg wrote:
> On Wed, Sep 02, 2009 at 10:56:28PM +0200, Johan Hake wrote:
> > On Wednesday 02 September 2009 22:35:37 DOLFIN wrote:
> > > One or more new changesets pushed to the primary dolfin repository.
> > > A short summary of the last three changesets is included below.
> > >
> > > changeset:   6876:b2bf81ebe3725e0548b50e6b4fd3cf5827ce3f48
> > > tag:         tip
> > > user:        "Johan Hake <hake@xxxxxxxxx>"
> > > date:        Wed Sep 02 22:35:31 2009 +0200
> > > files:       ChangeLog demo/mesh/intersection/python/demo.py
> > >  dolfin/fem/assemble.cpp dolfin/fem/assemble.h dolfin/swig/Indices.i
> > >  dolfin/swig/common_post.i dolfin/swig/common_pre.i
> > > dolfin/swig/defines.i dolfin/swig/directors.i dolfin/swig/docstrings.i
> > > dolfin/swig/dolfin.i dolfin/swig/dolfin_common_post.i
> > > dolfin/swig/dolfin_common_pre.i dolfin/swig/dolfin_docstrings.i
> > > dolfin/swig/dolfin_exceptions.i dolfin/swig/dolfin_fem_pre.i
> > > dolfin/swig/dolfin_la_post.i
> > >  dolfin/swig/dolfin_la_pre.i dolfin/swig/dolfin_log_post.i
> > >  dolfin/swig/dolfin_log_pre.i dolfin/swig/dolfin_mesh_post.i
> > >  dolfin/swig/dolfin_mesh_pre.i dolfin/swig/dolfin_parameter_post.i
> > >  dolfin/swig/dolfin_parameter_pre.i
> > > dolfin/swig/dolfin_shared_ptr_classes.i
> > > dolfin/swig/dolfin_std_vector_typemaps.i dolfin/swig/exceptions.i
> > > dolfin/swig/fem_pre.i dolfin/swig/function_post.i
> > >  dolfin/swig/function_pre.i dolfin/swig/generate.py
> > >  dolfin/swig/generate_docstrings.py dolfin/swig/headers.i
> > >  dolfin/swig/ignores.i dolfin/swig/io_post.i dolfin/swig/la_post.i
> > >  dolfin/swig/la_pre.i dolfin/swig/log_post.i dolfin/swig/log_pre.i
> > >  dolfin/swig/mesh_post.i dolfin/swig/mesh_pre.i
> > >  dolfin/swig/numpy_typemaps.i dolfin/swig/parameter_post.i
> > >  dolfin/swig/parameter_pre.i dolfin/swig/renames.i
> > >  dolfin/swig/renames_pre.i dolfin/swig/shared_ptr_classes.i
> > >  dolfin/swig/std_vector_typemaps.i dolfin/swig/swig_version.i
> > >  dolfin/swig/typemaps.i sandbox/misc/python/test_params.py
> > >  site-packages/dolfin/__init__.py site-packages/dolfin/assemble.py
> > >  site-packages/dolfin/form.py
> > > site-packages/dolfin/variationalproblem.py description:
> > > Major revision in PyDOLFIN
> >
> > Sorry for the big word. Not really major. It just touch most of the SWIG
> > interface files.
> >
> > The only real change for the user is that we now do not use the
> > STLFooVector. We do not use the built in SWIG interface as the
> > std_vector.i macros produces a lot of code and functionalities we do not
> > use. The functionalities is now substituted by typemaps. Please inform me
> > if some functionality got lost on the way.
> 
> Very good!
> 
> > Other implications:
> > In IntersectionDetector.intersection we now return the intersected cells
> > using a numpy array of int, instead of a handed STLUintVector
> 
> Also good.

We do some copying to facilitate this, so we have traded some speed for 
usability.

Also a

  std::vector<double> & values 

typemap, used for getting the values out of a row, using 
GenericMatrix::getrow, triggers some MPI::foo typemaps. This means that some 
functions in the MPI class now only returns values. That is to say we cannot 
send a numpy array of doubles using MPI in python, where the above signature 
is used. My knowledge of the MPI interface in DOLFIN is limited so this might 
not be a problem. 

Not sure how we should tackle this. We might choose another name on the 
argument. We could also split the inclusion of the foo_pre.i and foo_post.i, 
so the logic of including module specific SWIG interface files would be:

  %include foo_pre.i
  %include foo_headers.i
  %include foo_post.i

  %include bar_pre.i
  %include bar_headers.i
  %include bar_post.i

instead of 

  %include foo_pre.i
  %include bar_pre.i

  %include foo_headers.i
  %include bar_headers.i

  %include foo_post.i
  %include bar_post.i

as it is now. Then we can apply module specific typemaps, which only kicks in 
for a certain modules. We could generate such an inclusion file automatically 
using the generate.py script.

> > We can now also send a list of FunctionSpaces, Functions,
> > BoundaryConditions a.s.o instead of instantiate a STLFooVector and push
> > the objects to this. We can now also handle std::vector<const Foo*>&,
> > where the const was the tricky one before, using just a list of Foo
> > objects. So we no longer need the assemble_system_swig function.
> 
> Very good. I guess this mostly affected the code in
> site-packages/dolfin, not user code?

That is true. However it might be useful to go over the C++ interface and 
change any:

  const std::vector<Foo*>& 

to 

  const std::vector<const Foo*>& 

where this make sense. We have avoided this before as the SWIG std::vector 
interface prevented this before. 


Johan

> --
> Anders
> 
> > Johan
> >
> > >  - Extend comments to SWIG interface files
> > >  - Add copyright statements to SWIG interface files (not finished yet)
> > >  - Remove dependencies on std_vector.i reducing SWIG wrapper code size
> > >    * This together with other efforts reduced the wrapper file
> > >      from 5.2 MB -> 3.2MB
> > >  - Add typemaps for misc std::vector<types> in PyDOLFIN
> > >    * This makes it possible to send a list of Foo where DOLFIN
> > >      wants [const] std::vector<[const] Foo*>, where const is optional
> > >  - Use relative %includes in dolfin.i
> > >  - Changed names on SWIG interface files dolfin_foo.i -> foo.i
> > >    * We now write
> > >        %include "dolfin/swig/exceptions.i"
> > >      instead of
> > >        %include "dolfin_exceptions.i"
> > >
> > >
> > > changeset:   6875:6ada20ae6ecb56880ef285764b7fd2d6f3a120a8
> > > user:        "Garth N. Wells <gnw20@xxxxxxxxx>"
> > > date:        Wed Sep 02 20:08:35 2009 +0100
> > > files:       dolfin/fem/FiniteElement.h dolfin/function/Function.cpp
> > >  dolfin/function/UFCFunction.cpp description:
> > > Fix bug in Data.
> > >
> > >
> > > changeset:   6874:626ed73482edf00c23300defa03d9707448a0ec3
> > > user:        Anders Logg <logg@xxxxxxxxx>
> > > date:        Sat Aug 29 15:45:14 2009 +0200
> > > files:       site-packages/dolfin/jit.py
> > > description:
> > > Set "log_prefix" for form compiler (in options) when running in
> > > parallel. Should perhaps have been in the decorator but seems
> > > complicated with all the kwargs...
> > >
> > > ----------------------------------------------------------------------
> > > For more details, visit http://www.fenics.org/hg/dolfin
> > > _______________________________________________
> > > DOLFIN-dev mailing list
> > > DOLFIN-dev@xxxxxxxxxx
> > > http://www.fenics.org/mailman/listinfo/dolfin-dev
> >
> > _______________________________________________
> > DOLFIN-dev mailing list
> > DOLFIN-dev@xxxxxxxxxx
> > http://www.fenics.org/mailman/listinfo/dolfin-dev
> 


Follow ups

References