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 |
:) dear buddy, maybe you want to share your code and one test case here, maybe we can help you to solve the problem :)
|
Hey,
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: http://publications.lib.chalmers.se/...173/174173.pdf Another question is, what solver are u using? I am now trying to implement AMR into steady solver.But I met some problems. |
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? |
Have you seen this thesis? (http://digitalcommons.mtu.edu/cgi/vi...8&context=etds)
Especially Apendix B. It seems like the 2D adaptive mesh refinement we are looking for. |
Hi,
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] http://digitalcommons.mtu.edu/etds/1005/[/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. Regards, Jakub. |
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:) Hannes |
Hi Hannes89,
I am interested in adaptive mesh refinement. I found and fixed some problems, but I still don't understand how to declare: -anchorPointJ -isDivisibleFace -isDivisibleEdge. Did you solve the problems? Could you help me? Regards, Carmelina |
Catelyn,
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. Regards, Jakub. |
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. Hannes |
Hi,
here are my thoughts regarding variables you asked.
When it comes to anchorPointJ, we don't know yet what it should be. Kuba. |
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. Catelyn |
2d amr
Quote:
|
Quote:
Catelyn |
I have study the codes at Appendix B in the thesis of http://digitalcommons.mtu.edu/cgi/vi...8&context=etds. I changed the codes as the thesis suggest, but when I run my 2d heat transfer case, there's error. And I output the debug informaion, I found basically those values are right.
I find the error was occur in the function createInternalFaces ( original in file hexRef8.C for 3D ,but I change this file hexRef4.C for 2D) . The "if (edgeMidPointI==-1)" judgement ,which I think is the key problem, because for 2D problem ,the value of edgeMidPointI of empaty boundary 's edge are not -1, but the value of edgeMidPointI of internal edges are -1, so when loop the interal edge this judgement is right, it will output the wrong message,and stop the programm. So, I look into the function of storeMidPointInfo, I want to do some change, but I do not unstand its theory. I will continue to handle this problem. Is there anyone can give me some help how to sovle this problem? If I successed to run the 2D AMR , I will show the codes! http://www.cfd-online.com/Forums/mem...831-cell0.html http://www.cfd-online.com/Forums/mem...re829-mesh.png http://www.cfd-online.com/Forums/mem...mperature.html http://www.cfd-online.com/Forums/mem...33-output.html http://www.cfd-online.com/Forums/mem...l0details.html |
Hi,
I recently started to work on this problem too. I tried to implement the (in)famous code described in Dr. Baniabedalruhman's thesis in Openfoam 3.2 extend, whose dynamicMesh libraries are very close to the "standard" version. As already reported, the description of the code in the thesis is quite incomplete. After some modification, I reached the same point of XuDongNa: when runiing the solver, the refinement process stops when the first cell is split as the createInternalFaces function sends an error because the edgeMidPointl is not set. Unfortunately, I don't have much time to work on this. Where you able to solve the problem? |
5 Attachment(s)
Dear All
Here is the code and a case following the introduction of the Ahmad thesis, It doesnt run! here is the error it looks like that spilitting the faces and edges are done correctly, however, it has errors when creating the internal faces. Quote:
Attachment 52595 Attachment 52596 Attachment 52597 Attachment 52598 I hope that somebody could share his successful implementation of the 2D AMR. Mahdi |
1 Attachment(s)
Attached, you can find the code I developed.
From my tests, It seems to work well with 2D meshes. Anyway, the refining part of the code can be improved. (the code is developed for foam-extend 3.2, most of it is anyway the same of the standard OpenFOAM version). |
1 Attachment(s)
Here is Luca Cornolti's code adapted for OpenFOAM 4.0. I've made it by line-by-line comparisons:
(original dynamicRefineFvMesh+hexRef8 for foam-extend 3.2) <-> (dynamicRefineFvMesh2D+hexRef2D for foam-extend 3.2) and (original dynamicRefineFvMesh+hexRef8 for foam-extend 3.2) <-> (original dynamicRefineFvMesh+hexRef8 for OpenFOAM 4.0). I understood only about 30% of the code, and ran only very basic tests, so cannot guarantee that everything is correct. But it seems to work OK at least in single-process mode. I also added basic support of axisymmetric 2D ("wedge" boundary condition), but cells that are directly adjacent to the symmetry axis would not refine since they are not parallelepipedal. In OpenFOAM 4.0 code structure is slightly different. Complete installation is as follows (assuming you installed OF4 into '/opt/openfoam4/'): 1. put 'dynamicRefineFvMesh2D' folder into '/opt/openfoam4/src/dynamicFvMesh/' folder; add 'dynamicRefineFvMesh2D/dynamicRefineFvMesh2D.C' line into '/opt/openfoam4/src/dynamicFvMesh/Make/files'; run 'wmake' command from 'opt/openfoam4/src/dynamicFvMesh/'; 2. put 'hexRef2D' folder into 'opt/openfoam4/src/dynamicMesh/polyTopoChange/polyTopoChange/' folder; add 'polyTopoChange/polyTopoChange/hexRef2D/hexRef2D.C' line into '/opt/openfoam4/src/dynamicMesh/Make/files'; run 'wmake' command from 'opt/openfoam4/src/dynamicMesh/'; Enjoy! |
2D+axisy. codes
2D+axisy. dynamic mesh refinement can be found in the link below.
http://faculty.yu.edu.jo/ahmad_a/Lis.../AllItems.aspx |
Quote:
|
1 Attachment(s)
In my previous post, I have somehow managed to put wrong version of some file(s) in the archive. I cannot find the way to edit that post, so correct version of the archive is attached here.
|
Hi Oleg,
I want to try your dynamicRefineFvMesh2D tool for OpneFoam4, but got problems while compiling it. Doint exactly aus you described it I get Code:
In file included from dynamicRefineFvMesh2D/dynamicRefineFvMesh2D.C:26:0: Do you know what I'm doing wrong? Greetings David |
david112,
my mistake! You need to put hexRef2D codes to the place before trying to compile 'wmaking' dynamicFvMesh folder. Here is updated and extended installation guide (still assuming you installed OF4 into '/opt/openfoam4/'): 0. go into root mode: run 'sudo -i' 1. put 'dynamicRefineFvMesh2D' folder into '/opt/openfoam4/src/dynamicFvMesh/' folder; add 'dynamicRefineFvMesh2D/dynamicRefineFvMesh2D.C' line into '/opt/openfoam4/src/dynamicFvMesh/Make/files'; 2. put 'hexRef2D' folder into 'opt/openfoam4/src/dynamicMesh/polyTopoChange/polyTopoChange/' folder; add 'polyTopoChange/polyTopoChange/hexRef2D/hexRef2D.C' line into '/opt/openfoam4/src/dynamicMesh/Make/files'; 3. compile code: 'cd /opt/openfoam4/src/dynamicFvMesh/' 'wmake' cd '/opt/openfoam4/src/dynamicMesh/' 'wmake' This works for me. Hope it will work for you too! |
Thank you for the quick answer. Quiet easy... I when tried it yesterday in this order I forgot to change to root mode. Now it seems to work for me too.
I will try some 2D cases but atually I want to adapt to a 3D-Case for refining the Mesh in 2 directions. Do you know whether anyone did that before? Greetings David |
David, I believe that no one had posted such code. Obviously, if I found such code here, I would use it instead of aforementioned 2D libraries: refining only in 2 dimensions is exactly what is needed in 2D cases.
|
Hi Oleg,
the compiling works now without errors, but the solver doesnt run. I got this error while running the pimpleDyMFoam solver: Code:
Starting time loop greetings David |
David,
I have tested this lib only on the simplest meshes (rectangular, even-sized cells) and rhoCentralFoam solver, so cannot predict it's behavior in more complex cases. I remember it kind of randomly (after thousands of successful time steps and un/refinements) crashing on forwardStep tutorial, though. But that was with my custom solver, so I'm not sure the problem was in the refinement lib. Don't know why your case crashes, sorry :-( |
Checking some computation with my code in foam ext 3.2, it seems that sometimes the simulations crash when the fields are mapped from the old mesh to the new one.
This problem rarely appears with planar configurations, while it takes place more often when wedges are considered. Anyway, I have no clear idea about the reason of this, as these events are quite random. |
Hi,
I tried to compile the library from Ahmad but I get the following error message(OF 2.2.2): Code:
g++: error: unrecognized command line option ‘-fvMotionSolver’ Best, Moritz |
5 Attachment(s)
Hi Oleg and all other interested!
I took the code from Oleg and tried to change it for my purpose. So I changed the dicision which Face has to be cutted in 4 faces. Instead of looking for empty faces the code now looks for faces where all points have the same y-position. here you can see the changes: Code:
boolList isDivisibleFace(mesh_.nFaces(), false); //OS: change to PackedBoolList? A mesh consiting of a single cell will be splitted perfectly. Also meshes with only 1 cell in the y-direction work fine (case1unrefined.png -> case1refined.png). When getting more cells in y-direction the order of some faces isn't correct anymore. :( (case2unrefined.png -> case2refined.png). Perhaps it helpes to find the mistake if we do more cells in the y-direction. Here you can see, that the first cell is spitted correct, at all the following cells one of the new split cells is uncorrect for the last cell two of the new splitted cells are uncorrect (case3 refined.png). Do you have an idea where in the code I should look for solving this problem? |
I looked into the faces, owner and neighbour files in the polyMesh folder of case2 and figured out where the mistakes happen. Here are the corrected files. Perhaps that helps to find the mistake.
faces Code:
/*--------------------------------*- C++ -*----------------------------------*\ Code:
/*--------------------------------*- C++ -*----------------------------------*\ Code:
/*--------------------------------*- C++ -*----------------------------------*\ David |
Hi, David!
Unfortunately, I'm not able to perform proper analysis of the code, because it's still too complex for me. But one thing have catched my eye: Quote:
Quote:
|
Quote:
Thank you very much for your help |
Quote:
good point. I fixed that. the problems I mentioned befor where caused by the diffent orientation of the faces which where cutted into 4 faces. So, checking which faces are owned and which neighbours of a cell and reordering the points if neccesary solved that. Now i have problems with the cells at the border of the refinement, but hope for sol @ssss: in the hexRef2D.C file there is a line saying: Code:
if (mesh_.boundaryMesh()[patchID].type() == "empty" || mesh_.boundaryMesh()[patchID].type() == "wedge") |
Hi @david112 I swear that I searched both .C files for the wedge string, but it seems I made a mistake somewhere. It is true that wedge and empty patches are treated equally. However, I observe 3D refinement in my ("complex") axisymmetric testcase while in simple 2D with empty BCs simulations there is no refinement at all in the empty direction, so maybe some additions need to be added to the code to manage wedge meshes...
|
Hi, @ssss!
I've just run a simple test for 2D wedge refining, it works OK (but, as I mentioned before, it ignores cells that adjoin symmetry axis, since they are not hexahedrons): there was no refinement in the 3rd axis. I have no idea why that doesn't work for you :-( Quote:
|
Thanks for your contribution.
However, when I compile your files in OpenFoam 5.0 and 4.1, it gave me many errors. Can you give me some tips to debug? Quote:
|
3 Attachment(s)
Dear all,
after some time I was able to work again on this topic and I completed a class which is able to refine 2D cases for both planar and axis symmetric (wedge) configurations. Attached you can find the developed classes for OpenFOAM-6, foam-extend-4.0 and OpenFOAM-v1806. The folders are arranged to be copied into the user directory ($WM_PROJECT_USER_DIR). In the OpenFOAM-6 version there are also two tests for planar and wedge configurations. I tested quite extensively the foam-extend-4.0 version. The OpenFOAM-6 version should work as well as the code is almost the same, but I tested it only with the attached two tests as I don’t use the foundation version a lot. The same is true for the v1806 version. I hope that everything will work properly. Note that a problem reported previously by me in this thread regarding mapping was solved by following the suggestion given in: https://www.cfd-online.com/Forums/op...major-bug.html |
Quote:
I am now also working on utilizing 1D AMR method in OpenFOAM, I want to know that could the 2D dynamicRefineFvMesh you write changed into 1D dynamicRefineFvMesh? Thanks. |
All times are GMT -4. The time now is 01:12. |