From c40faa99e69d2900707bcf69e3a273a7da522094 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Mon, 23 Nov 2015 16:52:18 +0000
Subject: [PATCH] fixedMultiPhaseHeatFlux: Added optional relaxation

---
 ...allBoilingWallFunctionFvPatchScalarField.C | 62 +++++++++----------
 ...allBoilingWallFunctionFvPatchScalarField.H |  2 +-
 ...ixedMultiPhaseHeatFluxFvPatchScalarField.C | 31 ++++++----
 ...ixedMultiPhaseHeatFluxFvPatchScalarField.H |  3 +
 4 files changed, 53 insertions(+), 45 deletions(-)

diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C
index 58293c7bac7..a2df2670f5c 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.C
@@ -83,10 +83,10 @@ alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::yPlusTherm
 ) const
 {
 
-    tmp<scalarField> typtf(new scalarField(this->size()));
-    scalarField& yptf = typtf();
+    tmp<scalarField> typsf(new scalarField(this->size()));
+    scalarField& ypsf = typsf();
 
-    forAll(yptf, faceI)
+    forAll(ypsf, faceI)
     {
         scalar ypt = 11.0;
 
@@ -98,11 +98,11 @@ alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::yPlusTherm
 
             if (yptNew < VSMALL)
             {
-                yptf[faceI] =  0;
+                ypsf[faceI] =  0;
             }
             else if (mag(yptNew - ypt) < tolerance_)
             {
-                yptf[faceI] = yptNew;
+                ypsf[faceI] = yptNew;
             }
             else
             {
@@ -110,10 +110,10 @@ alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::yPlusTherm
             }
         }
 
-        yptf[faceI] = ypt;
+        ypsf[faceI] = ypt;
     }
 
-    return typtf;
+    return typsf;
 }
 
 
@@ -160,52 +160,52 @@ alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
 alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::
 alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
 (
-    const alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField& ptf,
+    const alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField& psf,
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
     const fvPatchFieldMapper& mapper
 )
 :
-    alphatPhaseChangeWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
-    Prt_(ptf.Prt_),
-    Cmu_(ptf.Cmu_),
-    kappa_(ptf.kappa_),
-    E_(ptf.E_),
-    dmdtRelax_(ptf.dmdtRelax_),
-    fixedDmdt_(ptf.fixedDmdt_)
+    alphatPhaseChangeWallFunctionFvPatchScalarField(psf, p, iF, mapper),
+    Prt_(psf.Prt_),
+    Cmu_(psf.Cmu_),
+    kappa_(psf.kappa_),
+    E_(psf.E_),
+    dmdtRelax_(psf.dmdtRelax_),
+    fixedDmdt_(psf.fixedDmdt_)
 {}
 
 
 alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::
 alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
 (
-    const alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField& awfpsf
+    const alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField& psf
 )
 :
-    alphatPhaseChangeWallFunctionFvPatchScalarField(awfpsf),
-    Prt_(awfpsf.Prt_),
-    Cmu_(awfpsf.Cmu_),
-    kappa_(awfpsf.kappa_),
-    E_(awfpsf.E_),
-    dmdtRelax_(awfpsf.dmdtRelax_),
-    fixedDmdt_(awfpsf.fixedDmdt_)
+    alphatPhaseChangeWallFunctionFvPatchScalarField(psf),
+    Prt_(psf.Prt_),
+    Cmu_(psf.Cmu_),
+    kappa_(psf.kappa_),
+    E_(psf.E_),
+    dmdtRelax_(psf.dmdtRelax_),
+    fixedDmdt_(psf.fixedDmdt_)
 {}
 
 
 alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField::
 alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
 (
-    const alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField& awfpsf,
+    const alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField& psf,
     const DimensionedField<scalar, volMesh>& iF
 )
 :
-    alphatPhaseChangeWallFunctionFvPatchScalarField(awfpsf, iF),
-    Prt_(awfpsf.Prt_),
-    Cmu_(awfpsf.Cmu_),
-    kappa_(awfpsf.kappa_),
-    E_(awfpsf.E_),
-    dmdtRelax_(awfpsf.dmdtRelax_),
-    fixedDmdt_(awfpsf.fixedDmdt_)
+    alphatPhaseChangeWallFunctionFvPatchScalarField(psf, iF),
+    Prt_(psf.Prt_),
+    Cmu_(psf.Cmu_),
+    kappa_(psf.kappa_),
+    E_(psf.E_),
+    dmdtRelax_(psf.dmdtRelax_),
+    fixedDmdt_(psf.fixedDmdt_)
 {}
 
 
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.H b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.H
index 1d34ff1b08c..01e51e24d84 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.H
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/alphatFixedDmdtWallBoilingWallFunction/alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField.H
@@ -73,7 +73,7 @@ class alphatFixedDmdtWallBoilingWallFunctionFvPatchScalarField
         //- E coefficient
         scalar E_;
 
-        //- dmdt relaxationFactor
+        //- dmdt relaxation factor
         scalar dmdtRelax_;
 
         //- Reference dmdt
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
index ee5fa39f92b..8f9abe642cd 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.C
@@ -44,7 +44,8 @@ fixedMultiPhaseHeatFluxFvPatchScalarField
 )
 :
     fixedValueFvPatchScalarField(p, iF),
-    q_(p.size(), 0.0)
+    q_(p.size(), 0.0),
+    relax_(1.0)
 {}
 
 
@@ -57,44 +58,48 @@ fixedMultiPhaseHeatFluxFvPatchScalarField
 )
 :
     fixedValueFvPatchScalarField(p, iF, dict),
-    q_("q", dict, p.size())
+    q_("q", dict, p.size()),
+    relax_(dict.lookupOrDefault<scalar>("relax", 1.0))
 {}
 
 
 Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::
 fixedMultiPhaseHeatFluxFvPatchScalarField
 (
-    const fixedMultiPhaseHeatFluxFvPatchScalarField& ptf,
+    const fixedMultiPhaseHeatFluxFvPatchScalarField& psf,
     const fvPatch& p,
     const DimensionedField<scalar, volMesh>& iF,
     const fvPatchFieldMapper& mapper
 )
 :
-    fixedValueFvPatchScalarField(ptf, p, iF, mapper),
-    q_(ptf.q_, mapper)
+    fixedValueFvPatchScalarField(psf, p, iF, mapper),
+    q_(psf.q_, mapper),
+    relax_(psf.relax_)
 {}
 
 
 Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::
 fixedMultiPhaseHeatFluxFvPatchScalarField
 (
-    const fixedMultiPhaseHeatFluxFvPatchScalarField& awfpsf
+    const fixedMultiPhaseHeatFluxFvPatchScalarField& psf
 )
 :
-    fixedValueFvPatchScalarField(awfpsf),
-    q_(awfpsf.q_)
+    fixedValueFvPatchScalarField(psf),
+    q_(psf.q_),
+    relax_(psf.relax_)
 {}
 
 
 Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::
 fixedMultiPhaseHeatFluxFvPatchScalarField
 (
-    const fixedMultiPhaseHeatFluxFvPatchScalarField& awfpsf,
+    const fixedMultiPhaseHeatFluxFvPatchScalarField& psf,
     const DimensionedField<scalar, volMesh>& iF
 )
 :
-    fixedValueFvPatchScalarField(awfpsf, iF),
-    q_(awfpsf.q_)
+    fixedValueFvPatchScalarField(psf, iF),
+    q_(psf.q_),
+    relax_(psf.relax_)
 {}
 
 
@@ -165,8 +170,7 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
             << gMin(Q) << " - " << gMax(Q) << endl;
     }
 
-    scalar relax(1);
-    operator==((1 - relax)*Tp + relax*(q_ + A)/(B));
+    operator==((1 - relax_)*Tp + relax_*(q_ + A)/(B));
 
     fixedValueFvPatchScalarField::updateCoeffs();
 }
@@ -175,6 +179,7 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
 void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::write(Ostream& os) const
 {
     fvPatchField<scalar>::write(os);
+    os.writeKeyword("relax") << relax_ << token::END_STATEMENT << nl;
     q_.writeEntry("q", os);
     writeEntry("value", os);
 }
diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.H b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.H
index 0024fd08e79..c3eb42d6913 100644
--- a/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.H
+++ b/applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/derivedFvPatchFields/fixedMultiPhaseHeatFlux/fixedMultiPhaseHeatFluxFvPatchScalarField.H
@@ -67,6 +67,9 @@ class fixedMultiPhaseHeatFluxFvPatchScalarField
         //- Heat power [W] or flux [W/m2]
         scalarField q_;
 
+        //- Relaxation factor
+        scalar relax_;
+
 
 public:
 
-- 
GitLab