How to know mesh size after dynamic refinement
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; } 
If you're running in parallel you could do something like this:
Code:
label nCells = returnReduce(mesh.cells().size(), sumOp<label>()); Code:
label nCells = mesh.cells().size(); 
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?

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()); 
Thanks. I'll give it a try.

Quote:

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; 
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; 
To get the total volume of cells in the alpha1 field, I tried this: "gSum(alpha1.internalFieldvolume())". It blew up:eek:. Please also provide this line of code. Thanks.

I'm going to be honest and say that at this point I really don't know what you're asking.

Quote:

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. 
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.

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:D. Case closed. Thanks for your comments.

Hi all,
just a damn question. Is there a solver in Standard of solvers that is using that code for adaptive mesh refinement? Tobi 
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 
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? 
All times are GMT 4. The time now is 16:12. 