← Back to team overview

ffc team mailing list archive

Re: inverting constants

 

On Wed, Jan 24, 2007 at 09:02:44AM -0600, Garth N. Wells wrote:
> 
> 
> Anders Logg wrote:
> > On Tue, Jan 23, 2007 at 02:25:55PM -0600, Garth N. Wells wrote:
> >> I used to be able to invert constants in a FFC file, but this now 
> >> returns an error. Has something changed?
> > 
> > Probably so... could you give an example?
> >
> 
> element = FiniteElement("Vector Lagrange", "tetrahedron", 1)
> 
> v = TestFunction(element)  # test function
> U = TrialFunction(element) # trial function
> 
> E  = Constant()
> nu = Constant()
> 
> mu    = E / (2*(1 + nu))
> lmbda = E*nu / ((1 + nu) * (1 - 2*nu))
> 
> def epsilon(v):
>      return 0.5 * (grad(v) + transp(grad(v)))
> 
> def sigma(v):
>      return 2*mu*epsilon(v) + lmbda*mult(trace(epsilon(v)), 
> Identity(len(v)))
> 
> a = dot(grad(v), sigma(U))*dx
> 
> 
> Garth

Aha. I don't think this has ever worked. 1 + nu is a Form (previously
known as Sum) and not a Constant so you can't invert it.

Try the following:

nu = Constant()
mu = 1 + nu

print mu

if isinstance(mu, Form):
    print "It's a Form, not a constant!"

You can do things like

    a = v*u/c*dx

but not

    a = v*u/(1+c)*dx

/Anders


References