void CHSAsteroid::GiveScanReport(CHSObject *cScanner, dbref player, BOOL id) { char tbuf[256]; // Print a header sprintf(tbuf, "%s%s.------------------------------------------------.%s", ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL); notify(player, tbuf); sprintf(tbuf, "%s%s|%s Scan Report %30s %s%s|%s", ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL, id ? GetName() : "Unknown", ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL); notify(player, tbuf); sprintf(tbuf, "%s%s >----------------------------------------------<%s", ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL); notify(player, tbuf); // Give Nebula info sprintf(tbuf, "%s%s| %sX:%s %9.0f %s%sDiameter:%s %7d hm %s%s|%s", ANSI_HILITE, ANSI_BLUE, ANSI_GREEN, ANSI_NORMAL, GetX(), ANSI_HILITE, ANSI_GREEN, ANSI_NORMAL, GetSize() * 100, ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL); notify(player, tbuf); sprintf(tbuf, "%s%s| %sY:%s %9.0f %s%sDensity:%s %3d/100m2 %s%s|%s", ANSI_HILITE, ANSI_BLUE, ANSI_GREEN, ANSI_NORMAL, GetY(), ANSI_HILITE, ANSI_GREEN, ANSI_NORMAL, GetDensity(), ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL); notify(player, tbuf); sprintf(tbuf, "%s%s| %sZ:%s %9.0f%35s%s%s|%s", ANSI_HILITE, ANSI_BLUE, ANSI_GREEN, ANSI_NORMAL, GetZ(), " ", ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL); notify(player, tbuf); // Finish the report sprintf(tbuf, "%s%s`------------------------------------------------'%s", ANSI_HILITE, ANSI_BLUE, ANSI_NORMAL); notify(player, tbuf); }
BOOL CGretagScan::ProcessResult( CCommRequest *pRequest, double *data) { int code[5]; if(pRequest->m_dwRequestType == REQUEST_COMMAND){ if(m_type == 1) //LAB return GetLab(pRequest, data); else return GetDensity(pRequest, data); } return FALSE; }
//-------------------------------------------------------------------------------------- // Create and blur a noise volume texture //-------------------------------------------------------------------------------------- HRESULT SoftParticles::CreateNoiseVolume( ID3D11Device* pd3dDevice, UINT VolumeSize ) { HRESULT hr = S_OK; D3D11_SUBRESOURCE_DATA InitData; InitData.pSysMem = new CHAR4[ VolumeSize*VolumeSize*VolumeSize ]; InitData.SysMemPitch = VolumeSize*sizeof(CHAR4); InitData.SysMemSlicePitch = VolumeSize*VolumeSize*sizeof(CHAR4); // Gen a bunch of random values CHAR4* pData = (CHAR4*)InitData.pSysMem; for( UINT i=0; i<VolumeSize*VolumeSize*VolumeSize; i++ ) { pData[i].w = (char)(RPercent() * 128.0f); } // Generate normals from the density gradient float heightAdjust = 0.5f; D3DXVECTOR3 Normal; D3DXVECTOR3 DensityGradient; for( UINT z=0; z<VolumeSize; z++ ) { for( UINT y=0; y<VolumeSize; y++ ) { for( UINT x=0; x<VolumeSize; x++ ) { DensityGradient.x = GetDensity( x+1, y, z, pData, VolumeSize ) - GetDensity( x-1, y, z, pData, VolumeSize )/heightAdjust; DensityGradient.y = GetDensity( x, y+1, z, pData, VolumeSize ) - GetDensity( x, y-1, z, pData, VolumeSize )/heightAdjust; DensityGradient.z = GetDensity( x, y, z+1, pData, VolumeSize ) - GetDensity( x, y, z-1, pData, VolumeSize )/heightAdjust; D3DXVec3Normalize( &Normal, &DensityGradient ); SetNormal( Normal, x,y,z, pData, VolumeSize ); } } } D3D11_TEXTURE3D_DESC desc; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; desc.CPUAccessFlags = 0; desc.Depth = desc.Height = desc.Width = VolumeSize; desc.Format = DXGI_FORMAT_R8G8B8A8_SNORM; desc.MipLevels = 1; desc.MiscFlags = 0; desc.Usage = D3D11_USAGE_IMMUTABLE; V_RETURN( pd3dDevice->CreateTexture3D( &desc, &InitData, &g_pNoiseVolume ) ); D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc; ZeroMemory( &SRVDesc, sizeof(SRVDesc) ); SRVDesc.Format = desc.Format; SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; SRVDesc.Texture3D.MipLevels = desc.MipLevels; SRVDesc.Texture3D.MostDetailedMip = 0; V_RETURN(pd3dDevice->CreateShaderResourceView( g_pNoiseVolume, &SRVDesc, &g_pNoiseVolumeRV )); delete InitData.pSysMem; return hr; }
void OpenSMOKE_Droplet::UpdateProperties() { double cGasTot; MoleFractionsAndMolecularWeights(); for(int i=1;i<=N;i++) { // Mass and mole fractions Omega.GetRow(i,&OmegaVector); X.GetRow(i,&XVector); // a. Concentration and density rho[i] = GetDensity(T[i], OmegaVector); // [kg/m3] // b. Specific heat cp[i] = GetSpecificHeat(T[i], OmegaVector); // [J/kg/K] // c. Thermal conductivity lambda[i] = GetThermalConductivity(T[i], OmegaVector); // [W/m/K] // e. Diffusion coefficients Dm.SetRow(i, GetDiffusionCoefficients(T[i], OmegaVector)); // [m2/s] } // Density at centers A_x_rhow[1] = grid.A[1]*rho[1]; for(int i=1;i<N;i++) { A_x_rhoe[i] = 0.50*(grid.A[i]*rho[i]+grid.A[i+1]*rho[i+1]); A_x_rhow[i+1] = A_x_rhoe[i]; } A_x_rhoe[N] = grid.A[N]*rho[N]; // Thermal conductivity at centers A_x_lambdaw[1] = grid.A[1]*lambda[1]; for(int i=1;i<N;i++) { A_x_lambdae[i] = 0.50 * (grid.A[i]*lambda[i] + grid.A[i+1]*lambda[i+1]); A_x_lambdaw[i+1] = A_x_lambdae[i]; } A_x_lambdae[N] = grid.A[N]*lambda[N]; }
Double_t KVIonRangeTable::GetDensity(const Char_t* mat) { // Return density of material (g/cm**3) of given type or name if it is in range tables FIND_MAT_AND_EXEC(GetDensity(),0.0); }
void Physical::AeroFrame(double s) { arcade_velocity = Point(); // if this object is under direction, // but doesn't need subframe accuracy, // update the control parameters: if (dir && !dir->Subframe()) dir->ExecFrame(s); // decrement life before destroying the frame time: if (life > 0) life -= s; // integrate equations // using slices no larger // than sub_frame: double seconds = s; while (s > 0.0) { if (s > sub_frame) seconds = sub_frame; else seconds = s; // if the director needs subframe accuracy, run it now: if (dir && dir->Subframe()) dir->ExecFrame(seconds); AngularFrame(seconds); // LINEAR MOVEMENT ---------------------------- Point pos = cam.Pos(); // if the object is thrusting, // accelerate along the camera normal: if (thrust) { Point thrustvec = cam.vpn(); thrustvec *= ((thrust/mass) * seconds); velocity += thrustvec; } // AERODYNAMICS ------------------------------ if (lat_thrust) LinearFrame(seconds); // if no thrusters, do constant gravity: else if (g_accel > 0) velocity += Point(0, -g_accel, 0) * seconds; // compute alpha, rho, drag, and lift: Point vfp = velocity; double v = vfp.Normalize(); double v_2 = 0; double rho = GetDensity(); double lift = 0; if (v > 150) { v_2 = (v-150) * (v-150); Point vfp1 = vfp - cam.vrt() * (vfp * cam.vrt()); vfp1.Normalize(); double cos_alpha = vfp1 * cam.vpn(); if (cos_alpha >= 1) { alpha = 0.0f; } else { alpha = (float) acos(cos_alpha); } // if flight path is above nose, alpha is negative: if (vfp1 * cam.vup() > 0) alpha = -alpha; if (alpha <= stall) { lift = CL * alpha * rho * v_2; } else { lift = CL * (2*stall - alpha) * rho * v_2; } // add lift to velocity: if (_finite(lift)) velocity += cam.vup() * lift * seconds; else lift = 0; // if drag applies, decellerate: double alpha_2 = alpha*alpha; double drag_eff = (drag + (CD * alpha_2)) * rho * v_2; Point vn = velocity; vn.Normalize(); velocity += vn * -drag_eff * seconds; } else { velocity *= exp(-drag * seconds); } // move the position by the (time-frame scaled) velocity: pos += velocity * seconds; cam.MoveTo(pos); s -= seconds; } // now update the graphic rep and light sources: if (rep) { rep->MoveTo(cam.Pos()); rep->SetOrientation(cam.Orientation()); } if (light) { light->MoveTo(cam.Pos()); } }
bool CNSVariable::SetPrimVar_Compressible(su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel) { unsigned short iVar; su2double density, staticEnergy; bool check_dens = false, check_press = false, check_sos = false, check_temp = false, RightVol = true; SetVelocity(); // Computes velocity and velocity^2 density = GetDensity(); staticEnergy = GetEnergy()-0.5*Velocity2 - turb_ke; /*--- Check will be moved inside fluid model plus error description strings ---*/ FluidModel->SetTDState_rhoe(density, staticEnergy); check_dens = SetDensity(); check_press = SetPressure(FluidModel->GetPressure()); check_sos = SetSoundSpeed(FluidModel->GetSoundSpeed2()); check_temp = SetTemperature(FluidModel->GetTemperature()); /*--- Check that the solution has a physical meaning ---*/ if (check_dens || check_press || check_sos || check_temp) { /*--- Copy the old solution ---*/ for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Solution_Old[iVar]; /*--- Recompute the primitive variables ---*/ SetVelocity(); // Computes velocity and velocity^2 density = GetDensity(); staticEnergy = GetEnergy()-0.5*Velocity2 - turb_ke; /*--- Check will be moved inside fluid model plus error description strings ---*/ FluidModel->SetTDState_rhoe(density, staticEnergy); SetDensity(); SetPressure(FluidModel->GetPressure()); SetSoundSpeed(FluidModel->GetSoundSpeed2()); SetTemperature(FluidModel->GetTemperature()); RightVol = false; } /*--- Set enthalpy ---*/ SetEnthalpy(); // Requires pressure computation. /*--- Set laminar viscosity ---*/ SetLaminarViscosity(FluidModel->GetLaminarViscosity()); /*--- Set eddy viscosity ---*/ SetEddyViscosity(eddy_visc); /*--- Set thermal conductivity ---*/ SetThermalConductivity(FluidModel->GetThermalConductivity()); /*--- Set specific heat ---*/ SetSpecificHeatCp(FluidModel->GetCp()); return RightVol; }
double CBody::GetMass()const { return GetVolume() * GetDensity(); }