From 65831d8103aeea2596c5d4576fcd57b5307f667b Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Wed, 20 Dec 2017 13:58:59 +0100
Subject: [PATCH] STYLE: add End info output for solver and utilities

- for easier parsing of tutorial output etc.
---
 .../implicitSolver/faSavageHutterFoam.C       | 100 ++++++++++--------
 .../releaseAreaMapping/releaseAreaMapping.C   |  34 +++---
 applications/utilities/slopeMesh/slopeMesh.C  |  29 ++---
 3 files changed, 89 insertions(+), 74 deletions(-)

diff --git a/applications/solvers/implicitSolver/faSavageHutterFoam.C b/applications/solvers/implicitSolver/faSavageHutterFoam.C
index 7017c43..4e56cb8 100644
--- a/applications/solvers/implicitSolver/faSavageHutterFoam.C
+++ b/applications/solvers/implicitSolver/faSavageHutterFoam.C
@@ -48,35 +48,35 @@ Author
 
 int main(int argc, char *argv[])
 {
-#   include "setRootCase.H"
-#   include "createTime.H"
-#   include "createMesh.H"
-#   include "createFaMesh.H"
-#   include "readGravitationalAcceleration.H"
-#   include "createFaFields.H"
-#   include "readTransportProperties.H"
-#   include "createFvFields.H"
-#   include "createTimeControls.H"
-
-    Info << "\nStarting time loop\n" << endl;
-
-#       include "readSolutionControls.H"
-
-        Info << endl
-             << "Numerical settings" << endl
-             << "    max number of iterations " << nCorr << endl
-             << "    min number of iterations " << minCorr << endl
-             << "    TOL h " << hResidualMax << endl
-             << "    TOL Us " << UsResidualMax << endl << endl;
+    #include "setRootCase.H"
+    #include "createTime.H"
+    #include "createMesh.H"
+    #include "createFaMesh.H"
+    #include "readGravitationalAcceleration.H"
+    #include "createFaFields.H"
+    #include "readTransportProperties.H"
+    #include "createFvFields.H"
+    #include "createTimeControls.H"
+
+    Info<< "\nStarting time loop\n" << endl;
+
+    #include "readSolutionControls.H"
+
+    Info<< endl
+        << "Numerical settings" << endl
+        << "    max number of iterations " << nCorr << endl
+        << "    min number of iterations " << minCorr << endl
+        << "    TOL h " << hResidualMax << endl
+        << "    TOL Us " << UsResidualMax << endl << endl;
 
     Switch initDeltaT =
         runTime.controlDict().lookup("initDeltaT");
 
     if (initDeltaT)
     {
-        Info << "Initializing Delta T" << endl;
-#       include "readTimeControls.H"
-#       include "surfaceCourantNo.H"
+        Info<< "Initializing Delta T" << endl;
+        #include "readTimeControls.H"
+        #include "surfaceCourantNo.H"
         runTime.setDeltaT(
             min(maxCo/(CoNum + SMALL)*runTime.deltaT().value(), maxDeltaT)
         );
@@ -86,19 +86,19 @@ int main(int argc, char *argv[])
 
     while (runTime.run())
     {
-#       include "readSolutionControls.H"
-#       include "readTimeControls.H"
-#       include "surfaceCourantNo.H"
-#       include "setDeltaT.H"
+        #include "readSolutionControls.H"
+        #include "readTimeControls.H"
+        #include "surfaceCourantNo.H"
+        #include "setDeltaT.H"
 
         runTime++;
 
-        Info << "Time = " << runTime.timeName() << nl << endl;
+        Info<< "Time = " << runTime.timeName() << nl << endl;
         final = false;
 
         for (int iCorr = 0; ; iCorr++)
         {
-#           include "calcBasalstress.H"
+            #include "calcBasalstress.H"
 
             const areaVectorField & tauSc = friction->tauSc();
             const areaScalarField & tauSp = friction->tauSp();
@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
                 }
                 if (dryCellCount  > 0)
                 {
-                    Info << "Number of dry cells = " << dryCellCount << endl;
+                    Info<< "Number of dry cells = " << dryCellCount << endl;
                 }
             }
 
@@ -237,27 +237,34 @@ int main(int argc, char *argv[])
             {
                 if (hResidual.initialResidual() < hResidualMax && mag(UsResidual.initialResidual()) < UsResidualMax)
                 {
-                    Info << "reached residual in h = "
-                         << hResidual.initialResidual()
-                         << " < " << hResidualMax
-                         << " and in Us = "
-                         << UsResidual.initialResidual()
-                         << " < " << UsResidualMax
-                         << ", stopping loop!" << endl;
+                    Info<< "reached residual in h = "
+                        << hResidual.initialResidual()
+                        << " < " << hResidualMax
+                        << " and in Us = "
+                        << UsResidual.initialResidual()
+                        << " < " << UsResidualMax
+                        << ", stopping loop!" << endl;
                 }
                 else
                 {
-                    Info << "Reached maximum numbers of iterations, stopping loop!" << endl;
+                    Info<< "Reached maximum numbers of iterations, "
+                        << "stopping loop!" << endl;
                 }
                 break;
             }
-            if ((hResidual.initialResidual() < hResidualMax && mag(UsResidual.initialResidual()) < UsResidualMax &&  iCorr >= minCorr) || iCorr >= nCorr)
+
+            if
+            (
+                (
+                    hResidual.initialResidual() < hResidualMax
+                 && mag(UsResidual.initialResidual()) < UsResidualMax
+                 && iCorr >= minCorr
+                )
+             || iCorr >= nCorr
+            )
             {
                 final = true;
             }
-
-
-
         }
 
         if (runTime.outputTime())
@@ -270,13 +277,16 @@ int main(int argc, char *argv[])
             runTime.write();
         }
 
-
-        Info << "ExecutionTime = "
+        Info<< "ExecutionTime = "
             << scalar(runTime.elapsedCpuTime())
             << " s\n" << endl << endl;
     }
 
-    return(0);
+
+    Info<< nl << "End" << endl;
+
+    return 0;
 }
 
+
 // ************************************************************************* //
diff --git a/applications/utilities/releaseAreaMapping/releaseAreaMapping.C b/applications/utilities/releaseAreaMapping/releaseAreaMapping.C
index 0b72d0e..211551b 100644
--- a/applications/utilities/releaseAreaMapping/releaseAreaMapping.C
+++ b/applications/utilities/releaseAreaMapping/releaseAreaMapping.C
@@ -41,10 +41,10 @@ Author
 
 int main(int argc, char *argv[])
 {
-#   include "setRootCase.H"
-#   include "createTime.H"
-#   include "createMesh.H"
-#   include "createFaMesh.H"
+    #include "setRootCase.H"
+    #include "createTime.H"
+    #include "createMesh.H"
+    #include "createFaMesh.H"
 
     areaVectorField c = aMesh.areaCentres();
     areaVectorField n = aMesh.faceAreaNormals();
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
 
 
 
-        Info << "Reading field " << fieldNames[fieldsI] << endl;
+        Info<< "Reading field " << fieldNames[fieldsI] << endl;
 
         areaScalarField f
         (
@@ -106,13 +106,14 @@ int main(int argc, char *argv[])
 
         if (fdefault.value() > -1e99)
         {
-            Info << "Setting field " << fieldNames[fieldsI] << " to default value" << endl;
+            Info<< "Setting field " << fieldNames[fieldsI]
+                << " to default value" << endl;
             f.ref() = fdefault;
         }
         string str = fieldNames[fieldsI];
         str[0] = toupper(str[0]);
 
-        Info << "Creating field " << str << endl;
+        Info<< "Creating field " << str << endl;
 
         volScalarField F
         (
@@ -132,7 +133,7 @@ int main(int argc, char *argv[])
         volSurfaceMapping vsm(aMesh);
 
 
-        Info << "Reading regions" << endl;
+        Info<< "Reading regions" << endl;
 
         const PtrList<entry> regions
         (
@@ -146,7 +147,7 @@ int main(int argc, char *argv[])
         {
             const entry& regionInfo = regions[areaI];
 
-            Info << "processing region " << regions[areaI].keyword() << endl;
+            Info<< "processing region " << regions[areaI].keyword() << endl;
             if (!regionInfo.isDict())
             {
                 FatalIOErrorIn("releaseAreaMapping.C", releaseArea)
@@ -246,10 +247,10 @@ int main(int argc, char *argv[])
                     projection = n&vector(0, 0, -1);
                 }
 
-                Info << "linear function with" << endl
-                     << "     x0 = " << x0 << ", dfdx = " << fx << endl
-                     << "     y0 = " << y0 << ", dfdy = " << fy << endl
-                     << "     z0 = " << z0 << ", dfdz = " << fz << endl;
+                Info<< "linear function with" << nl
+                    << "     x0 = " << x0 << ", dfdx = " << fx << nl
+                    << "     y0 = " << y0 << ", dfdy = " << fy << nl
+                    << "     z0 = " << z0 << ", dfdz = " << fz << endl;
 
                 points.resize(vertices.size());
 
@@ -291,16 +292,17 @@ int main(int argc, char *argv[])
             }
         }
 
-        Info << "Writing fields" << endl;
+        Info<< "Writing fields" << endl;
 
         vsm.mapToVolume(f, F.boundaryFieldRef());
 
         f.write();
         F.write();
-
     }
 
-    return(0);
+    Info<< nl << "End" << endl;
+    return 0;
 }
 
+
 // ************************************************************************* //
diff --git a/applications/utilities/slopeMesh/slopeMesh.C b/applications/utilities/slopeMesh/slopeMesh.C
index f5b3e21..8cfbcee 100644
--- a/applications/utilities/slopeMesh/slopeMesh.C
+++ b/applications/utilities/slopeMesh/slopeMesh.C
@@ -40,13 +40,12 @@ Author
 
 int main(int argc, char *argv[])
 {
-#   include "setRootCase.H"
-#   include "createTime.H"
+    #include "setRootCase.H"
+    #include "createTime.H"
 
     const word dictName("slopeMeshDict");
     const word polyMeshDir = polyMesh::meshSubDir;
 
-
     IOdictionary demMeshDict
     (
          IOobject
@@ -75,7 +74,6 @@ int main(int argc, char *argv[])
     );
 
 
-
     label cellCountX, cellCountY;
     scalar minX, maxX, minY, maxY, meshH;
     Switch tri;
@@ -104,10 +102,14 @@ int main(int argc, char *argv[])
     //y-paralell-faces
 
 
-    Info << "creating Mesh with "<< cellCount << " cells, "<< faceCount << " faces and " << pointCount << " points" << endl;
-    Info << "x = [" << minX << ";" << maxX << "] (" << cellCountX << ")" << endl;
-    Info << "y = [" << minY << ";" << maxY << "] (" << cellCountY << ")" << endl;
-    Info << "cellsize = " << dx << "m x " << dy << "m" << endl;
+    Info<< "creating Mesh with "
+        << cellCount << " cells, "
+        << faceCount << " faces and "
+        << pointCount << " points" << nl;
+
+    Info<< "x = [" << minX << ";" << maxX << "] (" << cellCountX << ")" << nl
+        << "y = [" << minY << ";" << maxY << "] (" << cellCountY << ")" << nl
+        << "cellsize = " << dx << "m x " << dy << "m" << endl;
 
 
     pointField points(pointCount);
@@ -203,8 +205,6 @@ int main(int argc, char *argv[])
     }
 
 
-
-
     minXboundary = lf;
 
     //creating x-planes
@@ -362,7 +362,7 @@ int main(int argc, char *argv[])
             << exit(FatalError);
     }
 /*
-    Info << "Points of Interest:" << endl;
+    Info<< "Points of Interest:" << endl;
 
     const PtrList<entry> pois
     (
@@ -391,11 +391,14 @@ int main(int argc, char *argv[])
 
         poiDict.lookup("localPosition") >> localPos;
 
-        Info << poiNames[poiI] << "(" << localPos << ")" << " = " << elevation->X(localPos) << endl;
+        Info<< poiNames[poiI] << "(" << localPos << ")" << " = " << elevation->X(localPos) << endl;
     }*/
 
 
-    return(0);
+    Info<< nl << "End" << endl;
+
+    return 0;
 }
 
+
 // ************************************************************************* //
-- 
GitLab