def DiffuseBlobs(vortexBlobs, time, boundary):
	lambdaLen = abs((boundary[2]-boundary[1]))

	mu = 1.12*1*2/1000
	sigma = sqrt(2*mu*time)
	numOfVortexBlobs = len(vortexBlobs)
	
	numOfDaughterBlobs = [0 for i in range(numOfVortexBlobs)]

	gammaMax = 0.1*lambdaLen

	for i in range(numOfVortexBlobs):
		temp = abs(vortexBlobs[i].strength)/gammaMax
		numOfDaughterBlobs[i] = int(floor(temp)) + 1

	newNumDaughterBlobs = int(sum(numOfDaughterBlobs) - numOfVortexBlobs)	
	daughterBlobs = [FluidElement() for i in range(newNumDaughterBlobs)]
	
	count = 0

	for i in range(numOfVortexBlobs):
		try:
			x = random.normal(0, sigma, numOfDaughterBlobs[i])
			y = random.normal(0, sigma, numOfDaughterBlobs[i])*1.0j
		except:
			x = 0
			y = 0

#		print vortexBlobs[i].strength
		if(vortexBlobs[i].strength>0):
			vortexBlobs[i].strength = vortexBlobs[i].strength - gammaMax*(numOfDaughterBlobs[i]-1)
			flag = 1
		else:
			vortexBlobs[i].strength = vortexBlobs[i].strength + gammaMax*(numOfDaughterBlobs[i]-1)
			flag = 0
#		print vortexBlobs[i].strength
#		print type(numOfDaughterBlobs[i])
		for j in range(numOfDaughterBlobs[i]-1): 
			locationTemp = vortexBlobs[i].xy + x[j] + y[j]
			locationTemp = CheckReflection(boundary[i], boundary[i+1], locationTemp)
			daughterBlobs[count] = Vortex(locationTemp)
			if flag == 1:
				daughterBlobs[count].strength = gammaMax
			else:
				daughterBlobs[count].strength = -gammaMax

			daughterBlobs[count].delta = vortexBlobs[i].delta
			count = count + 1
			

	vortexBlobs = append(vortexBlobs, daughterBlobs)

	return vortexBlobs
def NoSlipCondition(Boundary, controlPoints, dt):
	dim = len(controlPoints)
	
	lambdaLen = abs(Boundary[2]-Boundary[1])	
	deltaVal = lambdaLen/pi
	vortexBlob = [FluidElement() for i in range(dim)]
	for i in range(dim):
		vslip = (controlPoints[i].updatexy - controlPoints[i].lastpos)/dt
		mp = (Boundary[i+1] + Boundary[i])/2
		er = (Boundary[i+1] - Boundary[i])
		en = (er)/abs(er)
		gamma = (vslip.real*en.real + vslip.imag*en.imag)*lambdaLen
		vortexBlob[i] = Vortex(mp*(abs(mp)+deltaVal)/abs(mp))
		vortexBlob[i].strength = gamma
		vortexBlob[i].delta = deltaVal
	return vortexBlob