|
[Sponsors] |
[blockMesh] Creating blockMeshDict from python |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 3, 2020, 04:33 |
Creating blockMeshDict from python
|
#1 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
Hello.
I've been using Python and jinja2 to calculate points and create blockMeshDict files with it. I've shared the script with a few examples here: https://github.com/damogranlabs/classyBlocks https://damogranlabs.com/2020/02/cla...for-blockmesh/ So far it proved useful to me. Feel free to use it, any comments and suggestions are most welcome. Thanks! |
|
June 9, 2020, 15:47 |
|
#2 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
Just a bump, I made some massive updates to mentioned scripts. Now you can (almost) easily create pipings, revolved (rotational) geometry, axisymmetric - wedge meshes etc. etc. etc.
In some cases blockMesh is better than snappy or anything else:
I'd be happy to improve or add features! Have fun! https://github.com/damogranlabs/classy_blocks |
|
July 26, 2021, 04:22 |
|
#3 |
New Member
wangyang
Join Date: Jun 2019
Posts: 9
Rep Power: 7 |
That's wonderful works!
Thank you very much |
|
July 26, 2021, 07:12 |
|
#4 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
glad to hear that. there's another update coming soon, with some more goodies.
if anyone did actually ever use this, i'd be happy to get some feedback - where the problems are, what to improve, what to add. |
|
July 26, 2021, 22:57 |
|
#5 | |
New Member
wangyang
Join Date: Jun 2019
Posts: 9
Rep Power: 7 |
Quote:
Hi Nejc I want to generate more than 100 cases. I think I can use some scripts. so I find you work. It's great. Thank you! But I am a newbie about OpenFOAM and parametric design. I want to put the solid in a 4.575m * 0.313 m numerical wave tank. I divided the domain to water and air. 1. the water height is change from 0.143 to 0.071. I want to use 0.001m * 0.001m per cell. 2. the solid will up the still water level or submerge in the water. Can you give me some advice, how to use your tool to generate mesh like this? It's 2D cases. If I want to use turbulence model, like kOmegaSST, how to handle the meshes? Thank you very much best regards. Yang Wang |
||
July 27, 2021, 04:41 |
|
#6 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
If I understood you correctly, this is the solid immersed in water. In that case your blocking would be something like the sketch in the attachment.
Create a function that creates the darker blue blocks on a specified position. Then just call it n-times with a for loop to generate other light blue parts. The same goes for the darker green blocks. k-Omega SST could work with or without boundary layers so it depends on your flow conditions. in case you'll need resolved boundary layer (y+ < 1) that will complicate the mesh; I guess the simplest for you would be to use blockMesh just to generate geometry and use cartesian2DMesh from cfMesh to create the actual mesh for you: https://damogranlabs.com/2020/10/blo...xternal-flows/ . In that case the blocking gets much simpler - create a single block for outer domain, get STL from that, then another blockMesh for the 'white' wall parts for from the sketch and extract those, then combine to a single STL. See chapter 2.2 in this manual: http://cfmesh.com/wp-content/uploads...fMesh_v1.1.pdf You'll find everything else in the simpleFoam/pitzDaily tutorial. |
|
July 27, 2021, 05:24 |
|
#7 | |
New Member
wangyang
Join Date: Jun 2019
Posts: 9
Rep Power: 7 |
Quote:
Thank you reply. I will try to follow your advice. I am modifying your airfoil_2d case that's the only example I think is same my case. but I think if I use your tools, I needn't to use cfMesh or snappyHexMesh to generate boundary layer. I can refine the near wall region use expansion ratio to 1.2 or some other value and let's the yPlus < 1. If the yPlus > 30, the first boundary layer thickness is greater than the yPlus < 1. But the total boundary layer total thickness has some different? Can you tell me ? Thank you very much! Best regards Yang Wang |
||
July 27, 2021, 05:49 |
|
#8 | |
New Member
wangyang
Join Date: Jun 2019
Posts: 9
Rep Power: 7 |
Quote:
I just read the linke you give me. 1. I can not find anything about two main script. “./generate_mode.py and ./generate_domain.py" 2. but the link has another link, maybe can solve my probel I will read it and get it. Is it right? Thank you Yang Wang |
||
July 27, 2021, 07:18 |
|
#9 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
you must write your own scripts for your geometry.
the next article is a more specific example but you'll still need your own classy_blocks scripts: https://damogranlabs.com/2020/10/a-p...ne-from-pipes/ |
|
July 27, 2021, 09:12 |
|
#10 | |
New Member
wangyang
Join Date: Jun 2019
Posts: 9
Rep Power: 7 |
Quote:
Thank you. I am reading you blog paper now. I almost know you thinking. Yang Wang |
||
July 29, 2021, 11:01 |
|
#11 | |
New Member
wangyang
Join Date: Jun 2019
Posts: 9
Rep Power: 7 |
Quote:
Hi, Nejc I almost finished the procedure you told me how to generate hex mesh. Thank you very much! I need read your tutorials and code more time. Maybe I will ask you more questions, please give me more advices. Thank you Yang Wang |
||
July 31, 2021, 11:37 |
|
#12 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
yaay, you did it! =D
|
|
August 4, 2021, 07:59 |
|
#13 |
Senior Member
|
Thank you for making your wonderful code available!
Apologies for being impatient and only poorly acquainted with Python as programming environment. How do I make sure that modules defined by classy_blocks get loaded prior to running the examples? Edit: when running an example (e.g. "python from_points.py"), I get the error ModuleNotFoundError: No module named 'classy_blocks'. I have not been able to find where this module is defined. Thanks! Domenico Lahaye. Last edited by dlahaye; August 4, 2021 at 12:11. Reason: New information added. |
|
August 5, 2021, 05:40 |
|
#14 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
this has been updated just yesterday - it's quite an overhaul.
see this repository: https://github.com/damogranlabs/classy_examples and try to keep roughly the same directory structure as the examples repository. good luck! EDIT: the examples are made to be run via run.py where they are imported from respective directories - uncomment the "from_points" line in run.py and run that. |
|
August 5, 2021, 07:22 |
|
#15 |
Senior Member
|
Sincere thanks for getting in touch!
My sincere apologies for being as slow as an old lame snake in my understanding. Below is what I tried. Further guidance is much appreciated. Here is what I did 1/ Downloaded both classy_blocks-master and classy_examples-main djplahaye@Djps-MBP mypython % ls classy_blocks-master classy_examples-main 2/ Set PYTHONPATH and verify its setting export PYTHONPATH=/Users/djplahaye/mysoftware/mypython/classy_blocks-master/classes ls $PYTHONPATH __init__.py block.py mesh.py operations.py primitives.py shapes.py 3/ cd into classy_examples-main, uncomment import examples.primitive.from_points and run the script run.py djplahaye@Djps-MBP classy_examples-main % ls LICENSE README.md case classy_blocks examples run.py tests djplahaye@Djps-MBP classy_examples-main % python run.py Traceback (most recent call last): File "run.py", line 7, in <module> import examples.primitive.from_points File "/Users/djplahaye/mysoftware/mypython/classy_examples-main/examples/primitive/from_points.py", line 1, in <module> from classy_blocks.classes.primitives import Edge ModuleNotFoundError: No module named 'classy_blocks.classes' |
|
August 5, 2021, 10:30 |
|
#16 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
You don't have to add anything to path. Just rename classy_blocks-master to classy_blocks and put them into your working directory. For instance, your home folder:
Code:
~/example/ classy_blocks/ case/ custom_modules/ run.py |
|
August 11, 2021, 12:55 |
|
#18 |
Senior Member
|
Greetings,
Question: revolve with angle equal to 180 degrees or larger does not work, correct? This has to do with face orientation, correct? Edit: I would like to revolve over 360 (full circle) degrees? How do I concatenate 4 revolves each over 90 degrees taking as base the result of the previous operation? How do i merge pairs at the end? Edit again: found cylinder as building block. Will look into this first. Thx! Thanks, Domenico. Last edited by dlahaye; August 11, 2021 at 16:06. Reason: Info added |
|
August 12, 2021, 13:29 |
|
#19 |
Senior Member
|
Greetings again.
The function set_axial_cell_size() allows to grade the mesh of a Cylinder object in axial direction. The same function does not work for a RevolvedRing object as this object has no 'core' attribute. How to you suggest to grade the mesh of a RevolvedRing object? Thanks so much again. Domenico. |
|
August 12, 2021, 18:22 |
|
#20 |
Senior Member
Nejc
Join Date: Feb 2017
Location: Slovenia
Posts: 196
Rep Power: 9 |
Hello,
that's a bug. It's fixed in the latest update. Also please note I've renamed those functions with a more descriptive names: - count_to_size_*() sets number of cells - grade_to_size_*() keeps cell number and sets grading. See the examples repository. Thanks for the comment. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[blockMesh] Created a python package for generating blockMeshDict | grokkingStuff | OpenFOAM Meshing & Mesh Conversion | 3 | November 5, 2020 08:55 |
[blockMesh] Creating a blockmeshDict file | andrewlindsay | OpenFOAM Meshing & Mesh Conversion | 8 | August 15, 2020 10:56 |
[blockMesh] Creating an axisymmetric piston cylinder in blockMeshDict | foadsf | OpenFOAM Meshing & Mesh Conversion | 9 | August 23, 2018 08:54 |
[blockMesh] what commands should I use to start creating a blockMeshdict file? | Hojae | OpenFOAM Meshing & Mesh Conversion | 1 | November 12, 2014 17:58 |
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) | cfdonline2mohsen | OpenFOAM | 3 | October 21, 2013 10:28 |