← Back to team overview

dolfin team mailing list archive

Re: python assembly problem, STL

 

On Mon, Mar 03, 2008 at 01:47:33PM +0100, Ola Skavhaug wrote:
> Hi,
> 
> I'm trying to assemble a pde using pyDOLFIN, but I get some template related
> errors.
> 
> The code:
> 
> 
> from dolfin import *
> 
> P1 = FiniteElement("Lagrange", "triangle", 1)
> element = P1 + P1
> 
> (v,q) = TestFunctions(element)
> (s1,h1) = TrialFunctions(element)
> (s0,h0) = Functions(element)

Looks like this is the problem. s0 and h0 never get any values before
you assemble.

-- 
Anders


> class K(Function):
>     def __init__(self, element, mesh, value):
>         Function.__init__(self, element, mesh)
>         self.value = value
>     def eval(self, values, x):
>         values[0] = self.value
> 
> class Alpha(Function):
>     def __init__(self, element, mesh, value):
>         Function.__init__(self, element, mesh)
>         self.value = value
>     def eval(self, values, x):
>         values[0] = self.value
> 
> class Beta(Function):
>     def __init__(self, element, mesh, value):
>         Function.__init__(self, element, mesh)
>         self.value = value
>     def eval(self, values, x):
>         values[0] = self.value
> 
> 
> mesh  = UnitSquare(10,10)
> k     = K(P1, mesh, 1.0)
> alpha = Alpha(P1, mesh, 1.0)
> beta  = Beta(P1, mesh, 1.0)
> 
> a = v*s1*dx + q*h1*dx
> L = v*s0*dx + q*h0*dx + k*( \
>         alpha*s0*dot(grad(h0),grad((1-s0)*v)) \
>         -beta*(1-s0)*dot(grad(h0),(grad(s0*v))) \
>         + alpha*s0*dot(grad(h0),grad(q)) \
>         + beta*(1-s0)*dot(grad(h0),grad(q)) \
>         )*dx
> 
> A   = assemble(a, mesh)
> rhs = assemble(L, mesh)
> 
> 
> Crashes:
> 
> Traceback (most recent call last):
>   File "sim_error.py", line 57, in <module>
>     rhs = assemble(L, mesh)
>   File
> "/home/skavhaug/extsoft/lib/python2.5/site-packages/dolfin/assemble.py", line
> 49, in assemble
>     coefficients_.push_back(c.f)
>   File "/home/skavhaug/extsoft/lib/python2.5/site-packages/dolfin/dolfin.py",
> line 8456, in push_back
>     return _dolfin.STLVectorFunctionPtr_push_back(*args)
> TypeError: in method 'STLVectorFunctionPtr_push_back', argument 2 of type
> 'std::vector<dolfin::Function * >::value_type'
> 
> 
> Does anyone know what the problem is here? The c.f variable is a ffc_Function,
> so perhaps the assembler doesn't know what to do. Is there a way of sending
> the correct functions (concrete cpp_Functions, for instance) to the assembler?
> 
> Ola
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev


References