CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Specifying two locations in mesh with snappyHexMesh (

Cyberholmes July 7, 2011 11:44

Specifying two locations in mesh with snappyHexMesh
I am trying to mesh two concentric spheres using snappyHexMesh, but I want the interior of both spheres to be meshed while removing the meshing that is outside the larger sphere.

Using locationInMesh, if I specify a point inside the inner sphere, I only end up up with its interior meshed, and if I specify a point inside the outer sphere but not the inner sphere, I end up with the interior of the large sphere with a cavity where the smaller sphere was.

The reason I want this is because I want the inner sphere to be a patch that I can use to set a temperature boundary condition, but I do not want it to be a wall, so I need its interior to be meshed so I can solve there as well.

Is there any way with snappyHexMesh to end up meshing the interior of both spheres?

wyldckat July 9, 2011 05:50

Greetings Cyberholmes,

What you'll need is chtMultiRegionFoam as a solver! Assuming of course you want two regions...

There is a tutorial that exemplifies just this: heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater

If you simply want to set a temperature field inside a single region, then you should look into setFields.

Best regards,

Cyberholmes July 11, 2011 10:37

Thank you for the reply, but before I even get to the stage of using a solver, I need to figure out how to use snappyHexMesh to mesh two regions. As far as I currently know, you can only specify one locationInMesh, and it removes all cells outside of that region.

wyldckat July 11, 2011 16:21

Hi Cyberholmes,

I (wrongly) assumed you would investigate more about that tutorial case...

OK, this is what happens with OpenFOAM (afaik):
  1. It does not allow internal boundary conditions. For example, if you wanted a door between two rooms to close or open instantaneously, that can't be done with normal solvers. It sort-of could be done with some sort of variable porous region.
  2. Therefore, since internal boundaries are not allowed in OpenFOAM, then snappyHexMesh also will not allow two regions in the same mesh. Two or more volumes would only be meshed if and only if there was a physical opening between them.
  3. So, how can OpenFOAM handle two volumes, even if they are contiguous, only separated by a thin surface? Simple! You have to use a solver designed to handle those two volumes, which are named regions. Therefore, you have to mesh two regions, instead of just one.
  4. In essence, if you want two locationInMesh points, then you need two regions! This is where the tutorial I wrote about comes in!!
It's a bit complex and time consuming to explain it all, therefore I pointed you in the direction I think is the best one, at least for now.

On the other hand, if you only want one single region, because those two spheres are going to transfer fluid between them through that surface that separates them, then the other possibility I talked about was about setFields. With setFields, you can set a zone in the mesh to have the desired value; for example, if you wanted to start that surface with an initial temperature of 300K, then you can do it with setFields. In case you do want to learn more about setFields, you can start here:

Best regards,

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