当前位置: 首页>>代码示例>>C++>>正文


C++ FluidSystem类代码示例

本文整理汇总了C++中FluidSystem的典型用法代码示例。如果您正苦于以下问题:C++ FluidSystem类的具体用法?C++ FluidSystem怎么用?C++ FluidSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FluidSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

    void BlackoilCo2PVT::computeState(BlackoilCo2PVT::SubState& ss, double zBrine, double zCO2, double pressure) const
    {
               
        CompositionalFluidState state;     
        state.setTemperature(temperature_);
        state.setPressure(wPhase, pressure);
        state.setPressure(nPhase, pressure);
        
        double massH20 = surfaceDensities_[Oil]*zBrine;
        double massCO2 = surfaceDensities_[Gas]*zCO2;
        
        // A priori, assume presence of both phases
        brineCo2_.computeEquilibrium(state); 
        ss.density[wPhase] = state.density(wPhase);
        ss.density[nPhase] = state.density(nPhase);
        ss.massfrac[wPhase][nComp] = state.massFraction(wPhase, nComp);
        ss.massfrac[nPhase][wComp] = state.massFraction(nPhase, wComp);
        ss.massfrac[wPhase][wComp] = 1.0 - ss.massfrac[wPhase][nComp];
        ss.massfrac[nPhase][nComp] = 1.0 - ss.massfrac[nPhase][wComp];

        double detX = ss.massfrac[wPhase][wComp]*ss.massfrac[nPhase][nComp]-ss.massfrac[wPhase][nComp]*ss.massfrac[nPhase][wComp];
        ss.phaseVolume[wPhase] = (massH20*ss.massfrac[nPhase][nComp] - massCO2*ss.massfrac[nPhase][wComp])/(ss.density[wPhase]*detX);
        ss.phaseVolume[nPhase] = (massCO2*ss.massfrac[wPhase][wComp] - massH20*ss.massfrac[wPhase][nComp])/(ss.density[nPhase]*detX);
        
        // Determine number of phase
        if (ss.phaseVolume[wPhase] > 0.0 && ss.phaseVolume[nPhase] > 0.0) { // Both phases
            ss.saturation = ss.phaseVolume[wPhase]/(ss.phaseVolume[wPhase]+ss.phaseVolume[nPhase]);
            state.setSaturation(wPhase, ss.saturation);
            state.setSaturation(nPhase, 1.0 - ss.saturation);
        }
        else if (ss.phaseVolume[wPhase] <= 0.0) { // Wetting phase only
            ss.saturation = 0.0;
            // Gas phase:
            ss.massfrac[nPhase][nComp] = massCO2/(massCO2+massH20);
            ss.massfrac[nPhase][wComp] = 1.0 - ss.massfrac[nPhase][nComp];
            double M1 = FluidSystem::molarMass(wComp);
            double M2 = FluidSystem::molarMass(nComp);
            double avgMolarMass = M1*M2/(M2 + ss.massfrac[nPhase][nComp]*(M1 - M2));
            state.setMoleFraction(nPhase, nComp, ss.massfrac[nPhase][nComp]*avgMolarMass/M2);
            state.setMoleFraction(nPhase, wComp, ss.massfrac[nPhase][wComp]*avgMolarMass/M1);
            ss.density[nPhase] = brineCo2_.phaseDensity(nPhase, state.temperature(nPhase), state.pressure(nPhase), state);
            state.setDensity(nPhase, ss.density[nPhase]);
            ss.phaseVolume[nPhase] = (massH20+massCO2)/ss.density[nPhase];
            state.setSaturation(nPhase, 1.0 - ss.saturation);
            // Virtual properties of non-existing liquid phase:
            brineCo2_.computeEquilibrium(state, nPhase);
            ss.massfrac[wPhase][wComp] = state.massFraction(wPhase, wComp);
            ss.massfrac[wPhase][nComp] = state.massFraction(wPhase, nComp);
            ss.density[wPhase] = state.density(wPhase);
            ss.phaseVolume[wPhase] = 0.0;
            state.setSaturation(wPhase, ss.saturation);
        }
        else if (ss.phaseVolume[nPhase] <= 0.0) { // Non-wetting phase only
            ss.saturation = 1.0;
            // Liquid phase:
            ss.massfrac[wPhase][wComp] = massH20/(massCO2+massH20);
            ss.massfrac[wPhase][nComp] = 1.0 - ss.massfrac[wPhase][wComp];
            double M1 = FluidSystem::molarMass(wComp);
            double M2 = FluidSystem::molarMass(nComp);
            double avgMolarMass = M1*M2/(M2 + ss.massfrac[wPhase][nComp]*(M1 - M2));
            state.setMoleFraction(wPhase, nComp, ss.massfrac[wPhase][nComp]*avgMolarMass/M2);
            state.setMoleFraction(wPhase, wComp, ss.massfrac[wPhase][wComp]*avgMolarMass/M1);
            ss.density[wPhase] = brineCo2_.phaseDensity(wPhase, state.temperature(wPhase), state.pressure(wPhase), state);
            state.setDensity(wPhase, ss.density[wPhase]);
            ss.phaseVolume[wPhase] = (massH20+massCO2)/ss.density[wPhase];
            state.setSaturation(wPhase, ss.saturation);
            // Virtual properties of non-existing gas phase:
            brineCo2_.computeEquilibrium(state, wPhase);
            ss.massfrac[nPhase][nComp] = state.massFraction(nPhase, nComp);
            ss.massfrac[nPhase][wComp] = state.massFraction(nPhase, wComp);
            ss.density[nPhase] = state.density(nPhase);
            ss.phaseVolume[nPhase] = 0.0;
            state.setSaturation(nPhase, 1.0 - ss.saturation);
        } 
        
        ss.phaseViscosity[wPhase] = brineCo2_.phaseViscosity(wPhase, temperature_, pressure, state);
        ss.phaseViscosity[nPhase] = brineCo2_.phaseViscosity(nPhase, temperature_, pressure, state);        

    }
开发者ID:laods,项目名称:opm-porsol,代码行数:79,代码来源:BlackoilCo2PVT.hpp

示例2: if

void BlackoilCo2PVT::computeState(BlackoilCo2PVT::SubState& ss, double zBrine, double zCO2, double pressure) const
{
               
    CompositionalFluidState fluidState;     
    fluidState.setTemperature(temperature_);
    fluidState.setPressure(wPhase, pressure);
    fluidState.setPressure(nPhase, pressure);
        
    double massH20 = surfaceDensities_[Oil]*zBrine;
    double massCO2 = surfaceDensities_[Gas]*zCO2;
        
    // A priori, assume presence of both phases
    FluidSystem::ParameterCache<double> paramCache;
    typedef Opm::MiscibleMultiPhaseComposition</*Scalar=*/double, FluidSystem> MMPC;
    MMPC::solve(fluidState, paramCache, /*setViscosity=*/false, /*setEnthalpy=*/false);
    ss.density[wPhase] = fluidState.density(wPhase);
    ss.density[nPhase] = fluidState.density(nPhase);
    ss.massfrac[wPhase][nComp] = fluidState.massFraction(wPhase, nComp);
    ss.massfrac[nPhase][wComp] = fluidState.massFraction(nPhase, wComp);
    ss.massfrac[wPhase][wComp] = 1.0 - ss.massfrac[wPhase][nComp];
    ss.massfrac[nPhase][nComp] = 1.0 - ss.massfrac[nPhase][wComp];

    double detX = ss.massfrac[wPhase][wComp]*ss.massfrac[nPhase][nComp]-ss.massfrac[wPhase][nComp]*ss.massfrac[nPhase][wComp];
    ss.phaseVolume[wPhase] = (massH20*ss.massfrac[nPhase][nComp] - massCO2*ss.massfrac[nPhase][wComp])/(ss.density[wPhase]*detX);
    ss.phaseVolume[nPhase] = (massCO2*ss.massfrac[wPhase][wComp] - massH20*ss.massfrac[wPhase][nComp])/(ss.density[nPhase]*detX);
        
    // Determine number of phase
    if (ss.phaseVolume[wPhase] > 0.0 && ss.phaseVolume[nPhase] > 0.0) { // Both phases
        ss.saturation = ss.phaseVolume[wPhase]/(ss.phaseVolume[wPhase]+ss.phaseVolume[nPhase]);
        fluidState.setSaturation(wPhase, ss.saturation);
        fluidState.setSaturation(nPhase, 1.0 - ss.saturation);
    }
    else if (ss.phaseVolume[wPhase] <= 0.0) { // Wetting phase only
        ss.saturation = 0.0;
        // Gas phase:
        ss.massfrac[nPhase][nComp] = massCO2/(massCO2+massH20);
        ss.massfrac[nPhase][wComp] = 1.0 - ss.massfrac[nPhase][nComp];
        double M1 = FluidSystem::molarMass(wComp);
        double M2 = FluidSystem::molarMass(nComp);
        double avgMolarMass = M1*M2/(M2 + ss.massfrac[nPhase][nComp]*(M1 - M2));
        fluidState.setMoleFraction(nPhase, nComp, ss.massfrac[nPhase][nComp]*avgMolarMass/M2);
        fluidState.setMoleFraction(nPhase, wComp, ss.massfrac[nPhase][wComp]*avgMolarMass/M1);
        ss.density[nPhase] = brineCo2_.density(fluidState, paramCache, nPhase);
        fluidState.setDensity(nPhase, ss.density[nPhase]);
        ss.phaseVolume[nPhase] = (massH20+massCO2)/ss.density[nPhase];
        fluidState.setSaturation(nPhase, 1.0 - ss.saturation);
        // Virtual properties of non-existing liquid phase:
        paramCache.updatePhase(fluidState, /*phaseIdx=*/nPhase);
        typedef Opm::ComputeFromReferencePhase</*Scalar=*/double, FluidSystem> CFRP;
        CFRP::solve(fluidState,
                    paramCache,
                    /*refPhaseIdx=*/nPhase,
                    /*setViscosity=*/false,
                    /*setEnthalpy=*/false);
        ss.massfrac[wPhase][wComp] = fluidState.massFraction(wPhase, wComp);
        ss.massfrac[wPhase][nComp] = fluidState.massFraction(wPhase, nComp);
        ss.density[wPhase] = fluidState.density(wPhase);
        ss.phaseVolume[wPhase] = 0.0;
        fluidState.setSaturation(wPhase, ss.saturation);
    }
    else if (ss.phaseVolume[nPhase] <= 0.0) { // Non-wetting phase only
        ss.saturation = 1.0;
        // Liquid phase:
        ss.massfrac[wPhase][wComp] = massH20/(massCO2+massH20);
        ss.massfrac[wPhase][nComp] = 1.0 - ss.massfrac[wPhase][wComp];
        double M1 = FluidSystem::molarMass(wComp);
        double M2 = FluidSystem::molarMass(nComp);
        double avgMolarMass = M1*M2/(M2 + ss.massfrac[wPhase][nComp]*(M1 - M2));
        fluidState.setMoleFraction(wPhase, nComp, ss.massfrac[wPhase][nComp]*avgMolarMass/M2);
        fluidState.setMoleFraction(wPhase, wComp, ss.massfrac[wPhase][wComp]*avgMolarMass/M1);
        ss.density[wPhase] = brineCo2_.density(fluidState, paramCache, wPhase);
        fluidState.setDensity(wPhase, ss.density[wPhase]);
        ss.phaseVolume[wPhase] = (massH20+massCO2)/ss.density[wPhase];
        fluidState.setSaturation(wPhase, ss.saturation);
        // Virtual properties of non-existing gas phase:
        paramCache.updatePhase(fluidState, /*phaseIdx=*/nPhase);
        typedef ComputeFromReferencePhase</*Scalar=*/double, FluidSystem> CFRP;
        CFRP::solve(fluidState,
                    paramCache,
                    /*refPhaseIdx=*/wPhase,
                    /*setViscosity=*/false,
                    /*setEnthalpy=*/false);
        ss.massfrac[nPhase][nComp] = fluidState.massFraction(nPhase, nComp);
        ss.massfrac[nPhase][wComp] = fluidState.massFraction(nPhase, wComp);
        ss.density[nPhase] = fluidState.density(nPhase);
        ss.phaseVolume[nPhase] = 0.0;
        fluidState.setSaturation(nPhase, 1.0 - ss.saturation);
    } 
        
    ss.phaseViscosity[wPhase] = brineCo2_.viscosity(fluidState, paramCache, wPhase);
    ss.phaseViscosity[nPhase] = brineCo2_.viscosity(fluidState, paramCache, nPhase);

}
开发者ID:,项目名称:,代码行数:93,代码来源:

示例3: init

void init ()
{
	
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);	
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);	

	srand ( time ( 0x0 ) );

	glClearColor( 0.49, 0.49, 0.49, 1.0 );
	glShadeModel( GL_SMOOTH );

	glEnable ( GL_COLOR_MATERIAL );
	glEnable (GL_DEPTH_TEST);  
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
	glDepthMask ( 1 );
	glEnable ( GL_TEXTURE_2D );

	// callbacks
	glutDisplayFunc( display );
	glutReshapeFunc( reshape );
	glutKeyboardFunc( keyboard_func );
	glutMouseFunc( mouse_click_func );  
	glutMotionFunc( mouse_move_func );
	glutIdleFunc( idle_func );
	glutSetCursor ( GLUT_CURSOR_NONE );

	cam_angs.x = 29;		cam_angs.y = 75;		cam_angs.z = 80.0;
	cam_to.x = 0;		cam_to.y = 0;		cam_to.z = 5;
	cam_fov = 35.0;

	light[0].x = 39;		light[0].y = -60;	light[0].z = 43;
	light_to[0].x = 0;	light_to[0].y = 0;	light_to[0].z = 0;

	light[1].x = 15;		light[1].y = -5;	light[1].z = 145;	
	light_to[1].x = 0;	light_to[1].y = 0;	light_to[1].z = 0;  

	light_fov = 45;

	#ifdef USE_SHADOWS
		createShadowTextures();
		createFrameBuffer ();
		setShadowLight ( light[0].x, light[0].y, light[0].z, light_to[0].x, light_to[0].y, light_to[0].z, light_fov );
		setShadowLightColor ( .7, .7, .7, 0.2, 0.2, 0.2 );		
	#endif

	obj_from.x = 0;		obj_from.y = 0;		obj_from.z = 20;		// emitter
	obj_angs.x = 118.7;	obj_angs.y = 200;	obj_angs.z = 1.0;
	obj_dang.x = 1;	obj_dang.y = 1;		obj_dang.z = 0;

	psys.Initialize ( BFLUID, psys_nmax );
	psys.SPH_CreateExample ( 0, psys_nmax );
	psys.SetVec ( EMIT_ANG, Vector3DF ( obj_angs.x, obj_angs.y, obj_angs.z ) );
	psys.SetVec ( EMIT_POS, Vector3DF ( obj_from.x, obj_from.y, obj_from.z ) );

	psys.SetParam ( PNT_DRAWMODE, int(bPntDraw ? 1:0) );
	psys.SetParam ( CLR_MODE, iClrMode );	
}
开发者ID:macsyums92,项目名称:screen-space-fluid-rendering,代码行数:58,代码来源:main.cpp

示例4: init

void init ()
{
	srand ( time ( 0x0 ) );
	
  obj_from.x = 0;		obj_from.y = 0;		obj_from.z = 20;		// emitter
	obj_angs.x = 118.7;	obj_angs.y = 200;	obj_angs.z = 1.0;

	psys.Initialize ( BFLUID, psys_nmax );
	psys.SPH_CreateExample ( 0, psys_nmax );
	psys.SetVec ( EMIT_ANG, Vector3DF ( obj_angs.x, obj_angs.y, obj_angs.z ) );
	psys.SetVec ( EMIT_POS, Vector3DF ( obj_from.x, obj_from.y, obj_from.z ) );

	psys.SetParam ( PNT_DRAWMODE, int(bPntDraw ? 1:0) );
	psys.SetParam ( CLR_MODE, iClrMode );	
}
开发者ID:tikwid,项目名称:jsfluid,代码行数:15,代码来源:jsfluid.cpp

示例5: addForce

void WaterSimulationApp::addForce(float dt )
{

	float length= randomForce.length();
	Vec3f pos1=randomForceX+randomForce;
	Vec3f x = Vec3f::zero();
	if(length<1e-6)return;
	int num =(int)(length/fluidsys->cellDim.x+1);
	for(int i=0;i<num;i++){
		x=randomForceX.lerp((float)i/length,pos1);
		fluidsys->addSource(x,dt,fluidsys->u0,randomForce.x);
		fluidsys->addSource(x,dt,fluidsys->v0,randomForce.y);
		fluidsys->addSource(x,dt,fluidsys->w0,randomForce.z);
	}
	randomForce.zero();
}
开发者ID:myartings,项目名称:WaterSimulation,代码行数:16,代码来源:WaterSimulationApp.cpp

示例6: draw

void WaterSimulationApp::draw(){

	gl::clear( Color( 0.11f, 0.13f, 0.1f ) );
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	mParams->draw();

	gl::setMatrices(mMayaCam.getCamera());
	if(mDrawBox){
		glColor4f(0.2, 0.4, 0.5, 1);//orange
		gl::drawStrokedCube(boxCenter,boxDimension);
	}
	if(mDrawGravity){
		glColor4f(1.0f,0.3f,0.0f,0.5f);//red
		if(mDrawGravity)glColor4f(0.0f,1.0f,0.5f,1);//green
		gl::drawVector(boxCenter,(boxCenter-gravity),3.0f,1.0f);
	}

	//draw random force
	if(mDrawForce){
		if(randomForce.lengthSquared()!=0){
			glColor4f(1.0f,0.0f,0.0f,1);
			gl::drawVector(randomForceX,randomForce+randomForceX,1.0f,0.5f);
		}
	}

	fluidsys->draw();

}
开发者ID:myartings,项目名称:WaterSimulation,代码行数:29,代码来源:WaterSimulationApp.cpp

示例7: display

void display () 
{
	mint::Time start, stop;	

//	iso = sin(frame*0.01f );
	
	// Do simulation!
	if ( !bPause ) psys.Run ();

	frame++;
	measureFPS ();

	glEnable ( GL_DEPTH_TEST );

	// Render depth map shadows
	start.SetSystemTime ( ACC_NSEC );
	disableShadows ();
	#ifdef USE_SHADOWS
		if ( iShade==1 ) {
			renderDepthMap_FrameBuffer ( 0, window_width, window_height );
		} else {
			renderDepthMap_Clear ( window_width, window_height );		
		}
	#endif	

	// Clear frame buffer
	if ( iShade<=1 ) 	glClearColor( 0.29, 0.29, 0.29, 1.0 );
	else				glClearColor ( 0, 0, 0, 0 );
	glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	glDisable ( GL_CULL_FACE );
	glShadeModel ( GL_SMOOTH );

	// Compute camera view
	computeFromPositions ();
	computeProjection ();
	computeView ();		

	// Draw Shadows (if on)
	#ifdef USE_SHADOWS	
		if ( iShade==1 )	renderShadows ( view_matrix );			
	#endif

	// Draw 3D	
	start.SetSystemTime ( ACC_NSEC );
	glEnable ( GL_LIGHTING );  
	glLoadMatrixf ( view_matrix );	
	drawScene ( view_matrix, true );
	if ( bTiming) { stop.SetSystemTime ( ACC_NSEC ); stop = stop - start; printf ( "SCENE: %s\n", stop.GetReadableTime().c_str() ); }

	// Draw 2D overlay
	draw2D ();
 
	// Swap buffers
	glutSwapBuffers();  
	glutPostRedisplay();
}
开发者ID:macsyums92,项目名称:screen-space-fluid-rendering,代码行数:56,代码来源:main.cpp

示例8:

void BlackoilCo2PVT::init(const Opm::Deck& /* deck */)
{
	surfaceDensities_[Water]   = 1000.;
	surfaceDensities_[Gas] = 2.0;
	surfaceDensities_[Oil] = 1000.;

    temperature_ = 300.;

    brineCo2_.init();
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例9:

    void BlackoilCo2PVT::init(const Opm::EclipseGridParser& ep)
    {
	surfaceDensities_[Water]   = 1000.;
	surfaceDensities_[Gas] = 2.0;
	surfaceDensities_[Oil] = 1000.;

        temperature_ = 300.;

        brineCo2_.init();
    }
开发者ID:laods,项目名称:opm-porsol,代码行数:10,代码来源:BlackoilCo2PVT.hpp

示例10: update

void WaterSimulationApp::update(){
	////change status
	float dt = 1.f/60.0f;
	if(mAnimate){
		if(randomForce.lengthSquared()>0 && mAddNewForce) addForce(dt);
		fluidsys->step(dt);
		mParams->setOptions("status","label=`In animation:`");
	}else{
		mParams->setOptions("status","label=`Idle:`");
	}
}
开发者ID:myartings,项目名称:WaterSimulation,代码行数:11,代码来源:WaterSimulationApp.cpp

示例11: drawScene

void drawScene ( float* viewmat, bool bShade )
{
	if ( iShade <= 1 && bShade ) {		
		glEnable ( GL_LIGHT0 );
		GLfloat diff[4];
		GLfloat spec[4];
		GLfloat shininess = 60.0;
		
		diff[0] = 0.8f; diff[1] = 0.8f; diff[2] = 0.8f; diff[3] = 1.0f;
		spec[0] = 1.0f; spec[1] = 1.0f; spec[2] = 1.0f; spec[3] = 1.0f;
		glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, &diff[0]);
		glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, &spec[0]);
		glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, &shininess);		
		glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );

		glColor3f ( 1, 1, 1 );
		glLoadMatrixf ( viewmat );
		glBegin ( GL_QUADS );
		glNormal3f ( 0, 0, 1 );
		glVertex3f ( -1000, -1000, 0.0 );
		glVertex3f ( 1000, -1000, 0.0 );
		glVertex3f ( 1000, 1000, 0.0 );
		glVertex3f ( -1000, 1000, 0.0 );
		glEnd ();
		glBegin ( GL_LINES );
		for (float n=-100; n <= 100; n += 20.0 ) {
			glVertex3f ( -100, n, 0.1 );
			glVertex3f ( 100, n, 0.1 );
			glVertex3f ( n, -100, 0.1 );
			glVertex3f ( n,  100, 0.1 );
		}
		glEnd ();
		//psys.SPH_DrawDomain();						//Draw Particle Volume
		psys.Grid_Draw(&viewmat[0]);
		psys.Draw ( &viewmat[0], 0.8 );				// Draw particles		

	} else {
		glDisable ( GL_LIGHTING );
		psys.Draw ( &viewmat[0], 0.55 );			// Draw particles
	}
}
开发者ID:macsyums92,项目名称:screen-space-fluid-rendering,代码行数:41,代码来源:main.cpp

示例12: keyDown

void WaterSimulationApp::keyDown( KeyEvent event ){
	switch(event.getChar()){
	case 'r':fluidsys->reset(boxDimension);break;
	case 'f':setFullScreen( ! isFullScreen() ); break;
	case 'a':mAddNewForce=true;break;
	}

	switch(event.getCode()){
	case KeyEvent::KEY_SPACE:mAnimate=!mAnimate;break;
	case KeyEvent::KEY_ESCAPE:this->quit();break;
	}

}
开发者ID:myartings,项目名称:WaterSimulation,代码行数:13,代码来源:WaterSimulationApp.cpp

示例13:

float *get_points() {
  char *dat;
  Point *p;
  float *cp;

  dat = psys.mBuf[0].data;
  for (int i = 0; i < psys.NumPoints(); i++) {
	  p = (Point*) dat;
    cpoints[i*3+0] = p->pos.x;
    cpoints[i*3+1] = p->pos.y;
    cpoints[i*3+2] = p->pos.z;
    dat += psys.mBuf[0].stride; 
  }
  return cpoints;
}
开发者ID:tikwid,项目名称:jsfluid,代码行数:15,代码来源:jsfluid.cpp

示例14: setup

void WaterSimulationApp::setup(){

	boxDimension=Vec3f(30.0f,30.0f,30.0f);
	boxCenter=Vec3f(boxDimension)/2.0f;

	//Fluid System setup
	fluidsys=&stamfluid;
	fluidsys->reset(boxDimension);

	randomForce=Vec3f(2,3,-1);
	randomForceX=boxCenter;

	//// setup our default camera, looking down the z-axis
	CameraPersp	cam;
	cam.setEyePoint(Vec3f(200, 50, 50));
	cam.setCenterOfInterestPoint(boxCenter);
	cam.setPerspective(60.0, getWindowAspectRatio(), 1.0, 1000.0);
	mMayaCam.setCurrentCam(cam);

	Matrix44f mvM=mMayaCam.getCamera().getModelViewMatrix();
	gravity = Vec3f(mvM.m10,mvM.m11,mvM.m12);//col4:camera center, row: right,up,back
	gravity*= 9.8f;
	// Setup the parameters
	mDrawGravity=false;
	mAddNewForce=false;
	mAnimate	=false;
	mDrawBox	=true;


	mParams = params::InterfaceGl::create( getWindow(), "Water Simulation Parameters", toPixels( Vec2i( 250,300  ) ) );
	mParams->addParam("Draw Box", &mDrawBox);
	mParams->addParam("Draw Grid",&mDrawGrid);
	mParams->addParam("Draw Random Force",&mDrawForce);
	mParams->addSeparator();
	mParams->addParam("External Force Position",&randomForceX);
	mParams->addParam("External Force Dir",&randomForce);
	mParams->addParam("Draw Gravity",&mDrawGravity);
	mParams->addParam("Draw Velocity", &(fluidsys->mDrawVelocity));
	mParams->addSeparator();
	mParams->addParam("Animate",&mAnimate);
	mParams->addText("status","label=` `");
	mParams->addParam("Time Elapsed",&(fluidsys->elapsed),"",true);
	mParams->addSeparator();
	mParams->addParam("Viscosity", &fluidsys->viscosity);
	mParams->addParam("Diffusion Rate", &fluidsys->diffusion);
	mParams->addParam("Buoyancy Rate",&fluidsys->buoyancy);
}
开发者ID:myartings,项目名称:WaterSimulation,代码行数:47,代码来源:WaterSimulationApp.cpp

示例15: mouse_move_func

void mouse_move_func ( int x, int y )
{
	int dx = x - last_x;
	int dy = y - last_y;

	switch ( mode ) {
	case MODE_CAM:
		if ( dragging == DRAG_LEFT ) {
			cam_angs.x += dx;
			cam_angs.y += dy;
			if ( cam_angs.x >= 360.0 )	cam_angs.x -= 360.0;
			if ( cam_angs.x < 0 )		cam_angs.x += 360.0;
			if ( cam_angs.y >= 180.0 )	cam_angs.y = 180.0;
			if ( cam_angs.y <= -180.0 )	cam_angs.y = -180.0;
			printf ( "Cam Ang: %f %f %f\n", cam_angs.x, cam_angs.y, cam_angs.z );
			printf ( "Cam To:  %f %f %f\n", cam_to.x, cam_to.y, cam_to.z );
			printf ( "Cam FOV: %f\n", cam_fov);
		} else if ( dragging == DRAG_RIGHT ) {
			cam_angs.z += dy*.15;
			if ( cam_angs.z < 0)		cam_angs.z = 0;
			printf ( "Cam Ang: %f %f %f\n", cam_angs.x, cam_angs.y, cam_angs.z );
			printf ( "Cam To:  %f %f %f\n", cam_to.x, cam_to.y, cam_to.z );
			printf ( "Cam FOV: %f\n", cam_fov );
		}
		break;
	case MODE_CAM_TO:
		if ( dragging == DRAG_LEFT ) {
			cam_to.x += dx;
			cam_to.y += dy;			
		} else if ( dragging == DRAG_RIGHT ) {
			cam_to.z += dy*.05;
			if ( cam_to.z < 0) 	cam_to.z = 0;
		}
		break;	
	case MODE_OBJ:
		if ( dragging == DRAG_LEFT ) {
			obj_angs.x -= dx*0.1;
			obj_angs.y += dy*0.1;
			printf ( "Obj Angs:  %f %f %f\n", obj_angs.x, obj_angs.y, obj_angs.z );
			//force_x += dx*.1;
			//force_y += dy*.1;
		} else if (dragging == DRAG_RIGHT) {
			obj_angs.z -= dy*.005;			
			printf ( "Obj Angs:  %f %f %f\n", obj_angs.x, obj_angs.y, obj_angs.z );
		}
		psys.SetVec ( EMIT_ANG, Vector3DF ( obj_angs.x, obj_angs.y, obj_angs.z ) );
		break;
	case MODE_OBJPOS:
		if ( dragging == DRAG_LEFT ) {
			obj_from.x -= dx*.1;
			obj_from.y += dy*.1;
			printf ( "Obj:  %f %f %f\n", obj_from.x, obj_from.y, obj_from.z );
		} else if (dragging == DRAG_RIGHT) {
			obj_from.z -= dy*.1;
			printf ( "Obj:  %f %f %f\n", obj_from.x, obj_from.y, obj_from.z );
		}
		psys.SetVec ( EMIT_POS, Vector3DF ( obj_from.x, obj_from.y, obj_from.z ) );
		//psys.setPos ( obj_x, obj_y, obj_z, obj_ang, obj_tilt, obj_dist );
		break;
	case MODE_LIGHTPOS:
		if ( dragging == DRAG_LEFT ) {
			light[0].x -= dx*.1;
			light[0].y += dy*.1;		
			printf ( "Light: %f %f %f\n", light[0].x, light[0].y, light[0].z );
		} else if (dragging == DRAG_RIGHT) {
			light[0].z -= dy*.1;			
			printf ( "Light: %f %f %f\n", light[0].x, light[0].y, light[0].z );
		}	
		#ifdef USE_SHADOWS
			setShadowLight ( light[0].x, light[0].y, light[0].z, light_to[0].x, light_to[0].y, light_to[0].z, light_fov );
		#endif
		break;
	}

	if ( x < 10 || y < 10 || x > 1000 || y > 700 ) {
		glutWarpPointer ( 1024/2, 768/2 );
		last_x = 1024/2;
		last_y = 768/2;
	} else {
		last_x = x;
		last_y = y;
	}
}
开发者ID:macsyums92,项目名称:screen-space-fluid-rendering,代码行数:83,代码来源:main.cpp


注:本文中的FluidSystem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。