//---------------------------------------------------------------------------
fvVectorMatrixHolder fun_Ueqn( const pimpleControlHolder& pimple,
                               const volScalarFieldHolder& rho,
                               const volScalarFieldHolder& p,
                               volVectorFieldHolder& U, 
                               const surfaceScalarFieldHolder& phi, 
                               const compressible::turbulenceModelHolder& turbulence,
                               MRFZonesHolder& mrfZones, porousZonesHolder& pZones )
{
  fvVectorMatrixHolder UEqn( fvm::ddt( rho, U ) + fvm::div( phi, U ) + fvVectorMatrixHolder( turbulence->divDevRhoReff( U() ), Deps( &turbulence, &U ) ) );
  
  UEqn->relax();
  
  mrfZones->addCoriolis( rho(), UEqn() );
  pZones->addResistance( UEqn() );
  
  smart_tmp< volScalarField >  rAU( 1.0 / UEqn->A() );
  
  if ( pimple->momentumPredictor() )
  {
    solve( UEqn == -fvc::grad( p ) );
  }
  else
  {
    U = rAU() * ( UEqn->H() - fvc::grad( p() ) );
    U->correctBoundaryConditions();
  }
  
  return UEqn;
}
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;
  }
}
Beispiel #3
0
//---------------------------------------------------------------------------
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();
}
Beispiel #4
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 "createDynamicFvMesh.H"

    pimpleControl pimple(mesh);

    #include "../interFoam/interDyMFoam/createControls.H"
    #include "initContinuityErrs.H"
    #include "createFields.H"
    #include "createFvOptions.H"

    volScalarField rAU
    (
        IOobject
        (
            "rAU",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0)
    );

    #include "createUf.H"
    #include "CourantNo.H"
    #include "setInitialDeltaT.H"

    turbulence->validate();

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.run())
    {
        #include "../interFoam/interDyMFoam/readControls.H"

        // Store divU from the previous mesh so that it can be mapped
        // and used in correctPhi to ensure the corrected phi has the
        // same divergence
        volScalarField divU("divU0", fvc::div(fvc::absolute(phi, U)));

        #include "CourantNo.H"
        #include "setDeltaT.H"

        runTime++;

        Info<< "Time = " << runTime.timeName() << nl << endl;

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            if (pimple.firstIter() || moveMeshOuterCorrectors)
            {
                scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();

                mesh.update();

                if (mesh.changing())
                {
                    Info<< "Execution time for mesh.update() = "
                        << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
                        << " s" << endl;

                    gh = (g & mesh.C()) - ghRef;
                    ghf = (g & mesh.Cf()) - ghRef;
                }

                if (mesh.changing() && correctPhi)
                {
                    // Calculate absolute flux from the mapped surface velocity
                    phi = mesh.Sf() & Uf;

                    #include "correctPhi.H"

                    // Make the flux relative to the mesh motion
                    fvc::makeRelative(phi, U);
                }

                if (mesh.changing() && checkMeshCourantNo)
                {
                    #include "meshCourantNo.H"
                }
            }

            #include "alphaControls.H"

            surfaceScalarField rhoPhi
            (
                IOobject
                (
                    "rhoPhi",
                    runTime.timeName(),
                    mesh
                ),
                mesh,
                dimensionedScalar("0", dimMass/dimTime, 0)
            );

            mixture->correct();

            #include "alphaEqnSubCycle.H"
            interface.correct();

            #include "UEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }

        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}
Beispiel #6
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;
}
Beispiel #7
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 "readThermodynamicProperties.H"
    #include "readTransportProperties.H"
    #include "createFields.H"
    #include "initContinuityErrs.H"

    pimpleControl pimple(mesh);

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        #include "readTimeControls.H"
        #include "compressibleCourantNo.H"

        #include "rhoEqn.H"

        // --- 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(1.0/UEqn.A());
                U = rAU*UEqn.H();

                surfaceScalarField phid
                (
                    "phid",
                    psi
                   *(
                       (fvc::interpolate(U) & mesh.Sf())
                     + fvc::ddtPhiCorr(rAU, rho, U, phi)
                   )
                );

                phi = (rhoO/psi)*phid;
                volScalarField Dp("Dp", rho*rAU);

                fvScalarMatrix pEqn
                (
                    fvm::ddt(psi, p)
                  + fvc::div(phi)
                  + fvm::div(phid, p)
                  - fvm::laplacian(Dp, p)
                );

                pEqn.solve();

                phi += pEqn.flux();

                #include "compressibleContinuityErrs.H"

                U -= rAU*fvc::grad(p);
                U.correctBoundaryConditions();
            }
        }

        rho = rhoO + psi*p;

        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 pimpleControlHolder& pimple,
               basicPsiThermoHolder& thermo,
               volScalarFieldHolder& rho,
               volScalarFieldHolder& p,
               volScalarFieldHolder& h,
               volScalarFieldHolder& psi,
               volVectorFieldHolder& U,
               surfaceScalarFieldHolder& phi,
               compressible::turbulenceModelHolder& turbulence,
               fvVectorMatrixHolder& UEqn,
               MRFZonesHolder& mrfZones,
               volScalarFieldHolder& DpDt,
               scalar& cumulativeContErr,
               int& corr,
               dimensionedScalar& rhoMax,
               dimensionedScalar& rhoMin )
{
  rho = thermo->rho();
  rho = max( rho(), rhoMin );
  rho = min( rho(), rhoMax );
  rho->relax();

  smart_tmp< volScalarField >  rAU( 1.0 / UEqn->A() );
  U = rAU() * UEqn->H();

  if (pimple->nCorr() <= 1)
  {
    //UEqn->clear();
  }

  if (pimple->transonic())
  {
     surfaceScalarField phid( "phid", fvc::interpolate( psi() ) * ( ( fvc::interpolate( U() ) & mesh->Sf() )
                                                                    + fvc::ddtPhiCorr( rAU(), rho(), U(), phi() ) ) );

    mrfZones->relativeFlux( fvc::interpolate( psi() ), phid);
    
    for (int nonOrth=0; nonOrth <= pimple->nNonOrthCorr(); nonOrth++ )
    {
      smart_tmp< fvScalarMatrix > pEqn( fvm::ddt( psi(), p() ) + fvm::div( phid, p() ) - fvm::laplacian( rho() * rAU(), p() ) );

      pEqn->solve( mesh->solver( p->select( pimple->finalInnerIter( corr, nonOrth ) ) ) );

      if ( nonOrth == pimple->nNonOrthCorr() )
      {
        phi == pEqn->flux();
      }
    }
  }
  else
  {
    phi = fvc::interpolate( rho() ) * ( ( fvc::interpolate( U() ) & mesh->Sf() ) + fvc::ddtPhiCorr( rAU(), rho(), U(), phi() ) );
    
    mrfZones->relativeFlux( fvc::interpolate( rho() ), phi() );

    for (int nonOrth=0; nonOrth<=pimple->nNonOrthCorr(); nonOrth++)
    {
      // Pressure corrector
      smart_tmp< fvScalarMatrix > pEqn( fvm::ddt( psi(), p() ) + fvc::div( phi() ) - fvm::laplacian( rho()*rAU(), p() ) );

      pEqn->solve( mesh->solver( p->select( pimple->finalInnerIter( corr, nonOrth ) ) ) );

      if ( nonOrth == pimple->nNonOrthCorr() )
      {
        phi += pEqn->flux();
      }
    }
  }

  rhoEqn( rho, phi );
  compressibleContinuityErrs( thermo, rho, cumulativeContErr );

  // Explicitly relax pressure for momentum corrector
  p->relax();

  // Recalculate density from the relaxed pressure
  rho = thermo->rho();
  rho = max( rho(), rhoMin );
  rho = min( rho(), rhoMax );
  rho->relax();
  Info<< "rho max/min : " << max( rho() ).value()  << " " << min( rho() ).value() << endl;

  U -= rAU() * fvc::grad( p() );
  U->correctBoundaryConditions();

  DpDt = fvc::DDt(surfaceScalarField("phiU", phi() / fvc::interpolate( rho() ) ), p());
}
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)
          - (fvc::grad(U) & fvc::grad(fluid.nu()))
        );

        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;
    }

    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[])
{
  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;
}
Beispiel #15
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;
}
Beispiel #16
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 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;
}
Beispiel #17
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;
}
Beispiel #18
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;
}
int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createDynamicFvMesh.H"
    #include "initContinuityErrs.H"

    pimpleControl pimple(mesh);

    #include "createControls.H"
    #include "createFields.H"
    #include "createMRF.H"
    #include "createFvOptions.H"

    volScalarField rAU
    (
        IOobject
        (
            "rAU",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("rAUf", dimTime, 1.0)
    );

    #include "correctPhi.H"
    #include "createUf.H"

    turbulence->validate();

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nStarting time loop\n" << endl;

    while (runTime.run())
    {
        #include "readControls.H"
        #include "CourantNo.H"
        #include "setDeltaT.H"

        runTime++;

        Info<< "Time = " << runTime.timeName() << nl << endl;

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            if (pimple.firstIter() || moveMeshOuterCorrectors)
            {
                scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();

                mesh.update();

                if (mesh.changing())
                {
                    Info<< "Execution time for mesh.update() = "
                        << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
                        << " s" << endl;
                }

                if (mesh.changing() && correctPhi)
                {
                    // Calculate absolute flux from the mapped surface velocity
                    phi = mesh.Sf() & Uf;

                    #include "correctPhi.H"

                    // Make the flux relative to the mesh motion
                    fvc::makeRelative(phi, U);
                }

                if (mesh.changing() && checkMeshCourantNo)
                {
                    #include "meshCourantNo.H"
                }
            }

            #include "UEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                laminarTransport.correct();
                turbulence->correct();
            }
        }

        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}
Beispiel #20
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 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();
                    }
                }

                #include "continuityErrs.H"

                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 "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];
	}
Beispiel #22
0
int main(int argc, char *argv[])
{
    #include "postProcess.H"

    #include "setRootCase.H"
    #include "createTime.H"
    #include "createDynamicFvMesh.H"
    #include "initContinuityErrs.H"
    #include "createControl.H"
    #include "createTimeControls.H"
    #include "createDyMControls.H"
    #include "createRDeltaT.H"
    #include "createFields.H"
    #include "createFvOptions.H"

    volScalarField rAU
    (
        IOobject
        (
            "rAU",
            runTime.timeName(),
            mesh,
            IOobject::READ_IF_PRESENT,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0)
    );

    #include "correctPhi.H"
    #include "createUf.H"

    turbulence->validate();

    if (!LTS)
    {
        #include "CourantNo.H"
        #include "setInitialDeltaT.H"
    }

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    Info<< "\nStarting time loop\n" << endl;

    while (runTime.run())
    {
        #include "readControls.H"

        if (LTS)
        {
            #include "setRDeltaT.H"
        }
        else
        {
            #include "CourantNo.H"
            #include "alphaCourantNo.H"
            #include "setDeltaT.H"
        }

        runTime++;

        Info<< "Time = " << runTime.timeName() << nl << endl;

        // --- Pressure-velocity PIMPLE corrector loop
        while (pimple.loop())
        {
            if (pimple.firstIter() || moveMeshOuterCorrectors)
            {
                scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();

                mesh.update();

                if (mesh.changing())
                {
                    Info<< "Execution time for mesh.update() = "
                        << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
                        << " s" << endl;

                    gh = (g & mesh.C()) - ghRef;
                    ghf = (g & mesh.Cf()) - ghRef;
                }

                if (mesh.changing() && correctPhi)
                {
                    // Calculate absolute flux from the mapped surface velocity
                    phi = mesh.Sf() & Uf;

                    #include "correctPhi.H"

                    // Make the flux relative to the mesh motion
                    fvc::makeRelative(phi, U);

                    mixture.correct();
                }

                if (mesh.changing() && checkMeshCourantNo)
                {
                    #include "meshCourantNo.H"
                }
            }

            #include "alphaControls.H"
            #include "alphaEqnSubCycle.H"

            mixture.correct();

            #include "UEqn.H"

            // --- Pressure corrector loop
            while (pimple.correct())
            {
                #include "pEqn.H"
            }

            if (pimple.turbCorr())
            {
                turbulence->correct();
            }
        }

        runTime.write();
        // Write Porous Variables
        if( activePorosity && runTime.outputTime() ) 
        {
            porosity.write();
            porosityIndex.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;
  }

}