CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Adaptive Mesh Refinement in Arbitary Direction (https://www.cfd-online.com/Forums/openfoam-programming-development/108282-adaptive-mesh-refinement-arbitary-direction.html)

mm.abdollahzadeh October 18, 2012 10:50

Adaptive Mesh Refinement in Arbitary Direction
 
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

nimasam October 18, 2012 12:14

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

mm.abdollahzadeh October 24, 2012 08:48

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.

nimasam October 27, 2012 01:35

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

mm.abdollahzadeh October 29, 2012 09:28

Quote:

Originally Posted by nimasam (Post 388789)
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 October 29, 2012 09:41

2 Attachment(s)
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

nimasam October 30, 2012 03:45

1 Attachment(s)
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

mm.abdollahzadeh October 30, 2012 07:53

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

nimasam October 30, 2012 13:05

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?

mm.abdollahzadeh October 31, 2012 08:31

Hi Nima

Thanks again for help. With paraFoam its possible .

paraFoam -touchAll

or

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

Best Mahdi

nimasam October 31, 2012 11:50

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 :)

mm.abdollahzadeh November 2, 2012 05:26

Dear Nima

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

Best
Mahdi

mm.abdollahzadeh November 3, 2012 13:28

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 November 6, 2012 07:07

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::polyTopoChanger::update(const mapPolyMesh& m)
// Foam::polyMesh::updateMesh
//Foam::dynamicRefineFvMesh::update()

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

any idea?

best
Mahdi

mm.abdollahzadeh November 9, 2012 11:36

Some part of discussion is continuing in the following thread also:

http://www.cfd-online.com/Forums/ope...y-changes.html

nimasam December 2, 2012 05:38

hi mahdi
what is the recent progress? i was too busy to follow the progress ;)

pcaron January 9, 2013 15:23

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

mm.abdollahzadeh January 12, 2013 09:35

1 Attachment(s)
Quote:

Originally Posted by nimasam (Post 395247)
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

mm.abdollahzadeh January 12, 2013 09:37

Quote:

Originally Posted by pcaron (Post 401026)
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


All times are GMT -4. The time now is 15:01.