コード例 #1
0
ファイル: smoothingWidget.cpp プロジェクト: bertholet/DDG2011
smoothingWidget::smoothingWidget(QWidget *parent):QWidget(parent)
{
	implicitSmoother = NULL;
	timeStep = 0.001f; 
	smootherTimer = new QTimer(this);
	connect( smootherTimer, SIGNAL(timeout()), this, SLOT(doSmoothing()) );
	implicitSmootherTimer = new QTimer(this);
	connect( implicitSmootherTimer, SIGNAL(timeout()), this, SLOT(doImplicitSmoothing()) );


	QPushButton * smoothButton = new QPushButton("Explicit Smoothing");
	connect(smoothButton,SIGNAL(released()), this, SLOT(startDirectSmoothing()));

	QPushButton * implicitSmoothButton = new QPushButton("Implicit Smoothing");
	connect(implicitSmoothButton,SIGNAL(released()), this, SLOT(startImplicitSmoothing()));
	
	timeLabel = new QLabel("Timestep ()");
	
	timeStepSlider = new QSlider(Qt::Horizontal, this);
	timeStepSlider->setMinimum(1);
	timeStepSlider->setMaximum(1000);
	timeStepSlider->setTickPosition(QSlider::TicksAbove);
	connect(timeStepSlider,SIGNAL(sliderReleased()), this, SLOT(updateTimeStep()));

	QVBoxLayout *layout = new QVBoxLayout();
	layout->addWidget(timeLabel);
	layout->addWidget(timeStepSlider);
	layout->addWidget(smoothButton);
	layout->addWidget(implicitSmoothButton);

	this->setLayout(layout);
}
コード例 #2
0
void OnePipeSimulation::stepping() {
  updateTimeStep();
  pipe.applyReaction();
  pipe.applyAdvection();
  accumulativeFlux += dt_*T0*flux;
  updateFlux();
}
コード例 #3
0
void fluidControlWidget::initSimulation()
{

	this->mySimulation = new fluidSimulation(Model::getModel()->getMeshInfo());
	Model::getModel()->setFluidSim(mySimulation);
	meshMetaInfo & mesh = * Model::getModel()->getMeshInfo();
	dirs.reserve(mesh.getBasicMesh().getFaces().size());
	for(int i = 0; i < mesh.getBasicMesh().getFaces().size(); i++){
		dirs.push_back(tuple3f());
	}

	dirs_cleared = true;
	updateTimeStep();
	updateViscosity();
	
}
コード例 #4
0
void fluidControlWidget::flux2vort2flux()
{

	if(mySimulation == NULL){
		initSimulation();
	}

	//mySimulation->flux2Vorticity();

	updateViscosity();
	updateTimeStep();
	
//	mySimulation->addDiffusion2Vorticity();

	
//	mySimulation->vorticity2Flux();
//	mySimulation->showFlux2Vel();


/*	mesh & m = * Model::getModel()->getMesh();
	float temp = 0;
	for(int i = 0; i < m.getVertices().size(); i++){
		temp += Operator::aVornoi(i,m);
	}
	
	cout << "Overall Area: " << temp << "\n";*/

	meshMetaInfo & mesh = *Model::getModel()->getMeshInfo();
	pardisoMatrix dtstar1 = DDGMatrices::dual_d1(mesh) * DDGMatrices::star1(mesh) + DDGMatrices::dual_d1star1_borderdiff(mesh);
	nullForm harmonicVort(mesh);
	oneForm & flux = mySimulation->getHarmonicFlux();
	oneForm f2v2f(mesh);
	fluidTools::flux2Vorticity(flux, harmonicVort, mesh, dtstar1);

	mySimulation->vorticity2Flux(harmonicVort,f2v2f);
	
	fluidTools::flux2Velocity(f2v2f, debugVectors,mesh);

	Model::getModel()->setVectors(& mySimulation->getDualVertices(),&debugVectors);

}
コード例 #5
0
fluidControlWidget::fluidControlWidget(QWidget *parent)
	: QWidget(parent)
{

	mySimulation = NULL;

	animationTimer = new QTimer(this);
	connect( animationTimer, SIGNAL(timeout()), this, SLOT(doAnimation()) ); 

	//setUp Gui

	QPushButton * but_resetFlux = new QPushButton("Reset Flux!");
	connect(but_resetFlux, SIGNAL(released()), this, SLOT(resetToCollectedFlux()));
	//QPushButton * butt_defForce = new QPushButton("Define Force!");
	//connect(butt_defForce, SIGNAL(released()), this, SLOT(setForceFlux()));
	//QPushButton * butt = new QPushButton("Flux 2 Vorticity 2 Flux!");
	//connect(butt, SIGNAL(released()), this, SLOT(flux2vort2flux()));

	QPushButton * butt_simStep = new QPushButton("Do 1 Timestep");
	connect(butt_simStep, SIGNAL(released()), this, SLOT(singleSimulationStep()));
	QPushButton * butt_startSim = new QPushButton("Start/Stop Simulation");
	connect(butt_startSim , SIGNAL(released()), this, SLOT(startSim()));


	QPushButton * but_borderconstr = new QPushButton("Define Border Constraints");//"Debug (harmonic flow)!");
	connect(but_borderconstr , SIGNAL(released()), this, SLOT(debugSome()));

	QPushButton * debug2 = new QPushButton("Debug (pathtracing/vorts)!");
	connect(debug2 , SIGNAL(released()), this, SLOT(debugSome2()));

	stepSliderLabel = new QLabel("Timestep Size ()");
	viscosityLabel = new QLabel("Viscosity [0,10]");
	forceAgeLabel = new QLabel("ForceAge (nr Iteratons): ");
	forceStrengthLabel = new QLabel("Force Strength (): ");


	stepSlider = new QSlider(Qt::Horizontal, this);
	stepSlider->setMinimum(0);
	stepSlider->setMaximum(1000);
	stepSlider->setTickPosition(QSlider::TicksAbove);
	stepSlider->setValue(0);
	connect(stepSlider,SIGNAL(sliderReleased()), this, SLOT(updateTimeStep()));


	viscositySlider = new QSlider(Qt::Horizontal, this);
	viscositySlider->setMinimum(0);
	viscositySlider->setMaximum(200);
	viscositySlider->setTickPosition(QSlider::TicksAbove);
	viscositySlider->setValue(0);
	connect(viscositySlider,SIGNAL(sliderReleased()), this, SLOT(updateViscosity()));


	forceAgeSlider = new QSlider(Qt::Horizontal, this);
	forceAgeSlider->setMinimum(0);
	forceAgeSlider->setMaximum(100);
	forceAgeSlider->setTickPosition(QSlider::TicksAbove);
	forceAgeSlider->setValue(5);
	connect(forceAgeSlider,SIGNAL(sliderReleased()), this, SLOT(forceAgeChanged()));
	forceAgeChanged();

	forceStrengthSlider = new QSlider(Qt::Horizontal, this);
	forceStrengthSlider->setMinimum(0);
	forceStrengthSlider->setMaximum(480);
	forceStrengthSlider->setTickPosition(QSlider::TicksAbove);
	forceStrengthSlider->setValue(80);
	connect(forceStrengthSlider,SIGNAL(sliderReleased()), this, SLOT(forceStrengthChanged()));
	forceStrengthChanged();


//	viscosityAndTimestep = new QLabel("");
//	updateViscTimeLabel();
	animationLabel = new QLabel("");

	vectorInput = new QLineEdit();
	vectorInput->setText("");
	//vectorInput->setInputMask("#09.00 #09.00 #09.00");
	connect(vectorInput,SIGNAL(textChanged( const QString& )), this, SLOT(borderDirInput(const QString & )));

	//////////////////////////////////////////////////////////////////////////
	//display settings
	//////////////////////////////////////////////////////////////////////////
	QCheckBox * showStreamLines;
	QCheckBox * doInterpolation;
	QCheckBox * showVortNotSpeed;
	QCheckBox * texLine;
	showStreamLines = new QCheckBox();
	showStreamLines->setChecked(false);
	connect(showStreamLines, SIGNAL(stateChanged(int)), this, SLOT(showStreamLn(int)));

	doInterpolation = new QCheckBox();
	doInterpolation->setChecked(true);
	connect(doInterpolation, SIGNAL(stateChanged(int)), this, SLOT(doInterpl(int)));

	showVortNotSpeed = new QCheckBox();
	showVortNotSpeed->setChecked(true);
	connect(showVortNotSpeed, SIGNAL(stateChanged(int)), this, SLOT(showVorticity(int)));

	texLine = new QCheckBox();
	texLine->setChecked(true);
	connect(texLine, SIGNAL(stateChanged(int)), this, SLOT(showTexLines(int)));

	QLabel * streamLinesInterpolationLable = new QLabel("Lines/Interpol/Linelength/Vort/Tex/Color");
	QSpinBox * lineLength = new QSpinBox(this);
	lineLength->setMinimum(1);
	lineLength->setMaximum(50);
	lineLength->setSingleStep(1);
	connect(lineLength, SIGNAL(valueChanged(int)), this, SLOT(streamLineLengthChanged(int)));

	QSpinBox * colorScale = new QSpinBox(this);
	colorScale->setMinimum(1);
	colorScale->setMaximum(100);
	colorScale->setSingleStep(1);
	colorScale->setValue(50);
	connect(colorScale, SIGNAL(valueChanged(int)), this, SLOT(colorScaleChanged(int)));



	QVBoxLayout * layout = new QVBoxLayout();

	layout->addWidget(animationLabel);
	layout->addWidget(vectorInput);
	layout->addWidget(but_borderconstr);
	//layout->addWidget(butt);
	//layout->addWidget(butt_defForce);
	layout->addWidget(butt_startSim);
	layout->addWidget(but_resetFlux);
	layout->addWidget(butt_simStep);

	layout->addWidget(stepSliderLabel);
	layout->addWidget(stepSlider);
	layout->addWidget(viscosityLabel);
	layout->addWidget(viscositySlider);
	layout->addWidget(forceAgeLabel);
	layout->addWidget(forceAgeSlider);
	layout->addWidget(forceStrengthLabel);
	layout->addWidget(forceStrengthSlider);
//	layout->addWidget(viscosityAndTimestep);



	layout->addWidget(streamLinesInterpolationLable);

	QHBoxLayout * hlayout = new QHBoxLayout();
	hlayout->addWidget(showStreamLines);
	hlayout->addWidget(doInterpolation);
	hlayout->addWidget(lineLength);
	hlayout->addWidget(showVortNotSpeed);
	hlayout->addWidget(texLine);
	hlayout->addWidget(colorScale);
	layout->addLayout(hlayout);

	layout->addWidget(debug2);


	QPushButton * dbg1 = new QPushButton("PathTr");
	connect(dbg1 , SIGNAL(released()), this, SLOT(pathtrace()));
	QPushButton * dbg2= new QPushButton("VortPart");
	connect(dbg2 , SIGNAL(released()), this, SLOT(showVorticityPart()));
	QHBoxLayout * hlayout2 = new QHBoxLayout();
	hlayout2->addWidget(dbg1);
	hlayout2->addWidget(dbg2);
	layout->addLayout(hlayout2);

	this->setLayout(layout);

	Model::getModel()->attach(this);


	this->selectedBorder = 0;
	for(int i = 0; i < Model::getModel()->getMeshInfo()->getBorder().size(); i++){
		borderConstrDirs.push_back(tuple3f());
	}

}