ENH: Updated porosity models

This commit is contained in:
andy
2013-05-08 17:17:51 +01:00
parent 98a1262035
commit d8b925175b
11 changed files with 204 additions and 42 deletions

View File

@ -52,8 +52,8 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer
) )
: :
porosityModel(name, modelType, mesh, dict, cellZoneName), porosityModel(name, modelType, mesh, dict, cellZoneName),
D_(cellZoneIds_.size()), D_(cellZoneIDs_.size()),
F_(cellZoneIds_.size()), F_(cellZoneIDs_.size()),
rhoName_(coeffs_.lookupOrDefault<word>("rho", "rho")), rhoName_(coeffs_.lookupOrDefault<word>("rho", "rho")),
muName_(coeffs_.lookupOrDefault<word>("mu", "thermo:mu")), muName_(coeffs_.lookupOrDefault<word>("mu", "thermo:mu")),
nuName_(coeffs_.lookupOrDefault<word>("nu", "nu")) nuName_(coeffs_.lookupOrDefault<word>("nu", "nu"))
@ -67,7 +67,7 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer
if (coordSys_.R().uniform()) if (coordSys_.R().uniform())
{ {
forAll (cellZoneIds_, zoneI) forAll (cellZoneIDs_, zoneI)
{ {
D_[zoneI].setSize(1, tensor::zero); D_[zoneI].setSize(1, tensor::zero);
F_[zoneI].setSize(1, tensor::zero); F_[zoneI].setSize(1, tensor::zero);
@ -89,9 +89,9 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer
} }
else else
{ {
forAll(cellZoneIds_, zoneI) forAll(cellZoneIDs_, zoneI)
{ {
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
D_[zoneI].setSize(cells.size(), tensor::zero); D_[zoneI].setSize(cells.size(), tensor::zero);
F_[zoneI].setSize(cells.size(), tensor::zero); F_[zoneI].setSize(cells.size(), tensor::zero);
@ -122,6 +122,24 @@ Foam::porosityModels::DarcyForchheimer::~DarcyForchheimer()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModels::DarcyForchheimer::calcForce
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu,
vectorField& force
) const
{
scalarField Udiag(U.size());
vectorField Usource(U.size());
const scalarField& V = mesh_.V();
apply(Udiag, Usource, V, rho, mu, U);
force = Udiag*U - Usource;
}
void Foam::porosityModels::DarcyForchheimer::correct void Foam::porosityModels::DarcyForchheimer::correct
( (
fvVectorMatrix& UEqn fvVectorMatrix& UEqn
@ -194,10 +212,12 @@ void Foam::porosityModels::DarcyForchheimer::correct
} }
void Foam::porosityModels::DarcyForchheimer::writeData(Ostream& os) const bool Foam::porosityModels::DarcyForchheimer::writeData(Ostream& os) const
{ {
os << indent << name_ << endl; os << indent << name_ << endl;
dict_.write(os); dict_.write(os);
return true;
} }

View File

@ -143,6 +143,15 @@ public:
// Member Functions // Member Functions
//- Calculate the porosity force
virtual void calcForce
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu,
vectorField& force
) const;
//- Add resistance //- Add resistance
virtual void correct(fvVectorMatrix& UEqn) const; virtual void correct(fvVectorMatrix& UEqn) const;
@ -165,7 +174,7 @@ public:
// I-O // I-O
//- Write //- Write
void writeData(Ostream& os) const; bool writeData(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -36,12 +36,12 @@ void Foam::porosityModels::DarcyForchheimer::apply
const vectorField& U const vectorField& U
) const ) const
{ {
forAll(cellZoneIds_, zoneI) forAll(cellZoneIDs_, zoneI)
{ {
const tensorField& dZones = D_[zoneI]; const tensorField& dZones = D_[zoneI];
const tensorField& fZones = F_[zoneI]; const tensorField& fZones = F_[zoneI];
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
forAll(cells, i) forAll(cells, i)
{ {
@ -68,12 +68,12 @@ void Foam::porosityModels::DarcyForchheimer::apply
const vectorField& U const vectorField& U
) const ) const
{ {
forAll(cellZoneIds_, zoneI) forAll(cellZoneIDs_, zoneI)
{ {
const tensorField& dZones = D_[zoneI]; const tensorField& dZones = D_[zoneI];
const tensorField& fZones = F_[zoneI]; const tensorField& fZones = F_[zoneI];
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
forAll(cells, i) forAll(cells, i)
{ {

View File

@ -50,12 +50,12 @@ void Foam::porosityModels::fixedCoeff::apply
const scalar rho const scalar rho
) const ) const
{ {
forAll(cellZoneIds_, zoneI) forAll(cellZoneIDs_, zoneI)
{ {
const tensorField& alphaZones = alpha_[zoneI]; const tensorField& alphaZones = alpha_[zoneI];
const tensorField& betaZones = beta_[zoneI]; const tensorField& betaZones = beta_[zoneI];
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
forAll(cells, i) forAll(cells, i)
{ {
@ -79,12 +79,12 @@ void Foam::porosityModels::fixedCoeff::apply
) const ) const
{ {
forAll(cellZoneIds_, zoneI) forAll(cellZoneIDs_, zoneI)
{ {
const tensorField& alphaZones = alpha_[zoneI]; const tensorField& alphaZones = alpha_[zoneI];
const tensorField& betaZones = beta_[zoneI]; const tensorField& betaZones = beta_[zoneI];
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
forAll(cells, i) forAll(cells, i)
{ {
@ -111,8 +111,8 @@ Foam::porosityModels::fixedCoeff::fixedCoeff
) )
: :
porosityModel(name, modelType, mesh, dict, cellZoneName), porosityModel(name, modelType, mesh, dict, cellZoneName),
alpha_(cellZoneIds_.size()), alpha_(cellZoneIDs_.size()),
beta_(cellZoneIds_.size()) beta_(cellZoneIDs_.size())
{ {
dimensionedVector alpha(coeffs_.lookup("alpha")); dimensionedVector alpha(coeffs_.lookup("alpha"));
dimensionedVector beta(coeffs_.lookup("beta")); dimensionedVector beta(coeffs_.lookup("beta"));
@ -122,7 +122,7 @@ Foam::porosityModels::fixedCoeff::fixedCoeff
if (coordSys_.R().uniform()) if (coordSys_.R().uniform())
{ {
forAll (cellZoneIds_, zoneI) forAll (cellZoneIDs_, zoneI)
{ {
alpha_[zoneI].setSize(1, tensor::zero); alpha_[zoneI].setSize(1, tensor::zero);
beta_[zoneI].setSize(1, tensor::zero); beta_[zoneI].setSize(1, tensor::zero);
@ -140,9 +140,9 @@ Foam::porosityModels::fixedCoeff::fixedCoeff
} }
else else
{ {
forAll(cellZoneIds_, zoneI) forAll(cellZoneIDs_, zoneI)
{ {
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
alpha_[zoneI].setSize(cells.size(), tensor::zero); alpha_[zoneI].setSize(cells.size(), tensor::zero);
beta_[zoneI].setSize(cells.size(), tensor::zero); beta_[zoneI].setSize(cells.size(), tensor::zero);
@ -175,6 +175,25 @@ Foam::porosityModels::fixedCoeff::~fixedCoeff()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModels::fixedCoeff::calcForce
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu,
vectorField& force
) const
{
scalarField Udiag(U.size());
vectorField Usource(U.size());
const scalarField& V = mesh_.V();
scalar rhoRef = readScalar(coeffs_.lookup("rhoRef"));
apply(Udiag, Usource, V, U, rhoRef);
force = Udiag*U - Usource;
}
void Foam::porosityModels::fixedCoeff::correct void Foam::porosityModels::fixedCoeff::correct
( (
fvVectorMatrix& UEqn fvVectorMatrix& UEqn
@ -235,10 +254,12 @@ void Foam::porosityModels::fixedCoeff::correct
} }
void Foam::porosityModels::fixedCoeff::writeData(Ostream& os) const bool Foam::porosityModels::fixedCoeff::writeData(Ostream& os) const
{ {
os << indent << name_ << endl; os << indent << name_ << endl;
dict_.write(os); dict_.write(os);
return true;
} }

View File

@ -119,6 +119,15 @@ public:
// Member Functions // Member Functions
//- Calculate the porosity force
virtual void calcForce
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu,
vectorField& force
) const;
//- Add resistance //- Add resistance
virtual void correct(fvVectorMatrix& UEqn) const; virtual void correct(fvVectorMatrix& UEqn) const;
@ -141,7 +150,7 @@ public:
// I-O // I-O
//- Write //- Write
void writeData(Ostream& os) const; bool writeData(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -88,13 +88,14 @@ Foam::porosityModel::porosityModel
const word& cellZoneName const word& cellZoneName
) )
: :
MeshObject<fvMesh, Foam::UpdateableMeshObject, porosityModel>(mesh),
name_(name), name_(name),
mesh_(mesh), mesh_(mesh),
dict_(dict), dict_(dict),
coeffs_(dict.subDict(modelType + "Coeffs")), coeffs_(dict.subDict(modelType + "Coeffs")),
active_(true), active_(true),
zoneName_(cellZoneName), zoneName_(cellZoneName),
cellZoneIds_(), cellZoneIDs_(),
coordSys_(coordinateSystem::New(mesh, coeffs_)) coordSys_(coordinateSystem::New(mesh, coeffs_))
{ {
if (zoneName_ == word::null) if (zoneName_ == word::null)
@ -103,11 +104,11 @@ Foam::porosityModel::porosityModel
dict_.lookup("cellZone") >> zoneName_; dict_.lookup("cellZone") >> zoneName_;
} }
cellZoneIds_ = mesh_.cellZones().findIndices(zoneName_); cellZoneIDs_ = mesh_.cellZones().findIndices(zoneName_);
Info<< " creating porous zone: " << zoneName_ << endl; Info<< " creating porous zone: " << zoneName_ << endl;
bool foundZone = !cellZoneIds_.empty(); bool foundZone = !cellZoneIDs_.empty();
reduce(foundZone, orOp<bool>()); reduce(foundZone, orOp<bool>());
if (!foundZone && Pstream::master()) if (!foundZone && Pstream::master())
@ -136,12 +137,30 @@ Foam::porosityModel::~porosityModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::vectorField> Foam::porosityModel::porosityModel::force
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu
) const
{
tmp<vectorField> tforce(new vectorField(U.size(), vector::zero));
if (!cellZoneIDs_.empty())
{
this->calcForce(U, rho, mu, tforce());
}
return tforce;
}
void Foam::porosityModel::porosityModel::addResistance void Foam::porosityModel::porosityModel::addResistance
( (
fvVectorMatrix& UEqn fvVectorMatrix& UEqn
) const ) const
{ {
if (cellZoneIds_.empty()) if (cellZoneIDs_.empty())
{ {
return; return;
} }
@ -157,7 +176,7 @@ void Foam::porosityModel::porosityModel::addResistance
const volScalarField& mu const volScalarField& mu
) const ) const
{ {
if (cellZoneIds_.empty()) if (cellZoneIDs_.empty())
{ {
return; return;
} }
@ -173,7 +192,7 @@ void Foam::porosityModel::porosityModel::addResistance
bool correctAUprocBC bool correctAUprocBC
) const ) const
{ {
if (cellZoneIds_.empty()) if (cellZoneIDs_.empty())
{ {
return; return;
} }
@ -190,12 +209,30 @@ void Foam::porosityModel::porosityModel::addResistance
} }
bool Foam::porosityModel::porosityModel::movePoints()
{
// no updates necessary; all member data independent of mesh
return true;
}
void Foam::porosityModel::porosityModel::updateMesh(const mapPolyMesh& mpm)
{
// no updates necessary; all member data independent of mesh
}
bool Foam::porosityModel::writeData(Ostream& os) const
{
return true;
}
bool Foam::porosityModel::read(const dictionary& dict) bool Foam::porosityModel::read(const dictionary& dict)
{ {
active_ = readBool(dict.lookup("active")); active_ = readBool(dict.lookup("active"));
coeffs_ = dict.subDict(type() + "Coeffs"); coeffs_ = dict.subDict(type() + "Coeffs");
dict.lookup("cellZone") >> zoneName_; dict.lookup("cellZone") >> zoneName_;
cellZoneIds_ = mesh_.cellZones().findIndices(zoneName_); cellZoneIDs_ = mesh_.cellZones().findIndices(zoneName_);
return true; return true;
} }

View File

@ -36,6 +36,7 @@ SourceFiles
#ifndef porosityModel_H #ifndef porosityModel_H
#define porosityModel_H #define porosityModel_H
#include "MeshObject.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "dictionary.H" #include "dictionary.H"
#include "fvMatricesFwd.H" #include "fvMatricesFwd.H"
@ -54,6 +55,8 @@ namespace Foam
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class porosityModel class porosityModel
:
public MeshObject<fvMesh, UpdateableMeshObject, porosityModel>
{ {
private: private:
@ -88,8 +91,8 @@ protected:
//- Name(s) of cell-zone //- Name(s) of cell-zone
keyType zoneName_; keyType zoneName_;
//- Cell zone Ids //- Cell zone IDs
labelList cellZoneIds_; labelList cellZoneIDs_;
//- Local co-ordinate system //- Local co-ordinate system
coordinateSystem coordSys_; coordinateSystem coordSys_;
@ -100,6 +103,15 @@ protected:
//- Adjust negative resistance values to be multiplier of max value //- Adjust negative resistance values to be multiplier of max value
void adjustNegativeResistance(dimensionedVector& resist); void adjustNegativeResistance(dimensionedVector& resist);
//- Calculate the porosity force
virtual void calcForce
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu,
vectorField& force
) const = 0;
virtual void correct(fvVectorMatrix& UEqn) const = 0; virtual void correct(fvVectorMatrix& UEqn) const = 0;
virtual void correct virtual void correct
@ -207,6 +219,17 @@ public:
//- Return const access to the porosity active flag //- Return const access to the porosity active flag
inline bool active() const; inline bool active() const;
//- Return const access to the cell zone IDs
inline const labelList& cellZoneIDs() const;
//- Return the force over the cell zone(s)
virtual tmp<vectorField> force
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu
) const;
//- Add resistance //- Add resistance
virtual void addResistance(fvVectorMatrix& UEqn) const; virtual void addResistance(fvVectorMatrix& UEqn) const;
@ -227,10 +250,19 @@ public:
) const; ) const;
// Topology change
//- Move points
virtual bool movePoints();
//- Update on meshUpdate
virtual void updateMesh(const mapPolyMesh& mpm);
// I-O // I-O
//- Write //- Write
virtual void writeData(Ostream& os) const = 0; virtual bool writeData(Ostream& os) const;
//- Read porosity dictionary //- Read porosity dictionary
virtual bool read(const dictionary& dict); virtual bool read(const dictionary& dict);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -35,4 +35,10 @@ inline bool Foam::porosityModel::active() const
} }
inline const Foam::labelList& Foam::porosityModel::cellZoneIDs() const
{
return cellZoneIDs_;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -66,6 +66,23 @@ Foam::porosityModels::powerLaw::~powerLaw()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModels::powerLaw::calcForce
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu,
vectorField& force
) const
{
scalarField Udiag(U.size());
const scalarField& V = mesh_.V();
apply(Udiag, V, rho, U);
force = Udiag*U;
}
void Foam::porosityModels::powerLaw::correct void Foam::porosityModels::powerLaw::correct
( (
fvVectorMatrix& UEqn fvVectorMatrix& UEqn
@ -126,10 +143,12 @@ void Foam::porosityModels::powerLaw::correct
} }
void Foam::porosityModels::powerLaw::writeData(Ostream& os) const bool Foam::porosityModels::powerLaw::writeData(Ostream& os) const
{ {
os << indent << name_ << endl; os << indent << name_ << endl;
dict_.write(os); dict_.write(os);
return true;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -127,6 +127,15 @@ public:
// Member Functions // Member Functions
//- Calculate the porosity force
virtual void calcForce
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu,
vectorField& force
) const;
//- Add resistance //- Add resistance
virtual void correct(fvVectorMatrix& UEqn) const; virtual void correct(fvVectorMatrix& UEqn) const;
@ -149,7 +158,7 @@ public:
// I-O // I-O
//- Write //- Write
void writeData(Ostream& os) const; bool writeData(Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,9 +37,9 @@ void Foam::porosityModels::powerLaw::apply
const scalar C0 = C0_; const scalar C0 = C0_;
const scalar C1m1b2 = (C1_ - 1.0)/2.0; const scalar C1m1b2 = (C1_ - 1.0)/2.0;
forAll(cellZoneIds_, zoneI) forAll(cellZoneIDs_, zoneI)
{ {
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
forAll(cells, i) forAll(cells, i)
{ {
@ -63,9 +63,9 @@ void Foam::porosityModels::powerLaw::apply
const scalar C0 = C0_; const scalar C0 = C0_;
const scalar C1m1b2 = (C1_ - 1.0)/2.0; const scalar C1m1b2 = (C1_ - 1.0)/2.0;
forAll(cellZoneIds_, zoneI) forAll(cellZoneIDs_, zoneI)
{ {
const labelList& cells = mesh_.cellZones()[cellZoneIds_[zoneI]]; const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zoneI]];
forAll(cells, i) forAll(cells, i)
{ {