mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Updated pressureGradientExplicitSource
This commit is contained in:
@ -46,7 +46,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::pressureGradientExplicitSource::writeGradP() const
|
void Foam::pressureGradientExplicitSource::writeProps(const scalar gradP) const
|
||||||
{
|
{
|
||||||
// Only write on output time
|
// Only write on output time
|
||||||
if (mesh_.time().outputTime())
|
if (mesh_.time().outputTime())
|
||||||
@ -63,7 +63,7 @@ void Foam::pressureGradientExplicitSource::writeGradP() const
|
|||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
propsDict.add("gradient", gradP_);
|
propsDict.add("gradient", gradP);
|
||||||
propsDict.regIOobject::write();
|
propsDict.regIOobject::write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,8 +81,8 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
|
|||||||
:
|
:
|
||||||
basicSource(sourceName, modelType, dict, mesh),
|
basicSource(sourceName, modelType, dict, mesh),
|
||||||
Ubar_(coeffs_.lookup("Ubar")),
|
Ubar_(coeffs_.lookup("Ubar")),
|
||||||
gradPini_(coeffs_.lookup("gradPini")),
|
gradP0_(0.0),
|
||||||
gradP_(gradPini_),
|
dGradP_(0.0),
|
||||||
flowDir_(Ubar_/mag(Ubar_)),
|
flowDir_(Ubar_/mag(Ubar_)),
|
||||||
invAPtr_(NULL)
|
invAPtr_(NULL)
|
||||||
{
|
{
|
||||||
@ -95,7 +95,7 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
|
|||||||
"Foam::pressureGradientExplicitSource::"
|
"Foam::pressureGradientExplicitSource::"
|
||||||
"pressureGradientExplicitSource"
|
"pressureGradientExplicitSource"
|
||||||
"("
|
"("
|
||||||
"onst word&, "
|
"const word&, "
|
||||||
"const word&, "
|
"const word&, "
|
||||||
"const dictionary&, "
|
"const dictionary&, "
|
||||||
"const fvMesh&"
|
"const fvMesh&"
|
||||||
@ -116,10 +116,10 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource
|
|||||||
{
|
{
|
||||||
Info<< " Reading pressure gradient from file" << endl;
|
Info<< " Reading pressure gradient from file" << endl;
|
||||||
dictionary propsDict(dictionary::null, propsFile);
|
dictionary propsDict(dictionary::null, propsFile);
|
||||||
propsDict.lookup("gradient") >> gradP_;
|
propsDict.lookup("gradient") >> gradP0_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< " Initial pressure gradient = " << gradP_ << nl << endl;
|
Info<< " Initial pressure gradient = " << gradP0_ << nl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -151,22 +151,21 @@ void Foam::pressureGradientExplicitSource::correct(volVectorField& U)
|
|||||||
|
|
||||||
// Calculate the pressure gradient increment needed to adjust the average
|
// Calculate the pressure gradient increment needed to adjust the average
|
||||||
// flow-rate to the desired value
|
// flow-rate to the desired value
|
||||||
scalar gradPplus = (mag(Ubar_) - magUbarAve)/rAUave;
|
dGradP_ = (mag(Ubar_) - magUbarAve)/rAUave;
|
||||||
|
|
||||||
// Apply correction to velocity field
|
// Apply correction to velocity field
|
||||||
forAll(cells_, i)
|
forAll(cells_, i)
|
||||||
{
|
{
|
||||||
label cellI = cells_[i];
|
label cellI = cells_[i];
|
||||||
U[cellI] += flowDir_*rAU[cellI]*gradPplus;
|
U[cellI] += flowDir_*rAU[cellI]*dGradP_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update pressure gradient
|
scalar gradP = gradP0_ + dGradP_;
|
||||||
gradP_.value() += gradPplus;
|
|
||||||
|
|
||||||
Info<< "Pressure gradient source: uncorrected Ubar = " << magUbarAve
|
Info<< "Pressure gradient source: uncorrected Ubar = " << magUbarAve
|
||||||
<< ", pressure gradient = " << gradP_.value() << endl;
|
<< ", pressure gradient = " << gradP << endl;
|
||||||
|
|
||||||
writeGradP();
|
writeProps(gradP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -187,10 +186,12 @@ void Foam::pressureGradientExplicitSource::addSup
|
|||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
),
|
),
|
||||||
mesh_,
|
mesh_,
|
||||||
dimensionedVector("zero", gradP_.dimensions(), vector::zero)
|
dimensionedVector("zero", eqn.dimensions()/dimVolume, vector::zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
UIndirectList<vector>(Su, cells_) = flowDir_*gradP_.value();
|
scalar gradP = gradP0_ + dGradP_;
|
||||||
|
|
||||||
|
UIndirectList<vector>(Su, cells_) = flowDir_*gradP;
|
||||||
|
|
||||||
eqn += Su;
|
eqn += Su;
|
||||||
}
|
}
|
||||||
@ -224,6 +225,9 @@ void Foam::pressureGradientExplicitSource::setValue
|
|||||||
{
|
{
|
||||||
invAPtr_() = 1.0/eqn.A();
|
invAPtr_() = 1.0/eqn.A();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gradP0_ += dGradP_;
|
||||||
|
dGradP_ = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,11 +73,11 @@ class pressureGradientExplicitSource
|
|||||||
//- Average velocity
|
//- Average velocity
|
||||||
vector Ubar_;
|
vector Ubar_;
|
||||||
|
|
||||||
//- Initial pressure gradient
|
//- Pressure gradient before correction
|
||||||
dimensionedScalar gradPini_;
|
scalar gradP0_;
|
||||||
|
|
||||||
//- Pressure gradient
|
//- Change in pressure gradient
|
||||||
dimensionedScalar gradP_;
|
scalar dGradP_;
|
||||||
|
|
||||||
//- Flow direction
|
//- Flow direction
|
||||||
vector flowDir_;
|
vector flowDir_;
|
||||||
@ -89,7 +89,7 @@ class pressureGradientExplicitSource
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Write the pressure gradient to file (for restarts etc)
|
//- Write the pressure gradient to file (for restarts etc)
|
||||||
void writeGradP() const;
|
void writeProps(const scalar gradP) const;
|
||||||
|
|
||||||
//- Correct driving force for a constant mass flow rate
|
//- Correct driving force for a constant mass flow rate
|
||||||
void update(fvMatrix<vector>& eqn);
|
void update(fvMatrix<vector>& eqn);
|
||||||
|
|||||||
Reference in New Issue
Block a user