← Back to team overview

ffc team mailing list archive

Re: including a file in .form

 

On Fri, Dec 30, 2005 at 06:46:19PM +0100, Johan Jansson wrote:
> On Fri, Dec 30, 2005 at 04:43:27PM +0100, Garth N. Wells wrote:
> > On Fri, 2005-12-30 at 09:34 -0600, Anders Logg wrote:
> > > We could add some built-in support to the parser/command-line
> > > interface to handle both 2D and 3D problems, but one could also argue
> > > that we should keep it as simple as possible, since all the
> > > flexibility you need is available anyway through the Python interface.
> > > 
> > 
> > The procedure to include files seems really simple, so I think that
> > there is no need to build in any extra functionality for 2D/3D.
> > 
> > Garth
> > 
> 
> I think there could be a problem with the Python search path (at least
> when using the FFC executable). I remember testing something similar
> to this, but then the Python search path was not set to the directory
> containing the form file. So perhaps the DOLFIN build system needs to
> be exploited to handle this, or some other convention adopted, like
> adding the current directory to the search path.
> 
>   Johan

You're right, there is (was) a problem. I've fixed it so now it should
work to use import from .form files.

Note that if you put stuff in foo.py, you need to import it using

    import foo

and then access the functions etc you put in there by foo.bar.

The easiest is probably to just declare a and L etc in foo.py and then
do

    from foo import *

I tested this for a simple example and it works now, so tell me if you
run into difficulties.

/Anders



References