 __constant__ int2 portionD;
 __constant__ int flagD;
 __constant__ int numRigidBodiesD;
+__constant__ int numFlexBodiesD;
 __constant__ int startRigidMarkersD;
 __constant__ int startFlexMarkersD;
 __constant__ int numRigid_SphMarkersD;

//		///ff1
//	 	 real_ hh = paramsD.HSML;
//	 	 printf("dist %f \n", length(dist3)/hh);
	posRadD[absMarkerIndex] = beamPointPos + R3(dot(A1, dist3), dot(A2, dist3), dot(A3, dist3));

//	//ask Radu

		posRigid.z += (paramsD.cMax.z - paramsD.cMin.z);
		posRigidD[index] = posRigid;
		return;
	}
}
//--------------------------------------------------------------------------------------------------------------------------------
//applies periodic BC along x, for ridid bodies
__global__ void ApplyPeriodicBoundaryKernel_FlexBodies(real3* ANCF_NodesD, int2* ANCF_ReferenceArrayNodesOnBeamsD) {
	uint index = blockIdx.x * blockDim.x + threadIdx.x;
	if (index >= numFlexBodiesD) {
		return;
	}
	int2 nodesInterval = ANCF_ReferenceArrayNodesOnBeamsD[index];
	bool flagX = true, flagY = true, flagZ = true;
	for (int i = nodesInterval.x; i < nodesInterval.y; i++) {
		real3 nodePos = ANCF_NodesD[i];
		if (nodePos.x <= paramsD.cMax.x && nodePos.x >= paramsD.cMin.x) flagX = false;
		if (nodePos.y <= paramsD.cMax.y && nodePos.y >= paramsD.cMin.y) flagY = false;
		if (nodePos.z <= paramsD.cMax.z && nodePos.z >= paramsD.cMin.z) flagZ = false;
	}
	for (int i = nodesInterval.x; i < nodesInterval.y; i++) {
		real3 nodePos = ANCF_NodesD[i];
		if (flagX) nodePos.x = fmod(nodePos.x - paramsD.cMin.x, paramsD.boxDims.x) + paramsD.cMin.x;
		if (flagY) nodePos.y = fmod(nodePos.y - paramsD.cMin.y, paramsD.boxDims.y) + paramsD.cMin.y;
		if (flagZ) nodePos.z = fmod(nodePos.z - paramsD.cMin.z, paramsD.boxDims.z) + paramsD.cMin.z;
	}
}
//--------------------------------------------------------------------------------------------------------------------------------
