← Back to team overview

dolfin team mailing list archive

Re: Updated elasticity: [...]

 

Check if it works now. I've tested with the following example:

    element = FiniteElement("Vector Lagrange", "triangle", 1)

    v = BasisFunction(element)
    u = BasisFunction(element)

    c = Constant()

    epsilon = grad(u) + transp(grad(u))
    tmp = c * epsilon
    L = tmp[0][0] * dx

Note that tmp is a matrix so you need to pick one component for the
integral.

/Anders

On Fri, Sep 16, 2005 at 02:59:39PM +0200, Johan Jansson wrote:
> On Thu, Sep 15, 2005 at 08:52:04PM -0500, Anders Logg wrote:
> > I just added it. Can you try and see if it works? I've implemented
> > component-wise multiplication of scalar basis functions, functions and
> > constants with vectors (Python built-in list). It was just two lines
> > added to algebra.py:
> > 
> > if isinstance(other, list) and self.rank() == 0:
> >     return [self*v for v in other]
> > 
> > Is this enough, or are you using Numeric.array for something so I
> > should add that too? The new operators assume Python list.
> > 
> > /Anders
> > 
> 
> It works for vectors (which are represented by Python list), but as
> you guessed, it doesn't work for Numeric.array objects. This matrix
> becomes a Numeric.array:
> 
> epsilon = grad(u) + trans(grad(u))
> 
> I guess it should work to just add this too?:
> 
> if isinstance(other, Numeric.array) and self.rank() == 0:
>     return [mult(self, v) for v in other]
> 
> except it doesn't work:
> 
> TypeError: isinstance() arg 2 must be a class, type, or tuple of
> classes and types
> 
> I think Numeric.array is also the name of a function, I can't figure
> out how to specify the type name.
> 
> Well, it's not so critical, mult() works just as well for now.
> 
> Here's the test case I used:
> 
> element = FiniteElement("Vector Lagrange", "triangle", 1)
> 
> v = BasisFunction(element)
> u = BasisFunction(element)
> 
> c = Constant()
> epsilon = grad(u) + transp(grad(u))
> tmp = c * epsilon
> L = tmp * dx
> 
>   Johan
> 
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/cgi-bin/mailman/listinfo/dolfin-dev
> 

-- 
Anders Logg
Research Assistant Professor
Toyota Technological Institute at Chicago
http://www.tti-c.org/logg/



References