mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added new pressureDrop porosity model
This commit is contained in:
@ -381,8 +381,9 @@ $(porosity)/porosityModel/porosityModelNew.C
|
||||
$(porosity)/porosityModel/porosityModelList.C
|
||||
$(porosity)/porosityModel/IOporosityModelList.C
|
||||
$(porosity)/DarcyForchheimer/DarcyForchheimer.C
|
||||
$(porosity)/powerLaw/powerLaw.C
|
||||
$(porosity)/fixedCoeff/fixedCoeff.C
|
||||
$(porosity)/powerLaw/powerLaw.C
|
||||
$(porosity)/pressureDrop/pressureDrop.C
|
||||
|
||||
MRF = $(general)/MRF
|
||||
$(MRF)/MRFZone.C
|
||||
|
||||
@ -0,0 +1,144 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "pressureDrop.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "geometricOneField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace porosityModels
|
||||
{
|
||||
defineTypeNameAndDebug(pressureDrop, 0);
|
||||
addToRunTimeSelectionTable(porosityModel, pressureDrop, mesh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::porosityModels::pressureDrop::pressureDrop
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const fvMesh& mesh,
|
||||
const dictionary& dict,
|
||||
const word& cellZoneName
|
||||
)
|
||||
:
|
||||
porosityModel(name, modelType, mesh, dict, cellZoneName),
|
||||
coordSys_(coeffs_, mesh),
|
||||
mDotvsDp_(DataEntry<scalar>::New("mDotvsDp", coeffs_)),
|
||||
lRef_(readScalar(coeffs_.lookup("lRef"))),
|
||||
rhoName_(coeffs_.lookupOrDefault<word>("rho", "rho"))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::porosityModels::pressureDrop::~pressureDrop()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::porosityModels::pressureDrop::correct
|
||||
(
|
||||
fvVectorMatrix& UEqn
|
||||
) const
|
||||
{
|
||||
const vectorField& U = UEqn.psi();
|
||||
const scalarField& V = mesh_.V();
|
||||
scalarField& Udiag = UEqn.diag();
|
||||
vectorField& Usource = UEqn.source();
|
||||
|
||||
scalar rhoScale = 1.0;
|
||||
if (UEqn.dimensions() == dimForce)
|
||||
{
|
||||
const volScalarField& rho =
|
||||
mesh_.lookupObject<volScalarField>(rhoName_);
|
||||
|
||||
apply(Udiag, Usource, V, rho, U, rhoScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
coeffs_.lookup("rhoRef") >> rhoScale;
|
||||
apply(Udiag, Usource, V, geometricOneField(), U, rhoScale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Foam::porosityModels::pressureDrop::correct
|
||||
(
|
||||
fvVectorMatrix& UEqn,
|
||||
const volScalarField& rho,
|
||||
const volScalarField&
|
||||
) const
|
||||
{
|
||||
const vectorField& U = UEqn.psi();
|
||||
const scalarField& V = mesh_.V();
|
||||
scalarField& Udiag = UEqn.diag();
|
||||
vectorField& Usource = UEqn.source();
|
||||
|
||||
apply(Udiag, Usource, V, rho, U, 1.0);
|
||||
}
|
||||
|
||||
|
||||
void Foam::porosityModels::pressureDrop::correct
|
||||
(
|
||||
const fvVectorMatrix& UEqn,
|
||||
volTensorField& AU
|
||||
) const
|
||||
{
|
||||
const vectorField& U = UEqn.psi();
|
||||
|
||||
scalar rhoScale = 1.0;
|
||||
if (UEqn.dimensions() == dimForce)
|
||||
{
|
||||
const volScalarField& rho =
|
||||
mesh_.lookupObject<volScalarField>(rhoName_);
|
||||
|
||||
apply(AU, rho, U, rhoScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
coeffs_.lookup("rhoRef") >> rhoScale;
|
||||
apply(AU, geometricOneField(), U, rhoScale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::porosityModels::pressureDrop::writeData(Ostream& os) const
|
||||
{
|
||||
os << indent << name_ << endl;
|
||||
dict_.write(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,206 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::pressureDrop
|
||||
|
||||
Description
|
||||
Pressure drop porosity model, whereby the user speciefies the pressure
|
||||
drop per unit length as a function of mass flow rate, over a fixed distance.
|
||||
|
||||
Example usage:
|
||||
\verbatim
|
||||
pressureDropCoeffs
|
||||
{
|
||||
coordinateSystem
|
||||
{
|
||||
e1 (1 0 0);
|
||||
e2 (0 1 0);
|
||||
}
|
||||
|
||||
lRef 0.5;
|
||||
|
||||
mDotvsDp table
|
||||
(
|
||||
(0 0)
|
||||
(0.2 20)
|
||||
(0.4 40)
|
||||
(0.6 65)
|
||||
(0.8 95)
|
||||
(1.0 125)
|
||||
(1.5 220)
|
||||
(2.0 320)
|
||||
(2.5 435)
|
||||
(3.0 560)
|
||||
(3.5 700)
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The mDotvsDp entry is a DataEntry type, able to describe the pressure drop
|
||||
per unit length as a function mass flow rate. The example above gives the
|
||||
usage for supplying in-line tabulated data.
|
||||
|
||||
SeeAlso
|
||||
Foam::DataEntry
|
||||
|
||||
SourceFiles
|
||||
pressureDrop.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pressureDrop_H
|
||||
#define pressureDrop_H
|
||||
|
||||
#include "porosityModel.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "autoPtr.H"
|
||||
#include "DataEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace porosityModels
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pressureDrop Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pressureDrop
|
||||
:
|
||||
public porosityModel
|
||||
{
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Local co-ordinate system
|
||||
coordinateSystem coordSys_;
|
||||
|
||||
//- Pressure drop per unit length [Pa/m] as a function of
|
||||
// mass flow rate [kg/s]
|
||||
autoPtr<DataEntry<scalar> > mDotvsDp_;
|
||||
|
||||
//- Distance over which pressure drop is applied
|
||||
scalar lRef_;
|
||||
|
||||
//- Name of density field
|
||||
word rhoName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Apply
|
||||
template<class RhoFieldType>
|
||||
void apply
|
||||
(
|
||||
scalarField& Udiag,
|
||||
vectorField& Usource,
|
||||
const scalarField& V,
|
||||
const RhoFieldType& rho,
|
||||
const vectorField& U,
|
||||
const scalar rhoScale
|
||||
) const;
|
||||
|
||||
//- Apply
|
||||
template<class RhoFieldType>
|
||||
void apply
|
||||
(
|
||||
tensorField& AU,
|
||||
const RhoFieldType& rho,
|
||||
const vectorField& U,
|
||||
const scalar rhoScale
|
||||
) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pressureDrop(const pressureDrop&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const pressureDrop&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("pressureDrop");
|
||||
|
||||
//- Constructor
|
||||
pressureDrop
|
||||
(
|
||||
const word& name,
|
||||
const word& modelType,
|
||||
const fvMesh& mesh,
|
||||
const dictionary& dict,
|
||||
const word& cellZoneName
|
||||
);
|
||||
|
||||
//- Destructor
|
||||
virtual ~pressureDrop();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add resistance
|
||||
virtual void correct(fvVectorMatrix& UEqn) const;
|
||||
|
||||
//- Add resistance
|
||||
virtual void correct
|
||||
(
|
||||
fvVectorMatrix& UEqn,
|
||||
const volScalarField& rho,
|
||||
const volScalarField& mu
|
||||
) const;
|
||||
|
||||
//- Add resistance
|
||||
virtual void correct
|
||||
(
|
||||
const fvVectorMatrix& UEqn,
|
||||
volTensorField& AU
|
||||
) const;
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write
|
||||
void writeData(Ostream& os) const;
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace porosityModels
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "pressureDropTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,89 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class RhoFieldType>
|
||||
void Foam::porosityModels::pressureDrop::apply
|
||||
(
|
||||
scalarField& Udiag,
|
||||
vectorField& Usource,
|
||||
const scalarField& V,
|
||||
const RhoFieldType& rho,
|
||||
const vectorField& U,
|
||||
const scalar rhoScale
|
||||
) const
|
||||
{
|
||||
// local-to-global transformation tensor
|
||||
const tensor& E = coordSys_.R();
|
||||
|
||||
forAll(cellZoneIds_, zoneI)
|
||||
{
|
||||
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]];
|
||||
|
||||
forAll(cells, i)
|
||||
{
|
||||
const label cellI = cells[i];
|
||||
const scalar magU = mag(U[cellI]);
|
||||
const scalar mDot = rho[cellI]*magU;
|
||||
const scalar dp = mDotvsDp_->value(mDot);
|
||||
const tensor Cd = E*dp/(lRef_*magU*rhoScale + ROOTVSMALL);
|
||||
const scalar isoCd = tr(Cd);
|
||||
|
||||
Udiag[cellI] += V[cellI]*isoCd;
|
||||
Usource[cellI] -= V[cellI]*((Cd - I*isoCd) & U[cellI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class RhoFieldType>
|
||||
void Foam::porosityModels::pressureDrop::apply
|
||||
(
|
||||
tensorField& AU,
|
||||
const RhoFieldType& rho,
|
||||
const vectorField& U,
|
||||
const scalar rhoScale
|
||||
) const
|
||||
{
|
||||
// local-to-global transformation tensor
|
||||
const tensor& E = coordSys_.R();
|
||||
|
||||
forAll(cellZoneIds_, zoneI)
|
||||
{
|
||||
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]];
|
||||
|
||||
forAll(cells, i)
|
||||
{
|
||||
const label cellI = cells[i];
|
||||
const scalar magU = mag(U[cellI]);
|
||||
const scalar mDot = rho[cellI]*magU;
|
||||
const scalar dp = mDotvsDp_->value(mDot);
|
||||
|
||||
AU[cellI] += E*dp/(lRef_*magU*rhoScale + ROOTVSMALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user