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] STL file for snappyHexMesh (https://www.cfd-online.com/Forums/openfoam-meshing/230563-stl-file-snappyhexmesh.html)

TommyM September 28, 2020 17:14

STL file for snappyHexMesh
 
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

petros September 29, 2020 09:22

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

otaolafr September 29, 2020 09:23

Quote:

Originally Posted by TommyM (Post 783957)
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

TommyM September 30, 2020 09:49

Quote:

Originally Posted by petros (Post 784029)
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 September 30, 2020 09:54

Quote:

Originally Posted by otaolafr (Post 784030)
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

otaolafr September 30, 2020 13:25

Quote:

Originally Posted by TommyM (Post 784138)
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 https://www.cfd-online.com/Forums/op...sh-salome.html

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.

petros September 30, 2020 13:43

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

TommyM October 1, 2020 10:40

Hi,
ok, I will learn to use Salome.
Thank you both for your hints, they are very helpful!
Best,

Tommy

tedbr October 2, 2020 04:40

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.

afshindpe March 8, 2022 11:13

STL file
 
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?

Tobi March 9, 2022 08:02

Quote:

Originally Posted by afshindpe (Post 823786)
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.

LakshmiIC35134 April 18, 2022 02:06

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 April 18, 2022 02:07

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

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


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