 		const real3 * ANCF_NodesAccD,
 		const real3 * ANCF_SlopesAccD,
 
-		int2 nodesPortionAdjusted,
-		real_ lE) {
+		int2 nodesPortionAdjusted
+		)
+{
 	int numNodesAdjusted = nodesPortionAdjusted.y - nodesPortionAdjusted.x;
 	for (int j = 0; j < numNodesAdjusted; j++) {
 		int nodeIdx = nodesPortionAdjusted.x + j;

		ANCF_SlopesVelD2[nodeIdx] += dTD * ANCF_SlopesAccD[nodeIdx];
	}
}
//------------------------------------------------------------------------------
__device__ __host__ inline void SolveAndIntegrateInTimeKernel(
		real3 * ANCF_NodesD2,
		real3 * ANCF_SlopesD2,
		real3 * ANCF_NodesVelD2,
		real3 * ANCF_SlopesVelD2,

		real3 * ANCF_NodesAccD,
		real3 * ANCF_SlopesAccD,

		real3 * flex_FSI_NodesForcesD1,
		real3 * flex_FSI_NodesForcesD2,
		const real3 * ANCF_NodesVelD,
		const real3 * ANCF_SlopesVelD,

		const int2 * ANCF_ReferenceArrayNodesOnBeamsD,
		const real_ * ANCF_Beam_LengthD,
		const bool * ANCF_IsCantileverD,
		uint i
	)
{
	real_ lBeam = ANCF_Beam_LengthD[i];
	bool isCantilever = ANCF_IsCantileverD[i];
	int2 nodesPortion = ANCF_ReferenceArrayNodesOnBeamsD[i];
	int numNodes = nodesPortion.y - nodesPortion.x;
	int numElements = numNodes - 1;
	real_ lE = lBeam / numElements;
	int2 nodesPortionAdjusted2 = nodesPortion;
	if (isCantilever) {
		nodesPortionAdjusted2.x = nodesPortionAdjusted2.x + 1;
	}
	int numNodesAdjusted;
	numNodesAdjusted = nodesPortionAdjusted2.y - nodesPortionAdjusted2.x;

									//		//ff1
									//		for (int i = 0; i < numNodesAdjusted * 6; i ++) {
									//			printf("%e\n", f[i]);
									//		}
									//		printf("\n\n\n\n\n");

	real_ mult = (1/(flexParamsD.rho * flexParamsD.A * lE));
	min_vec(
			ANCF_NodesAccD,
			ANCF_SlopesAccD,
			flex_FSI_NodesForcesD1,
			flex_FSI_NodesForcesD2,
			mult,
			lE,
			nodesPortion,
			isCantilever);


				//ff1 : the followin commented lines are the real algorithm
	ItegrateInTime(
			ANCF_NodesD2, ANCF_SlopesD2, ANCF_NodesVelD2, ANCF_SlopesVelD2,
			ANCF_NodesVelD, ANCF_SlopesVelD, ANCF_NodesAccD, ANCF_SlopesAccD,
			nodesPortionAdjusted2,
			lE);

//		//ff1: dummy, to check rigid body motion and such
//		RigidBodyRotation(ANCF_NodesD2, ANCF_SlopesD2, ANCF_NodesVelD2, ANCF_SlopesVelD2,
//				nodesPortion,
//				lE, dT);

}
//------------------------------------------------------------------------------
__global__ void CalcElasticForces(
		real3 * flex_FSI_NodesForcesD1,


}
//------------------------------------------------------------------------------
__global__ void SolveForAccD(
		real3 * ANCF_NodesAccD,
		real3 * ANCF_SlopesAccD,

		const real3 * flex_FSI_NodesForcesD1,
		const real3 * flex_FSI_NodesForcesD2,

		const int2 * ANCF_ReferenceArrayNodesOnBeamsD,
		const real_ * ANCF_Beam_LengthD,
		const bool * ANCF_IsCantileverD
	)
{
	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;
	real_ lBeam = ANCF_Beam_LengthD[i];
	real_ lE = lBeam / numElements;
	bool isCantilever = ANCF_IsCantileverD[i];
	real_ mult = (1/(flexParamsD.rho * flexParamsD.A * lE));

	min_vec(
			ANCF_NodesAccD,
			ANCF_SlopesAccD,
			flex_FSI_NodesForcesD1,
			flex_FSI_NodesForcesD2,
			mult,
			lE,
			nodesPortion,
			isCantilever);
}
//------------------------------------------------------------------------------
__global__ void IntegrateInTimeD(
		real3 * ANCF_NodesD2,
		real3 * ANCF_SlopesD2,
		real3 * ANCF_NodesVelD2,
		real3 * ANCF_SlopesVelD2,

		const real3 * ANCF_NodesVelD,
		const real3 * ANCF_SlopesVelD,
		const real3 * ANCF_NodesAccD,
		const real3 * ANCF_SlopesAccD,

		const int2 * ANCF_ReferenceArrayNodesOnBeamsD,
		const bool * ANCF_IsCantileverD
	)
{
	uint i = blockIdx.x * blockDim.x + threadIdx.x;
	if (i >= numFlexBodiesD) return;

	int2 nodesPortion = ANCF_ReferenceArrayNodesOnBeamsD[i];
	int2 nodesPortionAdjusted2 = nodesPortion;
	bool isCantilever = ANCF_IsCantileverD[i];
	if (isCantilever) {
		nodesPortionAdjusted2.x = nodesPortionAdjusted2.x + 1;
	}

	ItegrateInTimeKernel(
		ANCF_NodesD2, ANCF_SlopesD2, ANCF_NodesVelD2, ANCF_SlopesVelD2,
		ANCF_NodesVelD, ANCF_SlopesVelD, ANCF_NodesAccD, ANCF_SlopesAccD,
		nodesPortionAdjusted2);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
