dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #10081
Re: BC specification in PyDOLFIN
On Mon, Oct 13, 2008 at 09:42:51PM +0200, Johan Hake wrote:
> On Monday 13 October 2008 18:34:01 Ostien, Jakob T wrote:
> > > -----Original Message-----
> > > From: dolfin-dev-bounces@xxxxxxxxxx
> > > [mailto:dolfin-dev-bounces@xxxxxxxxxx] On Behalf Of Anders Logg
> > > Sent: Monday, October 13, 2008 8:37 AM
> > > To: dolfin-dev@xxxxxxxxxx
> > > Subject: Re: [DOLFIN-dev] BC specification in PyDOLFIN
> > >
> > > On Mon, Oct 13, 2008 at 08:10:35AM -0600, Ostien, Jakob T wrote:
> > > > Hi,
> > > >
> > > > Is it currently possible to set the boundary condition
> > >
> > > search specification in PyDOLFIN?
> > >
> > > > in cpp
> > > > DirichletBC bc(function, mesh, subdomain, geometric);
> > > >
> > > > in PyDOLFIN
> > > > bc = DirichletBC(function, mesh, subdomain, geometric)
> > > >
> > > > this gives
> > > > NameError: name 'geometric' is not defined
> > > >
> > > > (same for pointwise)
> > > >
> > > > Jake
> > >
> > > Does it work if you instead write dolfin.geometric?
> >
> > Yes (see below).
> >
> > > In that case, it's a simple fix to include it in the
> > > __init__.py file for DOLFIN (site-packages/dolfin/__init__.py).
> >
> > Adding the following to __init__.py got rid of the NameError.
> >
> > # BC specification
> > from dolfin import topological, geometric, pointwise
Added.
> > However a simple 2D DG elasticity script uncovers other problems. Namely,
> > trying to use the pointwise specification gives the following error:
> >
> > TypeError: 'PySwigObject' object is unscriptable Swig director
> > method error. Error detected when calling 'SubDomain.inside'
>
> It seems that swig get problems when the function
>
> user_sub_domain->inside(data.coordinates[i], false)
>
> is called in
>
> DirichletBC::computeBCPointwise
>
> Here data.coordinates is a double** array. The double* that is sent in to
> inside is wrapped by swig as a crude
>
> <Swig Object of type 'double *' at 0x86c44c0>
>
> which is not subscriptable, and hence the error.
>
> I think this is a known problem as the dolfin devs have added a data type,
> simple_array, that wrap the double* and makes the array subscriptable.
Yes!
> To Kent: Maybe something for your book chapter on known issues with
> crosslanguage programming? ;)
>
> A patch that fix the problem is attached. :)
>
> > (I have absolutely no idea what that even means, I don't know python/swig
> > very well)
> >
> > Also, trying to use a LinearPDE gives a seg fault for the geometric
> > specification. (or some other nasty glibc error)
>
> I haven't looked at this one...
>
> Johan
I've applied the patch from Johan (our Python-maintainer to be... ;-)
--
Anders
> # HG changeset patch
> # User "Johan Hake <hake@xxxxxxxxx>"
> # Date 1223926649 -7200
> # Node ID d4b1ca4d9a980d8904de48988806b1ad1c5a1f69
> # Parent 9e36520b1151b497e7c5ad21c9e1e0c3a78bbb7b
> Fixed a bug when userdefined subdomain is used from python, together with pointwise applyied DirichletBC
>
> diff -r 9e36520b1151 -r d4b1ca4d9a98 dolfin/fem/DirichletBC.cpp
> --- a/dolfin/fem/DirichletBC.cpp Mon Oct 13 00:16:19 2008 +0200
> +++ b/dolfin/fem/DirichletBC.cpp Mon Oct 13 21:37:29 2008 +0200
> @@ -5,7 +5,7 @@
> // Modified by Martin Sandve Alnes, 2008
> //
> // First added: 2007-04-10
> -// Last changed: 2008-10-01
> +// Last changed: 2008-10-13
>
> #include <dolfin/common/constants.h>
> #include <dolfin/function/Function.h>
> @@ -569,7 +569,8 @@
> for (uint i = 0; i < data.dof_map->local_dimension(); ++i)
> {
> // Check if the coordinates are part of the sub domain
> - if ( !user_sub_domain->inside(data.coordinates[i], false) )
> + simple_array<double> x(data.ufc_mesh.geometric_dimension, data.coordinates[i]);
> + if ( !user_sub_domain->inside(x, false) )
> continue;
>
> if(!interpolated)
Attachment:
signature.asc
Description: Digital signature
References