Created
October 28, 2024 13:55
-
-
Save 0x1d107/babc9ace0db18da96b20c50fbadfaebd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import * | |
| HEADER = """ | |
| FoamFile | |
| { | |
| version 2.0; | |
| format ascii; | |
| class dictionary; | |
| object blockMeshDict; | |
| } | |
| """ | |
| scale = 0.1 | |
| vertices=[] | |
| edges=[] | |
| blocks=[] | |
| n=10 | |
| r= 5 | |
| h= 10 | |
| vertices.extend([(r*cos(pi*i/n),r*sin(pi*i/n),0) for i in range(n)]) | |
| vertices.extend([(r*cos(pi*i/n),r*sin(pi*i/n),h) for i in range(n)]) | |
| def print_file(): | |
| print(HEADER) | |
| print(f"convertToMeters {scale};") | |
| print('vertices\n(') | |
| for vx in vertices: | |
| print("(",*vx,")") | |
| print(');') | |
| print('edges\n(') | |
| for ed in edges: | |
| print(*ed[0:3],"(",*ed[3],")") | |
| print(');') | |
| print('blocks\n(') | |
| for bl in blocks: | |
| print(bl[0],'(',*bl[1],')','(',*bl[2],')',bl[3],'(',*bl[4],')') | |
| print(');') | |
| print_file() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment