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

[snappyHexMesh] irregular nozzle surface

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   Today, 08:18
Default irregular nozzle surface
  #1
New Member
 
Carmelo Baronetto
Join Date: Dec 2023
Posts: 21
Rep Power: 2
Carmelo98 is on a distinguished road
Good morning to all,
I'm trying to build the mesh of a nozzle from a 3D CAD.
The nozzle is quite small compared to the whole domain.
I followed these steps in the mesh generation:
1. I created a rectangular block with uniform dx=0.5 (mm) using blockMesh
2. I used snappyHexMesh to create the mesh from the CAD, setting a local level refinement of 4 near the nozzle
The mesh is not too bad, ut I expected a better results considering the very small spatial grid, in particular for the nozzle wall which is quite irregular with many steps.
I hope you can help me, at least just to know if it is the best you can obtain or if the mesh quality can be increased.
Thank you so much
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2306                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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


// 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
{
    domain.stl
    {
        type triSurfaceMesh;
        name domain;
    }
	
    inlet.stl
    {
	type triSurfaceMesh;
	name inlet;
    }
    HP_wall.stl
    {
	type triSurfaceMesh;
	name HP_wall;
    }
    nozzle_wall.stl
    {
	type triSurfaceMesh;
	name nozzle_wall;
    }
    tank_wall.stl
    {
	type triSurfaceMesh;
	name tank_wall;
    }
    tank.stl
    {
	type triSurfaceMesh;
	name tank;
    }

    
    refinementCylinder
    {
	type searchableCylinder;
	point1 (-0.003 0 0);
	point2 (0.02 0 0);
	radius 0.003;
    }
}


// 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 2000000;

    // 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 40000000;

    // 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 0;

    // 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 4;



    // 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 "inlet.eMesh";
            level 0;
        }
        
        {
            file "HP_wall.eMesh";
            level 0;
        }
        
	
	{
	    file "nozzle_wall.eMesh";
	    level 0;
	}
	
	{
            file "tank_wall.eMesh";
            level 0;
        }

	{
	    file "tank.eMesh";
	    level 0;
	}
    );



    // 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
    {
        inlet
        {
            level (0 0);
		
		patchInfo
		{
		    type patch;
		} 
         }
        HP_wall
        {
            level (0 0);
		
		patchInfo
		{
		    type patch;
		} 
         }
	nozzle_wall
	{
	    level (0 0);
	    patchInfo
		{
		    type patch;
		} 
        }
        tank_wall
        {
            level (0 0);
		
		patchInfo
		{
		    type patch;
		} 
         }
	tank
	{
	    level (0 0);
	    patchInfo
		{
		    type patch;
		} 
	}
  
    }

    // Resolve sharp angles
    resolveFeatureAngle 80;// 30;


   planarAngle 30;

   refinementRegions
   {
	refinementCylinder
	{
	    mode inside;
    	    levels ((4 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 (-0.01 0 0);


    // 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 2.0;

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

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

    // Feature snapping

        //- Number of feature edge snapping iterations.
        //  Leave out altogether to disable.
        nFeatureSnapIter 10;

        //- Detect (geometric only) features by sampling the surface
        //  (default=false).
        implicitFeatureSnap false;

        //- Use castellatedMeshControls::features (default = true)
        explicitFeatureSnap true;

        //- Detect points on multiple surfaces (only for explicitFeatureSnap)
        multiRegionFeatureSnap false;
}


addLayersControls
{
}

// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
    #include "meshQualityDict"


    // Advanced

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


// Advanced

// Write flags
writeFlags
(
    scalarLevels
    layerSets
    layerFields     // write volScalarField for layer coverage
);


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


// ************************************************************************* //
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v1806                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

L1	0.06;
L2	0.025;
r	0.02;

scale   1;

vertices
(
    (-$L2 -$r -$r)
    ($L1 -$r -$r)
    ($L1 $r -$r)
    (-$L2 $r -$r)
    
    (-$L2 -$r $r)
    ($L1 -$r $r)
    ($L1 $r $r)
    (-$L2 $r $r)
    
    
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (170 80 80) simpleGrading (1 1 1)

);

edges
(
	
		
);

boundary
(
    
);

mergePatchPairs
(
);

// ************************************************************************* //
Attached Images
File Type: jpg nozzle.jpg (81.0 KB, 3 views)
File Type: jpg nozzle_zoom.jpg (190.9 KB, 2 views)
Carmelo98 is offline   Reply With Quote

Old   Today, 08:35
Default
  #2
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,062
Rep Power: 26
Yann will become famous soon enough
Hello,

Not sure if it will solve your issue, but have you tried refining the surfaces and not only the volume?

For instance :
Code:
nozzle_wall
	{
	    level (4 4);
	    patchInfo
		{
		    type patch;
		} 
        }
Same for the features section.

(On a side note, unrelated to your problem: only inlet (and outlet if there is one) should be defined as type patch, walls should be defined as type wall, which is the default setting if you don't define any patchInfo section.)
Yann is offline   Reply With Quote

Old   Today, 09:24
Default
  #3
New Member
 
Carmelo Baronetto
Join Date: Dec 2023
Posts: 21
Rep Power: 2
Carmelo98 is on a distinguished road
Hi Yann, thank you for the reply.
I tried to refine the surface and the edges (if I understood right) but nothing changed. I guess if you refine the enitre volume, it means cells of surface are refined too.
About the second point, I got it. This was just a test, I would have changed it later.
Carmelo98 is offline   Reply With Quote

Old   Today, 10:32
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,062
Rep Power: 26
Yann will become famous soon enough
Quote:
Originally Posted by Carmelo98 View Post
I guess if you refine the enitre volume, it means cells of surface are refined too.
Yes it should, but I wanted to be sure.

Your issue reminds me of this thread: snappyHexMesh - 90° edges problem

I noticed you don't define any boundaries in your blockMeshDict. Usually if you do so, blockMesh will define it as defaultPatch, with a type empty. This is a problem for snappy (and you should get warnings about this in the snappy log)

Try adding this in your blockMeshDict:

Code:
defaultPatch
{
    name    defaultPatch;
    type    patch;
}
If this does not solve the issue, it might be related to the fact you are using separate stl files. Have a look at this specific post from the same thread: snappyHexMesh - 90° edges problem
Yann is offline   Reply With Quote

Old   Today, 13:05
Default
  #5
New Member
 
Carmelo Baronetto
Join Date: Dec 2023
Posts: 21
Rep Power: 2
Carmelo98 is on a distinguished road
I'm doing some tests but at the moment I can't improve the mesh.
However, if I mesh only the nozzle,without the two big cylinders, the mesh is perfect. I followed exactly the same method and the mesh is very good.
Is it possible the problem is in the big difference in size between the three bodies?
Carmelo98 is offline   Reply With Quote

Reply


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
[Gmsh] Error : Self intersecting surface mesh, computing intersections & Error : Impossible velan OpenFOAM Meshing & Mesh Conversion 3 October 22, 2015 11:05
[ICEM] Preparing Irregular Surface Boundary for Extrusion J_Keel ANSYS Meshing & Geometry 1 March 5, 2015 08:43
Normal - Helical Surface m. malik Main CFD Forum 3 February 3, 2006 12:56
compressible flow in a counterflow nozzle d.vamsidhar FLUENT 0 November 24, 2005 01:45
CFX4.3 -build analysis form Chie Min CFX 5 July 12, 2001 23:19


All times are GMT -4. The time now is 21:05.