diff --git a/applications/solvers/multiphase/lesCavitatingFoam/CourantNo.H b/applications/solvers/multiphase/lesCavitatingFoam/CourantNo.H new file mode 100644 index 0000000000..cf83423557 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/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/lesCavitatingFoam/Make/files b/applications/solvers/multiphase/lesCavitatingFoam/Make/files new file mode 100644 index 0000000000..51055479ca --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/Make/files @@ -0,0 +1,10 @@ +lesCavitatingFoam.C +compressibilityModels/compressibilityModel/compressibilityModel.C +compressibilityModels/compressibilityModel/newCompressibilityModel.C +compressibilityModels/linear/linear.C +compressibilityModels/Wallis/Wallis.C +compressibilityModels/Chung/Chung.C + +devOneEqEddy/devOneEqEddy.C + +EXE = $(FOAM_USER_APPBIN)/lesCavitatingFoam diff --git a/applications/solvers/multiphase/lesCavitatingFoam/Make/options b/applications/solvers/multiphase/lesCavitatingFoam/Make/options new file mode 100644 index 0000000000..a86b97dbbd --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/Make/options @@ -0,0 +1,15 @@ +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)/LESmodels \ + -I$(LIB_SRC)/LESmodels/incompressible/lnInclude \ + -I$(LIB_SRC)/LESmodels/LESdeltas/lnInclude \ + -IcompressibilityModels/compressibilityModel + +EXE_LIBS = \ + -lincompressibleTransportModels \ + -lincompressibleLESmodels \ + -lfiniteVolume + diff --git a/applications/solvers/multiphase/lesCavitatingFoam/UEqn.H b/applications/solvers/multiphase/lesCavitatingFoam/UEqn.H new file mode 100644 index 0000000000..22e4a47056 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/UEqn.H @@ -0,0 +1,21 @@ + surfaceScalarField gammaf = fvc::interpolate(gamma); + surfaceScalarField muf + ( + "muf", + gammaf*muv + (1.0 - gammaf)*mul + + fvc::interpolate(rho*turbulence->nuSgs()) + ); + + 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/lesCavitatingFoam/calculateAverages.H b/applications/solvers/multiphase/lesCavitatingFoam/calculateAverages.H new file mode 100644 index 0000000000..1d5aace302 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/calculateAverages.H @@ -0,0 +1,12 @@ +Info << "Calculating averages" << endl; + +scalar alpha = + (runTime.value() - timeToStartAveraging - runTime.deltaT().value()) + /(runTime.value() - timeToStartAveraging); + +scalar onemAlpha = 1.0 - alpha; + +Umean == alpha*Umean + onemAlpha*U; +rhoMean == alpha*rhoMean + onemAlpha*rho; +pMean == alpha*pMean + onemAlpha*p; +gammaMean == alpha*gammaMean + onemAlpha*gamma; diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Chung/Chung.C b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Chung/Chung.C new file mode 100644 index 0000000000..6010d8f6df --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Chung/Chung.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "Chung.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +defineTypeNameAndDebug(Chung, 0); +addToRunTimeSelectionTable(compressibilityModel, Chung, dictionary); + +} +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibilityModels::Chung::Chung +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +: + compressibilityModel(compressibilityProperties, gamma), + psiv_(compressibilityProperties_.lookup("psiv")), + psil_(compressibilityProperties_.lookup("psil")), + rhovSat_(compressibilityProperties_.lookup("rhovSat")), + rholSat_(compressibilityProperties_.lookup("rholSat")) +{ + correct(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::compressibilityModels::Chung::correct() +{ + volScalarField sfa = sqrt + ( + (rhovSat_/psiv_) + /((scalar(1) - gamma_)*rhovSat_/psiv_ + gamma_*rholSat_/psil_) + ); + + psi_ = sqr + ( + ((scalar(1) - gamma_)/sqrt(psiv_) + gamma_*sfa/sqrt(psil_)) + *sqrt(psiv_*psil_)/sfa + ); +} + + +bool Foam::compressibilityModels::Chung::read +( + const dictionary& compressibilityProperties +) +{ + compressibilityModel::read(compressibilityProperties); + + compressibilityProperties_.lookup("psiv") >> psiv_; + compressibilityProperties_.lookup("psil") >> psil_; + compressibilityProperties_.lookup("rhovSat") >> rhovSat_; + compressibilityProperties_.lookup("rholSat") >> rholSat_; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Chung/Chung.H b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Chung/Chung.H new file mode 100644 index 0000000000..316054231e --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Chung/Chung.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressibilityModels::Chung + +Description + Chung compressibility model. + +SourceFiles + Chung.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Chung_H +#define Chung_H + +#include "compressibilityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +/*---------------------------------------------------------------------------*\ + Class Chung Declaration +\*---------------------------------------------------------------------------*/ + +class Chung +: + public compressibilityModel +{ + // Private data + + dimensionedScalar psiv_; + dimensionedScalar psil_; + + dimensionedScalar rhovSat_; + dimensionedScalar rholSat_; + + +public: + + //- Runtime type information + TypeName("Chung"); + + + // Constructors + + //- construct from components + Chung + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Destructor + + ~Chung() + {} + + + // Member Functions + + //- Correct the Chung compressibility + void correct(); + + //- Read transportProperties dictionary + bool read(const dictionary& compressibilityProperties); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressibilityModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Wallis/Wallis.C b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Wallis/Wallis.C new file mode 100644 index 0000000000..370cd1413f --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Wallis/Wallis.C @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "Wallis.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +defineTypeNameAndDebug(Wallis, 0); +addToRunTimeSelectionTable(compressibilityModel, Wallis, dictionary); + +} +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibilityModels::Wallis::Wallis +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +: + compressibilityModel(compressibilityProperties, gamma), + psiv_(compressibilityProperties_.lookup("psiv")), + psil_(compressibilityProperties_.lookup("psil")), + rhovSat_(compressibilityProperties_.lookup("rhovSat")), + rholSat_(compressibilityProperties_.lookup("rholSat")) +{ + correct(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::compressibilityModels::Wallis::correct() +{ + psi_ = (gamma_*rhovSat_ + (scalar(1) - gamma_)*rholSat_) + *(gamma_*psiv_/rhovSat_ + (scalar(1) - gamma_)*psil_/rholSat_); +} + + +bool Foam::compressibilityModels::Wallis::read +( + const dictionary& compressibilityProperties +) +{ + compressibilityModel::read(compressibilityProperties); + + compressibilityProperties_.lookup("psiv") >> psiv_; + compressibilityProperties_.lookup("psil") >> psil_; + compressibilityProperties_.lookup("rhovSat") >> rhovSat_; + compressibilityProperties_.lookup("rholSat") >> rholSat_; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Wallis/Wallis.H b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Wallis/Wallis.H new file mode 100644 index 0000000000..df576fc63a --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/Wallis/Wallis.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressibilityModels::Wallis + +Description + Wallis compressibility model. + +SourceFiles + Wallis.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Wallis_H +#define Wallis_H + +#include "compressibilityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +/*---------------------------------------------------------------------------*\ + Class Wallis Declaration +\*---------------------------------------------------------------------------*/ + +class Wallis +: + public compressibilityModel +{ + // Private data + + dimensionedScalar psiv_; + dimensionedScalar psil_; + + dimensionedScalar rhovSat_; + dimensionedScalar rholSat_; + + +public: + + //- Runtime type information + TypeName("Wallis"); + + + // Constructors + + //- construct from components + Wallis + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Destructor + + ~Wallis() + {} + + + // Member Functions + + //- Correct the Wallis compressibility + void correct(); + + //- Read transportProperties dictionary + bool read(const dictionary& compressibilityProperties); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressibilityModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.C b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.C new file mode 100644 index 0000000000..c879f05a82 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.C @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +InClass + compressibilityModel + +\*---------------------------------------------------------------------------*/ + +#include "compressibilityModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(compressibilityModel, 0); + defineRunTimeSelectionTable(compressibilityModel, dictionary); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibilityModel::compressibilityModel +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +: + compressibilityProperties_(compressibilityProperties), + psi_ + ( + IOobject + ( + "psi", + gamma.mesh().time().timeName(), + gamma.mesh() + ), + gamma.mesh(), + dimensionedScalar("psi", dimensionSet(0, -2, 2, 0, 0), 0) + ), + gamma_(gamma) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::compressibilityModel::read +( + const dictionary& compressibilityProperties +) +{ + compressibilityProperties_ = compressibilityProperties; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.H b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.H new file mode 100644 index 0000000000..e0df9d99f5 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressibilityModel + +Description + +SourceFiles + compressibilityModel.C + newCompressibilityModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibilityModel_H +#define compressibilityModel_H + +#include "IOdictionary.H" +#include "typeInfo.H" +#include "runTimeSelectionTables.H" +#include "volFields.H" +#include "dimensionedScalar.H" +#include "autoPtr.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class compressibilityModel Declaration +\*---------------------------------------------------------------------------*/ + +class compressibilityModel +{ + +protected: + + // Protected data + + dictionary compressibilityProperties_; + + volScalarField psi_; + const volScalarField& gamma_; + + + // Private Member Functions + + //- Disallow copy construct + compressibilityModel(const compressibilityModel&); + + //- Disallow default bitwise assignment + void operator=(const compressibilityModel&); + + +public: + + //- Runtime type information + TypeName("compressibilityModel"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + compressibilityModel, + dictionary, + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ), + (compressibilityProperties, gamma) + ); + + + // Selectors + + //- Return a reference to the selected compressibility model + static autoPtr New + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Constructors + + //- Construct from components + compressibilityModel + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Destructor + + virtual ~compressibilityModel() + {} + + + // Member Functions + + //- Return the phase transport properties dictionary + const dictionary& compressibilityProperties() const + { + return compressibilityProperties_; + } + + //- Return the compressibility + const volScalarField& psi() const + { + return psi_; + } + + //- Correct the compressibility + virtual void correct() = 0; + + //- Read compressibilityProperties dictionary + virtual bool read(const dictionary& compressibilityProperties) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/newCompressibilityModel.C b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/newCompressibilityModel.C new file mode 100644 index 0000000000..9604b563f5 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/compressibilityModel/newCompressibilityModel.C @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "compressibilityModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::compressibilityModel::New +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +{ + word compressibilityModelTypeName + ( + compressibilityProperties.lookup("compressibilityModel") + ); + + Info<< "Selecting compressibility model " + << compressibilityModelTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(compressibilityModelTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "compressibilityModel::New(const volScalarField&)" + ) << "Unknown compressibilityModel type " + << compressibilityModelTypeName << endl << endl + << "Valid compressibilityModels are : " << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalError); + } + + return autoPtr + ( + cstrIter()(compressibilityProperties, gamma) + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/linear/linear.C b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/linear/linear.C new file mode 100644 index 0000000000..8bd2316cdc --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/linear/linear.C @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "linear.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +defineTypeNameAndDebug(linear, 0); +addToRunTimeSelectionTable(compressibilityModel, linear, dictionary); + +} +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibilityModels::linear::linear +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +: + compressibilityModel(compressibilityProperties, gamma), + psiv_(compressibilityProperties_.lookup("psiv")), + psil_(compressibilityProperties_.lookup("psil")) +{ + correct(); + psi_.oldTime(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::compressibilityModels::linear::correct() +{ + psi_ = gamma_*psiv_ + (scalar(1) - gamma_)*psil_; +} + + +bool Foam::compressibilityModels::linear::read +( + const dictionary& compressibilityProperties +) +{ + compressibilityModel::read(compressibilityProperties); + + compressibilityProperties_.lookup("psiv") >> psiv_; + compressibilityProperties_.lookup("psil") >> psil_; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/linear/linear.H b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/linear/linear.H new file mode 100644 index 0000000000..fbb614cf45 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/compressibilityModels/linear/linear.H @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressibilityModels::linear + +Description + linear compressibility model. + +SourceFiles + linear.C + +\*---------------------------------------------------------------------------*/ + +#ifndef linear_H +#define linear_H + +#include "compressibilityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +/*---------------------------------------------------------------------------*\ + Class linear Declaration +\*---------------------------------------------------------------------------*/ + +class linear +: + public compressibilityModel +{ + // Private data + + dimensionedScalar psiv_; + dimensionedScalar psil_; + + +public: + + //- Runtime type information + TypeName("linear"); + + + // Constructors + + //- construct from components + linear + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Destructor + + ~linear() + {} + + + // Member Functions + + //- Correct the linear compressibility + void correct(); + + //- Read transportProperties dictionary + bool read(const dictionary& compressibilityProperties); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressibilityModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/lesCavitatingFoam/continuityErrs.H b/applications/solvers/multiphase/lesCavitatingFoam/continuityErrs.H new file mode 100644 index 0000000000..6f1622510f --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/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/lesCavitatingFoam/createAverages.H b/applications/solvers/multiphase/lesCavitatingFoam/createAverages.H new file mode 100644 index 0000000000..d1ffac2958 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/createAverages.H @@ -0,0 +1,53 @@ +scalar timeToStartAveraging = runTime.value(); + +volVectorField Umean +( + IOobject + ( + "Umean", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + U +); + +volScalarField rhoMean +( + IOobject + ( + "rhoMean", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + rho +); + +volScalarField pMean +( + IOobject + ( + "pMean", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + p +); + +volScalarField gammaMean +( + IOobject + ( + "gammaMean", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + gamma +); diff --git a/applications/solvers/multiphase/lesCavitatingFoam/createFields.H b/applications/solvers/multiphase/lesCavitatingFoam/createFields.H new file mode 100644 index 0000000000..69fe4ba411 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/createFields.H @@ -0,0 +1,84 @@ + 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 = compressibilityModel::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 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/lesCavitatingFoam/gammaPsi.H b/applications/solvers/multiphase/lesCavitatingFoam/gammaPsi.H new file mode 100644 index 0000000000..b259ddd322 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/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/lesCavitatingFoam/lesCavitatingFoam.C b/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C new file mode 100644 index 0000000000..4cf652063f --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/lesCavitatingFoam.C @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "compressibilityModel.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 "readThermodynamicProperties.H" +# include "readTransportProperties.H" +# include "readControls.H" +# include "createFields.H" +# include "createAverages.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; + + turbulence->correct(); + + for (int outerCorr=0; outerCorr(phiPatches[patchI]); + + phiPatch == ((rhoPatches[patchI]*Upatches[patchI]) & SfPatches[patchI]); + } +} diff --git a/applications/solvers/multiphase/lesCavitatingFoam/resetPhivPatches.H b/applications/solvers/multiphase/lesCavitatingFoam/resetPhivPatches.H new file mode 100644 index 0000000000..7e8b040bb6 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/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/lesCavitatingFoam/rhoEqn.H b/applications/solvers/multiphase/lesCavitatingFoam/rhoEqn.H new file mode 100644 index 0000000000..d0bd6e1dad --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/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/lesCavitatingFoam/setDeltaT.H b/applications/solvers/multiphase/lesCavitatingFoam/setDeltaT.H new file mode 100644 index 0000000000..fa77283ca5 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/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/lesCavitatingFoam/setInitialDeltaT.H b/applications/solvers/multiphase/lesCavitatingFoam/setInitialDeltaT.H new file mode 100644 index 0000000000..1c709c87f2 --- /dev/null +++ b/applications/solvers/multiphase/lesCavitatingFoam/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/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..35ad5c90c7 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/Make/files @@ -0,0 +1,8 @@ +rasCavitatingFoam.C +compressibilityModels/compressibilityModel/compressibilityModel.C +compressibilityModels/compressibilityModel/newCompressibilityModel.C +compressibilityModels/linear/linear.C +compressibilityModels/Wallis/Wallis.C +compressibilityModels/Chung/Chung.C + +EXE = $(FOAM_USER_APPBIN)/rasCavitatingFoam diff --git a/applications/solvers/multiphase/rasCavitatingFoam/Make/options b/applications/solvers/multiphase/rasCavitatingFoam/Make/options new file mode 100644 index 0000000000..b124119a11 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/Make/options @@ -0,0 +1,13 @@ +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 \ + -IcompressibilityModels/compressibilityModel + +EXE_LIBS = \ + -lincompressibleTransportModels \ + -lincompressibleTurbulenceModels \ + -lfiniteVolume + diff --git a/applications/solvers/multiphase/rasCavitatingFoam/UEqn.H b/applications/solvers/multiphase/rasCavitatingFoam/UEqn.H new file mode 100644 index 0000000000..2a54e1fba2 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/UEqn.H @@ -0,0 +1,21 @@ + surfaceScalarField gammaf = fvc::interpolate(gamma); + surfaceScalarField muf + ( + "muf", + gammaf*muv + (1.0 - gammaf)*mul + + fvc::interpolate(rho*turbulence->nuEff()) + ); + + 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/rasCavitatingFoam/compressibilityModels/Chung/Chung.C b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Chung/Chung.C new file mode 100644 index 0000000000..6010d8f6df --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Chung/Chung.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "Chung.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +defineTypeNameAndDebug(Chung, 0); +addToRunTimeSelectionTable(compressibilityModel, Chung, dictionary); + +} +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibilityModels::Chung::Chung +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +: + compressibilityModel(compressibilityProperties, gamma), + psiv_(compressibilityProperties_.lookup("psiv")), + psil_(compressibilityProperties_.lookup("psil")), + rhovSat_(compressibilityProperties_.lookup("rhovSat")), + rholSat_(compressibilityProperties_.lookup("rholSat")) +{ + correct(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::compressibilityModels::Chung::correct() +{ + volScalarField sfa = sqrt + ( + (rhovSat_/psiv_) + /((scalar(1) - gamma_)*rhovSat_/psiv_ + gamma_*rholSat_/psil_) + ); + + psi_ = sqr + ( + ((scalar(1) - gamma_)/sqrt(psiv_) + gamma_*sfa/sqrt(psil_)) + *sqrt(psiv_*psil_)/sfa + ); +} + + +bool Foam::compressibilityModels::Chung::read +( + const dictionary& compressibilityProperties +) +{ + compressibilityModel::read(compressibilityProperties); + + compressibilityProperties_.lookup("psiv") >> psiv_; + compressibilityProperties_.lookup("psil") >> psil_; + compressibilityProperties_.lookup("rhovSat") >> rhovSat_; + compressibilityProperties_.lookup("rholSat") >> rholSat_; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Chung/Chung.H b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Chung/Chung.H new file mode 100644 index 0000000000..316054231e --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Chung/Chung.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressibilityModels::Chung + +Description + Chung compressibility model. + +SourceFiles + Chung.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Chung_H +#define Chung_H + +#include "compressibilityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +/*---------------------------------------------------------------------------*\ + Class Chung Declaration +\*---------------------------------------------------------------------------*/ + +class Chung +: + public compressibilityModel +{ + // Private data + + dimensionedScalar psiv_; + dimensionedScalar psil_; + + dimensionedScalar rhovSat_; + dimensionedScalar rholSat_; + + +public: + + //- Runtime type information + TypeName("Chung"); + + + // Constructors + + //- construct from components + Chung + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Destructor + + ~Chung() + {} + + + // Member Functions + + //- Correct the Chung compressibility + void correct(); + + //- Read transportProperties dictionary + bool read(const dictionary& compressibilityProperties); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressibilityModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Wallis/Wallis.C b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Wallis/Wallis.C new file mode 100644 index 0000000000..370cd1413f --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Wallis/Wallis.C @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "Wallis.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +defineTypeNameAndDebug(Wallis, 0); +addToRunTimeSelectionTable(compressibilityModel, Wallis, dictionary); + +} +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibilityModels::Wallis::Wallis +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +: + compressibilityModel(compressibilityProperties, gamma), + psiv_(compressibilityProperties_.lookup("psiv")), + psil_(compressibilityProperties_.lookup("psil")), + rhovSat_(compressibilityProperties_.lookup("rhovSat")), + rholSat_(compressibilityProperties_.lookup("rholSat")) +{ + correct(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::compressibilityModels::Wallis::correct() +{ + psi_ = (gamma_*rhovSat_ + (scalar(1) - gamma_)*rholSat_) + *(gamma_*psiv_/rhovSat_ + (scalar(1) - gamma_)*psil_/rholSat_); +} + + +bool Foam::compressibilityModels::Wallis::read +( + const dictionary& compressibilityProperties +) +{ + compressibilityModel::read(compressibilityProperties); + + compressibilityProperties_.lookup("psiv") >> psiv_; + compressibilityProperties_.lookup("psil") >> psil_; + compressibilityProperties_.lookup("rhovSat") >> rhovSat_; + compressibilityProperties_.lookup("rholSat") >> rholSat_; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Wallis/Wallis.H b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Wallis/Wallis.H new file mode 100644 index 0000000000..df576fc63a --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/Wallis/Wallis.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressibilityModels::Wallis + +Description + Wallis compressibility model. + +SourceFiles + Wallis.C + +\*---------------------------------------------------------------------------*/ + +#ifndef Wallis_H +#define Wallis_H + +#include "compressibilityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +/*---------------------------------------------------------------------------*\ + Class Wallis Declaration +\*---------------------------------------------------------------------------*/ + +class Wallis +: + public compressibilityModel +{ + // Private data + + dimensionedScalar psiv_; + dimensionedScalar psil_; + + dimensionedScalar rhovSat_; + dimensionedScalar rholSat_; + + +public: + + //- Runtime type information + TypeName("Wallis"); + + + // Constructors + + //- construct from components + Wallis + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Destructor + + ~Wallis() + {} + + + // Member Functions + + //- Correct the Wallis compressibility + void correct(); + + //- Read transportProperties dictionary + bool read(const dictionary& compressibilityProperties); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressibilityModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.C b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.C new file mode 100644 index 0000000000..c879f05a82 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.C @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +InClass + compressibilityModel + +\*---------------------------------------------------------------------------*/ + +#include "compressibilityModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(compressibilityModel, 0); + defineRunTimeSelectionTable(compressibilityModel, dictionary); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibilityModel::compressibilityModel +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +: + compressibilityProperties_(compressibilityProperties), + psi_ + ( + IOobject + ( + "psi", + gamma.mesh().time().timeName(), + gamma.mesh() + ), + gamma.mesh(), + dimensionedScalar("psi", dimensionSet(0, -2, 2, 0, 0), 0) + ), + gamma_(gamma) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +bool Foam::compressibilityModel::read +( + const dictionary& compressibilityProperties +) +{ + compressibilityProperties_ = compressibilityProperties; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.H b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.H new file mode 100644 index 0000000000..e0df9d99f5 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/compressibilityModel.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressibilityModel + +Description + +SourceFiles + compressibilityModel.C + newCompressibilityModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef compressibilityModel_H +#define compressibilityModel_H + +#include "IOdictionary.H" +#include "typeInfo.H" +#include "runTimeSelectionTables.H" +#include "volFields.H" +#include "dimensionedScalar.H" +#include "autoPtr.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class compressibilityModel Declaration +\*---------------------------------------------------------------------------*/ + +class compressibilityModel +{ + +protected: + + // Protected data + + dictionary compressibilityProperties_; + + volScalarField psi_; + const volScalarField& gamma_; + + + // Private Member Functions + + //- Disallow copy construct + compressibilityModel(const compressibilityModel&); + + //- Disallow default bitwise assignment + void operator=(const compressibilityModel&); + + +public: + + //- Runtime type information + TypeName("compressibilityModel"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + compressibilityModel, + dictionary, + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ), + (compressibilityProperties, gamma) + ); + + + // Selectors + + //- Return a reference to the selected compressibility model + static autoPtr New + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Constructors + + //- Construct from components + compressibilityModel + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Destructor + + virtual ~compressibilityModel() + {} + + + // Member Functions + + //- Return the phase transport properties dictionary + const dictionary& compressibilityProperties() const + { + return compressibilityProperties_; + } + + //- Return the compressibility + const volScalarField& psi() const + { + return psi_; + } + + //- Correct the compressibility + virtual void correct() = 0; + + //- Read compressibilityProperties dictionary + virtual bool read(const dictionary& compressibilityProperties) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/newCompressibilityModel.C b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/newCompressibilityModel.C new file mode 100644 index 0000000000..9604b563f5 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/compressibilityModel/newCompressibilityModel.C @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "compressibilityModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::compressibilityModel::New +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +{ + word compressibilityModelTypeName + ( + compressibilityProperties.lookup("compressibilityModel") + ); + + Info<< "Selecting compressibility model " + << compressibilityModelTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(compressibilityModelTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "compressibilityModel::New(const volScalarField&)" + ) << "Unknown compressibilityModel type " + << compressibilityModelTypeName << endl << endl + << "Valid compressibilityModels are : " << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalError); + } + + return autoPtr + ( + cstrIter()(compressibilityProperties, gamma) + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/linear/linear.C b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/linear/linear.C new file mode 100644 index 0000000000..8bd2316cdc --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/linear/linear.C @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "linear.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +defineTypeNameAndDebug(linear, 0); +addToRunTimeSelectionTable(compressibilityModel, linear, dictionary); + +} +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::compressibilityModels::linear::linear +( + const dictionary& compressibilityProperties, + const volScalarField& gamma +) +: + compressibilityModel(compressibilityProperties, gamma), + psiv_(compressibilityProperties_.lookup("psiv")), + psil_(compressibilityProperties_.lookup("psil")) +{ + correct(); + psi_.oldTime(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::compressibilityModels::linear::correct() +{ + psi_ = gamma_*psiv_ + (scalar(1) - gamma_)*psil_; +} + + +bool Foam::compressibilityModels::linear::read +( + const dictionary& compressibilityProperties +) +{ + compressibilityModel::read(compressibilityProperties); + + compressibilityProperties_.lookup("psiv") >> psiv_; + compressibilityProperties_.lookup("psil") >> psil_; + + return true; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/linear/linear.H b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/linear/linear.H new file mode 100644 index 0000000000..fbb614cf45 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/compressibilityModels/linear/linear.H @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + Foam::compressibilityModels::linear + +Description + linear compressibility model. + +SourceFiles + linear.C + +\*---------------------------------------------------------------------------*/ + +#ifndef linear_H +#define linear_H + +#include "compressibilityModel.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressibilityModels +{ + +/*---------------------------------------------------------------------------*\ + Class linear Declaration +\*---------------------------------------------------------------------------*/ + +class linear +: + public compressibilityModel +{ + // Private data + + dimensionedScalar psiv_; + dimensionedScalar psil_; + + +public: + + //- Runtime type information + TypeName("linear"); + + + // Constructors + + //- construct from components + linear + ( + const dictionary& compressibilityProperties, + const volScalarField& gamma + ); + + + // Destructor + + ~linear() + {} + + + // Member Functions + + //- Correct the linear compressibility + void correct(); + + //- Read transportProperties dictionary + bool read(const dictionary& compressibilityProperties); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressibilityModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // 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..e7877c947b --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/createFields.H @@ -0,0 +1,84 @@ + 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 = compressibilityModel::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..c945676d90 --- /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 + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "compressibilityModel.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 "readTransportProperties.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/readTransportProperties.H b/applications/solvers/multiphase/rasCavitatingFoam/readTransportProperties.H new file mode 100644 index 0000000000..e413743b78 --- /dev/null +++ b/applications/solvers/multiphase/rasCavitatingFoam/readTransportProperties.H @@ -0,0 +1,23 @@ + 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/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 + ) + ); + } +} + +// ************************************************************************* //