Skip to content

Commit

Permalink
Add a Stack (proposal definition) and a heater w.i.p. example
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzBangar committed May 7, 2024
1 parent 8756ddd commit cd597d8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/complex/heater/heater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os

import numpy as np

import classy_blocks as cb
from classy_blocks.construct.flat.sketches.disk import WrappedDisk

# TODO: direct imports!
from classy_blocks.construct.shape import ExtrudedShape
from classy_blocks.construct.stack import RevolvedStack

wire_diameter = 10
wire_length = 100
bend_radius = 2 * wire_diameter


mesh = cb.Mesh()

heater_xs = WrappedDisk([0, 0, 0], [0, -bend_radius / 2, -bend_radius / 2], wire_diameter / 2, [1, 0, 0])
straight_1 = ExtrudedShape(heater_xs, wire_length)

curve = RevolvedStack(straight_1.sketch_2, np.pi / 4, [0, 0, 1], [wire_length, bend_radius, 0], 4)
for shape in curve.shapes:
mesh.add(shape)

for i in range(3):
for op in shape.operations:
op.chop(i, count=10)

for i in range(3):
for op in straight_1.operations:
op.chop(i, count=10)

mesh.add(straight_1)

mesh.write(os.path.join("..", "..", "case", "system", "blockMeshDict"), debug_path="debug.vtk")
29 changes: 29 additions & 0 deletions src/classy_blocks/construct/stack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import List

from classy_blocks.construct.flat.sketch import Sketch
from classy_blocks.construct.operations.loft import Loft
from classy_blocks.construct.shape import LoftedShape, RevolvedShape
from classy_blocks.types import PointType, VectorType


class Stack:
"""A collection of topologically similar Shapes,
stacked on top of each other."""

shapes: List[LoftedShape] = []

@property
def grid(self) -> List[List[List[Loft]]]:
"""Returns a 3-dimensional list of operations;
first two dimensions within a shape, the third along the stack"""
return [shape.grid for shape in self.shapes]


class RevolvedStack(Stack):
"""Revolved shapes, stacked around the given center"""

def __init__(self, base: Sketch, angle: float, axis: VectorType, origin: PointType, repeats: int):
for _ in range(repeats):
shape = RevolvedShape(base, angle, axis, origin)
self.shapes.append(shape)
base = shape.sketch_2

0 comments on commit cd597d8

Please sign in to comment.