diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/EEqn.H b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/EEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..9dae89f003418a3dffdfdc8fcbf91f5f64c76b80 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/EEqn.H @@ -0,0 +1,50 @@ +{ + volScalarField& he = thermo.he(); + + const tmp<volScalarField>& tCp = thermo.Cp(); + const tmp<volScalarField>& tCv = thermo.Cv(); + + const volScalarField& Cp = tCp(); + const volScalarField& Cv = tCv(); + const scalar gamma = max(Cp/Cv).value(); + + if (mag(gamma - min(Cp/Cv).value()) > VSMALL) + { + notImplemented("gamma not constant in space"); + } + + const dictionary& thermoDict = thermo.subDict("mixture"); + + const dictionary& eosDict = thermoDict.subDict("equationOfState"); + + bool local = eosDict.lookupOrDefault<bool>("local", false); + + // Evolve T as: + // + // T_1 = T_0 \frac{p}{p_0}^{\frac{\gamma - 1}{\gamma}} + + if (!local) + { + const scalar T0 = readScalar(eosDict.lookup("T0")); + const scalar p0 = readScalar(eosDict.lookup("p0")); + + he = thermo.he(p, pow(p/p0, (gamma - scalar(1))/gamma)*T0); + } + else + { + const volScalarField& T0 = T.oldTime(); + const volScalarField& p0 = p.oldTime(); + + he = thermo.he(p, pow(p/p0, (gamma - scalar(1))/gamma)*T0); + } + + thermo.correct(); + + psi = 1.0/((Cp - Cv)*T); + + rho = thermo.rho(); + rho.relax(); + + rho.writeMinMax(Info); +} + diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/Make/files b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..6d0da3cb5c0820528ed81344bef77051819d6823 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/Make/files @@ -0,0 +1,3 @@ +rhoPimpleAdiabaticFoam.C + +EXE = $(FOAM_APPBIN)/rhoPimpleAdiabaticFoam diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/Make/options b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..0bf2d5dee74108e56caaa10d787394c06dc092cb --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/Make/options @@ -0,0 +1,20 @@ +EXE_INC = \ + -I$(LIB_SRC)/transportModels/compressible/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ + -I$(LIB_SRC)/finiteVolume/cfdTools \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + +EXE_LIBS = \ + -lcompressibleTransportModels \ + -lfluidThermophysicalModels \ + -lspecie \ + -lturbulenceModels \ + -lcompressibleTurbulenceModels \ + -lfiniteVolume \ + -lmeshTools \ + -lsampling \ + -lfvOptions diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/UEqn.H b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/UEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..c4a78e7056c329964f179929ddb2b58d8477ba7a --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/UEqn.H @@ -0,0 +1,24 @@ +// Solve the Momentum equation + +MRF.correctBoundaryVelocity(U); + +tmp<fvVectorMatrix> tUEqn +( + fvm::ddt(rho, U) + fvm::div(phi, U) + + MRF.DDt(rho, U) + + turbulence->divDevRhoReff(U) + == + fvOptions(rho, U) +); +fvVectorMatrix& UEqn = tUEqn.ref(); + +UEqn.relax(); + +fvOptions.constrain(UEqn); + +if (pimple.momentumPredictor()) +{ + solve(UEqn == -fvc::grad(p)); + + fvOptions.correct(U); +} diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/createFields.H b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..322ec367120e68a3fe67c4dcf7b6b61144c0101d --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/createFields.H @@ -0,0 +1,102 @@ +Info<< "Reading thermophysical properties\n" << endl; + +autoPtr<fluidThermo> pThermo +( + fluidThermo::New(mesh) +); +fluidThermo& thermo = pThermo(); +thermo.validate(args.executable(), "h", "e"); + +volScalarField& p = thermo.p(); +volScalarField& T = thermo.T(); + +volScalarField rho +( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + thermo.rho() +); + +Info<< "Reading field U\n" << endl; +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +Info<< "Calculating face flux field phi\n" << endl; + +surfaceScalarField phi +( + IOobject + ( + "phi", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + linearInterpolate(rho)*linearInterpolate(U) & mesh.Sf() +); + +Info<< "Calculating face flux field phiByRho\n" << endl; + +surfaceScalarField phiByRho +( + IOobject + ( + "phiByRho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + phi/linearInterpolate(rho) +); + +Info<< "Creating turbulence model\n" << endl; +autoPtr<compressible::turbulenceModel> turbulence +( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) +); + +mesh.setFluxRequired(p.name()); + +Info<< "Creating field dpdt\n" << endl; +volScalarField dpdt +( + IOobject + ( + "dpdt", + runTime.timeName(), + mesh + ), + mesh, + dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) +); + +#include "createMRF.H" + +Info<< "Creating compressibility field psi\n" << endl; +volScalarField psi("psi", 1.0/((thermo.Cp() - thermo.Cv())*T)); +psi.oldTime() = 1.0/((thermo.Cp() - thermo.Cv())*T.oldTime()); +psi.oldTime().oldTime() = 1.0/((thermo.Cp()-thermo.Cv())*T.oldTime().oldTime()); diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/pEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..75d184510c67ab1b6b1d66f828f198c70a41ad2b --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/pEqn.H @@ -0,0 +1,95 @@ +{ + volScalarField rAU(1.0/UEqn.A()); + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); + + + // Define coefficients and pseudo-velocities for RCM interpolation + // M[U] = AU - H = -grad(p) + // U = H/A - 1/A grad(p) + // H/A = U + 1/A grad(p) + surfaceScalarField rhorAUf + ( + "rhorAUf", + fvc::interpolate(rho)/fvc::interpolate(UEqn.A()) + ); + + surfaceVectorField rhoHbyAf + ( + "rhoHbyAf", + fvc::interpolate(rho)*fvc::interpolate(U) + + rhorAUf*fvc::interpolate(fvc::grad(p)) + ); + + #include "resetBoundaries.H" + + if (pimple.nCorrPISO() <= 1) + { + tUEqn.clear(); + } + + if (pimple.transonic()) + { + FatalError + << "\nTransonic option not available for " << args.executable() + << exit(FatalError); + } + else + { + // Rhie & Chow interpolation (part 1) + surfaceScalarField phiHbyA + ( + "phiHbyA", + ( + (rhoHbyAf & mesh.Sf()) + + rhorAUf*fvc::interpolate(rho)*fvc::ddtCorr(U, phiByRho) + + fvc::interpolate(rho) + * fvc::alphaCorr(U, phiByRho, pimple.finalInnerIter()) + ) + ); + + MRF.makeRelative(fvc::interpolate(rho), phiHbyA); + + // Non-orthogonal pressure corrector loop + while (pimple.correctNonOrthogonal()) + { + // Pressure corrector + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvc::div(phiHbyA) + - fvm::laplacian(rhorAUf, p) + == + fvOptions(psi, p, rho.name()) + ); + + pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter()))); + + // Rhie & Chow interpolation (part 2) + if (pimple.finalNonOrthogonalIter()) + { + phi = phiHbyA + pEqn.flux(); + } + } + } + + phiByRho = phi/fvc::interpolate(rho); + + #include "rhoEqn.H" + #include "compressibleContinuityErrs.H" + + // Explicitly relax pressure for momentum corrector + p.relax(); + + U = HbyA - rAU*fvc::grad(p); + U.correctBoundaryConditions(); + fvOptions.correct(U); +} + +rho = thermo.rho(); + +if (thermo.dpdt()) +{ + dpdt = fvc::ddt(p); +} + diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/resetBoundaries.H b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/resetBoundaries.H new file mode 100644 index 0000000000000000000000000000000000000000..2d1eecdc723aa60be8e732cff164541a8c007935 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/resetBoundaries.H @@ -0,0 +1,25 @@ +{ + // Keep standard formulation on domain boundaries to ensure compatibility + // with existing boundary conditions + const Foam::FieldField<Foam::fvsPatchField, scalar> rhorAUf_orig + ( + fvc::interpolate(rho.boundaryField()*rAU.boundaryField()) + ); + + const Foam::FieldField<Foam::fvsPatchField, vector> rhoHbyA_orig + ( + fvc::interpolate(rho.boundaryField()*HbyA.boundaryField()) + ); + + surfaceScalarField::Boundary& rhorAUfbf = rhorAUf.boundaryFieldRef(); + surfaceVectorField::Boundary& rhoHbyAfbf = rhoHbyAf.boundaryFieldRef(); + + forAll(U.boundaryField(), patchi) + { + if (!U.boundaryField()[patchi].coupled()) + { + rhorAUfbf[patchi] = rhorAUf_orig[patchi]; + rhoHbyAfbf[patchi] = rhoHbyA_orig[patchi]; + } + } +} diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/rhoPimpleAdiabaticFoam.C b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/rhoPimpleAdiabaticFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..c122090869a153352c6f431f9820a9e25db1db64 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/rhoPimpleAdiabaticFoam.C @@ -0,0 +1,129 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Application + rhoPimpleAdiabaticFoam + +Description + Transient solver for laminar or turbulent flow of weakly compressible + fluids for low Mach number aeroacoustic applications. + + Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and + pseudo-transient simulations. The RCM interpolation is used as in + + \verbatim + Knacke, T. (2013). + Potential effects of Rhie & Chow type interpolations in airframe + noise simulations. In: Schram, C., Dénos, R., Lecomte E. (ed): + Accurate and efficient aeroacoustic prediction approaches for + airframe noise, VKI LS 2013-03. + \endverbatim + + + Contact: info@cfd-berlin.com + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "fluidThermo.H" +#include "turbulentFluidThermoModel.H" +#include "bound.H" +#include "pimpleControl.H" +#include "fvOptions.H" + +#include "ddtScheme.H" +#include "fvcCorrectAlpha.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "postProcess.H" + + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "createControl.H" + #include "createTimeControls.H" + + #include "createFields.H" + #include "createFvOptions.H" + #include "initContinuityErrs.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readTimeControls.H" + #include "compressibleCourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + if (pimple.nCorrPIMPLE() <= 1) + { + #include "rhoEqn.H" + } + + // --- Pressure-velocity PIMPLE corrector loop + while (pimple.loop()) + { + U.storePrevIter(); + rho.storePrevIter(); + phi.storePrevIter(); + phiByRho.storePrevIter(); + + #include "UEqn.H" + + // --- Pressure corrector loop + while (pimple.correct()) + { + #include "pEqn.H" + } + + #include "EEqn.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; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index ca9bf31ff6f9ab606cca79fa955659661e65db54..dea1794a8baa9ab004ed12e29c422d4bb360fcf8 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -401,6 +401,7 @@ finiteVolume/fvc/fvcFlux.C finiteVolume/fvc/fvcMeshPhi.C finiteVolume/fvc/fvcSmooth/fvcSmooth.C finiteVolume/fvc/fvcReconstructMag.C +finiteVolume/fvc/fvcCorrectAlpha.C general = cfdTools/general $(general)/findRefCell/findRefCell.C diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H index abedc954a96579e6c6c37c25b00e01f05fdfa57e..24812aee9123bbf08618fbd714abc017ef5eb527 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -98,7 +98,19 @@ public: backwardDdtScheme(const fvMesh& mesh, Istream& is) : ddtScheme<Type>(mesh, is) - {} + { + if (is.good() && !is.eof()) + { + this->ddtPhiCoeff_ = readScalar(is); + } + + // Ensure the old-old-time cell volumes are available + // for moving meshes + if (mesh.moving()) + { + mesh.V00(); + } + } // Member Functions diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C index 03c205567318cbd271d6a645825162a7637349d9..a1ef450c2d7d6c3f6a02cf3f3566671ad894e572 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -156,13 +156,36 @@ tmp<surfaceScalarField> ddtScheme<Type>::fvcDdtPhiCoeff const fluxFieldType& phiCorr ) { - tmp<surfaceScalarField> tddtCouplingCoeff = scalar(1) - - min + tmp<surfaceScalarField> tddtCouplingCoeff + ( + new surfaceScalarField + ( + IOobject + ( + "ddtCouplingCoeff", + U.mesh().time().timeName(), + U.mesh() + ), + U.mesh(), + dimensionedScalar("one", dimless, 1.0) + ) + ); + + + if (ddtPhiCoeff_ < 0) + { + tddtCouplingCoeff.ref() =- min ( mag(phiCorr) /(mag(phi) + dimensionedScalar("small", phi.dimensions(), SMALL)), scalar(1) ); + } + else + { + tddtCouplingCoeff.ref() = + dimensionedScalar("ddtPhiCoeff", dimless, ddtPhiCoeff_); + } surfaceScalarField& ddtCouplingCoeff = tddtCouplingCoeff.ref(); diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.H index e2d1ca5c7bb3f27892f5b9f99b23f3d538ccd198..8a1dfbaa8de439fd766febe6aee2123ffef64c29 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,6 +30,7 @@ Group Description Abstract base class for ddt schemes. + SourceFiles ddtScheme.C @@ -76,6 +77,9 @@ protected: const fvMesh& mesh_; + //- Input for fvcDdtPhiCoeff (-1 default) + scalar ddtPhiCoeff_; + // Private Member Functions @@ -109,13 +113,15 @@ public: //- Construct from mesh ddtScheme(const fvMesh& mesh) : - mesh_(mesh) + mesh_(mesh), + ddtPhiCoeff_(-1) {} //- Construct from mesh and Istream - ddtScheme(const fvMesh& mesh, Istream&) + ddtScheme(const fvMesh& mesh, Istream& is) : - mesh_(mesh) + mesh_(mesh), + ddtPhiCoeff_(-1) {} diff --git a/src/finiteVolume/finiteVolume/fvc/fvcCorrectAlpha.C b/src/finiteVolume/finiteVolume/fvc/fvcCorrectAlpha.C new file mode 100644 index 0000000000000000000000000000000000000000..70a3b6ba291b042c6a7b5f5ada0bc4f0ac8006ab --- /dev/null +++ b/src/finiteVolume/finiteVolume/fvc/fvcCorrectAlpha.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +InNamespace + Foam::fvc + +Description + Correct flux-U difference in the internal loop using relaxation factor + +SourceFiles + fvcCorrectAlpha.C + +\*---------------------------------------------------------------------------*/ + +#include "fvcCorrectAlpha.H" +#include "fvMesh.H" +#include "surfaceInterpolate.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace fvc +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +tmp<GeometricField<scalar, fvsPatchField, surfaceMesh>> alphaCorr +( + const GeometricField<vector, fvPatchField, volMesh>& U, + const GeometricField<scalar, fvsPatchField, surfaceMesh>& phiU, + const bool finalIter +) +{ + const fvMesh& mesh = U.mesh(); + const word fieldName = U.select(finalIter); + + scalar alpha = 1; + if (mesh.relaxEquation(fieldName)) + { + alpha = mesh.equationRelaxationFactor(fieldName); + } + + return + (1 - alpha) + *(phiU.prevIter() - (fvc::interpolate(U.prevIter()) & mesh.Sf())); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fvc + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/fvc/fvcCorrectAlpha.H b/src/finiteVolume/finiteVolume/fvc/fvcCorrectAlpha.H new file mode 100644 index 0000000000000000000000000000000000000000..6bf60ce5c2523e040fd30aa4d9ed5a72aa69cd3e --- /dev/null +++ b/src/finiteVolume/finiteVolume/fvc/fvcCorrectAlpha.H @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +InNamespace + Foam::fvc + +Description + Correct flux-U difference in the internal loop using relaxation factor + +SourceFiles + fvcCorrectAlpha.C + +\*---------------------------------------------------------------------------*/ + + +#ifndef fvcCorrectAlpha_H +#define fvcCorrectAlpha_H + +#include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Namespace fvc functions Declaration +\*---------------------------------------------------------------------------*/ + +namespace fvc +{ + tmp<GeometricField<scalar, fvsPatchField, surfaceMesh>> alphaCorr + ( + const GeometricField<vector, fvPatchField, volMesh>& U, + const GeometricField<scalar, fvsPatchField, surfaceMesh>& phiU, + const bool finalIter + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/T b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/T new file mode 100644 index 0000000000000000000000000000000000000000..ba20e7f417f6f00fa757fb77b25efe9c7da4499d --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/T @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 224; + +boundaryField +{ + top + { + type slip; + } + + bottom + { + type slip; + } + + left + { + type fixedValue; + value $internalField; + } + + right + { + type inletOutlet; + inletValue $internalField; + value $internalField; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/U b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/U new file mode 100644 index 0000000000000000000000000000000000000000..e132b2720e385c4251bb71302a0a41eab6152e4e --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/U @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (50 0 0); + +boundaryField +{ + top + { + type slip; + } + + bottom + { + type slip; + } + + left + { + type fixedValue; + value uniform (50 0 0); + } + + right + { + type inletOutlet; + inletValue uniform (0 0 0); + value uniform (50 0 0); + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/p b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/p new file mode 100644 index 0000000000000000000000000000000000000000..0801e56b03b56dfc393c7128ae135c6aaa2b31a1 --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/p @@ -0,0 +1,65 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 101325; + +boundaryField +{ + top + { + type zeroGradient; + } + + bottom + { + type zeroGradient; + } + + left + { + type waveTransmissive; + field p; + phi phi; + rho rho; + psi thermo:psi; + gamma 1.4; + fieldInf 101325; + lInf 5.0; + value $internalField; + } + + right + { + type waveTransmissive; + field p; + phi phi; + rho rho; + psi thermo:psi; + gamma 1.4; + fieldInf 101325; + lInf 5.0; + value $internalField; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..f60abaf9c58489fb3f98e795e9de6174113713bc --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean @@ -0,0 +1,9 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +cleanCase +\rm -rf 0 + diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..9961aeb245f821f2cda555bec28ce9050f0df6fd --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun @@ -0,0 +1,11 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +restore0Dir +runApplication blockMesh +runApplication -s preProcess $(getApplication) -postProcess -dict system/preProcess +runApplication decomposePar +runParallel $(getApplication) diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/constant/thermophysicalProperties b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/constant/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..8b5b961f7f4b5d44c0f5d1084072802bf411c161 --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/constant/thermophysicalProperties @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type hePsiThermo; + mixture pureMixture; + transport const; + thermo hConst; + equationOfState perfectGas; + specie specie; + energy sensibleEnthalpy; +} + +mixture +{ + equationOfState + { + p0 103308.85730683322; + T0 225.24440406165331; + } + specie + { + molWeight 28.970278977370906; + } + thermodynamics + { + Cp 1004.5; + Hf 0; + } + transport + { + mu 1.4585464649816414e-05; + Pr 0.7179; + } +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/constant/turbulenceProperties b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..e4ad75d18c58796a41b783918420c965ae86fd6a --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/blockMeshDict b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..213fe055b14f0cf4037df2b6f1a58e5d6ec5872c --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/blockMeshDict @@ -0,0 +1,123 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// D = 0.57 +convertToMeters 0.57; + +x0 -3.5; +x1 1.8; +x2 15.7; +x3 21; +y0 -5.2; +y1 5.2; + +vertices +( + ($x0 $y0 0) + ($x1 $y0 0) + ($x2 $y0 0) + ($x3 $y0 0) + + ($x3 $y1 0) + ($x2 $y1 0) + ($x1 $y1 0) + ($x0 $y1 0) + + ($x0 $y0 0.1) + ($x1 $y0 0.1) + ($x2 $y0 0.1) + ($x3 $y0 0.1) + + ($x3 $y1 0.1) + ($x2 $y1 0.1) + ($x1 $y1 0.1) + ($x0 $y1 0.1) +); + +xSpacing ((0.5 0.5 5)(0.5 0.5 0.2)); +ySpacing ((1 0.5 0.25)(1 1 1)(1 0.5 4)); + + +blocks +( + hex (0 1 6 7 8 9 14 15) (150 200 1) simpleGrading (1 $ySpacing 1) + hex (1 2 5 6 9 10 13 14) (150 200 1) simpleGrading ($xSpacing $ySpacing 1) + hex (2 3 4 5 10 11 12 13) (150 200 1) simpleGrading (1 $ySpacing 1) +); + +edges +( +); + +boundary +( + top + { + type wall; + faces + ( + (7 15 14 6) + (6 14 13 5) + (5 13 12 4) + ); + } + bottom + { + type wall; + faces + ( + (1 9 8 0) + (2 10 9 1) + (3 11 10 2) + ); + } + left + { + type patch; + faces + ( + (0 8 15 7) + ); + } + right + { + type patch; + faces + ( + (4 12 11 3) + ); + } + frontAndBack + { + type empty; + faces + ( + (0 7 6 1) + (1 6 5 2) + (2 5 4 3) + + (8 9 14 15) + (9 10 13 14) + (10 11 12 13) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/controlDict b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..4b5fbc95346294e1db2e31f43bacc5969349173f --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/controlDict @@ -0,0 +1,69 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application rhoPimpleAdiabaticFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.22528; + +deltaT 3.2e-05; + +writeControl timeStep; + +writeInterval 100; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 10; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +functions +{ + probes + { + type probes; + + functionObjectLibs ("libsampling.so"); + + probeLocations + ( + (3.0 2.0 0.0) + (3.0 -2.0 0.0) + ); + + fields + ( + p + ); + } +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/decomposeParDict b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..20edb36158fefaa1a2b0679b42514dfa8053835b --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/decomposeParDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 3; + +method hierarchical; + +hierarchicalCoeffs +{ + n (3 1 1); + delta 0.001; + order xyz; +} + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/fvSchemes b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..780388292c11f1ff304a0280702fe5a1eabceb26 --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/fvSchemes @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + // Note: setting coefficient to 1 for the rhoPimpleAdiabaticFoam solver + default backward 1; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss LUST grad(U); + div(phi,h) Gauss LUST grad(h); + div(phi,K) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/fvSolution b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..297863b02a1235d21c6e9d46bd489780b2ca768d --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/fvSolution @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "(p|rho)" + { + solver PCG; + preconditioner DIC; + tolerance 1e-9; + relTol 0.01; + minIter 1; + } + + "(p|rho)Final" + { + $p; + relTol 0; + } + + "(U|e|h)" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-9; + relTol 0.01; + } + + "(U|e|h)Final" + { + $U; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor yes; + nOuterCorrectors 1; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess new file mode 100644 index 0000000000000000000000000000000000000000..7316fe1f9c07c8860a99e4f0a1732e7481925cef --- /dev/null +++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess @@ -0,0 +1,91 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location system; + object preProcess; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +functions +{ + createVortex + { + type coded; + functionObjectLibs ("libutilityFunctionObjects.so"); + redirectType createVortices; + enabled yes; + + codeInclude + #{ + #include "volFields.H" + #}; + + codeWrite + #{ + scalar D = 0.57; + scalar UInf = 50; + scalar pInf = 101325; + scalar TInf = 224; + scalar gamma = 1.4; + scalar A = 0.3*D*UInf; + const dimensionedScalar rhoRef("rhoRef", dimDensity, 1); + const volScalarField& rho = + mesh().lookupObject<volScalarField>("rho"); + + const vectorField& C = mesh().C(); + const scalarField x(C.component(0)); + const scalarField y(C.component(1)); + const scalar r2 = sqr(0.5*D/(Foam::sqrt(Foam::log(10.0)))); + const scalarField Psi(A*exp(-0.5/r2*(sqr(x) + sqr(y)))); + + volVectorField* Uptr = + mesh().lookupObjectRefPtr<volVectorField>("U"); + volScalarField* pPtr = + mesh().lookupObjectRefPtr<volScalarField>("p"); + volScalarField* TPtr = + mesh().lookupObjectRefPtr<volScalarField>("T"); + + + if (Uptr && pPtr && TPtr) + { + volVectorField& U = *Uptr; + volScalarField& p = *pPtr; + volScalarField& T = *TPtr; + + vectorField& Uc = U.primitiveFieldRef(); + Uc.replace(0, UInf - rhoRef/rho()*Psi/r2*y); + Uc.replace(1, rhoRef/rho()*Psi/r2*x); + U.correctBoundaryConditions(); + U.write(); + + scalarField& pc = p.primitiveFieldRef(); + pc = pInf - 0.5*sqr(rhoRef)/rho()*sqr(Psi)/r2; + p.correctBoundaryConditions(); + p.write(); + + scalarField& Tc = T.primitiveFieldRef(); + Tc = pow(pc/pInf, (gamma - 1)/gamma)*TInf; + T.correctBoundaryConditions(); + T.write(); + } + else + { + FatalErrorInFunction + << "Unable to find pressure, velocity and temperature" + << " fields" << exit(FatalError); + } + #}; + } +} + + +// ************************************************************************* //