8000 Bugfix mesh periodic by chemiskyy · Pull Request #27 · 3MAH/microgen · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bugfix mesh periodic #27

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

Merged
merged 19 commits into from
Dec 9, 2023
Merged

Bugfix mesh periodic #27

merged 19 commits into from
Dec 9, 2023

Conversation

chemiskyy
Copy link
Member
@chemiskyy chemiskyy commented Nov 23, 2023

Overview

Fixes bug #25

Details

Essentially removed the line : bounds_max[:, axis] -= 1 in mesh.py since bounds_min has been modified
Add test for an octet truss structure using two type of generation

Add the _is_periodic as a function in test_utils
This generate a test for octet truss considering two methods :

The fuse of Shapes in one cq.Shape
The cut of Phases to obtain an heterogeneous (i.e. one phase per cut cylinder)
Correct bug

 bounds_max[:, axis] -= 1 is redundant since bounds_min has been modified to test the same bounding boxes
minor fix : add fixtures for filenames
Copy link
Collaborator
@ylgrst ylgrst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR seems ok to me.

I do appreciate the added comments in mesh.py to help with understanding how meshPeriodic works

However I do believe that tests must be implemented for is_periodic as it seems to be an important function. I would first test it on a simple cube where I know the mesh to be periodic, then on another simple cube with an additional point on one face, and finally on another simple cube where one node is slightly shifted in regards to its corresponding node on the opposing face. I believe those test cases should cover all possibilities.

I understand the main goal of this PR was to fix bug #25 but I think meshPeriodic must be tested on a simpler box mesh prior to testing on a more complicated structure. By the way, why the two generation methods for the octet truss?

Finally, I'm not certain whether placing is_periodic in a test_utils kind of file is the most appropriate solution. Could it be a method in microgen's Mesh class?

microgen/mesh.py Outdated
for bounds_min, tag_min in _iter_bounding_boxes(minimum, maximum, eps):
# Translate the minmal bounds into the maximum value on axis surface
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo in "minimal"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

10000
Use numpy.typing syntax instead of hinting types in comments:
this replace the octetruss test by adding a simple box test
This adds a test on the is_periodic function
This reverts commit 3ac6d54.
Added a simple Box test
Allows to have a different center and cell size than the unit one
Added tests with non-unit RVE size
@chemiskyy
Copy link
Member Author

A commit has been added to correct the fact that the function was working for unit size cells only. This has been fixed and cells of different size and position have been added in the tests

Copy link
Collaborator
@rdesparbes rdesparbes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new tests look great! I suggested a few changes that are more related to style issues, and I noticed some inconsistencies in the formatting (there should be 2 spaces between the functions according to PEP8).
Maybe consider using black?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this new module is not named correctly or is in the wrong place.

What about moving the is_periodic function to the microgen.periodic module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good suggestion but since we are thinking about splitting micron somehow to handle either meshes or CAD geometry I think it is not recommended to place this into periodic at this time.
This module is temporary since it is scheduled to add a class that handle Box Meshes. The is_periodic function would naturally finds its place there

zmin = np.min(nodes_coords[:, 2])

# extract face nodes
left = np.where(np.abs(nodes_coords[:, 0] - xmin) < tol)[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly a matter of preference, but the pattern np.where(...)[0] can be replaced by np.flatnonzero(...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting thought but I do now how to handle the tolerance with np.flatnonzero(...)

@chemiskyy
Copy link
Member Author
chemiskyy commented Dec 8, 2023

Since the comments have been adresses I think this PR is ready to be merged
@ylgrst @rdesparbes please thumb up if you agree
Yves

@chemiskyy chemiskyy merged commit de9e62a into main Dec 9, 2023
@chemiskyy chemiskyy deleted the bugfix_MeshPeriodic branch December 10, 2023 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0