← Back to team overview

fenics team mailing list archive

Re: initial function

 

On Fri, Nov 07, 2008 at 10:04:05AM -0800, Chong Luo wrote:
> I'm trying to use Newton's method to solve an elasticity problem (using FEniCS,
> of course). I want to set the initial displacement u to be a given function
> (for example, u0(x,y) = (x, -0.5*y)). How I can initialise the degrees of
> freedom vector x of the displacement u, so that it takes the values of the
> given initial function u0(x,y)? If there is no direct way to do that, maybe my
> question can be reduced to: given a component of the degrees of freedom vector
> x of some discrete function u, how to get the corresponding coordinates in the
> mesh?
> 
> Thank you!
> 
> Best,
> Chong Luo

With the current (stable) version of FEniCS, I'd recommend projecting
or interpolating whatever function you have into the finite element
space. In Python, this can be done simply by

  f = InitialValue(...)
  u0 = project(f, element)
  u0 = interpolate(f, element)

With the current development version, you should be able to just
define u0 as the initial value, and then in subsequent iterations
(when you solve for the degrees of freedom), u0 will automatically
change behavior from being defined by an expression to being defined
by its degrees of freedom.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References