Skip to content

Commit

Permalink
Direct imports of *Joints
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzBangar committed Jul 28, 2024
1 parent b03abcd commit 2cec911
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
27 changes: 27 additions & 0 deletions examples/assembly/l_joint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os

import classy_blocks as cb
from classy_blocks.construct.assemblies.joints import LJoint
from classy_blocks.util import functions as f

mesh = cb.Mesh()

axis_point_1 = [0.0, 0.0, 0.0]
axis_point_2 = [5.0, 5.0, 0.0]
radius_point_1 = [0.0, 0.0, 2.0]

joint = LJoint(axis_point_1, axis_point_2, radius_point_1)

cell_size = f.norm(radius_point_1) / 10

joint.chop_axial(start_size=cell_size * 5, end_size=cell_size)
joint.chop_radial(start_size=cell_size, end_size=cell_size / 10)
joint.chop_tangential(start_size=cell_size)

joint.set_outer_patch("walls")
joint.set_hole_patch(0, "inlet")
joint.set_hole_patch(1, "outlet")

mesh.add(joint)

mesh.write(os.path.join("..", "case", "system", "blockMeshDict"), debug_path="debug.vtk")
5 changes: 5 additions & 0 deletions src/classy_blocks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .base.transforms import Mirror, Rotation, Scaling, Translation
from .construct.assemblies.joints import LJoint, NJoint, TJoint
from .construct.curves.analytic import AnalyticCurve, CircleCurve, LineCurve
from .construct.curves.discrete import DiscreteCurve
from .construct.curves.interpolated import LinearInterpolatedCurve, SplineInterpolatedCurve
Expand Down Expand Up @@ -113,4 +114,8 @@
"MeshSmoother",
"SketchSmoother",
"ViewpointReorienter",
# Assemblies
"NJoint",
"TJoint",
"LJoint",
]
4 changes: 0 additions & 4 deletions src/classy_blocks/construct/curves/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ def center(self):
warnings.warn("Using an approximate default curve center (average)!", stacklevel=2)
return np.average(self.discretize(), axis=0)

@property
def parts(self):
return [self.array]


class FunctionCurveBase(PointCurveBase):
"""A base object for curves, driven by functions"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_construct/test_curves/test_discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_get_length(self, param_from, param_to):
def test_get_closest_param(self, point, index):
self.assertEqual(self.curve.get_closest_param(point), index)

def test_transform(self):
def test_translate(self):
"""A simple translation to test .parts property"""
curve = self.curve
curve.translate([0, 0, 1])
Expand Down
5 changes: 5 additions & 0 deletions tests/test_construct/test_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ def test_core(self):

self.assertEqual(len(sphere.core), 1)

def test_center(self):
sphere = EighthSphere([0, 0, 0], [1, 0, 0], [0, 0, 1])

np.testing.assert_equal(sphere.center, [0, 0, 0])


class FrustumTests(unittest.TestCase):
def test_non_perpendicular_axis_radius(self):
Expand Down

0 comments on commit 2cec911

Please sign in to comment.