CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Meshing & Mesh Conversion (
-   -   2D adaptive Mesh Refinement (

baco June 5, 2013 13:44

2D adaptive Mesh Refinement
Hello Foamers,

i am new here.

i am not sure if it is right posting my problem in this forum... i hope it is ok.
I did create an adaptive mesh using dynamicRefineFvMesh. I adapted the hexRef8 class for splitting cells in 2D. Now i started my solver and the cell refinement runs good (the mesh check is OK) and now the big BUT it comes ...
Always if the mesh changes the calculations will be solved in 3D, i.e. the vector of velocity is directed in the 3.dimension.
And now comes sth weird. If i stop the calculation and then i re-start it from the last timestep then the calculation is correctly calculated in 2D. What is the problem, i have absolutely no idea.

many thanks

nimasam June 7, 2013 03:11

:) dear buddy, maybe you want to share your code and one test case here, maybe we can help you to solve the problem :)

yhaomin2007 July 17, 2013 14:45


As far as I know, the cut engine hexRef8 is only capable to cut cell into 8 subcells, which means it is 3 dimensions. I have seen a paper talking about cut cells in to 2 subcells, I think you look it up here:

Another question is, what solver are u using? I am now trying to implement AMR into steady solver.But I met some problems.

pjohannes183 July 28, 2013 10:04

I'm also working on a 2D adaptive mesh refinement with a dynamicFvMesh. Does anybody have an idea whether it's good to start modifying the hexRef8 class, keeping its low-level style (which is really complicated) or if one could adapt hexRef8, keep using all its nice features and just plug in simpler mesh modification operations?

I successfully managed to do exactly the refinement I want using multiDirRefinement which gives me the type of meshes I want BUT It still lacks all the other capabilities which are needed for a dynamic mesh (like: field mapping, keeping track of the refinement history, allowing unrefinement etc.)

What I'd like to do is: take hexRef8 and rewrite it partially, using the code from multiDirRefinement, thus turning it into a hexRef4 or hexRef2.

Does anybody have a good idea how to start?

K.C. May 31, 2016 10:00

Have you seen this thesis? (
Especially Apendix B.

It seems like the 2D adaptive mesh refinement we are looking for.

stainboy July 19, 2016 14:39


does anyone of you managed to implement the 2D engine for dynamic local mesh refinement?

I'm trying to do it according to mentioned paper: [Ahmad Baniabedalruhman][/URL]

I'm currently struggling with the code from appendix B related to splitting of internal faces. Does anyone know how the variable anchorPointJ should be initialized? It is appearing on the page 173 when author is proposing the algorithm for splitting internal faces.


Hannes89 July 20, 2016 04:46

Hi Jakub,

I am also currently trying to get the adaptive mesh refinement to run in 2D following the Baniabedalruhman thesis.

It seems to me that the modifications are neither complete nor all correct.
With some modifications, I was able to compile the new library but my code crashes during the first refinement step.

For the anchorPointJ I have added:
label anchorPointJ = anchors.otherVertex(anchorPointI);

Send me a PM if you are interested in a discussion:)


catelyn July 21, 2016 11:40

Hi Hannes89,

I am interested in adaptive mesh refinement.
I found and fixed some problems, but I still don't understand how to declare:

Did you solve the problems?
Could you help me?


stainboy July 21, 2016 14:47


together with Hannes89, we are trying to implement this solution. You can join us if you want. The more the better :)

On monday I will try to give you some hints regarding those variables.


Hannes89 July 25, 2016 06:02

Hi Catelyn,

the isDivisible variables should be boolean lists, holding a value for every face and edge, that can be declared like this:

boolList isDivisibleFace(mesh_.nFaces(),false);
boolList isDivisibleEdge(mesh_.nEdges(),false);

Regarding the anchorPointJ. I am not so sure about the algorithm implemented in the PhD thesis and can not give you a definitive answer.
I am currently trying to rewrite this bit of the code.


stainboy July 25, 2016 06:10


here are my thoughts regarding variables you asked.
  • isDivisibleFace - this is a bool list pointing if the face can be splitted. Faces on the empty boundary should be divided to four new faces, the others into two. I would use boolList at first glance, later it could be changed to PackedBoolList. The size is nFaces(). So the full declaration will be:


    boolList isDivisibleFace(mesh_.nFaces(), 0)
  • isDivisibleEdge - here similarly it is a list which index corresponds to edge index in the mesh. If the isDivisibleEdge[index] = true then edge number equal ti index can be splitted for creating new faces in the mesh.


    boolList isDivisibleEdge(mesh_.nEdges(), 0)

When it comes to anchorPointJ, we don't know yet what it should be.


catelyn July 26, 2016 05:30

Thank you all,
I realized they were boolean variables but I have a too approximate knowledge in programming.
I wrote to Dr. Baniabedalruhman, I'll keep you posted if I receive any answers.


All times are GMT -4. The time now is 02:49.