Add cuttable solid layer support#378
Conversation
…single side of plasma
Removed the _copy_metadata method and split_solids method from the Assembly class. I have found a better solution and will add it in next PR.
Removed the test for splitting solids.
|
Hi @approx-infinity, thanks for putting this together — the PR description and screenshots are really clear, and I can see the use case (different materials inboard vs. outboard). While I look into the best way to add this upstream, I wanted to mention that splitting a matched layer across the plasma boundary can also be done as a post-process on the returned Something like: import cadquery as cq
import paramak
from paramak.utils import sum_up_to_plasma
radial_build = [
(paramak.LayerType.GAP, 10),
(paramak.LayerType.SOLID, 30),
# ...
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(paramak.LayerType.SOLID, 20),
(paramak.LayerType.SOLID, 120), # the layer you want split
(paramak.LayerType.SOLID, 10),
]
model = paramak.tokamak_from_plasma(radial_build=radial_build, ...)
# Cylinder at the plasma's inboard edge — natural inboard/outboard boundary
inboard_edge_r = sum_up_to_plasma(radial_build)
boundary = cq.Workplane("XY").circle(inboard_edge_r).extrude(5000, both=True)
target = "layer_7" # whichever .names() shows
layer = next(p[0] for p in model if p[1].split('/')[-1] == target)
inboard = layer.intersect(boundary)
outboard = layer.cut(boundary)
model = model.remove(target)
model.add(inboard, name=f"{target}_inboard")
model.add(outboard, name=f"{target}_outboard")Would something like this cover your use case in the meantime? Happy to keep discussing the right shape of the upstream API. |
|
Thanks for the clarification. Yes, doing it as a post-process on the returned cq.Assembly should work for my current use case as well, and it actually gives more flexibility as you mentioned. I will not continue modifying the current PR, since the post-process already covers the use case. |
|
ok super i shall close this pr and make an example of this post processing for the docs. I will just keep it open for now till i have that example ready |
this outputs: I also tried So, here you can see that the same problem like #325, #327, #377 occurs. I applied split_solids() method from #379 to get separate solids with names but it shows a error: So, if we cut solids at the post-processing step then getting the parts name is again confusing. Should I apply this? |
|
Ok now i got it! outputs: So, we need to use Assembly from paramak. |
If i follow this work flow, it gives a error: So, I need to convert the list back into a CadQuery compound before passing it to CadToDagmc. And now this works as expected, Now the main concern is, we need do lots of conversions in-between. Though it didn't take much time(3-4 minutes) on my PC to start generating mesh. |


Summary
This PR introduces several improvements to the plasma-layer handling:
LayerType.SOLID(cut=True)support to split layers across the plasma boundary with stable naming (layer_N.1, layer_N.2)Motivation
Most of the time the Inner Board and Outer Board layers of a tokamak have different material compositions. Till now we need to create a continuous layer which can contain a single material composition. So, this PR improves SOLID layer handling by enabling deterministic splitting of layers while validating invalid configurations early.
1. Add
LayerType.SOLID(cut=True)supportoutput:
['layer_1', 'layer_2', 'layer_3', 'layer_4.1', 'layer_4.2', 'plasma']FreeCAD

New behavior
SOLID layers can now be split across the plasma boundary.
Example naming:
Validation behavior
Splitting only occurs when geometry exists on both sides of the plasma.
LayerType.SOLID(cut=True)can be called once or twice(both side of plasma) but result will be same.