-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Stack (proposal definition) and a heater w.i.p. example
- Loading branch information
1 parent
8756ddd
commit cd597d8
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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") |
This file contains 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
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 |