ENH: porosity model updates for moving meshes

This commit is contained in:
andy 2014-04-08 12:32:59 +01:00 committed by Andrew Heather
parent 557e7ebda8
commit 1e157ad7b2
10 changed files with 134 additions and 100 deletions

View File

@ -52,19 +52,31 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer
)
:
porosityModel(name, modelType, mesh, dict, cellZoneName),
dXYZ_(coeffs_.lookup("d")),
fXYZ_(coeffs_.lookup("f")),
D_(cellZoneIDs_.size()),
F_(cellZoneIDs_.size()),
rhoName_(coeffs_.lookupOrDefault<word>("rho", "rho")),
muName_(coeffs_.lookupOrDefault<word>("mu", "thermo:mu")),
nuName_(coeffs_.lookupOrDefault<word>("nu", "nu"))
{
adjustNegativeResistance(dXYZ_);
adjustNegativeResistance(fXYZ_);
dimensionedVector d(coeffs_.lookup("d"));
dimensionedVector f(coeffs_.lookup("f"));
calcTranformModelData();
}
adjustNegativeResistance(d);
adjustNegativeResistance(f);
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::porosityModels::DarcyForchheimer::~DarcyForchheimer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModels::DarcyForchheimer::calcTranformModelData()
{
if (coordSys_.R().uniform())
{
forAll (cellZoneIDs_, zoneI)
@ -72,20 +84,19 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer
D_[zoneI].setSize(1, tensor::zero);
F_[zoneI].setSize(1, tensor::zero);
D_[zoneI][0].xx() = d.value().x();
D_[zoneI][0].yy() = d.value().y();
D_[zoneI][0].zz() = d.value().z();
D_[zoneI][0].xx() = dXYZ_.value().x();
D_[zoneI][0].yy() = dXYZ_.value().y();
D_[zoneI][0].zz() = dXYZ_.value().z();
D_[zoneI][0] = coordSys_.R().transformTensor(D_[zoneI][0]);
// leading 0.5 is from 1/2*rho
F_[zoneI][0].xx() = 0.5*f.value().x();
F_[zoneI][0].yy() = 0.5*f.value().y();
F_[zoneI][0].zz() = 0.5*f.value().z();
F_[zoneI][0].xx() = 0.5*fXYZ_.value().x();
F_[zoneI][0].yy() = 0.5*fXYZ_.value().y();
F_[zoneI][0].zz() = 0.5*fXYZ_.value().z();
F_[zoneI][0] = coordSys_.R().transformTensor(F_[zoneI][0]);
}
}
else
{
@ -98,14 +109,14 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer
forAll(cells, i)
{
D_[zoneI][i].xx() = d.value().x();
D_[zoneI][i].yy() = d.value().y();
D_[zoneI][i].zz() = d.value().z();
D_[zoneI][i].xx() = dXYZ_.value().x();
D_[zoneI][i].yy() = dXYZ_.value().y();
D_[zoneI][i].zz() = dXYZ_.value().z();
// leading 0.5 is from 1/2*rho
F_[zoneI][i].xx() = 0.5*f.value().x();
F_[zoneI][i].yy() = 0.5*f.value().y();
F_[zoneI][i].zz() = 0.5*f.value().z();
F_[zoneI][i].xx() = 0.5*fXYZ_.value().x();
F_[zoneI][i].yy() = 0.5*fXYZ_.value().y();
F_[zoneI][i].zz() = 0.5*fXYZ_.value().z();
}
D_[zoneI] = coordSys_.R().transformTensor(D_[zoneI], cells);
@ -115,14 +126,6 @@ Foam::porosityModels::DarcyForchheimer::DarcyForchheimer
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::porosityModels::DarcyForchheimer::~DarcyForchheimer()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModels::DarcyForchheimer::calcForce
(
const volVectorField& U,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,11 +74,16 @@ private:
// Private data
//- Darcy coeffient XYZ components (user-supplied) [1/m2]
dimensionedVector dXYZ_;
//- Darcy coefficient [1/m2]
//- Forchheimer coeffient XYZ components (user-supplied) [1/m]
dimensionedVector fXYZ_;
//- Darcy coefficient - converted from dXYZ [1/m2]
List<tensorField> D_;
//- Forchheimer coefficient [1/m]
//- Forchheimer coefficient - converted from fXYZ [1/m]
List<tensorField> F_;
//- Name of density field
@ -143,6 +148,9 @@ public:
// Member Functions
//- Transform the model data wrt mesh changes
virtual void calcTranformModelData();
//- Calculate the porosity force
virtual void calcForce
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -111,15 +111,28 @@ Foam::porosityModels::fixedCoeff::fixedCoeff
)
:
porosityModel(name, modelType, mesh, dict, cellZoneName),
alphaXYZ_(coeffs_.lookup("alpha")),
betaXYZ_(coeffs_.lookup("beta")),
alpha_(cellZoneIDs_.size()),
beta_(cellZoneIDs_.size())
{
dimensionedVector alpha(coeffs_.lookup("alpha"));
dimensionedVector beta(coeffs_.lookup("beta"));
adjustNegativeResistance(alphaXYZ_);
adjustNegativeResistance(betaXYZ_);
adjustNegativeResistance(alpha);
adjustNegativeResistance(beta);
calcTranformModelData();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::porosityModels::fixedCoeff::~fixedCoeff()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModels::fixedCoeff::calcTranformModelData()
{
if (coordSys_.R().uniform())
{
forAll (cellZoneIDs_, zoneI)
@ -127,14 +140,14 @@ Foam::porosityModels::fixedCoeff::fixedCoeff
alpha_[zoneI].setSize(1, tensor::zero);
beta_[zoneI].setSize(1, tensor::zero);
alpha_[zoneI][0].xx() = alpha.value().x();
alpha_[zoneI][0].yy() = alpha.value().y();
alpha_[zoneI][0].zz() = alpha.value().z();
alpha_[zoneI][0].xx() = alphaXYZ_.value().x();
alpha_[zoneI][0].yy() = alphaXYZ_.value().y();
alpha_[zoneI][0].zz() = alphaXYZ_.value().z();
alpha_[zoneI][0] = coordSys_.R().transformTensor(alpha_[zoneI][0]);
beta_[zoneI][0].xx() = beta.value().x();
beta_[zoneI][0].yy() = beta.value().y();
beta_[zoneI][0].zz() = beta.value().z();
beta_[zoneI][0].xx() = betaXYZ_.value().x();
beta_[zoneI][0].yy() = betaXYZ_.value().y();
beta_[zoneI][0].zz() = betaXYZ_.value().z();
beta_[zoneI][0] = coordSys_.R().transformTensor(beta_[zoneI][0]);
}
}
@ -149,13 +162,13 @@ Foam::porosityModels::fixedCoeff::fixedCoeff
forAll(cells, i)
{
alpha_[zoneI][i].xx() = alpha.value().x();
alpha_[zoneI][i].yy() = alpha.value().y();
alpha_[zoneI][i].zz() = alpha.value().z();
alpha_[zoneI][i].xx() = alphaXYZ_.value().x();
alpha_[zoneI][i].yy() = alphaXYZ_.value().y();
alpha_[zoneI][i].zz() = alphaXYZ_.value().z();
beta_[zoneI][i].xx() = beta.value().x();
beta_[zoneI][i].yy() = beta.value().y();
beta_[zoneI][i].zz() = beta.value().z();
beta_[zoneI][i].xx() = betaXYZ_.value().x();
beta_[zoneI][i].yy() = betaXYZ_.value().y();
beta_[zoneI][i].zz() = betaXYZ_.value().z();
}
alpha_[zoneI] =
@ -167,14 +180,6 @@ Foam::porosityModels::fixedCoeff::fixedCoeff
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::porosityModels::fixedCoeff::~fixedCoeff()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModels::fixedCoeff::calcForce
(
const volVectorField& U,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -64,10 +64,16 @@ private:
// Private data
//- Model alpha coefficient [1/s]
//- alpha coefficient XYZ components (user-supplied) [1/s]
dimensionedVector alphaXYZ_;
//- beta coefficient XYZ components (user-supplied) [1/m]
dimensionedVector betaXYZ_;
//- Model alpha coefficient - converted from alphaXYZ [1/s]
List<tensorField> alpha_;
//- Model beta coefficient [1/m]
//- Model beta coefficient - converted from betaXYZ [1/m]
List<tensorField> beta_;
@ -119,6 +125,9 @@ public:
// Member Functions
//- Transform the model data wrt mesh changes
virtual void calcTranformModelData();
//- Calculate the porosity force
virtual void calcForce
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -147,13 +147,27 @@ Foam::porosityModel::~porosityModel()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModel::transformModelData()
{
if (!mesh_.upToDatePoints(*this))
{
calcTranformModelData();
// set model up-to-date wrt points
mesh_.setUpToDatePoints(*this);
}
}
Foam::tmp<Foam::vectorField> Foam::porosityModel::porosityModel::force
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu
) const
)
{
transformModelData();
tmp<vectorField> tforce(new vectorField(U.size(), vector::zero));
if (!cellZoneIDs_.empty())
@ -165,16 +179,14 @@ Foam::tmp<Foam::vectorField> Foam::porosityModel::porosityModel::force
}
void Foam::porosityModel::addResistance
(
fvVectorMatrix& UEqn
) const
void Foam::porosityModel::addResistance(fvVectorMatrix& UEqn)
{
if (cellZoneIDs_.empty())
{
return;
}
transformModelData();
this->correct(UEqn);
}
@ -184,13 +196,14 @@ void Foam::porosityModel::addResistance
fvVectorMatrix& UEqn,
const volScalarField& rho,
const volScalarField& mu
) const
)
{
if (cellZoneIDs_.empty())
{
return;
}
transformModelData();
this->correct(UEqn, rho, mu);
}
@ -200,13 +213,14 @@ void Foam::porosityModel::addResistance
const fvVectorMatrix& UEqn,
volTensorField& AU,
bool correctAUprocBC
) const
)
{
if (cellZoneIDs_.empty())
{
return;
}
transformModelData();
this->correct(UEqn, AU);
if (correctAUprocBC)
@ -219,24 +233,12 @@ void Foam::porosityModel::addResistance
}
bool Foam::porosityModel::movePoints()
{
// no updates necessary; all member data independent of mesh
return true;
}
void Foam::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)
{
active_ = readBool(dict.lookup("active"));

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -99,6 +99,10 @@ protected:
// Protected Member Functions
//- Transform the model data wrt mesh changes
virtual void calcTranformModelData() = 0;
//- Adjust negative resistance values to be multiplier of max value
void adjustNegativeResistance(dimensionedVector& resist);
@ -221,16 +225,19 @@ public:
//- Return const access to the cell zone IDs
inline const labelList& cellZoneIDs() const;
//- Transform the model data wrt mesh changes
virtual void transformModelData();
//- Return the force over the cell zone(s)
virtual tmp<vectorField> force
(
const volVectorField& U,
const volScalarField& rho,
const volScalarField& mu
) const;
);
//- Add resistance
virtual void addResistance(fvVectorMatrix& UEqn) const;
virtual void addResistance(fvVectorMatrix& UEqn);
//- Add resistance
virtual void addResistance
@ -238,7 +245,7 @@ public:
fvVectorMatrix& UEqn,
const volScalarField& rho,
const volScalarField& mu
) const;
);
//- Add resistance
virtual void addResistance
@ -246,16 +253,7 @@ public:
const fvVectorMatrix& UEqn,
volTensorField& AU,
bool correctAUprocBC
) const;
// Topology change
//- Move points
virtual bool movePoints();
//- Update on meshUpdate
virtual void updateMesh(const mapPolyMesh& mpm);
);
// I-O

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -126,7 +126,7 @@ bool Foam::porosityModelList::writeData(Ostream& os) const
void Foam::porosityModelList::addResistance
(
fvVectorMatrix& UEqn
) const
)
{
forAll(*this, i)
{
@ -140,7 +140,7 @@ void Foam::porosityModelList::addResistance
fvVectorMatrix& UEqn,
const volScalarField& rho,
const volScalarField& mu
) const
)
{
forAll(*this, i)
{
@ -154,7 +154,7 @@ void Foam::porosityModelList::addResistance
const fvVectorMatrix& UEqn,
volTensorField& AU,
bool correctAUprocBC
) const
)
{
forAll(*this, i)
{

View File

@ -94,7 +94,7 @@ public:
void reset(const dictionary& dict);
//- Add resistance
void addResistance(fvVectorMatrix& UEqn) const;
void addResistance(fvVectorMatrix& UEqn);
//- Add resistance
void addResistance
@ -102,7 +102,7 @@ public:
fvVectorMatrix& UEqn,
const volScalarField& rho,
const volScalarField& mu
) const;
);
//- Add resistance
void addResistance
@ -110,7 +110,7 @@ public:
const fvVectorMatrix& UEqn,
volTensorField& AU,
bool correctAUprocBC = true
) const;
);
// I-O

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -66,6 +66,12 @@ Foam::porosityModels::powerLaw::~powerLaw()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::porosityModels::powerLaw::calcTranformModelData()
{
// nothing to be transformed
}
void Foam::porosityModels::powerLaw::calcForce
(
const volVectorField& U,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -127,6 +127,9 @@ public:
// Member Functions
//- Transform the model data wrt mesh changes
virtual void calcTranformModelData();
//- Calculate the porosity force
virtual void calcForce
(