From 5527055a1c81c6202a3afd343669a7dec01db5e9 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 10 Dec 2012 10:13:19 +0000 Subject: [PATCH] ENH: Updated pressureGradientExplicitSource --- .../pressureGradientExplicitSource.C | 34 +++++++++++-------- .../pressureGradientExplicitSource.H | 10 +++--- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/fieldSources/derived/pressureGradientExplicitSource/pressureGradientExplicitSource.C b/src/fieldSources/derived/pressureGradientExplicitSource/pressureGradientExplicitSource.C index 790fac2c8b..d506bdb19e 100644 --- a/src/fieldSources/derived/pressureGradientExplicitSource/pressureGradientExplicitSource.C +++ b/src/fieldSources/derived/pressureGradientExplicitSource/pressureGradientExplicitSource.C @@ -46,7 +46,7 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::pressureGradientExplicitSource::writeGradP() const +void Foam::pressureGradientExplicitSource::writeProps(const scalar gradP) const { // Only write on output time if (mesh_.time().outputTime()) @@ -63,7 +63,7 @@ void Foam::pressureGradientExplicitSource::writeGradP() const IOobject::NO_WRITE ) ); - propsDict.add("gradient", gradP_); + propsDict.add("gradient", gradP); propsDict.regIOobject::write(); } } @@ -81,8 +81,8 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource : basicSource(sourceName, modelType, dict, mesh), Ubar_(coeffs_.lookup("Ubar")), - gradPini_(coeffs_.lookup("gradPini")), - gradP_(gradPini_), + gradP0_(0.0), + dGradP_(0.0), flowDir_(Ubar_/mag(Ubar_)), invAPtr_(NULL) { @@ -95,7 +95,7 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource "Foam::pressureGradientExplicitSource::" "pressureGradientExplicitSource" "(" - "onst word&, " + "const word&, " "const word&, " "const dictionary&, " "const fvMesh&" @@ -116,10 +116,10 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource { Info<< " Reading pressure gradient from file" << endl; 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 // flow-rate to the desired value - scalar gradPplus = (mag(Ubar_) - magUbarAve)/rAUave; + dGradP_ = (mag(Ubar_) - magUbarAve)/rAUave; // Apply correction to velocity field forAll(cells_, i) { label cellI = cells_[i]; - U[cellI] += flowDir_*rAU[cellI]*gradPplus; + U[cellI] += flowDir_*rAU[cellI]*dGradP_; } - // Update pressure gradient - gradP_.value() += gradPplus; + scalar gradP = gradP0_ + dGradP_; 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 ), mesh_, - dimensionedVector("zero", gradP_.dimensions(), vector::zero) + dimensionedVector("zero", eqn.dimensions()/dimVolume, vector::zero) ); - UIndirectList(Su, cells_) = flowDir_*gradP_.value(); + scalar gradP = gradP0_ + dGradP_; + + UIndirectList(Su, cells_) = flowDir_*gradP; eqn += Su; } @@ -224,6 +225,9 @@ void Foam::pressureGradientExplicitSource::setValue { invAPtr_() = 1.0/eqn.A(); } + + gradP0_ += dGradP_; + dGradP_ = 0.0; } diff --git a/src/fieldSources/derived/pressureGradientExplicitSource/pressureGradientExplicitSource.H b/src/fieldSources/derived/pressureGradientExplicitSource/pressureGradientExplicitSource.H index a45a7927de..72ed2d7cf5 100644 --- a/src/fieldSources/derived/pressureGradientExplicitSource/pressureGradientExplicitSource.H +++ b/src/fieldSources/derived/pressureGradientExplicitSource/pressureGradientExplicitSource.H @@ -73,11 +73,11 @@ class pressureGradientExplicitSource //- Average velocity vector Ubar_; - //- Initial pressure gradient - dimensionedScalar gradPini_; + //- Pressure gradient before correction + scalar gradP0_; - //- Pressure gradient - dimensionedScalar gradP_; + //- Change in pressure gradient + scalar dGradP_; //- Flow direction vector flowDir_; @@ -89,7 +89,7 @@ class pressureGradientExplicitSource // Private Member Functions //- 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 void update(fvMatrix& eqn);