From eebfda5f109551bb9028435b20b2485074908e1f Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 7 Jul 2009 18:21:13 +0100 Subject: [PATCH 1/2] optimisation for diffusion calc --- .../APIdiffCoefFunc/APIdiffCoefFunc.H | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/thermophysicalModels/thermophysicalFunctions/APIfunctions/APIdiffCoefFunc/APIdiffCoefFunc.H b/src/thermophysicalModels/thermophysicalFunctions/APIfunctions/APIdiffCoefFunc/APIdiffCoefFunc.H index b24d250d49..7f95e450e3 100644 --- a/src/thermophysicalModels/thermophysicalFunctions/APIfunctions/APIdiffCoefFunc/APIdiffCoefFunc.H +++ b/src/thermophysicalModels/thermophysicalFunctions/APIfunctions/APIdiffCoefFunc/APIdiffCoefFunc.H @@ -47,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class APIdiffCoefFunc Declaration + Class APIdiffCoefFunc Declaration \*---------------------------------------------------------------------------*/ class APIdiffCoefFunc @@ -59,6 +59,9 @@ class APIdiffCoefFunc // API vapour mass diffusivity function coefficients scalar a_, b_, wf_, wa_; + // Helper variables + scalar alpha_, beta_; + public: @@ -74,7 +77,9 @@ public: a_(a), b_(b), wf_(wf), - wa_(wa) + wa_(wa), + alpha_(sqrt(1/wf_ + 1/wa_)), + beta_(sqr((cbrt(a_) + cbrt(b_)))) {} //- Construct from Istream @@ -83,21 +88,21 @@ public: a_(readScalar(is)), b_(readScalar(is)), wf_(readScalar(is)), - wa_(readScalar(is)) + wa_(readScalar(is)), + alpha_(sqrt(1/wf_ + 1/wa_)), + beta_(sqr((cbrt(a_) + cbrt(b_)))) {} // Member Functions - //- API vapour mass diffusivity function + //- API vapour mass diffusivity function using properties from + // construction scalar f(scalar p, scalar T) const { - return - 3.6059e-3*(pow(1.8*T, 1.75))*sqrt(1/wf_ + 1/wa_) - /(p*sqr((cbrt(a_) + cbrt(b_)))); + return 3.6059e-3*(pow(1.8*T, 1.75))*alpha_/(p*beta_); } - //- Write the function coefficients void writeData(Ostream& os) const { From f8f5324740ab153cb3ec68ac8c4679920ba1303b Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 7 Jul 2009 18:34:42 +0100 Subject: [PATCH 2/2] comment clean-up --- .../basic/psiThermo/ePsiThermo/ePsiThermo.H | 4 ++-- .../basic/psiThermo/hPsiThermo/hPsiThermo.H | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermo.H b/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermo.H index 6952edc423..fd3071ff11 100644 --- a/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermo.H +++ b/src/thermophysicalModels/basic/psiThermo/ePsiThermo/ePsiThermo.H @@ -87,13 +87,13 @@ public: // Member functions - //- Return the compostion of the combustion mixture + //- Return the compostion of the mixture virtual basicMixture& composition() { return *this; } - //- Return the compostion of the combustion mixture + //- Return the compostion of the mixture virtual const basicMixture& composition() const { return *this; diff --git a/src/thermophysicalModels/basic/psiThermo/hPsiThermo/hPsiThermo.H b/src/thermophysicalModels/basic/psiThermo/hPsiThermo/hPsiThermo.H index c1d9b513a3..4eae7214a0 100644 --- a/src/thermophysicalModels/basic/psiThermo/hPsiThermo/hPsiThermo.H +++ b/src/thermophysicalModels/basic/psiThermo/hPsiThermo/hPsiThermo.H @@ -87,13 +87,13 @@ public: // Member functions - //- Return the compostion of the combustion mixture + //- Return the compostion of the mixture virtual basicMixture& composition() { return *this; } - //- Return the compostion of the combustion mixture + //- Return the compostion of the mixture virtual const basicMixture& composition() const { return *this;