def get_B_vector_point_uvp(u, v, p, elem_ID, elements_3D_counter, elem_type, elem_nodes, faces_ID, nodes_coordenates, flux, faces_from_to): #Instances shape_functions = ShapeFuncions() operations = Operations() this_elem_type = elem_type[elem_ID] number_local_faces = shape_functions.get_number_faces(this_elem_type) this_element_nodes = elem_nodes[elem_ID] faces_ID_Elem = faces_ID[elements_3D_counter] w_local_this_point = shape_functions.get_facet_shape_function( this_elem_type, u, v, p) b_at_point = 0 #Interpolation along all the faces for local_face_counter in range(0, number_local_faces): face_ID = faces_ID_Elem[local_face_counter] w_local_1 = w_local_this_point[local_face_counter] w_real = operations.convert_local_real_Piola( this_elem_type, w_local_1[0, 0], w_local_1[0, 1], w_local_1[0, 2], this_element_nodes, nodes_coordenates) flux_at_face = flux[face_ID] #Takes into account the faces orientation if faces_from_to[face_ID, 1] == elements_3D_counter: flux_at_face = -flux_at_face b_at_point += flux_at_face * w_real return b_at_point
def interpolated_along_line(vol_phys_ID, xyz_list, pre_proc_data, results_path): operations = Operations() mesh_data = pre_proc_data.MeshData get_gauss_points_class = GaussPoints() shape_functions = ShapeFuncions() file_names = File_names() #Mesh data nodes_coordenates = mesh_data.NodesCoordenates elem_tags = mesh_data.ElemTags elem_type = mesh_data.ElemType elem_nodes = mesh_data.ElemNodes number_elements = len(elem_tags) xy_plot = list() field = list() #Reads flux file flux_results_file_name = file_names.flux_results_file_name() full_path = os.path.join(results_path, flux_results_file_name) new_flux = read_numeric_file_numpy(full_path) #Read faces_ID faces_ID_file_name = file_names.get_faces_ID_file_name() full_path = os.path.join(results_path, faces_ID_file_name) data = get_data_from_file(full_path) faces_ID = get_file_block("$faces_ID", "$Endfaces_ID", 0, data, int) #Read faces_from_to from_to_file_name = file_names.faces_from_to_file_name() full_path = os.path.join(results_path, from_to_file_name) faces_from_to = read_numeric_file_numpy(full_path) for xyz in xyz_list: counter = -1 this_element = False for elem_counter in range(0, number_elements): this_elem_type = elem_type[elem_counter] if this_elem_type == 4: counter = counter + 1 if elem_tags[elem_counter][0] in vol_phys_ID: nodes_list = mesh_data.ElemNodes[elem_counter] uvp = operations.convert_real_to_local( elem_counter, this_elem_type, xyz[0], xyz[1], xyz[2], nodes_list, nodes_coordenates) N = shape_functions.get_node_shape_function( this_elem_type, uvp[0], uvp[1], uvp[2]) if max(N) <= 1.0 and min(N) >= 0.0: this_element = True break if this_element: b_at_point = get_B_vector_point_uvp(uvp[0], uvp[1], uvp[2], elem_counter, counter, elem_type, elem_nodes, faces_ID, nodes_coordenates, new_flux, faces_from_to) b_at_point = np.array( [b_at_point[0, 0], b_at_point[1, 0], b_at_point[2, 0]]) field.append(b_at_point) else: b_at_point = np.array([0.0, 0.0, 0.0]) field.append(b_at_point) Gmsh_file_name = file_names.get_B_Gmsh_line_file_name() path = os.path.join(results_path, Gmsh_file_name) Create_Vector_field(xyz_list, field, path, "B Vector") Gmsh_file_name = "line_field.txt" path = os.path.join(results_path, Gmsh_file_name) write_numeric_file_numpy(path, field)