feat(beams3d): add structural 3d beam problem#257
Conversation
| for dx in range(-rceil, rceil + 1): | ||
| for dy in range(-rceil, rceil + 1): | ||
| for dz in range(-rceil, rceil + 1): | ||
| dist = (dx * dx + dy * dy + dz * dz) ** 0.5 | ||
| weight = rmin - dist | ||
| if weight > 0.0: | ||
| offsets.append((dx, dy, dz, weight)) |
There was a problem hiding this comment.
how about numpy.meshgrid here, together with numpy.linalg.norm?
| """Matrix-free cone-filter data.""" | ||
|
|
||
| offsets: tuple[tuple[int, int, int, float], ...] | ||
| hs: np.ndarray |
There was a problem hiding this comment.
| hs: np.ndarray | |
| hs: npt.NDArray[np.float64] |
where npt = numpy.typing
| def _apply_filter( | ||
| values: np.ndarray, | ||
| sensitivity_filter: SensitivityFilter3D, | ||
| ) -> np.ndarray: |
| fixed_elements = np.transpose(fixed_elements, (2, 1, 0)) | ||
| force_elements = np.transpose(force_elements, (2, 1, 0)) | ||
|
|
||
| import napari # noqa: PLC0415 |
There was a problem hiding this comment.
Why dont you want that to be top level imported?
Is napari an optional dependency?
There was a problem hiding this comment.
Also, related to my comment on #260 do we even need napari? Could we visualize/render this with existing imports?
| return x | ||
|
|
||
|
|
||
| def solve_with_spsolve(a: csr_matrix, b: NDArray[np.float64]) -> NDArray[np.float64]: |
There was a problem hiding this comment.
why do we need a wrapper?
| asymax = 0.2 | ||
| asymin = 0.01 | ||
|
|
||
| xmma, _, _, _, _, _, _, _, _, low, up = external_mmasub( |
There was a problem hiding this comment.
what also should work:
xmma, *_, low, up = external_mmasub(However, I am not sure if we want to be notified by an error if external_mmasub changes the number of arguments (in this case we should keep it like it is).
|
|
||
| def __init__(self, seed: int = 0, config: dict[str, Any] | None = None) -> None: | ||
| """Initialize the Beams3D problem, sizing default masks and design space to the grid.""" | ||
| config = {key: (np.asarray(value) if isinstance(value, list) else value) for key, value in (config or {}).items()} |
There was a problem hiding this comment.
Another thing: default value handling is now duplicated here from (Config also provides default values).
You could use Config here:
raw_config: dict[str, Any] = {
key: (np.asarray(value) if isinstance(value, list) else value) for key, value in (config or {}).items()
}
self.config = self.Config(**raw_config)And then optionally adapt the default values of Config to your needs.
|
@g-braeunlich I just created a new branch where I addressed all your comments except the last one regarding The summary for the remaining comments in order:
|
|
I would definitely address the config handling, as this would be technical dept |
|
And why did you actually create an extra branch? |
Description
Add the structural-only Beams3D v0 problem, aligned with Beams2D's public API
and Thermoelastic3D's 3D FEM structure.
This PR introduces:
engibench.problems.beams3d.Beams3Dc, matching the dataset compliance columnvolfrac,rmin,forcedist_x,and
forcedist_yThe implementation keeps explicit FEM masks and solver parameters in
Config,while the public
Conditionsmatch the dataset schema. The helper_force_elements_z_from_forcedist()reconstructs the vertical top-face loadmask from compact dataset coordinates, and
_boundary_conditions()centralizesper-call config merging for simulation and optimization.
Type of change
Screenshots
Beams3D render output:
Checklist:
pre-commitchecks withpre-commit run --all-filesruff check .andruff formatmypy .Reviewer Checklist: