Open
Conversation
Add support for storing dic_closest_points_on_boundaries in __init__ and use it during initialize when not provided. Replace tuple-call dict access with standard dict indexing when constructing face/edge/corner members. Introduce helper methods _distance_weights (robust normalized distance weighting that handles exact matches) and _mpc_from_2d (convert 2D arrays to MPC list-of-arrays), and use them throughout to replace repeated normalization and MPC(...) calls. Convert D_xyz to a NumPy array and fix dtype usage for np.full_like. Improve error handling in initialize with a clear ValueError when non-periodic data is missing and pass d_rve from the dictionary. These changes simplify MPC construction, fix indexing/normalization bugs, and make weight computation more robust.
Forward the dic_closest_points_on_boundaries keyword from get_tangent_stiffness's **kargs** into the PeriodicBC constructor. This allows callers to supply a mapping of closest points on boundaries for periodic boundary conditions when computing the tangent stiffness.
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 refactors and improves the handling of periodic boundary conditions in
fedoo/constraint/periodic_bc.py, focusing on the construction of multi-point constraints (MPCs) based on node distances. The changes enhance code clarity, introduce utility methods for MPC creation and weight calculation, and fix issues with variable assignment and array handling.Refactoring and Utility Improvements:
_mpc_from_2dto streamline the creation ofMPCobjects from 2D arrays, and_distance_weightsto robustly compute normalized distance weights, including special handling for exact matches and edge cases._distance_weightsmethod throughout the MPC construction process. [1] [2] [3] [4] [5] [6] [7] [8]list_variablesby using[list_disp[i] for _ in range(...)]instead of[list_disp[i] for i in range(...)], avoiding variable shadowing and improving clarity. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Bug Fixes and API Consistency:
dic_closest_points_on_boundariesfrom function-call style to dictionary-style (e.g.,["face_Xm"]instead of("face_Xm")), ensuring correct data retrieval and preventing runtime errors.dic_closest_points_on_boundariesas an optional argument, improving flexibility and future extensibility. [1] [2]Other Notable Changes:
D_xyzfrom a list to a NumPy array for consistency and to enable efficient array operations.These changes collectively improve code maintainability, reliability, and performance in the handling of periodic boundary conditions.