def create_matrix(mesh, thickness): """ This method creates elements that are similar to the cohesive elements except that they have a finite width. The cohesive elements are made thicker by pulling them apart in the normal direction of the cohesive element. :param thickness: Thickness of the generated elements :type thickness: Float :param mesh: The mesh :type mesh: :class:`Mesh` """ print("create_matrix is EXPERIMENTAL!") corner_sets = ["x0y0z0", "x0y0z1", "x0y1z0", "x0y1z1", "x1y0z0", "x1y0z1", "x1y1z0", "x1y1z1"] edge_sets = ["x0y1", "x0z1", "x0y0", "x0z0", "x1y0", "x1z1", "x1y1", "x1z0", "y0z1", "y0z0", "y1z0", "y1z1"] face_sets = ["x0", "x1", "y0", "y1", "z0", "z1"] # Loop over every cohesive element set: create_cohesive_elements(mesh) normal_vec = {} # Pre calculate the normals for element_set_name in mesh.element_sets.keys(): if "coh_face" in element_set_name: element_set = mesh.element_sets[element_set_name] for element_id in element_set.ids: normal_vec[element_id] = _calculate_normal( mesh, mesh.elements[element_id]) for element_set_name in mesh.element_sets.keys(): if "coh_face" in element_set_name: node_already_moved = [] element_set = mesh.element_sets[element_set_name] # Loop over elements in face set for element_id in element_set.ids: element = mesh.elements[element_id] # Loop over the nodes in the element for i, node_id in enumerate(element.vertices): if node_id in node_already_moved: continue node_already_moved.append(node_id) node = mesh.nodes[node_id] r = find_displacement_vector(mesh, node_id, corner_sets, edge_sets, face_sets, normal_vec[element_id], thickness) node.x += r[0] node.y += r[1] node.z += r[2]
def test_export_to_oofem(self): """Test Phons exporter for oofem files.""" export_to_oofem("test_file.in", self.mesh, write_2d_elements=True) export_to_oofem("test_file.in", self.mesh, write_2d_elements=False) create_cohesive_elements(self.mesh, 3) export_to_oofem("test_file.in", self.mesh, write_2d_elements=True) export_to_oofem("test_file.in", self.mesh, write_2d_elements=False)
def test_create_cohesive_elements(self): create_cohesive_elements(self.mesh, mesh_dimension=3) export_to_abaqus("n10-id1_coh.inp", self.mesh, write_2d_elements=False) self.assertEqual(len(self.mesh.element_sets["cohes9_2"].ids), 6) #self.assertTrue(filecmp.cmp("n10-id1_coh.inp", # os.path.join(__location__, "mesh_test_files/n10-id1_coh_ref.inp"))) create_cohesive_elements(self.mesh_2d, mesh_dimension=2) export_to_abaqus("n10-id1_2d_coh.inp", self.mesh_2d, write_2d_elements=True)
def test_create_cohesive_elements(self): mesh_dim = 2 create_cohesive_elements(self.mesh, mesh_dim) # One cohesive zone element should be created self.assertEqual(len(self.mesh.element_sets["cohes1_2"].ids), 1) # There should be six nodes (2 nodes duplicated) self.assertEqual(len(self.mesh.nodes), 6)
from phon.io.read.read_from_abaqus_inp import read_from_abaqus_inp from phon.io.write.export_to_abaqus import export_to_abaqus from phon.mesh_tools.create_cohesive_elements import create_cohesive_elements inputfile = "../test/mesh_test_files/n10-id1.inp" mesh = read_from_abaqus_inp(inputfile, verbose=0) create_cohesive_elements(mesh, 3) export_to_abaqus("n10-id1_coh.inp", mesh, write_2d_elements=False)
requiredNamed.add_argument("-b", "--basefilename", help="The basename of the files, that is everything before the " "grain id and the file extension.", required=True) requiredNamed.add_argument("-n", "--n_grains", help="The number of total grains, you should have " "one .msh file for each grain.", required=True, type=int) requiredNamed.add_argument('-o', '--output', choices=["abaqus", "oofem"], help='Software to export the mesh to.', required=True) parser.add_argument("-s", '--scale', help="Scale to scale all the nodes with.", type=float) parser.add_argument('-v', '--verbose', action='count', help="Level of verbosity, -v for level 1, -vv for level 2 etc.", default=0) args = parser.parse_args() mesh = read_from_gmsh(args.basefilename, args.n_grains, args.verbose) create_cohesive_elements(mesh, mesh_dimension=3) # Rescale the RVE: if args.scale: for node_id, node in mesh.nodes.items(): node.c *= args.scale print("Exporting to " + args.output + "...") if args.output == "abaqus": export_to_abaqus(ntpath.basename(args.basefilename) + "_coh.inp", mesh, write_2d_elements=False) if args.output == "oofem": export_to_oofem(ntpath.basename(args.basefilename) + "_coh.in", mesh, write_2d_elements=False) print("Done!")
from phon.io_tools.read.read_from_abaqus_inp import read_from_abaqus_inp from phon.io_tools.write.export_to_abaqus import export_to_abaqus from phon.mesh_tools.create_cohesive_elements import create_cohesive_elements inputfile = "../test/mesh_test_files/n10-id1.inp" mesh = read_from_abaqus_inp(inputfile, verbose=0) create_cohesive_elements(mesh, 3) export_to_abaqus("n10-id1_coh.inp", mesh, write_2d_elements=False)
parser.add_argument("-s", '--scale', help="Scale to scale all the nodes with.", type=float) parser.add_argument( '-v', '--verbose', action='count', help="Level of verbosity, -v for level 1, -vv for level 2 etc.", default=0) args = parser.parse_args() mesh = read_from_gmsh(args.basefilename, args.n_grains, args.verbose) create_cohesive_elements(mesh, mesh_dimension=3) # Rescale the RVE: if args.scale: for node_id, node in mesh.nodes.items(): node.c *= args.scale print("Exporting to " + args.output + "...") if args.output == "abaqus": export_to_abaqus(ntpath.basename(args.basefilename) + "_coh.inp", mesh, write_2d_elements=False) if args.output == "oofem": export_to_oofem(ntpath.basename(args.basefilename) + "_coh.in", mesh, write_2d_elements=False)
def create_matrix(mesh, thickness, mesh_dimension): """ This method creates elements that are similar to the cohesive elements except that they have a finite width. The cohesive elements are made thicker by pulling them apart in the normal direction of the cohesive element. :param thickness: Thickness of the generated elements :type thickness: Float :param mesh: The mesh :type mesh: :class:`Mesh` :param mesh_dimension: The dimension of the mesh :type mesh_dimension: Int """ logger.warning("Method does currently only move the nodes in the " "interface between the grains. This means that excessive thickness " "will lead to bad mesh quality.") corner_sets = ["x0y0z0", "x0y0z1", "x0y1z0", "x0y1z1", "x1y0z0", "x1y0z1", "x1y1z0", "x1y1z1"] edge_sets = ["x0y1", "x0z1", "x0y0", "x0z0", "x1y0", "x1z1", "x1y1", "x1z0", "y0z1", "y0z0", "y1z0", "y1z1"] face_sets = ["x0", "x1", "y0", "y1", "z0", "z1"] # Loop over every cohesive element set: create_cohesive_elements(mesh, mesh_dimension) normal_vec = {} # Pre calculate the normals for element_set_name in mesh.element_sets.keys(): if element_set_name.startswith("coh_face"): element_set = mesh.element_sets[element_set_name] for element_id in element_set.ids: normal_vec[element_id] = _calculate_normal( mesh, mesh.elements[element_id], mesh_dimension) for element_set_name in mesh.element_sets.keys(): if "coh_face" in element_set_name: node_already_moved = [] element_set = mesh.element_sets[element_set_name] # Loop over elements in face set for element_id in element_set.ids: element = mesh.elements[element_id] # Loop over the nodes in the element for i, node_id in enumerate(element.vertices): if node_id in node_already_moved: continue node_already_moved.append(node_id) node = mesh.nodes[node_id] r = find_displacement_vector(mesh, node_id, corner_sets, edge_sets, face_sets, normal_vec[element_id], thickness) node.c += r