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
RWGNumber_edgeVertexes = readBlitzArrayFromDisk(saveDir + "RWGNumber_edgeVertexes.txt", N_RWG, 2, 'i') RWGNumber_oppVertexes = readBlitzArrayFromDisk(saveDir + "RWGNumber_oppVertexes.txt", N_RWG, 2, 'i') is_closed_surface = readASCIIBlitzIntArray1DFromDisk(saveDir + "is_closed_surface.txt") triangles_surfaces = readASCIIBlitzIntArray1DFromDisk(saveDir + "triangles_surfaces.txt") print(" edgeNumber_triangles construction cumulated time = " + str(time.clock() - t10)) saveDir = saveDir[:-1] return triangles_surfaces, is_closed_surface, RWGNumber_signedTriangles, RWGNumber_edgeVertexes, RWGNumber_oppVertexes if __name__=="__main__": path = './geo' targetName = 'strip' f = 2.12e9 write_geo(path, targetName, 'lc', c/f/10.0) write_geo(path, targetName, 'lx', 0.07) write_geo(path, targetName, 'ly', 0.07) write_geo(path, targetName, 'lz', 0.02) write_geo(path, targetName, 'w', 0.02) executeGmsh(path, targetName, 0) targetDimensions_scaling_factor = 1.0 z_offset = 0.0 t0 = time.clock() #vertexes_coord, triangle_vertexes, triangles_physicalSurface = read_mesh_GMSH_1(os.path.join(path, targetName + '.msh'), targetDimensions_scaling_factor, z_offset) vertexes_coord, triangle_vertexes, triangles_physicalSurface = read_mesh_GMSH_2(os.path.join(path, targetName + '.msh'), targetDimensions_scaling_factor, z_offset) print("reading mesh time = " + str(time.clock() - t0) + " seconds") triangles_surfaces_C, is_closed_surface_C, RWGNumber_signedTriangles_C, RWGNumber_edgeVertexes_C, RWGNumber_oppVertexes_C = edges_computation_C(triangle_vertexes, vertexes_coord) print(" Number of RWG = " + str(RWGNumber_oppVertexes_C.shape[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)