-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Facets From Point Cloud, and Volumes From Facets With Cubit #177
Draft
Edgar-21
wants to merge
4
commits into
svalinn:main
Choose a base branch
from
Edgar-21:cubit_faceted_surfaces
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
181b6e9
building faceted surfaces in cubit working
Edgar-21 f49277f
dagmc model export working
Edgar-21 dafae7d
re-organize to benefit from oo, integrate with parastell.py
Edgar-21 48c0254
fix double magnet import, import cub5 to avoid conflicts
Edgar-21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -346,6 +346,82 @@ def export_cad_to_dagmc(self, dagmc_filename="dagmc", export_dir=""): | |
|
||
model.export_dagmc_h5m_file(filename=str(export_path)) | ||
|
||
def build_volumes_cubit(self): | ||
cubit_io.init_cubit() | ||
for surface_name, surface in self.Surfaces.items(): | ||
print(surface_name) | ||
vertex_ids = [] | ||
for loop in surface.get_loci(): | ||
loop_vert_ids = [] | ||
for point in loop: | ||
cubit.cmd( | ||
f"create vertex {point[0]} {point[1]} {point[2]}" | ||
) | ||
vertex_id = cubit.get_last_id("vertex") | ||
loop_vert_ids.append(vertex_id) | ||
vertex_ids.append(loop_vert_ids) | ||
surface_ids = [] | ||
vertex_ids = np.array(vertex_ids) | ||
for loop_index, loop in enumerate(vertex_ids[0:-1, :]): | ||
for point_index, point in enumerate(loop[0:-1]): | ||
ul = vertex_ids[loop_index, point_index] | ||
ll = vertex_ids[loop_index + 1, point_index] | ||
ur = vertex_ids[loop_index, point_index + 1] | ||
lr = vertex_ids[loop_index + 1, point_index + 1] | ||
cubit.cmd(f"create surface vertex {ul} {ll} {ur}") | ||
surface_ids.append(cubit.get_last_id("surface")) | ||
cubit.cmd(f"create surface vertex {lr} {ll} {ur}") | ||
surface_ids.append(cubit.get_last_id("surface")) | ||
start_cap_ids = " ".join( | ||
[str(vertex) for vertex in vertex_ids[0][0:-1]] | ||
) | ||
print(start_cap_ids) | ||
end_cap_ids = " ".join( | ||
[str(vertex) for vertex in vertex_ids[-1][0:-1]] | ||
) | ||
surface_id_str = " ".join( | ||
[str(surf_id) for surf_id in surface_ids] | ||
) | ||
surface_ids = [] | ||
# for whatever reason, uniting this surface first makes the volume | ||
# creation go much faster (~10x) | ||
cubit.cmd(f"unite surface {surface_id_str}") | ||
surface_ids.append(cubit.get_last_id("surface")) | ||
cubit.cmd(f"create surface vertex {start_cap_ids}") | ||
surface_ids.append(cubit.get_last_id("surface")) | ||
cubit.cmd(f"create surface vertex {end_cap_ids}") | ||
surface_ids.append(cubit.get_last_id("surface")) | ||
surface_id_str = " ".join( | ||
[str(surf_id) for surf_id in surface_ids] | ||
) | ||
cubit.cmd(f"create volume surface {surface_id_str}") | ||
cubit.cmd("compress") | ||
volume_id = cubit.get_last_id("volume") | ||
self.radial_build.radial_build[surface_name]["vol_id"] = volume_id | ||
cubit.cmd('save cub5 "all_surfaces_faceted.cub5" overwrite') | ||
# remove overlap | ||
print("removing overlap") | ||
layers = list(self.radial_build.radial_build.values()) | ||
for layer, next_layer in zip( | ||
reversed(layers[0:-1]), reversed(layers[1:]) | ||
): | ||
cubit.cmd( | ||
"remove overlap volume " | ||
f"{layer['vol_id']} {next_layer['vol_id']} modify larger" | ||
) | ||
cubit.cmd('save cub5 "overlap_removed.cub5" overwrite') | ||
# merge layers | ||
for layer, next_layer in zip( | ||
reversed(layers[0:-1]), reversed(layers[1:]) | ||
): | ||
print(layer) | ||
cubit.cmd( | ||
f"imprint volume {layer['vol_id']} {next_layer['vol_id']}" | ||
) | ||
cubit.cmd(f"merge volume {layer['vol_id']} {next_layer['vol_id']}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably make this the way we imprint and merge by default in |
||
|
||
cubit.cmd('save cub5 "merged.cub5" overwrite') | ||
|
||
|
||
class Surface(object): | ||
"""An object representing a surface formed by lofting across a set of | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What overlap is occurring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
each volume is made without the through hole, similar to how they are made in CADquery now. This subtracts the inner component from the outer component, working outside in.