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

[mesh manipulation] Multi-region mesh from .stl files in OpenFoam V7

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By simrego

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 26, 2020, 01:25
Default Multi-region mesh from .stl files in OpenFoam V7
  #1
New Member
 
Carl Reilly
Join Date: Aug 2010
Posts: 25
Rep Power: 15
carl_r is on a distinguished road
I’m relatively new to OpenFoam but have experience with other commercial CFD packages. I am trying to create a domain with multiple meshed regions using OpenFoam V7 and snappyHexMesh. But am struggling to find the required methodology to do this.

In openFoam v19.12 snappyHexMesh (sHM) allows the use of the command locationsInMesh, however this command does not seem to be available in the openFoamV7 release. Instead OFV7 uses locationInMesh to define a single region. I am able to move to coordinate of this to choose which single region (of the 3 regions) in the domain is meshed.

All the tutorials I have found online show using topoSet and splitMesh functions to sub-divide the mesh into different regions / surfaces. However, these tutorials show simple mesh generated using block mesh, my geometry does not lend itself to this method, I want to be able to define the regions by .stl files.

I can’t use snappyHexMesh to create the mesh before using topoSet and splitMesh, as I can’t get sHM to generate a full mesh domain to split. If I merge my geometry files into one stl, to produce a mesh of the whole domain, then the nodes/elements will not align (will not have been snapped to the surfaces) with the boundaries between the different regions, meaning I won’t be able to split the domain along the stl file boundaries.

How do I create a multi-region mesh in OpenFoam V7 and snappyHexMesh using .stl files? Can this be done?

I have attached an image of a simple case study geometry and the files required to mesh in using blockMesh and snappyHexMesh. These files result in only the leftmost part being meshed. The geometry I want to mesh is more complex, this is a simplified geometry to try and solve this issue.
Attached Images
File Type: jpg simpleDomain.jpg (21.3 KB, 66 views)
File Type: jpg simpleDomainWireFrame.jpg (30.2 KB, 42 views)
Attached Files
File Type: zip multiRegionMesh.zip (24.6 KB, 14 views)
carl_r is offline   Reply With Quote

Old   February 26, 2020, 02:50
Default
  #2
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!


You need closed surfaces for the regions as you can see in this example:
https://github.com/OpenFOAM/OpenFOAM...ppyHexMeshDict
In the refinementSurfaces entry you can define a cellZone for each region.
It is more complicated than in the ESI version where you just tell shm the inisde points, but you can do it in the foundation version too. Good luck!
Yann likes this.
simrego is offline   Reply With Quote

Old   February 26, 2020, 23:42
Default
  #3
New Member
 
Carl Reilly
Join Date: Aug 2010
Posts: 25
Rep Power: 15
carl_r is on a distinguished road
Hi,
Thanks for the response. I've tried, but failed to make any progress, my latest files are attached.

I have created a simple geometry. Fluid is in blue and PartA in grey. Currently I can only get PartA meshed.

I did find another tutorial but this one is slightly different in that the external mesh volume is used with separate regions meshed inside. In my case I want to remove the external mesh and keep only the mesh defined inside the .stl files.

https://holzmann-cfd.com/en/openfoam...-snappyhexmesh


I have some questions which I'd be grateful for the answers too:

1) Can the .stl files for PartA and Fluid both be water tight. This would be my preference. Or do i have to delete the surface between Fluid/PartA in one of the files so that there are no duplicate surfaces?

2) Do I still need the locationInMesh variable, if so does it matter which component I specify it in?

3) Are the below definitions correct based on what I'm trying to achieve and is there something missing?

Code:
geometry
{
	Fluid_AllSurf.stl {type triSurfaceMesh; name Fluid;}
	PartA_AllSurf.stl {type triSurfaceMesh; name PartA;}
};


castellatedMeshControls
{
    features 
    (
        {file "Fluid_AllSurf.eMesh"; level 1;} 
        {file "PartA_AllSurf.eMesh"; level 1;}
    );
    
    
    refinementSurfaces
    {
        Fluid         // Tried using .stl file name here, No improvement 
        {
            level (1 1);
            faceZone    faceFluid;
            cellZone    cellFluid;
            cellZoneInside inside;     // inside / outside / specified insidePoint
            boundary    internal;
        }

        PartA
        {
            level (1 1);
            faceZone    facePartA;
            cellZone    cellPartA;
            cellZoneInside inside;
            boundary    internal;
        }
        

        locationInMesh (0.02 0.02 -0.01);   // located in PartA
}
Attached Images
File Type: jpg simpleGeom.jpg (15.3 KB, 41 views)
Attached Files
File Type: zip CaseFiles2.zip (12.6 KB, 5 views)
carl_r is offline   Reply With Quote

Old   February 27, 2020, 03:43
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,097
Rep Power: 26
Yann will become famous soon enough
Hi Carl,

I didn't run the case cause I don't have OF7 installed right now, but there is a chtMultiRegionFoam tutorial using snappyHexMesh in OF7 : https://github.com/OpenFOAM/OpenFOAM...eHeatExchanger

The process is still the same : defining cellzones for each regions, meshing the whole domain, then using splitMeshRegions to split your initial mesh in one mesh by region.

Removing the external region isn't a big deal: after splitting the mesh, you can simply delete the unwanted regions. Just pay attention to the boundaries, you may need to adjust the boundary types (wall, patch...) depending on your configuration.

I hope this helps,
Yann
Yann is offline   Reply With Quote

Old   March 2, 2020, 19:25
Default
  #5
New Member
 
Carl Reilly
Join Date: Aug 2010
Posts: 25
Rep Power: 15
carl_r is on a distinguished road
I have made some progress. I have broken my .stl files down into separate surfaces, so that I can define my patches.

I have got to the point where I can generate either a mesh in the two parts with no patches, or the mesh for 1 part including the patches, but not both.

If I include the faceZone, CellZones and cellZoneInside, boundry lines I get both parts meshed. If I don't include them I get only PartA Meshed, but all the patches are correctly defined.


Geometry Definition:
Code:
geometry
{
    Fluid.stl
    {
        type triSurfaceMesh;
        regions
        {
            Fluid_Inlet { name Fluid_Inlet; }
            Fluid_Sym   { name Fluid_Sym; }
            Fluid_Env   { name Fluid_Env; }
            Fluid_PartA { name Fluid_PartA; }
        }
    }
    
    PartA.stl
    {
        type triSurfaceMesh;
        regions
        {
            PartA_Inlet { name PartA_Inlet;}
            PartA_Sym   { name PartA_Sym;}
            PartA_Env   { name PartA_Env;}
            PartA_Fluid { name PartA_Fluid;}
        }
    }

RefinementSurfaces:
Code:
    refinementSurfaces         // Surface-wise min and max refinement level
    {
        Fluid.stl
        {
            level (1 1);

            regions
            {
                Fluid_Inlet { level (1 1); patchInfo { type patch; }}
                Fluid_Sym   { level (1 1); patchInfo { type patch }}
                Fluid_Env   { level (1 1); patchInfo { type wall; }}
                Fluid_PartA { level (1 1); patchInfo { type wall; }}
            }
       //     faceZone    faceFluid;
       //     cellZone    cellFluid;
       //     cellZoneInside inside;
       //     boundary    internal;
        }

        PartA.stl
        {
            level (1 1);

            regions
            {
                PartA_Inlet { level (1 1); patchInfo { type patch; }}
                PartA_Sym   { level (1 1); patchInfo { type patch }}
                PartA_Env   { level (1 1); patchInfo { type wall; }}
                PartA_Fluid { level (1 1); patchInfo { type wall; }}
            }
        //    faceZone    facePartA;
        //    cellZone    cellPartA;
        //    cellZoneInside inside;
        //    boundary    internal;
        }

How do I generate the patch names and the two volumes?

Am I correct in thinking that this can all be done in sHM, or do I have to do the patch and part definition in topoSet and splitMesh? I feel like i'm getting confused as there are multiple ways of doing the same thing, with each tutorial choosing a different method.

Files attached.
I would appreciate any help given.
Attached Files
File Type: zip CaseFiles.zip (22.9 KB, 14 views)
carl_r is offline   Reply With Quote

Old   March 18, 2020, 01:57
Default
  #6
Senior Member
 
linnemann's Avatar
 
Niels Nielsen
Join Date: Mar 2009
Location: NJ - Denmark
Posts: 555
Rep Power: 27
linnemann will become famous soon enough
Hi

If you look at the tutorial tutorials/heatTransfer/chtMultiRegionFoam/shellAndTubeHeatExchanger

It will give you an idea of what you need to do.
Basically you need to divide your geometry into "zones" containing a "closed" volume for each zone. The thing you need to do differently is to have the face between the "zones" being in a separate stl with not regions.

On another note snappy is really not the best mesher for you case due to the pointy end.
Attached Images
File Type: jpg 2020-03-18 07-Clipboard-000132.jpg (70.0 KB, 96 views)
__________________
Linnemann

PS. I do not do personal support, so please post in the forums.
linnemann is offline   Reply With Quote

Old   March 30, 2021, 10:23
Default
  #7
Member
 
Join Date: Nov 2018
Posts: 39
Rep Power: 7
MaySea is on a distinguished road
Quote:
Originally Posted by carl_r View Post
I have made some progress. I have broken my .stl files down into separate surfaces, so that I can define my patches.

I have got to the point where I can generate either a mesh in the two parts with no patches, or the mesh for 1 part including the patches, but not both.

If I include the faceZone, CellZones and cellZoneInside, boundry lines I get both parts meshed. If I don't include them I get only PartA Meshed, but all the patches are correctly defined.


Geometry Definition:
Code:
geometry
{
    Fluid.stl
    {
        type triSurfaceMesh;
        regions
        {
            Fluid_Inlet { name Fluid_Inlet; }
            Fluid_Sym   { name Fluid_Sym; }
            Fluid_Env   { name Fluid_Env; }
            Fluid_PartA { name Fluid_PartA; }
        }
    }
    
    PartA.stl
    {
        type triSurfaceMesh;
        regions
        {
            PartA_Inlet { name PartA_Inlet;}
            PartA_Sym   { name PartA_Sym;}
            PartA_Env   { name PartA_Env;}
            PartA_Fluid { name PartA_Fluid;}
        }
    }

RefinementSurfaces:
Code:
    refinementSurfaces         // Surface-wise min and max refinement level
    {
        Fluid.stl
        {
            level (1 1);

            regions
            {
                Fluid_Inlet { level (1 1); patchInfo { type patch; }}
                Fluid_Sym   { level (1 1); patchInfo { type patch }}
                Fluid_Env   { level (1 1); patchInfo { type wall; }}
                Fluid_PartA { level (1 1); patchInfo { type wall; }}
            }
       //     faceZone    faceFluid;
       //     cellZone    cellFluid;
       //     cellZoneInside inside;
       //     boundary    internal;
        }

        PartA.stl
        {
            level (1 1);

            regions
            {
                PartA_Inlet { level (1 1); patchInfo { type patch; }}
                PartA_Sym   { level (1 1); patchInfo { type patch }}
                PartA_Env   { level (1 1); patchInfo { type wall; }}
                PartA_Fluid { level (1 1); patchInfo { type wall; }}
            }
        //    faceZone    facePartA;
        //    cellZone    cellPartA;
        //    cellZoneInside inside;
        //    boundary    internal;
        }

How do I generate the patch names and the two volumes?

Am I correct in thinking that this can all be done in sHM, or do I have to do the patch and part definition in topoSet and splitMesh? I feel like i'm getting confused as there are multiple ways of doing the same thing, with each tutorial choosing a different method.

Files attached.
I would appreciate any help given.
Hi Carl,

May I ask you how did you separate your .stl file into regions?
I have multiple .stl files forming one terrain surface and I would like to have them as one .stl file with multiple regions.

EDIT: Ok, I got what I wanted using the cat command cat *.stl >> combined.stl. Easier than I thought.

like this:
Code:
    Fluid.stl
    {
        type triSurfaceMesh;
        regions
        {
            Fluid_Inlet { name Fluid_Inlet; }
            Fluid_Sym   { name Fluid_Sym; }
            Fluid_Env   { name Fluid_Env; }
            Fluid_PartA { name Fluid_PartA; }
        }
Cheers,
Jan
MaySea is offline   Reply With Quote

Old   January 4, 2024, 09:02
Default
  #8
Senior Member
 
TWB
Join Date: Mar 2009
Posts: 402
Rep Power: 19
quarkz is on a distinguished road
Thanks ppl, I got it to work too.

FYI, my stl was created using Pointwise and I can use the different domains to create the stl, which is separated into multi regions. The CAD was imported from Solidworks.
quarkz is offline   Reply With Quote

Reply

Tags
multi-region mesh


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
[snappyHexMesh] Creating multi region mesh for chtMultiregionFoam tclph OpenFOAM Meshing & Mesh Conversion 1 December 8, 2020 15:25
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 05:38
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 09:38
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 04:15


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