|
[Sponsors] |
February 16, 2016, 11:33 |
New checkAspectRatio Utility
|
#1 |
Member
Timm Severin
Join Date: Mar 2014
Location: Munich
Posts: 63
Rep Power: 12 |
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: steps-1.png steps-2.png 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: comparison.jpg 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 |
|
March 8, 2016, 11:23 |
|
#2 |
Member
Timm Severin
Join Date: Mar 2014
Location: Munich
Posts: 63
Rep Power: 12 |
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] options: -basedOnVolume Evaluate neighbouring cell sizes on volume instead of (x/y/z) dimensions. -case <dir> specify alternate case directory, default is the cwd -criticalRatio <value> Set the critical aspect ratio allowed in a cell, defaults to 3.0. -maxCells <value> The maximum number of cells the new mesh is supposed to have, use 0 means for unlimited passes. Defaults to 0. NOTE: Not precise (at the Moment)! -maxRefineLevel <value> The maximum number of iterations for refinement in every dimension, use 0 for unlimited passes. Defaults to 3. -neighbour Also refine cells with bad neighbour ratios. -neighbourRatio <value> Set the allowed ratio of neighbour cell sizes, defaults to 3.0. Implies -neighbour option. -overwrite overwrite existing mesh/results files -verbose Print more information during the refinement process. Also will write even more meshes when used in combination with 'writeMeshes'. -writeMeshes Writes the intermediate meshes to seperate time folders. Overrides overwrite. -srcDoc display source code in browser -doc display application documentation in browser -help print the usage A tool to refine a mesh, avoiding big aspect ratios in cells and differences in dimensions to neighbouring cells. Using: OpenFOAM-2.3.x (see www.OpenFOAM.org) Build: 2.3.x-2f9138f6f49f 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 set neighbourRatio; // critical value for neighbouring cell sizes while not(meshOk or maxCells or maxRefinement) { for (cell in cells) { set [x, y, z] = getCellDimensions(cell); if x/y or x/z is greater criticalRratio refine cell in x; ... repeat for x and y dimensions set [nX, nY, nZ] = getCellDimensions(neighbours of cell); if x/nX is greater neighbourRatio refine cell in x; ... continue for y and z } if number of cells is greater limit set maxCells = true; if number of loops is greater limit set maxRefinement = true; if no changes in mesh set meshOk = true; } 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. refineAspectRatio.png
__________________
PhD Student at the Institute of Biochemical Engineering at TU München Modelling of fluid dynamics in open photobioreactors. System: OpenFOAM 2.3.x, 64bit, 8 Core Xeon Workstation |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OF 6 wallHeatFlux utility not working on chtMultiRegionFoam tutorial | troparry | OpenFOAM Post-Processing | 1 | January 10, 2022 06:12 |
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field | lakeat | OpenFOAM Community Contributions | 58 | December 23, 2021 02:36 |
wallHeatFlux Calculation wrt utility version | ahmet | OpenFOAM Post-Processing | 1 | December 18, 2016 19:45 |
[mesh manipulation] mirrorMesh utility preserving regions | zfaraday | OpenFOAM Meshing & Mesh Conversion | 1 | November 7, 2016 21:51 |
Something doens't work with wallHeatFlux utility or externalWallHeatFluxTemperat BC!! | zfaraday | OpenFOAM Post-Processing | 0 | February 5, 2015 16:47 |