diff --git a/applications/solvers/multiphase/interFoam/alphaEqn.H b/applications/solvers/multiphase/interFoam/alphaEqn.H index d19ae9bb70..dc1146944e 100644 --- a/applications/solvers/multiphase/interFoam/alphaEqn.H +++ b/applications/solvers/multiphase/interFoam/alphaEqn.H @@ -30,7 +30,7 @@ } Info<< "Liquid phase volume fraction = " - << alpha1.weightedAverage(mesh.V()).value() + << alpha1.weightedAverage(mesh.Vsc()).value() << " Min(alpha1) = " << min(alpha1).value() << " Max(alpha1) = " << max(alpha1).value() << endl; diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H b/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H index b93ea3a020..675a410a16 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H @@ -155,7 +155,6 @@ phasei++; } Dp = mag(Dp); - adjustPhi(phi0, U, p); while (pimple.correctNonOrthogonal()) { diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 4c23251542..7ba18b3cc8 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -203,10 +203,15 @@ void Foam::Time::setControls() ) ); - if (timeDict.readIfPresent("deltaT", deltaT_)) + // Read and set the deltaT only if time-step adjustment is active + // otherwise use the deltaT from the controlDict + if (controlDict_.lookupOrDefault("adjustTimeStep", false)) { - deltaTSave_ = deltaT_; - deltaT0_ = deltaT_; + if (timeDict.readIfPresent("deltaT", deltaT_)) + { + deltaTSave_ = deltaT_; + deltaT0_ = deltaT_; + } } timeDict.readIfPresent("deltaT0", deltaT0_); diff --git a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C index e1f744b07e..baa873f5fc 100644 --- a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C +++ b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C @@ -36,7 +36,6 @@ void Foam::interpolation2DTable::readTable() // Read data from file reader_()(fName, *this); - //IFstream(fName)() >> *this; if (this->empty()) { @@ -361,7 +360,6 @@ void Foam::interpolation2DTable::write(Ostream& os) const { reader_->write(os); } - //*this >> os; } @@ -654,100 +652,6 @@ Type Foam::interpolation2DTable::operator() } } - label loY2 = 0; - label hiY2 = 0; - - nY = matrix::operator[](hiX).second().size(); - - minLimit = matrix::operator[](loX).second()[0].first(); - maxLimit = matrix::operator[](loX).second()[nY-1].first(); - - if (lookupValue < minLimit) - { - switch (boundsHandling_) - { - case interpolation2DTable::ERROR: - { - FatalErrorIn - ( - "Foam::interpolation2DTable::operator[]" - "(const scalar, const scalar) const" - ) << "value (" << lookupValue << ") underflow" << nl - << exit(FatalError); - break; - } - case interpolation2DTable::WARN: - { - WarningIn - ( - "Foam::interpolation2DTable::operator[]" - "(const scalar, const scalar) const" - ) << "value (" << lookupValue << ") underflow" << nl - << " Continuing with the first entry" - << endl; - // fall-through to 'CLAMP' - } - case interpolation2DTable::CLAMP: - { - loY2 = 0; - loY2 = 1; - break; - } - } - } - else if (lookupValue >= maxLimit) - { - switch (boundsHandling_) - { - case interpolation2DTable::ERROR: - { - FatalErrorIn - ( - "Foam::interpolation2DTable::operator[]" - "(const scalar, const scalar) const" - ) << "value (" << lookupValue << ") overflow" << nl - << exit(FatalError); - break; - } - case interpolation2DTable::WARN: - { - WarningIn - ( - "Foam::interpolation2DTable::operator[]" - "(const scalar, const scalar) const" - ) << "value (" << lookupValue << ") overflow" << nl - << " Continuing with the last entry" - << endl; - // fall-through to 'CLAMP' - } - case interpolation2DTable::CLAMP: - { - loY2 = nY-1; - loY2 = nY; - break; - } - } - } - else - { - // Finds the lo and hi of Y on the high x - for (label i = 0; i < nY; ++i) - { - if - ( - lookupValue >= matrix::operator[](hiX).second()[i].first() - ) - { - loY2 = hiY2 = i; - } - else - { - hiY2 = i; - break; - } - } - } - if (loX == hiX) { // we are at the end of the table - or there is only a single entry diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 2d4930f385..db1aee788a 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -170,7 +170,7 @@ $(derivedFvPatchFields)/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvP $(derivedFvPatchFields)/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/outletMappedUniformInlet/outletMappedUniformInletFvPatchFields.C $(derivedFvPatchFields)/waveSurfacePressure/waveSurfacePressureFvPatchScalarField.C - +$(derivedFvPatchFields)/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C fvsPatchFields = fields/fvsPatchFields $(fvsPatchFields)/fvsPatchField/fvsPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C new file mode 100644 index 0000000000..6b9a22da0f --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.C @@ -0,0 +1,202 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 "phaseHydrostaticPressureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "uniformDimensionedFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::phaseHydrostaticPressureFvPatchScalarField:: +phaseHydrostaticPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + phaseName_("alpha"), + rho_(0.0), + pRefValue_(0.0), + pRefPoint_(vector::zero) +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} + + +Foam::phaseHydrostaticPressureFvPatchScalarField:: +phaseHydrostaticPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + phaseName_(dict.lookupOrDefault("phaseName", "alpha")), + rho_(readScalar(dict.lookup("rho"))), + pRefValue_(readScalar(dict.lookup("pRefValue"))), + pRefPoint_(dict.lookup("pRefPoint")) +{ + this->refValue() = pRefValue_; + + if (dict.found("value")) + { + fvPatchScalarField::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + fvPatchScalarField::operator=(this->refValue()); + } + + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} + + +Foam::phaseHydrostaticPressureFvPatchScalarField:: +phaseHydrostaticPressureFvPatchScalarField +( + const phaseHydrostaticPressureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + phaseName_(ptf.phaseName_), + rho_(ptf.rho_), + pRefValue_(ptf.pRefValue_), + pRefPoint_(ptf.pRefPoint_) +{} + + +Foam::phaseHydrostaticPressureFvPatchScalarField:: +phaseHydrostaticPressureFvPatchScalarField +( + const phaseHydrostaticPressureFvPatchScalarField& ptf +) +: + mixedFvPatchScalarField(ptf), + phaseName_(ptf.phaseName_) +{} + + +Foam::phaseHydrostaticPressureFvPatchScalarField:: +phaseHydrostaticPressureFvPatchScalarField +( + const phaseHydrostaticPressureFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(ptf, iF), + phaseName_(ptf.phaseName_), + rho_(ptf.rho_), + pRefValue_(ptf.pRefValue_), + pRefPoint_(ptf.pRefPoint_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::phaseHydrostaticPressureFvPatchScalarField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const scalarField& alphap = + patch().lookupPatchField + ( + phaseName_ + ); + + const uniformDimensionedVectorField& g = + db().lookupObject("g"); + + // scalar rhor = 1000; + // scalarField alphap1 = max(min(alphap, 1.0), 0.0); + // valueFraction() = alphap1/(alphap1 + rhor*(1.0 - alphap1)); + valueFraction() = max(min(alphap, 1.0), 0.0); + + refValue() = + pRefValue_ + + rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_)); + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::phaseHydrostaticPressureFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + if (phaseName_ != "alpha") + { + os.writeKeyword("phaseName") + << phaseName_ << token::END_STATEMENT << nl; + } + os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl; + os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl; + os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void Foam::phaseHydrostaticPressureFvPatchScalarField::operator= +( + const fvPatchScalarField& ptf +) +{ + fvPatchScalarField::operator= + ( + valueFraction()*refValue() + + (1 - valueFraction())*ptf + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + phaseHydrostaticPressureFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.H new file mode 100644 index 0000000000..4c14094f49 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/phaseHydrostaticPressure/phaseHydrostaticPressureFvPatchScalarField.H @@ -0,0 +1,223 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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::phaseHydrostaticPressureFvPatchScalarField + +Description + Phase hydrostatic pressure boundary condition calculated as + + pRefValue + rho*g.(x - pRefPoint) + + where rho is provided and assumed uniform + + applied according to the phase-fraction field provided: + 1 -> fix value to that provided + 0 -> zero-gradient + +SourceFiles + phaseHydrostaticPressureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef phaseHydrostaticPressureFvPatchScalarField_H +#define phaseHydrostaticPressureFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class phaseHydrostaticPressureFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class phaseHydrostaticPressureFvPatchScalarField +: + public mixedFvPatchScalarField +{ + +protected: + + // Protected data + + //- Name of phase-fraction field + word phaseName_; + + //- Constant density in the far-field + scalar rho_; + + //- Reference pressure + scalar pRefValue_; + + //- Reference pressure location + vector pRefPoint_; + + +public: + + //- Runtime type information + TypeName("phaseHydrostaticPressure"); + + + // Constructors + + //- Construct from patch and internal field + phaseHydrostaticPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + phaseHydrostaticPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // phaseHydrostaticPressureFvPatchScalarField onto a new patch + phaseHydrostaticPressureFvPatchScalarField + ( + const phaseHydrostaticPressureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + phaseHydrostaticPressureFvPatchScalarField + ( + const phaseHydrostaticPressureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new phaseHydrostaticPressureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + phaseHydrostaticPressureFvPatchScalarField + ( + const phaseHydrostaticPressureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new phaseHydrostaticPressureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the phaseName + const word& phaseName() const + { + return phaseName_; + } + + //- Return reference to the phaseName to allow adjustment + word& phaseName() + { + return phaseName_; + } + + //- Return the constant density in the far-field + scalar rho() const + { + return rho_; + } + + //- Return reference to the constant density in the far-field + // to allow adjustment + scalar& rho() + { + return rho_; + } + + //- Return the reference pressure + scalar pRefValue() const + { + return pRefValue_; + } + + //- Return reference to the reference pressure to allow adjustment + scalar& pRefValue() + { + return pRefValue_; + } + + //- Return the pressure reference location + const vector& pRefPoint() const + { + return pRefPoint_; + } + + //- Return reference to the pressure reference location + // to allow adjustment + vector& pRefPoint() + { + return pRefPoint_; + } + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; + + + // Member operators + + virtual void operator=(const fvPatchScalarField& pvf); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution index 570725e737..c93b34506b 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/system/fvSolution @@ -128,7 +128,7 @@ relaxationFactors } equations { - "(U|k|epsilon|omega|R|nuTilda)" 1; + "(U|k|epsilon|omega|R|nuTilda).*" 1; } }