Example #1
0
 def test_lawgs_to_plot3d(self):
     """tests write_as_plot3d"""
     lawgs_filename = os.path.join(MODEL_PATH, 'tnd6480.wgs')
     plot3d_filename = os.path.join(MODEL_PATH, 'tnd6480.p3d')
     model = read_lawgs(lawgs_filename, log=None, debug=False)
     model.write_as_plot3d(plot3d_filename)
Example #2
0
    def load_lawgs_geometry(self, lawgs_filename, name='main', plot=True):
        #key = self.case_keys[self.icase]
        #case = self.result_cases[key]
        self.parent.eid_maps[name] = {}
        self.parent.nid_maps[name] = {}

        skip_reading = self.parent._remove_old_geometry(lawgs_filename)
        if skip_reading:
            return

        model = read_lawgs(lawgs_filename, log=self.parent.log, debug=False)
        self.parent.model_type = model.model_type

        nodes, elements, regions = model.get_points_elements_regions()
        self.parent.nnodes = len(nodes)
        self.parent.nelements = len(elements)

        nodes = array(nodes, dtype='float32')
        elements = array(elements, dtype='int32')

        #print("nNodes = ",self.nnodes)
        #print("nElements = ", self.nelements)

        self.parent.grid.Allocate(self.parent.nelements, 1000)

        points = vtk.vtkPoints()
        points.SetNumberOfPoints(self.parent.nnodes)
        self.parent.nid_map = {}

        assert len(nodes) > 0, len(nodes)
        assert len(elements) > 0, len(elements)
        for nid, node in enumerate(nodes):
            points.InsertPoint(nid, *node)

        elem = vtkQuad()
        etype = elem.GetCellType()
        for unused_eid, element in enumerate(elements):
            (p1, p2, p3, p4) = element
            elem = vtkQuad()
            pts = elem.GetPointIds()
            pts.SetId(0, p1)
            pts.SetId(1, p2)
            pts.SetId(2, p3)
            pts.SetId(3, p4)
            self.parent.grid.InsertNextCell(etype, elem.GetPointIds())

        self.parent.grid.SetPoints(points)
        self.parent.grid.Modified()
        if hasattr(self.parent.grid, 'Update'):
            self.parent.grid.Update()

        # loadCart3dResults - regions/loads
        #self.scalarBar.VisibilityOn()
        #self.scalarBar.Modified()

        self.parent.isubcase_name_map = {1: ['LaWGS', '']}
        cases = {}
        ID = 1

        #print("nElements = %s" % nElements)
        form, cases = self._fill_lawgs_case(cases, ID, nodes, elements,
                                            regions)
        self.parent._finish_results_io2(form, cases)
Example #3
0
    def load_lawgs_geometry(self, lawgs_filename, name='main', plot=True):
        #key = self.case_keys[self.icase]
        #case = self.result_cases[key]
        self.eid_maps[name] = {}
        self.nid_maps[name] = {}

        skip_reading = self._remove_old_geometry(lawgs_filename)
        if skip_reading:
            return

        model = read_lawgs(lawgs_filename, log=self.log, debug=False)
        self.model_type = model.model_type

        nodes, elements, regions = model.get_points_elements_regions()
        self.nNodes = len(nodes)
        self.nElements = len(elements)

        nodes = array(nodes, dtype='float32')
        elements = array(elements, dtype='int32')

        #print("nNodes = ",self.nNodes)
        #print("nElements = ", self.nElements)

        self.grid.Allocate(self.nElements, 1000)
        #self.gridResult.SetNumberOfComponents(self.nElements)

        points = vtk.vtkPoints()
        points.SetNumberOfPoints(self.nNodes)
        #self.gridResult.Allocate(self.nNodes, 1000)
        #vectorReselt.SetNumberOfComponents(3)
        self.nid_map = {}
        #elem.SetNumberOfPoints(nNodes)
        if 0:
            fraction = 1. / self.nNodes  # so you can color the nodes by ID
            for nid, node in sorted(iteritems(nodes)):
                points.InsertPoint(nid - 1, *node)
                self.gridResult.InsertNextValue(nid * fraction)
                #print(str(element))

                #elem = vtk.vtkVertex()
                #elem.GetPointIds().SetId(0, i)
                #self.aQuadGrid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())
                #vectorResult.InsertTuple3(0, 0.0, 0.0, 1.0)

        assert len(nodes) > 0, len(nodes)
        assert len(elements) > 0, len(elements)
        for nid, node in enumerate(nodes):
            points.InsertPoint(nid, *node)

        elem = vtkQuad()
        etype = elem.GetCellType()
        for eid, element in enumerate(elements):
            (p1, p2, p3, p4) = element
            elem = vtkQuad()
            pts = elem.GetPointIds()
            pts.SetId(0, p1)
            pts.SetId(1, p2)
            pts.SetId(2, p3)
            pts.SetId(3, p4)
            self.grid.InsertNextCell(etype, elem.GetPointIds())

        self.grid.SetPoints(points)
        #self.grid.GetPointData().SetScalars(self.gridResult)
        #print(dir(self.grid) #.SetNumberOfComponents(0))
        #self.grid.GetCellData().SetNumberOfTuples(1);
        #self.grid.GetCellData().SetScalars(self.gridResult)
        self.grid.Modified()
        if hasattr(self.grid, 'Update'):
            self.grid.Update()

        # loadCart3dResults - regions/loads
        #self.scalarBar.VisibilityOn()
        #self.scalarBar.Modified()

        self.isubcase_name_map = {1: ['LaWGS', '']}
        cases = {}
        ID = 1

        #print("nElements = %s" % nElements)
        form, cases = self._fill_lawgs_case(cases, ID, nodes, elements, regions)
        self._finish_results_io2(form, cases)