Subject: [FEniCS-dev] initial function

From: Chong Luo <[email-masked]>
Date: Fri, 7 Nov 2008 10:04:05 -0800 (PST)

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

---

From: Anders Logg <[email-masked]>
Date: Fri, 7 Nov 2008 19:52:16 +0100

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

---

From: Chong Luo <[email-masked]>
Date: Sat, 8 Nov 2008 09:56:41 -0800 (PST)

I saw that there are similar functions in C++, too. These functions looks very convenient, and are exactly what I want. 

Thank you very much! 

Best,
Chong Luo

________________________________
From: Anders Logg <[email-masked]>
To: [email-masked]
Sent: Friday, November 7, 2008 12:52:16 PM
Subject: Re: [FEniCS-dev] initial function

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

-- 
Anders

---

From: Chong Luo <[email-masked]>
Date: Tue, 11 Nov 2008 19:44:33 -0800 (PST)

My program is implemented in C++, so I'm looking for the equivalent C++ code of your Python code. When I look at dolfin-0.8.1/dolfin/function/ProjectL2.cpp, I found it's not implemented yet:

//-----------------------------------------------------------------------------
void dolfin::projectL2(Mesh& meshB, Function& fA, Function& fB, FiniteElement& element)
{
  error("dolfin::projectL2 is disabled. Will be fixed when new Function is in place.");
  /*
  Form* a = ProjectionLibrary::create_projection_a(element.signature());
  Form* L = ProjectionLibrary::create_projection_L(element.signature(), fA);

  // Compute projection
  // FIXME: LinearPDE should not own memory from fB, allocate on heap for now
  LinearPDE* pde = new LinearPDE(*a, *L, meshB);
  pde->solve(fB);
  */
}

Could you point me a way to do the projection or interpolation in C++?

Thank you.

Best,
Chong Luo

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

-- 
Anders

---

From: Chong Luo <[email-masked]>
Date: Thu, 13 Nov 2008 20:11:41 -0800 (PST)

Maybe I should consider porting my program to Python or wait for the next release.

Best,
Chong Luo

________________________________
From: Chong Luo <[email-masked]>
To: [email-masked]
Sent: Tuesday, November 11, 2008 9:44:33 PM
Subject: Re: [FEniCS-dev] initial function

  // Compute projection

Thank you.

Best,
Chong Luo

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

-- 
Anders

---

From: Anders Logg <[email-masked]>
Date: Fri, 14 Nov 2008 07:58:29 +0100

Take a look at demo/function/eval/cpp which does an interpolation.

-- 
Anders

On Tue, Nov 11, 2008 at 07:44:33PM -0800, Chong Luo wrote:
> My program is implemented in C++, so I'm looking for the equivalent C++ code of
> your Python code. When I look at dolfin-0.8.1/dolfin/function/ProjectL2.cpp, I
> found it's not implemented yet:
> 
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

> _______________________________________________
> FEniCS-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/fenics-dev

---

From: Chong Luo <[email-masked]>
Date: Sun, 16 Nov 2008 21:00:26 -0800 (PST)

Thank you for referring me to this demo. That is exactly what I want.

Best,
Chong Luo

Sent: Friday, November 14, 2008 12:58:29 AM

-- 
Anders