diff --git a/applications/solvers/DNSandLES/channelOodles/channelOodles.C b/applications/solvers/DNSandLES/channelOodles/channelOodles.C index 22d39a83f4..b4b73741fc 100644 --- a/applications/solvers/DNSandLES/channelOodles/channelOodles.C +++ b/applications/solvers/DNSandLES/channelOodles/channelOodles.C @@ -41,17 +41,13 @@ Description int main(int argc, char *argv[]) { - -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" -# include "readTransportProperties.H" -# include "createFields.H" -# include "createAverages.H" -# include "initContinuityErrs.H" -# include "createGradP.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readTransportProperties.H" + #include "createFields.H" + #include "initContinuityErrs.H" + #include "createGradP.H" Info<< "\nStarting time loop\n" << endl; @@ -59,9 +55,9 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPISOControls.H" + #include "readPISOControls.H" -# include "CourantNo.H" + #include "CourantNo.H" sgsModel->correct(); @@ -116,7 +112,7 @@ int main(int argc, char *argv[]) } } -# include "continuityErrs.H" + #include "continuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); @@ -126,12 +122,12 @@ int main(int argc, char *argv[]) // Correct driving force for a constant mass flow rate // Extract the velocity in the flow direction - dimensionedScalar magUbarStar = + dimensionedScalar magUbarStar = (flowDirection & U)().weightedAverage(mesh.V()); - // Calculate the pressure gradient increment needed to + // Calculate the pressure gradient increment needed to // adjust the average flow-rate to the correct value - dimensionedScalar gragPplus = + dimensionedScalar gragPplus = (magUbar - magUbarStar)/rUA.weightedAverage(mesh.V()); U += flowDirection*rUA*gragPplus; @@ -141,14 +137,9 @@ int main(int argc, char *argv[]) Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab << "pressure gradient = " << gradP.value() << endl; - -# include "calculateAverages.H" - runTime.write(); -# include "writeNaveragingSteps.H" - -# include "writeGradP.H" + #include "writeGradP.H" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" diff --git a/applications/solvers/DNSandLES/coodles/coodles.C b/applications/solvers/DNSandLES/coodles/coodles.C index 5d2e02caf4..a8bc87061e 100644 --- a/applications/solvers/DNSandLES/coodles/coodles.C +++ b/applications/solvers/DNSandLES/coodles/coodles.C @@ -26,6 +26,7 @@ Application coodles Description + Compressible LES solver. \*---------------------------------------------------------------------------*/ @@ -39,15 +40,12 @@ Description int main(int argc, char *argv[]) { + #include "setRootCase.H" -# include "setRootCase.H" - -# include "createTime.H" -# include "createMesh.H" -# include "createFields.H" -# include "initContinuityErrs.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" + #include "initContinuityErrs.H" Info<< "\nStarting time loop\n" << endl; @@ -55,17 +53,17 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPISOControls.H" -# include "compressibleCourantNo.H" + #include "readPISOControls.H" + #include "compressibleCourantNo.H" -# include "rhoEqn.H" -# include "UEqn.H" + #include "rhoEqn.H" + #include "UEqn.H" // --- PISO loop for (int corr=1; corr<=nCorr; corr++) { -# include "hEqn.H" -# include "pEqn.H" + #include "hEqn.H" + #include "pEqn.H" } turbulence->correct(); diff --git a/applications/solvers/DNSandLES/oodles/calculateAverages.H b/applications/solvers/DNSandLES/oodles/calculateAverages.H deleted file mode 100644 index 331a2aaa7e..0000000000 --- a/applications/solvers/DNSandLES/oodles/calculateAverages.H +++ /dev/null @@ -1,14 +0,0 @@ - nAveragingSteps++; - - scalar nm1Coeff = scalar(nAveragingSteps - 1)/nAveragingSteps; - scalar nCoeff = 1.0/nAveragingSteps; - - R += sqr(Umean); - Umean = nm1Coeff*Umean + nCoeff*U; - R = nm1Coeff*R + nCoeff*sqr(U) - sqr(Umean); - Bmean = nm1Coeff*Bmean + nCoeff*sgsModel->B(); - epsilonMean = nm1Coeff*epsilonMean + nCoeff*sgsModel->epsilon(); - - pPrime2Mean += sqr(pMean); - pMean = nm1Coeff*pMean + nCoeff*p; - pPrime2Mean = nm1Coeff*pPrime2Mean + nCoeff*sqr(p) - sqr(pMean); diff --git a/applications/solvers/DNSandLES/oodles/createAverages.H b/applications/solvers/DNSandLES/oodles/createAverages.H deleted file mode 100644 index 64e53cdc77..0000000000 --- a/applications/solvers/DNSandLES/oodles/createAverages.H +++ /dev/null @@ -1,234 +0,0 @@ - label nAveragingSteps = 1; - - IFstream nAveragingStepsFile - ( - runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw" - ); - - - autoPtr UmeanPtr; - autoPtr RPtr; - autoPtr BmeanPtr; - autoPtr epsilonMeanPtr; - - autoPtr pMeanPtr; - autoPtr pPrime2MeanPtr; - - if (nAveragingStepsFile.good()) - { - nAveragingStepsFile >> nAveragingSteps; - - Info<< "Reading field Umean\n" << endl; - UmeanPtr.reset - ( - new volVectorField - ( - IOobject - ( - "Umean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ) - ); - - Info<< "\nReading field R\n" << endl; - RPtr.reset - ( - new volSymmTensorField - ( - IOobject - ( - "R", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ) - ); - - Info<< "\nReading field Bmean\n" << endl; - BmeanPtr.reset - ( - new volSymmTensorField - ( - IOobject - ( - "Bmean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ) - ); - - Info<< "\nReading field epsilonMean\n" << endl; - epsilonMeanPtr.reset - ( - new volScalarField - ( - IOobject - ( - "epsilonMean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ) - ); - - Info<< "Reading field pMean\n" << endl; - pMeanPtr.reset - ( - new volScalarField - ( - IOobject - ( - "pMean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ) - ); - - Info<< "Reading field pPrime2Mean\n" << endl; - pPrime2MeanPtr.reset - ( - new volScalarField - ( - IOobject - ( - "pPrime2Mean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ) - ); - } - else - { - Info<< "Creating field Umean\n" << endl; - UmeanPtr.reset - ( - new volVectorField - ( - IOobject - ( - "Umean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - U - ) - ); - - Info<< "Creating field R\n" << endl; - RPtr.reset - ( - new volSymmTensorField - ( - IOobject - ( - "R", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - sqr(U) - sqr(UmeanPtr()) - ) - ); - - Info<< "Creating field Bmean\n" << endl; - BmeanPtr.reset - ( - new volSymmTensorField - ( - IOobject - ( - "Bmean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - sgsModel->B() - ) - ); - - Info<< "Creating field epsilonMean\n" << endl; - epsilonMeanPtr.reset - ( - new volScalarField - ( - IOobject - ( - "epsilonMean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - sgsModel->epsilon() - ) - ); - - Info<< "Creating field pMean\n" << endl; - pMeanPtr.reset - ( - new volScalarField - ( - IOobject - ( - "pMean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - p - ) - ); - - Info<< "Creating field pPrime2Mean\n" << endl; - pPrime2MeanPtr.reset - ( - new volScalarField - ( - IOobject - ( - "pPrime2Mean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - sqr(p) - sqr(pMeanPtr()) - ) - ); - } - - volVectorField& Umean = UmeanPtr(); - volSymmTensorField& R = RPtr(); - volSymmTensorField& Bmean = BmeanPtr(); - volScalarField& epsilonMean = epsilonMeanPtr(); - - volScalarField& pMean = pMeanPtr(); - volScalarField& pPrime2Mean = pPrime2MeanPtr(); diff --git a/applications/solvers/DNSandLES/oodles/oodles.C b/applications/solvers/DNSandLES/oodles/oodles.C index fb4681d96f..883eefe9e6 100644 --- a/applications/solvers/DNSandLES/oodles/oodles.C +++ b/applications/solvers/DNSandLES/oodles/oodles.C @@ -42,16 +42,11 @@ Description int main(int argc, char *argv[]) { - -# include "setRootCase.H" -# include "createTime.H" -# include "createMeshNoClear.H" -# include "createFields.H" -# include "createAverages.H" -# include "initContinuityErrs.H" - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #include "setRootCase.H" + #include "createTime.H" + #include "createMeshNoClear.H" + #include "createFields.H" + #include "initContinuityErrs.H" Info<< "\nStarting time loop\n" << endl; @@ -59,8 +54,8 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPISOControls.H" -# include "CourantNo.H" + #include "readPISOControls.H" + #include "CourantNo.H" sgsModel->correct(); @@ -76,9 +71,7 @@ int main(int argc, char *argv[]) solve(UEqn == -fvc::grad(p)); } - // --- PISO loop - for (int corr=0; corrcorrect(); -# include "UEqn.H" + #include "UEqn.H" // --- PISO loop for (int corr=1; corr<=nCorr; corr++) { -# include "ftEqn.H" -# include "bEqn.H" -# include "huEqn.H" -# include "hEqn.H" + #include "ftEqn.H" + #include "bEqn.H" + #include "huEqn.H" + #include "hEqn.H" if (!ign.ignited()) { hu == h; } -# include "pEqn.H" + #include "pEqn.H" } -# include "calculateAverages.H" - runTime.write(); -# include "writeNaveragingSteps.H" - rho = thermo->rho(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" diff --git a/applications/solvers/combustion/Xoodles/calculateAverages.H b/applications/solvers/combustion/Xoodles/calculateAverages.H deleted file mode 100644 index 4e9dc75f47..0000000000 --- a/applications/solvers/combustion/Xoodles/calculateAverages.H +++ /dev/null @@ -1,16 +0,0 @@ - nAveragingSteps++; - - scalar nm1Coeff = scalar(nAveragingSteps - 1)/nAveragingSteps; - scalar nCoeff = 1.0/nAveragingSteps; - - R += sqr(Umean); - Umean = nm1Coeff*Umean + nCoeff*U; - R = nm1Coeff*R + nCoeff*sqr(U) - sqr(Umean); - - pPrime2Mean += sqr(pMean); - pMean = nm1Coeff*pMean + nCoeff*p; - pPrime2Mean = nm1Coeff*pPrime2Mean + nCoeff*sqr(p) - sqr(pMean); - - Tmean = nm1Coeff*Tmean + nCoeff*T; - bmean = nm1Coeff*bmean + nCoeff*b; - Ximean = nm1Coeff*Ximean + nCoeff*Xi; diff --git a/applications/solvers/combustion/Xoodles/createAverages.H b/applications/solvers/combustion/Xoodles/createAverages.H deleted file mode 100644 index becb920cbc..0000000000 --- a/applications/solvers/combustion/Xoodles/createAverages.H +++ /dev/null @@ -1,229 +0,0 @@ - label nAveragingSteps = 1; - - IFstream nAveragingStepsFile - ( - runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw" - ); - - volVectorField* UmeanPtr; - volSymmTensorField* RPtr; - - volScalarField* pMeanPtr; - volScalarField* pPrime2MeanPtr; - - volScalarField* TmeanPtr; - volScalarField* bmeanPtr; - volScalarField* XimeanPtr; - - if (nAveragingStepsFile.good()) - { - nAveragingStepsFile >> nAveragingSteps; - - Info << "Reading field Umean\n" << endl; - UmeanPtr = new volVectorField - ( - IOobject - ( - "Umean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< "\nReading field R\n" << endl; - RPtr = new volSymmTensorField - ( - IOobject - ( - "R", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< "Reading field pMean\n" << endl; - pMeanPtr = new volScalarField - ( - IOobject - ( - "pMean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< "Reading field pPrime2Mean\n" << endl; - pPrime2MeanPtr = new volScalarField - ( - IOobject - ( - "pPrime2Mean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info << "Reading field Tmean\n" << endl; - TmeanPtr = new volScalarField - ( - IOobject - ( - "Tmean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info << "Reading field bmean\n" << endl; - bmeanPtr = new volScalarField - ( - IOobject - ( - "bmean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info << "Reading field Ximean\n" << endl; - XimeanPtr = new volScalarField - ( - IOobject - ( - "Ximean", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - } - else - { - Info << "Creating field Umean\n" << endl; - UmeanPtr = new volVectorField - ( - IOobject - ( - "Umean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - U - ); - - Info<< "Creating field R\n" << endl; - RPtr = new volSymmTensorField - ( - IOobject - ( - "R", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - sqr(U) - sqr(*UmeanPtr) - ); - - Info<< "Creating field pMean\n" << endl; - pMeanPtr = new volScalarField - ( - IOobject - ( - "pMean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - p - ); - - Info<< "Creating field pPrime2Mean\n" << endl; - pPrime2MeanPtr = new volScalarField - ( - IOobject - ( - "pPrime2Mean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - sqr(p) - sqr(*pMeanPtr) - ); - - Info << "Creating field Tmean\n" << endl; - TmeanPtr = new volScalarField - ( - IOobject - ( - "Tmean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - T - ); - - Info << "Creating field bmean\n" << endl; - bmeanPtr = new volScalarField - ( - IOobject - ( - "bmean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - b - ); - - Info << "Creating field Ximean\n" << endl; - XimeanPtr = new volScalarField - ( - IOobject - ( - "Ximean", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - Xi - ); - } - - volVectorField& Umean = *UmeanPtr; - volSymmTensorField& R = *RPtr; - - volScalarField& pMean = *pMeanPtr; - volScalarField& pPrime2Mean = *pPrime2MeanPtr; - - volScalarField& Tmean = *TmeanPtr; - volScalarField& bmean = *bmeanPtr; - volScalarField& Ximean = *XimeanPtr; diff --git a/applications/solvers/combustion/Xoodles/writeNaveragingSteps.H b/applications/solvers/combustion/Xoodles/writeNaveragingSteps.H deleted file mode 100644 index f590d9ba6f..0000000000 --- a/applications/solvers/combustion/Xoodles/writeNaveragingSteps.H +++ /dev/null @@ -1,18 +0,0 @@ - if (runTime.outputTime()) - { - OFstream nAveragingStepsFile - ( - runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw" - ); - - if (nAveragingStepsFile.good()) - { - nAveragingStepsFile << nAveragingSteps << endl; - } - else - { - FatalErrorIn(args.executable()) - << "Cannot open file " << nAveragingStepsFile.name() - << abort(FatalError); - } - } diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C index 6145646a7c..0be52e772f 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C @@ -26,9 +26,12 @@ Application rhoSimpleFoam Description - Steady-state solver for turbulent flow of compressible fluids for + Transient solver for turbulent flow of compressible fluids for ventilation and heat-transfer. + Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and + pseudo-transient simulations. + \*---------------------------------------------------------------------------*/ #include "fvCFD.H" @@ -40,23 +43,20 @@ Description int main(int argc, char *argv[]) { - -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" -# include "createFields.H" -# include "initContinuityErrs.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" + #include "initContinuityErrs.H" Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { -# include "readTimeControls.H" -# include "readPIMPLEControls.H" -# include "compressibleCourantNo.H" -# include "setDeltaT.H" + #include "readTimeControls.H" + #include "readPIMPLEControls.H" + #include "compressibleCourantNo.H" + #include "setDeltaT.H" runTime++; @@ -72,13 +72,13 @@ int main(int argc, char *argv[]) int oCorr=0; do { -# include "UEqn.H" -# include "hEqn.H" + #include "UEqn.H" + #include "hEqn.H" // --- PISO loop for (int corr=0; corrcorrect(); diff --git a/applications/solvers/heatTransfer/buoyantFoam/buoyantFoam.C b/applications/solvers/heatTransfer/buoyantFoam/buoyantFoam.C index 1efd637125..728e19e2e0 100644 --- a/applications/solvers/heatTransfer/buoyantFoam/buoyantFoam.C +++ b/applications/solvers/heatTransfer/buoyantFoam/buoyantFoam.C @@ -27,7 +27,8 @@ Application Description Transient Solver for buoyant, turbulent flow of compressible fluids for - ventilation and heat-transfer. + ventilation and heat-transfer. Turbulence is modelled using a run-time + selectable compressible RAS model. \*---------------------------------------------------------------------------*/ diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/Make/files b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/Make/files new file mode 100644 index 0000000000..5dccac44bc --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/Make/files @@ -0,0 +1,4 @@ +buoyantSimpleRadiationFoam.C + +EXE = $(FOAM_USER_APPBIN)/buoyantSimpleRadiationFoam + diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/Make/options b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/Make/options new file mode 100644 index 0000000000..12943280aa --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/cfdTools \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/turbulenceModels + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -lbasicThermophysicalModels \ + -lspecie \ + -lradiation \ + -lcompressibleTurbulenceModels diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/UEqn.H new file mode 100644 index 0000000000..d58a70a54e --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/UEqn.H @@ -0,0 +1,12 @@ + // Solve the Momentum equation + + tmp UEqn + ( + fvm::div(phi, U) + - fvm::Sp(fvc::div(phi), U) + + turbulence->divDevRhoReff(U) + ); + + UEqn().relax(); + + solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh); diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C new file mode 100644 index 0000000000..649a7d97b0 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/buoyantSimpleRadiationFoam.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + buoyantSimpleRadiationFoam + +Description + Steady-state solver for buoyant, turbulent flow of compressible fluids, + including radiation, for ventilation and heat-transfer. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "basicThermo.H" +#include "compressible/turbulenceModel/turbulenceModel.H" +#include "fixedGradientFvPatchFields.H" +#include "radiationModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + +# include "setRootCase.H" +# include "createTime.H" +# include "createMesh.H" +# include "readEnvironmentalProperties.H" +# include "createFields.H" +# include "initContinuityErrs.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + for (runTime++; !runTime.end(); runTime++) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + +# include "readSIMPLEControls.H" + + pd.storePrevIter(); + rho.storePrevIter(); + + // Pressure-velocity SIMPLE corrector + { +# include "UEqn.H" + +# include "hEqn.H" + +# include "pEqn.H" + } + + turbulence->correct(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createFields.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createFields.H new file mode 100644 index 0000000000..707ef2fff8 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/createFields.H @@ -0,0 +1,93 @@ + Info<< "Reading thermophysical properties\n" << endl; + + autoPtr thermo + ( + basicThermo::New(mesh) + ); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + thermo->rho() + ); + + volScalarField& p = thermo->p(); + volScalarField& h = thermo->h(); + const volScalarField& T = thermo->T(); + + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "compressibleCreatePhi.H" + + + Info<< "Creating turbulence model\n" << endl; + autoPtr turbulence + ( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo() + ) + ); + + Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); + + + dimensionedScalar pRef("pRef", p.dimensions(), 1.0e5); + + Info<< "Creating field pd\n" << endl; + volScalarField pd + ( + IOobject + ( + "pd", + runTime.timeName(), + mesh + ), + p - rho*gh - pRef, + p.boundaryField().types() + ); + + + label pdRefCell = 0; + scalar pdRefValue = 0.0; + setRefCell + ( + pd, + mesh.solutionDict().subDict("SIMPLE"), + pdRefCell, + pdRefValue + ); + + + Info<< "Creating radiation model\n" << endl; + autoPtr radiation + ( + radiation::radiationModel::New(T) + ); + + + dimensionedScalar initialMass = fvc::domainIntegrate(rho); diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H new file mode 100644 index 0000000000..88094369d4 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H @@ -0,0 +1,20 @@ +{ + fvScalarMatrix hEqn + ( + fvm::div(phi, h) + - fvm::Sp(fvc::div(phi), h) + - fvm::laplacian(turbulence->alphaEff(), h) + == + fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p)) + - p*fvc::div(phi/fvc::interpolate(rho)) + + radiation->Sh(thermo()) + ); + + hEqn.relax(); + + hEqn.solve(); + + thermo->correct(); + + radiation->correct(); +} diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/pEqn.H new file mode 100644 index 0000000000..8accc61b7f --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/pEqn.H @@ -0,0 +1,47 @@ +pd.boundaryField() == + p.boundaryField() - rho.boundaryField()*gh.boundaryField() - pRef.value(); + +volScalarField rUA = 1.0/UEqn().A(); +U = rUA*UEqn().H(); +UEqn.clear(); +phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf()); +bool closedVolume = adjustPhi(phi, U, p); +phi -= fvc::interpolate(rho*gh*rUA)*fvc::snGrad(rho)*mesh.magSf(); + +for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) +{ + fvScalarMatrix pdEqn + ( + fvm::laplacian(rho*rUA, pd) == fvc::div(phi) + ); + + pdEqn.setReference(pdRefCell, pdRefValue); + pdEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi -= pdEqn.flux(); + } +} + +#include "continuityErrs.H" + +// Explicitly relax pressure for momentum corrector +pd.relax(); + +p = pd + rho*gh + pRef; + +U -= rUA*(fvc::grad(pd) + fvc::grad(rho)*gh); +U.correctBoundaryConditions(); + +// For closed-volume cases adjust the pressure and density levels +// to obey overall mass continuity +if (closedVolume) +{ + p += (initialMass - fvc::domainIntegrate(thermo->psi()*p)) + /fvc::domainIntegrate(thermo->psi()); +} + +rho = thermo->rho(); +rho.relax(); +Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files new file mode 100644 index 0000000000..e924e9de68 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files @@ -0,0 +1,13 @@ +regionProperties/regionProperties.C + +coupleManager/coupleManager.C + +derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C +derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C +derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C + + +chtMultiRegionFoam.C + +EXE = $(FOAM_APPBIN)/chtMultiRegionFoam + diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options new file mode 100644 index 0000000000..6bf54dad00 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options @@ -0,0 +1,16 @@ +EXE_INC = \ + -Ifluid \ + -Isolid \ + -IregionProperties \ + -IcoupleManager \ + -IderivedFvPatchFields/solidWallTemperatureCoupled \ + -IderivedFvPatchFields/solidWallHeatFluxTemperatureCoupled \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/turbulenceModels + +EXE_LIBS = \ + -lfiniteVolume \ + -lbasicThermophysicalModels \ + -lspecie \ + -lcompressibleTurbulenceModels diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C new file mode 100644 index 0000000000..b815119630 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + chtMultiRegionFoam + +Description + Combination of heatConductionFoam and buoyantFoam for conjugate heat + transfer between a solid region and fluid region + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "basicThermo.H" +#include "compressible/turbulenceModel/turbulenceModel.H" +#include "fixedGradientFvPatchFields.H" +#include "regionProperties.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "solveContinuityEquation.C" +#include "solveMomentumEquation.C" +#include "compressibleContinuityErrors.C" +#include "solvePressureDifferenceEquation.C" +#include "solveEnthalpyEquation.C" +#include "compressibleCourantNo.C" + +int main(int argc, char *argv[]) +{ + +# include "setRootCase.H" +# include "createTime.H" + + regionProperties rp(runTime); + +# include "createFluidMeshes.H" +# include "createSolidMeshes.H" + +# include "createFluidFields.H" + +# include "createSolidFields.H" + +# include "initContinuityErrs.H" + +# include "readTimeControls.H" + + if (fluidRegions.size()) + { +# include "compressibleMultiRegionCourantNo.H" +# include "setInitialDeltaT.H" + } + + while(runTime.run()) + { +# include "readTimeControls.H" + + if (fluidRegions.size()) + { +# include "compressibleMultiRegionCourantNo.H" +# include "setDeltaT.H" + } + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + forAll(fluidRegions, i) + { + Info<< "\nSolving for fluid region " + << fluidRegions[i].name() << endl; +# include "readFluidMultiRegionPISOControls.H" +# include "solveFluid.H" + } + + forAll(solidRegions, i) + { + Info<< "\nSolving for solid region " + << solidRegions[i].name() << endl; +# include "readSolidMultiRegionPISOControls.H" +# include "solveSolid.H" + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info << "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.C new file mode 100644 index 0000000000..0fbe3ea29f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.C @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "coupleManager.H" +#include "OFstream.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::coupleManager::coupleManager(const fvPatch& patch) +: + patch_(patch), + neighbourRegionName_("undefined-neighbourRegionName"), + neighbourPatchName_("undefined-neighbourPatchName"), + neighbourFieldName_("undefined-neighbourFieldName"), + localRegion_(patch_.boundaryMesh().mesh()) +{} + + +Foam::coupleManager::coupleManager +( + const fvPatch& patch, + const dictionary& dict +) +: + patch_(patch), + neighbourRegionName_(dict.lookup("neighbourRegionName")), + neighbourPatchName_(dict.lookup("neighbourPatchName")), + neighbourFieldName_(dict.lookup("neighbourFieldName")), + localRegion_(patch_.boundaryMesh().mesh()) +{} + + +Foam::coupleManager::coupleManager +( + const coupleManager& cm +) +: + patch_(cm.patch()), + neighbourRegionName_(cm.neighbourRegionName()), + neighbourPatchName_(cm.neighbourPatchName()), + neighbourFieldName_(cm.neighbourFieldName()), + localRegion_(patch_.boundaryMesh().mesh()) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::coupleManager::~coupleManager() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::coupleManager::checkCouple() const +{ + Info<< "neighbourRegionName_ = " << neighbourRegionName_ << endl; + Info<< "neighbourPatchName_ = " << neighbourPatchName_ << endl; + Info<< "neighbourFieldName_ = " << neighbourFieldName_ << endl; + + const fvPatch& nPatch = neighbourPatch(); + + if (patch_.size() != nPatch.size()) + { + FatalErrorIn("Foam::coupleManager::checkCouple()") + << "Unequal patch sizes:" << nl + << " patch name (size) = " << patch_.name() + << "(" << patch_.size() << ")" << nl + << " neighbour patch name (size) = " + << nPatch.name() << "(" << patch_.size() << ")" << nl + << abort(FatalError); + } +} + + +void Foam::coupleManager::coupleToObj() const +{ + const fvPatch& nPatch = neighbourPatch(); + + OFstream obj + ( + patch_.name() + "_to_" + nPatch.name() + "_couple.obj" + ); + const vectorField& c1 = patch_.Cf(); + const vectorField& c2 = neighbourPatch().Cf(); + + if (c1.size() != c2.size()) + { + FatalErrorIn("coupleManager::coupleToObj() const") + << "Coupled patches are of unequal size:" << nl + << " patch0 = " << patch_.name() + << "(" << patch_.size() << ")" << nl + << " patch1 = " << nPatch.name() + << "(" << nPatch.size() << ")" << nl + << abort(FatalError); + } + + forAll(c1, i) + { + obj << "v " << c1[i].x() << " " << c1[i].y() << " " << c1[i].z() << nl + << "v " << c2[i].x() << " " << c2[i].y() << " " << c2[i].z() << nl + << "l " << (2*i + 1) << " " << (2*i + 2) << endl; + } +} + + +void Foam::coupleManager::writeEntries(Ostream& os) const +{ + os.writeKeyword("neighbourRegionName"); + os << neighbourRegionName_ << token::END_STATEMENT << nl; + os.writeKeyword("neighbourPatchName"); + os << neighbourPatchName_ << token::END_STATEMENT << nl; + os.writeKeyword("neighbourFieldName"); + os << neighbourFieldName_ << token::END_STATEMENT << nl; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H new file mode 100644 index 0000000000..a6f265faae --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H @@ -0,0 +1,170 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + coupleManager + +Description + Object to handle the coupling of region patches. It can be queried to + return the neighbour information. + +SourceFiles + coupleManager.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coupleManager_H +#define coupleManager_H + +#include "Ostream.H" +#include "dictionary.H" +#include "fvPatch.H" +#include "fvMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class coupleManager Declaration +\*---------------------------------------------------------------------------*/ + +class coupleManager +{ + // Private data + + //- Reference to the local fvPatch + const fvPatch& patch_; + + //- Name of neighbour region + word neighbourRegionName_; + + //- Name of patch on the neighbour region + word neighbourPatchName_; + + //- Name of field on the neighbour region + word neighbourFieldName_; + + //- Reference to the local region + const fvMesh& localRegion_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct +// coupleManager(const coupleManager&); + + //- Disallow default bitwise assignment + void operator=(const coupleManager&); + + +public: + + // Constructors + + //- Construct from fvPatch + coupleManager(const fvPatch& patch); + + //- Construct from fvPatch and dictionary + coupleManager(const fvPatch& patch, const dictionary& dict); + + //- Copy constructor + coupleManager(const coupleManager& cm); + + + // Destructor + + ~coupleManager(); + + + // Member Functions + + // Access + + //- Return a reference to the local patch + inline const fvPatch& patch() const; + + //- Return the name of the neighbour region + inline const word& neighbourRegionName() const; + + //- Return the name of the patch on the neighbour region + inline const word& neighbourPatchName() const; + + //- Return the name of the field on the neighbour region + inline const word& neighbourFieldName() const; + + //- Return a reference to the neighbour mesh + inline const fvMesh& neighbourRegion() const; + + //- Return the neighbour patch ID + inline const label neighbourPatchID() const; + + //- Return a reference to the neighbour patch + inline const fvPatch& neighbourPatch() const; + + //- Return a reference to the neighbour patch field + template + inline const fvPatchField& neighbourPatchField() const; + + //- Check that the couple is valid + void checkCouple() const; + + + // Edit + + //- Return the name of the neighbour region + word& neighbourRegionName(); + + //- Return the name of the patch on the neighbour region + word& neighbourPatchName(); + + //- Return the name of the field on the neighbour region + word& neighbourFieldName(); + + + // Write + + //- Write couple to obj file + void coupleToObj() const; + + //- Write entries for patches + void writeEntries(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "coupleManagerI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManagerI.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManagerI.H new file mode 100644 index 0000000000..5a252d8704 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManagerI.H @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +inline const Foam::fvPatch& Foam::coupleManager::patch() const +{ + return patch_; +}; + + +inline const Foam::word& Foam::coupleManager::neighbourRegionName() const +{ + return neighbourRegionName_; +}; + + +inline const Foam::word& Foam::coupleManager::neighbourPatchName() const +{ + return neighbourPatchName_; +}; + + +inline const Foam::word& Foam::coupleManager::neighbourFieldName() const +{ + return neighbourFieldName_; +}; + + +inline const Foam::fvMesh& Foam::coupleManager::neighbourRegion() const +{ + return localRegion_.objectRegistry::parent() + .lookupObject(neighbourRegionName_); +} + + +inline const Foam::label Foam::coupleManager::neighbourPatchID() const +{ + return neighbourRegion().boundaryMesh().findPatchID(neighbourPatchName_); +} + + +inline const Foam::fvPatch& Foam::coupleManager::neighbourPatch() const +{ + return neighbourRegion().boundary()[neighbourPatchID()]; +} + + +template +inline const Foam::fvPatchField& +Foam::coupleManager::neighbourPatchField() const +{ + return neighbourPatch().lookupPatchField + , Type> + (neighbourFieldName_); +} + + +inline Foam::word& Foam::coupleManager::neighbourRegionName() +{ + return neighbourRegionName_; +}; + + +inline Foam::word& Foam::coupleManager::neighbourPatchName() +{ + return neighbourPatchName_; +}; + + +inline Foam::word& Foam::coupleManager::neighbourFieldName() +{ + return neighbourFieldName_; +}; + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 0000000000..c1fdf3f538 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "solidWallHeatFluxTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + q_(p.size(), 0.0), + KName_("undefined-K") +{} + + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const solidWallHeatFluxTemperatureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + q_(ptf.q_, mapper), + KName_(ptf.KName_) +{} + + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + q_("q", dict, p.size()), + KName_(dict.lookup("K")) +{} + + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf), + q_(tppsf.q_), + KName_(tppsf.KName_) +{} + + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF), + q_(tppsf.q_), + KName_(tppsf.KName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchScalarField::autoMap(m); + q_.autoMap(m); +} + + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const solidWallHeatFluxTemperatureFvPatchScalarField& hfptf = + refCast(ptf); + + q_.rmap(hfptf.q_, addr); +} + + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const scalarField& Kw = + patch().lookupPatchField(KName_); + + const fvPatchScalarField& Tw = *this; + + operator==(q_/(patch().deltaCoeffs()*Kw) + Tw.patchInternalField()); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::write +( + Ostream& os +) const +{ + fixedValueFvPatchScalarField::write(os); + q_.writeEntry("q", os); + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + solidWallHeatFluxTemperatureFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H new file mode 100644 index 0000000000..a03fe7bf39 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + solidWallHeatFluxTemperatureFvPatchScalarField + +Description + Heat flux boundary condition for temperature on solid region + + Example usage: + myWallPatch + { + type solidWallHeatFluxTemperature; + K K; // Name of K field + q uniform 1000; // Heat flux / [W/m2] + value 300.0; // Initial temperature / [K] + } + + +SourceFiles + solidWallHeatFluxTemperatureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidWallHeatFluxTemperatureFvPatchScalarField_H +#define solidWallHeatFluxTemperatureFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class solidWallHeatFluxTemperatureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class solidWallHeatFluxTemperatureFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Heat flux / [W/m2] + scalarField q_; + + //- Name of thermal conductivity field + word KName_; + + +public: + + //- Runtime type information + TypeName("solidWallHeatFluxTemperature"); + + + // Constructors + + //- Construct from patch and internal field + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // solidWallHeatFluxTemperatureFvPatchScalarField + // onto a new patch + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const solidWallHeatFluxTemperatureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const solidWallHeatFluxTemperatureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new solidWallHeatFluxTemperatureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const solidWallHeatFluxTemperatureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new solidWallHeatFluxTemperatureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C new file mode 100644 index 0000000000..43a859a408 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +#include "solidWallTemperatureCoupledFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField:: +solidWallHeatFluxTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(p, iF), + coupleManager_(p), + KName_("undefined-K") +{} + + +Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField:: +solidWallHeatFluxTemperatureCoupledFvPatchScalarField +( + const solidWallHeatFluxTemperatureCoupledFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedGradientFvPatchScalarField(ptf, p, iF, mapper), + coupleManager_(ptf.coupleManager_), + KName_(ptf.KName_) +{} + + +Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField:: +solidWallHeatFluxTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedGradientFvPatchScalarField(p, iF), + coupleManager_(p, dict), + KName_(dict.lookup("K")) +{ + if (dict.found("value")) + { + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + evaluate(); + } +} + + +Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField:: +solidWallHeatFluxTemperatureCoupledFvPatchScalarField +( + const solidWallHeatFluxTemperatureCoupledFvPatchScalarField& whftcsf, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(whftcsf, iF), + coupleManager_(whftcsf.coupleManager_), + KName_(whftcsf.KName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvPatchField& neighbourField = + coupleManager_.neighbourPatchField(); + + const fvPatchField& K = + patch().lookupPatchField(KName_); + + gradient() = refCast + (neighbourField).flux()/K; + + fixedGradientFvPatchScalarField::updateCoeffs(); +} + + +void Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + coupleManager_.writeEntries(os); + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +makePatchTypeField +( + fvPatchScalarField, + solidWallHeatFluxTemperatureCoupledFvPatchScalarField +); + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H new file mode 100644 index 0000000000..12b75c1800 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H @@ -0,0 +1,165 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + solidWallHeatFluxTemperatureCoupledFvPatchScalarField + +Description + Fixed heat-flux boundary condition for temperature, to be used by the + conjugate heat transfer solver. + + Example usage: + myInterfacePatchName + { + type solidWallHeatFluxTemperatureCoupled; + neighbourRegionName fluid; + neighbourPatchName fluidSolidInterface; + neighbourFieldName T; + K K; + value uniform 300; + } + +SourceFiles + solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidWallHeatFluxTemperatureCoupledFvPatchScalarField_H +#define solidWallHeatFluxTemperatureCoupledFvPatchScalarField_H + +#include "fvPatchFields.H" +#include "fixedGradientFvPatchFields.H" +#include "coupleManager.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class solidWallHeatFluxTemperatureCoupledFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class solidWallHeatFluxTemperatureCoupledFvPatchScalarField +: + public fixedGradientFvPatchScalarField +{ + // Private data + + //- Couple manager object + coupleManager coupleManager_; + + //- Name of thermal conductivity field + word KName_; + + +public: + + //- Runtime type information + TypeName("solidWallHeatFluxTemperatureCoupled"); + + + // Constructors + + //- Construct from patch and internal field + solidWallHeatFluxTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + solidWallHeatFluxTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // solidWallHeatFluxTemperatureCoupledFvPatchScalarField + // onto a new patch + solidWallHeatFluxTemperatureCoupledFvPatchScalarField + ( + const solidWallHeatFluxTemperatureCoupledFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new solidWallHeatFluxTemperatureCoupledFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + solidWallHeatFluxTemperatureCoupledFvPatchScalarField + ( + const solidWallHeatFluxTemperatureCoupledFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new solidWallHeatFluxTemperatureCoupledFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C new file mode 100644 index 0000000000..b1480446bd --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C @@ -0,0 +1,156 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "solidWallTemperatureCoupledFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidWallTemperatureCoupledFvPatchScalarField:: +solidWallTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + coupleManager_(p), + KName_("undefined-K") +{} + + +Foam::solidWallTemperatureCoupledFvPatchScalarField:: +solidWallTemperatureCoupledFvPatchScalarField +( + const solidWallTemperatureCoupledFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + coupleManager_(ptf.coupleManager_), + KName_(ptf.KName_) +{} + + +Foam::solidWallTemperatureCoupledFvPatchScalarField:: +solidWallTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF), + coupleManager_(p, dict), + KName_(dict.lookup("K")) +{ + if (dict.found("value")) + { + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + evaluate(); + } +} + + +Foam::solidWallTemperatureCoupledFvPatchScalarField:: +solidWallTemperatureCoupledFvPatchScalarField +( + const solidWallTemperatureCoupledFvPatchScalarField& wtcsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(wtcsf, iF), + coupleManager_(wtcsf.coupleManager_), + KName_(wtcsf.KName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::solidWallTemperatureCoupledFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvPatchField& neighbourField = + coupleManager_.neighbourPatchField(); + + operator==(neighbourField); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +void Foam::solidWallTemperatureCoupledFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + coupleManager_.writeEntries(os); + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +Foam::tmp +Foam::solidWallTemperatureCoupledFvPatchScalarField::flux() const +{ + const fvPatchScalarField& Kw = + patch().lookupPatchField(KName_); + + const fvPatchScalarField& Tw = *this; + + return Tw.snGrad()*patch().magSf()*Kw; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +makePatchTypeField +( + fvPatchScalarField, + solidWallTemperatureCoupledFvPatchScalarField +); + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.H new file mode 100644 index 0000000000..abf33a7b43 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.H @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + solidWallHeatFluxCoupledFvPatchScalarField + +Description + Fixed value boundary condition for temperature, to be used by the + conjugate heat transfer solver. + + Example usage: + myInterfacePatchName + { + type solidWallTemperatureCoupled; + neighbourRegionName fluid; + neighbourPatchName fluidSolidInterface; + neighbourFieldName T; + K K; + value uniform 300; + } + +SourceFiles + solidWallTemperatureCoupledFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidWallTemperatureCoupledFvPatchScalarField_H +#define solidWallTemperatureCoupledFvPatchScalarField_H + +#include "fvPatchFields.H" +#include "fixedValueFvPatchFields.H" +#include "coupleManager.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class solidWallTemperatureCoupledFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class solidWallTemperatureCoupledFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Couple manager object + coupleManager coupleManager_; + + //- Name of thermal conductivity field + word KName_; + + +public: + + //- Runtime type information + TypeName("solidWallTemperatureCoupled"); + + + // Constructors + + //- Construct from patch and internal field + solidWallTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + solidWallTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given solidWallTemperatureCoupledFvPatchScalarField + // onto a new patch + solidWallTemperatureCoupledFvPatchScalarField + ( + const solidWallTemperatureCoupledFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new solidWallTemperatureCoupledFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + solidWallTemperatureCoupledFvPatchScalarField + ( + const solidWallTemperatureCoupledFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new solidWallTemperatureCoupledFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + //- Flux + tmp flux() const; + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H new file mode 100644 index 0000000000..ba3d099a9f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H @@ -0,0 +1,10 @@ + tmp UEqn = solveMomentumEquation + ( + momentumPredictor, + Uf[i], + rhof[i], + phif[i], + pdf[i], + ghf[i], + turb[i] + ); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleContinuityErrors.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleContinuityErrors.C new file mode 100644 index 0000000000..8101c81e93 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleContinuityErrors.C @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Continuity errors for fluid meshes + +\*---------------------------------------------------------------------------*/ + +void compressibleContinuityErrors +( + scalar& cumulativeContErr, + const volScalarField& rho, + const basicThermo& thermo +) +{ + dimensionedScalar totalMass = fvc::domainIntegrate(rho); + + scalar sumLocalContErr = + ( + fvc::domainIntegrate(mag(rho - thermo.rho()))/totalMass + ).value(); + + scalar globalContErr = + ( + fvc::domainIntegrate(rho - thermo.rho())/totalMass + ).value(); + + cumulativeContErr += globalContErr; + + const word& regionName = rho.mesh().name(); + + Info<< "time step continuity errors (" << regionName << ")" + << ": sum local = " << sumLocalContErr + << ", global = " << globalContErr + << ", cumulative = " << cumulativeContErr + << endl; +} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C new file mode 100644 index 0000000000..ce1f54aca1 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleCourantNo.C @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Calculates and outputs the mean and maximum Courant Numbers for the fluid + regions + +\*---------------------------------------------------------------------------*/ + +scalar compressibleCourantNo +( + const fvMesh& mesh, + const Time& runTime, + const volScalarField& rho, + const surfaceScalarField& phi +) +{ + scalar CoNum = 0.0; + scalar meanCoNum = 0.0; + + if (mesh.nInternalFaces()) + { + surfaceScalarField SfUfbyDelta = + mesh.surfaceInterpolation::deltaCoeffs() + * mag(phi) + / fvc::interpolate(rho); + + CoNum = max(SfUfbyDelta/mesh.magSf()) + .value()*runTime.deltaT().value(); + + meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) + .value()*runTime.deltaT().value(); + } + + Info<< "Region: " << mesh.name() << " Courant Number mean: " << meanCoNum + << " max: " << CoNum << endl; + + return CoNum; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H new file mode 100644 index 0000000000..68c3621ec1 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H @@ -0,0 +1,15 @@ + scalar CoNum = -GREAT; + forAll(fluidRegions, regionI) + { + CoNum = max + ( + compressibleCourantNo + ( + fluidRegions[regionI], + runTime, + rhof[regionI], + phif[regionI] + ), + CoNum + ); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H new file mode 100644 index 0000000000..73c51deeec --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -0,0 +1,181 @@ + // Initialise fluid field pointer lists + PtrList thermof(fluidRegions.size()); + PtrList rhof(fluidRegions.size()); + PtrList Kf(fluidRegions.size()); + PtrList Uf(fluidRegions.size()); + PtrList phif(fluidRegions.size()); + PtrList turb(fluidRegions.size()); + PtrList DpDtf(fluidRegions.size()); + PtrList ghf(fluidRegions.size()); + PtrList pdf(fluidRegions.size()); + + List initialMassf(fluidRegions.size()); + + dimensionedScalar pRef("pRef", dimensionSet(1, -1, -2, 0, 0), 1.0E5); + + // Populate fluid field pointer lists + forAll(fluidRegions, i) + { + Info<< "*** Reading fluid mesh thermophysical properties for region " + << fluidRegions[i].name() << nl << endl; + + Info<< " Adding to pdf\n" << endl; + pdf.set + ( + i, + new volScalarField + ( + IOobject + ( + "pd", + runTime.timeName(), + fluidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + fluidRegions[i] + ) + ); + + Info<< " Adding to thermof\n" << endl; + + thermof.set + ( + i, + autoPtr + ( + basicThermo::New(fluidRegions[i]) + ).ptr() + ); + + Info<< " Adding to rhof\n" << endl; + rhof.set + ( + i, + new volScalarField + ( + IOobject + ( + "rho", + runTime.timeName(), + fluidRegions[i], + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + thermof[i].rho() + ) + ); + + Info<< " Adding to Kf\n" << endl; + Kf.set + ( + i, + new volScalarField + ( + IOobject + ( + "K", + runTime.timeName(), + fluidRegions[i], + IOobject::NO_READ, + IOobject::NO_WRITE + ), + thermof[i].rho()*thermof[i].Cp()*thermof[i].alpha() + ) + ); + + Info<< " Adding to Uf\n" << endl; + Uf.set + ( + i, + new volVectorField + ( + IOobject + ( + "U", + runTime.timeName(), + fluidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + fluidRegions[i] + ) + ); + + Info<< " Adding to phif\n" << endl; + phif.set + ( + i, + new surfaceScalarField + ( + IOobject + ( + "phi", + runTime.timeName(), + fluidRegions[i], + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + linearInterpolate(rhof[i]*Uf[i]) + & fluidRegions[i].Sf() + ) + ); + + Info<< " Adding to turb\n" << endl; + turb.set + ( + i, + autoPtr + ( + compressible::turbulenceModel::New + ( + rhof[i], + Uf[i], + phif[i], + thermof[i] + ) + ).ptr() + ); + + Info<< " Adding to DpDtf\n" << endl; + DpDtf.set + ( + i, + new volScalarField + ( + fvc::DDt + ( + surfaceScalarField + ( + "phiU", + phif[i]/fvc::interpolate(rhof[i]) + ), + thermof[i].p() + ) + ) + ); + + const dictionary& environmentalProperties = + fluidRegions[i].lookupObject + ("environmentalProperties"); + dimensionedVector g(environmentalProperties.lookup("g")); + + Info<< " Adding to ghf\n" << endl; + ghf.set + ( + i, + new volScalarField + ( + "gh", + g & fluidRegions[i].C() + ) + ); + + Info<< " Updating p from pd\n" << endl; + thermof[i].p() == pdf[i] + rhof[i]*ghf[i] + pRef; + + + initialMassf[i] = fvc::domainIntegrate(rhof[i]).value(); + } + + diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidMeshes.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidMeshes.H new file mode 100644 index 0000000000..aec08349ec --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidMeshes.H @@ -0,0 +1,45 @@ + PtrList fluidRegions(rp.fluidRegionNames().size()); + + forAll(rp.fluidRegionNames(), i) + { + Info<< "Create fluid mesh for region " << rp.fluidRegionNames()[i] + << " for time = " << runTime.timeName() << nl << endl; + + fluidRegions.set + ( + i, + new fvMesh + ( + IOobject + ( + rp.fluidRegionNames()[i], + runTime.timeName(), + runTime, + IOobject::MUST_READ + ) + ) + ); + + // Force calculation of geometric properties to prevent it being done + // later in e.g. some boundary evaluation + //(void)fluidRegions[i].weights(); + //(void)fluidRegions[i].deltaCoeffs(); + + // Attach environmental properties to each region + autoPtr environmentalProperties + ( + new IOdictionary + ( + IOobject + ( + "environmentalProperties", + runTime.constant(), + fluidRegions[i], + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) + ); + + environmentalProperties.ptr()->store(); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H new file mode 100644 index 0000000000..301ceddfdb --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H @@ -0,0 +1,9 @@ + solveEnthalpyEquation + ( + rhof[i], + DpDtf[i], + phif[i], + turb[i], + thermof[i] + ); + diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H new file mode 100644 index 0000000000..9e07ab170c --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H @@ -0,0 +1,66 @@ +{ + bool closedVolume = false; + + //pdf[i].boundaryField() == + // thermof[i].p().boundaryField() + // - rhof[i].boundaryField()*ghf[i].boundaryField() + // - pRef.value(); + + rhof[i] = thermof[i].rho(); + + volScalarField rUA = 1.0/UEqn().A(); + Uf[i] = rUA*UEqn().H(); + + phif[i] = + fvc::interpolate(rhof[i]) + *( + (fvc::interpolate(Uf[i]) & fluidRegions[i].Sf()) +// + fvc::ddtPhiCorr(rUA, rhof[i], Uf[i], phif[i]) + ) + - fvc::interpolate(rhof[i]*rUA*ghf[i]) + *fvc::snGrad(rhof[i]) + *fluidRegions[i].magSf(); + + // Solve pressure difference +# include "pdEqn.H" + + // Solve continuity +# include "rhoEqn.H" + + // Update pressure field (including bc) + thermof[i].p() == pdf[i] + rhof[i]*ghf[i] + pRef; + DpDtf[i] = fvc::DDt + ( + surfaceScalarField("phiU", phif[i]/fvc::interpolate(rhof[i])), + thermof[i].p() + ); + + // Update continuity errors + compressibleContinuityErrors(cumulativeContErr, rhof[i], thermof[i]); + + // Correct velocity field + Uf[i] -= rUA*(fvc::grad(pdf[i]) + fvc::grad(rhof[i])*ghf[i]); + Uf[i].correctBoundaryConditions(); + + // For closed-volume cases adjust the pressure and density levels + // to obey overall mass continuity + if (closedVolume) + { + thermof[i].p() += + ( + dimensionedScalar + ( + "massIni", + dimMass, + initialMassf[i] + ) + - fvc::domainIntegrate(thermof[i].psi()*thermof[i].p()) + ) + /fvc::domainIntegrate(thermof[i].psi()); + + rhof[i] = thermof[i].rho(); + } + + // Update thermal conductivity + Kf[i] = rhof[i]*thermof[i].Cp()*turb[i].alphaEff(); +} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pdEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pdEqn.H new file mode 100644 index 0000000000..a393843256 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pdEqn.H @@ -0,0 +1,14 @@ + solvePressureDifferenceEquation + ( + corr, + nCorr, + nNonOrthCorr, + closedVolume, + pdf[i], + pRef, + rhof[i], + thermof[i].psi(), + rUA, + ghf[i], + phif[i] + ); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H new file mode 100644 index 0000000000..75d6d96d11 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPISOControls.H @@ -0,0 +1,27 @@ + dictionary piso = fluidRegions[i].solutionDict().subDict("PISO"); + + int nCorr(readInt(piso.lookup("nCorrectors"))); + + int nNonOrthCorr = 0; + if (piso.found("nNonOrthogonalCorrectors")) + { + nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors")); + } + + bool momentumPredictor = true; + if (piso.found("momentumPredictor")) + { + momentumPredictor = Switch(piso.lookup("momentumPredictor")); + } + + bool transonic = false; + if (piso.found("transonic")) + { + transonic = Switch(piso.lookup("transonic")); + } + + int nOuterCorr = 1; + if (piso.found("nOuterCorrectors")) + { + nOuterCorr = readInt(piso.lookup("nOuterCorrectors")); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rhoEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rhoEqn.H new file mode 100644 index 0000000000..a7e2a98c4a --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rhoEqn.H @@ -0,0 +1 @@ + solveContinuityEquation(rhof[i], phif[i]); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setInitialDeltaT.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setInitialDeltaT.H new file mode 100644 index 0000000000..161eb742e7 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setInitialDeltaT.H @@ -0,0 +1,15 @@ + if (adjustTimeStep) + { + if (CoNum > SMALL) + { + runTime.setDeltaT + ( + min + ( + maxCo*runTime.deltaT().value()/CoNum, + maxDeltaT + ) + ); + } + } + diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveContinuityEquation.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveContinuityEquation.C new file mode 100644 index 0000000000..3d834a32ae --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveContinuityEquation.C @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Solve continuity equation + +\*---------------------------------------------------------------------------*/ + +void solveContinuityEquation +( + volScalarField& rho, + const surfaceScalarField& phi +) +{ + solve(fvm::ddt(rho) + fvc::div(phi)); +} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveEnthalpyEquation.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveEnthalpyEquation.C new file mode 100644 index 0000000000..9c9ba030c3 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveEnthalpyEquation.C @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Solve enthalpy equation + +\*---------------------------------------------------------------------------*/ + +void solveEnthalpyEquation +( + const volScalarField& rho, + const volScalarField& DpDt, + const surfaceScalarField& phi, + const compressible::turbulenceModel& turb, + basicThermo& thermo +) +{ + volScalarField& h = thermo.h(); + + tmp hEqn + ( + fvm::ddt(rho, h) + + fvm::div(phi, h) + - fvm::laplacian(turb.alphaEff(), h) + == + DpDt + ); + hEqn().relax(); + hEqn().solve(); + + thermo.correct(); + + Info<< "Min/max T:" << min(thermo.T()) << ' ' << max(thermo.T()) + << endl; +} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H new file mode 100644 index 0000000000..e24771256f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H @@ -0,0 +1,15 @@ +# include "rhoEqn.H" + for (int ocorr=0; ocorr solveMomentumEquation +( + const bool momentumPredictor, + volVectorField& U, + const volScalarField& rho, + const surfaceScalarField& phi, + const volScalarField& pd, + const volScalarField& gh, + const compressible::turbulenceModel& turb +) +{ + // Solve the Momentum equation + tmp UEqn + ( + fvm::ddt(rho, U) + + fvm::div(phi, U) + + turb.divDevRhoReff(U) + ); + + UEqn().relax(); + + if (momentumPredictor) + { + solve(UEqn() == -fvc::grad(pd) - fvc::grad(rho)*gh); + } + + return UEqn; +} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solvePressureDifferenceEquation.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solvePressureDifferenceEquation.C new file mode 100644 index 0000000000..3dbd6c8264 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solvePressureDifferenceEquation.C @@ -0,0 +1,73 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Solve pressure difference equation + +\*---------------------------------------------------------------------------*/ + +void solvePressureDifferenceEquation +( + const label corr, + const label nCorr, + const label nNonOrthCorr, + bool& closedVolume, + volScalarField& pd, + const dimensionedScalar& pRef, + const volScalarField& rho, + const volScalarField& psi, + const volScalarField& rUA, + const volScalarField& gh, + surfaceScalarField& phi +) +{ + closedVolume = pd.needReference(); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pdEqn + ( + fvm::ddt(psi, pd) + + fvc::ddt(psi)*pRef + + fvc::ddt(psi, rho)*gh + + fvc::div(phi) + - fvm::laplacian(rho*rUA, pd) + ); + + //pdEqn.solve(); + if (corr == nCorr-1 && nonOrth == nNonOrthCorr) + { + pdEqn.solve(pd.mesh().solver(pd.name() + "Final")); + } + else + { + pdEqn.solve(pd.mesh().solver(pd.name())); + } + + if (nonOrth == nNonOrthCorr) + { + phi += pdEqn.flux(); + } + } +} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.C new file mode 100644 index 0000000000..8e70c6f07e --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "regionProperties.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::regionProperties::regionProperties(const Time& runTime) +: + IOdictionary + ( + IOobject + ( + "regionProperties", + runTime.time().constant(), + runTime.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + fluidRegionNames_(lookup("fluidRegionNames")), + solidRegionNames_(lookup("solidRegionNames")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::regionProperties::~regionProperties() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::List& Foam::regionProperties::fluidRegionNames() const +{ + return fluidRegionNames_; +} + + +const Foam::List& Foam::regionProperties::solidRegionNames() const +{ + return solidRegionNames_; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.H new file mode 100644 index 0000000000..86e00a5476 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/regionProperties/regionProperties.H @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + regionProperties + +Description + Simple class to hold region information for coupled region simulations + +SourceFiles + regionProperties.C + +\*---------------------------------------------------------------------------*/ + +#ifndef regionProperties_H +#define regionProperties_H + +#include "IOdictionary.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class regionProperties Declaration +\*---------------------------------------------------------------------------*/ + +class regionProperties +: + public IOdictionary +{ + // Private data + + //- List of the fluid region names + List fluidRegionNames_; + + //- List of the solid region names + List solidRegionNames_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + regionProperties(const regionProperties&); + + //- Disallow default bitwise assignment + void operator=(const regionProperties&); + + +public: + + // Constructors + + //- Construct from components + regionProperties(const Time& runTime); + + + // Destructor + + ~regionProperties(); + + + // Member Functions + + // Access + + //- Return const reference to the list of fluid region names + const List& fluidRegionNames() const; + + //- Return const reference to the list of solid region names + const List& solidRegionNames() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H new file mode 100644 index 0000000000..3361a89add --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H @@ -0,0 +1,91 @@ + // Initialise solid field pointer lists + PtrList rhos(solidRegions.size()); + PtrList cps(solidRegions.size()); + PtrList rhosCps(solidRegions.size()); + PtrList Ks(solidRegions.size()); + PtrList Ts(solidRegions.size()); + + // Populate solid field pointer lists + forAll(solidRegions, i) + { + Info<< "*** Reading solid mesh thermophysical properties for region " + << solidRegions[i].name() << nl << endl; + + Info<< " Adding to rhos\n" << endl; + rhos.set + ( + i, + new volScalarField + ( + IOobject + ( + "rho", + runTime.timeName(), + solidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidRegions[i] + ) + ); + + Info<< " Adding to cps\n" << endl; + cps.set + ( + i, + new volScalarField + ( + IOobject + ( + "cp", + runTime.timeName(), + solidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidRegions[i] + ) + ); + + rhosCps.set + ( + i, + new volScalarField("rhosCps", rhos[i]*cps[i]) + ); + + Info<< " Adding to Ks\n" << endl; + Ks.set + ( + i, + new volScalarField + ( + IOobject + ( + "K", + runTime.timeName(), + solidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidRegions[i] + ) + ); + + Info<< " Adding to Ts\n" << endl; + Ts.set + ( + i, + new volScalarField + ( + IOobject + ( + "T", + runTime.timeName(), + solidRegions[i], + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidRegions[i] + ) + ); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidMeshes.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidMeshes.H new file mode 100644 index 0000000000..eb50be2380 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidMeshes.H @@ -0,0 +1,27 @@ + PtrList solidRegions(rp.solidRegionNames().size()); + + forAll(rp.solidRegionNames(), i) + { + Info<< "Create solid mesh for region " << rp.solidRegionNames()[i] + << " for time = " << runTime.timeName() << nl << endl; + + solidRegions.set + ( + i, + new fvMesh + ( + IOobject + ( + rp.solidRegionNames()[i], + runTime.timeName(), + runTime, + IOobject::MUST_READ + ) + ) + ); + + // Force calculation of geometric properties to prevent it being done + // later in e.g. some boundary evaluation + //(void)solidRegions[i].weights(); + //(void)solidRegions[i].deltaCoeffs(); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H new file mode 100644 index 0000000000..6373e79d49 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H @@ -0,0 +1,7 @@ + dictionary piso = solidRegions[i].solutionDict().subDict("PISO"); + + int nNonOrthCorr = 0; + if (piso.found("nNonOrthogonalCorrectors")) + { + nNonOrthCorr = readInt(piso.lookup("nNonOrthogonalCorrectors")); + } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H new file mode 100644 index 0000000000..40299e7b57 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H @@ -0,0 +1,9 @@ +{ + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + solve + ( + fvm::ddt(rhosCps[i], Ts[i]) - fvm::laplacian(Ks[i], Ts[i]) + ); + } +} diff --git a/applications/solvers/heatTransfer/lesBuoyantFoam/lesBuoyantFoam.C b/applications/solvers/heatTransfer/lesBuoyantFoam/lesBuoyantFoam.C index 4833e3bbb9..1868d0322e 100644 --- a/applications/solvers/heatTransfer/lesBuoyantFoam/lesBuoyantFoam.C +++ b/applications/solvers/heatTransfer/lesBuoyantFoam/lesBuoyantFoam.C @@ -27,7 +27,8 @@ Application Description Transient Solver for buoyant, turbulent flow of compressible fluids for - ventilation and heat-transfer. + ventilation and heat-transfer. Turbulence is modelled using a run-time + selectable compressible LES model. \*---------------------------------------------------------------------------*/ diff --git a/applications/solvers/incompressible/icoDyMFoam/icoDyMFoam.C b/applications/solvers/incompressible/icoDyMFoam/icoDyMFoam.C index 54f64497f4..39774a3373 100644 --- a/applications/solvers/incompressible/icoDyMFoam/icoDyMFoam.C +++ b/applications/solvers/incompressible/icoDyMFoam/icoDyMFoam.C @@ -75,6 +75,9 @@ int main(int argc, char *argv[]) # include "correctPhi.H" } + // Keep the absolute fluxes for use in ddtPhiCorr + surfaceScalarField phiAbs("phiAbs", phi); + // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); @@ -95,7 +98,11 @@ int main(int argc, char *argv[]) U = rAU*UEqn.H(); phi = (fvc::interpolate(U) & mesh.Sf()); - //+ fvc::ddtPhiCorr(rAU, U, phi); + + if (ddtPhiCorr) + { + phi += fvc::ddtPhiCorr(rAU, U, phiAbs); + } adjustPhi(phi, U, p); @@ -116,7 +123,7 @@ int main(int argc, char *argv[]) { pEqn.solve(mesh.solver(p.name())); } - + if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); diff --git a/applications/solvers/multiphase/cavitatingFoam/Make/files b/applications/solvers/multiphase/cavitatingFoam/Make/files deleted file mode 100644 index 0538afb2fa..0000000000 --- a/applications/solvers/multiphase/cavitatingFoam/Make/files +++ /dev/null @@ -1,8 +0,0 @@ -cavitatingFoam.C -compressibilityModels/compressibilityModel/compressibilityModel.C -compressibilityModels/compressibilityModel/newCompressibilityModel.C -compressibilityModels/linear/linear.C -compressibilityModels/Wallis/Wallis.C -compressibilityModels/Chung/Chung.C - -EXE = $(FOAM_APPBIN)/cavitatingFoam diff --git a/applications/solvers/multiphase/cavitatingFoam/Make/options b/applications/solvers/multiphase/cavitatingFoam/Make/options deleted file mode 100644 index fc217bef43..0000000000 --- a/applications/solvers/multiphase/cavitatingFoam/Make/options +++ /dev/null @@ -1,6 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ - -IcompressibilityModels/compressibilityModel - -EXE_LIBS = \ - -lfiniteVolume diff --git a/applications/solvers/multiphase/cavitatingFoam/UEqn.H b/applications/solvers/multiphase/cavitatingFoam/UEqn.H deleted file mode 100644 index bbd5e31fa9..0000000000 --- a/applications/solvers/multiphase/cavitatingFoam/UEqn.H +++ /dev/null @@ -1,16 +0,0 @@ - surfaceScalarField gammaf = fvc::interpolate(gamma); - surfaceScalarField muf("muf", gammaf*muv + (1.0 - gammaf)*mul); - - fvVectorMatrix UEqn - ( - fvm::ddt(rho, U) - + fvm::div(phi, U) - - fvm::laplacian(muf, U) - //- (fvc::grad(U) & fvc::grad(muf)) - - fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) - ); - - if (momentumPredictor) - { - solve(UEqn == -fvc::grad(p)); - } diff --git a/applications/solvers/multiphase/cavitatingFoam/readTransportProperties.H b/applications/solvers/multiphase/cavitatingFoam/readTransportProperties.H deleted file mode 100644 index e413743b78..0000000000 --- a/applications/solvers/multiphase/cavitatingFoam/readTransportProperties.H +++ /dev/null @@ -1,23 +0,0 @@ - Info<< "Reading transportProperties\n" << endl; - - IOdictionary transportProperties - ( - IOobject - ( - "transportProperties", - runTime.constant(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); - - dimensionedScalar mul - ( - transportProperties.lookup("mul") - ); - - dimensionedScalar muv - ( - transportProperties.lookup("muv") - ); diff --git a/applications/solvers/multiphase/compressibleLesInterFoam/Make/files b/applications/solvers/multiphase/compressibleLesInterFoam/Make/files new file mode 100644 index 0000000000..0ec38b8d7a --- /dev/null +++ b/applications/solvers/multiphase/compressibleLesInterFoam/Make/files @@ -0,0 +1,3 @@ +compressibleLesInterFoam.C + +EXE = $(FOAM_USER_APPBIN)/compressibleLesInterFoam diff --git a/applications/solvers/multiphase/compressibleLesInterFoam/Make/options b/applications/solvers/multiphase/compressibleLesInterFoam/Make/options new file mode 100644 index 0000000000..7f7317e77a --- /dev/null +++ b/applications/solvers/multiphase/compressibleLesInterFoam/Make/options @@ -0,0 +1,15 @@ +INTERFOAM = $(FOAM_SOLVERS)/multiphase/interFoam + +EXE_INC = \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I$(LIB_SRC)/LESmodels \ + -I$(LIB_SRC)/LESmodels/LESdeltas/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -linterfaceProperties \ + -lincompressibleTransportModels \ + -lincompressibleLESmodels \ + -lfiniteVolume diff --git a/applications/solvers/multiphase/compressibleLesInterFoam/UEqn.H b/applications/solvers/multiphase/compressibleLesInterFoam/UEqn.H new file mode 100644 index 0000000000..0895917367 --- /dev/null +++ b/applications/solvers/multiphase/compressibleLesInterFoam/UEqn.H @@ -0,0 +1,29 @@ + surfaceScalarField muf = + twoPhaseProperties.muf() + + fvc::interpolate(rho*turbulence->nuSgs()); + + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(rhoPhi, U) + - fvm::laplacian(muf, U) + - (fvc::grad(U) & fvc::grad(muf)) + //- fvc::div(muf*(mesh.Sf() & fvc::interpolate(fvc::grad(U)().T()))) + ); + + if (momentumPredictor) + { + solve + ( + UEqn + == + fvc::reconstruct + ( + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + - fvc::snGrad(pd) + ) * mesh.magSf() + ) + ); + } diff --git a/applications/solvers/multiphase/compressibleLesInterFoam/alphaEqns.H b/applications/solvers/multiphase/compressibleLesInterFoam/alphaEqns.H new file mode 100644 index 0000000000..12eea31127 --- /dev/null +++ b/applications/solvers/multiphase/compressibleLesInterFoam/alphaEqns.H @@ -0,0 +1,76 @@ +{ + word alphaScheme("div(phi,alpha)"); + word alpharScheme("div(phirb,alpha)"); + + surfaceScalarField phir = phic*interface.nHatf(); + + for (int gCorr=0; gCorr 0.0 && alpha1[celli] > 0.0) + { + Sp[celli] -= dgdt[celli]*alpha1[celli]; + Su[celli] += dgdt[celli]*alpha1[celli]; + } + else if (dgdt[celli] < 0.0 && alpha1[celli] < 1.0) + { + Sp[celli] += dgdt[celli]*(1.0 - alpha1[celli]); + } + } + + + surfaceScalarField phiAlpha1 = + fvc::flux + ( + phi, + alpha1, + alphaScheme + ) + + fvc::flux + ( + -fvc::flux(-phir, alpha2, alpharScheme), + alpha1, + alpharScheme + ); + + MULES::explicitSolve(oneField(), alpha1, phi, phiAlpha1, Sp, Su, 1, 0); + + surfaceScalarField rho1f = fvc::interpolate(rho1); + surfaceScalarField rho2f = fvc::interpolate(rho2); + rhoPhi = phiAlpha1*(rho1f - rho2f) + phi*rho2f; + + alpha2 = scalar(1) - alpha1; + } + + Info<< "Liquid phase volume fraction = " + << alpha1.weightedAverage(mesh.V()).value() + << " Min(alpha1) = " << min(alpha1).value() + << " Min(alpha2) = " << min(alpha2).value() + << endl; +} diff --git a/applications/solvers/multiphase/compressibleLesInterFoam/alphaEqnsSubCycle.H b/applications/solvers/multiphase/compressibleLesInterFoam/alphaEqnsSubCycle.H new file mode 100644 index 0000000000..c52dce9690 --- /dev/null +++ b/applications/solvers/multiphase/compressibleLesInterFoam/alphaEqnsSubCycle.H @@ -0,0 +1,43 @@ +{ + label nAlphaCorr + ( + readLabel(piso.lookup("nAlphaCorr")) + ); + + label nAlphaSubCycles + ( + readLabel(piso.lookup("nAlphaSubCycles")) + ); + + surfaceScalarField phic = mag(phi/mesh.magSf()); + phic = min(interface.cGamma()*phic, max(phic)); + + volScalarField divU = fvc::div(phi); + + if (nAlphaSubCycles > 1) + { + dimensionedScalar totalDeltaT = runTime.deltaT(); + surfaceScalarField rhoPhiSum = 0.0*rhoPhi; + + for + ( + subCycle alphaSubCycle(alpha1, nAlphaSubCycles); + !(++alphaSubCycle).end(); + ) + { +# include "alphaEqns.H" + rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi; + } + + rhoPhi = rhoPhiSum; + } + else + { +# include "alphaEqns.H" + } + + if (oCorr == 0) + { + interface.correct(); + } +} diff --git a/applications/solvers/multiphase/compressibleLesInterFoam/compressibleLesInterFoam.C b/applications/solvers/multiphase/compressibleLesInterFoam/compressibleLesInterFoam.C new file mode 100644 index 0000000000..6a7874f196 --- /dev/null +++ b/applications/solvers/multiphase/compressibleLesInterFoam/compressibleLesInterFoam.C @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + compressibleLesInterFoam + +Description + Solver for 2 compressible, isothermal immiscible fluids using a VOF + (volume of fluid) phase-fraction based interface capturing approach. + The momentum and other fluid properties are of the "mixture" and a single + momentum equation is solved. Turbulence is modelled using a run-time + selectable incompressible LES model. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "MULES.H" +#include "subCycle.H" +#include "interfaceProperties.H" +#include "twoPhaseMixture.H" +#include "incompressible/LESmodel/LESmodel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readEnvironmentalProperties.H" + #include "readControls.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + turbulence->correct(); + + // --- Outer-corrector loop + for (int oCorr=0; oCorr turbulence + ( + LESmodel::New(U, phi, twoPhaseProperties) + ); diff --git a/applications/solvers/multiphase/compressibleLesInterFoam/pEqn.H b/applications/solvers/multiphase/compressibleLesInterFoam/pEqn.H new file mode 100644 index 0000000000..b794d4df2d --- /dev/null +++ b/applications/solvers/multiphase/compressibleLesInterFoam/pEqn.H @@ -0,0 +1,71 @@ +{ + volScalarField rUA = 1.0/UEqn.A(); + surfaceScalarField rUAf = fvc::interpolate(rUA); + + tmp pdEqnComp; + + if (transonic) + { + pdEqnComp = + (fvm::ddt(pd) + fvm::div(phi, pd) - fvm::Sp(fvc::div(phi), pd)); + } + else + { + pdEqnComp = + (fvm::ddt(pd) + fvc::div(phi, pd) - fvc::Sp(fvc::div(phi), pd)); + } + + + U = rUA*UEqn.H(); + + surfaceScalarField phiU + ( + "phiU", + (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, rho, U, phi) + ); + + phi = phiU + + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + )*rUAf*mesh.magSf(); + + for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pdEqnIncomp + ( + fvc::div(phi) + - fvm::laplacian(rUAf, pd) + ); + + solve + ( + (max(alpha1, 0.0)*(psi1/rho1) + max(alpha2, 0.0)*(psi2/rho2)) + *pdEqnComp() + + pdEqnIncomp + ); + + if (nonOrth == nNonOrthCorr) + { + dgdt = + (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) + *(pdEqnComp & pd); + phi += pdEqnIncomp.flux(); + } + } + + U += rUA*fvc::reconstruct((phi - phiU)/rUAf); + U.correctBoundaryConditions(); + + p = max + ( + (pd + gh*(alpha1*rho10 + alpha2*rho20))/(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), + pMin + ); + + rho1 = rho10 + psi1*p; + rho2 = rho20 + psi2*p; + + Info<< "max(U) " << max(mag(U)).value() << endl; + Info<< "min(pd) " << min(pd).value() << endl; +} diff --git a/applications/solvers/multiphase/compressibleLesInterFoam/readControls.H b/applications/solvers/multiphase/compressibleLesInterFoam/readControls.H new file mode 100644 index 0000000000..7e23354f47 --- /dev/null +++ b/applications/solvers/multiphase/compressibleLesInterFoam/readControls.H @@ -0,0 +1,20 @@ + #include "readPISOControls.H" + #include "readTimeControls.H" + + label nAlphaCorr + ( + readLabel(piso.lookup("nAlphaCorr")) + ); + + label nAlphaSubCycles + ( + readLabel(piso.lookup("nAlphaSubCycles")) + ); + + if (nAlphaSubCycles > 1 && nOuterCorr != 1) + { + FatalErrorIn(args.executable()) + << "Sub-cycling alpha is only allowed for PISO, " + "i.e. when the number of outer-correctors = 1" + << exit(FatalError); + } diff --git a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C index 12e03c3c8b..e46cba7db9 100644 --- a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C @@ -46,18 +46,17 @@ Description int main(int argc, char *argv[]) { - -# include "setRootCase.H" -# include "createTime.H" -# include "createDynamicFvMesh.H" -# include "readEnvironmentalProperties.H" -# include "readPISOControls.H" -# include "initContinuityErrs.H" -# include "createFields.H" -# include "readTimeControls.H" -# include "correctPhi.H" -# include "CourantNo.H" -# include "setInitialDeltaT.H" + #include "setRootCase.H" + #include "createTime.H" + #include "createDynamicFvMesh.H" + #include "readEnvironmentalProperties.H" + #include "readPISOControls.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "readTimeControls.H" + #include "correctPhi.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -65,17 +64,17 @@ int main(int argc, char *argv[]) while (runTime.run()) { -# include "readControls.H" -# include "CourantNo.H" + #include "readControls.H" + #include "CourantNo.H" -# include "setDeltaT.H" + #include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; // Make the fluxes absolute - if (mesh.changing() && correctPhi) + if (mesh.changing()) { fvc::makeAbsolute(phi, U); } @@ -97,33 +96,36 @@ int main(int argc, char *argv[]) if (mesh.changing() && correctPhi) { -# include "correctPhi.H" + #include "correctPhi.H" } + // Keep the absolute fluxes for use in ddtPhiCorr + surfaceScalarField phiAbs("phiAbs", phi); + // Make the fluxes relative to the mesh motion - if (mesh.changing() && correctPhi) + if (mesh.changing()) { fvc::makeRelative(phi, U); } if (mesh.changing() && checkMeshCourantNo) { -# include "meshCourantNo.H" + #include "meshCourantNo.H" } twoPhaseProperties.correct(); -# include "gammaEqnSubCycle.H" + #include "gammaEqnSubCycle.H" -# include "UEqn.H" + #include "UEqn.H" // --- PISO loop for (int corr=0; corrnuSgs()) + ); + + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(phi, U) + - fvm::laplacian(muEff, U) + //- (fvc::grad(U) & fvc::grad(muf)) + - fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) + ); + + if (momentumPredictor) + { + solve(UEqn == -fvc::grad(p)); + } diff --git a/applications/solvers/multiphase/cavitatingFoam/continuityErrs.H b/applications/solvers/multiphase/lesCavitatingFoam/continuityErrs.H similarity index 100% rename from applications/solvers/multiphase/cavitatingFoam/continuityErrs.H rename to applications/solvers/multiphase/lesCavitatingFoam/continuityErrs.H diff --git a/applications/solvers/multiphase/cavitatingFoam/createFields.H b/applications/solvers/multiphase/lesCavitatingFoam/createFields.H similarity index 77% rename from applications/solvers/multiphase/cavitatingFoam/createFields.H rename to applications/solvers/multiphase/lesCavitatingFoam/createFields.H index 505c68d4c1..47ac1c9387 100644 --- a/applications/solvers/multiphase/cavitatingFoam/createFields.H +++ b/applications/solvers/multiphase/lesCavitatingFoam/createFields.H @@ -40,11 +40,12 @@ gamma.oldTime(); Info<< "Creating compressibilityModel\n" << endl; - autoPtr psiModel = compressibilityModel::New - ( - thermodynamicProperties, - gamma - ); + autoPtr psiModel = + barotropicCompressibilityModel::New + ( + thermodynamicProperties, + gamma + ); const volScalarField& psi = psiModel->psi(); @@ -72,3 +73,13 @@ # include "createPhiv.H" # include "compressibleCreatePhi.H" + + Info<< "Reading transportProperties\n" << endl; + + twoPhaseMixture twoPhaseProperties(U, phiv, "gamma"); + + // Create LES model + autoPtr turbulence + ( + LESmodel::New(U, phiv, twoPhaseProperties) + ); diff --git a/applications/solvers/multiphase/lesCavitatingFoam/devOneEqEddy/devOneEqEddy.C b/applications/solvers/multiphase/lesCavitatingFoam/devOneEqEddy/devOneEqEddy.C new file mode 100644 index 0000000000..3a5db93cb8 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/devOneEqEddy/devOneEqEddy.C @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "devOneEqEddy.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace LESmodels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(devOneEqEddy, 0); +addToRunTimeSelectionTable(LESmodel, devOneEqEddy, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +devOneEqEddy::devOneEqEddy +( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport +) +: + LESmodel(typeName, U, phi, transport), + GenEddyVisc(U, phi, transport), + + k_ + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + + ck_(LESmodelProperties().lookup("ck")) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void devOneEqEddy::correct(const tmp& gradU) +{ + GenEddyVisc::correct(gradU); + + //volScalarField G = 2*nuSgs_*magSqr(symm(gradU)); + volScalarField G = 2*nuSgs_*(gradU() && dev(symm(gradU()))); + + solve + ( + fvm::ddt(k_) + + fvm::div(phi(), k_) + - fvm::Sp(fvc::div(phi()), k_) + - fvm::laplacian(DkEff(), k_) + == + G + - fvm::Sp(ce_*sqrt(k_)/delta(), k_) + ); + + bound(k_, k0()); + + nuSgs_ = ck_*sqrt(k_)*delta(); + nuSgs_.correctBoundaryConditions(); +} + + +bool devOneEqEddy::read() +{ + if (GenEddyVisc::read()) + { + LESmodelProperties().lookup("ck") >> ck_; + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESmodels +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/devOneEqEddy/devOneEqEddy.H b/applications/solvers/multiphase/lesCavitatingFoam/devOneEqEddy/devOneEqEddy.H new file mode 100644 index 0000000000..6581e962c4 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/devOneEqEddy/devOneEqEddy.H @@ -0,0 +1,145 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + devOneEqEddy + +Description +
+    One Equation Eddy Viscosity Model
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    Eddy viscosity SGS model using a modeled balance equation to simulate the
+    behaviour of k, hence,
+
+        d/dt(k) + div(U*k) - div(nuEff*grad(k))
+        =
+        -B*L - ce*k^3/2/delta
+
+    and
+
+        B = 2/3*k*I - 2*nuEff*dev(D)
+
+    where
+
+        D = symm(grad(U));
+        nuSgs = ck*sqrt(k)*delta
+        nuEff = nuSgs + nu
+
+ +SourceFiles + devOneEqEddy.C + +\*---------------------------------------------------------------------------*/ + +#ifndef devOneEqEddy_H +#define devOneEqEddy_H + +#include "GenEddyVisc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace LESmodels +{ + +/*---------------------------------------------------------------------------*\ + Class devOneEqEddy Declaration +\*---------------------------------------------------------------------------*/ + +class devOneEqEddy +: + public GenEddyVisc +{ + // Private data + + volScalarField k_; + + dimensionedScalar ck_; + + + // Private Member Functions + + // Disallow default bitwise copy construct and assignment + devOneEqEddy(const devOneEqEddy&); + devOneEqEddy& operator=(const devOneEqEddy&); + + +public: + + //- Runtime type information + TypeName("devOneEqEddy"); + + // Constructors + + //- Constructor from components + devOneEqEddy + ( + const volVectorField& U, + const surfaceScalarField& phi, + transportModel& transport + ); + + + // Destructor + + ~devOneEqEddy() + {} + + + // Member Functions + + //- Return SGS kinetic energy + tmp k() const + { + return k_; + } + + //- Return the effective diffusivity for k + tmp DkEff() const + { + return tmp + ( + new volScalarField("DkEff", nuSgs_ + nu()) + ); + } + + //- Correct Eddy-Viscosity and related properties + void correct(const tmp& gradU); + + //- Read turbulenceProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESmodels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/cavitatingFoam/gammaPsi.H b/applications/solvers/multiphase/lesCavitatingFoam/gammaPsi.H similarity index 100% rename from applications/solvers/multiphase/cavitatingFoam/gammaPsi.H rename to applications/solvers/multiphase/lesCavitatingFoam/gammaPsi.H diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C b/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C similarity index 92% rename from applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C rename to applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C index a1e03afdd7..31f5b90e13 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C +++ b/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C @@ -23,14 +23,17 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - cavitatingFoam + lesCavitatingFoam Description + Transient cavitation code with LES turbulence. \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "compressibilityModel.H" +#include "barotropicCompressibilityModel.H" +#include "twoPhaseMixture.H" +#include "incompressible/LESmodel/LESmodel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -42,7 +45,6 @@ int main(int argc, char *argv[]) # include "createTime.H" # include "createMesh.H" # include "readThermodynamicProperties.H" -# include "readTransportProperties.H" # include "readControls.H" # include "createFields.H" # include "initContinuityErrs.H" @@ -62,6 +64,8 @@ int main(int argc, char *argv[]) runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; + turbulence->correct(); + for (int outerCorr=0; outerCorrnuSgs()); + surfaceScalarField muEff + ( + "muEff", + twoPhaseProperties.muf() + + fvc::interpolate(rho*turbulence->nuSgs()) + ); fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) - - fvm::laplacian(muf, U) - - (fvc::grad(U) & fvc::grad(muf)) - //- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) + - fvm::laplacian(muEff, U) + - (fvc::grad(U) & fvc::grad(muEff)) + //- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) ); if (momentumPredictor) diff --git a/applications/solvers/multiphase/lesInterFoam/createFields.H b/applications/solvers/multiphase/lesInterFoam/createFields.H index 666e655871..c24f8bda35 100644 --- a/applications/solvers/multiphase/lesInterFoam/createFields.H +++ b/applications/solvers/multiphase/lesInterFoam/createFields.H @@ -44,7 +44,7 @@ Info<< "Reading transportProperties\n" << endl; twoPhaseMixture twoPhaseProperties(U, phi, "gamma"); - + const dimensionedScalar& rho1 = twoPhaseProperties.rho1(); const dimensionedScalar& rho2 = twoPhaseProperties.rho2(); @@ -87,9 +87,24 @@ Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); surfaceScalarField ghf("gh", g & mesh.Cf()); + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + pd + rho*gh + ); + + // Construct interface from gamma distribution interfaceProperties interface(gamma, U, twoPhaseProperties); diff --git a/applications/solvers/multiphase/lesInterFoam/lesInterFoam.C b/applications/solvers/multiphase/lesInterFoam/lesInterFoam.C index c006fc6dd6..acb11e1b29 100644 --- a/applications/solvers/multiphase/lesInterFoam/lesInterFoam.C +++ b/applications/solvers/multiphase/lesInterFoam/lesInterFoam.C @@ -26,8 +26,11 @@ Application lesInterFoam Description - Solver for 2 incompressible fluids capturing the interface. Turbulence is - modelled using a runtime selectable incompressible LES model. + Solver for 2 incompressible, isothermal immiscible fluids using a VOF + (volume of fluid) phase-fraction based interface capturing approach. + The momentum and other fluid properties are of the "mixture" and a single + momentum equation is solved. Turbulence is modelled using a run-time + selectable incompressible LES model. \*---------------------------------------------------------------------------*/ @@ -38,28 +41,21 @@ Description #include "twoPhaseMixture.H" #include "incompressible/LESmodel/LESmodel.H" -#include "IFstream.H" -#include "OFstream.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { - -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" -# include "readEnvironmentalProperties.H" -# include "readPISOControls.H" -# include "initContinuityErrs.H" - -# include "createFields.H" -//# include "createAverages.H" - -# include "readTimeControls.H" -# include "correctPhi.H" -# include "CourantNo.H" -# include "setInitialDeltaT.H" + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readEnvironmentalProperties.H" + #include "readPISOControls.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "readTimeControls.H" + #include "correctPhi.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,31 +63,29 @@ int main(int argc, char *argv[]) while (runTime.run()) { -# include "readPISOControls.H" -# include "readTimeControls.H" -# include "CourantNo.H" -# include "setDeltaT.H" + #include "readPISOControls.H" + #include "readTimeControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; -# include "gammaEqnSubCycle.H" + #include "gammaEqnSubCycle.H" turbulence->correct(); -# include "UEqn.H" + #include "UEqn.H" // --- PISO loop for (int corr=0; corr < nCorr; corr++) { -# include "pEqn.H" + #include "pEqn.H" } -# include "continuityErrs.H" -//# include "calculateAverages.H" + #include "continuityErrs.H" runTime.write(); -//# include "writeNaveragingSteps.H" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" diff --git a/applications/solvers/multiphase/rasCavitatingFoam/CourantNo.H b/applications/solvers/multiphase/rasCavitatingFoam/CourantNo.H new file mode 100644 index 0000000000..cf83423557 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/CourantNo.H @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + CourantNo + +Description + Calculates and outputs the mean and maximum Courant Numbers. + +\*---------------------------------------------------------------------------*/ + +scalar CoNum = 0.0; +scalar meanCoNum = 0.0; +scalar acousticCoNum = 0.0; + +if (mesh.nInternalFaces()) +{ + surfaceScalarField SfUfbyDelta = + mesh.surfaceInterpolation::deltaCoeffs()*mag(phiv); + + CoNum = max(SfUfbyDelta/mesh.magSf()) + .value()*runTime.deltaT().value(); + + meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf())) + .value()*runTime.deltaT().value(); + + acousticCoNum = max + ( + mesh.surfaceInterpolation::deltaCoeffs()/sqrt(fvc::interpolate(psi)) + ).value()*runTime.deltaT().value(); +} + +Info<< "phiv Courant Number mean: " << meanCoNum + << " max: " << CoNum + << " acoustic max: " << acousticCoNum + << endl; + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/Make/files b/applications/solvers/multiphase/rasCavitatingFoam/Make/files new file mode 100644 index 0000000000..4509463796 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/Make/files @@ -0,0 +1,3 @@ +rasCavitatingFoam.C + +EXE = $(FOAM_APPBIN)/rasCavitatingFoam diff --git a/applications/solvers/multiphase/rasCavitatingFoam/Make/options b/applications/solvers/multiphase/rasCavitatingFoam/Make/options new file mode 100644 index 0000000000..ffd4930257 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude + +EXE_LIBS = \ + -lincompressibleTransportModels \ + -lincompressibleTurbulenceModels \ + -lfiniteVolume \ + -lbarotropicCompressibilityModel + diff --git a/applications/solvers/multiphase/rasCavitatingFoam/UEqn.H b/applications/solvers/multiphase/rasCavitatingFoam/UEqn.H new file mode 100644 index 0000000000..374e410c2e --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/UEqn.H @@ -0,0 +1,20 @@ + surfaceScalarField muEff + ( + "muEff", + twoPhaseProperties.muf() + + fvc::interpolate(rho*turbulence->nut()) + ); + + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(phi, U) + - fvm::laplacian(muEff, U) + //- (fvc::grad(U) & fvc::grad(muf)) + - fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) + ); + + if (momentumPredictor) + { + solve(UEqn == -fvc::grad(p)); + } diff --git a/applications/solvers/multiphase/rasCavitatingFoam/continuityErrs.H b/applications/solvers/multiphase/rasCavitatingFoam/continuityErrs.H new file mode 100644 index 0000000000..6f1622510f --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/continuityErrs.H @@ -0,0 +1,22 @@ +{ + volScalarField thermoRho = psi*p + (1.0 - gamma)*rhol0; + + dimensionedScalar totalMass = fvc::domainIntegrate(rho); + + scalar sumLocalContErr = + ( + fvc::domainIntegrate(mag(rho - thermoRho))/totalMass + ).value(); + + scalar globalContErr = + ( + fvc::domainIntegrate(rho - thermoRho)/totalMass + ).value(); + + cumulativeContErr += globalContErr; + + Info<< "time step continuity errors : sum local = " << sumLocalContErr + << ", global = " << globalContErr + << ", cumulative = " << cumulativeContErr + << endl; +} diff --git a/applications/solvers/multiphase/rasCavitatingFoam/createFields.H b/applications/solvers/multiphase/rasCavitatingFoam/createFields.H new file mode 100644 index 0000000000..21f5b136bb --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/createFields.H @@ -0,0 +1,85 @@ + Info<< "Reading field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + volScalarField gamma + ( + IOobject + ( + "gamma", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0)) + ); + gamma.oldTime(); + + Info<< "Creating compressibilityModel\n" << endl; + autoPtr psiModel = + barotropicCompressibilityModel::New + ( + thermodynamicProperties, + gamma + ); + + const volScalarField& psi = psiModel->psi(); + + rho == max + ( + psi*p + + (1.0 - gamma)*rhol0 + + ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat, + rhoMin + ); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "createPhiv.H" +# include "compressibleCreatePhi.H" + + Info<< "Reading transportProperties\n" << endl; + + twoPhaseMixture twoPhaseProperties(U, phiv, "gamma"); + + // Create RAS turbulence model + autoPtr turbulence + ( + turbulenceModel::New(U, phiv, twoPhaseProperties) + ); diff --git a/applications/solvers/multiphase/rasCavitatingFoam/gammaPsi.H b/applications/solvers/multiphase/rasCavitatingFoam/gammaPsi.H new file mode 100644 index 0000000000..b259ddd322 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/gammaPsi.H @@ -0,0 +1,10 @@ +{ + gamma = max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0)); + + Info<< "max-min gamma: " << max(gamma).value() + << " " << min(gamma).value() << endl; + + psiModel->correct(); + + //Info<< "min a: " << 1.0/sqrt(max(psi)).value() << endl; +} diff --git a/applications/solvers/multiphase/rasCavitatingFoam/pEqn.H b/applications/solvers/multiphase/rasCavitatingFoam/pEqn.H new file mode 100644 index 0000000000..c9382dfc0f --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/pEqn.H @@ -0,0 +1,80 @@ +{ + if (nOuterCorr == 1) + { + p = + ( + rho + - (1.0 - gamma)*rhol0 + - ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat + )/psi; + } + + surfaceScalarField rhof = fvc::interpolate(rho, "rhof"); + + volScalarField rUA = 1.0/UEqn.A(); + surfaceScalarField rUAf("rUAf", rhof*fvc::interpolate(rUA)); + volVectorField HbyA = rUA*UEqn.H(); + + phiv = (fvc::interpolate(HbyA) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phiv); + + p.boundaryField().updateCoeffs(); + + surfaceScalarField phiGradp = rUAf*mesh.magSf()*fvc::snGrad(p); + + phiv -= phiGradp/rhof; + +# include "resetPhivPatches.H" + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + - (rhol0 + (psil - psiv)*pSat)*fvc::ddt(gamma) - pSat*fvc::ddt(psi) + + fvc::div(phiv, rho) + + fvc::div(phiGradp) + - fvm::laplacian(rUAf, p) + ); + + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phiv += (phiGradp + pEqn.flux())/rhof; + } + } + + Info<< "max-min p: " << max(p).value() + << " " << min(p).value() << endl; + + + U = HbyA - rUA*fvc::grad(p); + + // Remove the swirl component of velocity for "wedge" cases + if (piso.found("removeSwirl")) + { + label swirlCmpt(readLabel(piso.lookup("removeSwirl"))); + + Info<< "Removing swirl component-" << swirlCmpt << " of U" << endl; + U.field().replace(swirlCmpt, 0.0); + } + + U.correctBoundaryConditions(); + + Info<< "max(U) " << max(mag(U)).value() << endl; + + rho == max + ( + psi*p + + (1.0 - gamma)*rhol0 + + ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat, + rhoMin + ); + + Info<< "max-min rho: " << max(rho).value() + << " " << min(rho).value() << endl; + +# include "gammaPsi.H" + +} diff --git a/applications/solvers/multiphase/rasCavitatingFoam/rasCavitatingFoam.C b/applications/solvers/multiphase/rasCavitatingFoam/rasCavitatingFoam.C new file mode 100644 index 0000000000..bcc0b5441c --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/rasCavitatingFoam.C @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + rasCavitatingFoam + +Description + Transient cavitation code with RAS turbulence. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "barotropicCompressibilityModel.H" +#include "twoPhaseMixture.H" +#include "incompressible/turbulenceModel/turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + +# include "setRootCase.H" + +# include "createTime.H" +# include "createMesh.H" +# include "readThermodynamicProperties.H" +# include "readControls.H" +# include "createFields.H" +# include "initContinuityErrs.H" +# include "compressibleCourantNo.H" +# include "setInitialDeltaT.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { +# include "readControls.H" +# include "CourantNo.H" +# include "setDeltaT.H" + + runTime++; + Info<< "Time = " << runTime.timeName() << nl << endl; + + for (int outerCorr=0; outerCorrcorrect(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "\n end \n"; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/readControls.H b/applications/solvers/multiphase/rasCavitatingFoam/readControls.H new file mode 100644 index 0000000000..f53e7b9eb1 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/readControls.H @@ -0,0 +1,9 @@ +#include "readTimeControls.H" + +scalar maxAcousticCo +( + readScalar(runTime.controlDict().lookup("maxAcousticCo")) +); + + +#include "readPISOControls.H" diff --git a/applications/solvers/multiphase/rasCavitatingFoam/readThermodynamicProperties.H b/applications/solvers/multiphase/rasCavitatingFoam/readThermodynamicProperties.H new file mode 100644 index 0000000000..d3fbb9307a --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/readThermodynamicProperties.H @@ -0,0 +1,27 @@ + Info<< "Reading thermodynamicProperties\n" << endl; + + IOdictionary thermodynamicProperties + ( + IOobject + ( + "thermodynamicProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + dimensionedScalar psil(thermodynamicProperties.lookup("psil")); + + dimensionedScalar rholSat(thermodynamicProperties.lookup("rholSat")); + + dimensionedScalar psiv(thermodynamicProperties.lookup("psiv")); + + dimensionedScalar pSat(thermodynamicProperties.lookup("pSat")); + + dimensionedScalar rhovSat("rhovSat", psiv*pSat); + + dimensionedScalar rhol0("rhol0", rholSat - pSat*psil); + + dimensionedScalar rhoMin(thermodynamicProperties.lookup("rhoMin")); diff --git a/applications/solvers/multiphase/rasCavitatingFoam/resetPhiPatches.H b/applications/solvers/multiphase/rasCavitatingFoam/resetPhiPatches.H new file mode 100644 index 0000000000..e7d0c2f93e --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/resetPhiPatches.H @@ -0,0 +1,15 @@ +fvsPatchScalarFieldField& phiPatches = phi.boundaryField(); +const fvPatchScalarFieldField& rhoPatches = rho.boundaryField(); +const fvPatchVectorFieldField& Upatches = U.boundaryField(); +const fvsPatchVectorFieldField& SfPatches = mesh.Sf().boundaryField(); + +forAll(phiPatches, patchI) +{ + if (phi.boundaryField().types()[patchI] == "calculated") + { + calculatedFvsPatchScalarField& phiPatch = + refCast(phiPatches[patchI]); + + phiPatch == ((rhoPatches[patchI]*Upatches[patchI]) & SfPatches[patchI]); + } +} diff --git a/applications/solvers/multiphase/rasCavitatingFoam/resetPhivPatches.H b/applications/solvers/multiphase/rasCavitatingFoam/resetPhivPatches.H new file mode 100644 index 0000000000..7e8b040bb6 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/resetPhivPatches.H @@ -0,0 +1,14 @@ +surfaceScalarField::GeometricBoundaryField& phivPatches = phiv.boundaryField(); +const volVectorField::GeometricBoundaryField& Upatches = U.boundaryField(); +const surfaceVectorField::GeometricBoundaryField& SfPatches = mesh.Sf().boundaryField(); + +forAll(phivPatches, patchI) +{ + if (phiv.boundaryField().types()[patchI] == "calculated") + { + calculatedFvsPatchScalarField& phivPatch = + refCast(phivPatches[patchI]); + + phivPatch == (Upatches[patchI] & SfPatches[patchI]); + } +} diff --git a/applications/solvers/multiphase/rasCavitatingFoam/rhoEqn.H b/applications/solvers/multiphase/rasCavitatingFoam/rhoEqn.H new file mode 100644 index 0000000000..d0bd6e1dad --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/rhoEqn.H @@ -0,0 +1,16 @@ +{ + fvScalarMatrix rhoEqn + ( + fvm::ddt(rho) + + fvm::div(phiv, rho) + ); + + rhoEqn.solve(); + + phi = rhoEqn.flux(); + + Info<< "max-min rho: " << max(rho).value() + << " " << min(rho).value() << endl; + + rho == max(rho, rhoMin); +} diff --git a/applications/solvers/multiphase/rasCavitatingFoam/setDeltaT.H b/applications/solvers/multiphase/rasCavitatingFoam/setDeltaT.H new file mode 100644 index 0000000000..fa77283ca5 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/setDeltaT.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + setDeltaT + +Description + Reset the timestep to maintain a constant maximum courant Number. + Reduction of time-step is imediate but increase is damped to avoid + unstable oscillations. + +\*---------------------------------------------------------------------------*/ + +if (adjustTimeStep) +{ + scalar maxDeltaTFact = + min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL)); + + scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2); + + runTime.setDeltaT + ( + min + ( + deltaTFact*runTime.deltaT().value(), + maxDeltaT + ) + ); + + Info<< "deltaT = " << runTime.deltaT().value() << endl; +} + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/setInitialDeltaT.H b/applications/solvers/multiphase/rasCavitatingFoam/setInitialDeltaT.H new file mode 100644 index 0000000000..1c709c87f2 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/setInitialDeltaT.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Global + setInitialDeltaT + +Description + Set the initial timestep corresponding to the timestep adjustment + algorithm in setDeltaT + +\*---------------------------------------------------------------------------*/ + +if (adjustTimeStep) +{ +# include "CourantNo.H" + + if (CoNum > SMALL) + { + scalar maxDeltaTFact = + min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL)); + + runTime.setDeltaT + ( + min + ( + maxDeltaTFact*runTime.deltaT().value(), + maxDeltaT + ) + ); + } +} + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasInterFoam/UEqn.H b/applications/solvers/multiphase/rasInterFoam/UEqn.H index 59a6600777..c627f04d17 100644 --- a/applications/solvers/multiphase/rasInterFoam/UEqn.H +++ b/applications/solvers/multiphase/rasInterFoam/UEqn.H @@ -1,14 +1,17 @@ - surfaceScalarField muf = - twoPhaseProperties.muf() - + fvc::interpolate(rho*turbulence->nut()); + surfaceScalarField muEff + ( + "muEff", + twoPhaseProperties.muf() + + fvc::interpolate(rho*turbulence->nut()) + ); fvVectorMatrix UEqn ( fvm::ddt(rho, U) + fvm::div(rhoPhi, U) - - fvm::laplacian(muf, U) - - (fvc::grad(U) & fvc::grad(muf)) - //- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) + - fvm::laplacian(muEff, U) + - (fvc::grad(U) & fvc::grad(muEff)) + //- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) ); if (momentumPredictor) diff --git a/applications/solvers/multiphase/rasInterFoam/createFields.H b/applications/solvers/multiphase/rasInterFoam/createFields.H index 1aef6db579..988e8b3f74 100644 --- a/applications/solvers/multiphase/rasInterFoam/createFields.H +++ b/applications/solvers/multiphase/rasInterFoam/createFields.H @@ -44,7 +44,7 @@ Info<< "Reading transportProperties\n" << endl; twoPhaseMixture twoPhaseProperties(U, phi, "gamma"); - + const dimensionedScalar& rho1 = twoPhaseProperties.rho1(); const dimensionedScalar& rho2 = twoPhaseProperties.rho2(); @@ -88,9 +88,24 @@ Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); surfaceScalarField ghf("gh", g & mesh.Cf()); + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + pd + rho*gh + ); + + // Construct interface from gamma distribution interfaceProperties interface(gamma, U, twoPhaseProperties); diff --git a/applications/solvers/multiphase/rasInterFoam/rasInterFoam.C b/applications/solvers/multiphase/rasInterFoam/rasInterFoam.C index 9cf47c5f32..1c78f70bd8 100644 --- a/applications/solvers/multiphase/rasInterFoam/rasInterFoam.C +++ b/applications/solvers/multiphase/rasInterFoam/rasInterFoam.C @@ -23,11 +23,14 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - lesInterFoam + rasInterFoam Description - Solver for 2 incompressible fluids capturing the interface. Turbulence is - modelled using a runtime selectable incompressible RAS model. + Solver for 2 incompressible, isothermal immiscible fluids using a VOF + (volume of fluid) phase-fraction based interface capturing approach. + The momentum and other fluid properties are of the "mixture" and a single + momentum equation is solved. Turbulence is modelled using a run-time + selectable incompressible RAS model. \*---------------------------------------------------------------------------*/ @@ -42,18 +45,17 @@ Description int main(int argc, char *argv[]) { - -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" -# include "readEnvironmentalProperties.H" -# include "readPISOControls.H" -# include "initContinuityErrs.H" -# include "createFields.H" -# include "readTimeControls.H" -# include "correctPhi.H" -# include "CourantNo.H" -# include "setInitialDeltaT.H" + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readEnvironmentalProperties.H" + #include "readPISOControls.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "readTimeControls.H" + #include "correctPhi.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,26 +63,28 @@ int main(int argc, char *argv[]) while (runTime.run()) { -# include "readPISOControls.H" -# include "readTimeControls.H" -# include "CourantNo.H" -# include "setDeltaT.H" + #include "readPISOControls.H" + #include "readTimeControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; -# include "gammaEqnSubCycle.H" + #include "gammaEqnSubCycle.H" -# include "UEqn.H" + #include "UEqn.H" // --- PISO loop for (int corr=0; corr < nCorr; corr++) { -# include "pEqn.H" + #include "pEqn.H" } -# include "continuityErrs.H" + #include "continuityErrs.H" + + p = pd + rho*gh; turbulence->correct(); diff --git a/applications/utilities/mesh/advanced/refineHexMesh/Make/files b/applications/utilities/mesh/advanced/refineHexMesh/Make/files new file mode 100644 index 0000000000..824d6b0cd0 --- /dev/null +++ b/applications/utilities/mesh/advanced/refineHexMesh/Make/files @@ -0,0 +1,3 @@ +refineHexMesh.C +EXE = $(FOAM_APPBIN)/refineHexMesh + diff --git a/applications/utilities/mesh/advanced/refineHexMesh/Make/options b/applications/utilities/mesh/advanced/refineHexMesh/Make/options new file mode 100644 index 0000000000..376f4dff51 --- /dev/null +++ b/applications/utilities/mesh/advanced/refineHexMesh/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + + +EXE_LIBS = \ + -ldynamicMesh \ + -lmeshTools \ + -lfiniteVolume diff --git a/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C new file mode 100644 index 0000000000..4bed4c059c --- /dev/null +++ b/applications/utilities/mesh/advanced/refineHexMesh/refineHexMesh.C @@ -0,0 +1,185 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Hex 2x2x2 refiner + +\*---------------------------------------------------------------------------*/ + +#include "fvMesh.H" +#include "pointMesh.H" +#include "argList.H" +#include "Time.H" +#include "hexRef8.H" +#include "cellSet.H" +#include "OFstream.H" +#include "meshTools.H" +#include "IFstream.H" +#include "polyTopoChange.H" +#include "mapPolyMesh.H" +#include "volMesh.H" +#include "surfaceMesh.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "pointFields.H" +#include "ReadFields.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Main program: +int main(int argc, char *argv[]) +{ + argList::validArgs.append("cellSet"); +# include "setRootCase.H" +# include "createTime.H" +# include "createMesh.H" + pointMesh pMesh(mesh); + + word cellSetName(args.args()[1]); + + Info<< "Reading cells to refine from cellSet " << cellSetName + << nl << endl; + + cellSet cellsToRefine(mesh, cellSetName); + + Info<< "Read " << returnReduce(cellsToRefine.size(), sumOp