CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Adaptive Mesh Refinement in Arbitary Direction

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 1 Post By mm.abdollahzadeh
  • 3 Post By nimasam

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 18, 2012, 11:50
Default Adaptive Mesh Refinement in Arbitary Direction
  #1
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Dear All

I have started Working on Adding Adaptive Mesh Refinement to my Code. But As I have searched and see , The DynamicMeshRefinment in OpenFoam is not working in 1D or 2D Cases. But There is Multidirectionrefinment code that is supposed to do the code , but it is said to have some issues with mapping results from the previous Mesh to the new Mesh.

Please Share your experiences to help me and other Foamers enjoying the open source codes.

Best
Mahdi
mm.abdollahzadeh is offline   Reply With Quote

Old   October 18, 2012, 13:14
Default
  #2
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
nice Try, i think, the first step would be to read the existing code, you can post the pieces of code here, and your comments on each part of code here, so by discussion, a good references, would be available for all
nimasam is offline   Reply With Quote

Old   October 24, 2012, 09:48
Default
  #3
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Dear All

As I see at the moment there are some utility and applications for mesh refinement in openFoam.
utilities:
1-RefineMesh

Applications:
1-multiDirRefinement
2-dynamicRefineFvMesh
3-meshRefinement

There is some common Header file between these applications and utilities:

#include "polyMesh.H"
#include "hexRef8.H"
#include "surfaceInterpolate.H"
#include "polyTopoChange.H"
#include "syncTools.H"
#include "mapPolyMesh.H"
#include "meshTools.H"

So All the main refinement process and mapping should be inside these codes. In Fact the library which is responsible is "dynamicMesh" library.

Last edited by mm.abdollahzadeh; October 24, 2012 at 10:12.
mm.abdollahzadeh is offline   Reply With Quote

Old   October 27, 2012, 02:35
Default
  #4
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
it seems the first pieces of code you should look at, is "dynamicRefineFvMesh.H" and
"dynamicRefineFvMesh.C",
in this code is defined how to mark cell for refinement, how to gather cells and how to cut them
nimasam is offline   Reply With Quote

Old   October 29, 2012, 09:28
Default
  #5
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Quote:
Originally Posted by nimasam View Post
it seems the first pieces of code you should look at, is "dynamicRefineFvMesh.H" and
"dynamicRefineFvMesh.C",
in this code is defined how to mark cell for refinement, how to gather cells and how to cut them
Dear Nima

I have checked the dynamicRefineFvMesh . in this code the are using a mesh cutter with is called hexref8 . the problem related to that is that it will divide each cell in all direction. each cell to 8 cell. so it can not be used for 2D cases.
but there is another application multiDirRefinement which has two different cutter. if u choose splitting in all direction it will use hexr8 but if you give direction it will use undoabalemeshcutter.

so till the moment using multiDirRefinement or making a new application similar to this is the idea. but what is the problem? the problem is mapping the data. in dynamicRefineFvMesh and hexr8 there is a class member called meshupdate which actually do the refinement and mapping. but there is no class member in multiDirRefinement. moreover in dynamicfvmesh there is the same class member but in fvmesh the update member is not existed.

Best
Mahdi
mm.abdollahzadeh is offline   Reply With Quote

Old   October 29, 2012, 09:41
Default
  #6
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Dear Nima

So the thing that I have done for the step was a simple test with icoFoam.

1-defining two mesh. one as main for the calculation. second just for helping the mapping of data with fvmesh
2-I use the error-estimate application which is openfoam 1.7 and openfoam extended 1.6 to calculate a errorfield
2- Then marking the cell for refinement
3- Doing the mesh refinement on the second mesh.
4- mapping the data s from the first mesh to the second mesh by meshtomeshinterpolation
5-then refine the first mesh.
6-mappinmg the data from the second mesh to the first mesh
7- start again the computation

I know that is not good but it is my first try. the code is compiled . but when running it gives a segmentation error.
I have attached the code and the case.



please have a look if you have time.

Best
Mahdi
Attached Files
File Type: zip cavity.zip (81.3 KB, 25 views)
File Type: zip myicoFoam.zip (12.7 KB, 32 views)
hua1015 likes this.
mm.abdollahzadeh is offline   Reply With Quote

Old   October 30, 2012, 03:45
Default
  #7
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
i would like this discussion will be continued, so for who interested some description, how compile above file:
1) download errorEstimation.zip
2) unzip and compile it with wmake libso
3)download myIcoFoam.zip and unzip it
4) in Make folder, options file, then add
library and header files path address like this:
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/dynamicMesh/lnInclude \
    -I$(LIB_SRC)/dynamicFvMesh/lnInclude  \
    -I/home/nimasam/Desktop/errorEstimation/lnInclude \ (path address)
    -I$(LIB_SRC)/sampling/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -ldynamicMesh \
    -ldynamicFvMesh \
    -L$(FOAM_USER_LIBBIN)\ (lilibrary path address)
    -lerrorEstimation \
    -lsampling
4)compile it with wmake
Attached Files
File Type: zip errorEstimation.zip (26.9 KB, 22 views)
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   October 30, 2012, 07:53
Default
  #8
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Dear Nima

Actually I have tried to adopt the map-field utility in the code for the step 4 and 6. But As I check now my code is blowing in step 6 . but although I am writing the mapped values ... there is no change in the objects in time folder.
there is also four post related to adding mapfields:

http://www.cfd-online.com/Forums/ope...ded-cells.html
http://www.cfd-online.com/Forums/ope...time-step.html
http://www.cfd-online.com/Forums/ope...y-changes.html
http://www.cfd-online.com/Forums/ope...wo-meshes.html

Best
Mahdi

Last edited by mm.abdollahzadeh; October 30, 2012 at 09:46.
mm.abdollahzadeh is offline   Reply With Quote

Old   October 30, 2012, 13:05
Default
  #9
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
Hi mehdi
i check the code, ofcourse i need to look deeply to find what you are going to do i make these two headers (//#include "MapfromMeshnew.H" , #include "MaptomeshNew.H") comment , then it runs fine,
tell me how do you show the result in paraview?
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   October 31, 2012, 08:31
Default
  #10
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Hi Nima

Thanks again for help. With paraFoam its possible .

paraFoam -touchAll

or

paraFoam -touch -region MainMesh
paraFoam -touch -region HelpMesh

Best Mahdi
mm.abdollahzadeh is offline   Reply With Quote

Old   October 31, 2012, 11:50
Default
  #11
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
mehdi could you put more description in each part of you algorithm or your code, i can not understand what you are going to do?
i guess some algorithm like this:
1-defining two mesh (MainMesh, HelpMesh)
2-use the error-estimate application to calculate a errorfield
2- Then marking the cell for refinement
3- Doing the mesh refinement on the second mesh.
4- mapping the data s from the first mesh to the second mesh by meshtomeshinterpolation
5-calculate fields (pn,Un)
6-mappinmg the data from the second mesh to the first mesh
7- start again the computation
your step 5 is vague for me
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   November 2, 2012, 05:26
Default
  #12
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Dear Nima

Your guess is right.
Pn and Un are mutual values on the second grid for p and U.

Best
Mahdi
mm.abdollahzadeh is offline   Reply With Quote

Old   November 3, 2012, 13:28
Default
  #13
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Dear Nima

The thing is that I dont why meshtomesh interpolation is not changing anything in the objects p and u in the time folder.
if u replace the fieldtarget varalbele to p or pn and fieldsource to p or pn . depending on the mapping from which mesh. there will be error that is saying that the mesh and the field are not matched. the reason is that the field is created in createfeild but the mesh is replacing so the objects should be updated also according the mesh that they are registered to.

so I have checked the fvMesh.C and fvMesh.H.

there are two members that are used for updating the mesh and mapping of the field according to the map of the added cells to the mesh.

Best
Mahdi
mm.abdollahzadeh is offline   Reply With Quote

Old   November 6, 2012, 07:07
Default
  #14
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Dear All


There is a problem using meshtomeshinterpolation .... meshtomesh can not handel mapping of surfacescalarfields so its not complete. for mapping a volvector or volscalar my problem was that it was renewing the numeber of points of the objects in time folder.... so I just initialize the target objects by a uniform value to reset the number of points. then it works and the data was mapped.

but I think the solution is in some updateMesh member :

//Foam::fvMesh::updateMesh(morphMap);
//Foam::hexRef8::updateMesh
//Foam:olyTopoChanger::update(const mapPolyMesh& m)
// Foam:olyMesh::updateMesh
//Foam::dynamicRefineFvMesh::update()

******************************

any idea?

best
Mahdi
mm.abdollahzadeh is offline   Reply With Quote

Old   November 9, 2012, 11:36
Default
  #15
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Some part of discussion is continuing in the following thread also:

http://www.cfd-online.com/Forums/ope...y-changes.html
mm.abdollahzadeh is offline   Reply With Quote

Old   December 2, 2012, 05:38
Default
  #16
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
hi mahdi
what is the recent progress? i was too busy to follow the progress
__________________
My Personal Website (http://nimasamkhaniani.ir/)
Telegram channel (https://t.me/cfd_foam)
nimasam is offline   Reply With Quote

Old   January 9, 2013, 15:23
Default
  #17
Member
 
Pablo Caron
Join Date: Nov 2009
Location: Buenos Aires, Argentina
Posts: 75
Rep Power: 17
pcaron is on a distinguished road
Hello everybody

I would like to use this feature in my PhD thesis. I do not want to start coding from scratch. Please tell me what can I do to help you.

Pablo
pcaron is offline   Reply With Quote

Old   January 12, 2013, 09:35
Default
  #18
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Quote:
Originally Posted by nimasam View Post
hi mahdi
what is the recent progress? i was too busy to follow the progress
Dear Nima

Sorry for my late update. I got busy with some other extra works.
I have managed to make my code running. I have tested for a case IcoFoam tutorial and its run well and did the refinement and mapping.

I have attached the code needed for refinement and mapping. Just its needed to change the criteria of refinement and the variables that you want to the mapping.

Just I should mention that I have tried to use it in my real test case but it give me divergence ( possible to be related to my case ). if you had time and you have test it, let me know that it works or not?

Cheers
Mahdi
Attached Files
File Type: zip amrfluid.zip (5.8 KB, 53 views)
mm.abdollahzadeh is offline   Reply With Quote

Old   January 12, 2013, 09:37
Default
  #19
Senior Member
 
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15
mm.abdollahzadeh is on a distinguished road
Quote:
Originally Posted by pcaron View Post
Hello everybody

I would like to use this feature in my PhD thesis. I do not want to start coding from scratch. Please tell me what can I do to help you.

Pablo
Dear Pablo

I have attached the code. if you had time, test it and let me know about the results.

Best
Mahdi
mm.abdollahzadeh is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] Weird snapping outside a refinement region jasimpson89 OpenFOAM Meshing & Mesh Conversion 0 July 29, 2012 21:46
killed "snappyHexMesh" parkh32 OpenFOAM Pre-Processing 2 April 8, 2012 18:12
[Technical] Local adaptive mesh refinement with hybrid meshes holger_marschall OpenFOAM Meshing & Mesh Conversion 5 December 21, 2010 14:38
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55
basic of mesh refinement arya CFX 4 June 19, 2007 13:21


All times are GMT -4. The time now is 12:53.