int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< nl << "Starting time loop" << endl; while (runTime.loop()) { #include "readPISOControls.H" #include "readBPISOControls.H" Info<< "Time = " << runTime.timeName() << nl << endl; #include "CourantNo.H" { fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvc::div(phiB, 2.0*DBU*B) - fvm::laplacian(nu, U) + fvc::grad(DBU*magSqr(B)) ); solve(UEqn == -fvc::grad(p)); // --- PISO loop for (int corr=0; corr<nCorr; corr++) { volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); surfaceScalarField phiHbyA ( "phiHbyA", (fvc::interpolate(HbyA) & mesh.Sf()) + rAUf*fvc::ddtCorr(U, phi) ); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(rAUf, 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(); } } // --- B-PISO loop for (int Bcorr=0; Bcorr<nBcorr; Bcorr++) { fvVectorMatrix BEqn ( fvm::ddt(B) + fvm::div(phi, B) - fvc::div(phiB, U) - fvm::laplacian(DB, B) ); BEqn.solve(); volScalarField rAB(1.0/BEqn.A()); surfaceScalarField rABf("rABf", fvc::interpolate(rAB)); phiB = (fvc::interpolate(B) & mesh.Sf()) + rABf*fvc::ddtCorr(B, phiB); fvScalarMatrix pBEqn ( fvm::laplacian(rABf, pB) == fvc::div(phiB) ); pBEqn.solve(); phiB -= pBEqn.flux(); #include "magneticFieldErr.H" } runTime.write(); } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMeshNoClear.H" #include "readTransportProperties.H" #include "createFields.H" #include "readTurbulenceProperties.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< nl << "Starting time loop" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" force.internalField() = ReImSum ( fft::reverseTransform ( K/(mag(K) + 1.0e-6) ^ forceGen.newField(), K.nn() ) ); #include "globalProperties.H" fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(nu, U) == force ); solve(UEqn == -fvc::grad(p)); // --- PISO loop for (int corr=1; corr<=1; corr++) { volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); surfaceScalarField phiHbyA ( "phiHbyA", (fvc::interpolate(HbyA) & mesh.Sf()) + rAUf*fvc::ddtCorr(U, phi) ); fvScalarMatrix pEqn ( fvm::laplacian(rAUf, p) == fvc::div(phiHbyA) ); pEqn.solve(); phi = phiHbyA - pEqn.flux(); #include "continuityErrs.H" U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); if (runTime.outputTime()) { calcEk(U, K).write ( runTime.path()/"graphs"/runTime.timeName(), "Ek", runTime.graphFormat() ); } Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { #include "postProcess.H" #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createControl.H" #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< nl << "Starting time loop" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "CourantNo.H" { fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U) - fvc::div(phiB, 2.0*DBU*B) - fvm::laplacian(nu, U) + fvc::grad(DBU*magSqr(B)) ); if (piso.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop while (piso.correct()) { volScalarField rAU(1.0/UEqn.A()); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p)); surfaceScalarField phiHbyA ( "phiHbyA", fvc::flux(HbyA) + rAUf*fvc::ddtCorr(U, phi) ); // Update the pressure BCs to ensure flux consistency constrainPressure(p, U, phiHbyA, rAUf); while (piso.correctNonOrthogonal()) { fvScalarMatrix pEqn ( fvm::laplacian(rAUf, 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(); } } // --- B-PISO loop while (bpiso.correct()) { fvVectorMatrix BEqn ( fvm::ddt(B) + fvm::div(phi, B) - fvc::div(phiB, U) - fvm::laplacian(DB, B) ); BEqn.solve(); volScalarField rAB(1.0/BEqn.A()); surfaceScalarField rABf("rABf", fvc::interpolate(rAB)); phiB = fvc::flux(B) + rABf*fvc::ddtCorr(B, phiB); while (bpiso.correctNonOrthogonal()) { fvScalarMatrix pBEqn ( fvm::laplacian(rABf, pB) == fvc::div(phiB) ); pBEqn.solve(mesh.solver(pB.select(bpiso.finalInnerIter()))); if (bpiso.finalNonOrthogonalIter()) { phiB -= pBEqn.flux(); } } #include "magneticFieldErr.H" } runTime.write(); } 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; } }