-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add in-progress refactorization of EB_TaperWB.py
- Loading branch information
Showing
7 changed files
with
911 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from os.path import join | ||
|
||
# import pynumad | ||
import opensg | ||
import numpy as np | ||
|
||
# load blade.yml into pynumad | ||
# blade_path = join("data", "blade.yaml") | ||
# blade = pynumad.Blade(blade_path) | ||
|
||
# create mesh | ||
|
||
# NOTE: triangular elements are problematic so will need a workaround. | ||
# Evan may have a solution. | ||
|
||
# create mesh object for use with opensg | ||
# 3 options: | ||
# - create our own mesh class | ||
# - use pynumad class | ||
# - use dolfinx or gmsh structures? not sure if these are flexible enough though | ||
|
||
# blade_mesh_info = mesh() | ||
mesh_yaml = join("data", "bar_urc_shell_mesh.yaml") | ||
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) | ||
|
||
segment_matrices.append(data) | ||
|
||
|
||
# ideally, we could also have a step to run beamdyn | ||
opensg.beamdyn.run_analysis(blade_mesh_info, segment_matrices) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import yaml | ||
import numpy as np | ||
|
||
|
||
def load_yaml(yaml_file): | ||
with open(yaml_file, 'r') as file: | ||
mesh_data = yaml.load(file, Loader=yaml.CLoader) | ||
return mesh_data | ||
|
||
def write_yaml(data, yaml_file): | ||
with open(yaml_file, 'w') as file: | ||
yaml.dump(data, file, Loader=yaml.CLoader) | ||
return | ||
|
||
# TODO write a function to validate mesh data schema | ||
|
||
|
||
def write_mesh(filename, blade_mesh): | ||
mesh_file = open(filename, 'w') | ||
|
||
mesh_file.write('$MeshFormat\n2.2 0 8\n$EndMeshFormat\n$Nodes\n') | ||
newNumNds = np.max(ndNewLabs) | ||
mesh_file.write(str(newNumNds) + '\n') | ||
|
||
for i, nd in enumerate(nodes): | ||
lab = ndNewLabs[i] | ||
if(lab > -1): | ||
ln = [str(lab),str(nd[2]),str(nd[0]),str(nd[1])] | ||
# ln = [str(lab),str(nd[0]),str(nd[1]),str(nd[2])] | ||
mesh_file.write(' '.join(ln) + '\n') | ||
|
||
mesh_file.write('$EndNodes\n$Elements\n') | ||
|
||
newNumEls = np.max(elNewLabs) | ||
mesh_file.write(str(newNumEls) + '\n') | ||
|
||
for i, el in enumerate(elements): | ||
lab = elNewLabs[i] | ||
if(lab > -1): | ||
ln = [str(lab)] | ||
if(el[3] == -1): | ||
ln.append('2') | ||
else: | ||
ln.append('3') | ||
ln.append('2') | ||
ln.append(str(elLayID[i]+1)) | ||
ln.append(str(elLayID[i]+1)) | ||
for nd in el: | ||
if(nd > -1): | ||
ln.append(str(ndNewLabs[nd])) | ||
mesh_file.write(' '.join(ln) + '\n') | ||
mesh_file.write('$EndElements\n') | ||
|
||
mesh_file.close() |
Oops, something went wrong.