def test_quadrangle_geometry_cell(self, verbose=True): """ Args: verbose: """ v0 = np.array([0.0, 0.0], dtype=real) v1 = np.array([1.0, 0.0], dtype=real) v2 = np.array([1.0, 1.0], dtype=real) v3 = np.array([0.0, 1.0], dtype=real) quadrangle_vertices = np.array([v0, v1, v2, v3], dtype=real).T cell_quadrangle = Shape(ShapeType.QUADRANGLE, quadrangle_vertices) x_c = cell_quadrangle.get_centroid() h_c = cell_quadrangle.get_diameter() v_c = cell_quadrangle.get_volume() if verbose: print("-- centroid :\n{}".format(x_c)) print("-- diameter :\n{}".format(h_c)) print("-- volume :\n{}".format(v_c)) for i in range(4): plt.scatter(quadrangle_vertices[0, i], quadrangle_vertices[1, i], c="b") plt.scatter(x_c[0], x_c[1], c="b") plt.show()
def test_reference_tetrahedron_geometry_cell(self, verbose=True): """ Args: verbose: """ v0 = np.array([0.0, 0.0, 0.0], dtype=real) v1 = np.array([1.0, 0.0, 0.0], dtype=real) v2 = np.array([0.0, 1.0, 0.0], dtype=real) v3 = np.array([0.0, 0.0, 1.0], dtype=real) vertices = np.array([v0, v1, v2, v3], dtype=real).T shape = Shape(ShapeType.TETRAHEDRON, vertices) x_c = shape.get_centroid() h_c = shape.get_diameter() v_c = shape.get_volume() if verbose: print("-- centroid :\n{}".format(x_c)) print("-- diameter :\n{}".format(h_c)) print("-- volume :\n{}".format(v_c)) fig = plt.figure() ax = fig.add_subplot(111, projection="3d") ax.scatter(x_c[0], x_c[1], x_c[2], c="b", marker="o") for i in range(vertices.shape[1]): ax.scatter(vertices[0, i], vertices[1, i], vertices[2, i], c="b", marker="o") plt.show()
def test_polygon_geometry_cell(self, verbose=True): """ Args: verbose: """ v0 = np.array([0.0, 0.0], dtype=real) v1 = np.array([1.0, 0.0], dtype=real) v1p = np.array([1.0, 0.5], dtype=real) v2 = np.array([1.0, 1.0], dtype=real) v2p = np.array([0.5, 1.0], dtype=real) v3 = np.array([0.0, 1.0], dtype=real) polygon_vertices = np.array([v0, v1, v1p, v2, v2p, v3], dtype=real).T shape = Shape(ShapeType.POLYGON, polygon_vertices) x_c = shape.get_centroid() h_c = shape.get_diameter() v_c = shape.get_volume() if verbose: print("-- centroid :\n{}".format(x_c)) print("-- diameter :\n{}".format(h_c)) print("-- volume :\n{}".format(v_c)) for i in range(6): plt.scatter(polygon_vertices[0, i], polygon_vertices[1, i], c="b") plt.scatter(x_c[0], x_c[1], c="b") plt.show()
def test_reference_segment_geometry_face(self, verbose=True): """ Args: verbose: """ v0 = np.array([0.0, 0.0], dtype=real) v1 = np.array([1.0, 0.7], dtype=real) vertices = np.array([v0, v1], dtype=real).T shape = Shape(ShapeType.SEGMENT, vertices) x_c = shape.get_centroid() h_c = shape.get_diameter() v_c = shape.get_volume() if verbose: print("-- centroid :\n{}".format(x_c)) print("-- diameter :\n{}".format(h_c)) print("-- volume :\n{}".format(v_c)) for i in range(2): plt.scatter(vertices[0, i], vertices[1, i], c="b") plt.scatter(x_c[0], x_c[1], c="b") plt.show()
def test_reference_triangle_geometry_cell(self, verbose=True): """ Args: verbose: """ v0 = np.array([+.00000000000000E+00, +.28725932709342E-01], dtype=real) v1 = np.array([+.00000000000000E+00, +.30000000000000E-01], dtype=real) v2 = np.array([+.20769230769231E-03, +.30000000000000E-01], dtype=real) vertices = np.array([v0, v1, v2], dtype=real).T shape = Shape(ShapeType.TRIANGLE, vertices) x_c = shape.get_centroid() h_c = shape.get_diameter() v_c = shape.get_volume() if verbose: print("-- centroid :\n{}".format(x_c)) print("-- diameter :\n{}".format(h_c)) print("-- volume :\n{}".format(v_c)) for i in range(3): plt.scatter(vertices[0, i], vertices[1, i], c="b") plt.scatter(x_c[0], x_c[1], c="b") plt.show()
def test_reference_polyhedron_geometry_cell(self, verbose=True): """ V8 o_______________o V7 /| V6 /| / | o / | V4 o_______________o V5 | | | | V3 | o___________ |__o V2 Z | / | / ^ Y |/ |/ |/ V0 o_______________o V1 0---> X Args: verbose: """ v0 = np.array([0.0, 0.0, 0.0], dtype=real) v1 = np.array([1.0, 0.0, 0.0], dtype=real) v2 = np.array([1.0, 1.0, 0.0], dtype=real) v3 = np.array([0.0, 1.0, 0.0], dtype=real) v4 = np.array([0.0, 0.0, 1.0], dtype=real) v5 = np.array([1.0, 0.0, 1.0], dtype=real) v6 = np.array([0.5, 0.5, 1.0], dtype=real) v7 = np.array([1.0, 1.0, 1.0], dtype=real) v8 = np.array([0.0, 1.0, 1.0], dtype=real) vertices = np.array([v0, v1, v2, v3, v4, v5, v6, v7, v8], dtype=real).T # --- CONNECTIVITY, COUNTER CLOCK WISE # connectivity = [ # [0, 3, 2, 1], # [0, 1, 5, 4], # [1, 2, 7, 5], # [2, 3, 8, 7], # [3, 0, 4, 8], # [4, 5, 6], # [5, 7, 6], # [7, 8, 6], # [8, 4, 6], # ] # --- CONNECTIVIY, CLOCK WISE connectivity = [ [0, 1, 2, 3], [0, 4, 5, 1], [1, 5, 7, 2], [2, 7, 8, 3], [3, 8, 4, 0], [6, 5, 4], [6, 7, 5], [6, 8, 7], [6, 4, 8], ] shape = Shape(ShapeType.POLYHEDRON, vertices, connectivity=connectivity) x_c = shape.get_centroid() h_c = shape.get_diameter() v_c = shape.get_volume() if verbose: print("-- centroid :\n{}".format(x_c)) print("-- diameter :\n{}".format(h_c)) print("-- volume :\n{}".format(v_c)) fig = plt.figure() ax = fig.add_subplot(111, projection="3d") ax.scatter(x_c[0], x_c[1], x_c[2], c="b", marker="o") for i in range(vertices.shape[1]): ax.scatter(vertices[0, i], vertices[1, i], vertices[2, i], c="b", marker="o") plt.show()