static FileInfoListPtr GetLsCacheFileList(const char *const item) { int ci; int sortBy; int sortOrder; FileInfoListPtr filp; ci = LsCacheLookup(item); if (ci < 0) { /* This dir was not in the * cache -- go get it. */ Ls(item, 'l', "", NULL); ci = LsCacheLookup(item); if (ci < 0) return NULL; } sortBy = 'n'; /* Sort by filename. */ sortOrder = 'a'; /* Sort in ascending order. */ filp = &gLsCache[ci].fil; SortFileInfoList(filp, sortBy, sortOrder); return filp; } /* GetLsCacheFileList */
void Hl(int y, char *txt) { Ls(y); strncat(hstr, colour_str(WHITE, BLUE), 80); strncat(hstr, padleft(txt, 58, ' '), 80); Rs(); PUTSTR(chartran(hstr)); }
void Ws(int y) { int i; Ls(y); for (i = 0; i < 58; i++) strncat(hstr, (char *)" ", 80); Rs(); }
void Full_Help(void) { strcpy(hstr, colour_str(LIGHTGREEN, BLUE)); /* Top row */ strncat(hstr, locate_str(1, 10), 80); strncat(hstr, (char *)"\xDA", 80); strncat(hstr, hLine_str(58), 80); strncat(hstr, (char *)"\xBF", 80); PUTSTR(chartran(hstr)); Ws(2); PUTSTR(chartran(hstr)); Ls(3); strncat(hstr, colour_str(YELLOW, BLUE), 80); strncat(hstr, padleft((char *)" Editor Help", 58, ' '), 80); Rs(); PUTSTR(chartran(hstr)); Ws(4); PUTSTR(chartran(hstr)); Hl( 5, (char *)"Ctrl-S or LeftArrow - Cursor left"); Hl( 6, (char *)"Ctrl-D or RightArrow - Cursor right"); Hl( 7, (char *)"Ctrl-E or UpArrow - Cursor up"); Hl( 8, (char *)"Ctrl-X or DownArrow - Cursor down"); Hl( 9, (char *)"Ctrl-V or Insert - Insert or Overwrite"); Hl(10, (char *)"Ctrl-N - Insert line"); Hl(11, (char *)"Ctrl-Y - Delete line"); Ws(12); PUTSTR(chartran(hstr)); Hl(13, (char *)"Ctrl-L - Refresh screen"); Hl(14, (char *)"Ctrl-R - Read from file"); Ws(15); PUTSTR(chartran(hstr)); strcpy(hstr, locate_str(16,10)); strncat(hstr, (char *)"\xC0", 80); strncat(hstr, hLine_str(58), 80); strncat(hstr, (char *)"\xD9", 80); PUTSTR(chartran(hstr)); }
void v2f<BasicTurbulenceModel>::correct() { if (!this->turbulence_) { return; } // Local references const alphaField& alpha = this->alpha_; const rhoField& rho = this->rho_; const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_; const volVectorField& U = this->U_; volScalarField& nut = this->nut_; fv::options& fvOptions(fv::options::New(this->mesh_)); eddyViscosity<RASModel<BasicTurbulenceModel>>::correct(); volScalarField divU(fvc::div(fvc::absolute(this->phi(), U))); // Use N=6 so that f=0 at walls const dimensionedScalar N("N", dimless, 6.0); const volTensorField gradU(fvc::grad(U)); const volScalarField S2(2*magSqr(dev(symm(gradU)))); const volScalarField G(this->GName(), nut*S2); const volScalarField Ts(this->Ts()); const volScalarField L2(type() + ":L2", sqr(Ls())); const volScalarField v2fAlpha ( type() + ":alpha", 1.0/Ts*((C1_ - N)*v2_ - 2.0/3.0*k_*(C1_ - 1.0)) ); const volScalarField Ceps1 ( "Ceps1", 1.4*(1.0 + 0.05*min(sqrt(k_/v2_), scalar(100.0))) ); // Update epsilon (and possibly G) at the wall epsilon_.boundaryFieldRef().updateCoeffs(); // Dissipation equation tmp<fvScalarMatrix> epsEqn ( fvm::ddt(alpha, rho, epsilon_) + fvm::div(alphaRhoPhi, epsilon_) - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_) == Ceps1*alpha*rho*G/Ts - fvm::SuSp(((2.0/3.0)*Ceps1 + Ceps3_)*alpha*rho*divU, epsilon_) - fvm::Sp(Ceps2_*alpha*rho/Ts, epsilon_) + fvOptions(alpha, rho, epsilon_) ); epsEqn.ref().relax(); fvOptions.constrain(epsEqn.ref()); epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef()); solve(epsEqn); fvOptions.correct(epsilon_); bound(epsilon_, this->epsilonMin_); // Turbulent kinetic energy equation tmp<fvScalarMatrix> kEqn ( fvm::ddt(alpha, rho, k_) + fvm::div(alphaRhoPhi, k_) - fvm::laplacian(alpha*rho*DkEff(), k_) == alpha*rho*G - fvm::SuSp((2.0/3.0)*alpha*rho*divU, k_) - fvm::Sp(alpha*rho*epsilon_/k_, k_) + fvOptions(alpha, rho, k_) ); kEqn.ref().relax(); fvOptions.constrain(kEqn.ref()); solve(kEqn); fvOptions.correct(k_); bound(k_, this->kMin_); // Relaxation function equation tmp<fvScalarMatrix> fEqn ( - fvm::laplacian(f_) == - fvm::Sp(1.0/L2, f_) - 1.0/L2/k_*(v2fAlpha - C2_*G) ); fEqn.ref().relax(); fvOptions.constrain(fEqn.ref()); solve(fEqn); fvOptions.correct(f_); bound(f_, fMin_); // Turbulence stress normal to streamlines equation tmp<fvScalarMatrix> v2Eqn ( fvm::ddt(alpha, rho, v2_) + fvm::div(alphaRhoPhi, v2_) - fvm::laplacian(alpha*rho*DkEff(), v2_) == alpha*rho*min(k_*f_, C2_*G - v2fAlpha) - fvm::Sp(N*alpha*rho*epsilon_/k_, v2_) + fvOptions(alpha, rho, v2_) ); v2Eqn.ref().relax(); fvOptions.constrain(v2Eqn.ref()); solve(v2Eqn); fvOptions.correct(v2_); bound(v2_, v2Min_); correctNut(); }
Color AtmospherePathTracingIntegrator::Li( SceneCPtr scene, RendererCPtr renderer, const Ray &r, Color &transmittance, bool debug) const { Debug dd; Atmosphere::LUTParameters &parms = scene->m_atmosphere->m_parameters; const Real heightOffset = (Real)parms.R_e+0.1f; // move to correct height Ray ray = r; ray.o += Vector( 0.0f, heightOffset, 0.0f ); // find intersection with outer atmosphere Real t0,t1; if (!math::intersectionRaySphere<Real>( ray, (Real)parms.R_a, t0, t1)) return math::Vec3f(1.0f); if( t1 > ray.tmax ) t1 = ray.tmax; if( t0 < ray.tmin ) t0 = ray.tmin; ///* Real maxDist = t1-t0; //Real stepSize = maxDist/(parms.viewRaySamples); Real stepSize = 1.0f; //Real stepSize = m_stepSize; Vector step = ray.d*stepSize; Real tend; Real volSamplePDF; Vector x; ///* // uniform sampling --------------- tend = t0 + math::g_randomNumber.randomFloat()*maxDist; volSamplePDF = 1.0f/maxDist; // raymarch to tend and compute transmittance Real t = t0;// + math::g_randomNumber.randomFloat()*stepSize; x = ray.getPosition( t ); Real densityR = 0.0f; Real densityM = 0.0f; while( t<tend ) { Real height = x.getLength() - (Real)parms.R_e; Real currentDensityR = exp(-height / parms.h_r)*stepSize; Real currentDensityM = exp(-height / parms.h_m)*stepSize; densityR += currentDensityR; densityM += currentDensityM; t += stepSize; x += step; }; Vector opticalDepth = (Vector)parms.beta_r*densityR + (Vector)parms.beta_m*Real(1.1)*densityM; Vector transmittanceView = Vector( exp(-opticalDepth.x), exp(-opticalDepth.y), exp(-opticalDepth.z) ); //*/ /* // woodcock tracking Real maxDensity = 6.0f; Real densityEnd = -log( math::g_randomNumber.randomFloat() ) / maxDensity; // raymarch to tend and compute transmittance Real densityR = 0.0f; Real densityM = 0.0f; tend = t0; x = ray.getPosition(tend); while( (densityR+densityM<maxDensity)&&(tend<t1) ) { Real height = x.getLength() - (Real)parms.R_e; Real currentDensityR = exp(-height / parms.h_r)*stepSize; Real currentDensityM = exp(-height / parms.h_m)*stepSize; densityR += currentDensityR; densityM += currentDensityM; tend += stepSize; x += step; }; Vector opticalDepth = (Vector)parms.beta_r*densityR + (Vector)parms.beta_m*Real(1.1)*densityM; Vector transmittanceView = Vector( exp(-opticalDepth.x), exp(-opticalDepth.y), exp(-opticalDepth.z) ); volSamplePDF = exp(-(densityR+densityM))*maxDensity; */ /* // woodcock tracking2 Real maxDensity = 2.0f; Real densityEnd = -log( math::g_randomNumber.randomFloat() ) / maxDensity; // raymarch to tend and compute transmittance Real densityR = 0.0f; Real densityM = 0.0f; tend = t0; while(tend < t1) { tend += -log( math::g_randomNumber.randomFloat() ) / maxDensity; x = ray.getPosition(tend); Real height = x.getLength() - (Real)parms.R_e; Real currentDensityR = exp(-height / parms.h_r); Real currentDensityM = exp(-height / parms.h_m); densityR += currentDensityR; densityM += currentDensityM; if( math::g_randomNumber.randomFloat() < (currentDensityR+currentDensityM)/maxDensity ) break; }; Vector opticalDepth = (Vector)parms.beta_r*densityR + (Vector)parms.beta_m*Real(1.1)*densityM; Vector transmittanceView = Vector( exp(-opticalDepth.x), exp(-opticalDepth.y), exp(-opticalDepth.z) ); volSamplePDF = exp(-(densityR+densityM))*maxDensity; */ // --- Real nu = math::dot( ray.d, (Vector)scene->m_atmosphere->m_sunDirection ); Real phaseR = (Real)(3.0f / (16.0f * Real(MATH_PIf))) * (1.0f + nu * nu); Real g = (Real)parms.mie_phase_g; Real phaseM = (3 / (8 * Real(MATH_PI))) * (((1 - g * g) * (1 + nu * nu))/((2 + g * g) * pow(1 + g * g - 2 * g * nu, Real(1.5)))); Color Ls(0.0f); // single scattering { LightCPtr light = scene->m_lights[0]; Vector lx = x - Vector( 0.0f, heightOffset, 0.0f ); Vector wi; Real pdf; Ray vis; // visibility ray Color Li = light->sample_L( lx, wi, pdf, vis ); Color transmittanceLight = renderer->transmittance( scene, vis ); Real height = x.getLength() - (Real)parms.R_e; Real currentDensityR = exp(-height / parms.h_r)*stepSize; Real currentDensityM = exp(-height / parms.h_m)*stepSize; Color tt = transmittanceView*transmittanceLight; Color sum_r = tt*phaseR*currentDensityR*parms.beta_r; Color sum_m = tt*phaseM*currentDensityM*parms.beta_m*Real(1.1f); Ls += Li*(sum_r + sum_m)/pdf; ///* if( debug ) { Debug dd; dd.tend = tend; dd.transmittance = transmittanceLight; dd.Li = Ls; debugData.push_back(dd); } //*/ } transmittance = this->transmittance(scene, r); return Ls/volSamplePDF; }
TextFileWidget::TextFileWidget(Vector2n Position, std::string Path, TypingModule & TypingModule) : FlowLayoutWidget(Position, { std::shared_ptr<Widget>(new FlowLayoutWidget(Vector2n::ZERO, { std::shared_ptr<Widget>(m_FileMinimizeToggle = new ToggleWidget(Vector2n::ZERO, Vector2n(12, 12), [](bool State) { if (!State) g_InputManager->RequestTypingPointer(*static_cast<GestureRecognizer *>(nullptr)); }, true)), std::shared_ptr<Widget>(new LabelWidget(Vector2n(0, -lineHeight - 2), Path, LabelWidget::Background::Normal)) }, {})), std::shared_ptr<Widget>(m_TextFieldWidget = new TextFieldWidget(Vector2n::ZERO, TypingModule)) }, { std::shared_ptr<Behavior>(new DraggablePositionBehavior(*this)) }, FlowLayoutWidget::LayoutType::Vertical), m_Path(Path) { m_TextFieldWidget->SetContent(FromFileToString(Path)); m_OnChange = [=]() // Saving takes place in TextFileWidget when it gets its NotifyChange() from the contained TextFieldWidget { //PlayBeep(); //printf("Saving '%s'.\n", Path.c_str()); // Write to file WriteToFile(Path, m_TextFieldWidget->GetContent()); }; const std::string Folder = ParsePath(Path, 0); const std::string Filename = ParsePath(Path, 1); auto CopyPath = [this, &TypingModule]() { #if DECISION_USE_CLIPBOARD_INSTEAD_OF_TypingModule glfwSetClipboardString(this->m_Path); #else TypingModule.SetString(this->m_Path); #endif }; ModifyGestureRecognizer().AddShortcut(GestureRecognizer::ShortcutEntry('I', PointerState::Modifiers::Super, CopyPath, "Copy Path")); // TEST: Line Gutters #if 0 //if ("./Gen/5086673/gistfile1.go" == Path) m_TextFieldWidget->m_GetLineGutters = [=](uint32 LineNumber) -> std::string { #if 0 std::string x = "."; Ls(x); return std::to_string(LineNumber + 1); #endif // HACK: Pass file folder and name info if (0 == LineNumber) return Folder; else if (1 == LineNumber) return Filename; else throw 0; }; #endif if (IsFileTrackedByGit(Path)) { auto GitDiff = new GitDiffWidget(Vector2n::ZERO, TypingModule, this); GitDiff->RemoveAllBehaviors(); AddWidget(GitDiff); auto GitCommit = new ButtonWidget(Vector2n(-160, -350), [=, &TypingModule]() { auto Shell = std::unique_ptr<ShellWidget>(new ShellWidget(Vector2n::ZERO, TypingModule)); std::string Command = "cd \'" + Folder + "\'\ngit commit --allow-empty-message -m '' -- \'" + Filename + "\'"; Command += "\ngit push origin master"; Shell->m_CommandWidget->SetContent(Command); Shell->m_ExecuteWidget->GetAction()(); this->NotifyExternalChange(); // Do this to triger potential GitDiffWidget, GitStatusWidget, etc. //std::cerr << "Commit & Push: '" << Folder << "' folder and '" << Filename << "' file.\n"; std::cerr << Shell->m_OutputWidget->GetContent() << endl; }, "Commit & Push"); AddWidget(GitCommit); } m_TextFieldWidget->m_MinimizeToggle = m_FileMinimizeToggle; }