pyyeti.nastran.n2p.mkdofpv

pyyeti.nastran.n2p.mkdofpv(uset, nasset, dof, *, strict=True, grids_only=True)[source]

Make a DOF partition vector for a particular set from a Nastran USET table.

Parameters:
  • uset (pandas DataFrame or ndarray) – A DataFrame as output by pyyeti.nastran.op2.OP2.rdn2cop2(). It can also be an ndarray with at least 2-columns of [id, dof]; any other columns are quietly ignored. If ndarray, nasset must be ‘p’ (so no set partitions are needed).

  • nasset (string or integer) – The set(s) to partition the dof out of (eg, ‘p’ or ‘b+q’). May also be an integer bitmask (see mkusetmask() for more information).

  • dof (1d or 2d array_like) –

    dof can be input in 2 different ways:

    1. 1d array. Each element is assumed to be an ID. If grids_only is True (the default), this routine assumes the DOFs are 1-6, so the IDs are only of GRIDs. If grids_only is False, then the DOFs will be 0-6, which enables this routine to find both GRIDs and SPOINTs. See also expanddof().

    2. 2d 2-column DOF array. Each row is: [ID, DOF]. Here, DOF specifies which degrees-of-freedom of the ID to find. The DOF can be input in the same way as Nastran accepts it: 0 or any combo of digits 1-6; eg, 123456 for all 6.

  • strict (bool; optional) – If True, raise a ValueError if any DOF in dof are not in uset.

  • grids_only (bool; optional) – Ignored if dof has two columns. Otherwise, see option 1 of the dof description above and the examples shown in expanddof().

    Note

    Though not disallowed by this routine, using 1d dof, strict==True and grids_only==False will raise a ValueError. That’s because DOF 0-6 will be assumed for all IDs and all must be found, which is not possible.

Returns:

  • pv (vector) – Index vector for partitioning dof out of set; this maintains the order of DOF as specified.

  • outdof (vector) – The expanded version of the dof input, in order of output.

Raises:

ValueError – When requested dof are not found in the nasset and strict is True.

Examples

>>> import numpy as np
>>> from pyyeti import nastran
>>> # Want an a-set partition vector for all available a-set dof
>>> # of grids 100 and 200:
>>> ids = np.array([[100], [200]])
>>> uset = nastran.addgrid(
...     None, [100, 200], 'b', 0,
...     [[5, 10, 15], [32, 90, 10]], 0)
>>> nastran.mkdofpv(uset, "a", ids)
(array([ 0,  1,  2,  3,  4,  5... 10, 11]...), array([[100,   1],
       [100,   2],
       [100,   3],
       [100,   4],
       [100,   5],
       [100,   6],
       [200,   1],
       [200,   2],
       [200,   3],
       [200,   4],
       [200,   5],
       [200,   6]]...))
>>>
>>> # add an spoint for testing:
>>> qset = nastran.mkusetmask("q")
>>> uset = pd.concat(
...     (uset, nastran.make_uset([[991, 0]], qset)), axis=0
... )
>>> # request spoint 991 and dof 123 for grid 100 (in that order):
>>> ids2 = [[991, 0], [100, 123]]
>>> nastran.mkdofpv(uset, "a", ids2)
(array([12,  0,  1,  2]...), array([[991,   0],
       [100,   1],
       [100,   2],
       [100,   3]]...))