← Back to team overview

ffc team mailing list archive

bug in simplify?

 


Hi,

I think there is a bug in simplify.py. Consider the following simple forms and
their output:


element = VectorElement("Discontinuous Lagrange", "triangle", 0, 4)
v = TestFunction(element)
u = TrialFunction(element)

def Mat(v):
  return [[v[0], v[1]],
          [v[2], v[3]]]

def Sym(v):
  return 0.5*(Mat(v) + transp(Mat(v)))

a = dot(Mat(v), Sym(u))*dx

with simplify:

    // Compute geometry tensors
    const double G0_ = det*(1.0 + 1.0);
    const double G1_ = det;
    const double G2_ = det;
    
    // Compute element tensor
    A[0] = 0.25*G0_;
    A[1] = 0;
    A[2] = 0;
    A[3] = 0;
    A[4] = 0;
    A[5] = 0.25*G0_;
    A[6] = 0.25*G1_;
    A[7] = 0;
    A[8] = 0;
    A[9] = 0.25*G2_;
    A[10] = 0.25*G0_;
    A[11] = 0;
    A[12] = 0;
    A[13] = 0;
    A[14] = 0;
    A[15] = 0.25*G0_;

or [2 0 0 0]
   [0 2 1 0]
   [0 1 2 0]
   [0 0 0 2]

without simplify:

    // Compute geometry tensors
    const double G0_ = det*(1.0 + 1.0);
    const double G1_ = det;
    const double G2_ = det;
    const double G3_ = det;
    const double G4_ = det;
    const double G5_ = det*(1.0 + 1.0);
    
    // Compute element tensor
    A[0] = 0.25*G0_;
    A[1] = 0;
    A[2] = 0;
    A[3] = 0;
    A[4] = 0;
    A[5] = 0.25*G1_;
    A[6] = 0.25*G2_;
    A[7] = 0;
    A[8] = 0;
    A[9] = 0.25*G4_;
    A[10] = 0.25*G3_;
    A[11] = 0;
    A[12] = 0;
    A[13] = 0;
    A[14] = 0;
    A[15] = 0.25*G5_;

or [2 0 0 0]
   [0 1 1 0]
   [0 1 1 0]
   [0 0 0 2]

which I what one would expect. So I think this indicates a bug somewhere...


Kristian


Follow ups