CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [cfMesh] Duct Simulation (https://www.cfd-online.com/Forums/openfoam-community-contributions/240393-duct-simulation.html)

Sebastian Maier January 2, 2022 18:18

Duct Simulation
 
Hello Everyone,

I just started working with Openfoam and wanted to simulate my first case.
For this purpose I have designed a duct in an external CAD program and exported it as a stl. file, which I would like to mesh with cfMesh. For this I have additionally downloaded OpenFOAMv2106.
Now I have several problems. my stl. file has only one region, but I need to define an inlet/outlet and walls. I am not quite sure how to do this in Openfoam. Furthermore, the geometry of my stl. file currently has triangles that end in infinite small areas, I don't know if this could lead to additional problems.

Is there a general procedure to prepare the geometry for such cases?

Best Regards,

Sebastian

dlahaye January 3, 2022 09:08

In short: the idea is to (1/3) save the STL per patch, (2/3) annotate the STL per patch with boundary information and (3/3) concatenate the separate STL files into a new STL file.

More elaborate explanation follows:

OpenFoam: Salome/cfMesh Users Guide

This note discusses the use of Salome to generate of the input data that the package cfMesh requires to perform volumetric mesh generation. These notes complement [1,2].
The input that cfMesh requires consists of the following two elements:
(1/2): the triangulation of the surface (surface mesh) of the geometry;
(2/2) a dictionary file that contains the name of the surface mesh and parameter settings that control the mesh generation.
The cfMesh native format for the surface triangulation is the FMS format. The STL format is also supported. The STL format however results in larger files. In what follows we discuss how to create the surface mesh and the dictionary. We include the possibility to generate of the surface mesh using Comsol Multiphysics as an intermediate tool.

1/ Creation or reading of geometry in Salome

The geometry can be created using the geometry module of Salome. Alternatively, the geometry can be read from file (in STEP, IGES, BREP or STL) using again the geometry module. In the geometry module that patches can be given names (e.g. inlet, outlet and walls). Note that Comsol Multiphysics unfortunately does not allow export to other formats than STL. (It is unclear at the moment whether the STL format is viable to use in the following. It is also unclear at the moment whether or not Comsol allows to export the geometry per patch.)

2/ Generation of surface triangulation in FMS format using Salome/Python

To generate and export the surface triangulation from Salome, proceed as follows:
1. generate a triangulation in Salome, within the Mesh module.
2. import the salomeToSurf.py script. The Load Script option exists inside the File menu. The location of this script is given in [3]
3. select the surface you want to export, by highlighting it in the project tree, and write:
triSurf().writeFms("surfaceName.fms") in the python console.
This executes the script with the selected mesh as its argument, and writes the FMS file with the given name into the directory where Salome is installed. You can also provide an absolute path to get the fms file written to the desired location.

3/ Generation of surface triangulation in STL format of surface using STL per patch

The surface mesh can alternatively by created in STL format per patch. From the CAD modeling tool, export the surface per patch. Make sure that the STL file per patch has a begin/end sequence. Make sure that each patch has its name attached to it. Concatenate all the individual STL files into a single final STL file.

4/ Setting up the dictionary file

For both the anode baking furnace and the blast hot stove, dictionary files for cfMesh already exists. Please copy from those.

5/ (irrelevant for OpenFoam users) Avoiding polyhedral elements in case that the mesh is to be used by Comsol Multiphysics

To avoid polyhedral cells to be generated by cfMesh (because Comsol does not support them), place the following line into the meshDict dictionary file;

decomposePolyhedraIntoTetsAndPyrs true

References

[1]: https://www.cfd-online.com/Forums/op...ed-cfmesh.html
[2]: https://openfoamwiki.net/index.php/T...arametrization
[3]: location of Python script in the cfMesh source code: modules/cfmesh/python/Salome/salomeTriSurf.py
[4]: “Working With cfMesh” by Beg at Sheffield https://www.sheffield.ac.uk/polopoly...ith_cfMesh.pdf
[5]: https://curiosityfluids.com/2019/02/...-your-meshing/
[6]: very well explained: https://curiosityfluids.com/2019/02/...-your-meshing/

philiplu January 6, 2022 06:38

hello, thank you, dlahaye, for the guidelines.
I've a small question:

my preference: first save surfs as "iges", then in other tools, convert them to "stl", where I can
- further refine each surf or
- simly use default setting in "iges2stl"

so i wonder if "further refine" can expedite the meshing in cfmesh?(even it's just e.g. a "plane"), or it's not necessary to do so?

thank you in advance, if you or someone can give me some hints
philip

dlahaye January 6, 2022 11:09

Not sure. I image, however, that cfMesh constructs its own surface mesh. This implies that further refining the STL in case of planar surfaces add no information.

philiplu January 7, 2022 06:08

hello, dlahaye,
many thanx for the reply. Actually when using SHM, I got already this question.

regards, thanks
philip

Sebastian Maier January 7, 2022 09:30

hello

thank you also from me for the detailed guide. I needed a few days to fight my way through. was very helpful.

Sebastian Maier January 31, 2022 13:49

2 Attachment(s)
Hey everyone,

im working with cfMesh now for a view days and i encountered some problems, especially with the boundary layer.

for a given yPlus value, I have calculated the first cell height. furthermore, the boundary layer thickness is known. With these values I wanted to define my boundary layer.
Here I am not aware if this is possible in cfMesh at all. I am not that experienced with it yet, so I could be wrong.

I had tried to determine the value of the first cell via maxFirstLayerThickness. But this is much smaller than expected (see figure 1). furthermore i didn't find a way to specify the total boundary layer thickness. is this to be controlled by maxFirstLayerThickness and thicknessRatio ?
furthermore, there is a "wavy pattern" along the boundary layer instead of a uniform boundary layer (see picture 2), the reason for which is also unknown to me.

is there a possibility to make this more smooth ?

i posted my code below

Best regards,

Sebastian

Code:

maxCellSize 0.01;                // [m]

boundaryCellSize 0.005;

boundaryLayers
{
   
    nLayers 6;

    thicknessRatio 1.15;

    maxFirstLayerThickness 0.00129; 
   
    optimiseLayer 1;
   
}



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