Skip to content

Commit

Permalink
0713
Browse files Browse the repository at this point in the history
  • Loading branch information
tian50 committed Jul 14, 2021
1 parent f865310 commit beec438
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 131 deletions.
164 changes: 156 additions & 8 deletions msgpi/ms/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,15 @@ def __init__(self):
#: list of floats: Angular velocity of the rotating beam.
#: `[wa1, wa2, wa3]`
self.angular_velocity = []
#: list of int: Time function of angular velocity.
#: `[tf_wa1, tf_wa2, tf_wa3]`
self.av_tf = []
#: list of floats: Linear velocity of the first key point.
#: `[va1, va2, va3]`
self.linear_velocity = []
#: list of int: Time function of linear velocity.
#: `[tf_va1, tf_va2, tf_va3]`
self.lv_tf = []

#: dict of {int, list of floats}: Key point id and coordinates.
#: `{ptid: [x1, x2, x3], ...}`
Expand All @@ -203,8 +209,8 @@ def __init__(self):
#: list: Member conditions (B.C. and loads).
self.mconditions = []

#: dict of {int, msgpi.sg.MaterialSection}: Effective properties of cross-sections.
#: `{sid: MaterialSection object, ...}`
#: dict of {int, msgpi.sg.BeamProperty}: Effective properties of cross-sections.
#: `{sid: BeamProperty object, ...}`
self.sections = {}

self.frames = {} #: Local frames
Expand All @@ -221,11 +227,46 @@ def __init__(self):
self.results_eigen = []




def summary(self):
pp = pprint.PrettyPrinter(indent=1, width=80)
pp = pprint.PrettyPrinter(indent=4, compact=False)

print('\nAnalysis')
print('analysis type:', self.analysis_type)
print('max iteration:', self.max_iteration)
print('number of steps:', self.num_steps)
if self.analysis_type != 0:
print('angular velocity:', self.angular_velocity)
print('time function:', self.av_tf)
print('linear velocity:', self.linear_velocity)
print('time function:', self.lv_tf)
if self.analysis_type == 3:
print('number of eigen results:', self.num_eigens)

print('\nPoints')
pp.pprint(self.points)
# pp.pprint(self.points)
for pid, coords in self.points.items():
print(f'{pid}: ( {coords[0]} , {coords[1]} , {coords[2]} )')

print('\nSegments')
for k, v in self.segments.items():
print('segment', k)
v.summary()

print('\nPoint B.C.')

print('\nMember B.C.')

print('\nSectional properties')
for sid, bp in self.sections.items():
print('Section', sid)
print('Compliance')
pp.pprint(bp.cmpl_t)
if self.analysis_type != 0:
print('Mass')
pp.pprint(bp.mass)
print('')

print('\nDistributions')
pp.pprint(self.distributions)
Expand All @@ -235,10 +276,6 @@ def summary(self):
for k, v in self.functions.items():
print(k, ':', v)

print('\nSegments')
for k, v in self.segments.items():
print('segment', k)
v.summary()



Expand All @@ -262,12 +299,16 @@ def echo(self):
print('')




def printResults(self):
for i, step in enumerate(self.results_steps):
print('step', i+1)
step.printAll(self.analysis_type)




def findPtCoordByName(self, name):
"""Find key point coordinates by point id.
Expand All @@ -286,6 +327,9 @@ def findPtCoordByName(self, name):
return c
return None




def findSectionByName(self, name):
"""Find sectional properties by section id.
Expand All @@ -305,6 +349,8 @@ def findSectionByName(self, name):
return 0




def writeGmshMsh(self):
""" Write the Gmsh mesh file for the visualization of the whole blade
"""
Expand Down Expand Up @@ -371,3 +417,105 @@ def writeGmshMsh(self):
fout.write('Mesh.Lines = ' + str(1) + ';\n')
fout.write('Mesh.LineWidth = ' + str(1) + ';\n')




def writeGEBTIn(self, fn_gebt_in=''):
"""Write data to the GEBT input.
Parameters
----------
fn_gebt_in : str
File name of the GEBT input.
If left blank, the file name will be the same as the beam name,
i.e., `[beam.name].dat`.
"""

if fn_gebt_in == '':
fn_gebt_in = self.name + '.dat'

with open(fn_gebt_in, 'w') as fout:
ioutil.writeFormatIntegers(
fout, [self.analysis_type, self.max_iteration, self.num_steps], '8d'
)
if self.analysis_type != 0:
ioutil.writeFormatFloats(fout, self.angular_velocity[0])
ioutil.writeFormatIntegers(fout, self.angular_velocity[1])
ioutil.writeFormatFloats(fout, self.linear_velocity[0])
ioutil.writeFormatIntegers(fout, self.linear_velocity[1])
if self.analysis_type == 3:
fout.write('{0:8d}\n'.format(self.num_eigens))
fout.write('\n')

line = [
len(self.points), len(self.segments), len(self.pconditions),
len(self.sections), len(self.frames), len(self.mconditions),
len(self.distrloads), len(self.timefunctions), len(self.initcurvatures)
]
ioutil.writeFormatIntegers(fout, line, '4d')
fout.write('\n')

# Write the block of points
for pid, coord in self.points.items():
fout.write('{0:4d}'.format(pid))
ioutil.writeFormatFloats(fout, coord)
fout.write('\n')

# Write the block of members
# for i, member in enumerate(members):
for bsid, bs in self.segments.items():
line = [
bsid, bs.points[0], bs.points[1], bs.css[0], bs.css[1],
bs.frame_id, bs.num_divisions, bs.curv_id
]
ioutil.writeFormatIntegers(fout, line, '4d')
fout.write('\n')

# Write the block of point conditions
for condition in self.pconditions:
fout.write('{0:4d}\n'.format(condition['point']))
ioutil.writeFormatIntegers(fout, condition['components'], '16d')
ioutil.writeFormatFloats(fout, condition['values'])
ioutil.writeFormatIntegers(
fout, np.zeros(6, dtype=np.int8), '16d')
ioutil.writeFormatIntegers(
fout, np.zeros(6, dtype=np.int8), '16d')
fout.write('\n')

# Write the block of cross sectional properties
# for i, member in enumerate(members):
for sid, ms in self.sections.items():
fout.write('{0:4d}\n'.format(sid))
# tcm = st['tcm']
# for row in tcm:
# utl.writeFormatFloats(fout, row)
# if len(ms.eff_props[1]['compliance']['refined']) > 0:
if not ms.compliance_refined is None:
# for row in ms.eff_props[1]['compliance']['refined']:
for row in ms.compliance_refined:
ioutil.writeFormatFloats(fout, row)
else:
# for i, row in enumerate(ms.eff_props[1]['compliance']['classical']):
for i, row in enumerate(ms.compliance):
ioutil.writeFormatFloats(fout, (row[0], 0, 0, row[1], row[2], row[3]))
if i == 0:
ioutil.writeFormatFloats(fout, np.zeros(6))
ioutil.writeFormatFloats(fout, np.zeros(6))
fout.write('\n')
if self.analysis_type != 0:
# mass = st['mass']
# for row in mass:
# utl.writeFormatFloats(fout, row)
# for row in ms.eff_props[1]['mass']['origin']:
for row in ms.mass_origin:
ioutil.writeFormatFloats(fout, row)
fout.write('\n')

# Write the block of self.frames
for i, cij in self.frames.items():
fout.write('{0:4d}\n'.format(i))
for row in cij:
ioutil.writeFormatFloats(fout, row)
fout.write('\n')

123 changes: 0 additions & 123 deletions msgpi/ms/iogebt.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,126 +558,3 @@ def readGEBTOut(fn_gebt_out, beam, method=0):
# elif beam.analysis_type == 3:











# ====================================================================
#
#
# WRITERS
#
#
# ====================================================================

def writeGEBTIn(beam, fn_gebt_in=''):
"""Write data to the GEBT input.
Parameters
----------
beam : msgpi.ms.beam.Beam
Beam object that is going to be written to file.
fn_gebt_in : str
File name of the GEBT input.
If left blank, the file name will be the same as the beam name,
i.e., `[beam.name].dat`.
Returns
-------
str
File name of the GEBT input.
"""

if fn_gebt_in == '':
fn_gebt_in = beam.name + '.dat'

with open(fn_gebt_in, 'w') as fout:
utl.writeFormatIntegers(
fout, [beam.analysis_type, beam.max_iteration, beam.num_steps], '8d'
)
if beam.analysis_type != 0:
utl.writeFormatFloats(fout, beam.angular_velocity[0])
utl.writeFormatIntegers(fout, beam.angular_velocity[1])
utl.writeFormatFloats(fout, beam.linear_velocity[0])
utl.writeFormatIntegers(fout, beam.linear_velocity[1])
if beam.analysis_type == 3:
fout.write('{0:8d}\n'.format(beam.num_eigens))
fout.write('\n')

line = [
len(beam.points), len(beam.segments), len(beam.pconditions),
len(beam.sections), len(beam.frames), len(beam.mconditions),
len(beam.distrloads), len(beam.timefunctions), len(beam.initcurvatures)
]
utl.writeFormatIntegers(fout, line, '4d')
fout.write('\n')

# Write the block of points
for pid, coord in beam.points.items():
fout.write('{0:4d}'.format(pid))
utl.writeFormatFloats(fout, coord)
fout.write('\n')

# Write the block of members
# for i, member in enumerate(members):
for bsid, bs in beam.segments.items():
line = [
bsid, bs.points[0], bs.points[1], bs.css[0], bs.css[1],
bs.frame_id, bs.num_divisions, bs.curv_id
]
utl.writeFormatIntegers(fout, line, '4d')
fout.write('\n')

# Write the block of point conditions
for condition in beam.pconditions:
fout.write('{0:4d}\n'.format(condition['point']))
utl.writeFormatIntegers(fout, condition['components'], '16d')
utl.writeFormatFloats(fout, condition['values'])
utl.writeFormatIntegers(
fout, np.zeros(6, dtype=np.int8), '16d')
utl.writeFormatIntegers(
fout, np.zeros(6, dtype=np.int8), '16d')
fout.write('\n')

# Write the block of cross sectional properties
# for i, member in enumerate(members):
for sid, ms in beam.sections.items():
fout.write('{0:4d}\n'.format(sid))
# tcm = st['tcm']
# for row in tcm:
# utl.writeFormatFloats(fout, row)
# if len(ms.eff_props[1]['compliance']['refined']) > 0:
if not ms.compliance_refined is None:
# for row in ms.eff_props[1]['compliance']['refined']:
for row in ms.compliance_refined:
utl.writeFormatFloats(fout, row)
else:
# for i, row in enumerate(ms.eff_props[1]['compliance']['classical']):
for i, row in enumerate(ms.compliance):
utl.writeFormatFloats(fout, (row[0], 0, 0, row[1], row[2], row[3]))
if i == 0:
utl.writeFormatFloats(fout, np.zeros(6))
utl.writeFormatFloats(fout, np.zeros(6))
fout.write('\n')
if beam.analysis_type != 0:
# mass = st['mass']
# for row in mass:
# utl.writeFormatFloats(fout, row)
# for row in ms.eff_props[1]['mass']['origin']:
for row in ms.mass_origin:
utl.writeFormatFloats(fout, row)
fout.write('\n')

# Write the block of self.frames
for i, cij in beam.frames.items():
fout.write('{0:4d}\n'.format(i))
for row in cij:
utl.writeFormatFloats(fout, row)
fout.write('\n')

return fn_gebt_in

0 comments on commit beec438

Please sign in to comment.