From 67e8bd8bf9500f621e57069e37b7cc71450d64c1 Mon Sep 17 00:00:00 2001
From: Henry <Henry>
Date: Fri, 13 Mar 2015 22:14:08 +0000
Subject: [PATCH] shallowWaterFoam: Read hU rather than U to support complex
 e.g. time-varying BCs Disadvantage is that the BC values have to be specified
 in terms of hU rather than U.  The alternative would be to add complex code
 to map h and U BCs into the equivalent for hU. Resolves bug-report
 http://www.openfoam.org/mantisbt/view.php?id=1566

---
 .../shallowWaterFoam/createFields.H           |  21 +-
 .../shallowWaterFoam/squareBump/0/U           |  44 --
 .../shallowWaterFoam/squareBump/0/hU          | 448 ++++++++++++++++++
 .../squareBump/system/setFieldsDict           |   3 +-
 4 files changed, 461 insertions(+), 55 deletions(-)
 delete mode 100644 tutorials/incompressible/shallowWaterFoam/squareBump/0/U
 create mode 100644 tutorials/incompressible/shallowWaterFoam/squareBump/0/hU

diff --git a/applications/solvers/incompressible/shallowWaterFoam/createFields.H b/applications/solvers/incompressible/shallowWaterFoam/createFields.H
index 05dce1b3210..3bcfb683526 100644
--- a/applications/solvers/incompressible/shallowWaterFoam/createFields.H
+++ b/applications/solvers/incompressible/shallowWaterFoam/createFields.H
@@ -26,12 +26,12 @@ volScalarField h0
     dimensionedScalar("h0", dimLength, 0.0)
 );
 
-Info<< "Reading field U\n" << endl;
-volVectorField U
+Info<< "Creating field hU\n" << endl;
+volVectorField hU
 (
     IOobject
     (
-        "U",
+        "hU",
         runTime.timeName(),
         mesh,
         IOobject::MUST_READ,
@@ -40,17 +40,18 @@ volVectorField U
     mesh
 );
 
-Info<< "Creating field hU\n" << endl;
-volVectorField hU
+Info<< "Reading field U\n" << endl;
+volVectorField U
 (
     IOobject
     (
-        "hU",
+        "U",
         runTime.timeName(),
-        mesh
+        mesh,
+        IOobject::NO_READ,
+        IOobject::AUTO_WRITE
     ),
-    h*U,
-    U.boundaryField().types()
+    hU/h
 );
 
 Info<< "Creating field hTotal for post processing\n" << endl;
@@ -68,7 +69,7 @@ volScalarField hTotal
 );
 hTotal.write();
 
-    #include "createPhi.H"
+#include "createPhi.H"
 
 Info<< "Creating Coriolis Force" << endl;
 const dimensionedVector F("F", ((2.0*Omega) & gHat)*gHat);
diff --git a/tutorials/incompressible/shallowWaterFoam/squareBump/0/U b/tutorials/incompressible/shallowWaterFoam/squareBump/0/U
deleted file mode 100644
index 75b2a00ac26..00000000000
--- a/tutorials/incompressible/shallowWaterFoam/squareBump/0/U
+++ /dev/null
@@ -1,44 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
-| =========                 |                                                 |
-| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  dev                                   |
-|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
-|    \\/     M anipulation  |                                                 |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
-    version     2.0;
-    format      ascii;
-    class       volVectorField;
-    location    "0";
-    object      U;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-dimensions      [0 1 -1 0 0 0 0];
-
-internalField   uniform (0.1 0 0);
-
-boundaryField
-{
-    sides
-    {
-        type            slip;
-    }
-    inlet
-    {
-        type            fixedValue;
-        value           uniform (0.1 0 0);
-    }
-    outlet
-    {
-        type            zeroGradient;
-    }
-    frontAndBack
-    {
-        type            empty;
-    }
-}
-
-
-// ************************************************************************* //
diff --git a/tutorials/incompressible/shallowWaterFoam/squareBump/0/hU b/tutorials/incompressible/shallowWaterFoam/squareBump/0/hU
new file mode 100644
index 00000000000..134b60f778a
--- /dev/null
+++ b/tutorials/incompressible/shallowWaterFoam/squareBump/0/hU
@@ -0,0 +1,448 @@
+/*--------------------------------*- C++ -*----------------------------------*\
+| =========                 |                                                 |
+| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
+|  \\    /   O peration     | Version:  dev                                   |
+|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
+|    \\/     M anipulation  |                                                 |
+\*---------------------------------------------------------------------------*/
+FoamFile
+{
+    version     2.0;
+    format      ascii;
+    class       volVectorField;
+    location    "0";
+    object      hU;
+}
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+dimensions      [0 2 -1 0 0 0 0];
+
+internalField   nonuniform List<vector>
+400
+(
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.0009 0 0)
+(0.0009 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.0009 0 0)
+(0.0009 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+(0.001 0 0)
+)
+;
+
+boundaryField
+{
+    sides
+    {
+        type            slip;
+    }
+    inlet
+    {
+        type            fixedValue;
+        value           uniform (0.001 0 0);
+    }
+    outlet
+    {
+        type            zeroGradient;
+    }
+    frontAndBack
+    {
+        type            empty;
+    }
+}
+
+
+// ************************************************************************* //
diff --git a/tutorials/incompressible/shallowWaterFoam/squareBump/system/setFieldsDict b/tutorials/incompressible/shallowWaterFoam/squareBump/system/setFieldsDict
index ab438aafa7e..bd0c70dbff6 100644
--- a/tutorials/incompressible/shallowWaterFoam/squareBump/system/setFieldsDict
+++ b/tutorials/incompressible/shallowWaterFoam/squareBump/system/setFieldsDict
@@ -18,7 +18,7 @@ defaultFieldValues
 (
     volScalarFieldValue h0 0
     volScalarFieldValue h 0.01
-    volVectorFieldValue U (0.1 0 0)
+    volVectorFieldValue hU (0.001 0 0)
 );
 
 regions
@@ -31,6 +31,7 @@ regions
         (
             volScalarFieldValue h0 0.001
             volScalarFieldValue h  0.009
+            volVectorFieldValue hU  (0.0009 0 0)
         );
     }
 );
-- 
GitLab