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._check_sort_fields(fields)[source]
pyNastran.bdf.cards.collpase_card.build_thru(packs, max_dv: Optional[int] = None, nthru: Optional[int] = 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
packsList[pack]
packList[int first, int last, int delta]

the first, last, delta id values

max_dvint; default=None -> no limit

defines the max allowable delta between two values

nthruint; default=None

don’t use this; it will crash

Returns
valuevaries

the value of the field

pyNastran.bdf.cards.collpase_card.build_thru_float(packs: List[List[int]], max_dv: Optional[int] = None) → List[Union[int, str]][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
packsList[pack]

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

max_dvint; 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
packsList[pack]
packList[id_low, id_high, delta_id]

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

max_dvint; default=1

maximum allowed delta between two values

thru_splitint; 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
singlesList[int]

the list of singles

doublesList[pack]
packList[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
fieldsList[int]

the values to collapse

thru_splitint; 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
singlesList[int]

the list of singles

doublesList[pack]
packList[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
fieldslist[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: List[int], get_packs: bool = False) → List[List[int]][source]
Parameters
fieldsList[int]

the list of fields to collapse

get_packsbool; 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: List) → List[Union[int, str]][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_listList[int]

list of values to pack

Returns
packsList[pack]
packList[id_low, id_high, delta_id]

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

See also

build_thru ..