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 Tree2Likes
  • 1 Post By carl_r
  • 1 Post By simrego

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 26, 2020, 02:25
Default Multi-region mesh from .stl files in OpenFoam V7
  #1
New Member
 
Carl Reilly
Join Date: Aug 2010
Posts: 26
Rep Power: 16
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, 67 views)
File Type: jpg simpleDomainWireFrame.jpg (30.2 KB, 44 views)
Attached Files
File Type: zip multiRegionMesh.zip (24.6 KB, 15 views)
Jim1310 likes this.
carl_r is offline   Reply With Quote

Old   February 26, 2020, 03: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 27, 2020, 00:42
Default
  #3
New Member
 
Carl Reilly
Join Date: Aug 2010
Posts: 26
Rep Power: 16
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, 45 views)
Attached Files
File Type: zip CaseFiles2.zip (12.6 KB, 5 views)
carl_r is offline   Reply With Quote

Old   February 27, 2020, 04:43
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,236
Rep Power: 29
Yann will become famous soon enoughYann 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 online now   Reply With Quote

Old   March 2, 2020, 20:25
Default
  #5
New Member
 
Carl Reilly
Join Date: Aug 2010
Posts: 26
Rep Power: 16
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, 15 views)
carl_r is offline   Reply With Quote

Old   March 18, 2020, 02:57
Default
  #6
Senior Member
 
linnemann's Avatar
 
Niels Nielsen
Join Date: Mar 2009
Location: NJ - Denmark
Posts: 556
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, 103 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, 11:23
Default
  #7
Member
 
Jan Majcher
Join Date: Nov 2018
Posts: 39
Rep Power: 8
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, 10:02
Default
  #8
Senior Member
 
TWB
Join Date: Mar 2009
Posts: 414
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

Old   December 10, 2024, 05:24
Default
  #9
New Member
 
Join Date: Nov 2024
Posts: 3
Rep Power: 2
Patuco is on a distinguished road
Hi,

I am having the same problem, I am not able to generate a multiregion mesh with SHM. Could you send or explain how you managed to solve it, please.

Thank you very much,
Patuco is offline   Reply With Quote

Old   December 10, 2024, 05:48
Default
  #10
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,236
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Hello Patuco,

Your question is too generic, you should rather explain what you tried to do and what problems you are facing.

How to give enough info to get help
Yann is online now   Reply With Quote

Old   December 10, 2024, 06:38
Default
  #11
New Member
 
Join Date: Nov 2024
Posts: 3
Rep Power: 2
Patuco is on a distinguished road
Hello Yann,
The problem I am having is that when I change my stl and the file names of the tutorial sehllandtubeheatexchanger so that everything makes sense and when I launch the simulation it does not generate the mesh, it only generates the blockmesh.

When I change this blockmesh so that it cuts my mesh, it generates the patches, although it does not generate all my simulation zone. But it does not order them as it should even if I have specified it in SHM and many times they are not even patches between regions.

The geometry is very simple, it tells me that there are closed surfaces but in the tutorial also shows that failure and if it generates the mesh.

This is my SnappyHexMesh code:


#includeEtc "caseDicts/mesh/generation/snappyHexMeshDict.cfg"

castellatedMesh on;
snap on;
addLayers off;

geometry
{
shell
{
type triSurfaceMesh;
file "shell.stl";
regions
{
inlet_s { name inlet_s; }
outlet_s { name outlet_s; }
}
}
air
{
type triSurfaceMesh;
file "air.stl";
regions
{
inlet_a { name inlet_a; }
outlet_a { name outlet_a; }
down { name down; }
top { name top; }
laterales { name laterales; }
}
}
solid
{
type triSurfaceMesh;
file "solid.stl";
regions
{
in_wall { name in_wall; }
out_wall { name out_wall; }
}
}

shell_to_solid
{
type triSurfaceMesh;
file "shell_to_solid.stl";
}
air_to_shell
{
type triSurfaceMesh;
file "air_to_shell.stl";
}
};

castellatedMeshControls
{
features
(
);

refinementSurfaces
{
shell
{
level (1 1);

regions
{
inlet_s { level (1 1); patchInfo { type patch; } }
outlet_s { level (1 1); patchInfo { type patch; } }

}
}
air
{
level (1 1);
regions
{
inlet_a { level (1 1); patchInfo { type patch; } }
outlet_a { level (1 1); patchInfo { type patch; } }

}
}
solid
{
level (1 1);
regions
{
in_wall { level (1 1); patchInfo { type wall; } }
out_wall { level (1 1); patchInfo { type wall; } }
}
}

shell_to_solid
{
level (1 1);
faceZone shell_to_solid;
cellZone shell;
mode inside;
}
air_to_shell
{
level (1 1);
faceZone air_to_shell;
cellZone air;
mode inside;
}
}

insidePoint (0 0.008 0.015);

nCellsBetweenLevels 2;

resolveFeatureAngle 15;
}

snapControls
{
implicitFeatureSnap true;
}

addLayersControls
{
layers
{

shell_to_solid
{
nSurfaceLayers 2;
mergeFaces false;
}
air_to_shell
{
nSurfaceLayers 2;
mergeFaces false;
}
}

relativeSizes true;
expansionRatio 1.2;
finalLayerThickness 0.5;
minThickness 1e-3;
}

mergeTolerance 1e-6;
Patuco is offline   Reply With Quote

Old   December 11, 2024, 09:06
Default
  #12
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,236
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Could you post the log files of snappy and splitMesh?

Are you running the Allmesh.layers or Allmesh.noLayers scripts?
In order to debug your case it would probably be better to use the Allmesh.noLayers as it is simpler and avoid all the extra steps done to deal with layer addition.
Yann is online now   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 16:25
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 06:38
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15


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