View Issue Details

IDProjectCategoryView StatusLast Update
0002444OpenFOAMPatchpublic2017-01-28 18:12
Reporterwyldckat Assigned Tohenry  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0002444: Outdated check for 'UName' checks in 2 streamLine classes
DescriptionIn commit e22c65dd8e70 ( https://github.com/OpenFOAM/OpenFOAM-dev/commit/e22c65dd8e70d38fa6f6f8163dd8261d4fc75e20 ), on the 21st of May 2016, it was finally standardized which would be the naming convention for assigning names to the standard names, e.g. 'UName' keyword is now simply defined as 'U'.

But while I was checking the conventions used for warning and errors in function objects, for fixing report #2441, I stumbled upon a weird situation with at least two files within 'src/functionObjects/field':

  - wallBoundedStreamLine/wallBoundedStreamLine.C
  - streamLine/streamLine.C

Both of them have the following piece of code in 'read()':

    if (dict.found("U"))
    {
        dict.lookup("U") >> UName_;
    }
    else
    {
        UName_ = "U";
        if (dict.found("U"))
        {
            IOWarningInFunction(dict)
                << "Using deprecated entry \"U\"."
                << " Please use \"UName\" instead."
                << endl;
            dict.lookup("U") >> UName_;
        }
    }

After looking up a bit at the OpenFOAM history trees, it seems like there was a previous transition to using an explicit 'UName' convention, but possibly ended up not being the standard convention. But on the aforementioned commit, semi-automated updates were made and resulted in this stale and fairly inconsistent check.

The additional problem here is that it will not properly react when 'U' is undefined, it instead assume it's named 'U', which is inconsistent with the documentation (required: yes).


Given that the description states that 'U' is a required keyword, I will attach in a few minutes a patch (need to check compatibility between dev and 4.x on these two) that simply replaces this outdated check+parse and simply use a single line to do the lookup without a default.
I'm not suggesting a revised backward compatibility check, because I couldn't quickly find any evidence that this was done for OpenFOAM 4.0 to provide these checks, so now it's a bit too late to go adding them all around.
TagsNo tags attached.

Activities

wyldckat

2017-01-28 16:54

updater  

bug2444_v1.patch (3,894 bytes)   
diff --git a/src/functionObjects/field/streamLine/streamLine.C b/src/functionObjects/field/streamLine/streamLine.C
index 252b4d6..0c66a5f 100644
--- a/src/functionObjects/field/streamLine/streamLine.C
+++ b/src/functionObjects/field/streamLine/streamLine.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -311,22 +311,7 @@ bool Foam::functionObjects::streamLine::read(const dictionary& dict)
     Info<< type() << " " << name() << ":" << nl;
 
     dict.lookup("fields") >> fields_;
-    if (dict.found("U"))
-    {
-        dict.lookup("U") >> UName_;
-    }
-    else
-    {
-        UName_ = "U";
-        if (dict.found("U"))
-        {
-            IOWarningInFunction(dict)
-                << "Using deprecated entry \"U\"."
-                << " Please use \"UName\" instead."
-                << endl;
-            dict.lookup("U") >> UName_;
-        }
-    }
+    dict.lookup("U") >> UName_;
 
     if (findIndex(fields_, UName_) == -1)
     {
diff --git a/src/functionObjects/field/streamLine/streamLine.H b/src/functionObjects/field/streamLine/streamLine.H
index 008036b..7c0995e 100644
--- a/src/functionObjects/field/streamLine/streamLine.H
+++ b/src/functionObjects/field/streamLine/streamLine.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -41,16 +41,20 @@ Description
         writeControl    writeTime;
 
         setFormat       vtk;
+        U               U;
         trackForward    yes;
+
         fields
         (
             U
             p
         );
+
         lifeTime        10000;
         trackLength     1e-3;
         nSubCycle       5;
         cloudName       particleTracks;
+
         seedSampleSet   uniform;
         uniformCoeffs
         {
diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
index e918fcf..7fd4729 100644
--- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
+++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -427,24 +427,7 @@ bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict)
     Info<< type() << " " << name() << ":" << nl;
 
     dict.lookup("fields") >> fields_;
-    if (dict.found("U"))
-    {
-        dict.lookup("U") >> UName_;
-    }
-    else
-    {
-        UName_ = "U";
-        if (dict.found("U"))
-        {
-            IOWarningInFunction
-            (
-                dict
-            )   << "Using deprecated entry \"U\"."
-                << " Please use \"UName\" instead."
-                << endl;
-            dict.lookup("U") >> UName_;
-        }
-    }
+    dict.lookup("U") >> UName_;
 
     if (findIndex(fields_, UName_) == -1)
     {
bug2444_v1.patch (3,894 bytes)   

wyldckat

2017-01-28 16:54

updater  

bug2444_dev_v1.tar.gz (7,927 bytes)

wyldckat

2017-01-28 16:54

updater  

bug2444_4.x_v1.tar.gz (8,050 bytes)

wyldckat

2017-01-28 16:59

updater   ~0007686

Attached are the following files:

 - "bug2444_v1.patch" - This is a patch file that is common to both 4.x and dev, for easier pre-visualization of the proposed changes.

 - "bug2444_4.x_v1.tar.gz" - package with the modified files for OpenFOAM 4.x, commit 8ff56d46b9c.

 - "bug2444_dev_v1.tar.gz" - package with the modified files for OpenFOAM dev, commit 0dd9616dcf30.

The modified files are:

 - src/functionObjects/field/streamLine/streamLine.H

   - Revised the description to be similar to 'wallBoundedStreamLine.H' for easier readability.
   - Included the 'U' line on the example, because it's required.

 - src/functionObjects/field/streamLine/streamLine.C
 - src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C

   - Replaced the broken check block for the single line with the lookup for 'U'.

henry

2017-01-28 18:12

manager   ~0007689

Thanks Bruno

Resolved in OpenFOAM-4.x by commit a1a70270f0a93737fa161d212fc66f50eb9fc89a

Resolved in OpenFOAM-dev by commit 4d9a8870c65f168ec895f365a810e7119fe2b0bf

Issue History

Date Modified Username Field Change
2017-01-28 16:45 wyldckat New Issue
2017-01-28 16:54 wyldckat File Added: bug2444_v1.patch
2017-01-28 16:54 wyldckat File Added: bug2444_dev_v1.tar.gz
2017-01-28 16:54 wyldckat File Added: bug2444_4.x_v1.tar.gz
2017-01-28 16:54 wyldckat Product Version dev => 4.x
2017-01-28 16:59 wyldckat Note Added: 0007686
2017-01-28 16:59 wyldckat Assigned To => henry
2017-01-28 16:59 wyldckat Status new => assigned
2017-01-28 18:12 henry Status assigned => resolved
2017-01-28 18:12 henry Resolution open => fixed
2017-01-28 18:12 henry Fixed in Version => 4.x
2017-01-28 18:12 henry Note Added: 0007689