Esempio n. 1
0
 def get_quadrangle_volume(vertices: Mat) -> float:
     """
     ================================================================================================================
     Method :
     ================================================================================================================
     Computes the surface of a quadrangle.
     ================================================================================================================
     Parameters :
     ================================================================================================================
     - vertices : the matrix containing the coordinates of the vertices of the quadrangle as vectors.
     ================================================================================================================
     Returns :
     ================================================================================================================
     - quadrangle_volume : the surface of the quadrangle.
     """
     t0 = vertices[0, 1, 2]
     t0 = vertices[0, 3, 2]
     v0 = Triangle.get_triangle_volume(t0)
     v1 = Triangle.get_triangle_volume(t1)
     quadrangle_volume = v0 + v1
     return quadrangle_volume
Esempio n. 2
0
 def __init__(self, vertices: Mat, polynomial_order: int):
     """
     ================================================================================================================
     Class :
     ================================================================================================================
     The Polygon class inherits from the Domain class to specifiy its attributes when the domain is a polygon.
     ================================================================================================================
     Parameters :
     ================================================================================================================
     - vertices : the matrix containing the vertices coordinates as vectors.
     - polynomial_order : the polynomial order of integration over the polygon.
     ================================================================================================================
     Attributes :
     ================================================================================================================
     - centroid : the vector with values containing the center of mass of the polygon.
     - volume : the volume of the polygon.
     - diameter : the diameter of the polygon.
     - quadrature_points : the matrix containing the quadrature points of the polygon.
     - quadrature_weights : the vector containing the quadrature weights of the polygon.
     """
     if not vertices.shape[0] > 4 and not vertices.shape[1] == 2:
         raise TypeError(
             "The domain dimension do not match that of a polygon")
     else:
         barycenter = Domain.get_domain_barycenter_vector(vertices)
         volume = 0.0
         # volume = Polygon.get_polygon_volume(vertices)
         simplicial_sub_domains = Polygon.get_polygon_simplicial_partition(
             vertices, barycenter)
         # sub_domains_centroids = []
         quadrature_points, quadrature_weights = [], []
         for simplicial_sub_domain in simplicial_sub_domains:
             # simplex_centroid = Domain.get_domain_barycenter_vector(simplicial_sub_domain)
             simplex_volume = Triangle.get_triangle_volume(
                 simplicial_sub_domain)
             simplex_quadrature_points, simplex_quadrature_weights = DunavantRule.get_triangle_quadrature(
                 simplicial_sub_domain, simplex_volume, polynomial_order)
             volume += simplex_volume
             quadrature_points.append(simplex_quadrature_points)
             quadrature_weights.append(simplex_quadrature_weights)
             # sub_domains_centroids.append(simplex_centroid)
         # centroid = np.zeros(2,)
         # for sub_domain_centroid in sub_domains_centroids:
         #     centroid += sub_domain_centroid
         # number_of_vertices = vertices.shape[0]
         # centroid = 1.0 / number_of_vertices * centroid
         centroid = Polygon.get_polygon_centroid(vertices, volume)
         diameter = Polygon.get_polygon_diameter(vertices)
         quadrature_points = np.concatenate(quadrature_points, axis=0)
         quadrature_weights = np.concatenate(quadrature_weights, axis=0)
         super().__init__(centroid, volume, diameter, quadrature_points,
                          quadrature_weights)