CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Assigning values to a cartesian grid from a binary image (or stl) (https://www.cfd-online.com/Forums/openfoam-pre-processing/139994-assigning-values-cartesian-grid-binary-image-stl.html)

Cyp August 5, 2014 17:06

Assigning values to a cartesian grid from a binary image (or stl)
 
Dear all,

I stuck with the problem of assigning value to a field (let's call it alpha).

Let's say I have a very fine cartesian grid generated with blockMesh and that I want to assign value to a field alpha defined on this grid in order to match the binary image shown below. The cells in the black region will have the value 1 and the cells in the white region will have the value alpha=0.

I have a .stl file of this file and I am able to generate a grid with snappyHexMesh for either the black region. Then with mapField I can assign the value I want for alpha. However, the workflow is a little far-fetched.

Do you think of a more direct way to assign this value? Using snappyHexMesh and this *.stl file to assign values to my field alpha defined on a cartesian grid ?

Any ideas will be strongly appreciated.

Cheers,
Cyp


ngj August 5, 2014 18:02

Hi Cyp,

I cannot check right here, but at least there is an option called surfaceToCellSet in some OF-version. In the more recent ones, I would expect that you can find it in connection with topoSet.

Note, that when using surfaceToCellSrt you define a stl-surface and a number of points. These are either inside or outside of the STL (additional flags), but the important thing is that you will probably need a lot of points, because the STL is by no means convex.

You might even be able to use surfaceToCell directly inside setField?


Good luck,

Niels


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