 
 		const int2 * ANCF_ReferenceArrayNodesOnBeamsD,
 		const real_ * ANCF_Beam_LengthD,
-		const bool * ANCF_IsCantileverD
+		const bool * ANCF_IsCantileverD,
+		uint i
 	)
 {
-	uint i = blockIdx.x * blockDim.x + threadIdx.x;
-	if (i >= numFlexBodiesD) return;
-
 	int2 nodesPortion = ANCF_ReferenceArrayNodesOnBeamsD[i];
 	int numNodes = nodesPortion.y - nodesPortion.x;
 	int numElements = numNodes - 1;


#include <cstdio>

//#####################################################################################
__constant__ ANCF_Params flexParamsD;
__constant__ real_ dTD;
__constant__ int numFlexBodiesD;
__constant__ GaussQuadrature GQD;

//------------------------------------------------------------------------------
__device__ __host__ inline void Zero12(Elem12 & m) {

		const real3 * ANCF_SlopesAccD,

		const int2 * ANCF_ReferenceArrayNodesOnBeamsD,
		const bool * ANCF_IsCantileverD,
		uint i
	)
{
	int2 nodesPortion = ANCF_ReferenceArrayNodesOnBeamsD[i];
	int2 nodesPortionAdjusted2 = nodesPortion;
	bool isCantilever = ANCF_IsCantileverD[i];
