Skip to content

Commit

Permalink
removed unused file
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Apr 13, 2024
2 parents cf6df3b + 0fe8357 commit d9dadd1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 67 deletions.
11 changes: 2 additions & 9 deletions examples/surface_mesh/cadquery_compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,12 @@
cq_shape_1 = r.extrude(-1)

s2 = cq.Workplane("XY")
r2 = (
s2.lineTo(3.0, 0)
.lineTo(3.0, 1.0)
.spline(spline_points, includeCurrent=True)
.close()
)
r2 = s2.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close()
cq_shape_2 = r2.extrude(1)


compound_of_shapes = cq.Compound.makeCompound([cq_shape_1.val(), cq_shape_2.val()])

my_model = CadToDagmc()
my_model.add_cadquery_object(
cadquery_object=compound_of_shapes, material_tags=["mat1", "mat2"]
)
my_model.add_cadquery_object(cadquery_object=compound_of_shapes, material_tags=["mat1", "mat2"])
my_model.export_dagmc_h5m_file(max_mesh_size=0.2, min_mesh_size=0.1)
4 changes: 1 addition & 3 deletions examples/surface_mesh/multiple_cadquery_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@

my_model = CadToDagmc()
my_model.add_cadquery_object(cadquery_object=box, material_tags=["mat1"])
my_model.add_cadquery_object(
cadquery_object=box_with_round_corners, material_tags=["mat2"]
)
my_model.add_cadquery_object(cadquery_object=box_with_round_corners, material_tags=["mat2"])
my_model.export_dagmc_h5m_file()
7 changes: 1 addition & 6 deletions examples/surface_mesh/single_stp_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
(0.5, 1.0),
(0, 1.0),
]
r = (
result.lineTo(3.0, 0)
.lineTo(3.0, 1.0)
.spline(spline_points, includeCurrent=True)
.close()
)
r = result.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close()
result = r.extrude(1.5)
assembly = cq.Assembly()
assembly.add(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,4 @@ def gear(t, r1=4, r2=1):
my_model.add_cadquery_object(result)
my_model.add_cadquery_object(result2)

my_model.export_unstructured_mesh_file(
filename="umesh.h5m", max_mesh_size=1, min_mesh_size=0.1
)
my_model.export_unstructured_mesh_file(filename="umesh.h5m", max_mesh_size=1, min_mesh_size=0.1)
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,5 @@
centroids = umesh_from_sp.centroids
mesh_vols = umesh_from_sp.volumes

flux_mean = tally_result.get_values(scores=["flux"], value="mean").reshape(
umesh_from_sp.dimension
)
flux_mean = tally_result.get_values(scores=["flux"], value="mean").reshape(umesh_from_sp.dimension)
umesh_from_sp.write_data_to_vtk(filename="tally.vtk", datasets={"mean": flux_mean})
29 changes: 7 additions & 22 deletions src/cad_to_dagmc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ def _vertices_to_h5m(
typing.Iterable[typing.Tuple[float, float, float]],
typing.Iterable["cadquery.occ_impl.geom.Vector"],
],
triangles_by_solid_by_face: typing.Iterable[
typing.Iterable[typing.Tuple[int, int, int]]
],
triangles_by_solid_by_face: typing.Iterable[typing.Iterable[typing.Tuple[int, int, int]]],
material_tags: typing.Iterable[str],
h5m_filename="dagmc.h5m",
implicit_complement_material_tag=None,
Expand All @@ -88,11 +86,7 @@ def _vertices_to_h5m(
raise ValueError(msg)

# limited attribute checking to see if user passed in a list of CadQuery vectors
if (
hasattr(vertices[0], "x")
and hasattr(vertices[0], "y")
and hasattr(vertices[0], "z")
):
if hasattr(vertices[0], "x") and hasattr(vertices[0], "y") and hasattr(vertices[0], "z"):
vertices_floats = []
for vert in vertices:
vertices_floats.append((vert.x, vert.y, vert.z))
Expand Down Expand Up @@ -142,9 +136,7 @@ def _vertices_to_h5m(
if len(face_ids_with_solid_ids[face_id]) == 2:
other_solid_id = face_ids_with_solid_ids[face_id][1]
other_volume_set = volume_sets_by_solid_id[other_solid_id]
sense_data = np.array(
[other_volume_set, volume_set], dtype="uint64"
)
sense_data = np.array([other_volume_set, volume_set], dtype="uint64")
else:
sense_data = np.array([volume_set, 0], dtype="uint64")

Expand Down Expand Up @@ -283,8 +275,7 @@ def mesh_to_vertices_and_triangles(
for nodeTag in nodeTags:
shifted_node_tags.append(nodeTag - 1)
grouped_node_tags = [
shifted_node_tags[i : i + n]
for i in range(0, len(shifted_node_tags), n)
shifted_node_tags[i : i + n] for i in range(0, len(shifted_node_tags), n)
]
nodes_in_each_surface[surface] = grouped_node_tags
triangles_by_solid_by_face[vol_id] = nodes_in_each_surface
Expand Down Expand Up @@ -426,9 +417,7 @@ def add_stp_file(
scaled_part = part
else:
scaled_part = part.scale(scale_factor)
self.add_cadquery_object(
cadquery_object=scaled_part, material_tags=material_tags
)
self.add_cadquery_object(cadquery_object=scaled_part, material_tags=material_tags)

def add_cadquery_object(
self,
Expand All @@ -452,9 +441,7 @@ def add_cadquery_object(
if isinstance(cadquery_object, cq.assembly.Assembly):
cadquery_object = cadquery_object.toCompound()

if isinstance(
cadquery_object, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)
):
if isinstance(cadquery_object, (cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid)):
iterable_solids = cadquery_object.Solids()
else:
iterable_solids = cadquery_object.val().Solids()
Expand Down Expand Up @@ -565,9 +552,7 @@ def export_dagmc_h5m_file(
for part in self.parts:
assembly.add(part)

imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(
assembly
)
imprinted_assembly, imprinted_solids_with_org_id = cq.occ_impl.assembly.imprint(assembly)

original_ids = _get_ids_from_assembly(assembly)
scrambled_ids = _get_ids_from_imprinted_assembly(imprinted_solids_with_org_id)
Expand Down
26 changes: 5 additions & 21 deletions tests/test_file_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,14 @@ def test_cq_compound():
]

s = cq.Workplane("XY")
r = (
s.lineTo(3.0, 0)
.lineTo(3.0, 1.0)
.spline(spline_points, includeCurrent=True)
.close()
)
r = s.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close()
cq_shape_1 = r.extrude(-1)

s2 = cq.Workplane("XY")
r2 = (
s2.lineTo(3.0, 0)
.lineTo(3.0, 1.0)
.spline(spline_points, includeCurrent=True)
.close()
)
r2 = s2.lineTo(3.0, 0).lineTo(3.0, 1.0).spline(spline_points, includeCurrent=True).close()
cq_shape_2 = r2.extrude(1)

compound_of_workplanes = cq.Compound.makeCompound(
[cq_shape_1.val(), cq_shape_2.val()]
)
compound_of_workplanes = cq.Compound.makeCompound([cq_shape_1.val(), cq_shape_2.val()])

my_model = CadToDagmc()
my_model.add_cadquery_object(
Expand Down Expand Up @@ -216,9 +204,7 @@ def test_gmsh_mesh_with_multi_volume_not_touching():
gmsh_mesh_files = [
"tests/two_disconnected_cubes.msh",
]
for stp_file, mat_tags, gmsh_mesh_file in zip(
stp_files, material_tags, gmsh_mesh_files
):
for stp_file, mat_tags, gmsh_mesh_file in zip(stp_files, material_tags, gmsh_mesh_files):
my_model = CadToDagmc()
my_model.add_stp_file(filename=stp_file, material_tags=mat_tags)

Expand All @@ -238,9 +224,7 @@ def test_gmsh_mesh_with_multi_volume_touching():
"tests/multi_volume_cylinders.msh",
"tests/two_connected_cubes.msh",
]
for stp_file, mat_tags, gmsh_mesh_file in zip(
stp_files, material_tags, gmsh_mesh_files
):
for stp_file, mat_tags, gmsh_mesh_file in zip(stp_files, material_tags, gmsh_mesh_files):
my_model = CadToDagmc()
my_model.add_stp_file(stp_file, material_tags=mat_tags)

Expand Down

0 comments on commit d9dadd1

Please sign in to comment.