View Issue Details

IDProjectCategoryView StatusLast Update
0002238OpenFOAMPatchpublic2017-01-05 16:06
Reporteruser696Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
PlatformlinuxOSopensuseOS Version11.4
Fixed in Versiondev 
Summary0002238: STYLE: use of bounding box in fluentMeshToFoam is odd/misleading
DescriptionUses bounding box with inverted min/max extents (confusing), but only to obtain the overall box size. Can just do directly.

fluentMeshToFoam.L
lines 970ff

- boundBox box(max(points), min(points));
- const scalar zOffset = extrusionFactor*box.mag();

+ const scalar overallSize = Foam::mag(max(points) - min(points));
+ const scalar zOffset = extrusionFactor*overallSize;
TagsNo tags attached.

Activities

MattijsJ

2016-09-09 11:39

reporter  

fluentMeshToFoam.L (49,784 bytes)

wyldckat

2017-01-01 21:06

updater   ~0007579

The attached package "patch_name_v1.tar.gz" provides updates for the following files:

 - applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L

   - Fix for the reported aesthetic coding issue. I didn't go with either solutions, but went instead with the middle term: simply use "boundBox box(points)", instead of going around with min/max operations which 'boundBox' already has an overload for, i.e.:

         boundBox box(points);
         const scalar zOffset = extrusionFactor*box.mag();

   - Although the feature for automated scaling in the Z direction is nice, I don't like not having a manual override for it. Therefore, the provided change uses the same argument naming convention as 'plot3dToFoam', namely to provide the argument '-2D <thickness>' for manual override.

   - The message for this new argument is nearly identical to the original one on 'plot3dToFoam', but appended the indication '(applied before scale)'.


 - applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C

   - For consistency, added the same indication to the option '-2D' as mentioned in the last point above, namely '(applied before scale)'.
patch_name_v1.tar.gz (13,061 bytes)

wyldckat

2017-01-01 21:08

updater   ~0007580

(OK... forgot to rename the package name that I had on my snippet... anyway:)

Attached is the file 'patch_name_v1.patch' for easier inspection.
patch_name_v1.patch (3,252 bytes)   
diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
index c7ed9ca..cf8c8cd 100644
--- a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
+++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
@@ -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
@@ -871,6 +871,12 @@ int main(int argc, char *argv[])
         "factor",
         "geometry scaling factor - default is 1"
     );
+    argList::addOption
+    (
+        "2D",
+        "thickness",
+        "use when converting a 2-D mesh (applied before scale)"
+    );
     argList::addBoolOption
     (
         "writeSets",
@@ -957,22 +963,26 @@ int main(int argc, char *argv[])
     // Construct shapes from face lists
     cellShapeList cellShapes(nCells);
 
-    // Extrude 2-D mesh into 3-D
-
     Info<< "dimension of grid: " << dimensionOfGrid << endl;
     faceList frontAndBackFaces;
 
     if (dimensionOfGrid == 2)
     {
-        const scalar extrusionFactor = 0.01;
+        // Extrude 2-D mesh into 3-D, in z-direction
 
-        boundBox box(max(points), min(points));
+        scalar twoDThickness = 1.0;
 
-        const scalar zOffset = extrusionFactor*box.mag();
+        if (!args.optionReadIfPresent("2D", twoDThickness))
+        {
+            const scalar extrusionFactor = 0.02; //0.01 in each direction
+            boundBox box(points);
+            twoDThickness = extrusionFactor*box.mag();
+        }
+
+        Info<< "Grid is 2-D. Extruding in z-direction by: " << twoDThickness
+            << endl;
 
-        // two-dimensional grid. Extrude in z-direction
-        Info<< "Grid is 2-D. Extruding in z-direction by: "
-            << 2*zOffset << endl;
+        const scalar zOffset = twoDThickness / 2;
 
         pointField oldPoints = points;
 
diff --git a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C
index e473bba..0b45118 100644
--- a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C
+++ b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.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
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
     (
         "2D",
         "thickness",
-        "use when converting a 2-D geometry"
+        "use when converting a 2-D mesh (applied before scale)"
     );
 
     argList args(argc, argv);
patch_name_v1.patch (3,252 bytes)   

henry

2017-01-05 16:06

manager   ~0007597

Thanks Bruno

Resolved by commit db69053ef729cca390d431d777587ad5c596aaa5

Issue History

Date Modified Username Field Change
2016-09-08 06:19 user696 New Issue
2016-09-08 08:18 henry Category Bug => Patch
2016-09-09 11:39 MattijsJ File Added: fluentMeshToFoam.L
2017-01-01 21:06 wyldckat File Added: patch_name_v1.tar.gz
2017-01-01 21:06 wyldckat Note Added: 0007579
2017-01-01 21:06 wyldckat Assigned To => henry
2017-01-01 21:06 wyldckat Status new => assigned
2017-01-01 21:08 wyldckat File Added: patch_name_v1.patch
2017-01-01 21:08 wyldckat Note Added: 0007580
2017-01-05 16:06 henry Status assigned => resolved
2017-01-05 16:06 henry Resolution open => fixed
2017-01-05 16:06 henry Fixed in Version => dev
2017-01-05 16:06 henry Note Added: 0007597