-
Notifications
You must be signed in to change notification settings - Fork 17
Separating Femlearn into individual modules. Work in progress #789
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
base: 713-feature-request-add-femlearn-to-blueprints
Are you sure you want to change the base?
Separating Femlearn into individual modules. Work in progress #789
Conversation
# # femlearn.py # # Authors: Victor Lueddemann and Emile Breyer # # ----------------------------------- Imported as is with permission by the authors.
|
Thank you so much for contributing to Blueprints! Now that you've created your pull request, please don't go away; take a look at the bottom of this page for the automated checks that should already be running. If they pass, great! If not, please click on 'Details' and see if you can fix the problem they've identified. A maintainer should be along shortly to review your pull request and help get it added! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the femlearn 2D finite element method (FEM) library as individual modules to the Blueprints package. The change represents the first task in integrating femlearn into Blueprints by separating it into distinct modules for geometry, mesh handling, boundary conditions, loads, and solving.
Key changes:
- Added new femlearn package with modular structure for 2D FEM analysis
- Added new dependencies (pygmsh, pynastran, vtk) and private package indices for specialized libraries
- Implemented core FEM functionality including solver, solution handling, and visualization
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added new dependencies and private package indices for FEM libraries |
| blueprints/utils/femlearn/init.py | Package initialization with project description |
| blueprints/utils/femlearn/_base_classes.py | Base classes for points, loads, and displacement functionality |
| blueprints/utils/femlearn/geometry.py | Geometry handling for points, lines, and polygon creation |
| blueprints/utils/femlearn/mesh.py | Mesh management including nodes, elements, and integration points |
| blueprints/utils/femlearn/boundary_conditions.py | Boundary condition definitions for nodes, points, and lines |
| blueprints/utils/femlearn/loads.py | Load application classes for different geometry types |
| blueprints/utils/femlearn/solver_data.py | Core FEM solver implementation with matrix assembly and solving |
| blueprints/utils/femlearn/solution.py | Solution data container and result processing |
| blueprints/utils/femlearn/model_2d.py | Main 2D model class integrating all components |
Comments suppressed due to low confidence (1)
blueprints/utils/femlearn/loads.py:1
- Variable name has a typo. Should be 'quadratic' instead of 'quadtratic'.
import numpy as np
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| stressY[curIntPointIndex] = stressVector[0] | ||
| stressXY[curIntPointIndex] = stressVector[0] |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect stress component assignment. stressY should use stressVector[1] and stressXY should use stressVector[2], not stressVector[0] for both.
| stressY[curIntPointIndex] = stressVector[0] | |
| stressXY[curIntPointIndex] = stressVector[0] | |
| stressY[curIntPointIndex] = stressVector[1] | |
| stressXY[curIntPointIndex] = stressVector[2] |
| import pygmsh # externe meshing bibliothek | ||
|
|
||
| vertices = self.geometry.points.coordinates | ||
| with blueprints.utils.femlearn.geometry.Geometry() as pygeom: |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect module reference. Should be 'pygmsh.geo.Geometry()' instead of 'blueprints.utils.femlearn.geometry.Geometry()' based on the import statement on line 122.
| with blueprints.utils.femlearn.geometry.Geometry() as pygeom: | |
| with pygmsh.geo.Geometry() as pygeom: |
| plt.show() | ||
|
|
||
| # Meshing | ||
| model.generateTRIAngleMesh(size=2, type=6, integrationOrder=3, thickness=1, poissonRation=0.3, youngsModulus=100, planarAssumption="plane stress") |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method name has inconsistent capitalization. Should be 'generateTriangleMesh' to match the method definition on line 114.
| model.generateTRIAngleMesh(size=2, type=6, integrationOrder=3, thickness=1, poissonRation=0.3, youngsModulus=100, planarAssumption="plane stress") | |
| model.generateTriangleMesh(size=2, type=6, integrationOrder=3, thickness=1, poissonRation=0.3, youngsModulus=100, planarAssumption="plane stress") |
| def generateQuadMesh( | ||
| self, nx=1, ny=1, type=4, specified_nodes=None, integrationOrder=4, thickness=[], poissonRation=[], youngsModulus=[], planarAssumption=[] |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter name has a typo. Should be 'poissonRatio' instead of 'poissonRation'.
|
|
||
| self.mesh.elements.integrationOrder = np.array([integrationOrder for _ in range(self.mesh.numberOfElements)]) | ||
|
|
||
| def generateTriangleMesh(self, size, type=3, integrationOrder=1, thickness=[], poissonRation=[], youngsModulus=[], planarAssumption=[]): |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter name has a typo. Should be 'poissonRatio' instead of 'poissonRation'.
| self.mesh.elements.integrationOrder = np.array([integrationOrder for _ in range(self.mesh.numberOfElements)]) | ||
| pass | ||
|
|
||
| def importNasFile(self, filename, integrationOrder=1, thickness=[], poissonRation=[], youngsModulus=[], planarAssumption=[]): |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter name has a typo. Should be 'poissonRatio' instead of 'poissonRation'.
| self.stiffnessMatrix[nodeIndex * 2 + 1, nodeIndex * 2 + 1] = 1 | ||
| self.loadVector[nodeIndex * 2 + 1] = yDisp[dispIndex] | ||
|
|
||
| def _reduceStiffnesMatrixAndLoadVector(self): |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method name has a typo. Should be '_reduceStiffnessMatrixAndLoadVector' (missing 's' in 'Stiffness').
| def _reduceStiffnesMatrixAndLoadVector(self): | |
| def _reduceStiffnessMatrixAndLoadVector(self): |
|
|
||
| def _reduceStiffnesMatrixAndLoadVector(self): | ||
| """ | ||
| Reduces sitffness matrix and load vector based on fixated nodes |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in docstring. Should be 'stiffness' instead of 'sitffness'.
| Reduces sitffness matrix and load vector based on fixated nodes | |
| Reduces stiffness matrix and load vector based on fixated nodes |
|
@VictorLued we will get there step by step :-) |
Description
First task out of six. Where Femlearn will be integrated into Blueprints :-)
Fixes #748
Type of change
Please delete options that are not relevant.
Checklist: