CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [snappyHexMesh] jagged, ragged edges... (https://www.cfd-online.com/Forums/openfoam-meshing/72595-jagged-ragged-edges.html)

ziemowitzima February 11, 2010 06:06

jagged, ragged edges...
 
2 Attachment(s)
Dear everyone !

I am doing flow in 3D abdominal aorta. To create mesh I utilized snappyHexMesh. But I obtained strange jagged edges where inlet (outlet) patches are joining with rest of the mesh. I attached figures showing this problem. If some of you know how to deal with this issue pleas let me know !!
Thanks
Ziemowit

ziemowitzima February 11, 2010 06:11

Here is my snappyHexMeshDict:

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://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
{
aortwz.stl
{
type triSurfaceMesh;
name aort;
}
inz.stl
{
type triSurfaceMesh;
name in;
}
out1z.stl
{
type triSurfaceMesh;
name out1;
}
out2z.stl
{
type triSurfaceMesh;
name out2;
}

// refinementBox
// {
// type searchableBox;
// min ( 0.07 0.05 -0.1);
// max ( 0.26 0.25 0.2);
// }
};


// Settings for the castellatedMesh generation.
castellatedMeshControls
{

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

// While refining maximum number of cells per processor. This is basically
// the number of cells that fit on a processor. If you choose this too small
// it will do just more refinement iterations to obtain a similar mesh.
maxLocalCells 1000000;

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

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



// 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 "someLine.eMesh";
// level 2;
//}
);



// 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
{
aort
{
// Surface-wise min and max refinement level
level (4 4);
}
in
{
// Surface-wise min and max refinement level
level (4 4);
}
out1
{
// Surface-wise min and max refinement level
level (4 4);
}
out2
{
// Surface-wise min and max refinement level
level (4 4);
}
}

// Resolve sharp angles
resolveFeatureAngle 60;


// 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
{
// in
// {
// 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 (1.5 1.25 5);
}



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

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

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

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



// Settings for the layer addition.
addLayersControls
{
relativeSizes true;

// Per final patch (so not geometry!) the layer information
layers
{

aort
{
nSurfaceLayers 2;
}
out1
{
nSurfaceLayers 2;
}
out2
{
nSurfaceLayers 2;
}
in
{
nSurfaceLayers 2;
}

}

// Expansion factor for layer mesh
expansionRatio 1;

//- 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.
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.
nGrow 1;


// Advanced settings

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

//- 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;//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
minMedianAxisAngle 130;

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

// Overall max number of layer addition iterations
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 projected area v.s. actual area. Set to -1 to disable.
minFlatness 0.5;

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

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


// ************************************************** *********************** //

wyldckat February 11, 2010 06:38

Greetings Ziemowit,

In my limited experience, snappyHexMesh gets a bit annoyed when there are perpendicular edges. So, by what I know, you have two options:
  • make those edges a bit more curved in the STL;
  • set-up the snappyHexMeshDict to refine in area of the in/outlets.
The refinement process will only minimize those jagged edges into very small jagged edges! The curved STL will give a fighting chance to snappy to snap the cells along the curved surface :D

I've read somewhere on this forum about defining line edges on the snappyHexMeshDict, but last time I saw something about it, it was still on the TODO list for snappyHexMesh :(

Best Regards,
Bruno Santos

ziemowitzima February 12, 2010 05:07

Hi Bruno,
Thanks for your quick answer and help.
I tried to use Explicit feature edge refinement:
features
(
{
file "someLine.eMesh";
level 2;
}
);

In the file someLine.eMesh I defined outflow edge (set of 132 points going around it circumference) and then edges.
But this didnt improved anything. I think that it is because I defined 131 edges from point to point. Similar like in igloo example.
Do you know how to use it to define one edge as spline for example ?

Best Regards
ZM

wyldckat February 12, 2010 06:02

Hi Ziemowit,

Sadly, like I said, I have limited experience with snappyHexMesh. I have only dealt with the motorBike tutorial, and I have yet to test the igloo tutorial! And like I said, I don't know if they have already implemented the edge part of snappyHexMesh :(

My last advice is to search this forum for "snappyHexMesh edge" and hope to find some thread that already answers your question, or that have asked the same issue about the edge feature!

Best regards,
Bruno Santos

bjr March 31, 2010 23:46

My (perhaps incorrect) understanding is that cranking up the 60 in...

// Resolve sharp angles
resolveFeatureAngle 60;

Is intended to do this? Would you volunteer to experiment? My geometries at hand don't lend themselves to quickly inspecting this?

Ben Racine

ziemowitzima April 1, 2010 05:18

Hi Ben,
Thanks for you interest.
Of course I will experiment with "Resolve sharp angles" value.
But please let me know what value do u suggest ? 90 ?
All Best
Ziemowit

rv82 May 18, 2010 00:56

Hello!
Strange! My post appeared not in this topic, but in blogs. Here. Help me please! :(

niklas June 24, 2010 03:05

I've written a little program that might help, I call it snapEdge.

http://openfoamwiki.net/index.php/Contrib_snapEdge

openfoam_user June 24, 2010 04:15

Hi Niklas,

thanks a lot for the utility snapEdge.

I would like to try it.

Could you explain me how and where to install the directory snapEdge.

Best Regards,

Stephane.

niklas June 24, 2010 04:33

I updated the wiki with some instructions.

openfoam_user June 24, 2010 05:20

2 Attachment(s)
Hi Niklas,

I did another way for the installation.
1. Download snapEdge.tgz
2. Unpack it with 'tar zxfv snapEdge.tgz
3. Put the snapEdge folder in .../OpenFOAM/OpenFOAM-1.6.x/applications/utilities/preProcessing
4. Step back into .../OpenFOAM/OpenFOAM-1.6.x/
5. ./Allwmake

and then the snapEdge command runs well.

Thanks a lot Niklas !

I have attached 2 snapshots of a cube (before and after using the snapEdge utility). I have used your own settings.

The length of my cube is 10 meters. Maybe you know how to modify the settings (parameters) in order to obtain a perfect cube.

Thanks again.

Stephane.

niklas June 24, 2010 06:20

Quote:

Originally Posted by openfoam_user (Post 264310)
The length of my cube is 10 meters. Maybe you know how to modify the settings (parameters) in order to obtain a perfect cube.

That case should be quite simple, try these

// only move those points that are closer to the features than the tolerance*| edge length |
tolerance 2.0;

// 1.0 = move the points to the edge, 0 = dont move the point
relaxation 1.0;

// number of iterations to move points towards edge
nIterations 1;

openfoam_user June 24, 2010 06:59

1 Attachment(s)
hi,

no the result remains the same !

I attach a zipped tar file. If you have time you can try to improve the mesh.

tar xvzf cube.tar.gz

and run the following commands:
blockMesh
snappyHexMesh -overwrite
snapEdge

Regards,
Stephane

niklas June 24, 2010 07:30

OK, no I see the problem. Your points are right on the vertices of the stl-triangles.

in snapEdge.C
change

Code:

if ((lam0 > 0.0) && (lam0 < 1.0))
to
Code:

if ((lam0 >= 0.0) && (lam0 <= 1.0))
and

Code:

if ((lam1 > 0.0) && (lam1 < 1.0))
to
Code:

if ((lam1 >= 0.0) && (lam1 <= 1.0))
recompile and try again

openfoam_user June 24, 2010 07:46

2 Attachment(s)
Hi,

I made the changes.

Now along the edges the mesh is perfect.

Some small problems remain at the corners. Have a closer look at the second picture.

Stephane.

niklas June 24, 2010 07:48

yeah, you have to live with that for now. I still dont know how to fix that :)

niklas June 24, 2010 08:14

hmmm...try this

replace

Code:

if (d0 < minDist0)
with
Code:

if ((d0 < minDist0) && (d0 > VSMALL))
and


Code:

if (d1 < minDist1)
with
Code:

if ((d1 < minDist1) && (d1 > VSMALL))

openfoam_user June 24, 2010 08:52

1 Attachment(s)
The grid at the corner is improved. Now the corner locations are right, but still a very small problem remains. Look at the attached picture. Thanks !

Stephane

niklas June 24, 2010 09:18

right,

the points can now belong to more than 1 edge and because of that you
should decrease the tolerance to below 1, otherwise the corners will attract more points

set
tolerance 0.99

and this will fix it


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