diff --git a/applications/solvers/multiphase/driftFluxFoam/driftFluxFoam.C b/applications/solvers/multiphase/driftFluxFoam/driftFluxFoam.C index da03517e..8ab48d7b 100644 --- a/applications/solvers/multiphase/driftFluxFoam/driftFluxFoam.C +++ b/applications/solvers/multiphase/driftFluxFoam/driftFluxFoam.C @@ -87,7 +87,6 @@ int main(int argc, char *argv[]) #include "alphaEqnSubCycle.H" twoPhaseProperties.correct(); - Info<< average(twoPhaseProperties.mu()) << endl; #include "UEqn.H" diff --git a/applications/solvers/multiphase/driftFluxFoam/kEpsilon.H b/applications/solvers/multiphase/driftFluxFoam/kEpsilon.H index 66216b87..ddcc8cf2 100644 --- a/applications/solvers/multiphase/driftFluxFoam/kEpsilon.H +++ b/applications/solvers/multiphase/driftFluxFoam/kEpsilon.H @@ -10,8 +10,6 @@ if (turbulence) dimensionedScalar epsilon0("epsilon0", epsilon.dimensions(), 0); dimensionedScalar epsilonMin("epsilonMin", epsilon.dimensions(), SMALL); - volScalarField divU(fvc::div(phi)); - tmp tgradU = fvc::grad(U); volScalarField G(mut*(tgradU() && dev(twoSymm(tgradU())))); tgradU.clear(); @@ -21,7 +19,7 @@ if (turbulence) Cmu*k/sigmak*(g & fvc::grad(rho))/(epsilon + epsilonMin) ); - volScalarField muc(twoPhaseProperties.nucModel().nu()*rho2); + volScalarField mul(twoPhaseProperties.mu()); #include "wallFunctions.H" @@ -32,12 +30,12 @@ if (turbulence) + fvm::div(rhoPhi, epsilon) - fvm::laplacian ( - mut/sigmaEps + muc, epsilon, + mut/sigmaEps + mul, epsilon, "laplacian(DepsilonEff,epsilon)" ) == C1*G*epsilon/(k + kMin) - - fvm::SuSp(C1*(1.0 - C3)*Gcoef + (2.0/3.0*C1)*rho*divU, epsilon) + - fvm::SuSp(C1*(1.0 - C3)*Gcoef, epsilon) - fvm::Sp(C2*rho*epsilon/(k + kMin), epsilon) ); @@ -56,12 +54,12 @@ if (turbulence) + fvm::div(rhoPhi, k) - fvm::laplacian ( - mut/sigmak + muc, k, + mut/sigmak + mul, k, "laplacian(DkEff,k)" ) == G - - fvm::SuSp(Gcoef + 2.0/3.0*rho*divU, k) + - fvm::SuSp(Gcoef, k) - fvm::Sp(rho*epsilon/(k + kMin), k) ); @@ -75,6 +73,10 @@ if (turbulence) mut = rho*Cmu*sqr(k)/(epsilon + epsilonMin); #include "wallViscosity.H" -} -muEff = mut + twoPhaseProperties.mu(); + muEff = mut + mul; +} +else +{ + muEff = mut + twoPhaseProperties.mu(); +} diff --git a/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/general/general.C b/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/general/general.C index c260bf85..b3d46e1e 100644 --- a/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/general/general.C +++ b/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/general/general.C @@ -70,8 +70,7 @@ void Foam::relativeVelocityModels::general::correct() *( exp(-a_*max(alphad_ - residualAlpha_, scalar(0))) - exp(-a1_*max(alphad_ - residualAlpha_, scalar(0))) - ) - /max(alphac_, residualAlpha_); + ); } diff --git a/applications/solvers/multiphase/driftFluxFoam/wallFunctions.H b/applications/solvers/multiphase/driftFluxFoam/wallFunctions.H index b9ff8481..2a064b47 100644 --- a/applications/solvers/multiphase/driftFluxFoam/wallFunctions.H +++ b/applications/solvers/multiphase/driftFluxFoam/wallFunctions.H @@ -33,7 +33,7 @@ if (isA(curPatch)) { const scalarField& mutw = mut.boundaryField()[patchi]; - const scalarField& mucw = muc.boundaryField()[patchi]; + const scalarField& mulw = mul.boundaryField()[patchi]; scalarField magFaceGradU ( @@ -55,7 +55,7 @@ /(kappa_*y[patchi][facei]); G[faceCelli] += - (mutw[facei] + mucw[facei]) + (mutw[facei] + mulw[facei]) *magFaceGradU[facei] *Cmu25*::sqrt(k[faceCelli]) /(kappa_*y[patchi][facei]); diff --git a/applications/solvers/multiphase/driftFluxFoam/wallViscosity.H b/applications/solvers/multiphase/driftFluxFoam/wallViscosity.H index 2b54f6c2..632432ff 100644 --- a/applications/solvers/multiphase/driftFluxFoam/wallViscosity.H +++ b/applications/solvers/multiphase/driftFluxFoam/wallViscosity.H @@ -12,7 +12,8 @@ if (isA(curPatch)) { scalarField& mutw = mut.boundaryField()[patchi]; - const scalarField& mucw = muc.boundaryField()[patchi]; + const scalarField& mulw = mul.boundaryField()[patchi]; + const scalarField& rhow = rho.boundaryField()[patchi]; forAll(curPatch, facei) { @@ -20,12 +21,12 @@ scalar yPlus = Cmu25*y[patchi][facei]*::sqrt(k[faceCelli]) - /(mucw[facei]/rho2.value()); + /(mulw[facei]/rhow[facei]); if (yPlus > 11.6) { mutw[facei] = - mucw[facei]*(yPlus*kappa_/::log(E_*yPlus) - 1); + mulw[facei]*(yPlus*kappa_/::log(E_*yPlus) - 1); } else { diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/Make/files b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/Make/files index 96f9c63e..2a3a6a96 100644 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/Make/files +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/Make/files @@ -32,4 +32,7 @@ kineticTheoryModels/frictionalStressModel/frictionalStressModel/newFrictionalStr kineticTheoryModels/frictionalStressModel/JohnsonJackson/JohnsonJacksonFrictionalStress.C kineticTheoryModels/frictionalStressModel/Schaeffer/SchaefferFrictionalStress.C +kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C +kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C + LIB = $(FOAM_LIBBIN)/libphaseIncompressibleTurbulenceModels diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C new file mode 100644 index 00000000..c9549399 --- /dev/null +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.C @@ -0,0 +1,258 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "JohnsonJacksonParticleSlipFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "twoPhaseSystem.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + JohnsonJacksonParticleSlipFvPatchVectorField + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::JohnsonJacksonParticleSlipFvPatchVectorField:: +JohnsonJacksonParticleSlipFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + partialSlipFvPatchVectorField(p, iF), + specularityCoefficient_(p.size()) +{} + + +Foam::JohnsonJacksonParticleSlipFvPatchVectorField:: +JohnsonJacksonParticleSlipFvPatchVectorField +( + const JohnsonJacksonParticleSlipFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + partialSlipFvPatchVectorField(ptf, p, iF, mapper), + specularityCoefficient_(ptf.specularityCoefficient_) +{} + + +Foam::JohnsonJacksonParticleSlipFvPatchVectorField:: +JohnsonJacksonParticleSlipFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + partialSlipFvPatchVectorField(p, iF), + specularityCoefficient_ + ( + "specularityCoefficient", + dimless, + dict.lookup("specularityCoefficient") + ) +{ + if + ( + (specularityCoefficient_.value() < 0) + || (specularityCoefficient_.value() > 1) + ) + { + FatalErrorIn + ( + "(" + "Foam::JohnsonJacksonParticleSlipFvPatchVectorField::" + "JohnsonJacksonParticleSlipFvPatchVectorField" + "const fvPatch& p," + "const DimensionedField& iF," + "const dictionary& dict" + ")" + ) << "The specularity coefficient has to be between 0 and 1" + << abort(FatalError); + } + + if (dict.found("value")) + { + fvPatchVectorField::operator= + ( + vectorField("value", dict, p.size()) + ); + } + else + { + partialSlipFvPatchVectorField::evaluate(); + } +} + + +Foam::JohnsonJacksonParticleSlipFvPatchVectorField:: +JohnsonJacksonParticleSlipFvPatchVectorField +( + const JohnsonJacksonParticleSlipFvPatchVectorField& ptf +) +: + partialSlipFvPatchVectorField(ptf), + specularityCoefficient_(ptf.specularityCoefficient_) +{} + + +Foam::JohnsonJacksonParticleSlipFvPatchVectorField:: +JohnsonJacksonParticleSlipFvPatchVectorField +( + const JohnsonJacksonParticleSlipFvPatchVectorField& ptf, + const DimensionedField& iF +) +: + partialSlipFvPatchVectorField(ptf, iF), + specularityCoefficient_(ptf.specularityCoefficient_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::autoMap +( + const fvPatchFieldMapper& m +) +{ + partialSlipFvPatchVectorField::autoMap(m); +} + + +void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::rmap +( + const fvPatchVectorField& ptf, + const labelList& addr +) +{ + partialSlipFvPatchVectorField::rmap(ptf, addr); +} + + +void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // lookup the fluid model and the phase + const twoPhaseSystem& fluid = db().lookupObject + ( + "phaseProperties" + ); + + const phaseModel& phased + ( + fluid.phase1().name() == dimensionedInternalField().group() + ? fluid.phase1() + : fluid.phase2() + ); + + // lookup all the fields on this patch + const fvPatchScalarField& alpha + ( + patch().lookupPatchField + ( + phased.volScalarField::name() + ) + ); + + const fvPatchScalarField& gs0 + ( + patch().lookupPatchField + ( + IOobject::groupName("gs0", phased.name()) + ) + ); + + const scalarField nu + ( + phased.nu()->boundaryField()[patch().index()] + ); + + word ThetaName(IOobject::groupName("Theta", phased.name())); + + const fvPatchScalarField& Theta + ( + db().foundObject(ThetaName) + ? patch().lookupPatchField(ThetaName) + : alpha + ); + + // lookup the packed volume fraction + dimensionedScalar alphaMax + ( + "alphaMax", + dimless, + db() + .lookupObject + ( + IOobject::groupName("turbulenceProperties", phased.name()) + ) + .subDict("RAS") + .subDict("kineticTheoryCoeffs") + .lookup("alphaMax") + ); + + // calculate the slip value fraction + scalarField c + ( + constant::mathematical::pi + *alpha + *gs0 + *specularityCoefficient_.value() + *sqrt(3.0*Theta) + /max(6.0*nu*alphaMax.value(), SMALL) + ); + + this->valueFraction() = c/(c + patch().deltaCoeffs()); + + partialSlipFvPatchVectorField::updateCoeffs(); +} + + +void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::write +( + Ostream& os +) const +{ + fvPatchVectorField::write(os); + os.writeKeyword("specularityCoefficient") + << specularityCoefficient_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.H b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.H new file mode 100644 index 00000000..9d3bc14a --- /dev/null +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleSlip/JohnsonJacksonParticleSlipFvPatchVectorField.H @@ -0,0 +1,177 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::JohnsonJacksonParticleSlipFvPatchVectorField + +Description + Partial slip boundary condition for the particulate velocity. + + References: + \verbatim + "Multifluid Eulerian modeling of dense gas–solids fluidized bed + hydrodynamics: Influence of the dissipation parameters" + N Reuge + Chemical Engineering Science + Volume 63, Issue 22, Pages 5540-5551, November 2008 + \endverbatim + + \verbatim + "Frictional-collisional constitutive relations for granular materials, + with application to plane shearing" + P C Johnson and R Jackson + Journal of Fluid Mechanics + Volume 176, Pages 67-93, March 1987 + \endverbatim + +SourceFiles + JohnsonJacksonParticleSlipFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef JohnsonJacksonParticleSlipFvPatchVectorField_H +#define JohnsonJacksonParticleSlipFvPatchVectorField_H + +#include "partialSlipFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class JohnsonJacksonParticleSlipFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class JohnsonJacksonParticleSlipFvPatchVectorField +: + public partialSlipFvPatchVectorField +{ + // Private data + + //- Specularity coefficient + dimensionedScalar specularityCoefficient_; + + +public: + + //- Runtime type information + TypeName("JohnsonJacksonParticleSlip"); + + + // Constructors + + //- Construct from patch and internal field + JohnsonJacksonParticleSlipFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + JohnsonJacksonParticleSlipFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping onto a new patch + JohnsonJacksonParticleSlipFvPatchVectorField + ( + const JohnsonJacksonParticleSlipFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + JohnsonJacksonParticleSlipFvPatchVectorField + ( + const JohnsonJacksonParticleSlipFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new JohnsonJacksonParticleSlipFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + JohnsonJacksonParticleSlipFvPatchVectorField + ( + const JohnsonJacksonParticleSlipFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new JohnsonJacksonParticleSlipFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchVectorField&, + const labelList& + ); + + //- Update the coefficients + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C new file mode 100644 index 00000000..4369c4ad --- /dev/null +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.C @@ -0,0 +1,323 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "JohnsonJacksonParticleThetaFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "twoPhaseSystem.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + JohnsonJacksonParticleThetaFvPatchScalarField + ); +} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::JohnsonJacksonParticleThetaFvPatchScalarField:: +JohnsonJacksonParticleThetaFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + restitutionCoefficient_(p.size()), + specularityCoefficient_(p.size()) +{} + + +Foam::JohnsonJacksonParticleThetaFvPatchScalarField:: +JohnsonJacksonParticleThetaFvPatchScalarField +( + const JohnsonJacksonParticleThetaFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + restitutionCoefficient_(ptf.restitutionCoefficient_), + specularityCoefficient_(ptf.specularityCoefficient_) +{ +} + + +Foam::JohnsonJacksonParticleThetaFvPatchScalarField:: +JohnsonJacksonParticleThetaFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + restitutionCoefficient_ + ( + "restitutionCoefficient", + dimless, + dict.lookup("restitutionCoefficient") + ), + specularityCoefficient_ + ( + "specularityCoefficient", + dimless, + dict.lookup("specularityCoefficient") + ) +{ + if + ( + (restitutionCoefficient_.value() < 0) + || (restitutionCoefficient_.value() > 1) + ) + { + FatalErrorIn + ( + "Foam::JohnsonJacksonParticleThetaFvPatchScalarField::" + "JohnsonJacksonParticleThetaFvPatchScalarField" + "(" + "const fvPatch& p," + "const DimensionedField& iF," + "const dictionary& dict" + ")" + ) << "The restitution coefficient has to be between 0 and 1" + << abort(FatalError); + } + + if + ( + (specularityCoefficient_.value() < 0) + || (specularityCoefficient_.value() > 1) + ) + { + FatalErrorIn + ( + "Foam::JohnsonJacksonParticleThetaFvPatchScalarField::" + "JohnsonJacksonParticleThetaFvPatchScalarField" + "(" + "const fvPatch& p," + "const DimensionedField& iF," + "const dictionary& dict" + ")" + ) << "The specularity coefficient has to be between 0 and 1" + << abort(FatalError); + } + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + evaluate(); + } +} + + +Foam::JohnsonJacksonParticleThetaFvPatchScalarField:: +JohnsonJacksonParticleThetaFvPatchScalarField +( + const JohnsonJacksonParticleThetaFvPatchScalarField& ptf +) +: + mixedFvPatchScalarField(ptf), + restitutionCoefficient_(ptf.restitutionCoefficient_), + specularityCoefficient_(ptf.specularityCoefficient_) +{} + + +Foam::JohnsonJacksonParticleThetaFvPatchScalarField:: +JohnsonJacksonParticleThetaFvPatchScalarField +( + const JohnsonJacksonParticleThetaFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptf, iF), + restitutionCoefficient_(ptf.restitutionCoefficient_), + specularityCoefficient_(ptf.specularityCoefficient_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + mixedFvPatchScalarField::autoMap(m); +} + + +void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); +} + + +void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // lookup the fluid model and the phase + const twoPhaseSystem& fluid = db().lookupObject + ( + "phaseProperties" + ); + + const phaseModel& phased + ( + fluid.phase1().name() == dimensionedInternalField().group() + ? fluid.phase1() + : fluid.phase2() + ); + + // lookup all the fields on this patch + const fvPatchScalarField& alpha + ( + patch().lookupPatchField + ( + phased.volScalarField::name() + ) + ); + + const fvPatchVectorField& U + ( + patch().lookupPatchField + ( + IOobject::groupName("U", phased.name()) + ) + ); + + const fvPatchScalarField& gs0 + ( + patch().lookupPatchField + ( + IOobject::groupName("gs0", phased.name()) + ) + ); + + const fvPatchScalarField& kappa + ( + patch().lookupPatchField + ( + IOobject::groupName("kappa", phased.name()) + ) + ); + + const scalarField Theta(patchInternalField()); + + // lookup the packed volume fraction + dimensionedScalar alphaMax + ( + "alphaMax", + dimless, + db() + .lookupObject + ( + IOobject::groupName("turbulenceProperties", phased.name()) + ) + .subDict("RAS") + .subDict("kineticTheoryCoeffs") + .lookup("alphaMax") + ); + + // calculate the reference value and the value fraction + if (restitutionCoefficient_.value() != 1.0) + { + this->refValue() = + (2.0/3.0) + *specularityCoefficient_.value() + *magSqr(U) + /(scalar(1) - sqr(restitutionCoefficient_.value())); + + this->refGrad() = 0.0; + + scalarField c + ( + constant::mathematical::pi + *alpha + *gs0 + *(scalar(1) - sqr(restitutionCoefficient_.value())) + *sqrt(3.0*Theta) + /max(4.0*kappa*alphaMax.value(), SMALL) + ); + + this->valueFraction() = c/(c + patch().deltaCoeffs()); + } + + // for a restitution coefficient of 1, the boundary degenerates to a fixed + // gradient condition + else + { + this->refValue() = 0.0; + + this->refGrad() = + pos(alpha - SMALL) + *constant::mathematical::pi + *specularityCoefficient_.value() + *alpha + *gs0 + *sqrt(3.0*Theta) + *magSqr(U) + /max(6.0*kappa*alphaMax.value(), SMALL); + + this->valueFraction() = 0.0; + } + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("restitutionCoefficient") + << restitutionCoefficient_ << token::END_STATEMENT << nl; + os.writeKeyword("specularityCoefficient") + << specularityCoefficient_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.H b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.H new file mode 100644 index 00000000..9c75efd9 --- /dev/null +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/phaseIncompressibleTurbulenceModels/kineticTheoryModels/derivedFvPatchFields/JohnsonJacksonParticleTheta/JohnsonJacksonParticleThetaFvPatchScalarField.H @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::JohnsonJacksonParticleThetaFvPatchScalarField + +Description + Robin condition for the particulate granular temperature. + + References: + \verbatim + "Multifluid Eulerian modeling of dense gas–solids fluidized bed + hydrodynamics: Influence of the dissipation parameters" + N Reuge + Chemical Engineering Science + Volume 63, Issue 22, Pages 5540-5551, November 2008 + \endverbatim + + \verbatim + "Frictional-collisional constitutive relations for granular materials, + with application to plane shearing" + P C Johnson and R Jackson + Journal of Fluid Mechanics + Volume 176, Pages 67-93, March 1987 + \endverbatim + +SourceFiles + JohnsonJacksonParticleThetaFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef JohnsonJacksonParticleThetaFvPatchScalarField_H +#define JohnsonJacksonParticleThetaFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class JohnsonJacksonParticleThetaFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class JohnsonJacksonParticleThetaFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Particle-wall restitution coefficient + dimensionedScalar restitutionCoefficient_; + + //- Specularity coefficient + dimensionedScalar specularityCoefficient_; + + +public: + + //- Runtime type information + TypeName("JohnsonJacksonParticleTheta"); + + + // Constructors + + //- Construct from patch and internal field + JohnsonJacksonParticleThetaFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + JohnsonJacksonParticleThetaFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping onto a new patch + JohnsonJacksonParticleThetaFvPatchScalarField + ( + const JohnsonJacksonParticleThetaFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + JohnsonJacksonParticleThetaFvPatchScalarField + ( + const JohnsonJacksonParticleThetaFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new JohnsonJacksonParticleThetaFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + JohnsonJacksonParticleThetaFvPatchScalarField + ( + const JohnsonJacksonParticleThetaFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new JohnsonJacksonParticleThetaFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + //- Update the coefficients + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C index 136dea38..aa792712 100644 --- a/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C +++ b/applications/utilities/parallelProcessing/redistributePar/loadOrCreateMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,10 +25,19 @@ License #include "loadOrCreateMesh.H" #include "processorPolyPatch.H" +#include "processorCyclicPolyPatch.H" #include "Time.H" +#include "IOPtrList.H" // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // +namespace Foam +{ + defineTemplateTypeNameAndDebug(IOPtrList, 0); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + // Read mesh if available. Otherwise create empty mesh with same non-proc // patches as proc0 mesh. Requires all processors to have all patches // (and in same order). @@ -48,11 +57,68 @@ Foam::autoPtr Foam::loadOrCreateMesh meshSubDir = io.name()/polyMesh::meshSubDir; } + + // Scatter master patches + PtrList patchEntries; + if (Pstream::master()) + { + // Read PtrList of dictionary as dictionary. + const word oldTypeName = IOPtrList::typeName; + const_cast(IOPtrList::typeName) = word::null; + IOPtrList dictList + ( + IOobject + ( + "boundary", + io.time().findInstance + ( + meshSubDir, + "boundary", + IOobject::MUST_READ + ), + meshSubDir, + io.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + const_cast(IOPtrList::typeName) = oldTypeName; + // Fake type back to what was in field + const_cast(dictList.type()) = dictList.headerClassName(); + + patchEntries.transfer(dictList); + + // Send patches + for + ( + int slave=Pstream::firstSlave(); + slave<=Pstream::lastSlave(); + slave++ + ) + { + OPstream toSlave(Pstream::scheduled, slave); + toSlave << patchEntries; + } + } + else + { + // Receive patches + IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); + fromMaster >> patchEntries; + } + + + // Check who has a mesh const bool haveMesh = isDir(io.time().path()/io.instance()/meshSubDir); if (!haveMesh) { + bool oldParRun = Pstream::parRun(); + Pstream::parRun() = false; + + // Create dummy mesh. Only used on procs that don't have mesh. IOobject noReadIO(io); noReadIO.readOpt() = IOobject::NO_READ; @@ -65,6 +131,39 @@ Foam::autoPtr Foam::loadOrCreateMesh xferCopy(labelList()), false ); + + // Add patches + List patches(patchEntries.size()); + label nPatches = 0; + + forAll(patchEntries, patchI) + { + const entry& e = patchEntries[patchI]; + const word type(e.dict().lookup("type")); + const word& name = e.keyword(); + + if + ( + type != processorPolyPatch::typeName + && type != processorCyclicPolyPatch::typeName + ) + { + dictionary patchDict(e.dict()); + patchDict.set("nFaces", 0); + patchDict.set("startFace", 0); + + patches[patchI] = polyPatch::New + ( + name, + patchDict, + nPatches++, + dummyMesh.boundaryMesh() + ).ptr(); + } + } + patches.setSize(nPatches); + dummyMesh.addFvPatches(patches, false); // no parallel comms + // Add some dummy zones so upon reading it does not read them // from the undecomposed case. Should be done as extra argument to // regIOobject::readStream? @@ -106,6 +205,8 @@ Foam::autoPtr Foam::loadOrCreateMesh //Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath() // << endl; dummyMesh.write(); + + Pstream::parRun() = oldParRun; } //Pout<< "Reading mesh from " << io.objectPath() << endl; @@ -116,118 +217,57 @@ Foam::autoPtr Foam::loadOrCreateMesh // Sync patches // ~~~~~~~~~~~~ - if (Pstream::master()) + if (!Pstream::master() && haveMesh) { - // Send patches - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) + // Check master names against mine + + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + forAll(patchEntries, patchI) { - OPstream toSlave(Pstream::scheduled, slave); - toSlave << mesh.boundaryMesh(); - } - } - else - { - // Receive patches - IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); - PtrList patchEntries(fromMaster); + const entry& e = patchEntries[patchI]; + const word type(e.dict().lookup("type")); + const word& name = e.keyword(); - if (haveMesh) - { - // Check master names against mine - - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - forAll(patchEntries, patchI) + if (type == processorPolyPatch::typeName) { - const entry& e = patchEntries[patchI]; - const word type(e.dict().lookup("type")); - const word& name = e.keyword(); - - if (type == processorPolyPatch::typeName) - { - break; - } - - if (patchI >= patches.size()) - { - FatalErrorIn - ( - "createMesh(const Time&, const fileName&, const bool)" - ) << "Non-processor patches not synchronised." - << endl - << "Processor " << Pstream::myProcNo() - << " has only " << patches.size() - << " patches, master has " - << patchI - << exit(FatalError); - } - - if - ( - type != patches[patchI].type() - || name != patches[patchI].name() - ) - { - FatalErrorIn - ( - "createMesh(const Time&, const fileName&, const bool)" - ) << "Non-processor patches not synchronised." - << endl - << "Master patch " << patchI - << " name:" << type - << " type:" << type << endl - << "Processor " << Pstream::myProcNo() - << " patch " << patchI - << " has name:" << patches[patchI].name() - << " type:" << patches[patchI].type() - << exit(FatalError); - } + break; } - } - else - { - // Add patch - List patches(patchEntries.size()); - label nPatches = 0; - forAll(patchEntries, patchI) + if (patchI >= patches.size()) { - const entry& e = patchEntries[patchI]; - const word type(e.dict().lookup("type")); - const word& name = e.keyword(); - - if (type == processorPolyPatch::typeName) - { - break; - } - - //Pout<< "Adding patch:" << nPatches - // << " name:" << name << " type:" << type << endl; - - dictionary patchDict(e.dict()); - patchDict.remove("nFaces"); - patchDict.add("nFaces", 0); - patchDict.remove("startFace"); - patchDict.add("startFace", 0); - - patches[patchI] = polyPatch::New + FatalErrorIn ( - name, - patchDict, - nPatches++, - mesh.boundaryMesh() - ).ptr(); + "createMesh(const Time&, const fileName&, const bool)" + ) << "Non-processor patches not synchronised." + << endl + << "Processor " << Pstream::myProcNo() + << " has only " << patches.size() + << " patches, master has " + << patchI + << exit(FatalError); } - patches.setSize(nPatches); - mesh.addFvPatches(patches, false); // no parallel comms - //// Write empty mesh now we have correct patches - //meshPtr().write(); + if + ( + type != patches[patchI].type() + || name != patches[patchI].name() + ) + { + FatalErrorIn + ( + "createMesh(const Time&, const fileName&, const bool)" + ) << "Non-processor patches not synchronised." + << endl + << "Master patch " << patchI + << " name:" << type + << " type:" << type << endl + << "Processor " << Pstream::myProcNo() + << " patch " << patchI + << " has name:" << patches[patchI].name() + << " type:" << patches[patchI].type() + << exit(FatalError); + } } } diff --git a/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C b/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C index 83edf7de..91c401ee 100644 --- a/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C +++ b/src/TurbulenceModels/phaseIncompressible/RAS/LaheyKEpsilon/LaheyKEpsilon.C @@ -194,7 +194,6 @@ tmp LaheyKEpsilon::bubbleG() const tmp bubbleG ( Cp_ - *liquid*liquid.rho() *( pow3(magUr) + pow(fluid.drag(gas).CdRe()*liquid.nu()/gas.d(), 4.0/3.0) diff --git a/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.C b/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.C index b6eef980..b3b453d6 100644 --- a/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.C +++ b/src/TurbulenceModels/phaseIncompressible/RAS/continuousGasKEpsilon/continuousGasKEpsilon.C @@ -124,9 +124,17 @@ void continuousGasKEpsilon::correctNut() const transportModel& liquid = fluid.otherPhase(gas); volScalarField thetal(liquidTurbulence.k()/liquidTurbulence.epsilon()); - volScalarField thetag((1.0/(18*liquid.nu()))*sqr(gas.d())); - volScalarField expThetar(exp(min(thetal/thetag, scalar(50)))); - volScalarField omega(sqr(expThetar - 1)/(sqr(expThetar) - 1)); + volScalarField rhodv(gas.rho() + fluid.virtualMass(gas).Cvm()*liquid.rho()); + volScalarField thetag((rhodv/(18*liquid.rho()*liquid.nu()))*sqr(gas.d())); + volScalarField expThetar + ( + min + ( + exp(min(thetal/thetag, scalar(50))), + scalar(1) + ) + ); + volScalarField omega((1 - expThetar)/(1 + expThetar)); nutEff_ = omega*liquidTurbulence.nut(); } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C index 1c7d63e6..8e9e844c 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -649,22 +649,20 @@ void Foam::refinementHistory::countProc // Increment parent if whole splitCell moves to same processor if (splitCellNum[index] == 8) { - Pout<< "Moving " << splitCellNum[index] - << " cells originating from cell " << index - << " from processor " << Pstream::myProcNo() - << " to processor " << splitCellProc[index] - << endl; + if (debug) + { + Pout<< "Moving " << splitCellNum[index] + << " cells originating from cell " << index + << " from processor " << Pstream::myProcNo() + << " to processor " << splitCellProc[index] + << endl; + } label parent = splitCells_[index].parent_; if (parent >= 0) { - string oldPrefix = Pout.prefix(); - Pout.prefix() = " " + oldPrefix; - countProc(parent, newProcNo, splitCellProc, splitCellNum); - - Pout.prefix() = oldPrefix; } } } @@ -924,7 +922,10 @@ void Foam::refinementHistory::distribute(const mapDistributePolyMesh& map) forAll(newVisibleCells, i) { - visibleCells_[constructMap[i]] = newVisibleCells[i] + offset; + if (newVisibleCells[i] >= 0) + { + visibleCells_[constructMap[i]] = newVisibleCells[i] + offset; + } } } splitCells_.shrink(); diff --git a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/0.org/U b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/0.org/U index 695fc93f..e6b10c7c 100644 --- a/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/0.org/U +++ b/tutorials/multiphase/potentialFreeSurfaceFoam/oscillatingBox/0.org/U @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 2.3.0 | +| \\ / O peration | Version: 2.3.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -33,16 +33,25 @@ boundaryField } floatingObject { - type oscillatingFixedValue; - refValue uniform (0 1 0); - offset (0 -1 0); - amplitude table - ( - ( 0 0) - ( 10 0.025) - (1000 0.025) - ); - frequency constant 1; + type fixedNormalInletOutletVelocity; + + fixTangentialInflow false; + + normalVelocity + { + type oscillatingFixedValue; + refValue uniform (0 1 0); + offset (0 -1 0); + amplitude table + ( + ( 0 0) + ( 10 0.025) + (1000 0.025) + ); + frequency constant 1; + value uniform (0 0 0); + } + value uniform (0 0 0); } frontAndBack