void demIcoFoam::run(double time_increment) { volVectorField &U = *U_; volVectorField &f = *f_; volScalarField &n = *n_; volScalarField &p = *p_; dimensionedScalar &nu = *nu_; surfaceScalarField &phi = *phi_; Foam::Time &runTime = *runTime_; Foam::fvMesh &mesh = *mesh_; scalar &cumulativeContErr = cumulativeContErr_; runTime.setEndTime(runTime.value() + time_increment); while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "CourantNo.H" fvVectorMatrix UEqn (fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) - f/n); if (piso_->momentumPredictor()) solve(UEqn == -fvc::grad(p)); while (piso_->correct()) { volScalarField rAU(1.0/UEqn.A()); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); surfaceScalarField phiHbyA ("phiHbyA", (fvc::interpolate(HbyA) & mesh_->Sf())); adjustPhi(phiHbyA, U, p); while (piso_->correctNonOrthogonal()) { fvScalarMatrix pEqn (fvm::laplacian(rAU, p) == fvc::div(phiHbyA) //+ dndt ); pEqn.setReference(pRefCell_, pRefValue_); pEqn.solve(mesh.solver(p.select(piso_->finalInnerIter()))); if (piso_->finalNonOrthogonalIter()) phi = phiHbyA - pEqn.flux(); } #include "continuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); Info<< "ExecutionTime = " << runTime_->elapsedCpuTime() << " s" << " ClockTime = " << runTime_->elapsedClockTime() << " s" << nl << endl; } }
void recalcPhiFunctionObject::recalc() { Info << "Calculating flux field " << phiName_ << " for velocity " << UName_ << endl; const fvMesh &mesh=dynamicCast<const fvMesh&>(obr_); const volVectorField &U=mesh.lookupObject<volVectorField>(UName_); volScalarField &p=const_cast<volScalarField&>( mesh.lookupObject<volScalarField>(pName_) ); surfaceScalarField &phi=const_cast<surfaceScalarField&>( mesh.lookupObject<surfaceScalarField>(phiName_) ); if(writeOldFields_) { Info << "Writing copy of old " << phiName_ << endl; surfaceScalarField oldPhi(phiName_+".old",phi); oldPhi.write(); } if(phi.dimensions()==dimensionSet(0,3,-1,0,0,0,0)) { phi = fvc::interpolate(U) & mesh.Sf(); } else if(phi.dimensions()==dimensionSet(1,0,-1,0,0,0,0)) { if(rhoName_=="none") { // force read rhoName_=word(dict_.lookup("rhoName")); } const volScalarField &rho=mesh.lookupObject<volScalarField>(rhoName_); phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf()); } else { FatalErrorIn("recalcPhiFunctionObject::calcPhi()") << "Can't deal with a flux field " << phiName_ << " with dimensions " << phi.dimensions() << endl << exit(FatalError); } adjustPhi(phi, U, p); if(writeFields_) { Info << "Writing new value of " << phiName_ << endl; phi.write(); } }
//--------------------------------------------------------------------------- void fun_pEqn( const fvMeshHolder& mesh, const TimeHolder& runTime, const simpleControlHolder& simple, volVectorFieldHolder& U, surfaceScalarFieldHolder& phi, incompressible::RASModelHolder& turbulence, volScalarFieldHolder& p, fvVectorMatrixHolder& UEqn, label& pRefCell, scalar& pRefValue, scalar& cumulativeContErr ) { p->boundaryField().updateCoeffs(); smart_tmp< volScalarField > rAU(1.0/UEqn->A()); U = rAU() * UEqn->H(); phi = fvc::interpolate( U(), "interpolate(HbyA)") & mesh->Sf(); adjustPhi(phi, U, p); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=simple->nNonOrthCorr(); nonOrth++) { smart_tmp< fvScalarMatrix > pEqn( fvm::laplacian( rAU(), p() ) == fvc::div( phi() ) ); pEqn->setReference(pRefCell, pRefValue); pEqn->solve(); if (nonOrth == simple->nNonOrthCorr()) { phi -= pEqn->flux(); } } continuityErrors( runTime, mesh, phi, cumulativeContErr ); // Explicitly relax pressure for momentum corrector p->relax(); // Momentum corrector U -= rAU() * fvc::grad( p() ); U->correctBoundaryConditions(); }
int main(int argc, char *argv[]) { argList::validOptions.insert("writep", ""); #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "readControls.H" #include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< nl << "Calculating potential flow" << endl; adjustPhi(phi, U, p); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian ( dimensionedScalar ( "1", dimTime/p.dimensions()*dimensionSet(0, 2, -2, 0, 0), 1 ), p ) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } Info<< "continuity error = " << mag(fvc::div(phi))().weightedAverage(mesh.V()).value() << endl; U = fvc::reconstruct(phi); U.correctBoundaryConditions(); Info<< "Interpolated U error = " << (sqrt(sum(sqr((fvc::interpolate(U) & mesh.Sf()) - phi))) /sum(mesh.magSf())).value() << endl; // Force the write U.write(); p.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; Info<< "End\n" << endl; return 0; }
//--------------------------------------------------------------------------- int main(int argc, char *argv[]) { argList args = setRootCase( argc, argv ); TimeHolder runTime=createTime( Time::controlDictName, args ); fvMeshHolder mesh = createMesh( runTime ); IOdictionaryHolder transportProperties; volScalarFieldHolder p; volVectorFieldHolder U; surfaceScalarFieldHolder phi; label pRefCell = 0; scalar pRefValue = 0.0; dimensionedScalar nu = createFields( runTime, mesh, transportProperties, p, U, phi, pRefCell, pRefValue ); scalar cumulativeContErr = initContinuityErrs(); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime->loop()) { Info<< "Time = " << runTime->timeName() << nl << endl; dictionary pisoDict; int nOuterCorr; int nCorr; int nNonOrthCorr; bool momentumPredictor; bool transonic; readPISOControls( mesh, pisoDict, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic); CourantNo( runTime, mesh, phi ); fvVectorMatrixHolder UEqn ( fvm::ddt( U ) + fvm::div( phi, U ) - fvm::laplacian( nu, U ) ); solve( UEqn == -fvc::grad( p ) ); // --- PISO loop for (int corr=0; corr<nCorr; corr++) { volScalarFieldHolder rAU( 1.0 / volScalarFieldHolder( UEqn->A(), &UEqn ) ); U = rAU * volVectorFieldHolder( UEqn->H(), &UEqn ); phi = ( fvc::interpolate(U) & surfaceVectorFieldHolder( mesh->Sf(), &mesh ) ) + fvc::ddtPhiCorr(rAU, U, phi); adjustPhi(phi, U, p); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrixHolder pEqn ( fvm::laplacian(rAU, p ) == fvc::div(phi) ); pEqn->setReference(pRefCell, pRefValue); pEqn->solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn->flux(); } } continuityErrors( runTime, mesh, phi, cumulativeContErr ); U -= rAU * fvc::grad(p); U->correctBoundaryConditions(); } runTime->write(); Info<< "ExecutionTime = " << runTime->elapsedCpuTime() << " s" << " ClockTime = " << runTime->elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "CourantNo.H" fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) ); solve(UEqn == -fvc::grad(p)); // --- PISO loop for (int corr=0; corr<nCorr; corr++) { volScalarField rAU(1.0/UEqn.A()); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); surfaceScalarField phiHbyA ( "phiHbyA", (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi) ); adjustPhi(phiHbyA, U, p); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rAU, p) == fvc::div(phiHbyA) ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); if (nonOrth == nNonOrthCorr) { phi = phiHbyA - pEqn.flux(); } } #include "continuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; // Get index of patch const word w0("fixedWalls"); const word w1("movingWall"); const word w2("frontAndBack"); // call size() of mother class fvPatchList label nb_fvPatch = mesh.boundaryMesh().size(); // const label w0PatchID = mesh.boundaryMesh().findPatchID(w0); const label w1PatchID = mesh.boundaryMesh().findPatchID(w1); const label w2PatchID = mesh.boundaryMesh().findPatchID(w2); Info<< "Size of fvBoundryMesh = " << nb_fvPatch << "\n"<< endl; Info<< "PatchID for " << w0 << " is " << w0PatchID << "\n" << endl; Info<< "PatchID for " << w1 << " is " << w1PatchID << "\n" << endl; Info<< "PatchID for " << w2 << " is " << w2PatchID << "\n" << endl; // Get reference to boundary value const fvsPatchVectorField& faceCentreshub = mesh.Cf().boundaryField()[w0PatchID]; // const fvsPatchVectorField fvPatchVectorField& U_b = U.boundaryField()[w1PatchID]; // fvPatchVectorField // get coordinate for cell centre const fvPatchVectorField& centre = mesh.C().boundaryField()[w0PatchID]; scalarField y = centre.component(vector::Y); scalarField x = centre.component(vector::X); // calculate inlet velocity //U_b = y*0.75/0.0051*vector (1,0,0)+x*0.75/0.0051*vector(0,1,0)+7.5*vector(0,0,1); //inletU.write(); forAll(U_b, faceI) { const double PI = 3.14; //get coordinate for face centre const vector& c = faceCentreshub[faceI]; //vector p(0.5*(1+Foam::sin(40*PI*c[0]-PI/2)), 0, 0); //if (c[0]>0.025 & c[0]<0.075) //vector p1 = vector(1, 0, 0); //vector p1(1, 0, 0); //U_b[faceI] = p1; Info<< "faceI = " << faceI << "c = "<< c << "U = "<< U_b[faceI] << endl; } Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n\n" << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "createMeanFields.H" #include "createDivSchemeBlendingField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Enter the time loop Info << "\nStarting time loop\n" << endl; while (runTime.loop()) { Info << "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "CourantNo.H" #include "updateDivSchemeBlendingField.H" // PISO algorithm { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) + turbulence->divDevReff(U) - turbines.force() ); UEqn.relax(); if (momentumPredictor) { solve(UEqn == -fvc::grad(p)); } // Pressure/velocity corrector loop for (int corr=0; corr<nCorr; corr++) { volScalarField rAU(1.0/UEqn.A()); U = rAU*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, U, phi); adjustPhi(phi, U, p); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rAU, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); if ( corr == nCorr-1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver("pFinal")); } else { pEqn.solve(); } if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } // Velocity corrector U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); } } // Calculate the divergence of velocity flux and display. #include "computeDivergence.H" // Compute the turbulence model variables. turbulence->correct(); // Update the turbine. turbines.update(); // Compute the mean fields. #include "computeMeanFields.H" // Compute vorticity and second-invariant of velocity gradient tensor. omega = fvc::curl(U); Q = 0.5*(sqr(tr(fvc::grad(U))) - tr(((fvc::grad(U))&(fvc::grad(U))))); // Update the solution field if necessary. runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" # include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" # include "CourantNo.H" fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) ); solve(UEqn == -fvc::grad(p)); // --- PISO loop for (int corr = 0; corr < nCorr; corr++) { volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); adjustPhi(phi, U, p); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include "continuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "readTransportProperties.H" #include "createFields.H" #include "initContinuityErrs.H" #include "createGradP.H" Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "CourantNo.H" sgsModel->correct(); fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) + sgsModel->divDevBeff(U) == flowDirection*gradP ); if (momentumPredictor) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop volScalarField rUA = 1.0/UEqn.A(); for (int corr=0; corr<nCorr; corr++) { U = rUA*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); adjustPhi(phi, U, p); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); if (corr == nCorr-1 && nonOrth == nNonOrthCorr) { pEqn.solve(mesh.solver(p.name() + "Final")); } else { pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } #include "continuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } // Correct driving force for a constant mass flow rate // Extract the velocity in the flow direction dimensionedScalar magUbarStar = (flowDirection & U)().weightedAverage(mesh.V()); // Calculate the pressure gradient increment needed to // adjust the average flow-rate to the correct value dimensionedScalar gragPplus = (magUbar - magUbarStar)/rUA.weightedAverage(mesh.V()); U += flowDirection*rUA*gragPplus; gradP += gragPplus; Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab << "pressure gradient = " << gradP.value() << endl; runTime.write(); #include "writeGradP.H" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { argList::addOption ( "pName", "pName", "Name of the pressure field" ); argList::addBoolOption ( "initialiseUBCs", "Initialise U boundary conditions" ); argList::addBoolOption ( "writePhi", "Write the velocity potential field" ); argList::addBoolOption ( "writep", "Calculate and write the pressure field" ); argList::addBoolOption ( "withFunctionObjects", "execute functionObjects" ); #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" pisoControl potentialFlow(mesh, "potentialFlow"); #include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< nl << "Calculating potential flow" << endl; // Since solver contains no time loop it would never execute // function objects so do it ourselves runTime.functionObjects().start(); MRF.makeRelative(phi); adjustPhi(phi, U, p); // Non-orthogonal velocity potential corrector loop while (potentialFlow.correctNonOrthogonal()) { fvScalarMatrix PhiEqn ( fvm::laplacian(dimensionedScalar("1", dimless, 1), Phi) == fvc::div(phi) ); PhiEqn.setReference(PhiRefCell, PhiRefValue); PhiEqn.solve(); if (potentialFlow.finalNonOrthogonalIter()) { phi -= PhiEqn.flux(); } } MRF.makeAbsolute(phi); Info<< "Continuity error = " << mag(fvc::div(phi))().weightedAverage(mesh.V()).value() << endl; U = fvc::reconstruct(phi); U.correctBoundaryConditions(); Info<< "Interpolated velocity error = " << (sqrt(sum(sqr(fvc::flux(U) - phi)))/sum(mesh.magSf())).value() << endl; // Write U and phi U.write(); phi.write(); // Optionally write Phi if (args.optionFound("writePhi")) { Phi.write(); } // Calculate the pressure field if (args.optionFound("writep")) { Info<< nl << "Calculating approximate pressure field" << endl; label pRefCell = 0; scalar pRefValue = 0.0; setRefCell ( p, potentialFlow.dict(), pRefCell, pRefValue ); // Calculate the flow-direction filter tensor volScalarField magSqrU(magSqr(U)); volSymmTensorField F(sqr(U)/(magSqrU + SMALL*average(magSqrU))); // Calculate the divergence of the flow-direction filtered div(U*U) // Filtering with the flow-direction generates a more reasonable // pressure distribution in regions of high velocity gradient in the // direction of the flow volScalarField divDivUU ( fvc::div ( F & fvc::div(phi, U), "div(div(phi,U))" ) ); // Solve a Poisson equation for the approximate pressure while (potentialFlow.correctNonOrthogonal()) { fvScalarMatrix pEqn ( fvm::laplacian(p) + divDivUU ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); } p.write(); } runTime.functionObjects().end(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createDynamicFvMesh.H" # include "initContinuityErrs.H" # include "initTotalVolume.H" # include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { # include "readControls.H" # include "checkTotalVolume.H" # include "CourantNo.H" // Make the fluxes absolute fvc::makeAbsolute(phi, U); # include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; bool meshChanged = mesh.update(); # include "volContinuity.H" if (correctPhi && meshChanged) { // Fluxes will be corrected to absolute velocity // HJ, 6/Feb/2009 # include "correctPhi.H" } // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); if (checkMeshCourantNo) { # include "meshCourantNo.H" } // --- SIMPLE loop for (int ocorr = 0; ocorr < nOuterCorr; ocorr++) { # include "CourantNo.H" # include "UEqn.H" rAU = 1.0/UEqn.A(); U = rAU*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()); //+ fvc::ddtPhiCorr(rAU, U, phi); adjustPhi(phi, U, p); p.storePrevIter(); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rAU, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); if ( ocorr == nOuterCorr - 1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver(p.name() + "Final")); } else { pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include "continuityErrs.H" // Explicitly relax pressure for momentum corrector p.relax(); // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return(0); }
//--------------------------------------------------------------------------- int main(int argc, char *argv[]) { argList args = setRootCase( argc, argv ); TimeHolder runTime=createTime( Time::controlDictName, args ); fvMeshHolder mesh = createMeshNoClear( runTime ); singlePhaseTransportModelHolder fluid; volScalarFieldHolder p; volVectorFieldHolder U; surfaceScalarFieldHolder phi; label pRefCell = 0; scalar pRefValue = 0.0; createFields( runTime, mesh, fluid, p, U, phi, pRefCell, pRefValue ); scalar cumulativeContErr = initContinuityErrs(); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime->loop()) { Info<< "Time = " << runTime->timeName() << nl << endl; dictionary pisoDict; int nOuterCorr; int nCorr; int nNonOrthCorr; bool momentumPredictor; bool transonic; readPISOControls( mesh, pisoDict, nOuterCorr, nCorr, nNonOrthCorr, momentumPredictor, transonic); scalar CoNum; scalar meanCoNum; CourantNo( runTime, mesh, phi, CoNum, meanCoNum ); fluid->correct(); smart_tmp< fvVectorMatrix > UEqn( fvm::ddt( U() ) + fvm::div( phi(), U() ) - fvm::laplacian( fluid->nu(), U() ) ); solve( UEqn() == -fvc::grad( p() )); // --- PISO loop for (int corr=0; corr<nCorr; corr++) { smart_tmp< volScalarField > rAU( 1.0 / UEqn->A() ); U = rAU() * UEqn->H(); phi = ( fvc::interpolate( U() ) & mesh->Sf() ) + fvc::ddtPhiCorr( rAU(), U(), phi() ); adjustPhi(phi, U, p); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { smart_tmp< fvScalarMatrix > pEqn( fvm::laplacian( rAU(), p() ) == fvc::div( phi() ) ); pEqn->setReference( pRefCell, pRefValue ); pEqn->solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn->flux(); } } continuityErrors( runTime, mesh, phi, cumulativeContErr ); U -= rAU() * fvc::grad( p() ); U->correctBoundaryConditions(); } runTime->write(); Info << "ExecutionTime = " << runTime->elapsedCpuTime() << " s" << " ClockTime = " << runTime->elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #if defined(version30) pisoControl piso(mesh); #include "createTimeControls.H" #endif #include "createFields.H" #include "initContinuityErrs.H" #include "createFvOptions.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int flag; MPI_Initialized(&flag); if (!flag) { int argc = 0; char **argv = NULL; MPI_Init(&argc,&argv); } int proc_name; MPI_Comm_rank(MPI_COMM_WORLD,&proc_name); # include "c3po_modifications_1.H" Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #if defined(version30) #include "readTimeControls.H" #include "CourantNo.H" #include "setDeltaT.H" #else #include "readPISOControls.H" #include "CourantNo.H" #endif // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) + turbulence->divDevReff(U) - fvOptions(U) ); UEqn.relax(); #if defined(version30) if (piso.momentumPredictor()) #else if (momentumPredictor) #endif { solve(UEqn == -fvc::grad(p)); } // --- PISO loop #if defined(version30) while (piso.correct()) #else int nCorrSoph = nCorr + 5 * pow((1-particleCloud.dataExchangeM().timeStepFraction()),1); for (int corr=0; corr<nCorrSoph; corr++) #endif { volScalarField rAU(1.0/UEqn.A()); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); surfaceScalarField phiHbyA ( "phiHbyA", (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi) ); adjustPhi(phiHbyA, U, p); // Non-orthogonal pressure corrector loop #if defined(version30) while (piso.correctNonOrthogonal()) #else for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) #endif { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rAU, p) == fvc::div(phiHbyA) ); pEqn.setReference(pRefCell, pRefValue); #if defined(version30) pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); #else if( corr == nCorr-1 && nonOrth == nNonOrthCorr ) pEqn.solve(mesh.solver("pFinal")); else pEqn.solve(); #endif } #include "continuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); } } turbulence->correct(); //In this example CPPPO is called when OF writes data to disk if(runTime.write()) { # include "c3po_modifications_2.H" runTime.write(); } Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } # include "c3po_modifications_3.H" Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "postProcess.H" #include "setRootCase.H" #include "createTime.H" #include "createMeshNoClear.H" #include "createControl.H" #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "CourantNo.H" fluid.correct(); // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(fluid.nu(), U) - (fvc::grad(U) & fvc::grad(fluid.nu())) ); if (piso.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop while (piso.correct()) { volScalarField rAU(1.0/UEqn.A()); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); surfaceScalarField phiHbyA ( "phiHbyA", fvc::flux(HbyA) + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi) ); adjustPhi(phiHbyA, U, p); // Update the pressure BCs to ensure flux consistency constrainPressure(p, U, phiHbyA, rAU); // Non-orthogonal pressure corrector loop while (piso.correctNonOrthogonal()) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rAU, p) == fvc::div(phiHbyA) ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); if (piso.finalNonOrthogonalIter()) { phi = phiHbyA - pEqn.flux(); } } #include "continuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" # include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; for (runTime++; !runTime.end(); runTime++) { Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSIMPLEControls.H" p.storePrevIter(); // Pressure-velocity SIMPLE corrector { // Momentum predictor tmp<fvVectorMatrix> UEqn ( fvm::div(phi, U) + turbulence->divDevReff(U) ); mrfZones.addCoriolis(UEqn()); UEqn().relax(); solve(UEqn() == -fvc::grad(p)); p.boundaryField().updateCoeffs(); volScalarField rAU = 1.0/UEqn().A(); U = rAU*UEqn().H(); UEqn.clear(); phi = fvc::interpolate(U, "interpolate(HbyA)") & mesh.Sf(); mrfZones.relativeFlux(phi); adjustPhi(phi, U, p); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rAU, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include "continuityErrs.H" // Explicitly relax pressure for momentum corrector p.relax(); // Momentum corrector U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); } turbulence->correct(); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return(0); }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" #include "createFields.H" #include "initContinuityErrs.H" #if defined(version22) #include "createFvOptions.H" #endif // create cfdemCloud #include "readGravitationalAcceleration.H" cfdemCloudIB particleCloud(mesh); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; //=== dyM =================== interFace = mag(mesh.lookupObject<volScalarField>("voidfractionNext")); mesh.update(); //dyM #include "readPISOControls.H" #include "CourantNo.H" // do particle stuff Info << "- evolve()" << endl; particleCloud.evolve(); // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(voidfraction,U) + fvm::div(phi, U) + turbulence->divDevReff(U) #if defined(version22) == fvOptions(U) #endif ); UEqn.relax(); #if defined(version22) fvOptions.constrain(UEqn); #endif if (momentumPredictor) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop for (int corr=0; corr<nCorr; corr++) { volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); #ifdef version23 phi = (fvc::interpolate(U) & mesh.Sf()); // there is a new version in 23x #else phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); #endif adjustPhi(phi, U, p); #if defined(version22) fvOptions.relativeFlux(phi); #endif // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) + particleCloud.ddtVoidfraction() ); pEqn.setReference(pRefCell, pRefValue); if ( corr == nCorr-1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver("pFinal")); } else { pEqn.solve(); } if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } #include "continuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } } turbulence->correct(); Info << "particleCloud.calcVelocityCorrection() " << endl; volScalarField voidfractionNext=mesh.lookupObject<volScalarField>("voidfractionNext"); particleCloud.calcVelocityCorrection(p,U,phiIB,voidfractionNext); #if defined(version22) fvOptions.correct(U); #endif runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" # include "immersedBoundaryInitContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPIMPLEControls.H" # include "CourantNo.H" // Pressure-velocity corrector int oCorr = 0; do { fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) ); UEqn.boundaryManipulate(U.boundaryField()); solve(UEqn == -cellIbMask*fvc::grad(p)); // --- PISO loop for (int corr = 0; corr < nCorr; corr++) { volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); // Immersed boundary update U.correctBoundaryConditions(); phi = faceIbMask*(fvc::interpolate(U) & mesh.Sf()); // Adjust immersed boundary fluxes immersedBoundaryAdjustPhi(phi, U); adjustPhi(phi, U, p); for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); pEqn.boundaryManipulate(p.boundaryField()); pEqn.solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include "immersedBoundaryContinuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } } while (++oCorr < nOuterCorr); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "createFvOptions.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "CourantNo.H" // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) + turbulence->divDevReff(U) ); UEqn.relax(); if (momentumPredictor) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop for (int corr=0; corr<nCorr; corr++) { volScalarField rAU(1.0/UEqn.A()); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); surfaceScalarField phiHbyA ( "phiHbyA", (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::interpolate(rAU)*fvc::ddtCorr(U, phi) ); adjustPhi(phiHbyA, U, p); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rAU, p) == fvc::div(phiHbyA) ); pEqn.setReference(pRefCell, pRefValue); if ( corr == nCorr-1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver("pFinal")); } else { pEqn.solve(); } if (nonOrth == nNonOrthCorr) { phi = phiHbyA - pEqn.flux(); } } #include "continuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); } } turbulence->correct(); /*tmp<fvScalarMatrix> sEqn ( fvm::ddt(s) + fvm::div(phi, s) - fvm::laplacian(Ds, s) ); sources.constrain(sEqn()); solve(sEqn() == sources(s));*/ tmp<fv::convectionScheme<scalar> > mvConvection ( fv::convectionScheme<scalar>::New ( mesh, fields, phi, mesh.divScheme("div(phi,si_h)") ) ); volScalarField kappaEff ( "kappaEff", turbulence->nu()/Pr + turbulence->nut()/Prt ); forAll(s, i) { volScalarField& si = s[i]; tmp<fvScalarMatrix> siEqn ( fvm::ddt(si) + mvConvection->fvmDiv(phi, si) - fvm::laplacian(kappaEff, si) == fvOptions(si) ); fvOptions.constrain(siEqn()); solve(siEqn(),mesh.solver("si")); fvOptions.correct(si); } //create scalar Fields u*s for averaging forAll(us, i) { us[i]=U*s[i]; }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createEngineTime.H" # include "createDynamicFvMesh.H" # include "initContinuityErrs.H" # include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { # include "readControls.H" # include "checkTotalVolume.H" # include "CourantNo.H" // Make the fluxes absolute fvc::makeAbsolute(phi, U); # include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; bool meshChanged = mesh.update(); reduce(meshChanged, orOp<bool>()); if (meshChanged) { # include "checkTotalVolume.H" # include "correctPhi.H" # include "CourantNo.H" } // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); if (checkMeshCourantNo) { # include "meshCourantNo.H" } # include "UEqn.H" // --- PISO loop for (int corr = 0; corr < nCorr; corr++) { rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()); //+ fvc::ddtPhiCorr(rUA, U, phi); adjustPhi(phi, U, p); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); if (corr == nCorr - 1 && nonOrth == nNonOrthCorr) { pEqn.solve(mesh.solutionDict().solver(p.name() + "Final")); } else { pEqn.solve(mesh.solutionDict().solver(p.name())); } if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include "continuityErrs.H" // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } turbulence->correct(); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return(0); }
int main(int argc, char *argv[]) { # include <OpenFOAM/setRootCase.H> # include <OpenFOAM/createTime.H> # include <OpenFOAM/createMesh.H> # include "createFields.H" # include <finiteVolume/initContinuityErrs.H> //mesh.clearPrimitives(); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; for (runTime++; !runTime.end(); runTime++) { Info<< "Time = " << runTime.timeName() << nl << endl; # include <finiteVolume/readSIMPLEControls.H> p.storePrevIter(); // Pressure-velocity SIMPLE corrector { // Momentum predictor tmp<fvVectorMatrix> UrelEqn ( fvm::div(phi, Urel) + turbulence->divDevReff(Urel) + SRF->Su() ); UrelEqn().relax(); solve(UrelEqn() == -fvc::grad(p)); p.boundaryField().updateCoeffs(); volScalarField AUrel = UrelEqn().A(); Urel = UrelEqn().H()/AUrel; UrelEqn.clear(); phi = fvc::interpolate(Urel) & mesh.Sf(); adjustPhi(phi, Urel, p); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(1.0/AUrel, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include <finiteVolume/continuityErrs.H> // Explicitly relax pressure for momentum corrector p.relax(); // Momentum corrector Urel -= fvc::grad(p)/AUrel; Urel.correctBoundaryConditions(); } turbulence->correct(); if (runTime.outputTime()) { volVectorField Uabs ( IOobject ( "Uabs", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), Urel + SRF->U() ); runTime.write(); } Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return(0); }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" # include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" # include "CourantNo.H" // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) + turbulence->divDevReff(U) ); UEqn.relax(); if (momentumPredictor) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop for (int corr=0; corr<nCorr; corr++) { volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); adjustPhi(phi, U, p); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); if ( corr == nCorr-1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver("pFinal")); } else { pEqn.solve(); } if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include "continuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } } turbulence->correct(); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" simpleControl simple(mesh); #include "createFields.H" #include "initContinuityErrs.H" Info<< "\nStarting time loop\n" << endl; while (simple.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; curvature.correctBoundaryConditions(); /** temperature equation */ fvScalarMatrix TEqn( fvm::laplacian(0.5 * gamma2 * sqrt(T), T) == fvc::div(U) ); TEqn.solve(); /** SIMPLE algorithm for solving pressure-velocity equations */ /** velocity predictor */ tmp<fvVectorMatrix> tUEqn( fvm::div(phi, U) - fvm::laplacian(0.5 * gamma1 * sqrt(T), U) == 0.5 * gamma1 * fvc::div(sqrt(T) * dev2(::T(fvc::grad(U)))) ); fvVectorMatrix& UEqn = tUEqn.ref(); UEqn.relax(); solve(UEqn == fvc::reconstruct(( - fvc::snGrad(p2) + gamma7 * fvc::snGrad(T) * fvc::interpolate( (U / gamma2 / sqrt(T) - 0.25*fvc::grad(T)) & fvc::grad(T)/T ) ) * mesh.magSf()) ); /** pressure corrector */ volScalarField rAU(1./UEqn.A()); surfaceScalarField rAUbyT("rhorAUf", fvc::interpolate(rAU / T)); volVectorField HbyA("HbyA", U); HbyA = rAU * UEqn.H(); tUEqn.clear(); surfaceScalarField phiHbyA("phiHbyA", fvc::interpolate(HbyA / T) & mesh.Sf()); adjustPhi(phiHbyA, U, p2); surfaceScalarField phif( gamma7 * rAUbyT * fvc::snGrad(T) * mesh.magSf() * fvc::interpolate( (U / gamma2 / sqrt(T) - 0.25*fvc::grad(T)) & fvc::grad(T)/T ) ); phiHbyA += phif; // Update the fixedFluxPressure BCs to ensure flux consistency setSnGrad<fixedFluxPressureFvPatchScalarField> ( p2.boundaryFieldRef(), phiHbyA.boundaryField() / (mesh.magSf().boundaryField() * rAUbyT.boundaryField()) ); while (simple.correctNonOrthogonal()) { fvScalarMatrix pEqn( fvm::laplacian(rAUbyT, p2) == fvc::div(phiHbyA) ); pEqn.setReference(pRefCell, getRefCellValue(p2, pRefCell)); pEqn.solve(); if (simple.finalNonOrthogonalIter()) { // Calculate the conservative fluxes phi = phiHbyA - pEqn.flux(); p2.relax(); /** velocity corrector */ U = HbyA + rAU * fvc::reconstruct((phif - pEqn.flux()) / rAUbyT); U.correctBoundaryConditions(); } } #include "continuityErrs.H" // Pressure is defined up to a constant factor, // we adjust it to maintain the initial domainIntegrate p2 += (initialPressure - fvc::domainIntegrate(p2)) / totalVolume; runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" # include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; for (runTime++; !runTime.end(); runTime++) { Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" # include "CourantNo.H" fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) ); fvVectorMatrix UEqnp(UEqn == -fvc::grad(p)); lduVectorMatrix U3Eqnp(mesh); U3Eqnp.diag() = UEqnp.diag(); U3Eqnp.upper() = UEqnp.upper(); U3Eqnp.lower() = UEqnp.lower(); U3Eqnp.source() = UEqnp.source(); UEqnp.addBoundaryDiag(U3Eqnp.diag(), 0); UEqnp.addBoundarySource(U3Eqnp.source(), false); autoPtr<lduVectorMatrix::solver> U3EqnpSolver = lduVectorMatrix::solver::New ( U.name(), U3Eqnp, dictionary ( IStringStream ( "{" " solver PBiCG;" " preconditioner DILU;" " tolerance (1e-13 1e-13 1e-13);" " relTol (0 0 0);" "}" )() ) ); U3EqnpSolver->solve(U).print(Info); // --- PISO loop for (int corr=0; corr<nCorr; corr++) { volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); adjustPhi(phi, U, p); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) ); pEqn.setReference(pRefCell, pRefValue); pEqn.solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include "continuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return(0); }
//--------------------------------------------------------------------------- void fun_pEqn( const fvMeshHolder& mesh, const TimeHolder& runTime, const simpleControlHolder& simple, volScalarFieldHolder& p, volScalarFieldHolder& rhok, volVectorFieldHolder& U, surfaceScalarFieldHolder& phi, incompressible::RASModelHolder& turbulence, volScalarFieldHolder& gh, surfaceScalarFieldHolder& ghf, volScalarFieldHolder& p_rgh, fvVectorMatrixHolder& UEqn, label& pRefCell, scalar& pRefValue, scalar& cumulativeContErr ) { volScalarField rAU("rAU", 1.0/UEqn->A()); surfaceScalarField rAUf("(1|A(U))", fvc::interpolate( rAU ) ); U = rAU * UEqn->H(); phi = fvc::interpolate( U() ) & mesh->Sf(); adjustPhi(phi, U, p_rgh); smart_tmp< surfaceScalarField > buoyancyPhi( rAUf * ghf() * fvc::snGrad( rhok() ) * mesh->magSf() ); phi -= buoyancyPhi(); for (int nonOrth=0; nonOrth<=simple->nNonOrthCorr(); nonOrth++) { smart_tmp< fvScalarMatrix > p_rghEqn = fvm::laplacian( rAUf, p_rgh() ) == fvc::div( phi() ); p_rghEqn->setReference( pRefCell, getRefCellValue( p_rgh, pRefCell ) ); p_rghEqn->solve(); if ( nonOrth == simple->nNonOrthCorr() ) { // Calculate the conservative fluxes phi -= p_rghEqn->flux(); // Explicitly relax pressure for momentum corrector p_rgh->relax(); // Correct the momentum source with the pressure gradient flux // calculated from the relaxed pressure U -= rAU * fvc::reconstruct( ( buoyancyPhi() + p_rghEqn->flux() ) / rAUf ); U->correctBoundaryConditions(); } } continuityErrors( runTime, mesh, phi, cumulativeContErr ); p = p_rgh + rhok * gh; if ( p_rgh->needReference() ) { p += dimensionedScalar( "p", p->dimensions(), pRefValue - getRefCellValue( p(), pRefCell ) ); p_rgh = p - rhok * gh; } }