Example #1
0
  static void GenerateMatrix (const FEL & bfel, const MIP & mip,
			      MAT & mat, LocalHeap & lh)
  {
    // must get the right elements, otherwise an exception is thrown.

    const CompoundFiniteElement & cfel = 
      dynamic_cast<const CompoundFiniteElement&> (bfel);

    // a scalar H1 element
    const ScalarFiniteElement<2> & fel_u = 
      dynamic_cast<const ScalarFiniteElement<2>&> (cfel[0]);
    const ScalarFiniteElement<2> & fel_p = 
      dynamic_cast<const ScalarFiniteElement<2>&> (cfel[2]);
    
    int nd_u = fel_u.GetNDof();
    int nd_p = fel_p.GetNDof();
    
    // transformation of derivatives from reference element to general element:
    FlatMatrixFixWidth<2> gradu(nd_u, lh);
    fel_u.CalcMappedDShape (mip, gradu);

    // the shape functions of the pressure
    FlatVector<> vecp(nd_p, lh);
    fel_p.CalcShape (mip.IP(), vecp);

    mat = 0;

    // the first nd_u shape functions belong to u_x, the next nd_u belong to u_y:
    mat.Rows(0,2).Cols(cfel.GetRange(0)) = Trans (gradu);
    mat.Rows(2,4).Cols(cfel.GetRange(1)) = Trans (gradu);

    // ... and finally nd_p shape functions for the pressure:
    mat.Row(4).Range(cfel.GetRange(2)) = vecp;
  }
Example #2
0
  static void GenerateMatrix (const FEL & bfel, const MIP & mip,
			      MAT & mat, LocalHeap & lh)
  {
    const CompoundFiniteElement & cfel = 
      dynamic_cast<const CompoundFiniteElement&> (bfel);
    const ScalarFiniteElement<2> & fel_u = 
      dynamic_cast<const ScalarFiniteElement<2>&> (cfel[0]);
    
    int nd_u = fel_u.GetNDof();

    FlatVector<> vecu(nd_u, lh);
    fel_u.CalcShape (mip.IP(), vecu);

    mat = 0;
    mat.Row(0).Range(cfel.GetRange(0)) = vecu;
    mat.Row(1).Range(cfel.GetRange(1)) = vecu;
  }