View Issue Details

IDProjectCategoryView StatusLast Update
0001975OpenFOAMpublic2016-01-19 16:30
Reporteralexeym Assigned Tohenry  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Versiondev 
Summary0001975: foamToVTK can not write binary files if WM_LABEL_SIZE=64
DescriptionfoamToVTK honestly tells user it can not write binary files and proposes to add -ascii flag. Why not check WM_LABEL_SIZE value in Allrun script?

This addition to Allrun seems to be sufficient:

...
ascii_flag=
[ "$WM_LABEL_SIZE" -eq 64 ] && ascii_flag="-ascii"

runAnsysToFoam flange.ans 0.001
runApplication $application
runApplication foamToEnsight
runApplication foamToEnsightParts
runApplication foamToVTK $ascii_flag

unset ascii_flag
Steps To Reproduce1. Compile OpenFOAM with WM_LABEL_SIZE=64
2. Run flange tutorial case in basic/laplacianFoam/flange
TagsNo tags attached.

Activities

henry

2016-01-19 15:15

manager   ~0005857

I think this would add a lot of clutter to the already cluttered Allrun scripts and none of the tutorial cases need WM_LABEL_SIZE=64 anyway.

If automatic selection of ASCII operation of foamToVTK for WM_LABEL_SIZE=64 is generally needed it would be better that foamToVTK does this internally and issues a warning message to this effect.

alexeym

2016-01-19 15:57

reporter  

foamToVTK-auto-ascii.patch (1,521 bytes)   
diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
index b11a5c9..bd25dbc 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C
@@ -324,7 +324,7 @@ int main(int argc, char *argv[])
     const bool doWriteInternal = !args.optionFound("noInternal");
     const bool doFaceZones     = !args.optionFound("noFaceZones");
     const bool doLinks         = !args.optionFound("noLinks");
-    const bool binary          = !args.optionFound("ascii");
+    bool binary                = !args.optionFound("ascii");
     const bool useTimeName     = args.optionFound("useTimeName");
 
     // decomposition of polyhedral cells into tets/pyramids cells
@@ -332,10 +332,11 @@ int main(int argc, char *argv[])
 
     if (binary && (sizeof(floatScalar) != 4 || sizeof(label) != 4))
     {
-        FatalErrorInFunction
-            << "floatScalar and/or label are not 4 bytes in size" << nl
-            << "Hence cannot use binary VTK format. Please use -ascii"
-            << exit(FatalError);
+        Warning
+            << "floatScalar and/or label are not 4 bytes in size." << nl
+            << "Hence cannot use binary VTK format, falling back to ASCII"
+            << " output." << nl << endl;
+        binary = false;
     }
 
     const bool nearCellValue = args.optionFound("nearCellValue");
foamToVTK-auto-ascii.patch (1,521 bytes)   

alexeym

2016-01-19 16:01

reporter  

log.foamToVTK.gz (1,826 bytes)

alexeym

2016-01-19 16:03

reporter   ~0005858

Attached: possible patch and foamToVTK output with the patch applied.

henry

2016-01-19 16:30

manager   ~0005859

Thanks for the patch.
Resolved by commit 96966f468daafc57ae2b5060a72e8ec05e5463c9

Issue History

Date Modified Username Field Change
2016-01-19 14:42 alexeym New Issue
2016-01-19 15:15 henry Note Added: 0005857
2016-01-19 15:57 alexeym File Added: foamToVTK-auto-ascii.patch
2016-01-19 16:01 alexeym File Added: log.foamToVTK.gz
2016-01-19 16:03 alexeym Note Added: 0005858
2016-01-19 16:30 henry Note Added: 0005859
2016-01-19 16:30 henry Status new => resolved
2016-01-19 16:30 henry Resolution open => fixed
2016-01-19 16:30 henry Assigned To => henry
2016-03-11 11:44 administrator Category 3.0.1 => (No Category)