Commit 3f7c0577 authored by Sergio Ferraris's avatar Sergio Ferraris Committed by Kutalmış Berçin
Browse files

ENH: Adding new permeable boundary conditions

- prghPermeableAlphaTotalPressure for p_rgh
- pressurePermeableAlphaInletOutletVelocity for U
- new helper class for pressure-related BCs: updateableSnGrad
parent 371619bc
......@@ -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
......
......@@ -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]
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //
......@@ -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
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
);
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
(