Skip to content

Commit

Permalink
Merge pull request #83 from ladisk/dataset_definitions
Browse files Browse the repository at this point in the history
ENH: added uff data structure for each dataset
  • Loading branch information
jankoslavic committed Sep 26, 2023
2 parents b2b5fa6 + f26de04 commit f0ae0cc
Show file tree
Hide file tree
Showing 14 changed files with 2,131 additions and 65 deletions.
48 changes: 26 additions & 22 deletions pyuff/datasets/dataset_15.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
from os import write
import os
import numpy as np

from ..tools import _opt_fields, _parse_header_line, _write_record, check_dict_for_none
from .. import pyuff

# def _write15(fh, dset):
# """Writes coordinate data - data-set 15 - to an open file fh"""
# try:
# n = len(dset['node_nums'])
# # handle optional fields
# dset = _opt_fields(dset, {'def_cs': np.asarray([0 for ii in range(0, n)], 'i'),
# 'disp_cs': np.asarray([0 for ii in range(0, n)], 'i'),
# 'color': np.asarray([0 for ii in range(0, n)], 'i')})
# # write strings to the file
# fh.write('%6i\n%6i%74s\n' % (-1, 15, ' '))
# for ii in range(0, n):
# fh.write('%10i%10i%10i%10i%13.5e%13.5e%13.5e\n' % (
# dset['node_nums'][ii], dset['def_cs'][ii], dset['disp_cs'][ii], dset['color'][ii],
# dset['x'][ii], dset['y'][ii], dset['z'][ii]))
# fh.write('%6i\n' % -1)
# except KeyError as msg:
# raise Exception('The required key \'' + msg.args[0] + '\' not present when writing data-set #15')
# except:
# raise Exception('Error writing data-set #15')

def get_structure_15(raw=False):
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
out = """
Universal Dataset Number: 15
Name: Nodes
-----------------------------------------------------------------------
Record 1: FORMAT(4I10,1P3E13.5)
Field 1 - node label
Field 2 - definition coordinate system number
Field 3 - displacement coordinate system number
Field 4 - color
Field 5-7 - 3 - Dimensional coordinates of node
in the definition system
NOTE: Repeat record for each node
------------------------------------------------------------------------------
"""

if raw:
return out
else:
print(out)

FORMATS = [
['10.0f', '10.0f', '10.0f', '10.0f', '13.5f', '13.5f', '13.5f'],
Expand Down
41 changes: 40 additions & 1 deletion pyuff/datasets/dataset_151.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,46 @@
import os

from ..tools import _opt_fields, _parse_header_line, check_dict_for_none
from .. import pyuff

def get_structure_151(raw=False):
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
out = """
Universal Dataset Number: 151
Name: Header
-----------------------------------------------------------------------
Record 1: FORMAT(80A1)
Field 1 -- model file name
Record 2: FORMAT(80A1)
Field 1 -- model file description
Record 3: FORMAT(80A1)
Field 1 -- program which created DB
Record 4: FORMAT(10A1,10A1,3I10)
Field 1 -- date database created (DD-MMM-YY)
Field 2 -- time database created (HH:MM:SS)
Field 3 -- Version from database
Field 4 -- Version from database
Field 5 -- File type
=0 Universal
=1 Archive
=2 Other
Record 5: FORMAT(10A1,10A1)
Field 1 -- date database last saved (DD-MMM-YY)
Field 2 -- time database last saved (HH:MM:SS)
Record 6: FORMAT(80A1)
Field 1 -- program which created universal file
Record 7: FORMAT(10A1,10A1)
Field 1 -- date universal file written (DD-MMM-YY)
Field 2 -- time universal file written (HH:MM:SS)
-----------------------------------------------------------------
"""

if raw:
return out
else:
print(out)

def _write151(fh, dset):
"""Writes dset data - data-set 151 - to an open file fh."""
Expand Down
42 changes: 41 additions & 1 deletion pyuff/datasets/dataset_164.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,47 @@
import os

from ..tools import _opt_fields, _parse_header_line, check_dict_for_none
from .. import pyuff

def get_structure_164(raw=False):
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
out = """
Universal Dataset Number: 164
Name: Units
-----------------------------------------------------------------------
Record 1: FORMAT(I10,20A1,I10)
Field 1 -- units code
= 1 - SI: Meter (newton)
= 2 - BG: Foot (pound f)
= 3 - MG: Meter (kilogram f)
= 4 - BA: Foot (poundal)
= 5 - MM: mm (milli newton)
= 6 - CM: cm (centi newton)
= 7 - IN: Inch (pound f)
= 8 - GM: mm (kilogram f)
= 9 - US: USER_DEFINED
Field 2 -- units description (used for
documentation only)
Field 3 -- temperature mode
= 1 - absolute
= 2 - relative
Record 2: FORMAT(3D25.17)
Unit factors for converting universal file units to SI.
To convert from universal file units to SI divide by
the appropriate factor listed below.
Field 1 -- length
Field 2 -- force
Field 3 -- temperature
Field 4 -- temperature offset
-----------------------------------------------------------------
"""

if raw:
return out
else:
print(out)

def _write164(fh, dset):
"""Writes units data - data-set 164 - to an open file fh."""
Expand Down
38 changes: 38 additions & 0 deletions pyuff/datasets/dataset_18.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@

from ..tools import _opt_fields, _parse_header_line

def get_structure_18(raw=False):
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
out = """
Universal Dataset Number: 18
Name: Coordinate Systems
-----------------------------------------------------------------------
Record 1: FORMAT(5I10)
Field 1 -- coordinate system number
Field 2 -- coordinate system type
Field 3 -- reference coordinate system number
Field 4 -- color
Field 5 -- method of definition
= 1 - origin, +x axis, +xz plane
Record 2: FORMAT(20A2)
Field 1 -- coordinate system name
Record 3: FORMAT(1P6E13.5)
Total of 9 coordinate system definition parameters.
Fields 1-3 -- origin of new system specified in
reference system
Fields 4-6 -- point on +x axis of the new system
specified in reference system
Fields 7-9 -- point on +xz plane of the new system
specified in reference system
Records 1 thru 3 are repeated for each coordinate system in the model.
-----------------------------------------------------------------
"""

if raw:
return out
else:
print(out)

def _extract18(block_data):
'''Extract local CS definitions -- data-set 18.'''
dset = {'type': 18}
Expand Down
27 changes: 27 additions & 0 deletions pyuff/datasets/dataset_2411.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

from ..tools import _opt_fields, _parse_header_line, check_dict_for_none

def get_structure_2411(raw=False):
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
out = """
Universal Dataset Number: 2411
Name: Nodes - Double Precision
----------------------------------------------------------------------------
Record 1: FORMAT(4I10)
Field 1 -- node label
Field 2 -- export coordinate system number
Field 3 -- displacement coordinate system number
Field 4 -- color
Record 2: FORMAT(1P3D25.16)
Fields 1-3 -- node coordinates in the part coordinate
system
Records 1 and 2 are repeated for each node in the model.
----------------------------------------------------------------------------
"""

if raw:
return out
else:
print(out)

def _write2411(fh, dset):
try:
dict = {}
Expand Down
41 changes: 41 additions & 0 deletions pyuff/datasets/dataset_2412.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,47 @@

from ..tools import _opt_fields, _parse_header_line, check_dict_for_none

def get_structure_2412(raw=False):
"""(source: https://www.ceas3.uc.edu/sdrluff/"""
out = """
Universal Dataset Number: 2412
Name: Elements
-----------------------------------------------------------------------
Record 1: FORMAT(6I10)
Field 1 -- element label
Field 2 -- fe descriptor id
Field 3 -- physical property table number
Field 4 -- material property table number
Field 5 -- color
Field 6 -- number of nodes on element
Record 2: *** FOR NON-BEAM ELEMENTS ***
FORMAT(8I10)
Fields 1-n -- node labels defining element
Record 2: *** FOR BEAM ELEMENTS ONLY ***
FORMAT(3I10)
Field 1 -- beam orientation node number
Field 2 -- beam fore-end cross section number
Field 3 -- beam aft-end cross section number
Record 3: *** FOR BEAM ELEMENTS ONLY ***
FORMAT(8I10)
Fields 1-n -- node labels defining element
Records 1 and 2 are repeated for each non-beam element in the model.
Records 1 - 3 are repeated for each beam element in the model.
------------------------------------------------------------------------------
"""

if raw:
return out
else:
print(out)

def _write2412(fh, dset):
try:
fh.write('%6i\n%6i%74s\n' % (-1, 2412, ' '))
Expand Down
Loading

0 comments on commit f0ae0cc

Please sign in to comment.