Refactor/rve#140
Open
chemiskyy wants to merge 3 commits into
Open
Conversation
Make Shape.generate_surface_mesh polymorphic for Box, Sphere and Spinodoid by accepting optional bounds/resolution and falling back to the SDF/marching-cubes path when callers request explicit sampling. Add BoundsType imports and update docstrings to explain the behavior. Remove the legacy rotate_pv_euler function and its export from operations/__init__ (cleanup of Euler helper). Tidy Rve by removing unused is_matrix/matrix_number defaults. Expose new TPMS-related classes (GradedInfill, Sweep) in shape exports and update __all__ accordingly. Add a lint test (tests/test_no_top_level_ocp_imports.py) to prevent top-level OCP imports outside the CAD boundary.
Make Rve a frozen dataclass with validated inputs and explicit pbc flags. Introduce helper validators, cached min_point/max_point and a cached box property (lazy CAD box creation). Add Rve.grid(...) to produce a pyvista.StructuredGrid with flexible resolution handling. Improve __repr__ and update from_min_max to accept pbc. Expand tests to cover pbc behavior, immutability, min/max consistency, grid generation, invalid inputs, and repr content.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces several improvements and refactorings to the
microgencodebase, focusing on enhancing theRveclass, improving surface mesh generation for shapes, and maintaining clean import boundaries for optional dependencies. The most significant changes include makingRveimmutable and more robust, updating mesh generation methods for greater flexibility, and adding a lint-style test to enforce import constraints.Rve class improvements:
Rveto be a frozen dataclass, making it immutable and thread-safe. Added validation helpers for its parameters, new properties formin_pointandmax_point, and a newgrid()method for generating structured grids aligned with the RVE. The constructor now supports periodic boundary condition flags, and a more robustfrom_min_maxconstructor was added. ([[1]](https://github.com/3MAH/microgen/pull/140/files#diff-d871fe5a64aa369935f17dce4cd4c4f7213c9c965ce1841732e5d33f5e696e01L3-R14),[[2]](https://github.com/3MAH/microgen/pull/140/files#diff-d871fe5a64aa369935f17dce4cd4c4f7213c9c965ce1841732e5d33f5e696e01L19-R162))center,dim, andpbcparameters inRve, with clear error messages and support for various input types. ([microgen/rve.pyL19-R162](https://github.com/3MAH/microgen/pull/140/files#diff-d871fe5a64aa369935f17dce4cd4c4f7213c9c965ce1841732e5d33f5e696e01L19-R162))Surface mesh generation flexibility:
generate_surface_meshmethods inBox,Sphere, andSpinodoidto acceptboundsandresolutionparameters. When these are provided, the methods fall back to the base implementation, allowing polymorphic callers to request specific sampling, otherwise using the native PyVista mesh. ([[1]](https://github.com/3MAH/microgen/pull/140/files#diff-c227cea663f04fbc41b04b36b599dab1ec943df83f886a2a33b2cb0d4e68cc84R109-R126),[[2]](https://github.com/3MAH/microgen/pull/140/files#diff-a0646891e8c15a45af285eb3b34d22c1471f0e2d500596d51d9bad049d38a9d3R82-R100),[[3]](https://github.com/3MAH/microgen/pull/140/files#diff-d4d99a42f3f33d721a232441455fe4b2781c7eadf3b3928b75ebf3343ea75556R219-R235))API and import/export maintenance:
GradedInfill,Sweep) to the public API inmicrogen/__init__.pyandmicrogen/shape/__init__.py, ensuring they are accessible as top-level imports. ([[1]](https://github.com/3MAH/microgen/pull/140/files#diff-9eae507ca7aca3774110b95b4c1d94be6defba96ce1b3864edb9f133d7ab8846R39),[[2]](https://github.com/3MAH/microgen/pull/140/files#diff-9eae507ca7aca3774110b95b4c1d94be6defba96ce1b3864edb9f133d7ab8846R51),[[3]](https://github.com/3MAH/microgen/pull/140/files#diff-9eae507ca7aca3774110b95b4c1d94be6defba96ce1b3864edb9f133d7ab8846R80),[[4]](https://github.com/3MAH/microgen/pull/140/files#diff-9eae507ca7aca3774110b95b4c1d94be6defba96ce1b3864edb9f133d7ab8846R96),[[5]](https://github.com/3MAH/microgen/pull/140/files#diff-024071544e6e765768b16b31822ce0d8281e1f283764ef04d85e614b23c1672fL51-R51),[[6]](https://github.com/3MAH/microgen/pull/140/files#diff-024071544e6e765768b16b31822ce0d8281e1f283764ef04d85e614b23c1672fR165),[[7]](https://github.com/3MAH/microgen/pull/140/files#diff-024071544e6e765768b16b31822ce0d8281e1f283764ef04d85e614b23c1672fR177))rotate_pv_eulerfunction from both the code and the public API. ([[1]](https://github.com/3MAH/microgen/pull/140/files#diff-9eae507ca7aca3774110b95b4c1d94be6defba96ce1b3864edb9f133d7ab8846L20),[[2]](https://github.com/3MAH/microgen/pull/140/files#diff-9eae507ca7aca3774110b95b4c1d94be6defba96ce1b3864edb9f133d7ab8846L120),[[3]](https://github.com/3MAH/microgen/pull/140/files#diff-663e8d6f8a6794e0262c63d472ccfd5a707f973570dc7304e33508cf97dad97cL129-L161))Dependency management and testing:
tests/test_no_top_level_ocp_imports.py) to ensure that top-level imports of the optionalOCPdependency only occur within the CAD boundary, preventing accidental import errors for users not installing CAD extras. ([tests/test_no_top_level_ocp_imports.pyR1-R88](https://github.com/3MAH/microgen/pull/140/files#diff-36aaedd6993eff5e45adb5c160afaec6aafa53661ada94663c1e7c29f63da346R1-R88))Type hints and code clarity:
BoundsTypeand related imports, enhancing code clarity and type checking. ([[1]](https://github.com/3MAH/microgen/pull/140/files#diff-c227cea663f04fbc41b04b36b599dab1ec943df83f886a2a33b2cb0d4e68cc84R24),[[2]](https://github.com/3MAH/microgen/pull/140/files#diff-a0646891e8c15a45af285eb3b34d22c1471f0e2d500596d51d9bad049d38a9d3R21),[[3]](https://github.com/3MAH/microgen/pull/140/files#diff-d4d99a42f3f33d721a232441455fe4b2781c7eadf3b3928b75ebf3343ea75556R37))These changes collectively improve the robustness, flexibility, and maintainability of the
microgencodebase.