Ejemplo n.º 1
0
    def test_gui_deflection_csv_01b(self):
        """tests solid_bending_multi_deflection_node.txt with deflection loader"""
        csv_filename = os.path.join(MODEL_PATH, 'solid_bending',
                                    'solid_bending_multi_deflection_node.txt')
        A, nids_index, fmt_dict, headers = load_deflection_csv(csv_filename)
        result_type = 'node'

        header0 = headers[0]
        unused_result0 = A[header0]
        #nrows = result0.shape[0]
        #assert nrows == self.nnodes, 'nrows=%s nnodes=%s' % (nrows, self.nnodes)
        header = header0
        islot = 0
        with self.assertRaises(RuntimeError):
            create_res_obj(islot,
                           headers,
                           header,
                           A,
                           fmt_dict,
                           result_type,
                           dim_max=1.0,
                           xyz_cid0=None,
                           is_deflection=False,
                           is_force=False)

        create_res_obj(islot,
                       headers,
                       header,
                       A,
                       fmt_dict,
                       result_type,
                       dim_max=1.0,
                       xyz_cid0=None,
                       is_deflection=True,
                       is_force=False)
Ejemplo n.º 2
0
    def test_gui_deflection_csv_01b(self):
        """tests solid_bending_multi_deflection_node.txt with deflection loader"""
        csv_filename = os.path.join(MODEL_PATH, 'solid_bending',
                                    'solid_bending_multi_deflection_node.txt')
        A, fmt_dict, headers = load_deflection_csv(csv_filename)
        result_type = 'node'

        header0 = headers[0]
        result0 = A[header0]
        nrows = result0.shape[0]
        #assert nrows == self.nnodes, 'nrows=%s nnodes=%s' % (nrows, self.nnodes)
        header = header0
        islot = 0
        create_res_obj(islot,
                       headers,
                       header,
                       A,
                       fmt_dict,
                       result_type,
                       dim_max=1.0,
                       xyz_cid0=None)
Ejemplo n.º 3
0
    def _add_cases_to_form(self,
                           A,
                           fmt_dict,
                           headers,
                           result_type,
                           out_filename_short,
                           update=True,
                           is_scalar=True,
                           is_deflection=False,
                           is_force=False):
        """
        common method between:
          - _load_csv
          - _load_deflection_csv

        Parameters
        ----------
        A : dict[key] = (n, m) array
            the numpy arrays
            key : str
                the name
            n : int
                number of nodes/elements
            m : int
                secondary dimension
                N/A : 1D array
                3 : deflection
        fmt_dict : dict[header] = fmt
            the format of the arrays
            header : str
                the name
            fmt : str
                '%i', '%f'
        headers : List[str]???
            the titles???
        result_type : str
            'node', 'centroid'
        out_filename_short : str
            the display name
        update : bool; default=True
            update the res_widget

        # A = np.loadtxt('loadtxt_spike.txt', dtype=('float,int'))
        # dtype=[('f0', '<f8'), ('f1', '<i4')])
        # A['f0']
        # A['f1']
        """
        #print('A =', A)
        formi = []
        form = self.gui.get_form()
        icase = len(self.gui.case_keys)
        islot = 0
        for case_key in self.gui.case_keys:
            if isinstance(case_key, tuple):
                islot = case_key[0]
                break

        #assert len(headers) > 0, 'headers=%s' % (headers)
        #assert len(headers) < 50, 'headers=%s' % (headers)
        for header in headers:
            if is_scalar:
                out = create_res_obj(islot,
                                     headers,
                                     header,
                                     A,
                                     fmt_dict,
                                     result_type,
                                     colormap='jet')
            else:
                out = create_res_obj(islot,
                                     headers,
                                     header,
                                     A,
                                     fmt_dict,
                                     result_type,
                                     is_deflection=is_deflection,
                                     is_force=is_force,
                                     dim_max=self.gui.settings.dim_max,
                                     xyz_cid0=self.gui.xyz_cid0,
                                     colormap='jet')
            res_obj, title = out

            #cases[icase] = (stress_res, (subcase_id, 'Stress - isElementOn'))
            #form_dict[(key, itime)].append(('Stress - IsElementOn', icase, []))
            #key = (res_obj, (0, title))
            self.gui.case_keys.append(icase)
            self.gui.result_cases[icase] = (res_obj, (islot, title))
            formi.append((header, icase, []))

            # TODO: double check this should be a string instead of an int
            self.gui.label_actors[icase] = []
            self.gui.label_ids[icase] = set()
            icase += 1
        form.append((out_filename_short, None, formi))

        self.gui.ncases += len(headers)
        #cases[(ID, 2, 'Region', 1, 'centroid', '%i')] = regions
        if update:
            self.gui.res_widget.update_results(form, 'main')