CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

problem with meshing after setSet

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By boffin5
  • 1 Post By boffin5

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 8, 2021, 14:38
Default problem with meshing after setSet
  #1
Senior Member
 
Alan w
Join Date: Feb 2021
Posts: 260
Rep Power: 6
boffin5 is on a distinguished road
Hi everyone,


Currently I am in the throes of creating a simulation of airflow through a car radiator. I had success with the 2D case, and am now working with a 3D model of a canted radiator inside a simple fairing.


In order to have separate regions to facilitate assigning Darcy Forchheimer coefficients in fvOptions, I followed the Toby Holzmann video on setSet. It worked as advertised, and I now have a fluid (air) region and a radiator region.


The problem is, the meshing in a corner is too coarse and doesn't capture the corner (see images). I tried to fix this in 3 different ways: captured the intended corner (called edge1) for refinement, creating a refinement zone, and creating a box stl file containing the problem area. None of them worked.


Somehow the process of using setSet to create multiple regions is hampering my efforts at mesh refinement; or maybe it's some other problem that is eluding me. btw, to facilitate the setSet operations, i created a big space called domain, that is the same size as the blockMesh. I believe that SHM -overwrite causes the blockMesh to be replaced with my 'domain' stl file.
Here is my SHMDict file:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  8                                     |
|   \\  /    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         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;
        regions
        {
            domain-inlet            { name inlet;    }
            domain-outlet           { name outlet;   } 
            domain-upperwall        { name upperwall;}
            domain-ground           { name ground;   }
            domain-leftside         { name leftside; }
            domain-rightside        { name rightside;}
        }
    }
    
    simple-bod.stl
    {
        type triSurfaceMesh;
        name bod;        
    }
    
    radiator.stl
    {
        type triSurfaceMesh;
        name rad;
    
    refbox.stl
    {
        type triSurfaceMesh;
        name    refbox;
    }
       
    /*refinementBox
    {
        type searchableBox;
        min ( 2.1 -0.5 -0.1);
        max ( 2.3  0.5  0.1);
    }*/
    
    }
};

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

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


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



    // 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 "domain.eMesh";
            level 3;
        }
        
        {
            file "simple-bod.eMesh";
            level 3;
        }
        
        {
            file "radiator.eMesh";
            level 3;
        }
        
        {
            file "edge1.eMesh";
            level 3;
        }
    );



    // 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
    {
        domain.stl
        {
            level (3 3);
            regions
            {
                domain-inlet            { level (0 0); patchInfo { type patch;   }}
                domain-outlet           { level (0 0); patchInfo { type patch;   }} 
                domain-upperwall        { level (0 0); patchInfo { type slip ;   }} 
                domain-ground           { level (0 0); patchInfo { type wall ;   }} 
                domain-leftside         { level (0 0); patchInfo { type slip ;   }} 
                domain-rightside        { level (0 0); patchInfo { type symmetry;}} 
            }
        }
    
        bod
        {
            // Surface-wise min and max refinement level
            level (3 3);
            
        }
        
        rad
        {
            // Surface-wise min and max refinement level
            level (3 3);
            
            cellZone           solid;
            faceZone           solid;
            cellZoneInside    inside;
            
        }
    }

    // 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
    {
    
    refbox  
        {                
            mode inside;            //mode distance         
            levels ((1e15 3));      //levels ((0.02 4))
        }
        
    /*refinementBox
        {
            mode inside;
            levels ((1E15 3));
        }*/
    }


    // 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.1 -0.1 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 no;
}



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

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

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

    // Feature snapping

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

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



// 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
    {
        bod 
        {
            nSurfaceLayers  3;
        }
    }

    // Expansion factor for layer mesh
    expansionRatio 1.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.
    // is the thickness of the layer furthest away from the wall.
    // See relativeSizes parameter.
    finalLayerThickness 0.7;

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

    // 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
    // are perpendicular
    featureAngle 85;

    // At non-patched sides allow mesh to slip if extrusion direction makes
    // angle larger than slipFeatureAngle.
    slipFeatureAngle 25;

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

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

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

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


// ************************************************************************* //
If anyone has ideas on how to fix this mesh (aka in this case, mess), please let me know!
Attached Images
File Type: png radiator-section.png (49.0 KB, 11 views)
File Type: png radiator-iso.png (3.9 KB, 12 views)
boffin5 is offline   Reply With Quote

Old   September 12, 2021, 14:53
Default problem with meshing after using setSet to create regions
  #2
Senior Member
 
Alan w
Join Date: Feb 2021
Posts: 260
Rep Power: 6
boffin5 is on a distinguished road
Hi, this is continuation of the problem I posted on 8 September. This is regarding a simulation of a car radiator inside of a simple fairing. I still cannot resolve my meshing problem, and hope that someone can have a look.



My case files are in dropbox in a folder called radiator-case: https://www.dropbox.com/sh/upn8s43wm...txtblplba?dl=0
Images of the fairing and the meshing problem are attached.



Description: There are 2 regions: a domain, which is just smaller than the blockMeshDict, and a radiator. Additionally, there is a fairing called simple-bod which houses the radiator, but I don't think this needs to have its own region. But I could be wrong.



First I run surfaceFeatures, then blockMesh. After I run snappyHexMesh -overwrite, 2 regions are visible: a fluid region resulting from domain, and a solid region resulting from the radiator. The fairing, now called bod, is also visible.


Problem: an internal mesh also shows up, with very fine gridding. Was this the result of blockMeshDict? If so, I don't know how the gridding got so fine. I uncheck this, since it is not the region of interest.



The mesh at the bottom of the radiator is too coarse, and the radiator corner has rounded into a blob. But, all my attempts at refining the mesh are ineffective. In fact, for the region called domain, I can't seem to change the fineness of the mesh at all. Unlike in blockMeshDict, where you specify the cell count, the domain cell fineness is declared in snappyHexMeshDict, but changing the mesh settings for domain there don't have any effect as seen in paraView.


Question: how do I control the mesh fineness in the domain region? If I can understand that, I should be able to resolve the meshing problem at the corner of the radiator.


I would greatly appreciate any help, Alan w
Attached Images
File Type: png radiator-iso.png (3.9 KB, 3 views)
File Type: png radiator-section.png (49.0 KB, 2 views)
boffin5 is offline   Reply With Quote

Old   September 13, 2021, 03:56
Default
  #3
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,066
Rep Power: 26
Yann will become famous soon enough
Hi Alan,

You are having trouble to refine your mesh with snappyHexMesh because you reached the mesh size limit defined in the maxGlobalCells parameter:

Code:
    maxLocalCells 2000000;
    maxGlobalCells 400000;
These parameters are limiting the number of cells to 2 000 000 on each processor, but 400 000 for the whole mesh. (have a look there : https://cfd.direct/openfoam/user-gui...snappyhexmesh/)

If you look carefully the snappyHexMesh log you will see this message:

Code:
No cells marked for refinement since reached limit 400000.
Snappy basically stops refining the mesh because it reached the mesh size limit. It will keep on going with the meshing process but will not refine anything. This is why your attempts at refining the mesh are ineffective. You have to increase this limit if you want to be able to refine your mesh as you wish.

Snappy also complains about your cellZone definition because your STL files are not closed:

Code:
Reading refinement surfaces.
--> FOAM Warning : 
    From function Foam::surfaceZonesInfo::surfaceZonesInfo(const Foam::searchableSurface&, const Foam::dictionary&)
    in file refinementSurfaces/surfaceZonesInfo.C at line 125
    Reading "/mnt/c/Users/Yann/OpenFOAM-8-run/radiator-case/system/snappyHexMeshDict/castellatedMeshControls/refinementSurfaces/rad" from line 168 to line 179
    Illegal entry zoneInside inside for faceZone solid since surface is not closed.
--> FOAM Warning : 
    From function Foam::refinementSurfaces::refinementSurfaces(const Foam::searchableSurfaces&, const Foam::dictionary&, Foam::label)
    in file refinementSurfaces/refinementSurfaces.C at line 215
    Reading "/mnt/c/Users/Yann/OpenFOAM-8-run/radiator-case/system/snappyHexMeshDict/castellatedMeshControls/refinementSurfaces" from line 142 to line 179
      Not all entries in refinementSurfaces dictionary were used. The following entries were not used : 1(inlet-floor)
You should probably solve this before moving on.
I will leave you there for now, I am pretty sure this should be enough for you to get back on track. Let us know how it goes!


Cheers,
Yann
Yann is offline   Reply With Quote

Old   September 16, 2021, 11:51
Default Thanks, and I'm changing strategy
  #4
Senior Member
 
Alan w
Join Date: Feb 2021
Posts: 260
Rep Power: 6
boffin5 is on a distinguished road
Thanks Yann, as always your advice is helpful and valuable. However, in this case it didn't help my meshing problem. But I'm not sure that setSet is the way to go. One reason is that there's hardly any mention of it when I do searches; there is much more information available regarding topoSet.
So I have switched my approach on the car radiator problem to one using topoSet. I'll let you know if I have problems with this. Actually, 'if' is more likely to be 'when'.
boffin5 is offline   Reply With Quote

Old   September 16, 2021, 12:41
Default
  #5
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,066
Rep Power: 26
Yann will become famous soon enough
Hi Alan,


May I ask why you need to use setSet or topoSet? If your cellZone is properly defined in snappyHexMeshDict it should be enough, isn't it?

Can you elaborate on your workflow?


Yann
Yann is offline   Reply With Quote

Old   September 17, 2021, 12:24
Default
  #6
Senior Member
 
Alan w
Join Date: Feb 2021
Posts: 260
Rep Power: 6
boffin5 is on a distinguished road
Thanks Yann,
You are right, of course. As I slog my way through learning multiregions, I discovered that setting up cellZones simultaneously in SHMDict and topoSet is not allowed. But I feel that if I can understand topoSet, it will give me more capability in areas to come, including heat transfer.
That said, I am now struggling with making the topoSet surfaceToCells function work, and if after today's session I haven't conquered it, I will post another plea for help.
Alan w
Yann likes this.
boffin5 is offline   Reply With Quote

Old   September 19, 2021, 05:34
Default continuing problems with multiregion setup
  #7
Senior Member
 
Alan w
Join Date: Feb 2021
Posts: 260
Rep Power: 6
boffin5 is on a distinguished road
Alas, I am still in the wilderness in setting up a multiregion simulation case. And I found a video depicting the same situation that I am in when I initiated this thread. Here is the link: https://www.youtube.com/watch?v=lj7J0JI75CU and it is titled "snappy HexMesh setting for MultiRegion." The audio is in Japanese, but you can follow through and get the gist of things. Sorry, the image captures are fuzzy,but they are understandable.


Image1 shows a failure case, where the SHMDict geometry has a fluid.stl and a body.stl, and in the refinementSurfaces, the body has faceZone and cellZone prescribed, which should create it as a region. But when SHM is run, that region is ignored.


Image2 shows a success case, where the fluidzone regions are prescribed in the geometry section, and also in the refinementSurfaces section, along with the body.stl faceZone and cellZone lines. In this case, it is also necessary to use setSet, as shown in image3, to subtract out the body from the overall fluid region, to end up with the desired 2 regions.


When I did this in my first attempt, I found that basic internal mesh as given in blockMesh is now redundant. Apparently, this is normal. But, the problem is, that with this redundancy, you lose the "knobs" that control the overall mesh density, along with the refinement zones. Changing the individual region mesh settings in SHMDict had no effect. I lost control of the mesh fineness, and was unable to end up with an acceptable mesh. Apparently the Japanese had no problem with this, but how they solved it is not shown. Maybe they talked about it, but 'no hablo Japanese.'


I have also been wrangling with topoSet, but have been going around in circles and/or up dead ends, and have gotten nowhere.



My last hope is to look at the snappy multiregion heater v2012 tutorial. Obviously the technical world has no problem with this, and I'll get it at length (already there).
Attached Images
File Type: jpg multiregion1.jpg (32.9 KB, 6 views)
File Type: jpg multiregion2.jpg (35.1 KB, 6 views)
File Type: jpg multiregion3.jpg (30.8 KB, 5 views)
boffin5 is offline   Reply With Quote

Old   September 19, 2021, 10:29
Default
  #8
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,066
Rep Power: 26
Yann will become famous soon enough
Hi Alan,

I'm not sure to understand your post but to be honest I did not go into the video you described.

In the case you posted before, the cellZone is ignored because your STL files are not closed. Snappy gives you a warning about this when starting, as I mentioned before.

You have to fix your STL files and you will be able to do everything in snappy AND get proper regions with splitMeshRegions.

You will find an example attached. For the sake of simplicity I removed your domain.stl file and did it only with blockMesh, simple-bod and radiator STLs. But you can do pretty much the same thing with a domain.stl if you wish.

Starting from there you should be able to tune your refinement parameters to match your expectations.

To fix your STL files, I used surfacePointMerge on the radiator file because it has duplicate points on some edges. Then I used surfaceHookUp to close the open edges on both simple-bod.stl and radiator.stl. In such situations, surfaceCheck comes in handy to see what is wrong with the file.

I can develop this later if you struggle to use it.

Cheers,
Yann
Attached Files
File Type: zip radiator-case-mod.zip (12.4 KB, 6 views)
Yann is offline   Reply With Quote

Old   September 21, 2021, 15:31
Default
  #9
Senior Member
 
Alan w
Join Date: Feb 2021
Posts: 260
Rep Power: 6
boffin5 is on a distinguished road
Incredible. After all my struggles, you fix it just like that. And the problem was a defective cuboid!? A big takeaway for me from all this, is the surface repair functions, of which I was totally unaware. Okay; off I go, and profuse thanks to you for helping me again!
Yann likes this.
boffin5 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
Problem with querying the meshing database in CFX-Pre ashtonJ CFX 18 April 18, 2023 23:49
[ANSYS Meshing] Wing leading edge curvature meshing problem Alexia166 ANSYS Meshing & Geometry 2 April 21, 2021 04:29
[ICEM] ICEM CFD volume meshing problem PietW ANSYS Meshing & Geometry 5 September 15, 2020 04:19
[Gmsh] Vertex numbering is dense KateEisenhower OpenFOAM Meshing & Mesh Conversion 7 August 3, 2015 10:49
Meshing problem in GAMBIT Vidya Raja FLUENT 0 May 20, 2006 23:31


All times are GMT -4. The time now is 15:40.