Exemple #1
0
    def validate(self):
        msg = ''
        if self.x is None:
            if not isinstance(self.g0, integer_types):
                msg += 'CBEAM eid=%s: x is None, so g0=%s must be an integer' % (self.eid, self.g0)
        else:
            if not isinstance(self.x, (list, np.ndarray)):
                msg += 'CBEAM eid=%s: x=%s and g0=%s, so x must be a list; type(x)=%s' % (
                    self.eid, self.x, self.g0, type(self.x))
        if msg:
            raise ValueError(msg)

        if self.g0 is not None:
            assert isinstance(self.g0, integer_types), 'g0=%s must be an integer' % self.g0
        if self.g0 in [self.ga, self.gb]:
            msg = 'G0=%s cannot be GA=%s or GB=%s' % (self.g0, self.ga, self.gb)
            raise RuntimeError(msg)

        if self.bit is None and self.offt is None:
            msg = 'OFFT/BIT must not be None; offt=%r bit=%s' % (self.offt, self.bit)
            raise RuntimeError(msg)

        if self.offt is not None:
            if isinstance(self.offt, integer_types):
                assert self.offt in [1, 2, 21, 22, 41], 'invalid offt; offt=%i' % self.offt
                raise NotImplementedError('invalid offt; offt=%i' % self.offt)
            elif not isinstance(self.offt, string_types):
                raise SyntaxError('invalid offt expected a string of length 3 '
                                  'offt=%r; Type=%s' % (self.offt, type(self.offt)))
            check_offt(self)
Exemple #2
0
    def get_axes(self, model):
        """
        Gets the axes of a CBAR/CBEAM, while respecting the OFFT flag.

        See
        ---
        ``_rotate_v_wa_wb`` for a description of the OFFT flag.

        TODO: not integrated with CBAR yet...
        """
        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)
Exemple #3
0
    def get_axes(self, model):
        """
        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)