Skip to content

Conversation

@egarciamendez
Copy link
Member

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes

#
# femlearn.py
#
# Authors: Victor Lueddemann and Emile Breyer
#
# -----------------------------------

Imported as is with permission by the authors.
Copilot AI review requested due to automatic review settings October 4, 2025 21:03
@egarciamendez egarciamendez linked an issue Oct 4, 2025 that may be closed by this pull request
2 tasks
@github-actions
Copy link

github-actions bot commented Oct 4, 2025

Thank you so much for contributing to Blueprints!
Your contributions help thousands of engineers work more efficiently and accurately.

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!

@egarciamendez egarciamendez changed the base branch from main to 713-feature-request-add-femlearn-to-blueprints October 4, 2025 21:03
Copy link
Contributor

Copilot AI left a 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.

Comment on lines +798 to +799
stressY[curIntPointIndex] = stressVector[0]
stressXY[curIntPointIndex] = stressVector[0]
Copy link

Copilot AI Oct 4, 2025

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.

Suggested change
stressY[curIntPointIndex] = stressVector[0]
stressXY[curIntPointIndex] = stressVector[0]
stressY[curIntPointIndex] = stressVector[1]
stressXY[curIntPointIndex] = stressVector[2]

Copilot uses AI. Check for mistakes.
import pygmsh # externe meshing bibliothek

vertices = self.geometry.points.coordinates
with blueprints.utils.femlearn.geometry.Geometry() as pygeom:
Copy link

Copilot AI Oct 4, 2025

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.

Suggested change
with blueprints.utils.femlearn.geometry.Geometry() as pygeom:
with pygmsh.geo.Geometry() as pygeom:

Copilot uses AI. Check for mistakes.
plt.show()

# Meshing
model.generateTRIAngleMesh(size=2, type=6, integrationOrder=3, thickness=1, poissonRation=0.3, youngsModulus=100, planarAssumption="plane stress")
Copy link

Copilot AI Oct 4, 2025

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.

Suggested change
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")

Copilot uses AI. Check for mistakes.
Comment on lines 65 to 66
def generateQuadMesh(
self, nx=1, ny=1, type=4, specified_nodes=None, integrationOrder=4, thickness=[], poissonRation=[], youngsModulus=[], planarAssumption=[]
Copy link

Copilot AI Oct 4, 2025

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'.

Copilot uses AI. Check for mistakes.

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=[]):
Copy link

Copilot AI Oct 4, 2025

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'.

Copilot uses AI. Check for mistakes.
self.mesh.elements.integrationOrder = np.array([integrationOrder for _ in range(self.mesh.numberOfElements)])
pass

def importNasFile(self, filename, integrationOrder=1, thickness=[], poissonRation=[], youngsModulus=[], planarAssumption=[]):
Copy link

Copilot AI Oct 4, 2025

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'.

Copilot uses AI. Check for mistakes.
self.stiffnessMatrix[nodeIndex * 2 + 1, nodeIndex * 2 + 1] = 1
self.loadVector[nodeIndex * 2 + 1] = yDisp[dispIndex]

def _reduceStiffnesMatrixAndLoadVector(self):
Copy link

Copilot AI Oct 4, 2025

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').

Suggested change
def _reduceStiffnesMatrixAndLoadVector(self):
def _reduceStiffnessMatrixAndLoadVector(self):

Copilot uses AI. Check for mistakes.

def _reduceStiffnesMatrixAndLoadVector(self):
"""
Reduces sitffness matrix and load vector based on fixated nodes
Copy link

Copilot AI Oct 4, 2025

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'.

Suggested change
Reduces sitffness matrix and load vector based on fixated nodes
Reduces stiffness matrix and load vector based on fixated nodes

Copilot uses AI. Check for mistakes.
@egarciamendez
Copy link
Member Author

@VictorLued we will get there step by step :-)

@egarciamendez egarciamendez self-assigned this Oct 13, 2025
@egarciamendez egarciamendez marked this pull request as draft October 13, 2025 15:46
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.

[✨ Feature request]: refactor into separate modules

2 participants