Game Development Reference
In-Depth Information
void assembleK(CSparseMatrix &K, //Stiffness matrix (out)
CTetraArray tList, //Tetrahedron list (in)
CVertexArray vList, //Vertex list (in)
float mu, //Physical parameter (in)
float lambda) //Physical parameter (in)
{ int vSize = vList.size();
int tList = tList.size();
K.resize (3 vSize,3 viSize);
K.loadZero ();
for (tIdx = 0; iIdxt < tSize; tSize++)
{ //pIdx contain the index of the tetrahedron nodes.
int pIdx[4];
pIdx[0]=tList[tIdx].p1Idx;
pIdx[1]=tList[tIdx].p2Idx;
pIdx[2]=tList[tIdx].p3Idx;
pIdx[3]=tList[tIdx].p4Idx;
//Webuilda12by12matrix
CMatrix Ke(12,12);
buildKe(Ke,
vList[pIdx[0]],
vList[pIdx[1]],
vList[pIdx[2]],
vList[pIdx[3]],
mu,lambda);
for (i=0; i
4; i++)
for (j=0; j < 4; j++)
{
<
int orgX,orgY,destX,destY;
destI=pIdX[i] 3;
destJ=vector[j] 3;
for (t=0; t < 3; t++)
for (m=0; m < 3; m++)
K(destI+t,destJ+m)+=Ke(i 3+t,j 3);
}
}
}
Listing 10.4. Building a global matrix K .
Search Nedrilad ::




Custom Search