CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] Experimentally obtained STL file for internal Flow SnappyHexMesh

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 5, 2012, 14:19
Default Experimentally obtained STL file for internal Flow SnappyHexMesh
  #1
New Member
 
Tom
Join Date: Nov 2011
Location: Atlanta, Ga
Posts: 21
Rep Power: 15
Irish09 is on a distinguished road
Hello All!

I am working on determining the best method of creating an 'educated' geometry for an internal flow application where I have an STL file from X-ray tomagraphy. I shall attempt to explain what I have done and what I would like to do.

I have sized the blockMeshdict such that it smaller than my STL file in order to exclude the parts of the geometry not associated with the internal flow I am interested in. Also this is necessary since the experimentally obtained STL file is not a closed surface, so by shrinking the initial blockMesh it provides a boundary. I have taken a slice of my blockMesh with the STL file placed into it shown here, Blockmesh_with_STL.jpg.

The geometry is of a 3 hole injector nozzle and this image shows the slice through one of them.

By defining the blockMesh and the STL file with a cylinder around it in the geometry section of the snappyhexmeshdict I can create a suitable mesh. These can be seen here:
SprayB_Mesh.jpg

SprayB_mesh_slice.jpg

The problem I have with this approach is that there is an excessive number of cells (2.26 million cells) and most of them are not necessary. My thought was to place a searchable sphere at the outlet to each nozzle. The geometry would look something like this.

The spheres would be placed as so:
SprayB_sphere.jpg
In order to create a mesh that would result like this:
SprayB_fail.png

However, at the location which the searchable sphere is intersecting with the STL file snappyhexmesh is under the impression that is the boundary to the mesh, removing the part of the STL file that appears within the sphere instead of what I am desiring with is to make the opposite end of the sphere be the boundary. The result is that half of each nozzle has been removed, but what I would rather is that the sphere be considered part of the STL and create a semisphere around the outlet.


Here is the what I believe to be the pertinent parts of the snappyhexmeshdict:
Code:
geometry
{

    one
    {
        type searchableSphere;
        centre (-0.55 -0.4 -0.37);
        radius 0.3;
    }

    two
    {
       type searchableSphere;
       centre (1.18 -0.85 -0.34);
       radius 0.3;
    }

    three
    {
       type searchableSphere;
       centre (0.29 0.95 -0.37);
       radius 0.3;
    }

    Inj211201Tip48208withneedle.stl
    {
        type triSurfaceMesh;
        name Inj211201Tip48208withneedle;
    }
};
   refinementSurfaces
    {
      "Inj211201Tip48208withneedle_*"
      {
          // Surface-wise min and max refinement level
          level (5 6);
      }
      "one_*"
      {
          level (1 1);
      }
      "two_*"
      {
          level (1 1);
      }
      "three_*"
      {
          level (1 1);
      }
    }
    layers
    {
        "Inj211201Tip48208withneedle_*"
        {
           nSurfaceLayers 1;
        }
       "one_*"
        {
           nSurfaceLayers 1;
        }
        "two_*"
        {
           nSurfaceLayers 1;
        }
        "three_*"
        {
           nSurfaceLayers 1;
        }
    }
I also attempted to create a searchableSurfaceCollection with the STL file and all three spheres on that, but a floating point exception would occur when both types of surfaces were included. I was able to place the STL file in a searchableSurfaceCollection by itself and was able to place all three spheres without the STL file, but when combined the floating point occurred.

The snappyhexmeshdict for that looked like this:
Code:
geometry
{

    one
    {
        type searchableSphere;
        centre (-0.55 -0.4 -0.37);
        radius 0.3;
    }

    two
    {
       type searchableSphere;
       centre (1.18 -0.85 -0.34);
       radius 0.3;
    }

    three
    {
       type searchableSphere;
       centre (0.29 0.95 -0.37);
       radius 0.3;
    }

    Inj211201Tip48208withneedle.stl
    {
        type triSurfaceMesh;
        name Inj211201Tip48208withneedle;
    }
    Total
    {

      type searchableSurfaceCollection;

      mergeSubRegions true;

      injpart
      {
        surface Inj211201Tip48208withneedle.stl;
        scale (1 1 1);
        transform
        {
                type    cartesian;
                origin  (0 0 0);
                e1      (1 0 0);
                e3      (0 0 1);
        }
      }
      sphere1
      {
        surface one;
        scale (1 1 1);
        transform
        {
                type    cartesian;
                origin  (0 0 0);
                e1      (1 0 0);
                e3      (0 0 1);
        }
      }

      sphere2
      {
        surface two;
        scale (1 1 1);
        transform
        {
                type    cartesian;
                origin  (0 0 0);
                e1      (1 0 0);
                e3      (0 0 1);
        }
      }
      sphere3
      {
        surface three;
        scale (1 1 1);
        transform
        {
                type    cartesian;
                origin  (0 0 0);
                e1      (1 0 0);
                e3      (0 0 1);
        }
      }

    }
  
};
    refinementSurfaces
    {
        Total
        {
            level (2 2);
        }
    }
    layers
    {
        "Total_*"
        {
          nSurfaceLayers 1;
        }
    }
Any thoughts on how this might be accomplished would be appreciated. Thanks.
Irish09 is offline   Reply With Quote

Old   April 5, 2012, 14:48
Default
  #2
Senior Member
 
lore
Join Date: Mar 2010
Location: Italy
Posts: 460
Rep Power: 18
lovecraft22 is on a distinguished road
Send a message via Skype™ to lovecraft22
Hi Thomas;
your spheres should be within the refinementRegions section and not within the refinement surfaces.

So, eventually, you should have something like this:

Code:
geometry
{
   one
    {
        type searchableSphere;
        centre (-0.55 -0.4 -0.37);
        radius 0.3;
    }

    two
    {
       type searchableSphere;
       centre (1.18 -0.85 -0.34);
       radius 0.3;
    }

    three
    {
       type searchableSphere;
       centre (0.29 0.95 -0.37);
       radius 0.3;
    }

    Inj211201Tip48208withneedle.stl
    {
        type triSurfaceMesh;
        name Inj211201Tip48208withneedle;
    }

};



castellatedMeshControls
{

[SOME OTHER STUFF GOES HERE]
    
    refinementSurfaces
    {
        Inj211201Tip48208withneedle
      {
          // Surface-wise min and max refinement level
          level (5 6);
      }
    }

  
[SOME OTHER STUFF GOES HERE]


    refinementRegions
    {
        "one_*"
      {
          level (1 1);
      }
      "two_*"
      {
          level (1 1);
      }
      "three_*"
      {
          level (1 1);
      }    
}

[THE REST OF YOUR SHM DICT GOES HERE]
Anyway to me this is not a good way of removing the excess of cells, this way is good to add some mesh refinement instead.
If you upload your entire snappyHexMeshDict and possibly your snappyHexMex Log or your checkMesh Log I wouldn't mind having a look.
lovecraft22 is offline   Reply With Quote

Old   April 5, 2012, 15:25
Default Attempted refinementRegion
  #3
New Member
 
Tom
Join Date: Nov 2011
Location: Atlanta, Ga
Posts: 21
Rep Power: 15
Irish09 is on a distinguished road
Hello lovecraft22!

Thank you for your timely response. I have tried your suggestion of placing the spheres in the refinementregion section, but that still isn't doing quite what I would like. You can see here:

SprayB_refinementregion.jpg

My SHM dict file:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.0.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Which of the steps to run
castellatedMesh true;
snap            true;
addLayers       true;


// Geometry. Definition of all surfaces. All surfaces are of class
// searchableSurface.
// Surfaces are used
// - to specify refinement for any mesh cell intersecting it
// - to specify refinement for any mesh cell inside/outside/near
// - to 'snap' the mesh boundary to the surface
geometry
{

    one
    {
        type searchableSphere;
        centre (-0.55 -0.4 -0.37);
        radius 0.3;
    }

    two
    {
       type searchableSphere;
       centre (1.18 -0.85 -0.34);
       radius 0.3;
    }

    three
    {
       type searchableSphere;
       centre (0.29 0.95 -0.37);
       radius 0.3;
    }

    Inj211201Tip48208withneedle.stl
    {
        type triSurfaceMesh;
        name Inj211201Tip48208withneedle;
    }
};



// Settings for the castellatedMesh generation.
castellatedMeshControls
{

    // Refinement parameters
    // ~~~~~~~~~~~~~~~~~~~~~

    // If local number of cells is >= maxLocalCells on any processor
    // switches from from refinement followed by balancing
    // (current method) to (weighted) balancing before refinement.
    maxLocalCells 100000;

    // Overall cell limit (approximately). Refinement will stop immediately
    // upon reaching this number so a refinement level might not complete.
    // Note that this is the number of cells before removing the part which
    // is not 'visible' from the keepPoint. The final number of cells might
    // actually be a lot less.
    maxGlobalCells 2000000;

    // The surface refinement loop might spend lots of iterations refining just a
    // few cells. This setting will cause refinement to stop if <= minimumRefine
    // are selected for refinement. Note: it will at least do one iteration
    // (unless the number of cells to refine is 0)
    minRefinementCells 10;

    // Allow a certain level of imbalance during refining
    // (since balancing is quite expensive)
    // Expressed as fraction of perfect balance (= overall number of cells /
    // nProcs). 0=balance always.
    maxLoadUnbalance 0.10;


    // Number of buffer layers between different levels.
    // 1 means normal 2:1 refinement restriction, larger means slower
    // refinement.
    nCellsBetweenLevels 1;



    // Explicit feature edge refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // Specifies a level for any cell intersected by its edges.
    // This is a featureEdgeMesh, read from constant/triSurface for now.
    features
    (
//        {
//            file "Inj211201Tip48208withneedle.eMesh";
//            level 1;
//        }
    );



    // Surface based refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~

    // Specifies two levels for every surface. The first is the minimum level,
    // every cell intersecting a surface gets refined up to the minimum level.
    // The second level is the maximum level. Cells that 'see' multiple
    // intersections where the intersections make an
    // angle > resolveFeatureAngle get refined up to the maximum level.

    refinementSurfaces
    {
      "Inj211201Tip48208withneedle_*"
      {
          // Surface-wise min and max refinement level
          level (5 6);
      }

    }

    // Resolve sharp angles
    resolveFeatureAngle 30;


    // Region-wise refinement
    // ~~~~~~~~~~~~~~~~~~~~~~

    // Specifies refinement level for cells in relation to a surface. One of
    // three modes
    // - distance. 'levels' specifies per distance to the surface the
    //   wanted refinement level. The distances need to be specified in
    //   descending order.
    // - inside. 'levels' is only one entry and only the level is used. All
    //   cells inside the surface get refined up to the level. The surface
    //   needs to be closed for this to be possible.
    // - outside. Same but cells outside.

    refinementRegions
    {
          one
          {
             mode inside;
             levels ((1e15 4));
          }
          two
          {
             mode inside;
             levels ((1e15 4));
          }
          three
          {
             mode inside;
             levels ((1e15 4));
          }
    }


    // Mesh selection
    // ~~~~~~~~~~~~~~

    // After refinement patches get added for all refinementSurfaces and
    // all cells intersecting the surfaces get put into these patches. The
    // section reachable from the locationInMesh is kept.
    // NOTE: This point should never be on a face, always inside a cell, even
    // after refinement.
    locationInMesh (.2 -.05 -0.1);


    // Whether any faceZones (as specified in the refinementSurfaces)
    // are only on the boundary of corresponding cellZones or also allow
    // free-standing zone faces. Not used if there are no faceZones.
    allowFreeStandingZoneFaces true;
}



// Settings for the snapping.
snapControls
{
    //- Number of patch smoothing iterations before finding correspondence
    //  to surface
    nSmoothPatch 3;

    //- Relative distance for points to be attracted by surface feature point
    //  or edge. True distance is this factor times local
    //  maximum edge length.
    tolerance 4.0;

    //- Number of mesh displacement relaxation iterations.
    nSolveIter 0;

    //- Maximum number of snapping relaxation iterations. Should stop
    //  before upon reaching a correct mesh.
    nRelaxIter 5;

    //- Highly experimental and wip: number of feature edge snapping
    //  iterations. Leave out altogether to disable.
    //  Do not use here since mesh resolution too low and baffles present
    //nFeatureSnapIter 10;
}



// Settings for the layer addition.
addLayersControls
{
    // Are the thickness parameters below relative to the undistorted
    // size of the refined cell outside layer (true) or absolute sizes (false).
    relativeSizes true;

    // Per final patch (so not geometry!) the layer information
    layers
    {
        "Inj211201Tip48208withneedle_*"
        {
           nSurfaceLayers 1;
        }
    }

    // Expansion factor for layer mesh
    expansionRatio 1.0;

    //- Wanted thickness of final added cell layer. If multiple layers
    //  is the
    //  thickness of the layer furthest away from the wall.
    //  Relative to undistorted size of cell outside layer.
    //  is the thickness of the layer furthest away from the wall.
    //  See relativeSizes parameter.
    finalLayerThickness 0.3;

    //- Minimum thickness of cell layer. If for any reason layer
    //  cannot be above minThickness do not add layer.
    //  Relative to undistorted size of cell outside layer.
    minThickness 0.1;

    //- If points get not extruded do nGrow layers of connected faces that are
    //  also not grown. This helps convergence of the layer addition process
    //  close to features.
    // Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
    nGrow 0;

    // Advanced settings

    //- When not to extrude surface. 0 is flat surface, 90 is when two faces
    //  make straight angle.
    featureAngle 30;

    //- Maximum number of snapping relaxation iterations. Should stop
    //  before upon reaching a correct mesh.
    nRelaxIter 3;

    // Number of smoothing iterations of surface normals
    nSmoothSurfaceNormals 1;

    // Number of smoothing iterations of interior mesh movement direction
    nSmoothNormals 3;

    // Smooth layer thickness over surface patches
    nSmoothThickness 10;

    // Stop layer growth on highly warped cells
    maxFaceThicknessRatio 0.5;

    // Reduce layer growth where ratio thickness to medial
    // distance is large
    maxThicknessToMedialRatio 0.3;

    // Angle used to pick up medial axis points
    // Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 in 17x.
    minMedianAxisAngle 90;


    // Create buffer region for new layer terminations
    nBufferCellsNoExtrude 0;


    // Overall max number of layer addition iterations. The mesher will exit
    // if it reaches this number of iterations; possibly with an illegal
    // mesh.
    nLayerIter 50;
}



// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
    //- Maximum non-orthogonality allowed. Set to 180 to disable.
    maxNonOrtho 65;

    //- Max skewness allowed. Set to <0 to disable.
    maxBoundarySkewness 20;
    maxInternalSkewness 4;

    //- Max concaveness allowed. Is angle (in degrees) below which concavity
    //  is allowed. 0 is straight face, <0 would be convex face.
    //  Set to 180 to disable.
    maxConcave 80;

    //- Minimum pyramid volume. Is absolute volume of cell pyramid.
    //  Set to a sensible fraction of the smallest cell volume expected.
    //  Set to very negative number (e.g. -1E30) to disable.
    minVol 1e-13;

    //- Minimum quality of the tet formed by the face-centre
    //  and variable base point minimum decomposition triangles and
    //  the cell centre. This has to be a positive number for tracking
    //  to work. Set to very negative number (e.g. -1E30) to
    //  disable.
    //     <0 = inside out tet,
    //      0 = flat tet
    //      1 = regular tet
    minTetQuality 1e-30;

    //- Minimum face area. Set to <0 to disable.
    minArea -1;

    //- Minimum face twist. Set to <-1 to disable. dot product of face normal
    //- and face centre triangles normal
    minTwist 0.02;

    //- minimum normalised cell determinant
    //- 1 = hex, <= 0 = folded or flattened illegal cell
    minDeterminant 0.001;

    //- minFaceWeight (0 -> 0.5)
    minFaceWeight 0.02;

    //- minVolRatio (0 -> 1)
    minVolRatio 0.01;

    //must be >0 for Fluent compatibility
    minTriangleTwist -1;


    // Advanced

    //- Number of error distribution iterations
    nSmoothScale 4;
    //- amount to scale back displacement at error points
    errorReduction 0.75;
}


// Advanced

// Flags for optional output
// 0 : only write final meshes
// 1 : write intermediate meshes
// 2 : write volScalarField with cellLevel for postprocessing
// 4 : write current intersections as .obj files
debug 0;


// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1e-6;


// ************************************************************************* //
I'm sure this isn't the most graceful way to accomplish what I am attempting, but it is an interesting project since the STL file is not a closed surface and I am trying to get the boundary such that I can minimize the cell count. While the image shown above would theoretically be sufficient, it is 900k cells using the minimum amount of refinement in SHM. So obtaining any more refinement is likely prohibitive without finding a way to reduce the cell count elsewhere.
Irish09 is offline   Reply With Quote

Old   April 5, 2012, 15:28
Default
  #4
Senior Member
 
lore
Join Date: Mar 2010
Location: Italy
Posts: 460
Rep Power: 18
lovecraft22 is on a distinguished road
Send a message via Skype™ to lovecraft22
What about your blockmesh? Have you tried reducing the number of cells in it?
lovecraft22 is offline   Reply With Quote

Old   April 5, 2012, 15:39
Default STL file
  #5
New Member
 
Tom
Join Date: Nov 2011
Location: Atlanta, Ga
Posts: 21
Rep Power: 15
Irish09 is on a distinguished road
The problem is that SHM is trying to refine the mesh up against a surface for which very little flow is occuring. Shown here:

SprayB_refinementregion2.jpg

And so by trying to put an outlet semisphere on the nozzle I am trying to remove the need to mesh this surface almost entirely.
Irish09 is offline   Reply With Quote

Old   April 5, 2012, 15:43
Default
  #6
Senior Member
 
lore
Join Date: Mar 2010
Location: Italy
Posts: 460
Rep Power: 18
lovecraft22 is on a distinguished road
Send a message via Skype™ to lovecraft22
All right, now the problem is clear!
So you basically want a coarser mesh on only a part of the surface. The fact is that all of your body gets refined in a certain way and there's no way in reducing the mesh in such zones by using a refinementRegion simply because the refinementRegion won't affect the surface mesh…

So, what I would suggest you to do would be to separate your geometry in two different .stl files: one for the fine mesh and one for the coarse mesh. This way you'll get what you need.

You can do this with meshlab, paraview or engrid which are free.
lovecraft22 is offline   Reply With Quote

Old   April 7, 2012, 07:35
Default
  #7
Member
 
s.rasoul_varedi
Join Date: Feb 2010
Posts: 82
Rep Power: 15
desert_1250 is an unknown quantity at this point
Send a message via Yahoo to desert_1250
Hello foamers
how can define patches for every parts of the Geometry in the .stl file?
on the other hand, i created .stl file using CATIA software and import it in OpenFOAM using SHM, every things seems right, but i want to specify every parts of my Geometry by the name and patch for example Blade1,Blade2, Blade3, insideSlider and etc

tnx
desert_1250 is offline   Reply With Quote

Old   April 7, 2012, 07:43
Default
  #8
Senior Member
 
lore
Join Date: Mar 2010
Location: Italy
Posts: 460
Rep Power: 18
lovecraft22 is on a distinguished road
Send a message via Skype™ to lovecraft22
Hi;
you can either separate the region you need to different stl files or create a single stl file that keeps the names of the regions and then pass these names to snappy to have different surface refinement.

Have a look a these discussions:

http://www.cfd-online.com/Forums/ope...e-stlfile.html
http://www.cfd-online.com/Forums/ope...onditions.html
http://www.cfd-online.com/Forums/ope...-tutorial.html
http://www.cfd-online.com/Forums/ope...pyhexmesh.html
lovecraft22 is offline   Reply With Quote

Old   April 7, 2012, 09:04
Default
  #9
Member
 
s.rasoul_varedi
Join Date: Feb 2010
Posts: 82
Rep Power: 15
desert_1250 is an unknown quantity at this point
Send a message via Yahoo to desert_1250
great, thanks for your quick reply
so i think that is difficult work, is there a simpler solution?!

tnx
desert_1250 is offline   Reply With Quote

Old   April 7, 2012, 09:50
Default
  #10
Senior Member
 
lore
Join Date: Mar 2010
Location: Italy
Posts: 460
Rep Power: 18
lovecraft22 is on a distinguished road
Send a message via Skype™ to lovecraft22
Is very easy, I don't think there's a simpler alternative.
The easiest way is that of creating different stl files. So open you original CAD file, select what will be the blade1 part, delete all of the rest, save to blade1.stl.
Repeat that for blade2, blade3 and so on.

If you don't have a commercial CAD software and if your geometry is not complicate then you can achieve this whole process in paraview, meshlab or engrid which are totally free.
lovecraft22 is offline   Reply With Quote

Reply

Tags
internal flow, snappyhexmesh


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] Tabulated thermophysicalProperties library chriss85 OpenFOAM Community Contributions 62 October 2, 2022 04:50
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
[swak4Foam] Installation Problem with OF 6 version Aurel OpenFOAM Community Contributions 14 November 18, 2020 17:18
[OpenFOAM.org] Patches to compile OpenFOAM 2.2 on Mac OS X gschaider OpenFOAM Installation 136 October 10, 2017 18:25
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 07:42


All times are GMT -4. The time now is 23:47.