diff --git a/src/fvOptions/Make/files b/src/fvOptions/Make/files index 4591f3f3ae..ea5bbac675 100644 --- a/src/fvOptions/Make/files +++ b/src/fvOptions/Make/files @@ -37,6 +37,7 @@ $(derivedSources)/buoyancyForce/buoyancyForce.C $(derivedSources)/buoyancyForce/buoyancyForceIO.C $(derivedSources)/buoyancyEnergy/buoyancyEnergy.C $(derivedSources)/buoyancyEnergy/buoyancyEnergyIO.C +$(derivedSources)/verticalDamping/verticalDamping.C interRegion = sources/interRegion $(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C diff --git a/src/fvOptions/sources/derived/verticalDamping/verticalDamping.C b/src/fvOptions/sources/derived/verticalDamping/verticalDamping.C new file mode 100644 index 0000000000..6700bd44c0 --- /dev/null +++ b/src/fvOptions/sources/derived/verticalDamping/verticalDamping.C @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 "verticalDamping.H" +#include "fvMesh.H" +#include "fvMatrix.H" +#include "geometricOneField.H" +#include "meshTools.H" +#include "uniformDimensionedFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + defineTypeNameAndDebug(verticalDamping, 0); + addToRunTimeSelectionTable(option, verticalDamping, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::fv::verticalDamping::addSup +( + const volVectorField& alphaRhoU, + fvMatrix& eqn, + const label fieldi +) +{ + const uniformDimensionedVectorField& g = + mesh_.lookupObject("g"); + + const dimensionedSymmTensor lgg(lambda_*sqr(g)/magSqr(g)); + + const DimensionedField& V = mesh_.V(); + + // Check dimensions + eqn.dimensions() + - V.dimensions()*(lgg.dimensions() & alphaRhoU.dimensions()); + + forAll(cells_, i) + { + const label c = cells_[i]; + vector f = V[c]*(lgg.value() & alphaRhoU[c]); + meshTools::constrainDirection(mesh_, mesh_.solutionD(), f); + eqn.source()[c] += f; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fv::verticalDamping::verticalDamping +( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh +) +: + cellSetOption(name, modelType, dict, mesh), + lambda_("lambda", dimless/dimTime, coeffs_.lookup("lambda")) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fv::verticalDamping::addSup +( + fvMatrix& eqn, + const label fieldi +) +{ + addSup(eqn.psi(), eqn, fieldi); +} + + +void Foam::fv::verticalDamping::addSup +( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSup(rho*eqn.psi(), eqn, fieldi); +} + + +void Foam::fv::verticalDamping::addSup +( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi +) +{ + addSup(alpha*rho*eqn.psi(), eqn, fieldi); +} + + +bool Foam::fv::verticalDamping::read(const dictionary& dict) +{ + if (cellSetOption::read(dict)) + { + lambda_ = + dimensionedScalar + ( + lambda_.name(), + lambda_.dimensions(), + coeffs_.lookup(lambda_.name()) + ); + + fieldNames_ = wordList(1, coeffs_.lookupOrDefault("U", "U")); + + applied_.setSize(1, false); + + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/fvOptions/sources/derived/verticalDamping/verticalDamping.H b/src/fvOptions/sources/derived/verticalDamping/verticalDamping.H new file mode 100644 index 0000000000..6237c8e42d --- /dev/null +++ b/src/fvOptions/sources/derived/verticalDamping/verticalDamping.H @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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::fv::verticalDamping + +Description + This fvOption applies an explicit damping force to components of the vector + field in the direction of gravity. Its intended purpose is to damp the + vertical motions of an interface in the region approaching an outlet so that + no reflections are generated. + +Usage + Example usage: + \verbatim + verticalDamping1 + { + type verticalDamping; + + selectionMode cellZone; + cellZone nearOutlet; + + lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient + + timeStart 0; + duration 1e6; + } + \endverbatim + +SourceFiles + verticalDamping.C + +\*---------------------------------------------------------------------------*/ + +#ifndef verticalDamping_H +#define verticalDamping_H + +#include "cellSetOption.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + +/*---------------------------------------------------------------------------*\ + Class verticalDamping Declaration +\*---------------------------------------------------------------------------*/ + +class verticalDamping +: + public cellSetOption +{ +private: + + // Private data + + //- Damping coefficient [1/s] + dimensionedScalar lambda_; + + + // Private Member Functions + + //- Source term to momentum equation + void addSup + ( + const volVectorField& alphaRhoU, + fvMatrix& eqn, + const label fieldi + ); + + +public: + + //- Runtime type information + TypeName("verticalDamping"); + + + // Constructors + + //- Construct from components + verticalDamping + ( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh + ); + + + //- Destructor + virtual ~verticalDamping() + {} + + + // Member Functions + + // Add explicit and implicit contributions + + //- Source term to momentum equation + virtual void addSup + ( + fvMatrix& eqn, + const label fieldi + ); + + //- Source term to compressible momentum equation + virtual void addSup + ( + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + //- Source term to phase momentum equation + virtual void addSup + ( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const label fieldi + ); + + + // IO + + //- Read dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //