View Issue Details

IDProjectCategoryView StatusLast Update
0002615OpenFOAMBugpublic2017-07-18 15:27
ReporterArmin Assigned Tohenry  
PrioritylowSeveritytrivialReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinuxOSUbuntuOS Version16.04
Product Versiondev 
Fixed in Versiondev 
Summary0002615: foamSequenceVTKFiles does not enumerate chronologically
DescriptionIf the postprocessing folder contains VTK with time step folders of different name length (i.e "1" and "1.5"), the mapping between the symbolic links and the folders get the ordering wrong. E.g. file name.0001.vtk maps to 1.5/name.vkt and name.0002.vtk maps to 1/name.vtk
Steps To ReproduceChoose any tutorial case, set up a cutting plane and specify "writeControl andjustableRunTime; writeInterval 0.5;" in the system/surface. Run simulation and afterwards foamSequenceVTKFiles and inspect the symbolic links generated.
TagsNo tags attached.

Activities

wyldckat

2017-07-17 23:48

updater   ~0008409

@Armin: You could have made our/my life a bit easier by providing a ready-to-be-used case... took me a few minutes to look for the settings to set up and case that would do something similar ;)

But this was fortunate, because this way I also caught another bug, regarding file names that had common parts of the names, such as "patch_inlet.vtk" and "U_patch_inlet.vtk", would get indexed to the "patch_inlet" name.


I've used the tutorial case "incompressible/pimpleFoam/RAS/TJunction" as a basis for testing and I used the following function object entry:

    surface
    {
        type surfaceFieldValue;
        libs ("libfieldFunctionObjects.so");

        writeControl adjustableRunTime;
        writeInterval 0.5;

        writeFields true;
        surfaceFormat vtk;
        log false;

        regionType patch;

        name inlet;
        fields (U);

        operation areaIntegrate;
    }


After some Googling, I spotted this answer: https://stackoverflow.com/a/42169119
Namely that "sort -g" only work properly if we also use "LC_ALL=C", at least in systems that use locale settings that use commas as decimals separators.


I'm attaching two files:

  - "proposition_v1.patch" - patch file that shows the changes made.

  - "foamSequenceVTKFiles.v1" - file for replacing "bin/foamSequenceVTKFiles" in OpenFOAM-dev. I'm indexed to commit ddc01e5b8c3c391, which should still apply to the current git history.


Fixes the following issues:

  1- "sort -g" will now use the "LC_ALL=C", to properly catch the dot symbol as a decimal separator.

  2- When grep'ing for the VTK file name, it now searches as a word, instead of just the first hit.
proposition_v1.patch (496 bytes)   
diff --git a/bin/foamSequenceVTKFiles b/bin/foamSequenceVTKFiles
index c1e4952..de41932 100755
--- a/bin/foamSequenceVTKFiles
+++ b/bin/foamSequenceVTKFiles
@@ -112,9 +112,9 @@ do
     # Create list of VTK files, ordered by time step
     file_list=$(echo "$files" | \
         tr " " "\n" | \
-        grep "$n.vtk" | \
+        grep -w "$n\.vtk" | \
         awk -F'/' '{print($(NF-1)" "$0)}' | \
-        sort -k 1 -g | \
+        LC_ALL=C  sort -k 1 -g | \
         cut -d' ' -f2)
 
     i=0
proposition_v1.patch (496 bytes)   

wyldckat

2017-07-17 23:48

updater  

henry

2017-07-18 15:27

manager   ~0008411

Thanks Bruno

Resolved by commit bce6b7a728082708488f4645822b1854290f2a1b

Issue History

Date Modified Username Field Change
2017-07-14 15:38 Armin New Issue
2017-07-17 23:48 wyldckat File Added: proposition_v1.patch
2017-07-17 23:48 wyldckat Note Added: 0008409
2017-07-17 23:48 wyldckat File Added: foamSequenceVTKFiles.v1
2017-07-17 23:49 wyldckat Assigned To => chris
2017-07-17 23:49 wyldckat Status new => assigned
2017-07-18 15:27 henry Assigned To chris => henry
2017-07-18 15:27 henry Status assigned => resolved
2017-07-18 15:27 henry Resolution open => fixed
2017-07-18 15:27 henry Fixed in Version => dev
2017-07-18 15:27 henry Note Added: 0008411