Example #1
0
def readMesh(path, name, params_simu):
    if params_simu.meshFormat == 'GMSH':
        #vertexes_coord, triangle_vertexes, triangles_physicalSurface = read_mesh_GMSH_1(os.path.join(path, name), params_simu.targetDimensions_scaling_factor, params_simu.z_offset)
        vertexes_coord, triangle_vertexes, triangles_physicalSurface = read_mesh_GMSH_2(os.path.join(path, name), params_simu.targetDimensions_scaling_factor, params_simu.z_offset)
    elif params_simu.meshFormat == 'GiD':
        vertexes_coord, triangle_vertexes, triangles_physicalSurface = read_mesh_GiD(os.path.join(path, name), params_simu.targetDimensions_scaling_factor, params_simu.z_offset)
    elif params_simu.meshFormat == 'ANSYS':
        vertexes_coord, triangle_vertexes, triangles_physicalSurface = read_mesh_ANSYS(path, name, params_simu.targetDimensions_scaling_factor, params_simu.z_offset)
    else:
        print("setup_MLFMA_mesh.py : error on the mesh format. Enter a correct one please.")
    return vertexes_coord, triangle_vertexes, triangles_physicalSurface
Example #2
0
    def constructFromGmshFile(self):
        # we check to see if there is a delta_gap parameter in the geo file
        if self.meshFormat == 'GMSH':
            self.DELTA_GAP, ORIGIN_POINT, END_POINT = findDeltaGap(
                self.path, self.targetName)
            if self.DELTA_GAP:
                ## a delta gap should always be defined in the *.geo file as
                ## '// delta_gap' written aside the Line we want to be the delta gap
                self.delta_gap = [ORIGIN_POINT, END_POINT]
                self.delta_gap_indexes = [ORIGIN_POINT - 1, END_POINT - 1]
                print("There is a delta gap in file " + str(self.geoName))
                print("The extremities of the delta gap are points " +
                      str(self.delta_gap))
        else:
            # else we don't look for a delta gap in the file
            pass
        print("  Python construction of the Mesh object")
        sys.stdout.flush()

        print("  reading " + os.path.join(self.path, self.name) + "...")
        t0 = time.clock()
        if self.meshFormat == 'GMSH':
            #self.vertexes_coord, self.triangle_vertexes, self.triangles_physicalSurface = read_mesh_GMSH_1(os.path.join(self.path, self.name), self.targetDimensions_scaling_factor, self.z_offset)
            self.vertexes_coord, self.triangle_vertexes, self.triangles_physicalSurface = read_mesh_GMSH_2(
                os.path.join(self.path, self.name),
                self.targetDimensions_scaling_factor, self.z_offset)
        elif self.meshFormat == 'GiD':
            self.vertexes_coord, self.triangle_vertexes, self.triangles_physicalSurface = read_mesh_GiD(
                os.path.join(self.path, self.name),
                self.targetDimensions_scaling_factor, self.z_offset)
        elif self.meshFormat == 'ANSYS':
            self.vertexes_coord, self.triangle_vertexes, self.triangles_physicalSurface = read_mesh_ANSYS(
                self.path, self.name, self.targetDimensions_scaling_factor,
                self.z_offset)
        else:
            print(
                "meshClass.py : error on the mesh format. Enter a correct one please."
            )
        self.time_reading = time.clock() - t0
        print("reading mesh time = " + str(self.time_reading) + " seconds")
        self.T = self.triangle_vertexes.shape[0]
        print("  number of triangles = " + str(self.T))
        print("  edges classification...")
        sys.stdout.flush()

        if self.languageForMeshConstruction == "C" or self.languageForMeshConstruction == "C++":
            t0 = time.clock()
            #self.triangles_surfaces, self.IS_CLOSED_SURFACE, self.RWGNumber_signedTriangles, self.RWGNumber_edgeVertexes, self.RWGNumber_oppVertexes = edges_computation_C_old(self.triangle_vertexes, self.vertexes_coord, self.path)
            self.triangles_surfaces, self.IS_CLOSED_SURFACE, self.RWGNumber_signedTriangles, self.RWGNumber_edgeVertexes, self.RWGNumber_oppVertexes, self.triangle_vertexes = edges_computation_C(
                self.triangle_vertexes, self.vertexes_coord, self.path)
            self.N_RWG = self.RWGNumber_edgeVertexes.shape[0]
            self.S = len(self.IS_CLOSED_SURFACE)
            print("  test of the closed surfaces : " +
                  str(self.IS_CLOSED_SURFACE))
            if self.meshFormat == 'GMSH':
                if self.DELTA_GAP:
                    # here we must create a C++ function that calculates the mid point of each RWG and sees
                    # if the RWG is part of the delta gap. That function would use vertexes_coord and
                    # self.RWGNumber_edgeVertexes as inputs.
                    pass
            self.time_edges_classification = time.clock() - t0
            print("  edges classification cumulated time = " +
                  str(self.time_edges_classification) + " seconds")
            self.time_effective_RWG_functions_computation = self.time_edges_classification
            print("    Number of RWG = " + str(self.N_RWG))

        else:
            t0 = time.clock()
            edgeNumber_vertexes, edgeNumber_triangles, triangle_adjacentTriangles, is_triangle_adjacentTriangles_via_junction = edges_computation(
                self.triangle_vertexes, self.vertexes_coord)
            self.time_edges_classification = time.clock() - t0
            print("  edges classification cumulated time = " +
                  str(self.time_edges_classification) + " seconds")

            print("  reordering triangles for normals coherency...")
            sys.stdout.flush()
            t0 = time.clock()
            self.triangles_surfaces = reorder_triangle_vertexes(
                triangle_adjacentTriangles,
                is_triangle_adjacentTriangles_via_junction,
                self.triangle_vertexes, self.vertexes_coord)
            self.S = max(self.triangles_surfaces) + 1
            self.time_reordering_normals = time.clock() - t0
            print("  cumulated time = " + str(self.time_reordering_normals) +
                  " seconds")

            print("  checking the closed and open surfaces...")
            sys.stdout.flush()
            t0 = time.clock()
            self.IS_CLOSED_SURFACE, self.connected_surfaces, self.potential_closed_surfaces = is_surface_closed(
                self.triangles_surfaces, edgeNumber_triangles)
            print("  test of the closed surfaces : " +
                  str(self.IS_CLOSED_SURFACE))
            print("  connected surfaces : " + str(self.connected_surfaces))
            print("  potential closed surfaces : " +
                  str(self.potential_closed_surfaces))

            print(
                "  computing the effective RWG functions and their opposite vertexes..."
            )
            sys.stdout.flush()
            t0 = time.clock()
            self.RWGNumber_signedTriangles, self.RWGNumber_edgeVertexes, self.N_edges, self.N_RWG = RWGNumber_signedTriangles_computation(
                edgeNumber_triangles, edgeNumber_vertexes,
                self.triangles_surfaces, self.IS_CLOSED_SURFACE,
                self.triangle_vertexes, self.vertexes_coord)
            del edgeNumber_vertexes
            self.RWGNumber_oppVertexes = RWGNumber_oppVertexes_computation(
                self.RWGNumber_signedTriangles, self.RWGNumber_edgeVertexes,
                self.triangle_vertexes)
            # memory-economic way for computing average_RWG_length
            self.time_effective_RWG_functions_computation = time.clock() - t0
            print("  effective RWG functions computation cumulated time = " +
                  str(self.time_effective_RWG_functions_computation))
            print("  Number of edges = " + str(self.N_edges))
            print("  Number of RWG = " + str(self.N_RWG))
            sys.stdout.flush()

        self.compute_RWG_CFIE_OK()
        if self.N_RWG < 1e4:
            stride = 1
        else:
            stride = self.N_RWG / 100
        self.average_RWG_length = compute_RWG_meanEdgeLength(
            self.vertexes_coord, self.RWGNumber_edgeVertexes, stride)