Example #1
0
void StableFluid3D::initGrids()
{
	clearGrids();
	velocities = new double***[3];
	tempVelocities = new double***[3];
	for (int d = 0; d < 3; ++d)
	{
		velocities[d] = new double**[resX + xOffset3[d]];
		tempVelocities[d] = new double**[resX + xOffset3[d]];
		for (int i = 0; i < resX + xOffset3[d]; ++i)
		{
			velocities[d][i] = new double*[resY + yOffset3[d]];
			tempVelocities[d][i] = new double*[resY + yOffset3[d]];
			for (int j = 0; j < resY + yOffset3[d]; ++j)
			{
				velocities[d][i][j] = new double[resZ + zOffset3[d]];
				tempVelocities[d][i][j] = new double[resZ + zOffset3[d]];
				for (int k = 0; k<resZ + zOffset3[d]; k++)
				{
					velocities[d][i][j][k] = 0.0;
					tempVelocities[d][i][j][k] = 0.0;
				}
			}
		}
	}
}
Example #2
0
void StableFluid3D::setRes(int resX_, int resY_, int resZ_)
{
	clearGrids();
	resX = resX_;
	resY = resY_;
	resZ = resZ_;
	initGrids();
	initPoisson();
}
Example #3
0
void StableFluid3D::setSize(int width_, int height_, int depth_)
{
	clearGrids();
	width = width_;
	height = height_;
	depth = depth_;
	initGrids();
	initPoisson();
}
Example #4
0
void MarchCube::setRes (int x, int y, int z)
{
	if ((x < 0) || (y < 0) || (z < 0))
		return;

	clearGrids();
	resx = x;
	resy = y;
	resz = z;

	initGrids();
}
Example #5
0
StableFluid3D& StableFluid3D::operator =(const StableFluid3D& toCopy)
{
	viscosity = toCopy.viscosity;
	density = toCopy.density;
	if ((resX != toCopy.resX) || (resY != toCopy.resY) || (resZ != toCopy.resZ))
	{
		clearPoisson();
		resX = toCopy.resX;
		resY = toCopy.resY;
		resZ = toCopy.resZ;
		laplacian = toCopy.laplacian;
		preconditioner = toCopy.preconditioner;

		vel = toCopy.vel;
		r = toCopy.r;
		z = toCopy.z;
	}
	ones = toCopy.ones;
	pressure = toCopy.pressure;
	tempPressure = toCopy.tempPressure;

	if ((width != toCopy.width) || (height != toCopy.height) || (depth != toCopy.depth))
	{
		clearGrids();
		width = toCopy.width;
		height = toCopy.height;
		depth = toCopy.depth;
		initGrids();
	}

	for (int d = 0; d < 3; ++d)
	{
		for (int i = 0; i < resX + xOffset3[d]; ++i)
		{
			for (int j = 0; j < resY + yOffset3[d]; ++j)
			{
				for (int k = 0; k < resZ + zOffset3[d]; ++k)
				{
					tempVelocities[d][i][j][k] = tempVelocities[d][i][j][k];
					velocities[d][i][j][k] = toCopy.velocities[d][i][j][k];
				}
			}
		}
	}
	return *this;
}
Example #6
0
StableFluid3D::~StableFluid3D()
{
	clearGrids();
}
Example #7
0
MarchCube::~MarchCube ()
{
	clearGrids();
}