Ejemplo n.º 1
0
 def test_grid_quadratic_triangle(self):
     """Test the mesh class functions on a quadratic triangle mesh."""
     ref_vertices = quadratic_triangle_vertices
     ref_cells = quadratic_triangle_cells
     ref_cell_sets = quadratic_triangle_cell_sets
     mocmg.initialize()
     mesh = mocmg.mesh.GridMesh(ref_vertices,
                                ref_cells,
                                ref_cell_sets,
                                name="quad_tri_name")
     self.assertEqual(mesh.vertices, ref_vertices)
     self.assertEqual(mesh.cells, ref_cells)
     self.assertEqual(mesh.cell_sets, ref_cell_sets)
     # get_cells
     cell_set = mesh.get_cells("DISK")
     self.assertTrue(
         np.array_equal(cell_set, quadratic_triangle_cell_sets["DISK"]))
     # get_cell_area
     cell_area_ref = 0.261949
     cell_area = mesh.get_cell_area(2)
     self.assertAlmostEqual(cell_area, cell_area_ref, 6)
     # get_set_area
     set_area_ref = 3.1391725
     set_area = mesh.get_set_area("DISK")
     self.assertAlmostEqual(set_area, set_area_ref, 6)
     # name
     self.assertEqual(mesh.name, "quad_tri_name")
Ejemplo n.º 2
0
 def test_grid_linear_triangle(self):
     """Test the mesh class functions on a linear triangle mesh."""
     ref_vertices = linear_triangle_vertices
     ref_cells = linear_triangle_cells
     ref_cell_sets = linear_triangle_cell_sets
     mocmg.initialize()
     mesh = mocmg.mesh.GridMesh(ref_vertices, ref_cells, ref_cell_sets)
     self.assertEqual(mesh.vertices, ref_vertices)
     self.assertEqual(mesh.cells, ref_cells)
     self.assertEqual(mesh.cell_sets, ref_cell_sets)
     # get_cells
     cell_set = mesh.get_cells("DISK")
     self.assertTrue(
         np.array_equal(cell_set, linear_triangle_cell_sets["DISK"]))
     # Try w/ name that doesnt exist.
     with self.assertRaises(SystemExit):
         cell_set = mesh.get_cells("BAD NAME")
     # get_cell_area
     cell_area_ref = 0.210453
     cell_area = mesh.get_cell_area(1)
     self.assertAlmostEqual(cell_area, cell_area_ref, 6)
     # Try will cell that doesnt exist
     with self.assertRaises(SystemExit):
         cell_area = mesh.get_cell_area(-1)
     # get_set_area
     set_area_ref = 2.828427
     set_area = mesh.get_set_area("DISK")
     self.assertAlmostEqual(set_area, set_area_ref, 6)
     # get_vertices_for_cells
     verts_from_cells = mesh.get_vertices_for_cells([1, 2, 3])
     verts_from_cells_ref = [[1, 16, 13], [9, 16, 1], [12, 15, 4]]
     for i, vset in enumerate(verts_from_cells_ref):
         for j, v in enumerate(vset):
             self.assertEqual(v, verts_from_cells[i][j])
     # cell that doesnt exist
     with self.assertRaises(SystemExit):
         verts_from_cells = mesh.get_vertices_for_cells([1111111])
     # get_vertices for cell set
     verts_from_cell_set_name = mesh.get_vertices("DISK")
     verts_from_cell_set_name_ref = [
         1, 3, 4, 7, 9, 10, 11, 12, 13, 14, 15, 16
     ]
     for i, vert in enumerate(verts_from_cell_set_name_ref):
         self.assertEqual(vert, verts_from_cell_set_name[i])
     # cell set that doesnt exist
     with self.assertRaises(SystemExit):
         verts_from_cell_set_name = mesh.get_vertices("NO_NAME")
Ejemplo n.º 3
0
 def test_linear_quadrilateral(self):
     """Test the mesh class functions on a linear quadrilateral mesh."""
     ref_vertices = linear_quadrilateral_vertices
     ref_cells = linear_quadrilateral_cells
     ref_cell_sets = linear_quadrilateral_cell_sets
     mocmg.initialize()
     mesh = mocmg.mesh.Mesh(ref_vertices, ref_cells, ref_cell_sets)
     self.assertEqual(mesh.vertices, ref_vertices)
     self.assertEqual(mesh.cells, ref_cells)
     self.assertEqual(mesh.cell_sets, ref_cell_sets)
     # get_cells
     cell_set = mesh.get_cells("DISK")
     self.assertTrue(np.array_equal(cell_set, linear_quadrilateral_cell_sets["DISK"]))
     # get_cell_area
     cell_area_ref = 0.0874078
     cell_area = mesh.get_cell_area(1)
     self.assertAlmostEqual(cell_area, cell_area_ref, 6)
     # get_set_area
     set_area_ref = 3.0614675
     set_area = mesh.get_set_area("DISK")
     self.assertAlmostEqual(set_area, set_area_ref, 6)
Ejemplo n.º 4
0
 def test_quadratic_quadrilateral(self):
     """Test the mesh class functions on a quadratic quadrilateral mesh."""
     ref_vertices = quadratic_quadrilateral_vertices
     ref_cells = quadratic_quadrilateral_cells
     ref_cell_sets = quadratic_quadrilateral_cell_sets
     mocmg.initialize()
     mesh = mocmg.mesh.Mesh(ref_vertices, ref_cells, ref_cell_sets)
     self.assertEqual(mesh.vertices, ref_vertices)
     self.assertEqual(mesh.cells, ref_cells)
     self.assertEqual(mesh.cell_sets, ref_cell_sets)
     # get_cells
     cell_set = mesh.get_cells("DISK")
     self.assertTrue(np.array_equal(cell_set, quadratic_quadrilateral_cell_sets["DISK"]))
     # get_cell_area
     cell_area_ref = 0.7847974
     cell_area = mesh.get_cell_area(1)
     self.assertAlmostEqual(cell_area, cell_area_ref, 6)
     # get_set_area
     set_area_ref = 3.1391907
     set_area = mesh.get_set_area("DISK")
     self.assertAlmostEqual(set_area, set_area_ref, 6)
Ejemplo n.º 5
0
        gmsh.model.mesh.optimize("HighOrderElastic")

    gmsh.fltk.run()

    # Convert mesh to XDMF
    lcstr = f"{lc:.2f}"
    lcstr = lcstr.replace(".", "p")
    gmsh.write("p1a_" + lcstr + ".inp")
    gmsh.finalize()
    mesh = mocmg.mesh.read_abaqus_file("p1a_" + lcstr + ".inp")

    # Area info
    print("\nArea info")
    num_cells = mesh.n_cells()
    print("Number of cells: ", num_cells)
    total_mesh_area = mesh.get_set_area("GRID_L1_1_1")
    uo2_mesh_area = mesh.get_set_area("MATERIAL_UO2-3.1")
    gap_mesh_area = mesh.get_set_area("MATERIAL_GAP")
    clad_mesh_area = mesh.get_set_area("MATERIAL_CLAD")
    mod_mesh_area = mesh.get_set_area("MATERIAL_MODERATOR")

    total_area = 1.26**2
    uo2_area = np.pi * R2_f**2
    gap_area = np.pi * (R1_f**2 - R2_f**2)
    clad_area = np.pi * (R0_f**2 - R1_f**2)
    mod_area = total_area - uo2_area - gap_area - clad_area

    print(f"\nTotal area (analytic): {total_area}")
    print(f"Total area (computed): {total_mesh_area}")
    print(
        f"Total area error: {100*(total_mesh_area - total_area)/total_area} %\n"
Ejemplo n.º 6
0
    gmsh.fltk.run()

    # Mesh
    gmsh.model.mesh.setSize(gmsh.model.getEntities(0), lc)
    gmsh.option.setNumber("Mesh.ElementOrder", 2)
    gmsh.option.setNumber("Mesh.HighOrderOptimize", 2)
    gmsh.model.mesh.generate(2)
    gmsh.fltk.run()

    gmsh.write("c5g7.inp")
mesh = mocmg.mesh.read_abaqus_file("c5g7.inp")
# gridmesh = mocmg.mesh.make_gridmesh(mesh)
# mocmg.mesh.write_xdmf_file("c5g7.xdmf", mesh)
ncells = mesh.n_cells()
print("Number of cells: ", ncells)
total_area = 0.0
for i in range(1, 4):
    for j in range(1, 4):
        total_area = total_area + mesh.get_set_area(f"GRID_L1_0{i}_0{j}")
uo2 = mesh.get_set_area("MATERIAL_UO2-3.3")
mox70 = mesh.get_set_area("MATERIAL_MOX-7.0")
mox43 = mesh.get_set_area("MATERIAL_MOX-4.3")
mox87 = mesh.get_set_area("MATERIAL_MOX-8.7")
fis = uo2 + mox70 + mox43 + mox87
print(f"Total mesh area: {total_area}")
print("Total mesh area error: ", total_area - 64.26 ** 2)
print(f"Fissile mesh area: {fis}")
print("Fissile mesh area error: ", fis - pi * 0.54 ** 2 * (17 ** 2 - 25) * 4, "\n")

gmsh.finalize()