CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

How to know mesh size after dynamic refinement

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By kmooney

Reply
 
LinkBack Thread Tools Display Modes
Old   May 20, 2013, 13:40
Default How to know mesh size after dynamic refinement
  #1
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
Hello all,

Do you know how to obtain the actual size of a mesh after refinement? I've been trying to get this for quite a while now. The only way that I've able to come up with something close is to try to replicate the dynamic mesh results with that of a fine static mesh and then I assume the static mesh size as the dynamic mesh size after refinement. Is it a ratio of the initial mesh size? Below is my dynamicRefineFvMesh setting. Thanks for your help/explanation.

dynamicRefineFvMeshCoeffs
{
// How often to refine
refineInterval 1;
// Field to be refinement on
field alpha1;
// Refine field inbetween lower..upper
lowerRefineLevel 0.001;
upperRefineLevel 0.999;
// If value < unrefineLevel unrefine
unrefineLevel 10;
// Have slower than 2:1 refinement
NBufferLayers 1;
// Refine cells only up to maxRefinement levels
maxRefinement 2;
// Stop refinement if maxCells reached
maxCells 1000000;
// Flux field and corresponding velocity field. Fluxes on changed
// faces get recalculated by interpolating the velocity. Use 'none'
// on surfaceScalarFields that do not need to be reinterpolated.

correctFluxes
(
(phi Urel)
(phiAbs U)
(phiAbs_0 U_0)
(nHatf none)
(rho*phi none)
(ghf none)
);
// Write the refinement level as a volScalarField
dumpLevel true;
}
tayo is offline   Reply With Quote

Old   May 20, 2013, 21:13
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 279
Rep Power: 9
kmooney is on a distinguished road
If you're running in parallel you could do something like this:

Code:
label nCells = returnReduce(mesh.cells().size(), sumOp<label>());
Info<<"  Total number of cells in mesh:  "<<nCells<<endl;
If in serial you could do something like this:
Code:
label nCells = mesh.cells().size();
Info<<"  Total number of cells in mesh:  "<<nCells<<endl;
I'd imagine you could just throw this somewhere in the top level of your solver after the mesh.update() call.
dawnrain likes this.
kmooney is offline   Reply With Quote

Old   May 20, 2013, 22:42
Default
  #3
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
Hey Kyle, thanks for your response. I suppose this code would print in the log file, the number of cells in the alpha1 field after refinement at every time step. Assuming it gives me X cells in an alpha1 field with an initial size of Y, it will still be tough to obtain the average size/dimension of each cell after the refinement. Is there a way to obtain this average cell/grid size with a decent degree of accuracy?
tayo is offline   Reply With Quote

Old   May 20, 2013, 22:50
Default
  #4
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 279
Rep Power: 9
kmooney is on a distinguished road
I'm not sure if this is the exact code to make it happen but could could find the average cell volume exactly, no need for approximation:

Code:
scalar totalVol = gSum(mesh.cellVolumes());
scalar meanVol = totalVol / nCells;
kmooney is offline   Reply With Quote

Old   May 20, 2013, 22:53
Default
  #5
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
Thanks. I'll give it a try.
tayo is offline   Reply With Quote

Old   May 21, 2013, 13:03
Default
  #6
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
Quote:
Originally Posted by kmooney View Post
Code:
label nCells = mesh.cells().size();
Info<<"  Total number of cells in mesh:  "<<nCells<<endl;
Code:
scalar totalVol = gSum(mesh.cellVolumes());
scalar meanVol = totalVol / nCells;
Hi Kyle, this code gives me the total number of cells in the entire domain after refinement. However, I'm trying to get the total number of cells in the alpha1 field alone. I tried "volScalarField nAlphaCells = alpha1.db().mesh.cells().size()" but it didn't work. Can you help with this? Thanks
tayo is offline   Reply With Quote

Old   May 21, 2013, 19:14
Default
  #7
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 279
Rep Power: 9
kmooney is on a distinguished road
After refinement, the alpha field would have been resized and mapped from the previous mesh. It will have the same number of internalField values as there are cells in the mesh.

If you still want to count the number of internalField values of the alpha field I think you could get an integer count like this:

Code:
Info<< Number of internalField values for alpha1: << alpha1.internalField().size() << endl;
kmooney is offline   Reply With Quote

Old   May 21, 2013, 19:15
Default
  #8
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 279
Rep Power: 9
kmooney is on a distinguished road
After refinement, the alpha field would have been resized and mapped from the previous mesh. It will have the same number of internalField values as there are cells in the mesh.

If you still want to count the number of internalField values of the alpha field I think you could get an integer count like this:

Code:
Info<< Number of internalField values for alpha1: << alpha1.internalField().size() << endl;
kmooney is offline   Reply With Quote

Old   May 21, 2013, 21:55
Default
  #9
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
To get the total volume of cells in the alpha1 field, I tried this: "gSum(alpha1.internalFieldvolume())". It blew up. Please also provide this line of code. Thanks.
tayo is offline   Reply With Quote

Old   May 21, 2013, 21:57
Default
  #10
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 279
Rep Power: 9
kmooney is on a distinguished road
I'm going to be honest and say that at this point I really don't know what you're asking.
kmooney is offline   Reply With Quote

Old   May 21, 2013, 22:06
Default
  #11
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
Quote:
Originally Posted by kmooney View Post
Code:
scalar totalVol = gSum(mesh.cellVolumes());
scalar meanVol = totalVol / nCells;
I'm also trying to get the total volume of cells in the alpha1 field similar to the code above so that I will be able to estimate the volume of each cell.
tayo is offline   Reply With Quote

Old   May 21, 2013, 22:10
Default
  #12
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 279
Rep Power: 9
kmooney is on a distinguished road
The alpha1 field is stored on the mesh. It is one in the same as there is no alpha1 mesh, there is one domain mesh on which all of your flow fields are discretized onto. You should check out some introductory CFD texts, they will explain the basics better than I will.

You have a few conceptual gaps on your part which are causing communication issues between us.
kmooney is offline   Reply With Quote

Old   May 21, 2013, 22:25
Default
  #13
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
I clearly understand what you mean. What I'm saying is that the previous code seems to give the total volume of cells in the entire computation domain. But what I'm seeking the the total volume of cells in the alpha1 field alone. Remember it a 2-phase flow. Taking a 2nd look at the codes: "mesh.cells().size()" and "alpha1.internalField().size()" should give the same number of cells, just like you said. I guess I didn't explain clearly. What I wanted is the interfacial volume and number of cells (i.e. alpha1=0.5). Assuming the quasi bubble interface at alpha1=0.5, I will like to know its number of cells and volume after refinement at each time step.
tayo is offline   Reply With Quote

Old   May 21, 2013, 23:59
Default
  #14
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
Alright, just got an idea. I can get the number of cells in the phase at alpha1 = 0.5 using the iso-contour plot in paraFoam. To get the volume, swakFunctionObjects be nicely used. Hence, vol. of each cell can be obtained. Assuming uniform grid length, I can therefore compute an average length/size of the refined mesh. While not the most accurate, I think it solves the problem. Case closed. Thanks for your comments.

Last edited by tayo; May 22, 2013 at 02:00.
tayo is offline   Reply With Quote

Old   May 22, 2013, 08:44
Default
  #15
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,088
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

just a damn question.

Is there a solver in Standard of solvers that is using that code for adaptive mesh refinement?

Tobi
Tobi is offline   Reply With Quote

Old   May 22, 2013, 10:17
Default
  #16
Member
 
Tayo
Join Date: Aug 2012
Location: FL
Posts: 94
Rep Power: 4
tayo is on a distinguished road
OF has a couple of solvers with dynamic mesh refinement, based on your interest: pimpleDyMFoam for incompressible single-phase flow, sonicDyMFoam for compressible flow, and interDymFoam for 2-phase. You might need to modify the solver if your problem is complex. Check out the link below.

http://www.openfoam.com/features/standard-solvers.php
tayo is offline   Reply With Quote

Old   May 22, 2013, 13:39
Default
  #17
Senior Member
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,088
Blog Entries: 6
Rep Power: 19
Tobi will become famous soon enough
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

I thought that are "mesh moving solvers". So that a car or plane can go through a mesh not for adaptiv refinement! ?

Can I use that solvers for that problems too?
Tobi is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
SnappyHexMesh for internal Flow vishwa OpenFOAM Native Meshers: snappyHexMesh and Others 23 August 6, 2014 03:50
how to set periodic boundary conditions Ganesh FLUENT 13 January 22, 2014 05:11
[ICEM] Effect of globle mesh size and mesh independency sujay ANSYS Meshing & Geometry 13 March 4, 2013 03:07
How to control Minximum mesh space? hung FLUENT 7 April 18, 2005 09:38


All times are GMT -4. The time now is 08:45.