From c7b8b1f43c5b684b482db344e77c98989bb39caf Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Wed, 27 Jan 2010 10:36:06 +0000
Subject: [PATCH] ENH: Allow proper restart (without knowing the boundary
 condition)

The boundary conditions were still accessing e.g. the temperature even
when restarting. Now they
will reread all their data if there is a 'value' field present.
---
 .../MarshakRadiationMixedFvPatchScalarField.C | 18 +++++++++--------
 ...akRadiationFixedTMixedFvPatchScalarField.C | 15 ++++++++------
 ...iffusiveRadiationMixedFvPatchScalarField.C | 20 ++++++++++---------
 3 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C
index f599c447f64..2eac477a080 100644
--- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C
+++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C
@@ -76,21 +76,24 @@ Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
     TName_(dict.lookup("T")),
     emissivity_(readScalar(dict.lookup("emissivity")))
 {
-    const scalarField& Tp =
-        patch().lookupPatchField<volScalarField, scalar>(TName_);
-
-    refValue() = 4.0*constant::physicoChemical::sigma.value()*pow4(Tp);
-    refGrad() = 0.0;
-
     if (dict.found("value"))
     {
         fvPatchScalarField::operator=
         (
             scalarField("value", dict, p.size())
         );
+        refValue() = scalarField("refValue", dict, p.size());
+        refGrad() = scalarField("refGradient", dict, p.size());
+        valueFraction() = scalarField("valueFraction", dict, p.size());
     }
     else
     {
+        const scalarField& Tp =
+            patch().lookupPatchField<volScalarField, scalar>(TName_);
+
+        refValue() = 4.0*constant::physicoChemical::sigma.value()*pow4(Tp);
+        refGrad() = 0.0;
+
         fvPatchScalarField::operator=(refValue());
     }
 }
@@ -169,10 +172,9 @@ void Foam::MarshakRadiationFvPatchScalarField::updateCoeffs()
 
 void Foam::MarshakRadiationFvPatchScalarField::write(Ostream& os) const
 {
-    fvPatchScalarField::write(os);
+    mixedFvPatchScalarField::write(os);
     os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
     os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
-    writeEntry("value", os);
 }
 
 
diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C
index 2620d111cba..1e7836352cd 100644
--- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C
+++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C
@@ -79,18 +79,22 @@ MarshakRadiationFixedTMixedFvPatchScalarField
     Trad_("Trad", dict, p.size()),
     emissivity_(readScalar(dict.lookup("emissivity")))
 {
-    refValue() = 4.0*constant::physicoChemical::sigma.value()*pow4(Trad_);
-    refGrad() = 0.0;
-
     if (dict.found("value"))
     {
         fvPatchScalarField::operator=
         (
             scalarField("value", dict, p.size())
         );
+        refValue() = scalarField("refValue", dict, p.size());
+        refGrad() = scalarField("refGradient", dict, p.size());
+        valueFraction() = scalarField("valueFraction", dict, p.size());
     }
     else
     {
+        refValue() = 4.0*constant::physicoChemical::sigma.value()*pow4(Trad_);
+        refGrad() = 0.0;
+        valueFraction() = 1.0;
+
         fvPatchScalarField::operator=(refValue());
     }
 }
@@ -128,7 +132,7 @@ void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::autoMap
     const fvPatchFieldMapper& m
 )
 {
-    scalarField::autoMap(m);
+    mixedFvPatchScalarField::autoMap(m);
     Trad_.autoMap(m);
 }
 
@@ -173,10 +177,9 @@ void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::updateCoeffs()
 
 void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::write(Ostream& os) const
 {
-    fvPatchScalarField::write(os);
+    mixedFvPatchScalarField::write(os);
     Trad_.writeEntry("Trad", os);
     os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
-    writeEntry("value", os);
 }
 
 
diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C
index a0a83e9e843..8cb18201910 100644
--- a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C
+++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C
@@ -82,22 +82,25 @@ wideBandDiffusiveRadiationMixedFvPatchScalarField
     TName_(dict.lookup("T")),
     emissivity_(readScalar(dict.lookup("emissivity")))
 {
-    const scalarField& Tp =
-        patch().lookupPatchField<volScalarField, scalar>(TName_);
-
-    refValue() =
-        emissivity_*4.0*physicoChemical::sigma.value()*pow4(Tp)/pi;
-    refGrad() = 0.0;
-
     if (dict.found("value"))
     {
         fvPatchScalarField::operator=
         (
             scalarField("value", dict, p.size())
         );
+        refValue() = scalarField("refValue", dict, p.size());
+        refGrad() = scalarField("refGradient", dict, p.size());
+        valueFraction() = scalarField("valueFraction", dict, p.size());
     }
     else
     {
+        const scalarField& Tp =
+            patch().lookupPatchField<volScalarField, scalar>(TName_);
+
+        refValue() =
+            emissivity_*4.0*physicoChemical::sigma.value()*pow4(Tp)/pi;
+        refGrad() = 0.0;
+
         fvPatchScalarField::operator=(refValue());
     }
 }
@@ -218,10 +221,9 @@ void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::write
     Ostream& os
 ) const
 {
-    fvPatchScalarField::write(os);
+    mixedFvPatchScalarField::write(os);
     os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
     os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
-    writeEntry("value", os);
 }
 
 
-- 
GitLab