Subject: [FEniCS-users] bug in extracting sub functions?

From: Chong Luo <[email-masked]>
Date: Thu, 8 Oct 2009 10:31:48 -0700 (PDT)

I defined a function u which belongs to a three-fold mixed finite element space. Its definition in the form file is:

        vector = VectorElement("Lagrange", "triangle", 2)
        scalar = FiniteElement("Lagrange", "triangle", 1)
        Nh = VectorElement("Lagrange", "triangle", 1)
        mixed = vector+Nh+scalar+scalar
        v = TestFunction(mixed)
        u = TrialFunction(mixed)

Basically, u is a combination of 4 functions: dsp+ort+pr+lam.

After I solved for u, I tried to extract each component of function u. So I used the following code in my main.cpp:
          layer1 = u[0];   // dsp+ort+pr
          lam = u[1];   //lam
          layer2=layer1[0];   //dsp+ort
          pr = layer1[1];   //pr
          dsp = layer2[0];   //dsp
          ort = layer2[1];   //ort

However, I found that only the function "lam" was extracted correctly. The other three were not. 
For example, I printed out the first 30 elements of u.vector(), and they are non-zero. However,
the first 30 elements of dsp.vector() are identically zero. But they should be the same.

Since the same code worked well in dolfin-0.9.2, but not in dolfin-0.9.3, I am confused.

Is this a bug?

Thank you!

Best,
Chong

---

From: Andy Ray Terrel <[email-masked]>
Date: Thu, 8 Oct 2009 13:08:06 -0500

On Thu, Oct 8, 2009 at 12:31 PM, Chong Luo <[email-masked]> wrote:
> I defined a function u which belongs to a three-fold mixed finite element
> space. Its definition in the form file is:
>

Try:

  mixed =  MixedElement([vector, Nh, scalar, scalar])

Then:

  dsp = u[0];
  ort = u[1];
  pr = u[2];
  lam = u[3];

Then at least indexing is clearer.

-- Andy

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

---

From: Chong Luo <[email-masked]>
Date: Fri, 9 Oct 2009 13:11:50 -0700 (PDT)

Great! That solves the problem!

Thank you!

Best,
Chong

________________________________
From: Andy Ray Terrel <[email-masked]>
To: [email-masked]
Sent: Thu, October 8, 2009 1:08:06 PM
Subject: Re: [FEniCS-users] bug in extracting sub functions?

Try:

Then:

  dsp = u[0];
  ort = u[1];
  pr = u[2];
  lam = u[3];

-- Andy