Exemplo n.º 1
0
int main(){
	cout<<"LPM Chai test.."<<endl;

	int nx = 32;
	int ny = 8;
	int tMax = 25000;
	double l0 = 0.8e-6/nx;
	double V0 = -10e-3;

	CollisionD2Q9LPMChai *cm = new CollisionD2Q9LPMChai();
	StreamD2Q9Periodic *sm = new StreamD2Q9Periodic();
	LatticeModel *lm = new Lattice2D(nx, ny);
	UnitHandlerLPM *uh = new UnitHandlerLPM();

	uh->setCharLength(l0);
	uh->setCharVoltage(V0);
	cm->setUnitHandler(uh);
	cm->setW(0.5);
	cm->setC(1.0);

	LBM *lbm = new LBM(lm, cm, sm);

	/* Boundaries */
	HeZouPressureNodes *bds = new HeZouPressureNodes();
	//bds->setCollisionModel(cm);
	for(int i = 0; i < ny; i++){
		bds->addNode(0, i, 0, 1.0/1.8);
		bds->addNode(nx-1, i, 0, 1.0/1.8);
	}
	lbm->addBoundaryNodes(bds);

	//NeumannLPMNodes *iobds = new NeumannLPMNodes();
	//iobds->setCollisionModel(cm);
	for(int j = 0; j < ny; j++){
		//iobds->addNode(0, j, 0.0);
		//iobds->addNode(nx-1, j, 0.0);
	}
	//lbm->addBoundaryNodes(iobds);

	/* Initialize solver */
	lbm->init();

	/* Main loop */
	for(int t = 0; t < tMax; t++){
		cout<<t<<endl;
		lbm->collideAndStream();
		lbm->handleBoundaries();
	}

	//lbm->calcMacroscopicVars();
	cm->dataToFile();
	cout<<"done LPM."<<endl;

	return 0;
}
int main(){
	cout<<"LPM Wang Helmholtz..."<<endl;
	int nx = 101;
	int ny = 101;
	int tMax = 20000;
	double l0 = 1;
	double V0 = 1;
	double lambda = 2.0;
	double dt = 1.0/(nx-1)/(nx-1);
	double dx = 1.0/(nx-1);
	double c = dx/dt;
	double omega = 1.0/(1.5*dt/dx/dx + 0.5);

	cout<<"dx: "<<dx<<", dt: "<<dt<<endl;
	cout<<"OMEGA: "<<omega<<endl;

	CollisionD2Q9WangHelmholtz *cm = new CollisionD2Q9WangHelmholtz();
	UnitHandlerLPM *uh = new UnitHandlerLPM();
	StreamD2Q9Periodic *sm = new StreamD2Q9Periodic();//todo
	LatticeModel *lm = new Lattice2D(nx, ny);
	LBM *lbm = new LBM(lm, cm, sm);

	cm->setW(omega);
	cm->setC(c);
	cm->setUnitHandler(uh);
	cm->setLambda(lambda);
	uh->setCharLength(l0);
	uh->setCharVoltage(V0);
	uh->setTimeStep(dt);

	/* Boundaries */
	double mu = sqrt(lambda*lambda + M_PI*M_PI);

	DirichletLPMNodes<CollisionD2Q9WangHelmholtz> *bds =
				new DirichletLPMNodes<CollisionD2Q9WangHelmholtz>();
	bds->setCollisionModel(cm);
	for(int i = 0; i < nx; i++){
		bds->addNode(i, 0, cos(M_PI/(nx-1)*i));
		cout<<cos(M_PI/(nx-1)*i)<<endl;
		bds->addNode(i, ny-1, 0.0);
	}
	for(int j = 1; j < ny-1; j++){//no redundancy on corners..
		bds->addNode(0, j, YBDR(j));
		bds->addNode(nx-1, j, -YBDR(j));
	}

	lbm->addBoundaryNodes(bds);

	/* Initialize solver */
	lbm->init();

	/* Main loop */
	for(int t = 0; t < tMax; t++){
		cout<<t<<endl;
		lbm->collideAndStream();
		lbm->handleBoundaries();
	}

	cm->dataToFile();
	cout<<"done LPM."<<endl;

	return 0;
}