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

[snappyHexMesh] STL file for snappyHexMesh

Register Blogs Community New Posts Updated Threads Search

Like Tree9Likes
  • 3 Post By petros
  • 3 Post By otaolafr
  • 1 Post By otaolafr
  • 1 Post By tedbr
  • 1 Post By LakshmiIC35134

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 28, 2020, 18:14
Default STL file for snappyHexMesh
  #1
Member
 
Tommaso M.
Join Date: Sep 2018
Location: Milan, Italy
Posts: 67
Rep Power: 8
TommyM is on a distinguished road
Hi All,

I need to create a mesh by using snappyHexMesh.
I create the CAD file as an assembly and convert it into an STL. When I open such STL file it contains only a single "solid", while it should be composed by two solids, i.e. wall and cylinder. In this way I cannot distinguish them as different patches while making the mesh.
Does anyone know how to generate an STL file (from CAD) which contains the parts as different solids and not as a single object?
Best,

Tommy
TommyM is offline   Reply With Quote

Old   September 29, 2020, 10:22
Default
  #2
Member
 
Petros Ampatzidis
Join Date: Oct 2018
Location: Bath, UK
Posts: 64
Rep Power: 8
petros is on a distinguished road
Hi Tommy,

What you usually want to do is (1) to export the differet parts of your geometry in different STL files and (2) combine them in a single STL file and use it in snappyHexMesh.

1. Open the STL files with a text editor and check that the name of the boundary is correct. E.g.:

instead of
Code:
solid Exported from Blender-2.83.2
facet normal -1.000000 0.000000 0.000000
outer loop
...
...
endloop
endfacet
endsolid Exported from Blender-2.83.2
You change it into
Code:
solid inlet
facet normal -1.000000 0.000000 0.000000
outer loop
...
...
endloop
endfacet
endsolid inlet
2. Then you can combine the different STL files into a single one with:

Code:
cat *.stl >> combined.stl
Now you can access all your patches in snappyHexMesh.

Best,
Petros
lourencosm, hogsonik and TommyM like this.
petros is offline   Reply With Quote

Old   September 29, 2020, 10:23
Default
  #3
Senior Member
 
Franco
Join Date: Nov 2019
Location: Compiègne, France
Posts: 129
Rep Power: 7
otaolafr is on a distinguished road
Quote:
Originally Posted by TommyM View Post
Hi All,

I need to create a mesh by using snappyHexMesh.
I create the CAD file as an assembly and convert it into an STL. When I open such STL file it contains only a single "solid", while it should be composed by two solids, i.e. wall and cylinder. In this way I cannot distinguish them as different patches while making the mesh.
Does anyone know how to generate an STL file (from CAD) which contains the parts as different solids and not as a single object?
Best,

Tommy
hello tommy,
it depends in what CAD software you are using, from what I know, salomé, and blender (for sure) and maybe freecad? can do this.
if you are working with a different cad software than the ones i mentioned before, you have two possibilities (i recomend the fist one):
1. export your file (the complete geometry) in STEP format, import it to salomé (in the geometry section) and from there create groups with the faces that you want to be differentiated and then mesh it with 2D meshes, separatly, export them in separate stls and then use the command cat to create a combined stl. this way snappy will recognize the different groups you created. a good guide https://www.youtube.com/watch?v=CeuF...el=HolzmannCFD

2. use topoSet after doing the snappy by selecting the desired group of faces, the problem with this is that you are not going to be able to add the boundary layer in a specific patch. https://www.youtube.com/watch?v=l_ea...hannel=TheoOng

also recommend you to read the pinned post Creating waterproof STL using snappyHexMesh or salome

good luck!
franco
otaolafr is offline   Reply With Quote

Old   September 30, 2020, 10:49
Default
  #4
Member
 
Tommaso M.
Join Date: Sep 2018
Location: Milan, Italy
Posts: 67
Rep Power: 8
TommyM is on a distinguished road
Quote:
Originally Posted by petros View Post
Hi Tommy,

What you usually want to do is (1) to export the differet parts of your geometry in different STL files and (2) combine them in a single STL file and use it in snappyHexMesh.

1. Open the STL files with a text editor and check that the name of the boundary is correct. E.g.:

instead of
Code:
solid Exported from Blender-2.83.2
facet normal -1.000000 0.000000 0.000000
outer loop
...
...
endloop
endfacet
endsolid Exported from Blender-2.83.2
You change it into
Code:
solid inlet
facet normal -1.000000 0.000000 0.000000
outer loop
...
...
endloop
endfacet
endsolid inlet
2. Then you can combine the different STL files into a single one with:

Code:
cat *.stl >> combined.stl
Now you can access all your patches in snappyHexMesh.

Best,
Petros
Hi Petros,
I did not think about it but your solution is very simple and smart.
Thank you very much for the tip!
Best,

Tommy
TommyM is offline   Reply With Quote

Old   September 30, 2020, 10:54
Default
  #5
Member
 
Tommaso M.
Join Date: Sep 2018
Location: Milan, Italy
Posts: 67
Rep Power: 8
TommyM is on a distinguished road
Quote:
Originally Posted by otaolafr View Post
hello tommy,
it depends in what CAD software you are using, from what I know, salomé, and blender (for sure) and maybe freecad? can do this.
if you are working with a different cad software than the ones i mentioned before, you have two possibilities (i recomend the fist one):
1. export your file (the complete geometry) in STEP format, import it to salomé (in the geometry section) and from there create groups with the faces that you want to be differentiated and then mesh it with 2D meshes, separatly, export them in separate stls and then use the command cat to create a combined stl. this way snappy will recognize the different groups you created. a good guide https://www.youtube.com/watch?v=CeuF...el=HolzmannCFD

2. use topoSet after doing the snappy by selecting the desired group of faces, the problem with this is that you are not going to be able to add the boundary layer in a specific patch. https://www.youtube.com/watch?v=l_ea...hannel=TheoOng

also recommend you to read the pinned post Creating waterproof STL using snappyHexMesh or salome

good luck!
franco
Hi Franco,
I use Autodesk Inventor and SolidWorks. Anyway, as far as I know, Salome and Blender are free, so I can consider to download one of them.
The solution suggested by Petros is great but things could come to be complex when you are modelling an assembly composed by tens of parts (at the moment it is not my case), and an automatic way to generate solids in the same STL could be very useful.
Thanks!

Tommy
TommyM is offline   Reply With Quote

Old   September 30, 2020, 14:25
Default
  #6
Senior Member
 
Franco
Join Date: Nov 2019
Location: Compiègne, France
Posts: 129
Rep Power: 7
otaolafr is on a distinguished road
Quote:
Originally Posted by TommyM View Post
Hi Franco,
I use Autodesk Inventor and SolidWorks. Anyway, as far as I know, Salome and Blender are free, so I can consider to download one of them.
The solution suggested by Petros is great but things could come to be complex when you are modelling an assembly composed by tens of parts (at the moment it is not my case), and an automatic way to generate solids in the same STL could be very useful.
Thanks!

Tommy
hello tommyM,
the problem with petros way, and it really depends in the software (i dont know with solidworks and autodesk) is that when you do this without previously doing a remeshing of the surface you risk that your STL is not watertight. thats why you go to salome to remeshed and then export it separatly . please have a look at this post Creating waterproof STL using snappyHexMesh or salome

thats why i was telling you to go thought salomé, but you can try actually to export your different patches (in ASCII stl format!!!)directly from the cad software and use cat command ( you place all the stls in same folder, you modify them with a text editor and change the names as petros said, and then use the command (cat *.stl >> completeModel.stl). actually it is the same workflow as doing the salome path but the difference is that depending on the software where you export it, it is or not going to be watertight. and there you are going to have a only stl file (completeModel.stl) that it is going to have the boundaries (you should name them in the snappyHexDict too)
franco.
TommyM likes this.
otaolafr is offline   Reply With Quote

Old   September 30, 2020, 14:43
Default
  #7
Member
 
Petros Ampatzidis
Join Date: Oct 2018
Location: Bath, UK
Posts: 64
Rep Power: 8
petros is on a distinguished road
Franco is right. When I wrote my first post I assumed that the geometry is exported from a mesher like Salome or Blender. And by the way, you can always import CAD files into these software for manipulation.

Petros
petros is offline   Reply With Quote

Old   October 1, 2020, 11:40
Default
  #8
Member
 
Tommaso M.
Join Date: Sep 2018
Location: Milan, Italy
Posts: 67
Rep Power: 8
TommyM is on a distinguished road
Hi,
ok, I will learn to use Salome.
Thank you both for your hints, they are very helpful!
Best,

Tommy
TommyM is offline   Reply With Quote

Old   October 2, 2020, 05:40
Default
  #9
New Member
 
Bradon
Join Date: Jun 2020
Location: Berlin
Posts: 1
Rep Power: 0
tedbr is on a distinguished road
I generally use FreeCAD with their mesh option, to export my stl files. Which if you are a solidworks user you pretty get familiar with.
otaolafr likes this.
tedbr is offline   Reply With Quote

Old   March 8, 2022, 12:13
Default STL file
  #10
New Member
 
Afshin Davarpanah
Join Date: Oct 2021
Posts: 5
Rep Power: 5
afshindpe is on a distinguished road
Hello everyone

I export an STL file from surface Evolution to use for snappyHexMesh. Unfortunately, after running the snappyHexMesh command, it does not recognize the STL file and it is only show blockmesh in the form of rectangular channel.

Could you please help me how to proceed with that?
afshindpe is offline   Reply With Quote

Old   March 9, 2022, 09:02
Default
  #11
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by afshindpe View Post
Hello everyone

I export an STL file from surface Evolution to use for snappyHexMesh. Unfortunately, after running the snappyHexMesh command, it does not recognize the STL file and it is only show blockmesh in the form of rectangular channel.

Could you please help me how to proceed with that?



The problem is that you are doing things wrong:

code snippets from snappyHexMeshDict
Code:
geometry
{
    interface.stl
    {
        type triSurfaceMesh;
        name interface;

    }
    ...
}

castellatedMeshControls
{
    ...
    refinementSurfaces
    {
        interface.stl    /// <<< wrong. Its simply:  interface
        {
            // Surface-wise min and max refinement level
            level (2 5);
        }
    }
    ...
}
You renamed you STL in the geometry section to be named interface. Hence, snappy don't know any guy named interface.stl. That's your problem. If you check the output of snappy, it will let you know:
Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Read mesh in = 0.495 s

Overall mesh bounding box  : (-0.5 0 0) (0.5 1.5 1)
Relative tolerance         : 1e-06
Absolute matching distance : 2.06155e-06

Reading refinement surfaces.
--> FOAM Warning : 
    From function Foam::refinementSurfaces::refinementSurfaces(const Foam::searchableSurfaces&, const Foam::dictionary&, Foam::label)
    in file refinementSurfaces/refinementSurfaces.C at line 215
    Reading "D:/Paper5-OpenFoam/Afshin/InterfaceShapes/RectangularChannelIncludeInterface/system/snappyHexMeshDict/castellatedMeshControls/refinementSurfaces" from line 124 to line 124
    Not all entries in refinementSurfaces dictionary were used. The following entries were not used : 1(interface.stl)
Read refinement surfaces in = 0.005 s
It states, that the entry interface.stl is not used as snappy cannot find it.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 18, 2022, 03:06
Default
  #12
New Member
 
Lakshmi
Join Date: Mar 2022
Posts: 3
Rep Power: 4
LakshmiIC35134 is on a distinguished road
Hi Tobi,

I am Lakshmi, from India. I am currently working on modeling a packed bed reactor for non-particulate systems. I wanted to contact you to know how to use OpenFOAM for meshing a packed bed geometry as I came across your discussions on this forum. I created my bed using blender 3D software and I shall export the geometry in the .stl format. I successfully created a blockmesh and I and facing the following error for snappyHexMesh (FOAM FATAL IO ERROR:
keyword locationInMesh is undefined in dictionary "/home/hp/OpenFOAM/hp-9/run/testcase_1/system/snappyHexMeshDict/castellatedMeshControls" ). Kindly help me if you know how to resolve this error. Looking forward to hearing from you. Thank you.

Regards,
Lakshmi
LakshmiIC35134 is offline   Reply With Quote

Old   April 18, 2022, 03:07
Default
  #13
New Member
 
Lakshmi
Join Date: Mar 2022
Posts: 3
Rep Power: 4
LakshmiIC35134 is on a distinguished road
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

castellatedMesh on;
snap off;
addLayers off;



geometry
{
fluid
{
type triSurfaceMesh;
file "mesh.stl";
regions
{
wall { name wall; }
obj1 { name obj1; }
obj2 { name obj2; }
obj3 { name obj3; }
obj4 { name obj4; }
}
}
}

castellatedMeshControls
{
features
(
// { file "CAD.eMesh"; level 1; }
);

refinementSurfaces

{
#include "meshQualityDict"
fluid
{
level (0 0)
regions{
wall { level (0 0); patchInfo { type wall; } }
obj1 { level (1 1); patchInfo { type wall; } }
obj2 { level (1 1); patchInfo { type wall; } }
obj3 { level (1 1); patchInfo { type wall; } }
obj4 { level (1 1); patchInfo { type wall; } }
}
}
}

refinementRegions
{

}

locationInMesh (-1 -1 -1); // Offset from (0 0 0) to avoid
// coinciding with face or edge
nCellsBetweenLevels 1;
}

snapControls
{
// explicitFeatureSnap true;
// implicitFeatureSnap false;
}

addLayersControls
{
layers
{
"CAD.*"
{
nSurfaceLayers 2;
}
}

relativeSizes true; // false, usually with firstLayerThickness
expansionRatio 1.2;
finalLayerThickness 0.5;
minThickness 1e-3;
// firstLayerThickness 0.01;

// maxThicknessToMedialRatio 0.6;
}

writeFlags
(
// scalarLevels
layerSets
layerFields
);

meshQualityControls

{

#include "meshQualityDict"

maxNonOrtho 65;

maxBoundarySkewness 20;

maxInternalSkewness 4;

maxConcave 80;

minFlatness 0.5;

minVol 1e-13;

minTetQuality 1e-9;

minArea -1;

minTwist 0.02;

minDeterminant 0.001;

minFaceWeight 0.02;

minVolRatio 0.01;

minTriangleTwist -1;



// Advanced



nSmoothScale 4;

errorReduction 0.75;

}


mergeTolerance 1e-6;

// ************************************************** *********************** //
lourencosm likes this.
LakshmiIC35134 is offline   Reply With Quote

Reply

Tags
cad, snappy, stl


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
Using PengRobinsonGas EoS with sprayFoam Jabo OpenFOAM Running, Solving & CFD 36 July 16, 2024 04:52
how to calculate mass flow rate on patches and summation of that during the run? immortality OpenFOAM Post-Processing 104 February 16, 2021 09:46
what is swap4foam ?? AB08 OpenFOAM 28 February 2, 2016 02:22
[Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 Seroga OpenFOAM Community Contributions 9 June 12, 2015 18:18
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08


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