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 "createFvOptions.H" #include "initContinuityErrs.H" // create cfdemCloud #include "readGravitationalAcceleration.H" #include "checkImCoupleM.H" #if defined(anisotropicRotation) cfdemCloudRotation particleCloud(mesh); #elif defined(superquadrics_flag) cfdemCloudRotationSuperquadric particleCloud(mesh); #else cfdemCloud particleCloud(mesh); #endif #include "checkModelType.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 // do particle stuff particleCloud.clockM().start(1,"Global"); particleCloud.clockM().start(2,"Coupling"); bool hasEvolved = particleCloud.evolve(voidfraction,Us,U); if(hasEvolved) { particleCloud.smoothingM().smoothenAbsolutField(particleCloud.forceM(0).impParticleForces()); } Ksl = particleCloud.momCoupleM(particleCloud.registryM().getProperty("implicitCouple_index")).impMomSource(); Ksl.correctBoundaryConditions(); surfaceScalarField voidfractionf = fvc::interpolate(voidfraction); phi = voidfractionf*phiByVoidfraction; //Force Checks #include "forceCheckIm.H" #include "solverDebugInfo.H" particleCloud.clockM().stop("Coupling"); particleCloud.clockM().start(26,"Flow"); if(particleCloud.solveFlow()) { // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(voidfraction,U) - fvm::Sp(fvc::ddt(voidfraction),U) + fvm::div(phi,U) - fvm::Sp(fvc::div(phi),U) // + turbulence->divDevReff(U) + particleCloud.divVoidfractionTau(U, voidfraction) == - fvm::Sp(Ksl/rho,U) + fvOptions(U) ); UEqn.relax(); fvOptions.constrain(UEqn); #if defined(version30) if (piso.momentumPredictor()) #else if (momentumPredictor) #endif { if (modelType=="B" || modelType=="Bfull") solve(UEqn == - fvc::grad(p) + Ksl/rho*Us); else solve(UEqn == - voidfraction*fvc::grad(p) + Ksl/rho*Us); fvOptions.correct(U); } // --- PISO loop #if defined(version30) while (piso.correct()) #else for (int corr=0; corr<nCorr; corr++) #endif { volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA)); volScalarField rUAvoidfraction("(voidfraction2|A(U))",rUA*voidfraction); surfaceScalarField rUAfvoidfraction("(voidfraction2|A(U)F)", fvc::interpolate(rUAvoidfraction)); U = rUA*UEqn.H(); #ifdef version23 phi = ( fvc::interpolate(U) & mesh.Sf() ) + rUAfvoidfraction*fvc::ddtCorr(U, phiByVoidfraction); #else phi = ( fvc::interpolate(U) & mesh.Sf() ) + fvc::ddtPhiCorr(rUAvoidfraction, U, phiByVoidfraction); #endif surfaceScalarField phiS(fvc::interpolate(Us) & mesh.Sf()); phi += rUAf*(fvc::interpolate(Ksl/rho) * phiS); if (modelType=="A") rUAvoidfraction = volScalarField("(voidfraction2|A(U))",rUA*voidfraction*voidfraction); // Update the fixedFluxPressure BCs to ensure flux consistency #include "fixedFluxPressureHandling.H" // 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(rUAvoidfraction, p) == fvc::div(voidfractionf*phi) + particleCloud.ddtVoidfraction() ); pEqn.setReference(pRefCell, pRefValue); #if defined(version30) pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); if (piso.finalNonOrthogonalIter()) { phiByVoidfraction = phi - pEqn.flux()/voidfractionf; } #else if( corr == nCorr-1 && nonOrth == nNonOrthCorr ) #if defined(versionExt32) pEqn.solve(mesh.solutionDict().solver("pFinal")); #else pEqn.solve(mesh.solver("pFinal")); #endif else pEqn.solve(); if (nonOrth == nNonOrthCorr) { phiByVoidfraction = phi - pEqn.flux()/voidfractionf; } #endif } // end non-orthogonal corrector loop phi = voidfractionf*phiByVoidfraction; #include "continuityErrorPhiPU.H" if (modelType=="B" || modelType=="Bfull") U -= rUA*fvc::grad(p) - Ksl/rho*Us*rUA; else U -= voidfraction*rUA*fvc::grad(p) - Ksl/rho*Us*rUA; U.correctBoundaryConditions(); fvOptions.correct(U); } // end piso loop }
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; }
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 "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 "createDynamicFvMesh.H" # include "createFields.H" # include "initContinuityErrs.H" # include "createBubble.H" # include "createSurfactantConcentrationField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info << "\nStarting time loop\n" << endl; for (runTime++; !runTime.end(); runTime++) { Info << "Time = " << runTime.value() << endl << endl; # include "readPISOControls.H" interface.moveMeshPointsForOldFreeSurfDisplacement(); interface.updateDisplacementDirections(); interface.predictPoints(); Info<< "\nMax surface Courant Number = " << interface.maxCourantNumber() << endl << endl; for (int corr=0; corr<nOuterCorr; corr++) { // Update interface bc interface.updateBoundaryConditions(); // Make the fluxes relative phi -= fvc::meshPhi(rho, U); # include "CourantNo.H" fvVectorMatrix UEqn ( fvm::ddt(rho, U) + rho*aF + fvm::div(fvc::interpolate(rho)*phi, U, "div(phi,U)") - fvm::laplacian(mu, U) ); solve(UEqn == -fvc::grad(p)); // --- PISO loop for (int i=0; i<nCorr; i++) { volScalarField AU = UEqn.A(); U = UEqn.H()/AU; phi = (fvc::interpolate(U) & mesh.Sf()); # include "scalePhi.H" # include "scaleSpacePhi.H" // Non-orthogonal pressure corrector loop for (label nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn ( fvm::laplacian(1.0/AU, p) == fvc::div(phi) ); # include "setReference.H" pEqn.solve(); if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } # include "continuityErrs.H" // Momentum corrector U -= fvc::grad(p)/AU; U.correctBoundaryConditions(); } # include "solveBulkSurfactant.H" interface.correctPoints(); # include "freeSurfaceContinuityErrs.H" } # include "updateMovingReferenceFrame.H" # include "volContinuity.H" Info << "Total surface tension force: " << interface.totalSurfaceTensionForce() << endl; vector totalForce = interface.totalViscousForce() + interface.totalPressureForce(); Info << "Total force: " << totalForce << endl; runTime.write(); Info << "ExecutionTime = " << scalar(runTime.elapsedCpuTime()) << " s\n" << endl << 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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nCalculating displacement field\n" << endl; volScalarField rho = rheology.rho(); // Force n-sqaured projection // polyPatch::setNSquaredProjection(true); while (runTime.loop()) { Info<< "Iteration: " << runTime.timeName() << nl << endl; # include "readStressedFoamControls.H" volScalarField mu = rheology.mu(); volScalarField lambda = rheology.lambda(); int iCorr=0; scalar initialResidual=0; contact.correct(); do { fvVectorMatrix UEqn ( fvm::d2dt2(rho, U) == fvm::laplacian(2*mu + lambda, U, "laplacian(DU,U)") + fvc::div ( mu*gradU.T() + lambda*(I*tr(gradU)) - (mu + lambda)*gradU, "div(sigma)" ) ); # include "setComponentReference.H" initialResidual = UEqn.solve().initialResidual(); gradU = fvc::grad(U); # include "calculateSigma.H" rheology.correct(); rho = rheology.rho(); mu = rheology.mu(); lambda = rheology.lambda(); } while (initialResidual > convergenceTolerance && ++iCorr < nCorr); # include "calculateStress.H" # include "calculateContactArea.H" 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 "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[]) { argList::noParallel(); #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "createFvOptions.H" #include "interrogateWallPatches.H" turbulence->validate(); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; fvVectorMatrix divR(turbulence->divDevReff(U)); divR.source() = flowMask & divR.source(); fvVectorMatrix UEqn ( divR == gradP + fvOptions(U) ); UEqn.relax(); fvOptions.constrain(UEqn); UEqn.solve(); fvOptions.correct(U); // Correct driving force for a constant volume flow rate dimensionedVector UbarStar = flowMask & U.weightedAverage(mesh.V()); U += (Ubar - UbarStar); gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V()); laminarTransport.correct(); turbulence->correct(); Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value()) << ", pressure gradient = " << (flowDirection & gradP.value()) << endl; #include "evaluateNearWall.H" if (runTime.writeTime()) { #include "makeGraphs.H" } 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 "createCrackerMesh.H" # include "createFields.H" # include "createCrack.H" //# include "createReference.H" # include "createHistory.H" # include "readDivSigmaExpMethod.H" # include "createSolidInterfaceNoModify.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; lduMatrix::debug = 0; scalar maxEffTractionFraction = 0; // time rates for predictor volTensorField gradV = fvc::ddt(gradU); surfaceVectorField snGradV = (snGradU - snGradU.oldTime())/runTime.deltaT(); //# include "initialiseSolution.H" while (runTime.run()) { # include "readSolidMechanicsControls.H" # include "setDeltaT.H" runTime++; Info<< "\nTime: " << runTime.timeName() << " s\n" << endl; volScalarField rho = rheology.rho(); volDiagTensorField K = rheology.K(); surfaceDiagTensorField Kf = fvc::interpolate(K, "K"); volSymmTensor4thOrderField C = rheology.C(); surfaceSymmTensor4thOrderField Cf = fvc::interpolate(C, "C"); solidInterfacePtr->modifyProperties(Cf, Kf); //# include "waveCourantNo.H" int iCorr = 0; lduMatrix::solverPerformance solverPerf; scalar initialResidual = 0; scalar relativeResidual = 1; //scalar forceResidual = 1; label nFacesToBreak = 0; label nCoupledFacesToBreak = 0; bool topoChange = false; //bool noMoreCracks = false; // Predictor step using time rates if (predictor) { Info << "Predicting U, gradU and snGradU using velocity" << endl; U += V*runTime.deltaT(); gradU += gradV*runTime.deltaT(); snGradU += snGradV*runTime.deltaT(); } do { surfaceVectorField n = mesh.Sf()/mesh.magSf(); do { U.storePrevIter(); # include "calculateDivSigmaExp.H" fvVectorMatrix UEqn ( rho*fvm::d2dt2(U) == fvm::laplacian(Kf, U, "laplacian(K,U)") + divSigmaExp ); //# include "setReference.H" if(solidInterfacePtr) { solidInterfacePtr->correct(UEqn); } if (relaxEqn) { UEqn.relax(); } solverPerf = UEqn.solve(); if (aitkenRelax) { # include "aitkenRelaxation.H" } else { U.relax(); } if (iCorr == 0) { initialResidual = solverPerf.initialResidual(); aitkenInitialRes = gMax(mag(U.internalField())); } //gradU = solidInterfacePtr->grad(U); // use leastSquaresSolidInterface grad scheme gradU = fvc::grad(U); # include "calculateRelativeResidual.H" if (iCorr % infoFrequency == 0) { Info << "\tTime " << runTime.value() << ", Corr " << iCorr << ", Solving for " << U.name() << " using " << solverPerf.solverName() << ", res = " << solverPerf.initialResidual() << ", rel res = " << relativeResidual; if (aitkenRelax) { Info << ", aitken = " << aitkenTheta; } Info << ", inner iters " << solverPerf.nIterations() << endl; } } while ( //iCorr++ == 0 iCorr++ < 10 || ( //solverPerf.initialResidual() > convergenceTolerance relativeResidual > convergenceTolerance && iCorr < nCorr ) ); Info<< "Solving for " << U.name() << " using " << solverPerf.solverName() << ", Initial residual = " << initialResidual << ", Final residual = " << solverPerf.initialResidual() << ", No outer iterations " << iCorr << ", Relative residual " << relativeResidual << endl; # include "calculateTraction.H" # include "updateCrack.H" Info << "Max effective traction fraction: " << maxEffTractionFraction << endl; // reset counter if faces want to crack if ((nFacesToBreak > 0) || (nCoupledFacesToBreak > 0)) iCorr = 0; } while( (nFacesToBreak > 0) || (nCoupledFacesToBreak > 0)); if (cohesivePatchUPtr) { if (returnReduce(cohesivePatchUPtr->size(), sumOp<label>())) { cohesivePatchUPtr->cracking(); } } else { if ( returnReduce ( cohesivePatchUFixedModePtr->size(), sumOp<label>()) ) { Pout << "Number of faces in crack: " << cohesivePatchUFixedModePtr->size() << endl; cohesivePatchUFixedModePtr->relativeSeparationDistance(); } } // update time rates for predictor if (predictor) { V = fvc::ddt(U); gradV = fvc::ddt(gradU); snGradV = (snGradU - snGradU.oldTime())/runTime.deltaT(); } # include "calculateEpsilonSigma.H" # include "writeFields.H" # include "writeHistory.H" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " 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 "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 rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); 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(); } } // --- 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 rBA = 1.0/BEqn.A(); phiB = (fvc::interpolate(B) & mesh.Sf()) + fvc::ddtPhiCorr(rBA, B, phiB); fvScalarMatrix pBEqn ( fvm::laplacian(rBA, pB) == fvc::div(phiB) ); pBEqn.solve(); phiB -= pBEqn.flux(); #include "magneticFieldErr.H" } runTime.write(); } Info<< "End\n" << endl; return 0; }
void SolidSolver::solve() { Info << "Solve solid domain" << endl; scalar iCorr = 0; scalar displacementResidual = 1; scalar initialResidual = 1; lduMatrix::solverPerformance solverPerf; lduMatrix::debug = 0; scalar convergenceTolerance = absoluteTolerance; gradU = fvc::grad( U ); calculateEpsilonSigma(); dimensionedVector gravity( mesh.solutionDict().subDict( "solidMechanics" ).lookup( "gravity" ) ); for ( iCorr = 0; iCorr < maxIter; iCorr++ ) { U.storePrevIter(); tmp<surfaceTensorField> shearGradU = ( (I - n * n) & fvc::interpolate( gradU ) ); fvVectorMatrix UEqn ( rho * fvm::d2dt2( U ) == fvm::laplacian( 2 * muf + lambdaf, U, "laplacian(DU,U)" ) + fvc::div( mesh.magSf() * ( -(muf + lambdaf) * ( fvc::snGrad( U ) & (I - n * n) ) + lambdaf * tr( shearGradU() & (I - n * n) ) * n + muf * (shearGradU() & n) + muf * ( n & fvc::interpolate( gradU & gradU.T() ) ) + 0.5 * lambdaf * ( n * tr( fvc::interpolate( gradU & gradU.T() ) ) ) + ( n & fvc::interpolate( sigma & gradU ) ) ) ) ); // Add gravity UEqn -= rho * gravity; solverPerf = UEqn.solve(); U.relax(); gradU = fvc::grad( U ); calculateEpsilonSigma(); displacementResidual = gSumMag( U.internalField() - U.prevIter().internalField() ) / (gSumMag( U.internalField() ) + SMALL); displacementResidual = max( displacementResidual, solverPerf.initialResidual() ); if ( iCorr == 0 ) { initialResidual = displacementResidual; convergenceTolerance = std::max( relativeTolerance * displacementResidual, absoluteTolerance ); assert( convergenceTolerance > 0 ); } bool convergence = displacementResidual <= convergenceTolerance && iCorr >= minIter - 1; if ( convergence ) break; } lduMatrix::debug = 1; Info << "Solving for " << U.name(); Info << ", Initial residual = " << initialResidual; Info << ", Final residual = " << displacementResidual; Info << ", No outer iterations " << iCorr << endl; }
int main(int argc, char *argv[]) { # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; for (runTime++; !runTime.end(); runTime++) { Info<< "Time = " << runTime.timeName() << nl << endl; fvVectorMatrix divR = turbulence->divDevReff(U); divR.source() = flowMask & divR.source(); fvVectorMatrix UEqn ( divR == gradP ); UEqn.relax(); UEqn.solve(); // Correct driving force for a constant mass flow rate dimensionedVector UbarStar = flowMask & U.weightedAverage(mesh.V()); U += (Ubar - UbarStar); gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V()); scalar wallShearStress = flowDirection & turbulence->R()()[0] & wallNormal; scalar yplusWall = Foam::sqrt(mag(wallShearStress))*y[0]/laminarTransport.nu()[0]; Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())<< tab << "pressure gradient = " << (flowDirection & gradP.value()) << tab << "min y+ = " << yplusWall << endl; turbulence->correct(); if (runTime.outputTime()) { volSymmTensorField R ( IOobject ( "R", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), turbulence->R() ); runTime.write(); const word& gFormat = runTime.graphFormat(); makeGraph(y, flowDirection & U, "Uf", gFormat); makeGraph(y, laminarTransport.nu(), gFormat); makeGraph(y, turbulence->k(), gFormat); makeGraph(y, turbulence->epsilon(), gFormat); //makeGraph(y, flowDirection & R & flowDirection, "Rff", gFormat); //makeGraph(y, wallNormal & R & wallNormal, "Rww", gFormat); //makeGraph(y, flowDirection & R & wallNormal, "Rfw", gFormat); //makeGraph(y, sqrt(R.component(tensor::XX)), "u", gFormat); //makeGraph(y, sqrt(R.component(tensor::YY)), "v", gFormat); //makeGraph(y, sqrt(R.component(tensor::ZZ)), "w", gFormat); makeGraph(y, R.component(tensor::XY), "uv", gFormat); makeGraph(y, mag(fvc::grad(U)), "gammaDot", gFormat); } 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" pimpleControl pimple(mesh); #include "readThermodynamicProperties.H" // #include "readTransportProperties.H" #include "createFields.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readTimeControls.H" #include "compressibleCourantNo.H" solve(fvm::ddt(rho) + fvc::div(phi)); // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) - fvm::laplacian(mu, U) ); solve(UEqn == -fvc::grad(p)); // --- Pressure corrector loop while (pimple.correct()) { volScalarField rAU("rAU", 1.0/UEqn.A()); surfaceScalarField rhorAUf ( "rhorAUf", fvc::interpolate(rho*rAU) ); U = rAU*UEqn.H(); surfaceScalarField phid ( "phid", fvc::interpolate(psi)//psi *( (fvc::interpolate(U) & mesh.Sf()) + rhorAUf*fvc::ddtCorr(rho, U, phi)/fvc::interpolate(rho) ) ); // phi = (rhoO/psi)*phid; phi = (fvc::interpolate(rho0 - psi*p0)/fvc::interpolate(psi))*phid; fvScalarMatrix pEqn ( fvm::ddt(psi, p) + fvc::div(phi) + fvm::div(phid, p) - fvm::laplacian(rhorAUf, p) ); pEqn.solve(); phi += pEqn.flux(); solve(fvm::ddt(rho) + fvc::div(phi)); #include "compressibleContinuityErrs.H" U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); } } // rho = rhoO + psi*p; psi = (a0*pow(p,10) + a1*pow(p,9) + a2*pow(p,8) + a3*pow(p,7) + a4*pow(p,6) + a5*pow(p,5) + a6*pow(p,4) + a7*pow(p,3) + a8*pow(p,2) + a9*p + a10)/p; rho = psi*(p); mu = mu6 * pow(rho,6) + mu5 * pow(rho,5) + mu4 * pow(rho,4) + mu3 * pow(rho,3) + mu2 * pow(rho,2) + mu1 * rho + mu0; 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 <OpenFOAM/setRootCase.H> #include <OpenFOAM/createTime.H> #include <OpenFOAM/createMeshNoClear.H> #include "readTransportProperties.H" #include "createFields.H" #include "readTurbulenceProperties.H" #include <finiteVolume/initContinuityErrs.H> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< nl << "Starting time loop" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include <finiteVolume/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 rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) ); pEqn.solve(); phi -= pEqn.flux(); #include <finiteVolume/continuityErrs.H> U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } runTime.write(); if (runTime.outputTime()) { calcEk(U, K).write(runTime.timePath()/"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 "setRootCase.H" # include "createTime.H" # include "createMesh.H" # include "createFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nCalculating displacement field\n" << endl; volTensorField gradU = fvc::grad(U); for (runTime++; !runTime.end(); runTime++) { Info<< "Iteration: " << runTime.timeName() << nl << endl; # include "../stressedFoam/readStressedFoamControls.H" int iCorr=0; scalar initialResidual=0; # include "contactBoundaries.H" do { # include "tractionBoundaries.H" fvVectorMatrix UEqn ( # ifdef Dynamic fvm::d2dt2(U) == # endif fvm::laplacian(2*mu + lambda, U, "laplacian(DU,U)") + fvc::div ( mu*gradU.T() + lambda*(I*tr(gradU)) - (mu + lambda)*gradU, "div(sigma)" ) ); UEqn.setComponentReference(6, 0, vector::Z, 0); initialResidual = UEqn.solve().initialResidual(); gradU = fvc::grad(U); } while (initialResidual > convergenceTolerance && ++iCorr < nCorr); # include "calculateStress.H" 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 "readDivSigmaExpMethod.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while(runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; # include "readSolidMechanicsControls.H" int iCorr = 0; scalar initialResidual = 1.0; scalar relResT = 1.0; scalar relResU = 1.0; lduMatrix::solverPerformance solverPerfU; lduMatrix::solverPerformance solverPerfT; lduMatrix::debug = 0; // solve energy equation for temperature // the loop is for non-orthogonal corrections Info<< "Solving for " << T.name() << nl; do { T.storePrevIter(); fvScalarMatrix TEqn ( rhoC*fvm::ddt(T) == fvm::laplacian(k, T, "laplacian(k,T)") ); solverPerfT = TEqn.solve(); T.relax(); # include "calculateRelResT.H" if (iCorr % infoFrequency == 0) { Info<< "\tCorrector " << iCorr << ", residual = " << solverPerfT.initialResidual() << ", relative res = " << relResT << ", inner iters = " << solverPerfT.nIterations() << endl; } } while ( relResT > convergenceToleranceT && ++iCorr < nCorr ); Info<< "Solved for " << T.name() << " using " << solverPerfT.solverName() << " in " << iCorr << " iterations" << ", residual = " << solverPerfT.initialResidual() << ", relative res = " << relResT << nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << ", ClockTime = " << runTime.elapsedClockTime() << " s" << endl; // Solve momentum equation for displacement iCorr = 0; volVectorField gradThreeKalphaDeltaT = fvc::grad(threeKalpha*(T-T0), "grad(threeKalphaDeltaT)"); surfaceVectorField threeKalphaDeltaTf = mesh.Sf()*threeKalphaf*fvc::interpolate(T-T0, "deltaT"); Info<< "Solving for " << U.name() << nl; do { U.storePrevIter(); # include "calculateDivSigmaExp.H" // Linear momentum equaiton fvVectorMatrix UEqn ( rho*fvm::d2dt2(U) == fvm::laplacian(2*muf + lambdaf, U, "laplacian(DU,U)") + divSigmaExp ); solverPerfU = UEqn.solve(); if (aitkenRelax) { # include "aitkenRelaxation.H" } else { U.relax(); } gradU = fvc::grad(U); # include "calculateRelResU.H" if (iCorr == 0) { initialResidual = solverPerfU.initialResidual(); } if (iCorr % infoFrequency == 0) { Info<< "\tCorrector " << iCorr << ", residual = " << solverPerfU.initialResidual() << ", relative res = " << relResU; if (aitkenRelax) { Info << ", aitken = " << aitkenTheta; } Info<< ", inner iters = " << solverPerfU.nIterations() << endl; } } while ( iCorr++ == 0 || ( relResU > convergenceToleranceU && iCorr < nCorr ) ); Info<< "Solved for " << U.name() << " using " << solverPerfU.solverName() << " in " << iCorr << " iterations" << ", initial res = " << initialResidual << ", final res = " << solverPerfU.initialResidual() << ", final rel res = " << relResU << nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << ", ClockTime = " << runTime.elapsedClockTime() << " s" << endl; # include "calculateEpsilonSigma.H" # include "writeFields.H" 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 "readThermodynamicProperties.H" // #include "readTransportProperties.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 "compressibleCourantNo.H" #include "rhoEqn.H" fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) - fvm::laplacian(mu, 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(); surfaceScalarField phid ( "phid", fvc::interpolate(psi) *( (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, rho, U, phi) ) ); phi = (fvc::interpolate(rho0 - psi*p0)/fvc::interpolate(psi))*phid; fvScalarMatrix pEqn ( fvm::ddt(psi, p) + fvc::div(phi) + fvm::div(phid, p) - fvm::laplacian(rho*rUA, p) ); pEqn.solve(); phi += pEqn.flux(); #include "compressibleContinuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } // psi = (a0*pow(p,7) + b0*pow(p,6) + c0*pow(p,5) + d0*pow(p,4) + e0*pow(p,3) + f0*pow(p,2) + g0*p + h0) / (p) ; // psi = (a0*pow(p,3) + b0*pow(p,2) + c0*p + d0) / (p - p0) ; // rho = rho0 + psi*(p - p0); // psi = (a0*log(p/b0)+c0)/(p); // rho = psi*(p); psi = (a0*pow(p,10) + a1*pow(p,9) + a2*pow(p,8) + a3*pow(p,7) + a4*pow(p,6) + a5*pow(p,5) + a6*pow(p,4) + a7*pow(p,3) + a8*pow(p,2) + a9*p + a10)/p; rho = psi*(p); mu = mu6 * pow(rho,6) + mu5 * pow(rho,5) + mu4 * pow(rho,4) + mu3 * pow(rho,3) + mu2 * pow(rho,2) + mu1 * rho + mu0; // Info << "rho = " << rho << endl; // Info << "psi = " << psi << endl; //label patchID = mesh.boundaryMesh().findPatchID("walls"); //const polyPatch& cPatch = mesh.boundaryMesh()[patchID]; //vectorField nHat = cPatch.nf(); //vectorField gamma = (nHat & fvc::grad(U)().boundaryField()[patchID]) & (I - sqr(nHat)); 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 "createMeshNoClear.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" fluid.correct(); 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++) { 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 "createFields.H" #include "initContinuityErrs.H" // create cfdemCloud #include "readGravitationalAcceleration.H" cfdemCloud particleCloud(mesh); #include "checkModelType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "CourantNo.H" // do particle stuff bool hasEvolved = particleCloud.evolve(voidfraction,Us,U); if(hasEvolved) { particleCloud.smoothingM().smoothen(particleCloud.forceM(0).impParticleForces()); } Info << "update Ksl.internalField()" << endl; Ksl = particleCloud.momCoupleM(0).impMomSource(); Ksl.correctBoundaryConditions(); #include "solverDebugInfo.H" // get scalar source from DEM particleCloud.forceM(1).manipulateScalarField(Tsource); Tsource.correctBoundaryConditions(); // solve scalar transport equation fvScalarMatrix TEqn ( fvm::ddt(voidfraction,T) - fvm::Sp(fvc::ddt(voidfraction),T) + fvm::div(phi, T) - fvm::Sp(fvc::div(phi),T) - fvm::laplacian(DT*voidfraction, T) == Tsource ); TEqn.relax(); TEqn.solve(); if(particleCloud.solveFlow()) { // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(voidfraction,U) - fvm::Sp(fvc::ddt(voidfraction),U) + fvm::div(phi,U) - fvm::Sp(fvc::div(phi),U) // + turbulence->divDevReff(U) + particleCloud.divVoidfractionTau(U, voidfraction) == - fvm::Sp(Ksl/rho,U) ); UEqn.relax(); if (momentumPredictor && (modelType=="B" || modelType=="Bfull")) solve(UEqn == - fvc::grad(p) + Ksl/rho*Us); else if (momentumPredictor) solve(UEqn == - voidfraction*fvc::grad(p) + Ksl/rho*Us); // --- PISO loop //for (int corr=0; corr<nCorr; corr++) int nCorrSoph = nCorr + 5 * pow((1-particleCloud.dataExchangeM().timeStepFraction()),1); for (int corr=0; corr<nCorrSoph; corr++) { volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA)); volScalarField rUAvoidfraction("(voidfraction2|A(U))",rUA*voidfraction); surfaceScalarField rUAfvoidfraction("(voidfraction2|A(U)F)", fvc::interpolate(rUAvoidfraction)); U = rUA*UEqn.H(); #ifdef version23 phi = ( fvc::interpolate(U*voidfraction) & mesh.Sf() ) + rUAfvoidfraction*fvc::ddtCorr(U, phi); #else phi = ( fvc::interpolate(U*voidfraction) & mesh.Sf() ) + fvc::ddtPhiCorr(rUAvoidfraction, U, phi); #endif surfaceScalarField phiS(fvc::interpolate(Us*voidfraction) & mesh.Sf()); surfaceScalarField phiGes = phi + rUAf*(fvc::interpolate(Ksl/rho) * phiS); if (modelType=="A") rUAvoidfraction = volScalarField("(voidfraction2|A(U))",rUA*voidfraction*voidfraction); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rUAvoidfraction, p) == fvc::div(phiGes) + particleCloud.ddtVoidfraction() ); pEqn.setReference(pRefCell, pRefValue); if ( corr == nCorr-1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver("pFinal")); } else { pEqn.solve(); } if (nonOrth == nNonOrthCorr) { phiGes -= pEqn.flux(); phi = phiGes; } } // end non-orthogonal corrector loop #include "continuityErrorPhiPU.H" if (modelType=="B" || modelType=="Bfull") U -= rUA*fvc::grad(p) - Ksl/rho*Us*rUA; else U -= voidfraction*rUA*fvc::grad(p) - Ksl/rho*Us*rUA; U.correctBoundaryConditions(); } // end piso loop } turbulence->correct(); }// end solveFlow else { Info << "skipping flow solution." << endl; } 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.solutionDict().solver(p.name() + "Final")); } else { pEqn.solve(mesh.solutionDict().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[]) { #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 "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "readThermodynamicProperties.H" //#include "readTransportProperties.H" #include "createFields.H" #include "createFvOptions.H" #include "initContinuityErrs.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // dimensionedScalar period = dimensionedScalar("period", dimensionSet(0,0,1,0,0,0,0), 0.22e-9); //dimensionedScalar tRed = dimensionedScalar("tRed", dimensionSet(0,0,1,0,0,0,0), 2.16059e-12); //% STARTING PERIOD //dimensionedScalar P_S = dimensionedScalar("P_S", dimensionSet(0,0,1,0,0,0,0), 100* 2.16059e-12); scalar P_S = 100; // *2.16059e-12; //scalar P_S = 100*2.16059e-12; //% END PERIOD //dimensionedScalar P_E = dimensionedScalar("P_E", dimensionSet(0,0,1,0,0,0,0), 5000* 2.16059e-12); scalar P_E = 5000; //*2.16059e-12; //scalar P_E = 5000*2.16059e-12; //dimensionedScalar endTime = dimensionedScalar("endTime", dimensionSet(0,0,1,0,0,0,0), 10000* 2.16059e-12); scalar endTime = 10000; //*2.16059e-12; //scalar endTime = 10000*2.16059e-12; // QUICKER TO BEGIN WITH AND HIGHER ORDER POLYNOMIAL scalar n = 30; //*2.16059e-12; //dimensionedScalar phase = 0; scalar phase = 0; //scalar period = 0; Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "compressibleCourantNo.H" #include "rhoEqn.H" scalar T = runTime.time().value() / 2.16059e-12; scalar temp = ( Foam::pow(( (T - endTime)/endTime), n)); Info << "temp = " << temp << endl; // dimensionedScalar freq = dimensionedScalar("freq", dimensionSet(0,0,-1,0,0,0,0), 0); scalar freq= ((1/P_E) - ( ( (1/P_E) - (1/P_S) ) * temp )) /2.16059e-12 ; // dimensionedScalar period = dimensionedScalar("period", dimensionSet(0,0,1,0,0,0,0), 1/freq); // dimensionedScalar period = 1/freq; scalar period = 1/freq; // phase += (freq * runTime.deltaT().value()/2.16059e-12) ; // 0.0025*2.16059e-12; Info << "phase = " << phase << endl; phase += ((freq) * runTime.deltaT().value()) ; // 0.0025*2.16059e-12; Info << "freq = " << freq << endl; Info << "phase = " << phase << endl; Info << "period = " << period << endl; extForceField = extForce * rho / molMass * Foam::sin(2*3.1415*phase); // *phase) ; fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) - fvm::laplacian(mu, U) - extForceField ); solve(UEqn == -fvc::grad(p)); // --- PISO loop for (int corr=0; corr<nCorr; corr++) { psi = (a0*pow(p,10) + a1*pow(p,9) + a2*pow(p,8) + a3*pow(p,7) + a4*pow(p,6) + a5*pow(p,5) + a6*pow(p,4) + a7*pow(p,3) + a8*pow(p,2) + a9*p + a10)/p; rho = psi*(p); mu = mu6 * pow(rho,6) + mu5 * pow(rho,5) + mu4 * pow(rho,4) + mu3 * pow(rho,3) + mu2 * pow(rho,2) + mu1 * rho + mu0; volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); surfaceScalarField phid ( "phid", fvc::interpolate(psi) *( (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtCorr(rho, U, phi) //+ fvc::ddtPhiCorr(rUA, rho, U, phi) ) ); phi = (fvc::interpolate(rho0 - psi*p0)/fvc::interpolate(psi))*phid; fvScalarMatrix pEqn ( fvm::ddt(psi, p) + fvc::div(phi) + fvm::div(phid, p) - fvm::laplacian(rho*rUA, p) ); pEqn.solve(); phi += pEqn.flux(); #include "compressibleContinuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } // rhoU = ( rho*U.component(0) ) * (mesh.Sf()); // fvc::snGrad(fvc::reconstruct(phi)); // fvc::reconstruct(phi); runTime.write(); // #include "binMassFluxNew.H" 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 "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[]) { 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); scalar CoNum; scalar meanCoNum; CourantNo( runTime, mesh, phi, CoNum, meanCoNum ); 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++) { 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" #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; }