damogranlabs / classy_blocks

Python classes for easier creation of OpenFOAM's blockMesh dictionaries.
MIT License
126 stars 35 forks source link

Uneven cell count on equal blocks #13

Closed FranzBangar closed 2 years ago

FranzBangar commented 2 years ago

This fails when cell_size = 1.5 but works with other cell sizes:

#!/usr/bin/env python
import os
from classy_blocks.classes.mesh import Mesh
from classy_blocks.classes.shapes import ExtrudedRing

d_shaft = 12e-3
d_2 = 63e-3
d_3 = 80e-3
h = 20e-3
b_3 = 15e-3

cell_size = 1.5e-3

mesh = Mesh()

inner_ring = ExtrudedRing(
    [0, 0, 0],
    [0, 0, h],
    [d_shaft/2, 0, 0],
    d_2/2
)
inner_ring.chop_axial(start_size=cell_size)
inner_ring.chop_radial(start_size=cell_size)
inner_ring.chop_tangential(start_size=cell_size)

mesh.add(inner_ring)

Looks like same blocks with different orientation get a different calculated size; two things to check:

  1. Size calculation
  2. Only set one block of ring (and other shapes)
  3. why the above doesn't work (something with grading propagation)
  4. fix all of the above
FranzBangar commented 2 years ago
  1. Added proper arc length calculation
  2. Only relevant blocks of Shapes are chopped

In specific cases where block length is just between two values, rounding can produce different cell counts and this is unavoidable. Therefore it is important to only chop minimum number of blocks and let others be defined automatically. Unless you decide to do it manually and use count on everything.