Skip to content

Commit 9c2e6c4

Browse files
authored
Refactor (#3)
* Refactoring updates * test workflow updates * bugfix * bufix on workflow * add timing to env creation and * directing testing import opensg since pytest is being difficult * add conda list to diagnose env * debug * try another approach to conda environment * debug * fix bug * another attempt * now using pytest again * add an actual test * add extra package isntallation via apt * fix syntax in env file * removing python version requirement, perhaps it conflicts with the setting for the action * try another version * another attempt * one more try * try old version of workflow * try basic setup * try to fix versions * fix fenics-ufl version * clean up test.yml * fix variable name * misc comments * add basic test assertion
1 parent 342cf26 commit 9c2e6c4

File tree

13 files changed

+326115
-431
lines changed

13 files changed

+326115
-431
lines changed

.github/workflows/test.yml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,28 @@ on: [push, pull_request, workflow_dispatch]
44

55
jobs:
66
test:
7-
runs-on: ${{ matrix.os }}
8-
strategy:
9-
matrix:
10-
os: [windows-latest, macOS-13, ubuntu-latest]
11-
python-version: ['3.8', '3.9', '3.10']
12-
fail-fast: false
7+
runs-on: ubuntu-latest
8+
defaults:
9+
run:
10+
shell: bash -el {0}
11+
1312
steps:
14-
- uses: actions/checkout@v2
15-
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v4
17-
with:
18-
python-version: ${{ matrix.python-version }}
19-
- name: Install pynumad
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install -e .
23-
- name: Test with pytest
24-
run: |
25-
pip install --upgrade pytest coverage
26-
coverage run --source=pynumad --omit="*/tests/*" -m pytest
13+
# Step 1: Checkout your code
14+
- name: Checkout Code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up environment
18+
uses: conda-incubator/setup-miniconda@v3
19+
with:
20+
environment-file: environment.yml
21+
# python-version: "3.9" # setup-miniconda seems to ignore this setting.
22+
auto-activate-base: false
23+
- name: Check environmnet
24+
run: |
25+
conda info
26+
conda list
27+
- name: Run tests
28+
run: |
29+
python -c "import opensg"
30+
pip install pytest
31+
pytest opensg/tests/

environment.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@ name: opensg_env
22
channels:
33
- conda-forge
44
dependencies:
5-
- python=3.10
5+
- python=3.12
66
- numpy
77
- scipy
88
- mpi4py
99
- meshio
10-
- petsc4py
10+
- petsc4py=3.21.5
1111
- yaml
1212
- contextlib2 # For compatibility
1313
- pathlib
1414
- typing-extensions
15-
- fenics-dolfinx
16-
- fenics-basix
17-
- fenics-ufl
15+
- fenics-dolfinx=0.8.0
16+
- fenics-basix=0.8.0
17+
- fenics-ufl=2024.1.0
18+
- fenics-ffcx=0.8.0
1819
- mpich
1920
- pyvista
2021
- pyyaml
21-
# - gmsh # I have to install this through pip for it to work.
22+
- pip
23+
- pip:
24+
- -e .
25+
- gmsh

examples/compute_eb_blade.py

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# import pynumad
44
import opensg
55
import numpy as np
6+
import time
67

78
# load blade.yml into pynumad
89
# blade_path = join("data", "blade.yaml")
@@ -24,53 +25,68 @@
2425
mesh_data = opensg.load_yaml(mesh_yaml)
2526

2627
blade_mesh = opensg.BladeMesh(mesh_data)
27-
section_mesh = blade_mesh.generate_segment_mesh(segment_index=1, filename="section.msh")
28-
29-
section_layups = section_mesh._generate_layup_data()
30-
31-
frame = section_mesh.generate_local_orientations()
32-
33-
section_mesh.extract_boundaries()
34-
35-
section_mesh.generate_boundary_ABD()
36-
37-
38-
39-
pause
40-
41-
42-
## Extract the mesh for the section
43-
nodes = mesh_data['nodes']
44-
numNds = len(nodes)
45-
elements = mesh_data['elements']
46-
numEls = len(elements)
47-
48-
ndNewLabs = -1*np.ones(numNds,dtype=int)
49-
elNewLabs = -1*np.ones(numEls,dtype=int)
50-
elLayID = -1*np.ones(numEls,dtype=int)
51-
52-
# iterate through blade
53-
54-
segment_matrices = []
55-
56-
for i in range(len(blade.ispan)):
57-
# select ith blade segment
58-
blade_segment_mesh = opensg.blade.select_segment(blade_mesh_info)
59-
# analysis options
60-
# solid vs shell
61-
# whole segment vs boundary
62-
# analyses:
63-
# stresses/stiffness/buckling
64-
# stresses after beamdyn
65-
data = opensg.compute_eb_segment(blade_segment_mesh)
66-
# data = opensg.compute_eb_boundaries(blade_segment_mesh)
67-
# data = opensg.compute_timo_segment(blade_segment_mesh) # ***** high priority
68-
# data = opensg.compute_eb_buckling(blade_segment_mesh)
69-
# data = opensg.compute_timo_buckling(blade_segment_mesh) # **** top priority
70-
# data = opensg.compute_timo_boundaries(blade_segment_mesh)
28+
stiffness_matrices = []
29+
compute_times = []
30+
for i in range(1, 2):
31+
start_time = time.time()
32+
print(time.time()-start_time)
33+
34+
segment_mesh = blade_mesh.generate_segment_mesh(segment_index=i, filename="section.msh")
35+
print(time.time()-start_time)
36+
37+
ABD = segment_mesh.compute_ABD()
38+
print(time.time()-start_time)
39+
40+
stiffness_matrix = segment_mesh.compute_stiffness_EB(ABD)
41+
print(time.time()-start_time)
42+
43+
stiffness_matrices.append(stiffness_matrix)
44+
end_time = time.time()
45+
compute_times.append(end_time - start_time)
46+
47+
print("Average compute time for a single segment: ", sum(compute_times)/len(compute_times))
48+
print("Maximum compute time for a single segment: ", max(compute_times))
49+
50+
# combine matrices into a global
51+
combined_stiffness_matrices = np.concat(stiffness_matrices)
52+
53+
np.savetxt('stiffness_m.txt', combined_stiffness_matrices, fmt='%d')
54+
55+
# pause
56+
57+
58+
# ## Extract the mesh for the section
59+
# nodes = mesh_data['nodes']
60+
# numNds = len(nodes)
61+
# elements = mesh_data['elements']
62+
# numEls = len(elements)
63+
64+
# ndNewLabs = -1*np.ones(numNds,dtype=int)
65+
# elNewLabs = -1*np.ones(numEls,dtype=int)
66+
# elLayID = -1*np.ones(numEls,dtype=int)
67+
68+
# # iterate through blade
69+
70+
# segment_matrices = []
71+
72+
# for i in range(len(blade.ispan)):
73+
# # select ith blade segment
74+
# blade_segment_mesh = opensg.blade.select_segment(blade_mesh_info)
75+
# # analysis options
76+
# # solid vs shell
77+
# # whole segment vs boundary
78+
# # analyses:
79+
# # stresses/stiffness/buckling
80+
# # stresses after beamdyn
81+
# data = opensg.compute_eb_segment(blade_segment_mesh)
82+
# # data = opensg.compute_eb_boundaries(blade_segment_mesh)
83+
# # data = opensg.compute_timo_segment(blade_segment_mesh) # ***** high priority
84+
# # data = opensg.compute_eb_buckling(blade_segment_mesh)
85+
# # data = opensg.compute_timo_buckling(blade_segment_mesh) # **** top priority
86+
# # data = opensg.compute_timo_boundaries(blade_segment_mesh)
7187

72-
segment_matrices.append(data)
88+
# segment_matrices.append(data)
7389

7490

75-
# ideally, we could also have a step to run beamdyn
76-
opensg.beamdyn.run_analysis(blade_mesh_info, segment_matrices)
91+
# # ideally, we could also have a step to run beamdyn
92+
# opensg.beamdyn.run_analysis(blade_mesh_info, segment_matrices)

opensg/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from opensg.solve import ksp_solve, ABD_mat, nullspace
2-
from opensg.timo import local_frame_1D, directional_derivative, local_grad, ddot
1+
from opensg.solve import compute_ABD_matrix, compute_timo_boun, compute_stiffness_EB_blade_segment
2+
# from kirklocal.timo import local_frame_1D, directional_derivative, local_grad, ddot
33
from opensg.io import load_yaml, write_yaml
44
from opensg.mesh import BladeMesh
5-
from opensg import util
5+
from opensg.compute_utils import solve_ksp, solve_boun, compute_nullspace, \
6+
create_gamma_e, R_sig, Dee, sigma, eps, local_boun, local_frame_1D, \
7+
local_frame, local_frame_1D_manual, local_grad, deri, ddot, gamma_d, \
8+
construct_gamma_e, gamma_h, gamma_l, A_mat, initialize_array, dof_mapping_quad, generate_boundary_markers
69

710
__version__ = "0.0.1"

opensg/blade_utils.py

Whitespace-only changes.

0 commit comments

Comments
 (0)