From ead256f50629907bba8962ef86669a6a4bf3487b Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Fri, 9 Jun 2017 10:23:47 +0100 Subject: [PATCH 1/8] INT: Integration of rhoPimpleAdiabaticFoam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Solver for low Mach no. flows with adiabatic thermodynamics and updated pressure-velocity coupling given by the RCM interpolation procedure described 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 Original code supplied by Thilo Knacke, CFD E+F GmbH contact: info@cfd-berlin.com Integrated into OpenFOAM by OpenCFD Ltd. --- .../rhoPimpleAdiabaticFoam/EEqn.H | 50 +++++++ .../rhoPimpleAdiabaticFoam/Make/files | 3 + .../rhoPimpleAdiabaticFoam/Make/options | 20 +++ .../rhoPimpleAdiabaticFoam/UEqn.H | 24 ++++ .../rhoPimpleAdiabaticFoam/createFields.H | 102 ++++++++++++++ .../rhoPimpleAdiabaticFoam/pEqn.H | 95 +++++++++++++ .../rhoPimpleAdiabaticFoam/resetBoundaries.H | 25 ++++ .../rhoPimpleAdiabaticFoam.C | 129 ++++++++++++++++++ src/finiteVolume/Make/files | 1 + .../backwardDdtScheme/backwardDdtScheme.H | 16 ++- .../ddtSchemes/ddtScheme/ddtScheme.C | 29 +++- .../ddtSchemes/ddtScheme/ddtScheme.H | 14 +- .../finiteVolume/fvc/fvcCorrectAlpha.C | 80 +++++++++++ .../finiteVolume/fvc/fvcCorrectAlpha.H | 71 ++++++++++ .../rutlandVortex2D/0.orig/T | 52 +++++++ .../rutlandVortex2D/0.orig/U | 52 +++++++ .../rutlandVortex2D/0.orig/p | 65 +++++++++ .../rutlandVortex2D/Allclean | 9 ++ .../rutlandVortex2D/Allrun | 11 ++ .../constant/thermophysicalProperties | 53 +++++++ .../constant/turbulenceProperties | 20 +++ .../rutlandVortex2D/system/blockMeshDict | 123 +++++++++++++++++ .../rutlandVortex2D/system/controlDict | 69 ++++++++++ .../rutlandVortex2D/system/decomposeParDict | 29 ++++ .../rutlandVortex2D/system/fvSchemes | 54 ++++++++ .../rutlandVortex2D/system/fvSolution | 59 ++++++++ .../rutlandVortex2D/system/preProcess | 91 ++++++++++++ 27 files changed, 1337 insertions(+), 9 deletions(-) create mode 100644 applications/solvers/compressible/rhoPimpleAdiabaticFoam/EEqn.H create mode 100644 applications/solvers/compressible/rhoPimpleAdiabaticFoam/Make/files create mode 100644 applications/solvers/compressible/rhoPimpleAdiabaticFoam/Make/options create mode 100644 applications/solvers/compressible/rhoPimpleAdiabaticFoam/UEqn.H create mode 100644 applications/solvers/compressible/rhoPimpleAdiabaticFoam/createFields.H create mode 100644 applications/solvers/compressible/rhoPimpleAdiabaticFoam/pEqn.H create mode 100644 applications/solvers/compressible/rhoPimpleAdiabaticFoam/resetBoundaries.H create mode 100644 applications/solvers/compressible/rhoPimpleAdiabaticFoam/rhoPimpleAdiabaticFoam.C create mode 100644 src/finiteVolume/finiteVolume/fvc/fvcCorrectAlpha.C create mode 100644 src/finiteVolume/finiteVolume/fvc/fvcCorrectAlpha.H create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/T create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/U create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/0.orig/p create mode 100755 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allclean create mode 100755 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/Allrun create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/constant/thermophysicalProperties create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/constant/turbulenceProperties create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/blockMeshDict create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/controlDict create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/decomposeParDict create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/fvSchemes create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/fvSolution create mode 100644 tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess diff --git a/applications/solvers/compressible/rhoPimpleAdiabaticFoam/EEqn.H b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/EEqn.H new file mode 100644 index 0000000000..9dae89f003 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/EEqn.H @@ -0,0 +1,50 @@ +{ + volScalarField& he = thermo.he(); + + const tmp& tCp = thermo.Cp(); + const tmp& 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("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 0000000000..6d0da3cb5c --- /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 0000000000..0bf2d5dee7 --- /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 0000000000..c4a78e7056 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/UEqn.H @@ -0,0 +1,24 @@ +// Solve the Momentum equation + +MRF.correctBoundaryVelocity(U); + +tmp 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 0000000000..322ec36712 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleAdiabaticFoam/createFields.H @@ -0,0 +1,102 @@ +Info<< "Reading thermophysical properties\n" << endl; + +autoPtr 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 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 0000000000..75d184510c --- /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 0000000000..2d1eecdc72 --- /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 rhorAUf_orig + ( + fvc::interpolate(rho.boundaryField()*rAU.boundaryField()) + ); + + const Foam::FieldField 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 0000000000..c122090869 --- /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 . + +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 ca9bf31ff6..dea1794a8b 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 abedc954a9..24812aee91 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(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 03c2055673..a1ef450c2d 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 ddtScheme::fvcDdtPhiCoeff const fluxFieldType& phiCorr ) { - tmp tddtCouplingCoeff = scalar(1) - - min + tmp 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 e2d1ca5c7b..8a1dfbaa8d 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 0000000000..70a3b6ba29 --- /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 . + +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> alphaCorr +( + const GeometricField& U, + const GeometricField& 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 0000000000..6bf60ce5c2 --- /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 . + +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> alphaCorr + ( + const GeometricField& U, + const GeometricField& 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 0000000000..ba20e7f417 --- /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 0000000000..e132b2720e --- /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 0000000000..0801e56b03 --- /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 0000000000..f60abaf9c5 --- /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 0000000000..9961aeb245 --- /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 0000000000..8b5b961f7f --- /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 0000000000..e4ad75d18c --- /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 0000000000..213fe055b1 --- /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 0000000000..4b5fbc9534 --- /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 0000000000..20edb36158 --- /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 0000000000..780388292c --- /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 0000000000..297863b02a --- /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 0000000000..7316fe1f9c --- /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("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("U"); + volScalarField* pPtr = + mesh().lookupObjectRefPtr("p"); + volScalarField* TPtr = + mesh().lookupObjectRefPtr("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); + } + #}; + } +} + + +// ************************************************************************* // From 0f547660cec56f57a0ffba05270a7e555765e0e1 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 28 Jun 2017 12:16:38 +0200 Subject: [PATCH 2/8] TUT: make it easier to perform dry runs for lumpedPointMotion --- .../lumpedPointMotion/building/Allrun.move | 11 ++++++++--- .../lumpedPointMotion/building/files/Allrun.movement | 3 ++- .../lumpedPointMotion/building/files/Allrun.transient | 3 +++ .../lumpedPointMotion/building/steady/Allrun.pre | 7 ++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tutorials/incompressible/lumpedPointMotion/building/Allrun.move b/tutorials/incompressible/lumpedPointMotion/building/Allrun.move index 842eb6cefe..33b1a80e7b 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/Allrun.move +++ b/tutorials/incompressible/lumpedPointMotion/building/Allrun.move @@ -27,13 +27,18 @@ linkParallelCase() echo "Linking $dst parallel case from $src" mkdir $dst - for i in constant system + + # Copy system - may wish to change things + for i in system 0 do - cp -r $src/$i $dst + echo " copy $i/" + ( cd $dst && cp -r ../$src/$i . ) done - echo " link processor directories with $# times: $@" + echo " link constant/" + ( cd $dst && ln -sf ../$src/constant . ) + echo " link processor*/ with $# times: $@" for proc in $(cd $src && \ls -d processor*) do ( cd $dst && ln -sf ../$src/$proc . ) diff --git a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement index 4e7cab8fb7..bf69827a2c 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement +++ b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.movement @@ -3,7 +3,8 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/bin/tools/RunFunctions # The 0/ field only -runApplication reconstructPar -withZero -time 0 +# runApplication reconstructPar -withZero -time 0 +runApplication reconstructParMesh -constant -withZero -time 0 # Check the location of the pressure zones # runParallel lumpedPointZones <<- Parallel file writing not yet done diff --git a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient index 91920e1883..5004717368 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient +++ b/tutorials/incompressible/lumpedPointMotion/building/files/Allrun.transient @@ -2,6 +2,9 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/bin/tools/RunFunctions +# Cleanup old junk that may prevent things from starting +\rm -f comms/OpenFOAM.lock + # If OpenFOAM stops prematurely, trigger the external solver to stop trap '[ -e comms/OpenFOAM.lock ] && echo "status=done" > comms/OpenFOAM.lock' EXIT TERM INT diff --git a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre index b58f7f5cea..de42e2de8c 100755 --- a/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre +++ b/tutorials/incompressible/lumpedPointMotion/building/steady/Allrun.pre @@ -15,7 +15,7 @@ unset parallel parallel=true # Dummy 0 directory -mkdir 0 +mkdir -p 0 if [ "${parallel:-false}" = false ] then @@ -39,6 +39,11 @@ else runParallel renumberMesh -overwrite + # In case serial calculations are needed later + + restore0Dir # Overwrite dummy 0 directory + # runApplication reconstructParMesh -constant + fi From b39eece156adc507283830b41a082b4305641786 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 28 Jun 2017 13:37:50 +0200 Subject: [PATCH 3/8] CONFIG: revert to openmpi-1.10.4 - this is the same version as OpenFOAM-1612 shipped with and seems to have fewer issues than the newer openmpi-2.1.1 --- etc/config.csh/mpi | 2 +- etc/config.sh/mpi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/config.csh/mpi b/etc/config.csh/mpi index eaf11328da..c4df2b627e 100644 --- a/etc/config.csh/mpi +++ b/etc/config.csh/mpi @@ -49,7 +49,7 @@ case SYSTEMOPENMPI: breaksw case OPENMPI: - setenv FOAM_MPI openmpi-2.1.1 + setenv FOAM_MPI openmpi-1.10.4 _foamEtc config.csh/openmpi # <- Adjustments (optional) setenv MPI_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI diff --git a/etc/config.sh/mpi b/etc/config.sh/mpi index d28b3a37bb..4c663ce276 100644 --- a/etc/config.sh/mpi +++ b/etc/config.sh/mpi @@ -55,7 +55,7 @@ SYSTEMOPENMPI) ;; OPENMPI) - export FOAM_MPI=openmpi-2.1.1 + export FOAM_MPI=openmpi-1.10.4 _foamEtc config.sh/openmpi # <- Adjustments (optional) export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI From c5c48205febecc882408ba050d0940d2824fd8c6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 28 Jun 2017 12:46:01 +0100 Subject: [PATCH 4/8] BUG: pitzDaily: remove DebugSwitches --- .../incompressible/simpleFoam/pitzDaily/system/controlDict | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tutorials/incompressible/simpleFoam/pitzDaily/system/controlDict b/tutorials/incompressible/simpleFoam/pitzDaily/system/controlDict index 1335867e72..59da172c16 100644 --- a/tutorials/incompressible/simpleFoam/pitzDaily/system/controlDict +++ b/tutorials/incompressible/simpleFoam/pitzDaily/system/controlDict @@ -15,11 +15,6 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -DebugSwitches -{ - SolverPerformance 2; -} - application simpleFoam; startFrom startTime; From 367095f6668b8dd720c41035cc94acf2d697fc6b Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Wed, 28 Jun 2017 14:07:26 +0100 Subject: [PATCH 5/8] BUG: Correction for commit ead256f50 --- .../ddtSchemes/backwardDdtScheme/backwardDdtScheme.H | 2 +- .../finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H index 24812aee91..0d7e9174d9 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H @@ -101,7 +101,7 @@ public: { if (is.good() && !is.eof()) { - this->ddtPhiCoeff_ = readScalar(is); + is >> this->ddtPhiCoeff_; } // Ensure the old-old-time cell volumes are available diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C index a1ef450c2d..f5e11840b9 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.C @@ -171,10 +171,11 @@ tmp ddtScheme::fvcDdtPhiCoeff ) ); + surfaceScalarField& ddtCouplingCoeff = tddtCouplingCoeff.ref(); if (ddtPhiCoeff_ < 0) { - tddtCouplingCoeff.ref() =- min + ddtCouplingCoeff -= min ( mag(phiCorr) /(mag(phi) + dimensionedScalar("small", phi.dimensions(), SMALL)), @@ -183,14 +184,11 @@ tmp ddtScheme::fvcDdtPhiCoeff } else { - tddtCouplingCoeff.ref() = + ddtCouplingCoeff = dimensionedScalar("ddtPhiCoeff", dimless, ddtPhiCoeff_); } - surfaceScalarField& ddtCouplingCoeff = tddtCouplingCoeff.ref(); - - surfaceScalarField::Boundary& ccbf = - ddtCouplingCoeff.boundaryFieldRef(); + surfaceScalarField::Boundary& ccbf = ddtCouplingCoeff.boundaryFieldRef(); forAll(U.boundaryField(), patchi) { From bb2041ef69bf85665244f58a19e135b3caa3125d Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Wed, 28 Jun 2017 14:07:57 +0100 Subject: [PATCH 6/8] BUG: reactionSensitivity - corrected integral calculations --- .../reactionsSensitivityAnalysis.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C index 939de3548f..2efc7fcf46 100644 --- a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C +++ b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C @@ -110,12 +110,12 @@ calculateSpeciesRR if (RR[0] > 0.0) { production_[speciei][reactioni] = RR[0]; - productionInt_[speciei][reactioni] =+ dt*RR[0]; + productionInt_[speciei][reactioni] += dt*RR[0]; } else if (RR[0] < 0.0) { consumption_[speciei][reactioni] = RR[0]; - consumptionInt_[speciei][reactioni] =+ dt*RR[0]; + consumptionInt_[speciei][reactioni] += dt*RR[0]; } else { From a2d8e6e4f5f6a66f1585d9f4a7ce6e34209edb19 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 28 Jun 2017 16:11:24 +0200 Subject: [PATCH 7/8] STYLE: remove old references to 'dx' and 'foamFile' --- etc/controlDict | 1 - .../combustion/reactingFoam/RAS/SandiaD_LTS/system/sampleDict | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/etc/controlDict b/etc/controlDict index a2302326dc..72112b0ddc 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -498,7 +498,6 @@ DebugSwitches flowRateInletVelocity 0; fluxCorrectedVelocity 0; foamChemistryReader 0; - foamFile 0; forceCoeffs 0; forces 0; fourth 0; diff --git a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/sampleDict b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/sampleDict index b5fb7d735a..9ad795924b 100644 --- a/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/sampleDict +++ b/tutorials/combustion/reactingFoam/RAS/SandiaD_LTS/system/sampleDict @@ -26,8 +26,7 @@ setFormat raw; // Surface output format. Choice of // null : suppress output -// foamFile : separate points, faces and values file -// dx : DX scalar or vector format +// foam : separate points, faces and values file // vtk : VTK ascii format // raw : x y z value format for use with e.g. gnuplot 'splot'. // From cec7eb951846c10816328b51825f3b62422ac87a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 28 Jun 2017 17:41:15 +0200 Subject: [PATCH 8/8] ENH: add basic arch information to the output (issue #361) - end user can easily see which arch (endian, label/scalar size) was used from the log output, or via -help usage --- src/OpenFOAM/global/argList/argList.C | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 72215bc0a0..5219b7a20b 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -37,6 +37,7 @@ License #include "sigInt.H" #include "sigQuit.H" #include "sigSegv.H" +#include "endian.H" #include @@ -53,6 +54,22 @@ Foam::string::size_type Foam::argList::usageMin = 20; Foam::string::size_type Foam::argList::usageMax = 80; Foam::word Foam::argList::postProcessOptionName("postProcess"); +// file-scope +// Hint about machine endian, OpenFOAM label and scalar sizes +static const std::string archHint = +( +#ifdef WM_LITTLE_ENDIAN + "LSB" +#elif defined (WM_BIG_ENDIAN) + "MSB" +#else + "???" +#endif + ";label=" + std::to_string(8*sizeof(Foam::label)) + + ";scalar=" + std::to_string(8*sizeof(Foam::scalar)) +); + + Foam::argList::initValidTables::initValidTables() { argList::addOption @@ -622,6 +639,7 @@ void Foam::argList::parse { IOobject::writeBanner(Info, true) << "Build : " << Foam::FOAMbuild << nl + << "Arch : " << archHint << nl << "Exec : " << argListStr_.c_str() << nl << "Date : " << dateString.c_str() << nl << "Time : " << timeString.c_str() << nl @@ -1228,7 +1246,8 @@ void Foam::argList::printUsage() const Info<< nl <<"Using: OpenFOAM-" << Foam::FOAMversion << " (see www.OpenFOAM.com)" << nl - <<"Build: " << Foam::FOAMbuild << nl + << "Build: " << Foam::FOAMbuild << nl + << "Arch: " << archHint << nl << endl; }