From 2959bd257b9bb3f49ac486843b31a1b4610e0e71 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 10 Jun 2024 16:20:11 +0200
Subject: [PATCH] REGRESSION: missing "value" handling for some surface fields
 (#3144)

- changes in 8a8b5db977c3 were overly aggressive.
  Only need to suppress "value" IO for empty patches types
---
 .../constraint/empty/emptyFaPatchField.C            | 10 ++++++++++
 .../constraint/empty/emptyFaPatchField.H            |  6 ++++++
 .../basic/sliced/slicedFaePatchField.C              | 10 ++++++++++
 .../basic/sliced/slicedFaePatchField.H              |  3 +++
 .../constraint/empty/emptyFaePatchField.C           | 10 ++++++++++
 .../constraint/empty/emptyFaePatchField.H           | 10 ++++++++--
 .../constraint/empty/emptyFvPatchField.C            |  8 ++++++++
 .../constraint/empty/emptyFvPatchField.H            |  8 +++++++-
 .../basic/calculated/calculatedFvsPatchField.H      |  5 +++--
 .../basic/coupled/coupledFvsPatchField.H            |  2 +-
 .../basic/fixedValue/fixedValueFvsPatchField.H      |  6 +++---
 .../constraint/cyclic/cyclicFvsPatchField.H         |  2 +-
 .../constraint/cyclicSlip/cyclicSlipFvsPatchField.H |  1 -
 .../constraint/empty/emptyFvsPatchField.C           | 10 ++++++++++
 .../constraint/empty/emptyFvsPatchField.H           |  8 +++++++-
 .../nonuniformTransformCyclicFvsPatchField.H        |  1 -
 .../constraint/symmetry/symmetryFvsPatchField.C     | 12 +++++++++++-
 .../constraint/symmetry/symmetryFvsPatchField.H     | 13 ++++++++++---
 .../symmetryPlane/symmetryPlaneFvsPatchField.C      | 12 +++++++++++-
 .../symmetryPlane/symmetryPlaneFvsPatchField.H      | 13 ++++++++++---
 .../constraint/wedge/wedgeFvsPatchField.C           | 12 +++++++++++-
 .../constraint/wedge/wedgeFvsPatchField.H           | 13 ++++++++++---
 22 files changed, 150 insertions(+), 25 deletions(-)

diff --git a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C
index daeae4a111d..a011455ef27 100644
--- a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C
+++ b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.C
@@ -137,4 +137,14 @@ void Foam::emptyFaPatchField<Type>::updateCoeffs()
 }
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::emptyFaPatchField<Type>::write(Ostream& os) const
+{
+    faPatchField<Type>::write(os);
+    // Never write "value"
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.H b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.H
index ef6b2d9e36a..cd7d1febbe0 100644
--- a/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.H
+++ b/src/finiteArea/fields/faPatchFields/constraint/empty/emptyFaPatchField.H
@@ -186,6 +186,12 @@ public:
             {
                 return tmp<Field<Type>>::New();
             }
+
+
+    // Member Functions
+
+        //- Write without "value" entry!
+        virtual void write(Ostream&) const;
 };
 
 
diff --git a/src/finiteArea/fields/faePatchFields/basic/sliced/slicedFaePatchField.C b/src/finiteArea/fields/faePatchFields/basic/sliced/slicedFaePatchField.C
index 9f0e1818aba..4439efada22 100644
--- a/src/finiteArea/fields/faePatchFields/basic/sliced/slicedFaePatchField.C
+++ b/src/finiteArea/fields/faePatchFields/basic/sliced/slicedFaePatchField.C
@@ -131,4 +131,14 @@ Foam::slicedFaePatchField<Type>::~slicedFaePatchField()
 }
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::slicedFaePatchField<Type>::write(Ostream& os) const
+{
+    faePatchField<Type>::write(os);
+    faePatchField<Type>::writeValueEntry(os);
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteArea/fields/faePatchFields/basic/sliced/slicedFaePatchField.H b/src/finiteArea/fields/faePatchFields/basic/sliced/slicedFaePatchField.H
index 17302930ee5..3dd671d7644 100644
--- a/src/finiteArea/fields/faePatchFields/basic/sliced/slicedFaePatchField.H
+++ b/src/finiteArea/fields/faePatchFields/basic/sliced/slicedFaePatchField.H
@@ -141,6 +141,9 @@ public:
         //- True: this patch field fixes a value.
         virtual bool fixesValue() const { return true; }
 
+        //- Write includes "value" entry
+        virtual void write(Ostream&) const;
+
 
     // Member Operators
 
diff --git a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C
index d77ef591d5d..233c5888129 100644
--- a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C
+++ b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.C
@@ -108,4 +108,14 @@ Foam::emptyFaePatchField<Type>::emptyFaePatchField
 {}
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::emptyFaePatchField<Type>::write(Ostream& os) const
+{
+    faePatchField<Type>::write(os);
+    // Never write "value"
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.H b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.H
index 3d9afcace46..1d26f2b7881 100644
--- a/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.H
+++ b/src/finiteArea/fields/faePatchFields/constraint/empty/emptyFaePatchField.H
@@ -124,9 +124,9 @@ public:
     virtual ~emptyFaePatchField() = default;
 
 
-    // Member functions
+    // Member Functions
 
-        // Mapping functions
+        // Mapping Functions
 
             //- Map (and resize as needed) from self given a mapping object
             virtual void autoMap
@@ -142,6 +142,12 @@ public:
                 const labelList&
             )
             {}
+
+
+    // Member Functions
+
+        //- Write without "value" entry!
+        virtual void write(Ostream&) const;
 };
 
 
diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.C
index 5bbc2ddd6f2..3a7da4963b0 100644
--- a/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.C
@@ -123,4 +123,12 @@ void Foam::emptyFvPatchField<Type>::updateCoeffs()
 }
 
 
+template<class Type>
+void Foam::emptyFvPatchField<Type>::write(Ostream& os) const
+{
+    fvPatchField<Type>::write(os);
+    // Never write "value"
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.H
index b22e96584c7..3cf910fc072 100644
--- a/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/constraint/empty/emptyFvPatchField.H
@@ -42,7 +42,7 @@ Usage
     \verbatim
     <patchName>
     {
-        type            empty;
+        type    empty;
     }
     \endverbatim
 
@@ -194,6 +194,12 @@ public:
             {
                 return tmp<Field<Type>>::New();
             }
+
+
+    // Member Functions
+
+        //- Write without "value" entry!
+        virtual void write(Ostream&) const;
 };
 
 
diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.H
index 1e8914fd250..4b629cba984 100644
--- a/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/basic/calculated/calculatedFvsPatchField.H
@@ -43,8 +43,8 @@ Usage
     \verbatim
     <patchName>
     {
-        type            calculated;
-        value           uniform (0 0 0);    // Required value entry
+        type    calculated;
+        value   uniform (0 0 0);    // Required value entry
     }
     \endverbatim
 
@@ -88,6 +88,7 @@ public:
         );
 
         //- Construct from patch, internal field and dictionary
+        //- The "value" entry is MUST_READ.
         calculatedFvsPatchField
         (
             const fvPatch&,
diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.H
index b6ce0ea9f0c..ddb82695625 100644
--- a/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/basic/coupled/coupledFvsPatchField.H
@@ -123,7 +123,7 @@ public:
 
     // Member Functions
 
-        //- True if this patch field is derived from coupledFvsPatchField
+        //- True: this patch field is derived from coupledFvsPatchField
         virtual bool coupled() const
         {
             return true;
diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H
index 5934499fe08..600abc3ba6c 100644
--- a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.H
@@ -43,8 +43,8 @@ Usage
     \verbatim
     <patchName>
     {
-        type            fixedValue;
-        value           uniform 0;  // Example for scalar field usage
+        type    fixedValue;
+        value   uniform 0;  // Example for scalar field usage
     }
     \endverbatim
 
@@ -151,7 +151,7 @@ public:
         virtual void write(Ostream&) const;
 
 
-        // Evaluation functions
+        // Evaluation Functions
 
             //- Return the matrix diagonal coefficients corresponding to the
             //  evaluation of the value of this patchField with given weights
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclic/cyclicFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclic/cyclicFvsPatchField.H
index 384638a7547..8678370201c 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclic/cyclicFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclic/cyclicFvsPatchField.H
@@ -88,7 +88,7 @@ public:
         );
 
         //- Construct from patch, internal field and dictionary.
-        //- The "value" entry is NO_READ.
+        //- The "value" entry is MUST_READ.
         cyclicFvsPatchField
         (
             const fvPatch&,
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicSlip/cyclicSlipFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicSlip/cyclicSlipFvsPatchField.H
index 09833a088ea..023beff5b41 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicSlip/cyclicSlipFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/cyclicSlip/cyclicSlipFvsPatchField.H
@@ -54,7 +54,6 @@ class cyclicSlipFvsPatchField
 :
     public cyclicFvsPatchField<Type>
 {
-
 public:
 
     //- Runtime type information
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.C
index 5c1d93d7d53..4ad2d350be9 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.C
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.C
@@ -110,4 +110,14 @@ Foam::emptyFvsPatchField<Type>::emptyFvsPatchField
 {}
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::emptyFvsPatchField<Type>::write(Ostream& os) const
+{
+    fvsPatchField<Type>::write(os);
+    // Never write "value"
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.H
index 6a703550751..f736e76d2b4 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/empty/emptyFvsPatchField.H
@@ -37,7 +37,7 @@ Usage
     \verbatim
     <patchName>
     {
-        type            empty;
+        type    empty;
     }
     \endverbatim
 
@@ -146,6 +146,12 @@ public:
                 const labelList&
             )
             {}
+
+
+    // Member Functions
+
+        //- Write without "value" entry!
+        virtual void write(Ostream&) const;
 };
 
 
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvsPatchField.H
index 6f5fdd7d718..8c78a68aa1a 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/nonuniformTransformCyclic/nonuniformTransformCyclicFvsPatchField.H
@@ -54,7 +54,6 @@ class nonuniformTransformCyclicFvsPatchField
 :
     public cyclicFvsPatchField<Type>
 {
-
 public:
 
     //- Runtime type information
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.C
index 071abfefee3..fb604eabd44 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.C
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.C
@@ -49,7 +49,7 @@ Foam::symmetryFvsPatchField<Type>::symmetryFvsPatchField
     const dictionary& dict
 )
 :
-    fvsPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ)
+    fvsPatchField<Type>(p, iF, dict, IOobjectOption::MUST_READ)
 {
     if (!isType<symmetryFvPatch>(p))
     {
@@ -105,4 +105,14 @@ Foam::symmetryFvsPatchField<Type>::symmetryFvsPatchField
 {}
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::symmetryFvsPatchField<Type>::write(Ostream& os) const
+{
+    fvsPatchField<Type>::write(os);
+    fvsPatchField<Type>::writeValueEntry(os);
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.H
index 4142b0d70fa..03269966a17 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetry/symmetryFvsPatchField.H
@@ -30,14 +30,15 @@ Class
 Description
     This boundary condition enforces a symmetry constraint
 
-    The "value" entry is NO_READ, NO_WRITE.
+    The "value" entry is MUST_READ.
 
 Usage
     Example of the boundary condition specification:
     \verbatim
     <patchName>
     {
-        type            symmetry;
+        type    symmetry;
+        value   ...;
     }
     \endverbatim
 
@@ -82,7 +83,7 @@ public:
         );
 
         //- Construct from patch, internal field and dictionary
-        //- The "value" entry is NO_READ.
+        //- The "value" entry is MUST_READ.
         symmetryFvsPatchField
         (
             const fvPatch&,
@@ -126,6 +127,12 @@ public:
         {
             return fvsPatchField<Type>::Clone(*this, iF);
         }
+
+
+    // Member Functions
+
+        //- Write includes "value" entry
+        virtual void write(Ostream&) const;
 };
 
 
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.C
index 80d4b9378d4..c12a280cb33 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.C
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.C
@@ -49,7 +49,7 @@ Foam::symmetryPlaneFvsPatchField<Type>::symmetryPlaneFvsPatchField
     const dictionary& dict
 )
 :
-    fvsPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ)
+    fvsPatchField<Type>(p, iF, dict, IOobjectOption::MUST_READ)
 {
     if (!isType<symmetryPlaneFvPatch>(p))
     {
@@ -105,4 +105,14 @@ Foam::symmetryPlaneFvsPatchField<Type>::symmetryPlaneFvsPatchField
 {}
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::symmetryPlaneFvsPatchField<Type>::write(Ostream& os) const
+{
+    fvsPatchField<Type>::write(os);
+    fvsPatchField<Type>::writeValueEntry(os);
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.H
index 717506e082a..515f1bdbecf 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/symmetryPlane/symmetryPlaneFvsPatchField.H
@@ -29,14 +29,15 @@ Class
 Description
     This boundary condition enforces a symmetryPlane constraint
 
-    The "value" entry is NO_READ, NO_WRITE.
+    The "value" entry is MUST_READ.
 
 Usage
     Example of the boundary condition specification:
     \verbatim
     <patchName>
     {
-        type            symmetryPlane;
+        type    symmetryPlane;
+        value   ...;
     }
     \endverbatim
 
@@ -81,7 +82,7 @@ public:
         );
 
         //- Construct from patch, internal field and dictionary.
-        //- The "value" entry is NO_READ.
+        //- The "value" entry is MUST_READ.
         symmetryPlaneFvsPatchField
         (
             const fvPatch&,
@@ -125,6 +126,12 @@ public:
         {
             return fvsPatchField<Type>::Clone(*this, iF);
         }
+
+
+    // Member Functions
+
+        //- Write includes "value" entry
+        virtual void write(Ostream&) const;
 };
 
 
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.C
index df57e01f614..013a628b533 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.C
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.C
@@ -49,7 +49,7 @@ Foam::wedgeFvsPatchField<Type>::wedgeFvsPatchField
     const dictionary& dict
 )
 :
-    fvsPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ)
+    fvsPatchField<Type>(p, iF, dict, IOobjectOption::MUST_READ)
 {
     if (!isType<wedgeFvPatch>(p))
     {
@@ -105,4 +105,14 @@ Foam::wedgeFvsPatchField<Type>::wedgeFvsPatchField
 {}
 
 
+// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
+
+template<class Type>
+void Foam::wedgeFvsPatchField<Type>::write(Ostream& os) const
+{
+    fvsPatchField<Type>::write(os);
+    fvsPatchField<Type>::writeValueEntry(os);
+}
+
+
 // ************************************************************************* //
diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.H
index aeb04ff0bc3..1325dd9a422 100644
--- a/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/constraint/wedge/wedgeFvsPatchField.H
@@ -31,14 +31,15 @@ Description
     This boundary condition is similar to the cyclic condition, except that
     it is applied to 2-D geometries.
 
-    The "value" entry is NO_READ, NO_WRITE.
+    The "value" entry is MUST_READ.
 
 Usage
     Example of the boundary condition specification:
     \verbatim
     <patchName>
     {
-        type            wedge;
+        type    wedge;
+        value   uniform ...;    // Required value entry
     }
     \endverbatim
 
@@ -83,7 +84,7 @@ public:
         );
 
         //- Construct from patch, internal field and dictionary.
-        //- The "value" entry is NO_READ.
+        //- The "value" entry is MUST_READ.
         wedgeFvsPatchField
         (
             const fvPatch&,
@@ -127,6 +128,12 @@ public:
         {
             return fvsPatchField<Type>::Clone(*this, iF);
         }
+
+
+    // Member Functions
+
+        //- Write includes "value" entry
+        virtual void write(Ostream&) const;
 };
 
 
-- 
GitLab