def test_bedge_1(self): """tests the m3 model""" log = get_logger(level='warning') bedge_filename = os.path.join(TEST_PATH, 'm3.bedge') bdf_filename = os.path.join(TEST_PATH, 'm3.bdf') fixed_points_filename = os.path.join(TEST_PATH, 'm3.xyz') model = read_bedge(bedge_filename, beta_reverse=179.7, log=log, debug=False) model2 = read_bedge(bedge_filename, beta_reverse=179.7, log=log, debug=False) assert len(model.nodes) == 858, 'nodes=%s' % len(model.nodes) assert len(model.bars) == 858, 'nbars=%s' % len(model.bars) model.write_nastran(bdf_filename) model.write_fixed_points(fixed_points_filename) bedge_filename_out = os.path.join(TEST_PATH, 'm3.bedge_out') model.merge_bedge(model2, bedge_filename_out) export_to_bedge(bedge_filename_out, model.nodes, model.grid_bc, model.curves, model.subcurves, axis=1, log=model.log) os.remove(bdf_filename) os.remove(fixed_points_filename) os.remove(bedge_filename_out)
def test_bedge_1(self): """tests the m3 model""" bedge_filename = os.path.join(test_path, 'm3.bedge') bdf_filename = os.path.join(test_path, 'm3.bdf') model = read_bedge(bedge_filename, beta_reverse=179.7, log=None, debug=False) model.write_nastran(bdf_filename) assert len(model.nodes) == 858, 'nodes=%s' % len(model.nodes) assert len(model.bars) == 858, 'nbars=%s' % len(model.bars) os.remove(bdf_filename)
def load_bedge_geometry(self, bedge_filename, name='main', plot=True): #skip_reading = self.remove_old_openfoam_geometry(openfoam_filename) #if skip_reading: # return self.gui.modelType = 'bedge' model = read_bedge(bedge_filename) self.gui.log.info('bedge_filename = %s' % bedge_filename) nnodes = model.nodes.shape[0] nbars = model.bars.shape[0] nelements = nbars nodes = model.nodes self.gui.nelements = nelements self.gui.nnodes = nnodes self.gui.log.debug("nNodes = %s" % self.gui.nnodes) self.gui.log.debug("nElements = %s" % self.gui.nelements) assert nelements > 0, nelements black = (0., 0., 0.) self.gui.create_alternate_vtk_grid('nodes', color=black, line_width=5, opacity=1., point_size=3, representation='point') alt_grid = self.gui.alt_grids['nodes'] alt_grid.Allocate(nnodes, 1000) grid = self.gui.grid grid.Allocate(self.gui.nelements, 1000) points = numpy_to_vtk_points(nodes) mmax = np.amax(nodes, axis=0) mmin = np.amin(nodes, axis=0) unused_dim_max = (mmax - mmin).max() self.gui.log.info('max = %s' % mmax) self.gui.log.info('min = %s' % mmin) #print('dim_max =', dim_max) #self.update_axes_length(dim_max) etype = 1 # vtk.vtkVertex().GetCellType() #elements = np.arange(0, len(nodes), dtype='int32') #assert len(elements) == len(nodes) #create_vtk_cells_of_constant_element_type(alt_grid, elements, etype) for inode, unused_node in enumerate(nodes): elem = vtk.vtkVertex() elem.GetPointIds().SetId(0, inode) alt_grid.InsertNextCell(etype, elem.GetPointIds()) bars = model.bars etype = 3 # vtkLine().GetCellType() create_vtk_cells_of_constant_element_type(grid, bars, etype) self.gui.nelements = nelements alt_grid.SetPoints(points) grid.SetPoints(points) grid.Modified() if hasattr(grid, 'Update'): # pragma: no cover grid.Update() #print("updated grid") # loadBedgeResults - regions/loads #self.TurnTextOn() self.gui.scalarBar.VisibilityOn() self.gui.scalarBar.Modified() self.gui.isubcase_name_map = {1: ['AFLR BEDGE', '']} cases = OrderedDict() ID = 1 self.gui._add_alt_actors(self.gui.alt_grids) form, cases = self._fill_bedge_case(bedge_filename, cases, ID, nnodes, nelements, model) if plot: self.gui._finish_results_io2(form, cases)