Exemple #1
0
def _run_loads(model, nelements: int, run_loads=True):
    """helper method"""
    if not run_loads:
        return
    assert isinstance(nelements, int), nelements
    #node_ids = None

    #nnodes = model.nnodes
    #node_ids = [None] * nnodes
    try:
        out = model.get_displacement_index_xyz_cp_cd(
            fdtype='float64', idtype='int32', sort_ids=True)
    except ValueError:
        return
    unused_icd_transformi, unused_icp_transformi, unused_xyz_cpi, nid_cp_cd = out
    node_ids = nid_cp_cd[:, 0]
    normals, eids, eid_map = _normals_eid_map(model, nelements, fdtype='float64')

    nsubcases = len(model.subcases)
    if nsubcases == 0:
        load_ids = list(set(list(model.load_combinations) + list(model.loads)))
        for load_id in sorted(load_ids):
            unused_subcase = model.case_control_deck.add_subcase(load_id)
            get_pressure_array(model, load_id, eids, stop_on_failure=True,
                               fdtype='float32')

    load_ids = list(set(list(model.load_combinations) + list(model.loads)))
    for subcase_id in model.subcases:
        get_load_arrays(model, subcase_id, eid_map, node_ids, normals, nid_map=None,
                        fdtype='float32')

    if nsubcases == 0:
        del model.case_control_deck
Exemple #2
0
def _run_loads(model, nelements, run_loads=True):
    """helper method"""
    if not run_loads:
        return
    eid_map = {}
    normals = np.zeros((nelements, 3), dtype='float64')
    ieid = 0
    #node_ids = None

    #nnodes = model.nnodes
    #node_ids = [None] * nnodes
    try:
        out = model.get_displacement_index_xyz_cp_cd(fdtype='float64',
                                                     idtype='int32',
                                                     sort_ids=True)
    except ValueError:
        return
    unused_icd_transformi, unused_icp_transformi, unused_xyz_cpi, nid_cp_cd = out
    node_ids = nid_cp_cd[:, 0]
    eids = []
    for eid, elem in model.elements.items():
        if hasattr(elem, 'Normal'):
            normals[ieid, :] = elem.Normal()
        eid_map[eid] = ieid
        eids.append(eid)
        ieid += 1

    nsubcases = len(model.subcases)
    if nsubcases == 0:
        load_ids = list(set(list(model.load_combinations) + list(model.loads)))
        for load_id in sorted(load_ids):
            unused_subcase = model.case_control_deck.add_subcase(load_id)
            get_pressure_array(model, load_id, eids, stop_on_failure=True)

    load_ids = list(set(list(model.load_combinations) + list(model.loads)))
    for subcase_id in model.subcases:
        get_load_arrays(model,
                        subcase_id,
                        eid_map,
                        node_ids,
                        normals,
                        nid_map=None)

    if nsubcases == 0:
        del model.case_control_deck
Exemple #3
0
    def test_loads(self):
        """tests the ``get_load_arrays`` and ``_reduce_dload_case`` methods"""
        model = BDF(debug=True, log=None, mode='msc')
        subcase_id = 10
        eid_map = None
        node_ids = []
        normals = None
        lines = []
        cc = CaseControlDeck(lines, log=None)
        #print(model.case_control_deck)
        model.case_control_deck = cc
        subcase = cc.create_new_subcase(subcase_id)
        out = get_load_arrays(model,
                              subcase_id,
                              eid_map,
                              node_ids,
                              normals,
                              nid_map=None)
        is_loads, is_temperatures, temperature_data, load_data = out
        assert is_loads is False, is_loads
        assert is_temperatures is False, is_temperatures
        assert temperature_data == (None, None), temperature_data
        assert load_data == (None, None, None), load_data

        key = 'LOAD'
        value = 10
        options = []
        param_type = '???'
        with self.assertRaises(TypeError):
            subcase.add(key, value, options, param_type)

        param_type = 'STRESS-type'
        subcase.add(key, value, options, param_type)

        with self.assertRaises(KeyError):
            get_load_arrays(model,
                            subcase_id,
                            eid_map,
                            node_ids,
                            normals,
                            nid_map=None,
                            stop_on_failure=True)
        #is_loads, is_temperatures, temperature_data, load_data = out
        #assert is_loads is False, is_loads
        #assert is_temperatures is False, is_temperatures
        #assert temperature_data == (None, None), temperature_data
        #assert load_data == (None, None, None), load_data

        dload_case = []
        dloads, scale_factors = model._reduce_dload_case(
            dload_case,
            scale=1.,
            unallowed_dload_ids=None,
            skip_scale_factor0=False,
            msg='')
        assert dloads == [], dloads
        assert scale_factors == [], scale_factors
        del dloads, scale_factors

        # ----------------------------------------------------------------------
        dload_id = 5
        scale = 1.
        scale_factors = [2]
        load_ids = [3]
        dload = model.add_dload(dload_id, scale, scale_factors, load_ids)
        dload_case = [dload]

        with self.assertRaises(KeyError):
            model._reduce_dload_case(dload_case,
                                     scale=1.,
                                     unallowed_dload_ids=None,
                                     skip_scale_factor0=False,
                                     msg='')

        excite_id = 100
        tid = 2
        model.add_tload1(dload_id,
                         excite_id,
                         tid,
                         delay=0,
                         Type='LOAD',
                         us0=0.0,
                         vs0=0.0,
                         comment='')
        with self.assertRaises(KeyError):
            model._reduce_dload_case(dload_case,
                                     scale=1.,
                                     unallowed_dload_ids=None,
                                     skip_scale_factor0=False,
                                     msg='')