Ejemplo n.º 1
0
/**
* TODO: Implementar las funcion interpolation
*/
void interpolation(fluid fluido, mesh membrana, int x, int y, int z)
{
	//Recorrer todos los nodos de la malla
	float pos[3], distancia[3], delta, a, A, b, B, c, C, ux=0.0, uy=0.0, uz=0.0;
	int nNodos = membrana.darNumeroNodos();
	for(int u=0;u<nNodos;u++)
	{
		membrana.darPosNodo(u, pos);
		a = pos[0]-3.0;
		A = pos[0]+3.0;
		b = pos[1]-3.0;
		B = pos[1]+3.0;
		c = pos[2]-3.0;
		C = pos[2]+3.0;
		
		for(int i = (int) a;i<A;i++)
			for(int j = (int) b;j<B;j++)
				for(int k=(int) c;k<C;k++)
				{
					distancia[0]=pos[0]-i;
					distancia[1]=pos[1]-j;
					distancia[2]=pos[2]-k;
					delta = dirac_4(distancia);
					ux+=delta*fluido.darVelocidad(i,j,k,0);
					uy+=delta*fluido.darVelocidad(i,j,k,1);
					uz+=delta*fluido.darVelocidad(i,j,k,2);
				}
		membrana.setVelocidad(u,ux,uy,uz);
		ux=0.0;
		uy=0.0;
		uz=0.0;
	}
}
Ejemplo n.º 2
0
void spread(fluid fluido, mesh membrana, int x, int y, int z)
{
	// Recorrer todos los nodos del fluido 
	float pos[3]={0.0,0.0,0.0}, distancia[3]={0.0,0.0,0.0}, delta, df[3]={0.0,0.0,0.0}, fNodo[3]={0.0,0.0,0.0}, ref[3]={0.0,0.0,0.0};
	float a, A, b, B, c, C;
	int nodos = membrana.darNumeroNodos();
	for(int u=0;u<nodos;u++)
	{
		membrana.darPosNodo(u, pos);
		membrana.darFuerzaNodo(u, fNodo);
		a = pos[0]-3.0;
		A = pos[0]+3.0;
		b = pos[1]-3.0;
		B = pos[1]+3.0;
		c = pos[2]-3.0;
		C = pos[2]+3.0;

		for(int i = (int) a;i<A;i++)
			for(int j = (int) b;j<B;j++)
				for(int k=(int) c;k<C;k++)
				{
					distancia[0]=pos[0]-i;
					distancia[1]=pos[1]-j;
					distancia[2]=pos[2]-k;
					delta = dirac_4(distancia);
					df[0]=fNodo[0]*(-1.0)*delta;
					df[1]=fNodo[1]*(-1.0)*delta;
					df[2]=fNodo[2]*(-1.0)*delta;
					fluido.addFuerza(i,j,k,df);
				}
	}
}
Ejemplo n.º 3
0
/**
* TODO: Implementar las funcion spread
*/
void spread(fluid fluido, mesh membrana, int x, int y, int z)
{
	// Recorrer todos los nodos del fluido
	double pos[3]={0.0,0.0,0.0}, distancia[3]={0.0,0.0,0.0}, delta, df[3]={0.0,0.0,0.0}, fNodo[3]={0.0,0.0,0.0};
	double a, A, b, B, c, C;
	int nodos = membrana.darNumeroNodos();
	for(int u=0;u<nodos;u++)
	{
		membrana.darPosNodo(u, pos);
		membrana.darFuerzaNodo(u, fNodo);
		a = pos[0]-3.0;
		A = pos[0]+3.0;
		b = pos[1]-3.0;
		B = pos[1]+3.0;
		c = pos[2]-3.0;
		C = pos[2]+3.0;

		for(int i = (int) a;i<A;i++)
			for(int j = (int) b;j<B;j++)
				for(int k=(int) c;k<C;k++)
				{
					int posj = j;
					distancia[0]=pos[0]-i;
					distancia[1]=pos[1]-j;
					distancia[2]=pos[2]-k;
					delta = dirac_4(distancia);
					df[0]=fNodo[0]*delta;
					df[1]=fNodo[1]*delta;
					df[2]=fNodo[2]*delta;
					if(j<1)
					{
						posj = j+y-1;
					}else if(j>=y)
					{
						posj = j-y;
					}
					fluido.addFuerza(i,posj,k,df);
				}
		df[0] = 0.0;
		df[1] = 0.0;
		df[2] = 0.0;
	}
}