diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index be371512455a5e032d2dc58270f251292f2efa5a..ef849f6dff00d28cb8ca4d9ca51b4ba0a857f0c4 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -238,6 +238,8 @@ $(derivedFvPatchFields)/plenumPressure/plenumPressureFvPatchScalarField.C $(derivedFvPatchFields)/interfaceCompression/interfaceCompressionFvPatchScalarField.C $(derivedFvPatchFields)/swirlFanVelocity/swirlFanVelocityFvPatchField.C $(derivedFvPatchFields)/acousticWaveTransmissive/acousticWaveTransmissiveFvPatchFields.C +$(derivedFvPatchFields)/prghPermeableAlphaTotalPressure/prghPermeableAlphaTotalPressureFvPatchScalarField.C +$(derivedFvPatchFields)/pressurePermeableAlphaInletOutletVelocity/pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/mappedMixed/mappedMixedFvPatchFields.C $(derivedFvPatchFields)/mappedField/Sampled/makeSampledPatchFunction1s.C diff --git a/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.C b/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.C index a4410c7ea196dcedcd3dacbb7af13d6ee30db58d..4006afc62fcfd9a1b492f1fb5e378480a0b6e521 100644 --- a/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.C +++ b/src/finiteVolume/cfdTools/general/constrainPressure/constrainPressure.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,7 +30,7 @@ License #include "volFields.H" #include "surfaceFields.H" #include "geometricOneField.H" -#include "fixedFluxPressureFvPatchScalarField.H" +#include "updateableSnGrad.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,21 +52,19 @@ void Foam::constrainPressure const volVectorField::Boundary& UBf = U.boundaryField(); const surfaceScalarField::Boundary& phiHbyABf = phiHbyA.boundaryField(); - const typename RAUType::Boundary& rhorAUBf = - rhorAU.boundaryField(); - const surfaceVectorField::Boundary& SfBf = - mesh.Sf().boundaryField(); + const typename RAUType::Boundary& rhorAUBf = rhorAU.boundaryField(); + const surfaceVectorField::Boundary& SfBf = mesh.Sf().boundaryField(); const surfaceScalarField::Boundary& magSfBf = mesh.magSf().boundaryField(); forAll(pBf, patchi) { - if (isA<fixedFluxPressureFvPatchScalarField>(pBf[patchi])) + typedef updateablePatchTypes::updateableSnGrad snGradType; + const auto* snGradPtr = isA<snGradType>(pBf[patchi]); + + if (snGradPtr) { - refCast<fixedFluxPressureFvPatchScalarField> - ( - pBf[patchi] - ).updateSnGrad + const_cast<snGradType&>(*snGradPtr).updateSnGrad ( ( phiHbyABf[patchi] diff --git a/src/finiteVolume/cfdTools/general/updateableSnGrad/updateableSnGrad.H b/src/finiteVolume/cfdTools/general/updateableSnGrad/updateableSnGrad.H new file mode 100644 index 0000000000000000000000000000000000000000..a241db328ee6c7a72347b122b3473e289d4f95dc --- /dev/null +++ b/src/finiteVolume/cfdTools/general/updateableSnGrad/updateableSnGrad.H @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::updateableSnGrad + +Description + Helper class to fix pressure flux + for pressure-related boundary conditions. + +See also + - Foam::prghPermeableAlphaTotalPressureFvPatchScalarField + +SourceFiles + updateableSnGrad.C + +\*---------------------------------------------------------------------------*/ + +#ifndef updateableSnGrad_H +#define updateableSnGrad_H + +#include "primitiveFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace updateablePatchTypes +{ +/*---------------------------------------------------------------------------*\ + Class updateableSnGrad declaration +\*---------------------------------------------------------------------------*/ + +class updateableSnGrad +{ +public: + + // Public Member Functions + + //- Constructor + updateableSnGrad() = default; + + //- Destructor + virtual ~updateableSnGrad() = default; + + + // Member Functions + + //- Update snGrad + virtual void updateSnGrad(const scalarField& snGradp) = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace updateablePatchTypes +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H index da46ce3fac7920eeb71313f883a1b6925af93069..cddfa8aa34c2d075ffb1cd5cce1f98665339ea6b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,6 +56,7 @@ SourceFiles #include "fvPatchFields.H" #include "fixedGradientFvPatchFields.H" +#include "updateableSnGrad.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -68,7 +69,8 @@ namespace Foam class fixedFluxPressureFvPatchScalarField : - public fixedGradientFvPatchScalarField + public fixedGradientFvPatchScalarField, + public updateablePatchTypes::updateableSnGrad { // Private data diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressurePermeableAlphaInletOutletVelocity/pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/pressurePermeableAlphaInletOutletVelocity/pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.C new file mode 100644 index 0000000000000000000000000000000000000000..d3914c1e9fb0167c448f932c4a1e3a133b26870d --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressurePermeableAlphaInletOutletVelocity/pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.C @@ -0,0 +1,226 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField:: +pressurePermeableAlphaInletOutletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF +) +: + mixedFvPatchVectorField(p, iF), + phiName_("phi"), + rhoName_("rho"), + alphaName_("none"), + alphaMin_(1.0) +{ + refValue() = Zero; + refGrad() = Zero; + valueFraction() = 1.0; +} + + +Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField:: +pressurePermeableAlphaInletOutletVelocityFvPatchVectorField +( + const pressurePermeableAlphaInletOutletVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchVectorField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), + alphaName_(ptf.alphaName_), + alphaMin_(ptf.alphaMin_) +{} + + +Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField:: +pressurePermeableAlphaInletOutletVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchVectorField(p, iF), + phiName_(dict.getOrDefault<word>("phi", "phi")), + rhoName_(dict.getOrDefault<word>("rho", "rho")), + alphaName_(dict.getOrDefault<word>("alpha", "none")), + alphaMin_(dict.getOrDefault<scalar>("alphaMin", 1)) +{ + patchType() = dict.getOrDefault<word>("patchType", word::null); + fvPatchVectorField::operator=(vectorField("value", dict, p.size())); + refValue() = Zero; + refGrad() = Zero; + valueFraction() = 1.0; +} + + +Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField:: +pressurePermeableAlphaInletOutletVelocityFvPatchVectorField +( + const pressurePermeableAlphaInletOutletVelocityFvPatchVectorField& pivpvf +) +: + mixedFvPatchVectorField(pivpvf), + phiName_(pivpvf.phiName_), + rhoName_(pivpvf.rhoName_), + alphaName_(pivpvf.alphaName_), + alphaMin_(pivpvf.alphaMin_) +{} + + +Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField:: +pressurePermeableAlphaInletOutletVelocityFvPatchVectorField +( + const pressurePermeableAlphaInletOutletVelocityFvPatchVectorField& pivpvf, + const DimensionedField<vector, volMesh>& iF +) +: + mixedFvPatchVectorField(pivpvf, iF), + phiName_(pivpvf.phiName_), + rhoName_(pivpvf.rhoName_), + alphaName_(pivpvf.alphaName_), + alphaMin_(pivpvf.alphaMin_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +void Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField:: +updateCoeffs() +{ + if (updated()) + { + return; + } + + const auto& phi = db().lookupObject<surfaceScalarField>(phiName_); + + const fvsPatchField<scalar>& phip = + patch().patchField<surfaceScalarField, scalar>(phi); + + const vectorField n(patch().nf()); + + if (phi.dimensions() == dimVelocity*dimArea) + { + refValue() = (phip/patch().magSf())*n; + } + else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField<scalar>& rhop = + patch().lookupPatchField<volScalarField, scalar>(rhoName_); + + refValue() = (phip/(rhop*patch().magSf()))*n; + } + else + { + FatalErrorInFunction + << "dimensions of phi are not correct" + << "\n on patch " << this->patch().name() + << " of field " << this->internalField().name() + << " in file " << this->internalField().objectPath() + << exit(FatalError); + } + + valueFraction() = 1.0 - pos0(phip); + + if (alphaName_ != "none") + { + const scalarField& alphap = + patch().lookupPatchField<volScalarField, scalar>(alphaName_); + + const scalarField alphaCut(pos(alphap - alphaMin_)); + valueFraction() = max(alphaCut, valueFraction()); + forAll (*this, faceI) + { + if (valueFraction()[faceI] == 1.0) + { + refValue()[faceI] = Zero; + } + } + } + + mixedFvPatchVectorField::updateCoeffs(); +} + + +void Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField::write +( + Ostream& os +) const +{ + mixedFvPatchVectorField::write(os); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("alpha", "none", alphaName_); + os.writeEntryIfDifferent<scalar>("alphaMin", 1, alphaMin_); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField +::operator= +( + const fvPatchField<vector>& pvf +) +{ + tmp<vectorField> n = patch().nf(); + + fvPatchField<vector>::operator= + ( + valueFraction()*(n()*(n() & pvf)) + + (1 - valueFraction())*pvf + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + ); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/pressurePermeableAlphaInletOutletVelocity/pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/pressurePermeableAlphaInletOutletVelocity/pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.H new file mode 100644 index 0000000000000000000000000000000000000000..f087b5cae5b057956c590dd729f801191b415cff --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/pressurePermeableAlphaInletOutletVelocity/pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.H @@ -0,0 +1,255 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + +Group + grpInletBoundaryConditions grpOutletBoundaryConditions + +Description + The \c pressurePermeableAlphaInletOutletVelocity is a velocity inlet-outlet + boundary condition which can be applied to velocity boundaries for + multiphase flows when the pressure boundary condition is specified. + + In the \c pressurePermeableAlphaInletOutletVelocity, an open condition is + applied when \c alpha is under a user-defined \c alphaMin value and a wall + condition is applied when \c alpha is larger than the \c alphaMin. + + This boundary condition can be used in conjunction with + \c prghPermeableAlphaTotalPressure for the \c p_rgh variable. + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + // Mandatory entries + type pressurePermeableAlphaInletOutletVelocity; + + // Optional entries + phi phi; + rho rho; + alpha alpha.water; + alphaMin 0.01; + + // Inherited entries + value uniform (0 0 0); + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Deflt + phi | Name of flux field | word | no | phi + rho | Name of density field | word | no | rho + alpha | Name of mixture field | word | no | none + alphaMin | Minimum alpha | scalar | no | 1 + \endtable + + The inherited entries are elaborated in: + - \link mixedFvPatchFields.H \endlink + +See also + - Foam::prghPermeableAlphaTotalPressureFvPatchScalarField + - Foam::mixedFvPatchVectorField + +SourceFiles + pressurePermeableAlphaInletOutletVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef pressurePermeableAlphaInletOutletVelocityFvPatchVectorField_H +#define pressurePermeableAlphaInletOutletVelocityFvPatchVectorField_H + +#include "fvPatchFields.H" +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ +Class pressurePermeableAlphaInletOutletVelocityFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class pressurePermeableAlphaInletOutletVelocityFvPatchVectorField +: + public mixedFvPatchVectorField +{ + // Private Data + + //- Name of flux field + word phiName_; + + //- Name of density field + word rhoName_; + + //- Name of the mixture VOF field (if used) + word alphaName_; + + //- Minimum alpha value to outlet blockage + scalar alphaMin_; + + +public: + + //- Runtime type information + TypeName("permeableAlphaPressureInletOutletVelocity"); + + + // Constructors + + //- Construct from patch and internal field + pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + //- pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + //- onto a new patch + pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + ( + const pressurePermeableAlphaInletOutletVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + ( + const pressurePermeableAlphaInletOutletVelocityFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchVectorField> clone() const + { + return tmp<fvPatchVectorField> + ( + new pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + ( + const pressurePermeableAlphaInletOutletVelocityFvPatchVectorField&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchVectorField> clone + ( + const DimensionedField<vector, volMesh>& iF + ) const + { + return tmp<fvPatchVectorField> + ( + new pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + ( + *this, + iF + ) + ); + } + + + // Member Functions + + // Attributes + + //- Return true: this patch field is altered by assignment + virtual bool assignable() const + { + return true; + } + + + // Access + + //- Return the name of rho + const word& rhoName() const noexcept + { + return rhoName_; + } + + //- Return reference to the name of rho to allow adjustment + word& rhoName() + { + return rhoName_; + } + + //- Return the name of phi + const word& phiName() const noexcept + { + return phiName_; + } + + //- Return reference to the name of phi to allow adjustment + word& phiName() + { + return phiName_; + } + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; + + + // Member Operators + + //- Copy assignment + virtual void operator=(const fvPatchField<vector>& pvf); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/prghPermeableAlphaTotalPressure/prghPermeableAlphaTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/prghPermeableAlphaTotalPressure/prghPermeableAlphaTotalPressureFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..1141e88bcdfe22a5fbd9c7538e59bc2ae56d385f --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/prghPermeableAlphaTotalPressure/prghPermeableAlphaTotalPressureFvPatchScalarField.C @@ -0,0 +1,299 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "prghPermeableAlphaTotalPressureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "gravityMeshObject.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::prghPermeableAlphaTotalPressureFvPatchScalarField:: +prghPermeableAlphaTotalPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchField<scalar>(p, iF), + p0_(nullptr), + phiName_("phi"), + rhoName_("rho"), + UName_("U"), + alphaName_("none"), + alphaMin_(1.0), + curTimeIndex_(-1) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 0.0; +} + + +Foam::prghPermeableAlphaTotalPressureFvPatchScalarField:: +prghPermeableAlphaTotalPressureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchField<scalar>(p, iF), + p0_(PatchFunction1<scalar>::New(p.patch(), "p", dict)), + phiName_(dict.getOrDefault<word>("phi", "phi")), + rhoName_(dict.getOrDefault<word>("rho", "rho")), + UName_(dict.getOrDefault<word>("U", "U")), + alphaName_(dict.getOrDefault<word>("alpha", "none")), + alphaMin_(dict.getOrDefault<scalar>("alphaMin", 1)), + curTimeIndex_(-1) +{ + refValue() = 1.0; + refGrad() = 0.0; + valueFraction() = 0.0; + + if (dict.found("value")) + { + fvPatchField<scalar>::operator= + ( + Field<scalar>("value", dict, p.size()) + ); + } + else + { + fvPatchField<scalar>::operator=(refValue()); + } +} + + +Foam::prghPermeableAlphaTotalPressureFvPatchScalarField:: +prghPermeableAlphaTotalPressureFvPatchScalarField +( + const prghPermeableAlphaTotalPressureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchField<scalar>(ptf, p, iF, mapper), + p0_(ptf.p0_.clone(p.patch())), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), + UName_(ptf.UName_), + alphaName_(ptf.alphaName_), + alphaMin_(ptf.alphaMin_), + curTimeIndex_(-1) +{} + + +Foam::prghPermeableAlphaTotalPressureFvPatchScalarField:: +prghPermeableAlphaTotalPressureFvPatchScalarField +( + const prghPermeableAlphaTotalPressureFvPatchScalarField& tppsf +) +: + mixedFvPatchField<scalar>(tppsf), + p0_(tppsf.p0_.clone(this->patch().patch())), + phiName_(tppsf.phiName_), + rhoName_(tppsf.rhoName_), + UName_(tppsf.UName_), + alphaName_(tppsf.alphaName_), + alphaMin_(tppsf.alphaMin_), + curTimeIndex_(-1) +{} + + +Foam::prghPermeableAlphaTotalPressureFvPatchScalarField:: +prghPermeableAlphaTotalPressureFvPatchScalarField +( + const prghPermeableAlphaTotalPressureFvPatchScalarField& tppsf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchField<scalar>(tppsf, iF), + p0_(tppsf.p0_.clone(this->patch().patch())), + phiName_(tppsf.phiName_), + rhoName_(tppsf.rhoName_), + UName_(tppsf.UName_), + alphaName_(tppsf.alphaName_), + alphaMin_(tppsf.alphaMin_), + curTimeIndex_(-1) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::prghPermeableAlphaTotalPressureFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + mixedFvPatchField<scalar>::autoMap(m); + + if (p0_) + { + p0_->autoMap(m); + } +} + + +void Foam::prghPermeableAlphaTotalPressureFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + mixedFvPatchField<scalar>::rmap(ptf, addr); + + const auto& tptf = + refCast<const prghPermeableAlphaTotalPressureFvPatchScalarField>(ptf); + + if (p0_) + { + p0_->rmap(tptf.p0_(), addr); + } +} + + +void Foam::prghPermeableAlphaTotalPressureFvPatchScalarField::updateSnGrad +( + const scalarField& snGradp +) +{ + if (updated()) + { + return; + } + + const scalarField& rhop = + patch().lookupPatchField<volScalarField, scalar>(rhoName_); + + const scalarField& phip = + patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); + + const vectorField& Up = + patch().lookupPatchField<volVectorField, vector>(UName_); + + const uniformDimensionedVectorField& g = + meshObjects::gravity::New(db().time()); + + const auto& hRef = + db().lookupObject<uniformDimensionedScalarField>("hRef"); + + const dimensionedScalar ghRef + ( + mag(g.value()) > SMALL + ? g & (cmptMag(g.value())/mag(g.value()))*hRef + : dimensionedScalar(g.dimensions()*dimLength, 0) + ); + + const scalar t = db().time().timeOutputValue(); + + tmp<scalarField> p + ( + p0_->value(t) + - 0.5*rhop*(1.0 - pos0(phip))*magSqr(Up) + - rhop*((g.value() & patch().Cf()) - ghRef.value()) + ); + + refValue() = p; + + refGrad() = snGradp; + + if (alphaName_ != "none") + { + const scalarField& alphap = + patch().lookupPatchField<volScalarField, scalar>(alphaName_); + tmp<scalarField> alphaCut(pos(alphap - alphaMin_)); + valueFraction() = 1 - alphaCut; + } + + if (debug) + { + const scalar phi = gSum(-phip); + Info<< valueFraction() << endl; + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->internalField().name() << " :" + << " mass flux[Kg/s]:" << phi + << endl; + } + + curTimeIndex_ = this->db().time().timeIndex(); + + mixedFvPatchField<scalar>::updateCoeffs(); +} + + +void Foam::prghPermeableAlphaTotalPressureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + if (curTimeIndex_ != this->db().time().timeIndex()) + { + FatalErrorInFunction + << "updateCoeffs(const scalarField& snGradp) MUST be called before" + " updateCoeffs() or evaluate() to set the boundary gradient." + << exit(FatalError); + } +} + + +void Foam::prghPermeableAlphaTotalPressureFvPatchScalarField::write +( + Ostream& os +) const +{ + mixedFvPatchField<scalar>::write(os); + os.writeEntryIfDifferent<word>("phi", "phi", phiName_); + os.writeEntryIfDifferent<word>("rho", "rho", rhoName_); + os.writeEntryIfDifferent<word>("U", "U", UName_); + os.writeEntryIfDifferent<word>("alpha", "none", alphaName_); + os.writeEntryIfDifferent<scalar>("alphaMin", 1, alphaMin_); + + if (p0_) + { + p0_->writeData(os); + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + prghPermeableAlphaTotalPressureFvPatchScalarField + ); + +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/prghPermeableAlphaTotalPressure/prghPermeableAlphaTotalPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/prghPermeableAlphaTotalPressure/prghPermeableAlphaTotalPressureFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..ca4f952cebfaef4b7a9d94baa992251faf19bc51 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/prghPermeableAlphaTotalPressure/prghPermeableAlphaTotalPressureFvPatchScalarField.H @@ -0,0 +1,254 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 <http://www.gnu.org/licenses/>. + +Class + Foam::prghPermeableAlphaTotalPressureFvPatchScalarField + +Description + The \c prghPermeableAlphaTotalPressure is a mixed boundary condition + for the \c p_rgh variable in multiphase flows. + + It switches between an open boundary using the \c prghTotalPressure + boundary condition and a wall condition using the \c fixedFluxPressure + boundary condition. + + In the \c prghPermeableAlphaTotalPressure, an open condition is + applied when \c alpha is under a user-defined \c alphaMin value and a wall + condition is applied when \c alpha is larger than the \c alphaMin. + + This boundary condition can be used in conjunction with + \c pressurePermeableAlphaInletOutletVelocity for the \c U variable. + +Usage + Example of the boundary condition specification: + \verbatim + <patchName> + { + // Mandatory entries + type prghPermeableAlphaTotalPressure; + p uniform 0; + + // Optional entries + phi phi; + rho rho; + U U; + alphaName alpha.water; + alphaMin 0.01; + + // Inherited entries + value uniform 0; + ... + } + \endverbatim + + where the entries mean: + \table + Property | Description | Type | Reqd | Deflt + p | Total pressure | PatchFunction1\<scalar\> | yes | - + phi | Name of flux field | word | no | phi + rho | Name of density field | word | no | rho + U | Name of velocity field | word | no | U + alpha | Name of mixture field | word | no | none + alphaMin | Minimum alpha | scalar | no | 1 + \endtable + + The inherited entries are elaborated in: + - \link mixedFvPatchFields.H \endlink + - \link PatchFunction1.H \endlink + +See also + - Foam::pressurePermeableAlphaInletOutletVelocityFvPatchVectorField + - Foam::mixedFvPatchVectorField + - Foam::prghTotalPressureFvPatchScalarField + +SourceFiles + prghPermeableAlphaTotalPressureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef prghPermeableAlphaTotalPressureFvPatchScalarField_H +#define prghPermeableAlphaTotalPressureFvPatchScalarField_H + +#include "mixedFvPatchField.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "updateableSnGrad.H" +#include "PatchFunction1.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class prghPermeableAlphaTotalPressureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class prghPermeableAlphaTotalPressureFvPatchScalarField +: + public mixedFvPatchField<scalar>, + public updateablePatchTypes::updateableSnGrad +{ + // Private Data + + //- Total pressure field + autoPtr<PatchFunction1<scalar>> p0_; + + //- Name of the flux transporting the field + word phiName_; + + //- Name of the density field used to normalise the mass flux + word rhoName_; + + //- Name of the velocity field + word UName_; + + //- Name of the mixture VOF field (if used) + word alphaName_; + + //- Minimum alpha value to outlet blockage + scalar alphaMin_; + + //- Current time index (used for updating) + label curTimeIndex_; + + +public: + + //- Runtime type information + TypeName("prghPermeableAlphaTotalPressure"); + + + // Constructors + + //- Construct from patch and internal field + prghPermeableAlphaTotalPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + prghPermeableAlphaTotalPressureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + //- prghPermeableAlphaTotalPressureFvPatchScalarField + //- onto a new patch + prghPermeableAlphaTotalPressureFvPatchScalarField + ( + const prghPermeableAlphaTotalPressureFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + prghPermeableAlphaTotalPressureFvPatchScalarField + ( + const prghPermeableAlphaTotalPressureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<scalar>> clone() const + { + return tmp<fvPatchField<scalar>> + ( + new + prghPermeableAlphaTotalPressureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + prghPermeableAlphaTotalPressureFvPatchScalarField + ( + const prghPermeableAlphaTotalPressureFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<scalar>> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchField<scalar>> + ( + new + prghPermeableAlphaTotalPressureFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member Functions + + // Mapping + + //- 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& + ); + + + // Evaluation + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Update the patch pressure gradient field from the given snGradp + virtual void updateSnGrad(const scalarField& snGradp); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/U b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/U new file mode 100644 index 0000000000000000000000000000000000000000..7febd45f3b90602badfaaea3398b5a845a61cd52 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/U @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + leftWall + { + type noSlip; + } + + rightWall + { + type permeableAlphaPressureInletOutletVelocity; + alpha alpha.water; + alphaMin 0.01; + value uniform (0 0 0); + } + + lowerWall + { + type noSlip; + } + + atmosphere + { + type pressureInletOutletVelocity; + value uniform (0 0 0); + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/alpha.water b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/alpha.water new file mode 100644 index 0000000000000000000000000000000000000000..721ca601150436bf5071551166f213f396fbff5d --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/alpha.water @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type zeroGradient; + } + + rightWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + atmosphere + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/epsilon b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/epsilon new file mode 100644 index 0000000000000000000000000000000000000000..1ba6569c5997bdc3497fcf5bf8a96241006e3b3b --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/epsilon @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + leftWall + { + type epsilonWallFunction; + value uniform 0.1; + } + + rightWall + { + type epsilonWallFunction; + value uniform 0.1; + } + + lowerWall + { + type epsilonWallFunction; + value uniform 0.1; + } + + atmosphere + { + type inletOutlet; + inletValue uniform 0.1; + value uniform 0.1; + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/k b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/k new file mode 100644 index 0000000000000000000000000000000000000000..7d0e56de178fa44a2a3848914557b8ae0fcb687d --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/k @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + leftWall + { + type kqRWallFunction; + value uniform 0.1; + } + + rightWall + { + type kqRWallFunction; + value uniform 0.1; + } + + lowerWall + { + type kqRWallFunction; + value uniform 0.1; + } + + atmosphere + { + type inletOutlet; + inletValue uniform 0.1; + value uniform 0.1; + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/nut b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/nut new file mode 100644 index 0000000000000000000000000000000000000000..8bd8fdd6a568db58bc27e62ffa611cdb5d3c3701 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/nut @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type nutkWallFunction; + value uniform 0; + } + + rightWall + { + type nutkWallFunction; + value uniform 0; + } + + lowerWall + { + type nutkWallFunction; + value uniform 0; + } + + atmosphere + { + type calculated; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/p_rgh b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..96a5b6c493d480d57986f75349cbf3289c1ce75d --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/0.orig/p_rgh @@ -0,0 +1,57 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type fixedFluxPressure; + value uniform 0; + } + + rightWall + { + type prghPermeableAlphaTotalPressure; + alpha alpha.water; + alphaMin 0.01; + p uniform 0; + value uniform 0; + } + + lowerWall + { + type fixedFluxPressure; + value uniform 0; + } + + atmosphere + { + type totalPressure; + p0 uniform 0; + } + + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/Allclean b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..fb1f3847301c377e02e12439ba58cbf303af3ef9 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/Allclean @@ -0,0 +1,8 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions +#------------------------------------------------------------------------------ + +cleanCase0 + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/Allrun b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..e26a2e10417309a7f9e5a812f9e3e50ca722fe18 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/Allrun @@ -0,0 +1,18 @@ +#!/bin/sh +cd "${0%/*}" || exit # Run from this directory +. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions +#------------------------------------------------------------------------------ + +restore0Dir + +runApplication blockMesh + +runApplication setFields + +runApplication decomposePar + +runParallel $(getApplication) + +runParallel redistributePar -reconstruct -overwrite + +#------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/g b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..28b07d0b8775454e4fb6f1314f165492290a396a --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/transportProperties b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..15c0d5bd12c02dda59fffc7e9b1d915b8abcbc5a --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/transportProperties @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1e-06; + rho 1000; +} + +air +{ + transportModel Newtonian; + nu 1.48e-05; + rho 1; +} + +sigma 0.07; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/turbulenceProperties b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..f113b8d4078c0a15fba49dd6fbb3965f470968e0 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/constant/turbulenceProperties @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RAS; + +density variable; + +RAS +{ + RASModel kEpsilon; + + turbulence on; + + printCoeffs on; +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/blockMeshDict b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..867860524d7db076ba20d4e5a2610eebcfe5f448 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/blockMeshDict @@ -0,0 +1,109 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 0.146; + +vertices +( + (0 0 0) + (2 0 0) + (2.16438 0 0) + (4 0 0) + (0 0.32876 0) + (2 0.32876 0) + (2.16438 0.32876 0) + (4 0.32876 0) + (0 4 0) + (2 4 0) + (2.16438 4 0) + (4 4 0) + (0 0 0.1) + (2 0 0.1) + (2.16438 0 0.1) + (4 0 0.1) + (0 0.32876 0.1) + (2 0.32876 0.1) + (2.16438 0.32876 0.1) + (4 0.32876 0.1) + (0 4 0.1) + (2 4 0.1) + (2.16438 4 0.1) + (4 4 0.1) +); + +blocks +( + hex (0 1 5 4 12 13 17 16) (23 8 1) simpleGrading (1 1 1) + hex (2 3 7 6 14 15 19 18) (19 8 1) simpleGrading (1 1 1) + hex (4 5 9 8 16 17 21 20) (23 42 1) simpleGrading (1 1 1) + hex (5 6 10 9 17 18 22 21) (4 42 1) simpleGrading (1 1 1) + hex (6 7 11 10 18 19 23 22) (19 42 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + leftWall + { + type wall; + faces + ( + (0 12 16 4) + (4 16 20 8) + ); + } + rightWall + { + type wall; + faces + ( + (7 19 15 3) + (11 23 19 7) + ); + } + lowerWall + { + type wall; + faces + ( + (0 1 13 12) + (1 5 17 13) + (5 6 18 17) + (2 14 18 6) + (2 3 15 14) + ); + } + atmosphere + { + type patch; + faces + ( + (8 20 21 9) + (9 21 22 10) + (10 22 23 11) + ); + } +); + +mergePatchPairs +( +); + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/controlDict b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..472dac9be27176cf085a8e04945ac5b4be709dcb --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/controlDict @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application interFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 1; + +deltaT 0.001; + +writeControl adjustable; + +writeInterval 0.05; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep on; + +maxCo 1; + +maxAlphaCo 1; + +maxDeltaT 1; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/decomposeParDict b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..d96083400d61168c382b569cc2bc91911727531b --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/decomposeParDict @@ -0,0 +1,27 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +method simple; + +coeffs +{ + n (2 2 1); +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/fvSchemes b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..69508dc40446828a434ae7a7c5f59633eb9a85c5 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/fvSchemes @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss linear; + div(rhoPhi,k) Gauss upwind; + div(rhoPhi,epsilon) Gauss upwind; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/fvSolution b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..98dda729681a9b5d60e686dc05338c9cd7a40e6e --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/fvSolution @@ -0,0 +1,83 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 2; + nAlphaSubCycles 1; + cAlpha 1; + + MULESCorr yes; + nLimiterIter 3; + + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-5; + relTol 0; + } + + p_rgh + { + solver PCG; + preconditioner DIC; + tolerance 1e-07; + relTol 0.05; + } + + p_rghFinal + { + $p_rgh; + relTol 0; + } + + "(U|k|epsilon).*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-06; + relTol 0; + minIter 1; + } +} + +PIMPLE +{ + momentumPredictor no; + nOuterCorrectors 1; + nCorrectors 3; + nNonOrthogonalCorrectors 0; +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/setFieldsDict b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/setFieldsDict new file mode 100644 index 0000000000000000000000000000000000000000..bb00ea228479519fa0a210160a278074a996f21f --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/damBreakPermeable/system/setFieldsDict @@ -0,0 +1,35 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2012 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha.water 0 +); + +regions +( + boxToCell + { + box (0 0 -1) (0.2461 0.292 1); + fieldValues + ( + volScalarFieldValue alpha.water 1 + ); + } +); + + +// ************************************************************************* //