I am developing an unstructured FEM solver on tet meshes. I mainly intend to use the tet10 elements. I am however having a problem in my assembly.  I have read a sufficient amount of literature and could not find out the implementation details.For example in http://ccecka.com/resources/Papers/FEM_GPU_Gems_Chapter.pdf page 3 Algorithm 1, the Location matrix L is used for the assembly which needs to be determined. I just have the connectivity matrix E and do not know how to proceed to get L.  A snippet of the code for the assembly is given below (taken for J N Reddy). I also believe that storing matrix L for every element is not computationally feasible. Is there a work around?I am also open to share my full code in c++  written for a simple cantilever beam where it has worked.  // KGl: Global stffness matrix// BFGL:  Global force Vector// KelemMat: Element stiffness matrix // SurfaceForce:Element surface force vector// BodyForce: Element body force vector// npe: number of points per element// ndf:Degreed of freedom per node for(int m=0;m<npe;m++) {   int nr=(Element[i].node[m])*ndf;    for(int ii=0;ii<ndf;ii++)    {     nr+=1;     int l =m*ndf+ii;     BFGl(nr-1) += BodyForce(l)+SurfaceForce(l);       for(int p=0;p<npe;p++)         {          int ncl=(Element[i].node[p])*ndf;           for(int kk=0;kk<ndf;kk++)            {             int q=p*ndf+kk;             ncl+=1;             KGl(nr-1,ncl-1)=KGl(nr-1,ncl-1)+KelemMat(l,q);            }       }    } }I have  used the Eigen library to represent the Matrix KelemMat, KGl, ... etc hence the notation. Main problem is that the above works for some problems example a 1d mesh, linear tets but fails for quad tets where I get an overflow error.
FEM assembly on unstructured meshes
finite element;assembly