tmp<Foam::fvVectorMatrix> kinematicSingleLayer::solveMomentum ( const volScalarField& pu, const volScalarField& pp ) { if (debug) { InfoInFunction << endl; } // Momentum tmp<fvVectorMatrix> tUEqn ( fvm::ddt(deltaRho_, U_) + fvm::div(phi_, U_) == - USp_ // - fvm::SuSp(rhoSp_, U_) - rhoSp_*U_ + forces_.correct(U_) + turbulence_->Su(U_) ); fvVectorMatrix& UEqn = tUEqn.ref(); UEqn.relax(); if (momentumPredictor_) { solve ( UEqn == fvc::reconstruct ( - fvc::interpolate(delta_) * ( regionMesh().magSf() * ( fvc::snGrad(pu, "snGrad(p)") + fvc::snGrad(pp, "snGrad(p)")*fvc::interpolate(delta_) + fvc::snGrad(delta_)*fvc::interpolate(pp) ) - fvc::flux(rho_*gTan()) ) ) ); // Remove any patch-normal components of velocity U_ -= nHat()*(nHat() & U_); U_.correctBoundaryConditions(); } return tUEqn; }
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; }