CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   Simple manual cell deleting question (

jasimpson89 June 15, 2012 12:10

Simple manual cell deleting question
Hi, I am very new to CFD and the use of open foam.

I would like to be able to create a hex mesh over the whole bounding box of a geometry using blockMesh and then to go and remove all cells the lie outside the geometry.* The reason being is that I have a complex geometry that is difficult to block and can live with the CFD geometry being a stair-stepped approximation of the real geometry.* I want to automate the process so don't want to rely on a 3rd party mesher or snappyHexMesh * Has anyone done something similar?*

Currently I am using a very simple geometry of one block and a 3x1x1 cell configuration just to see a method of how I could automate this. So I have 3 cells adjacent to each other (012). What I am trying to do is delete cell 1 the middle cell of this system.

The procedure I am following is:

1. Editing the boundary file, subtracting off 2 faces because I have removed four faces but two of the internal faces have no become boundary faces. And setting the start to 0 (no more internal faces)

2. Editing the faces file to reflect the changed I have made of deleting the faces

3. Setting the neighbour file 0( ) as we have no neighbours now?

4. Deleting the in the owners file the owner associated with the faces I have deleted.

After all this is done when I open this in paraFoam, the internal mesh I am given is just weird it doesn't seem to reflect the changes I have made, Sometimes faces are missing and point join up in weird ways making weird and wonderful shapes.

Two things to note are:

1. All these changes are made after the command blockMesh is ran

2. I ran checkMesh on my edited geometry and obviously it crashed. However I did notice that it was expecting there to be 9 cells present, but I want 8 because I am trying to delete one. One would assume that paraFoam would be expecting 9 and not 8 so hence my weird shapes. But I don't know what file to edit to change the number of cells in my geometry. Does anyone know? or does checkMesh work it out from your blockMeshDict?

Apologies if anything I have mentioned is confusing I would be more than happy to clarify any of the points I have made.

Thanks in advance


wyldckat June 16, 2012 07:26

Greetings James and welcome to the forum!

I started to read you post and didn't finish reading it, sorry :(... so basically I'll answer only the first couples of questions:
Best regards,

jasimpson89 June 18, 2012 06:36

thanks very much Bruno, I'll give that a go! see what I can do.

Thanks again


jasimpson89 June 18, 2012 13:14

Thanks for linking me to those posts Bruno but, some of them talk about inverting selection, what does this mean? and how do I do it?

thanks in advance


wyldckat June 18, 2012 15:54

Hi James,

I forgot about another link that might help explain this a bit better: post #5
Keep reading the thread from that point onward and hopefully your questions will be answered :)

Best regards,

jasimpson89 June 19, 2012 08:52

Hi Burno,

I have read through the links I am still at a little loss at what to do. Here is what I think I should do.

I am working in a simple geometry of one block divided into 2 cells (adjacent to each other). I think I should do the following to the remove a cell:

1. create a set which includes one of the cells (I am not entirely sure how to do this)

2. Invert the new cell set

3 subSet the new set

4. subsetMesh the new set to remove the cell

I am thinking of the correct method to do this? Or can you only use setSet after checkMesh has flagged up any errors in the mesh?

Many thanks


jasimpson89 June 19, 2012 14:34

I am basically having an issue with having trying to setup a set which include my current cells and faces

wyldckat June 19, 2012 17:02

Hi James,

The idea is simple:
  1. Generate a mesh. Make sure you have all of the cells you need, including those you want to remove.
  2. Use setSet to create a cell set with the selection of the cells to be removed.
  3. Then invert the selection on that set, to select all of the other cells.
  4. Quit setSet.
  5. Run subsetMesh to extract the selected cell set.
The wiki page is using checkMesh as an example for using already existing cell and face sets. For other possibilities of selection, use the command help in setSet's command line.

If you're not understanding how to use setSet, you can also try topoSet, which is in essence the same thing, but using a dictionary! Check the links I posted before, where I explained how to find out more about each application... or more specifically, how to search for "*Dict" files, which in topoSet's case is "topoSetDict".

Best regards,

jasimpson89 June 20, 2012 09:15

Hi Burno,

Thanks for all your help so far. I was being a spanner and not being able to figure out step 2.

However this is what I have tried and setSet seems to work ok but it doesn't remove a cell for me:

faceSet f0 new patchToFace faces  // (this made me and empty faceSet object I think)

faceSet f0 add labelToFace (0 2 4 6 8 10)  // (add the faces which define the cell to be removed)

cellSet c0 new faceToCell f0 any

cellSet c0 invert 

cellSet c0 subset

then quit and run subsetMesh c0

This doesn't actually seem to do anything and I am not sure where entirely I am going wrong. One thing I am worried about is that my bounding box min or max coordinates seem to be the same, but I don't know why.

Also if I know the index of the cell I want to remove could I not just do the following:


cellSet c0 new labelToCell (1)

cellSet c0 invert

cellSet c0 subset


subsetMesh c0

This doesn't seem to work either but the logic should be the same should it not? It's just this way would be much easier for me to implement as a the method of extraction.

Apologies for all the questions, but I can't exactly seem what I am doing wrong

Many thanks


jasimpson89 June 20, 2012 11:20

Hi Bruno managed to figure it out.

Thanks again for all your time, it has been most helpful

All times are GMT -4. The time now is 10:58.