Beispiel #1
0
def get_beam_sections_map(model: BDF,
                          bar_beam_eids: List[int]) -> Dict[int, List[int]]:
    """gets the beams sorted by property_id that can be represented as 3d elements"""
    bar_pid_to_eids = defaultdict(list)
    int_offts = []
    for eid in bar_beam_eids:
        elem = model.elements[eid]  # type: Union[CBAR, CBEAM]
        if isinstance(elem.offt, int):
            int_offts.append(eid)
            continue

        pid_ref = elem.pid_ref
        if pid_ref is None:
            pid_ref = model.Property(elem.pid)
        assert not isinstance(pid_ref, int), elem
        ptype = pid_ref.type
        if ptype in ['PBEAML', 'PBARL']:
            pass
        elif ptype in ['PBEAM', 'PBAR']:
            continue
        else:
            raise NotImplementedError(pid_ref)
        beam_type = pid_ref.Type
        if beam_type not in BEAM_SETUP_MAP:
            model.log.warning(f'The following beam section is not supported:\n{pid_ref}')
            continue
        pid = pid_ref.pid
        bar_pid_to_eids[pid].append(eid)
    bar_pid_to_eids = dict(bar_pid_to_eids)
    if int_offts:
        int_offts.sort()
        model.log.warning(f'The following CBAR/CBEAMs have integer OFFTs: {int_offts}')

    return bar_pid_to_eids
Beispiel #2
0
    def cross_reference(self, model: BDF) -> None:
        """
        Cross links the card so referenced cards can be extracted directly

        Parameters
        ----------
        model : BDF()
            the BDF object
        """
        msg = ', which is required by CTRIAX eid=%s' % self.eid
        self.nodes_ref = model.EmptyNodes(self.nodes, msg=msg)
        self.pid_ref = model.Property(self.pid, msg=msg)
Beispiel #3
0
    def cross_reference(self, model: BDF) -> None:
        """
        Cross links the card so referenced cards can be extracted directly

        Parameters
        ----------
        model : BDF()
            the BDF object
        """
        msg = ', which is required by CBUSH2D eid=%s' % self.eid
        self.ga_ref = model.Node(self.ga, msg=msg)
        self.gb_ref = model.Node(self.gb, msg=msg)
        self.pid_ref = model.Property(self.pid)
        if self.cid is not None:
            self.cid_ref = model.Coord(self.cid, msg=msg)
Beispiel #4
0
    def cross_reference(self, model: BDF) -> None:
        """
        Cross links the card so referenced cards can be extracted directly

        Parameters
        ----------
        model : BDF()
            the BDF object
        """
        self.pid_ref = model.Property(self.pid)
        if self.tkid > 0:
            self.tkid_ref = model.TableD(self.tkid)
        if self.tgeid > 0:
            self.tgeid_ref = model.TableD(self.tgeid)
        if self.tknid > 0:
            self.tknid_ref = model.TableD(self.tknid)
Beispiel #5
0
    def cross_reference(self, model: BDF) -> None:
        """
        Cross links the card so referenced cards can be extracted directly

        Parameters
        ----------
        model : BDF()
            the BDF object
        """
        msg = ', which is required by CBUSH eid=%s' % self.eid
        self.nodes_ref = model.EmptyNodes(self.node_ids, msg=msg)
        self.pid_ref = model.Property(self.pid, msg=msg)
        if self.g0 is not None:
            self.g0_ref = model.Node(self.g0, msg=msg)
        if self.cid is not None:
            self.cid_ref = model.Coord(self.cid, msg=msg)
        if self.ocid is not None and self.ocid != -1:
            self.ocid_ref = model.Coord(self.ocid, msg=msg)
Beispiel #6
0
    def cross_reference(self, model: BDF) -> None:
        """
        Cross links the card so referenced cards can be extracted directly

        Parameters
        ----------
        model : BDF()
            the BDF object

        """
        msg = ', which is required by CFAST eid=%s' % self.eid
        self.pid_ref = model.Property(self.Pid(), msg=msg)
        if self.gs:
            self.gs_ref = model.Node(self.Gs(), msg=msg)
        if self.ga:
            self.ga_ref = model.Node(self.Ga(), msg=msg)
        if self.gb:
            self.gb_ref = model.Node(self.Gb(), msg=msg)
Beispiel #7
0
    def cross_reference(self, model: BDF) -> None:
        """
        Cross links the card so referenced cards can be extracted directly

        Parameters
        ----------
        model : BDF()
            the BDF object

        """
        msg = ', which is required by CGAP eid=%s' % self.eid
        self.ga_ref = model.Node(self.ga, msg=msg)
        self.gb_ref = model.Node(self.gb, msg=msg)
        if self.g0:
            self.g0_ref = model.Node(self.g0, msg=msg)
            self.x = self.g0_ref.get_position()
        self.pid_ref = model.Property(self.pid, msg=msg)
        if self.cid:
            self.cid_ref = model.Coord(self.cid, msg=msg)
Beispiel #8
0
    def get_axes(self, model: BDF) -> Tuple[Any, Any, Any, Any, Any]:
        """
        Gets the axes of a CBAR/CBEAM, while respecting the OFFT flag.

        Notes
        -----
        :func:`pyNastran.bdf.cards.elements.bars.rotate_v_wa_wb` for a
        description of the OFFT flag.

        is_passed: bool
        out: (wa, wb, ihat, jhat, khat)
        """
        is_failed = True
        #TODO: not integrated with CBAR yet...
        if self.bit is not None:
            print(self.get_stats())
            return is_failed, None

        check_offt(self)
        is_failed = True
        ihat = None
        yhat = None
        zhat = None

        eid = self.eid
        (nid1, nid2) = self.node_ids
        node1 = model.nodes[nid1]
        node2 = model.nodes[nid2]
        xyz1 = node1.get_position()
        xyz2 = node2.get_position()

        elem = model.elements[eid]
        pid_ref = elem.pid_ref
        if pid_ref is None:
            pid_ref = model.Property(elem.pid)
        assert not isinstance(pid_ref, integer_types), elem

        is_failed, (wa, wb, ihat, yhat, zhat) = self.get_axes_by_nodes(
            model, pid_ref, node1, node2, xyz1, xyz2, model.log)
        return is_failed, (wa, wb, ihat, yhat, zhat)
Beispiel #9
0
    def cross_reference(self, model: BDF) -> None:
        """
        Cross links the card so referenced cards can be extracted directly

        Parameters
        ----------
        model : BDF()
            the BDF object

        """
        msg = ', which is required by CBEAM eid=%s' % (self.eid)
        self.ga_ref = model.Node(self.ga, msg=msg)
        self.gb_ref = model.Node(self.gb, msg=msg)
        self.nodes_ref = [self.ga_ref, self.gb_ref]
        self.pid_ref = model.Property(self.pid, msg=msg)
        if self.g0:
            self.g0_ref = model.nodes[self.g0]
            self.g0_vector = self.g0_ref.get_position(
            ) - self.ga_ref.get_position()
        else:
            self.g0_vector = self.x
        if model.is_nx:
            assert self.offt == 'GGG', 'NX only support offt=GGG; offt=%r' % self.offt
Beispiel #10
0
    def cross_reference(self, model: BDF) -> None:
        """
        Cross links the card so referenced cards can be extracted directly

        Parameters
        ----------
        model : BDF()
            the BDF object
        """
        msg = ', which is required by CDAMP1 eid=%s' % self.eid
        self.nodes_ref = model.EmptyNodes(self.nodes, msg=msg)

        pid = self.pid
        if pid in model.properties:
            self.pid_ref = model.Property(pid, msg=msg)
        elif pid in model.pdampt:
            self.pid_ref = model.pdampt[pid]
        else:
            pids = model.properties.keys() + model.pdampt.keys()
            pids.sort()
            msg = ('pid=%i not found which is required by CDAMP1 eid=%i.  '
                   'Allowed Pids=%s' % (self.pid, self.eid, pids))
            raise KeyError(msg)
Beispiel #11
0
 def cross_reference(self, model: BDF) -> None:
     msg = ', which is required by CCONEAX eid=%s' % (self.eid)
     #self.rings_ref
     self.pid_ref = model.Property(self.pid, msg=msg)
Beispiel #12
0
 def cross_reference(self, model: BDF) -> None:
     msg = ', which is required by CTUBE eid=%s' % (self.eid)
     self.nodes_ref = model.Nodes(self.nodes, msg=msg)
     self.pid_ref = model.Property(self.pid, msg=msg)
Beispiel #13
0
def _create_bar_types_dict(model: BDF,
                           bar_types: Dict[str, List[List[int], List[Any],
                                                     List[Any]]],
                           bar_beam_eids: List[int],
                           eid_map,
                           log: SimpleLogger,
                           scale: float,
                           debug: bool = False):
    node0 = 0
    found_bar_types = set()
    nid_release_map = defaultdict(list)
    ugrid = vtk.vtkUnstructuredGrid()
    points_list = []

    allowed_types = [
        'BAR',
        'BOX',
        'BOX1',
        'CHAN',
        'CHAN1',
        'CHAN2',
        'CROSS',
        'DBOX',
        'H',
        'HAT',
        'HAT1',
        'HEXA',
        'I',
        'I1',
        'L',
        'ROD',
        'T',
        'T1',
        'T2',
        'TUBE',
        'TUBE2',
        'Z',
        'bar',
        'beam',
        'pbcomp',
    ]

    #debug = True
    bar_nids = set()
    #print('bar_beam_eids = %s' % bar_beam_eids)
    for eid in bar_beam_eids:
        if eid not in eid_map:
            log.error('eid=%s is not a valid bar/beam element...' % eid)
            if debug:  # pragma: no cover
                print('eid=%s is not a valid bar/beam element...' % eid)
            continue
        #unused_ieid = self.eid_map[eid]
        elem = model.elements[eid]
        pid_ref = elem.pid_ref
        if pid_ref is None:
            pid_ref = model.Property(elem.pid)
        assert not isinstance(pid_ref, integer_types), elem

        ptype = pid_ref.type
        bar_type = get_bar_type(ptype, pid_ref)

        if debug:  # pragma: no cover
            print('%s' % elem)
            print('  bar_type = %s' % bar_type)
        found_bar_types.add(bar_type)

        (nid1, nid2) = elem.node_ids
        bar_nids.update([nid1, nid2])
        node1 = model.nodes[nid1]
        node2 = model.nodes[nid2]
        n1 = node1.get_position()
        n2 = node2.get_position()

        # wa/wb are not considered in i_offset
        # they are considered in ihat
        i = n2 - n1
        Li = norm(i)
        ihat = i / Li

        if elem.pa != 0:
            nid_release_map[nid1].append((eid, elem.pa))
        if elem.pb != 0:
            nid_release_map[nid2].append((eid, elem.pb))

        if isinstance(elem.offt, int):
            continue
        unused_v, wa, wb, xform = rotate_v_wa_wb(model, elem, n1, n2, node1,
                                                 node2, ihat, i, eid, Li,
                                                 model.log)
        if wb is None:
            # one or more of v, wa, wb are bad
            continue

        yhat = xform[1, :]
        zhat = xform[2, :]

        ## concept has a GOO

        #if debug:  # pragma: no cover
        #print('  centroid = %s' % centroid)
        #print('  ihat = %s' % ihat)
        #print('  yhat = %s' % yhat)
        #print('  zhat = %s' % zhat)
        #print('  scale = %s' % scale)
        #if eid == 616211:
        #print('  check - eid=%s yhat=%s zhat=%s v=%s i=%s n%s=%s n%s=%s' % (
        #eid, yhat, zhat, v, i, nid1, n1, nid2, n2))

        #print('adding bar %s' % bar_type)
        #print('   centroid=%s' % centroid)
        #print('   yhat=%s len=%s' % (yhat, np.linalg.norm(yhat)))
        #print('   zhat=%s len=%s' % (zhat, np.linalg.norm(zhat)))
        #print('   Li=%s scale=%s' % (Li, scale))
        if bar_type not in allowed_types:
            allowed_types_str = ', '.join(allowed_types)
            msg = f'bar_type={bar_type!r} allowed=[{allowed_types_str}]'
            raise RuntimeError(msg)

        if bar_type in BEAM_GEOM_TYPES:
            node0 = add_3d_bar_element(bar_type, ptype, pid_ref, n1 + wa,
                                       n2 + wb, xform, ugrid, node0,
                                       points_list)

        centroid = (n1 + n2) / 2.
        bar_types[bar_type][0].append(eid)
        bar_types[bar_type][1].append((centroid, centroid + yhat * Li * scale))
        bar_types[bar_type][2].append((centroid, centroid + zhat * Li * scale))
    return node0, ugrid, points_list, bar_nids, nid_release_map