
[Sponsors] 
May 20, 2013, 13:40 
How to know mesh size after dynamic refinement

#1 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 
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; } 

May 20, 2013, 21:13 

#2 
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA  San Diego, CA USA
Posts: 319
Rep Power: 10 
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; Code:
label nCells = mesh.cells().size(); Info<<" Total number of cells in mesh: "<<nCells<<endl; 

May 20, 2013, 22:42 

#3 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 
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?


May 20, 2013, 22:50 

#4 
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA  San Diego, CA USA
Posts: 319
Rep Power: 10 
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; 

May 20, 2013, 22:53 

#5 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 
Thanks. I'll give it a try.


May 21, 2013, 13:03 

#6 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 
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


May 21, 2013, 19:14 

#7 
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA  San Diego, CA USA
Posts: 319
Rep Power: 10 
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; 

May 21, 2013, 19:15 

#8 
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA  San Diego, CA USA
Posts: 319
Rep Power: 10 
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; 

May 21, 2013, 21:55 

#9 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 
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.


May 21, 2013, 21:57 

#10 
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA  San Diego, CA USA
Posts: 319
Rep Power: 10 
I'm going to be honest and say that at this point I really don't know what you're asking.


May 21, 2013, 22:06 

#11 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 

May 21, 2013, 22:10 

#12 
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA  San Diego, CA USA
Posts: 319
Rep Power: 10 
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. 

May 21, 2013, 22:25 

#13 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 
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 2phase 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.


May 21, 2013, 23:59 

#14 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 
Alright, just got an idea. I can get the number of cells in the phase at alpha1 = 0.5 using the isocontour 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. 

May 22, 2013, 10:17 

#16 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 5 
OF has a couple of solvers with dynamic mesh refinement, based on your interest: pimpleDyMFoam for incompressible singlephase flow, sonicDyMFoam for compressible flow, and interDymFoam for 2phase. You might need to modify the solver if your problem is complex. Check out the link below.
http://www.openfoam.com/features/standardsolvers.php 

May 22, 2013, 13:39 

#17 
Senior Member
Tobias Holzmann
Join Date: Oct 2010
Location: Leoben (Austria)
Posts: 1,397
Blog Entries: 5
Rep Power: 24 
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? 

Thread Tools  
Display Modes  


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