Skip to content
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

Refactor #3

Merged
merged 28 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@ on: [push, pull_request, workflow_dispatch]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macOS-13, ubuntu-latest]
python-version: ['3.8', '3.9', '3.10']
fail-fast: false
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pynumad
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Test with pytest
run: |
pip install --upgrade pytest coverage
coverage run --source=pynumad --omit="*/tests/*" -m pytest
# Step 1: Checkout your code
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up environment
uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment.yml
# python-version: "3.9" # setup-miniconda seems to ignore this setting.
auto-activate-base: false
- name: Check environmnet
run: |
conda info
conda list
- name: Run tests
run: |
python -c "import opensg"
pip install pytest
pytest opensg/tests/
16 changes: 10 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ name: opensg_env
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.12
- numpy
- scipy
- mpi4py
- meshio
- petsc4py
- petsc4py=3.21.5
- yaml
- contextlib2 # For compatibility
- pathlib
- typing-extensions
- fenics-dolfinx
- fenics-basix
- fenics-ufl
- fenics-dolfinx=0.8.0
- fenics-basix=0.8.0
- fenics-ufl=2024.1.0
- fenics-ffcx=0.8.0
- mpich
- pyvista
- pyyaml
# - gmsh # I have to install this through pip for it to work.
- pip
- pip:
- -e .
- gmsh
110 changes: 63 additions & 47 deletions examples/compute_eb_blade.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# import pynumad
import opensg
import numpy as np
import time

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

blade_mesh = opensg.BladeMesh(mesh_data)
section_mesh = blade_mesh.generate_segment_mesh(segment_index=1, filename="section.msh")

section_layups = section_mesh._generate_layup_data()

frame = section_mesh.generate_local_orientations()

section_mesh.extract_boundaries()

section_mesh.generate_boundary_ABD()



pause


## Extract the mesh for the section
nodes = mesh_data['nodes']
numNds = len(nodes)
elements = mesh_data['elements']
numEls = len(elements)

ndNewLabs = -1*np.ones(numNds,dtype=int)
elNewLabs = -1*np.ones(numEls,dtype=int)
elLayID = -1*np.ones(numEls,dtype=int)

# iterate through blade

segment_matrices = []

for i in range(len(blade.ispan)):
# select ith blade segment
blade_segment_mesh = opensg.blade.select_segment(blade_mesh_info)
# analysis options
# solid vs shell
# whole segment vs boundary
# analyses:
# stresses/stiffness/buckling
# stresses after beamdyn
data = opensg.compute_eb_segment(blade_segment_mesh)
# data = opensg.compute_eb_boundaries(blade_segment_mesh)
# data = opensg.compute_timo_segment(blade_segment_mesh) # ***** high priority
# data = opensg.compute_eb_buckling(blade_segment_mesh)
# data = opensg.compute_timo_buckling(blade_segment_mesh) # **** top priority
# data = opensg.compute_timo_boundaries(blade_segment_mesh)
stiffness_matrices = []
compute_times = []
for i in range(1, 2):
start_time = time.time()
print(time.time()-start_time)

segment_mesh = blade_mesh.generate_segment_mesh(segment_index=i, filename="section.msh")
print(time.time()-start_time)

ABD = segment_mesh.compute_ABD()
print(time.time()-start_time)

stiffness_matrix = segment_mesh.compute_stiffness_EB(ABD)
print(time.time()-start_time)

stiffness_matrices.append(stiffness_matrix)
end_time = time.time()
compute_times.append(end_time - start_time)

print("Average compute time for a single segment: ", sum(compute_times)/len(compute_times))
print("Maximum compute time for a single segment: ", max(compute_times))

# combine matrices into a global
combined_stiffness_matrices = np.concat(stiffness_matrices)

np.savetxt('stiffness_m.txt', combined_stiffness_matrices, fmt='%d')

# pause


# ## Extract the mesh for the section
# nodes = mesh_data['nodes']
# numNds = len(nodes)
# elements = mesh_data['elements']
# numEls = len(elements)

# ndNewLabs = -1*np.ones(numNds,dtype=int)
# elNewLabs = -1*np.ones(numEls,dtype=int)
# elLayID = -1*np.ones(numEls,dtype=int)

# # iterate through blade

# segment_matrices = []

# for i in range(len(blade.ispan)):
# # select ith blade segment
# blade_segment_mesh = opensg.blade.select_segment(blade_mesh_info)
# # analysis options
# # solid vs shell
# # whole segment vs boundary
# # analyses:
# # stresses/stiffness/buckling
# # stresses after beamdyn
# data = opensg.compute_eb_segment(blade_segment_mesh)
# # data = opensg.compute_eb_boundaries(blade_segment_mesh)
# # data = opensg.compute_timo_segment(blade_segment_mesh) # ***** high priority
# # data = opensg.compute_eb_buckling(blade_segment_mesh)
# # data = opensg.compute_timo_buckling(blade_segment_mesh) # **** top priority
# # data = opensg.compute_timo_boundaries(blade_segment_mesh)

segment_matrices.append(data)
# segment_matrices.append(data)


# ideally, we could also have a step to run beamdyn
opensg.beamdyn.run_analysis(blade_mesh_info, segment_matrices)
# # ideally, we could also have a step to run beamdyn
# opensg.beamdyn.run_analysis(blade_mesh_info, segment_matrices)
9 changes: 6 additions & 3 deletions opensg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from opensg.solve import ksp_solve, ABD_mat, nullspace
from opensg.timo import local_frame_1D, directional_derivative, local_grad, ddot
from opensg.solve import compute_ABD_matrix, compute_timo_boun, compute_stiffness_EB_blade_segment
# from kirklocal.timo import local_frame_1D, directional_derivative, local_grad, ddot
from opensg.io import load_yaml, write_yaml
from opensg.mesh import BladeMesh
from opensg import util
from opensg.compute_utils import solve_ksp, solve_boun, compute_nullspace, \
create_gamma_e, R_sig, Dee, sigma, eps, local_boun, local_frame_1D, \
local_frame, local_frame_1D_manual, local_grad, deri, ddot, gamma_d, \
construct_gamma_e, gamma_h, gamma_l, A_mat, initialize_array, dof_mapping_quad, generate_boundary_markers

__version__ = "0.0.1"
Empty file removed opensg/blade_utils.py
Empty file.
Loading
Loading