collpase_card Module

defines:
  • collapse_thru_by(fields, get_packs=False)
  • collapse_thru_by_float(fields)
  • collapse_thru(fields, nthru=None)
  • collapse_thru_packs(fields)
  • collapse_colon_packs(fields, thru_split=3)
  • condense(value_list)
  • build_thru_packs(packs, max_dv=1, thru_split=3)
  • build_thru(packs, max_dv=None, nthru=None)
  • build_thru_float(packs, max_dv=None)
pyNastran.bdf.cards.collpase_card.build_thru(packs, max_dv=None, nthru=None)[source]

Takes a pack [1,7,2] and converts it into fields used by a SET card. The values correspond to the first value, last value, and delta in the list. This means that [1,1001,2] represents 500 values. [1,1001,1] represents 1001 values and will be written as [1,THRU,1001]..

Parameters:
packs : List[pack]
pack : List[int first, int last, int delta]

the first, last, delta id values

max_dv : int; default=None -> no limit

defines the max allowable delta between two values

nthru : int; default=None

don’t use this; it will crash

Returns:
value : varies

the value of the field

pyNastran.bdf.cards.collpase_card.build_thru_float(packs, max_dv=None)[source]

Takes a pack [1,7,2] and converts it into fields used by a SET card. The values correspond to the first value, last value, and delta in the list. This means that [1,1001,2] represents 500 values. [1,1001,1] represents 1001 values and will be written as [1,THRU,1001].

Parameters:
packs : List[pack]

pack : List[first, last, delta] first, last, delta are integers

max_dv : int; default=None -> no limit

integer defining the max allowable delta between two values (default=None; no limit)

pyNastran.bdf.cards.collpase_card.build_thru_packs(packs, max_dv=1, thru_split=3)[source]

Applies THRU and BY to packs to shorten output as Nastran does on cards like the SPOINT

Parameters:
packs : List[pack]
pack : List[id_low, id_high, delta_id]

a list representation of the min/max/delta id values

max_dv : int; default=1

maximum allowed delta between two values

thru_split : int; default=3

the length to not write THRU 3 : [10, 11, 12] will write as ‘10 THRU 12’ 4 : [10, 11, 12] will write as ‘10 11 12’

Returns:
singles : List[int]

the list of singles

doubles : List[pack]
pack : List[varies]

[3, THRU, 13] [3, THRU, 13, BY, 5]

the double packs

# invalid
SET1,4000, 1, 3, THRU, 10, 20, THRU, 30
# valid
SET1,4000, 1
SET1,4000, 3, THRU, 10
SET1,4000, 20, THRU, 30
returns

singles = [1] doubles = [[3, ‘THRU’, 10], [20, ‘THRU’, 30]]

pyNastran.bdf.cards.collpase_card.collapse_colon_packs(fields, thru_split=3)[source]

Applies colons (:) to packs to represent THRU and BY as is used by Patran.

Parameters:
fields : List[int]

the values to collapse

thru_split : int; default=3

the length to not write THRU 3 : [10, 11, 12] will write as ‘10 THRU 12’ 4 : [10, 11, 12] will write as ‘10 11 12’

Returns:
singles : List[int]

the list of singles

doubles : List[pack]
pack : List[varies]

[3, :, 13] [3, :, 13, :, 5]

the double packs

# invalid
SET1,4000, 1, 3, :, 10, 20, :, 30
# valid
SET1,4000, 1
SET1,4000, 3, :, 10
SET1,4000, 20, :, 30
# output
singles = [1]
doubles = [[3, ‘:’, 10], [20, ‘:’, 30]]
pyNastran.bdf.cards.collpase_card.collapse_thru(fields, nthru=None)[source]

Collapses fields into a set of packs

Parameters:
fields : list[int, int, …]

the list of integers to compress

Returns:
packs = list[pack]

pack = list[int first_val, int last_val, int_by]

pyNastran.bdf.cards.collpase_card.collapse_thru_by(fields, get_packs=False)[source]
Parameters:
fields : List[int]

the list of fields to collapse

get_packs : bool; default=False

get the list of packs so “special” formatting can be done

fields packs
[1, 2, 3…150] -> [1, 150, 1]
[1, 3, 5…150] -> [1, 150, 2]
pyNastran.bdf.cards.collpase_card.collapse_thru_by_float(fields)[source]
pyNastran.bdf.cards.collpase_card.collapse_thru_packs(fields)[source]
pyNastran.bdf.cards.collpase_card.condense(value_list)[source]

Builds a list of packs (list of 3 values representing the first, last, and delta values for condensing a SET card.

Parameters:
value_list : List[int]

list of values to pack

Returns:
packs : List[pack]
pack : List[id_low, id_high, delta_id]

a list representation of the min/max/delta id values

See also

build_thru ..