New checkAspectRatio Utility
4 Attachment(s)
Servus everyone,
lately I have been running some simulations with interFoam, in which very thin layers of fluid () in an inclined channel are involved. As it turns out, (at least) interFoam does not like meshs with aspect ratios above a certain value (about 3), or where neighbouring cells are much bigger (probably not only interFoam's problem). Since I stumbled upon the same problems, I decided to write a small tool to quickly (and may dirty) fix these problems: The utility attached can:
Either it prints "Mesh OK", or it will return a number of cellSets, namely (x|y|z)AspectCells and (x|y|z)NeighbourCells, wherein the first store the cells with a too high aspect ratio in the respective direction, and the latter to large ratios between neighbouring cells. Process example for my channel: Attachment 45208 Attachment 45209 0: Original mesh, refined using refineWallLayerSadly it is an iterative process, since you always have to reselect a cellSet after the mesh has been changed, however the order of above stesps basically is irrelevant. As an example of the results for my channel, it has changed the solution from the left (unrefined, 40550) picture to the right version (166500 cells). This process is probably far from optimal, but in my case it was right now the fastest way to solve the problem, and 166k cells is not too much: Attachment 45207 I don't know if this tool really is useful, but I thought I'd share it. Just wmake all it, and it should work (tested in OF 2.3.x). And I'd appricate if you let me know if you can use this, or if you have any further ideas/find bugs. Finally, here is a list of references, where I copied the code from and where I got some ideas/numbers: Reason for this: Jon Elvar WallevikCreating cellSets: Tomislav MaricFinding neighbours: Su JunweiDetermining the (approximate) size of cell Niels Gjoel Jacobsen--- Sorry I left out the axis, I had to edit the pictures a bit. the axis directions are: x: gropund to the right |
2 Attachment(s)
Hello again,
although the replies so far are sort of limited, I decided to extend the tool to do the refinement automatically, which should be easier to handle and thus more reproducible. The new tool would be refineAspectRatio. It does the same checks as the tool above, but can perform a refinement step after each analysis. Installation: Use the Allwmake script. This should work, tested in OF23x. The tool uses some mesh statistics functions that are included in checkMesh, and thus depends on symbolic links being created, since the functions are not available in any library. Should the paths be wrong or env-variables missing, you can manually create links to the checkMesh's files printMeshStats.(C|H) or put a copy of those in the directory. Use Quite unsurprising, the script has a -help argument: Code:
Usage: refineAspectRatio [OPTIONS] Most interesting options should be -criticalRatio <value> (defining the limit at which point cells are being refined), -maxRefineLevel <value> (defining how many refinement iterations are done) and -neighbour (activating the check for neighbour cells). As debug output the flags -verbose and -writeMeshes can help. A combination of both will output every single meshing step, whether refinement has been done or not. -writeMeshes only will only write all changes of a complete iteration. Internals: In some kind of undefined pseudo-code, the following algorithm describes roughly what is actually done: Code:
set criticalRatio; // critical value for aspect ratio Visual Process The following pictures show the results of a run. I'm thinking about also posting the test case I used, but I'd have to remove some stuff first, so maybe when I have spare time. Attachment 45776 |
All times are GMT -4. The time now is 08:34. |