You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-35Lines changed: 52 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,21 @@
3
3
Python classes for easier creation of OpenFOAM's blockMesh dictionaries.
4
4
5
5
# About
6
+
6
7
_blockMesh_ is a very powerful mesher but the amount of manual labour it requires to make even the simplest meshes makes it mostly useless. Even attempts to simplify or parametrize blockMeshDicts with `#calc` or even the dreadful `m4` quickly become unmanageable and cryptic.
7
8
8
9
classy_blocks' aim is to minimize the amount of meticulous work by providing a
9
10
more intuitive workflow, off-the-shelf parts and some automatic helpers for building and optimization of block-structured hexahedral meshes.
10
11
Still it is not an automatic mesher and therefore some kinds of geometry are more suited than others.
11
12
12
13
## Tutorial
14
+
13
15
Check out the [classy_blocks tutorial on damogranlabs.com](https://damogranlabs.com/2023/04/classy_blocks-tutorial-part-1-the-basics/)!
14
16
15
17
## Useful For
18
+
16
19
### Fields
20
+
17
21
- Turbomachinery (impellers, propellers)
18
22
- Microfluidics
19
23
- Flow around buildings
@@ -22,6 +26,7 @@ Check out the [classy_blocks tutorial on damogranlabs.com](https://damogranlabs.
@@ -33,60 +38,65 @@ Check out the [classy_blocks tutorial on damogranlabs.com](https://damogranlabs.
33
38
- Overset meshes
34
39
35
40
## Not Good For
41
+
36
42
- External aerodynamics of vehicles (too complex to mesh manually, without refinement generates too many cells)
37
43
- Complex geometry in general
38
44
- One-off simulations (use automatic meshers)
39
45
40
46
# How To Use It
47
+
41
48
- To install the current _stable_ version from pypi, use `pip install classy_blocks`
42
-
- To download the cutting-edge development version, install the development branch from github: `pip install git+https://github.com/damogranlabs/classy_blocks.git@development`
49
+
- To download the cutting-edge development version, install the development branch from Github: `pip install git+https://github.com/damogranlabs/classy_blocks.git@development`
43
50
- If you want to run examples, follow instructions in [Examples](#examples)
44
-
- If you want to contribute, follow instructions in [CONTRIBUTING.rst](CONTRIBUTING.rst)
51
+
- If you want to contribute, follow instructions in [CONTRIBUTING.md](CONTRIBUTING.md)
45
52
46
53
# Features
47
54
48
55
## Workflow
56
+
49
57
As opposed to blockMesh, where the user is expected to manually enter pre-calculated vertices, edges, blocks and whatnot, classy_blocks tries to mimic procedural modeling of modern 3D CAD programs. Here, a Python script contains steps that describe geometry of blocks, their cell count, grading, patches and so on. At the end, the procedure is translated directly to blockMeshDict and no manual editing of the latter should be required.
50
58
51
59
## Building Elements
60
+
52
61
_Unchecked items are not implemented yet but are on a TODO list_
53
62
54
63
-[x] Manual definition of a Block with Vertices, Edges and Faces
55
64
-[x] Operations (Loft, Extrude, Revolve)
56
-
-[x] Loft
57
-
-[x] Extrude
58
-
-[x] Revolve
59
-
-[x] Wedge (a shortcut to Revolve for 2D axisymmetric cases)
60
-
-[x] Connector (A Loft between two existing Operations)
65
+
-[x] Loft
66
+
-[x] Extrude
67
+
-[x] Revolve
68
+
-[x] Wedge (a shortcut to Revolve for 2D axisymmetric cases)
69
+
-[x] Connector (A Loft between two existing Operations)
61
70
-[x] Sketches of common cross-sections
62
-
-[x] Quarter and Semi circle
63
-
-[x] Circle
64
-
-[x] Boxed circle
65
-
-[x] Oval with straight sides
66
-
-[x] Ellipse (and ovals in various configurations)
67
-
-[x] Cartesian grid
71
+
-[x] Quarter and Semi circle
72
+
-[x] Circle
73
+
-[x] Boxed circle
74
+
-[x] Oval with straight sides
75
+
-[x] Ellipse (and ovals in various configurations)
76
+
-[x] Cartesian grid
68
77
-[x] Simple way of creating custom Sketches
69
78
-[x] Easy shape creation from Sketches
70
79
-[x] Predefined Shapes
71
-
-[x] Box (shortcut to Block aligned with coordinate system)
72
-
-[x] Elbow (bent pipe of various diameters/cross-sections)
73
-
-[x] Cone Frustum (truncated cone)
74
-
-[x] Cylinder
75
-
-[x] Ring (annulus)
76
-
-[x] Hemisphere
80
+
-[x] Box (shortcut to Block aligned with coordinate system)
81
+
-[x] Elbow (bent pipe of various diameters/cross-sections)
82
+
-[x] Cone Frustum (truncated cone)
83
+
-[x] Cylinder
84
+
-[x] Ring (annulus)
85
+
-[x] Hemisphere
77
86
-[x] Stacks (collections of similar Shapes stacked on top of each other)
78
87
-[x] Predefined parametric Objects
79
-
-[x] T-joint (round pipes)
80
-
-[x] X-joint
81
-
-[x] N-joint (multiple pipes)
82
-
-[] Other building tools
83
-
-[x] Use existing Operation's Face to generate a new Operation
84
-
-[x] Chain Shape's start/end surface to generate a new Shape
85
-
-[x] Expand Shape's outer surface to generate a new Shape (Cylinder/Annulus > Annulus)
86
-
-[x] Contract Shape's inner surface into a new Shape (Annulus > Cylinder/Annulus)
87
-
-[x] Offset Operation's faces to form new operations
88
+
-[x] T-joint (round pipes)
89
+
-[x] X-joint
90
+
-[x] N-joint (multiple pipes)
91
+
-[x] Other building tools
92
+
-[x] Use existing Operation's Face to generate a new Operation
93
+
-[x] Chain Shape's start/end surface to generate a new Shape
94
+
-[x] Expand Shape's outer surface to generate a new Shape (Cylinder/Annulus > Annulus)
95
+
-[x] Contract Shape's inner surface into a new Shape (Annulus > Cylinder/Annulus)
96
+
-[x] Offset Operation's faces to form new operations (Shell)
88
97
89
98
## Modifiers
99
+
90
100
After blocks have been placed, it is possible to create new geometry based on placed blocks or to modify them.
91
101
92
102
-[x] Move Vertex/Edge/Face
@@ -95,6 +105,7 @@ After blocks have been placed, it is possible to create new geometry based on pl
95
105
-[x] Optimize point position of a Sketch or mesh vertices
96
106
97
107
## Meshing Specification
108
+
98
109
-[x] Simple definition of all supported kinds of edges with a dedicated class (Arc/Origin/Angle/Spline/PolyLine/Project)
99
110
-[x] Automatic sorting/reorienting of block vertices based on specified _front_ and _top_ points
100
111
-[x] Automatic calculation of cell count and grading by specifying any of a number of parameters (cell-to-cell expansion ratio, start cell width, end cell width, total expansion ratio)
@@ -116,6 +127,7 @@ How to run:
116
127
- Open `examples/case/case.foam` in ParaView to view the result
117
128
118
129
For instance:
130
+
119
131
```bash
120
132
cd examples/chaining
121
133
python tank.py
@@ -161,8 +173,8 @@ mesh.add(revolve)
161
173
162
174
> See `examples/operations` for an example of each operation.
163
175
164
-
165
176
## Shapes
177
+
166
178
Some basic shapes are ready-made so that there's no need for workout with Operations.
167
179
168
180
A simple Cylinder:
@@ -204,6 +216,7 @@ Venturi tube
204
216
> See `examples/chaining` for an example of each operation.
205
217
206
218
## Custom Sketches and Shapes
219
+
207
220
A Sketch is a collection of faces - essentially a 2D geometric object, split into quadrangles. Each Face in a Sketch is transformed into 3D space, creating a Shape.
208
221
209
222
A number of predefined Sketches is available to choose from but it's easy to create a custom one.
@@ -220,6 +233,7 @@ Points that define a custom sketch can only be placed approximately. Their posit
220
233
> See `examples/shape/custom` for an example with a custom sketch.
221
234
222
235
## Stacks
236
+
223
237
A collection of similar Shapes; a Stack is created by starting with a Sketch, then transforming it a number of times, obtaining Shapes, stacked on top of each other.
224
238
225
239
An Oval sketch, translated and rotated to obtain a Shape from which a Stack is made.
> See `examples/stack/cube.py` for the full script.
241
256
242
-
243
257
An electric heater in water, a mesh with two cellZones. The heater zone with surrounding fuild of square cross-section is an extruded `WrappedDisk` followed by a `RevolvedStack` of the same cross-sections. The center is then filled with a `SemiCylinder`.
244
258

245
259
246
260
> See `examples/complex/heater` for the full script.
247
261
248
262
## Assemblies
263
+
249
264
A collection of pre-assembled parametric Shapes, ready to be used for further construction.
250
265
251
266
Three pipes, joined in a single point.
252
267

253
268
254
269
## Automatic Grading
270
+
255
271
After blocks have been positioned their cell count must be defined. This can be done manually with something like `operation.chop(axis, start_size=..., c2c_expansion=...)` or anything that `.chop()` method supports. Not all blocks need to be chopped as cell counts will be propagated throughout the mesh so it is advisable to only _chop_ the minimum required.
256
272
257
273
All that can also be avoided by using automatic graders, for instance, `SmoothGrader` will set counts so that desired cell size will be obtained but will also use multigrading to keep cell sizes between neighbouring blocks as uniform as possible.
@@ -271,7 +287,6 @@ Projecting a block side to a geometry is straightforward; edges, however, can be
271
287
272
288
Geometry is specified as a simple dictionary of strings and is thrown in blockMeshDict exactly as provided by the user.
273
289
274
-
275
290
```python
276
291
geometry = {
277
292
'terrain': [
@@ -375,6 +390,7 @@ Airfoil core with blunt trailing edge (imported points from NACA generator) and
When setting cell counts and expansion ratios, it is possible to specify which value to keep constant. Mostly this will be used for keeping thickness of the first cell at the wall consistent to maintain desired `y+` throughout the mesh. This is done by simple specifying a `preserve="..."` keyword.
379
395
380
396
Example: a block chopped in a classic way where cell sizes will increase when block size increases:
@@ -389,12 +405,12 @@ By showing `block_ids` with a proper color scale the blocking can be visualized.
389
405
This is useful when blockMesh fails with errors reporting invalid/inside-out blocks but VTK will
A gear, made from a curve of a single tooth, calculated by
@@ -408,9 +424,10 @@ A complex example: parametric, Low-Re mesh of a cyclone
408
424
409
425
# Prerequisites
410
426
411
-
Package (python) dependencies can be found in *pyproject.toml* file.
427
+
Package (python) dependencies can be found in _pyproject.toml_ file.
412
428
Other dependencies that must be installed:
413
-
- python3.8 and higher
429
+
430
+
- python3.9 and higher
414
431
- OpenFoam: .org or .com version is supported, foam-extend's blockMesh doesn't support multigrading but is otherwise also compatible. BlockMesh is not required to run Python scripts. There is an ongoing effort to create VTK meshes from within classy_blocks. See the wip_mesher branch for the latest updates.
0 commit comments