From e11c072bc4722ad53ab88aa1957faa74d600a36f Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Tue, 20 Oct 2020 14:14:40 +0200
Subject: [PATCH] CONFIG: incorrect BC code templates (fixes #1885)

- autoPtr to Function requires clone() method, not optional copy/move
  argument.

- fix bad character range for 'sed'
---
 bin/foamNewBC                                 |  2 +-
 etc/codeTemplates/BC/BC.C                     | 14 +++++------
 etc/codeTemplates/BC/BC.H                     | 25 +++++++++----------
 etc/codeTemplates/BC/BCs.C                    |  2 +-
 etc/codeTemplates/BC/BCs.H                    |  2 +-
 etc/codeTemplates/BC/BCsFwd.H                 |  2 +-
 etc/codeTemplates/app/app.C                   |  2 +-
 .../dynamicCode/codedPatchFunction1Template.C |  2 +-
 .../dynamicCode/functionObjectTemplate.H      |  2 +-
 .../functionObject/FUNCTIONOBJECT.C           |  2 +-
 etc/codeTemplates/source/_Template.H          | 18 ++++++-------
 etc/codeTemplates/source/_TemplateI.H         |  1 -
 .../template/_TemplateTemplate.H              | 14 +++++------
 .../template/_TemplateTemplateI.H             |  1 -
 14 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/bin/foamNewBC b/bin/foamNewBC
index 5b5384a9cb6..67bfad41ac6 100755
--- a/bin/foamNewBC
+++ b/bin/foamNewBC
@@ -207,7 +207,7 @@ do
             sed -i \
                 -e '/^template<class Type>$/d' \
                 -e 's/this->//g' \
-                -e 's/\.template[\t ]*\([a-Z]\)/\.\1/g' \
+                -e 's/\.template[\t ]*\([A-Za-z]\)/\.\1/g' \
                 -e '/#ifdef NoRepository/,/\/\/ */d' \
                 ${NAME}/${NEWFILE}
             ;;
diff --git a/etc/codeTemplates/BC/BC.C b/etc/codeTemplates/BC/BC.C
index a36fd713afa..beeb273e14c 100644
--- a/etc/codeTemplates/BC/BC.C
+++ b/etc/codeTemplates/BC/BC.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) YEAR YEAR AUTHOR,AFFILIATION
+    Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -51,7 +51,7 @@ CONSTRUCT
 )
 :
     PARENT(p, iF),
-    scalarData_(0.0),
+    scalarData_(0),
     data_(Zero),
     fieldData_(p.size(), Zero),
     timeVsData_(),
@@ -61,7 +61,7 @@ CONSTRUCT
 {
     this->refValue() = Zero;
     this->refGrad() = Zero;
-    this->valueFraction() = 0.0;
+    this->valueFraction() = Zero;
 }
 
 
@@ -84,7 +84,7 @@ CONSTRUCT
     boolData_(false)
 {
     this->refGrad() = Zero;
-    this->valueFraction() = 0.0;
+    this->valueFraction() = Zero;
 
     this->refValue() = FIELD("fieldData", dict, p.size());
     FVPATCHF::operator=(this->refValue());
@@ -116,7 +116,7 @@ CONSTRUCT
     scalarData_(ptf.scalarData_),
     data_(ptf.data_),
     fieldData_(ptf.fieldData_, mapper),
-    timeVsData_(ptf.timeVsData_, false),
+    timeVsData_(ptf.timeVsData_.clone()),
     wordData_(ptf.wordData_),
     labelData_(-1),
     boolData_(ptf.boolData_)
@@ -134,7 +134,7 @@ CONSTRUCT
     scalarData_(ptf.scalarData_),
     data_(ptf.data_),
     fieldData_(ptf.fieldData_),
-    timeVsData_(ptf.timeVsData_, false),
+    timeVsData_(ptf.timeVsData_.clone()),
     wordData_(ptf.wordData_),
     labelData_(-1),
     boolData_(ptf.boolData_)
@@ -153,7 +153,7 @@ CONSTRUCT
     scalarData_(ptf.scalarData_),
     data_(ptf.data_),
     fieldData_(ptf.fieldData_),
-    timeVsData_(ptf.timeVsData_, false),
+    timeVsData_(ptf.timeVsData_.clone()),
     wordData_(ptf.wordData_),
     labelData_(-1),
     boolData_(ptf.boolData_)
diff --git a/etc/codeTemplates/BC/BC.H b/etc/codeTemplates/BC/BC.H
index 636cad11134..8b1fb217963 100644
--- a/etc/codeTemplates/BC/BC.H
+++ b/etc/codeTemplates/BC/BC.H
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) YEAR YEAR AUTHOR,AFFILIATION
+    Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -47,12 +47,12 @@ Description
 
 Usage
     \table
-        Property   | Description                  | Req'd? | Default
-        scalarData | single scalar value          | yes    |
-        data       | single TYPE value          | yes    |
-        fieldData  | TYPE field across patch    | yes    |
-        timeVsData | TYPE function of time      | yes    |
-        wordData   | word, eg name of data object | no     | wordDefault
+        Property   | Description                  | Req'd | Default
+        scalarData | single scalar value          | yes |
+        data       | single TYPE value          | yes |
+        fieldData  | TYPE field across patch    | yes |
+        timeVsData | TYPE function of time      | yes |
+        wordData   | word, eg name of data object | no  | wordDefault
     \endtable
 
     Example of the boundary condition specification:
@@ -97,7 +97,7 @@ class CONSTRUCT
 :
     public PARENT
 {
-    // Private data
+    // Private Data
 
         //- Single valued scalar quantity, e.g. a coefficient
         scalar scalarData_;
@@ -152,8 +152,7 @@ public:
             const dictionary&
         );
 
-        //- Construct by mapping given BASETypeFvPatchField
-        //  onto a new patch
+        //- Construct by mapping onto a new patch
         CONSTRUCT
         (
             const CLASS&,
@@ -162,7 +161,7 @@ public:
             const fvPatchFieldMapper&
         );
 
-        //- Construct as copy
+        //- Copy construct
         CONSTRUCT
         (
             const CLASS&
@@ -201,7 +200,7 @@ public:
         }
 
 
-    // Member functions
+    // Member Functions
 
         // Mapping functions
 
@@ -226,7 +225,7 @@ public:
 
 
         //- Write
-        virtual void write(Ostream&) const;
+        virtual void write(Ostream& os) const;
 };
 
 
diff --git a/etc/codeTemplates/BC/BCs.C b/etc/codeTemplates/BC/BCs.C
index 932b47f2127..c45f74178b4 100644
--- a/etc/codeTemplates/BC/BCs.C
+++ b/etc/codeTemplates/BC/BCs.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) YEAR YEAR AUTHOR,AFFILIATION
+    Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/etc/codeTemplates/BC/BCs.H b/etc/codeTemplates/BC/BCs.H
index 68383803d77..f72f1bdd33d 100644
--- a/etc/codeTemplates/BC/BCs.H
+++ b/etc/codeTemplates/BC/BCs.H
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) YEAR YEAR AUTHOR,AFFILIATION
+    Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/etc/codeTemplates/BC/BCsFwd.H b/etc/codeTemplates/BC/BCsFwd.H
index 14ff789164c..4dce0ebca40 100644
--- a/etc/codeTemplates/BC/BCsFwd.H
+++ b/etc/codeTemplates/BC/BCsFwd.H
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) YEAR YEAR AUTHOR,AFFILIATION
+    Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/etc/codeTemplates/app/app.C b/etc/codeTemplates/app/app.C
index 49ae9b0f314..4851af38851 100644
--- a/etc/codeTemplates/app/app.C
+++ b/etc/codeTemplates/app/app.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) YEAR YEAR AUTHOR,AFFILIATION
+    Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C
index de80fee7a39..79bc49b9ed5 100644
--- a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C
+++ b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) YEAR YEAR AUTHOR,AFFILIATION
+    Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H
index f8c036fe575..e56ae695385 100644
--- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H
+++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H
@@ -46,7 +46,7 @@ ${codeInclude}
 namespace Foam
 {
 
-// Forward declarations
+// Forward Declarations
 class fvMesh;
 
 /*---------------------------------------------------------------------------*\
diff --git a/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C b/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C
index e6cb9ceb6ca..07606e89c3e 100644
--- a/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C
+++ b/etc/codeTemplates/functionObject/FUNCTIONOBJECT.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) YEAR YEAR AUTHOR,AFFILIATION
+    Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
diff --git a/etc/codeTemplates/source/_Template.H b/etc/codeTemplates/source/_Template.H
index 4cbc6bb3af2..e1bc7275806 100644
--- a/etc/codeTemplates/source/_Template.H
+++ b/etc/codeTemplates/source/_Template.H
@@ -45,11 +45,11 @@ SourceFiles
 namespace Foam
 {
 
-// Forward declarations
+// Forward Declarations
 class Istream;
 class Ostream;
-
 class CLASSNAME;
+
 Istream& operator>>(Istream&, CLASSNAME&);
 Ostream& operator<<(Ostream&, const CLASSNAME&);
 
@@ -87,7 +87,7 @@ public:
 
     // Generated Methods
 
-//        //- Construct null
+//        //- Default construct
 //        CLASSNAME() = default;
 //
 //        //- Copy construct
@@ -99,22 +99,22 @@ public:
 
     // Constructors
 
-        //- Construct null
+        //- Default construct
         CLASSNAME();
 
         //- Construct from components
         CLASSNAME(const dataType& data);
 
-        //- Construct from Istream
-        CLASSNAME(Istream& is);
-
-        //- Construct as copy
+        //- Copy construct
         CLASSNAME(const CLASSNAME&);
 
+        //- Construct from Istream
+        explicit CLASSNAME(Istream& is);
+
 
     // Selectors
 
-        //- Select null constructed
+        //- Select default constructed
         static autoPtr<CLASSNAME> New();
 
 
diff --git a/etc/codeTemplates/source/_TemplateI.H b/etc/codeTemplates/source/_TemplateI.H
index 1eaba0830c8..89c847f54a5 100644
--- a/etc/codeTemplates/source/_TemplateI.H
+++ b/etc/codeTemplates/source/_TemplateI.H
@@ -25,7 +25,6 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
diff --git a/etc/codeTemplates/template/_TemplateTemplate.H b/etc/codeTemplates/template/_TemplateTemplate.H
index 7d6500b666e..9efb9424783 100644
--- a/etc/codeTemplates/template/_TemplateTemplate.H
+++ b/etc/codeTemplates/template/_TemplateTemplate.H
@@ -45,7 +45,7 @@ SourceFiles
 namespace Foam
 {
 
-// Forward declarations
+// Forward Declarations
 class someClass;
 
 template<TemplateClassArgument>
@@ -90,7 +90,7 @@ public:
 
     // Generated Methods
 
-//        //- Construct null
+//        //- Default construct
 //        CLASSNAME() = default;
 //
 //        //- Copy construct
@@ -102,22 +102,22 @@ public:
 
     // Constructors
 
-        //- Construct null
+        //- Default construct
         CLASSNAME();
 
         //- Construct from components
         CLASSNAME(const dataType& data);
 
-        //- Construct from Istream
-        CLASSNAME(Istream& is);
-
         //- Construct as copy
         CLASSNAME(const CLASSNAME<TemplateArgument>&);
 
+        //- Construct from Istream
+        explicit CLASSNAME(Istream& is);
+
 
     // Selectors
 
-        //- Select null constructed
+        //- Select default constructed
         static autoPtr<CLASSNAME<TemplateArgument>> New();
 
 
diff --git a/etc/codeTemplates/template/_TemplateTemplateI.H b/etc/codeTemplates/template/_TemplateTemplateI.H
index 1eaba0830c8..89c847f54a5 100644
--- a/etc/codeTemplates/template/_TemplateTemplateI.H
+++ b/etc/codeTemplates/template/_TemplateTemplateI.H
@@ -25,7 +25,6 @@ License
 
 \*---------------------------------------------------------------------------*/
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
-- 
GitLab