View Issue Details

IDProjectCategoryView StatusLast Update
0001762OpenFOAM[All Projects] Bugpublic2015-06-29 16:46
ReporterTimm SeverinAssigned Tohenry 
PrioritynoneSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSUbuntuOS Version14.04
Product Version 
Fixed in Version 
Summary0001762: newTimes option for yPlusRAS
DescriptionyPlusRAS in default mode calculates yPlus for all times, and when executed again overwrites the old. While it is not exactly a problem, things could be sped up with a new option -newTimes (comparable to the one in reconstructPar e.g.).

Attached patch would add this option to the utility.
Additional InformationA quite similar patch would probably be usable for yPlusLES, but I don't use it, so I can't supply one. Sry ;).
TagsNo tags attached.

Activities

Timm Severin

2015-06-23 14:26

reporter  

yPlusRAS.patch (3,053 bytes)
--- yPlusRAS.C	2015-06-23 15:09:20.913501500 +0200
+++ yPlusRAS.c.new	2015-06-23 15:12:33.026454137 +0200
@@ -190,6 +190,12 @@
         "compressible",
         "calculate compressible y+"
     );
+    
+    argList::addBoolOption
+    (
+        "newTimes",
+        "only calculate if not already existent"
+    );
 
     #include "setRootCase.H"
     #include "createTime.H"
@@ -197,6 +203,8 @@
     #include "createNamedMesh.H"
 
     const bool compressible = args.optionFound("compressible");
+    
+    const bool newTimes = args.optionFound("newTimes");
 
     forAll(timeDirs, timeI)
     {
@@ -212,52 +220,56 @@
             Info<< "Writing wall distance to field " << y.name() << nl << endl;
             y.write();
         }
-
-        volScalarField yPlus
+        
+        IOobject yPlusHeader
         (
-            IOobject
-            (
-                "yPlus",
-                runTime.timeName(),
-                mesh,
-                IOobject::NO_READ,
-                IOobject::NO_WRITE
-            ),
-            mesh,
-            dimensionedScalar("yPlus", dimless, 0.0)
-        );
-
-        IOobject UHeader
-        (
-            "U",
+            "yPlus",
             runTime.timeName(),
             mesh,
-            IOobject::MUST_READ,
+            IOobject::READ_IF_PRESENT,
             IOobject::NO_WRITE
         );
-
-        if (UHeader.headerOk())
+        
+        if (newTimes && yPlusHeader.headerOk())
         {
-            Info<< "Reading field U\n" << endl;
-            volVectorField U(UHeader, mesh);
+            Info<< "Skipping this time dir, yPlus already calculated" << endl;
+        }
+        else
+        {
+            volScalarField yPlus(yPlusHeader, mesh, dimensionedScalar("yPlus", dimless, 0.0));
+
+            IOobject UHeader
+            (
+                "U",
+                runTime.timeName(),
+                mesh,
+                IOobject::MUST_READ,
+                IOobject::NO_WRITE
+            );
 
-            if (compressible)
+            if (UHeader.headerOk())
             {
-                calcCompressibleYPlus(mesh, runTime, U, yPlus);
+                Info<< "Reading field U\n" << endl;
+                volVectorField U(UHeader, mesh);
+
+                if (compressible)
+                {
+                    calcCompressibleYPlus(mesh, runTime, U, yPlus);
+                }
+                else
+                {
+                    calcIncompressibleYPlus(mesh, runTime, U, yPlus);
+                }
             }
             else
             {
-                calcIncompressibleYPlus(mesh, runTime, U, yPlus);
+                Info<< "    no U field" << endl;
             }
-        }
-        else
-        {
-            Info<< "    no U field" << endl;
-        }
 
-        Info<< "Writing yPlus to field " << yPlus.name() << nl << endl;
+            Info<< "Writing yPlus to field " << yPlus.name() << nl << endl;
 
-        yPlus.write();
+            yPlus.write();
+        }
     }
 
     Info<< "End\n" << endl;
yPlusRAS.patch (3,053 bytes)

henry

2015-06-23 21:13

manager   ~0004984

I agree that this would be useful functionality but rather than implement it specifically for yPlusRAS it would be better to create a more general structure which can be used in all post-processing tools which generate fields.

One option would be to create an additional select function for timeSelector which takes a file name as an argument and if the -newTimes option is specified the existence of the specified file in each time directory is checked.

Timm Severin

2015-06-24 09:31

reporter   ~0004985

This would probably be more useful than change every tool on it's own. I messed with my local version of the timeSelector before, and looked at it again, but I'm afraid I'm not good enough to change this on the fly.

Furthermore there would be the question on how to handle multiple fields. There are two ways I could think of, either the new selector would have to return a list of lists (ugly, and inconsistent with current implementation), or the function only accepts one name and has to be called multiple times, resulting in overhead and additional work on the tools side. I don't really know what would make sense, or if there is a good solution I haven't thought of.

henry

2015-06-24 09:44

manager   ~0004986

Most of the post-processing tools generate a single field so the issue of multiple fields isn't that important. However, it would be possible to provide a list of field names to check the existance of and process the time if any are missing.

user4

2015-06-24 09:47

  ~0004987

Or split it:
- have IOobjectList (or findInstance) functionality to find all occurances of selected objectnames (e.g. supplied as a wordHashSet)
- extract the instantList
- pass the instantList in to timeSelector to suppress these times.

henry

2015-06-24 10:10

manager   ~0004988

The advantage and disadvantage with using IOobject functionality is that file existance AND type would be checked by reading the header of each file whereas simple file existance is probably sufficient and simpler.

I have added experimental support for -newTimes in timeSelector and yPlus in OpenFOAM-dev:

    timeSelector: Add support for -newTimes option
    
        //- Return the set of times selected based on the argList options
        // including support for \b -newTimes in which times are selected
        // if the file <fName> does not exist in the time directory.
        // Also set the runTime to the first instance or the
        // \c constant/ directory if no instances are specified or available
        static instantList select
        (
            Time& runTime,
            const argList& args,
            const word& fName
        );
    
    This is experimental functionality and currently on test in the yPlus
    post-processing utility.

If this proves sufficient, useful and appropriate I will make the same change to the other post-processing applications.

Issue History

Date Modified Username Field Change
2015-06-23 14:26 Timm Severin New Issue
2015-06-23 14:26 Timm Severin File Added: yPlusRAS.patch
2015-06-23 21:13 henry Note Added: 0004984
2015-06-24 09:31 Timm Severin Note Added: 0004985
2015-06-24 09:44 henry Note Added: 0004986
2015-06-24 09:47 user4 Note Added: 0004987
2015-06-24 10:10 henry Note Added: 0004988
2015-06-29 16:46 henry Status new => resolved
2015-06-29 16:46 henry Resolution open => fixed
2015-06-29 16:46 henry Assigned To => henry