Skip to content

Commit

Permalink
Add methods to remove spline edges from shapes
Browse files Browse the repository at this point in the history
Namely, anything created from Disks that now contain spline edges;
these do not get updated during optimization and that will produce bad
cells.

Also, update optimization examples that are affected by that.
  • Loading branch information
FranzBangar committed Jun 11, 2024
1 parent 266ba8c commit b4ae003
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
5 changes: 2 additions & 3 deletions examples/complex/cyclone/regions/inlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ def create_inlet(self):
)

for op in inlet.operations:
# TODO: remove edges from face/operation
op.top_face.edges = [Line(), Line(), Line(), Line()]
op.bottom_face.edges = [Line(), Line(), Line(), Line()]
op.top_face.remove_edges()
op.bottom_face.remove_edges()

for point in op.top_face.points:
# move points on inlet's end face so that they touch cyclone body,
Expand Down
8 changes: 8 additions & 0 deletions examples/optimization/diffuser_free.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@

mesh.set_default_patch("walls", "wall")

# Internal edges in Cylinders are Splines by default;
# In this case their endpoints will be moved ('optimized') but not
# the points in between; this will create bad cells. Either re-define these edges after optimization
# or remove them altogether.
diffuser.remove_inner_edges()
small_pipe.remove_inner_edges()
big_pipe.remove_inner_edges()

# Assemble the mesh before making changes
mesh.assemble()

Expand Down
10 changes: 7 additions & 3 deletions examples/optimization/diffuser_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# The setup is the same as the diffuser_free example
# except that here vertices are only allowed to move
# axially in a straight line.
# See diffuser_free for comments.

small_pipe = cb.Cylinder([0, 0, 0], [2, 0, 0], [0, 1, 0])
small_pipe.chop_axial(start_size=size)
Expand All @@ -23,19 +24,22 @@

big_pipe = cb.Cylinder.chain(diffuser, 5)
big_pipe.chop_axial(start_size=size)

mesh.add(big_pipe)

mesh.set_default_patch("walls", "wall")

# Assemble the mesh before making changes
diffuser.remove_inner_edges()
small_pipe.remove_inner_edges()
big_pipe.remove_inner_edges()

mesh.assemble()

# Find inside vertices
finder = cb.RoundSolidFinder(mesh, diffuser)
inner_vertices = finder.find_core(True)
inner_vertices.update(finder.find_core(False))

# Release those vertices so that optimization can find a better position for them

optimizer = cb.Optimizer(mesh)

for vertex in inner_vertices:
Expand Down
7 changes: 7 additions & 0 deletions src/classy_blocks/construct/shapes/round.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def set_outer_patch(self, name: str) -> None:
for operation in self.shell:
operation.set_patch(self.outer_patch, name)

def remove_inner_edges(self) -> None:
"""Removes spline edges from cylinders.
This needs to be done in cases where any of the start/end plane points will move
(due to optimization or manual adjustments)."""
for face in (*self.sketch_1.core, *self.sketch_2.core):
face.remove_edges()


class RoundHollowShape(RoundSolidShape):
def __init__(
Expand Down

0 comments on commit b4ae003

Please sign in to comment.