(
        self,
        x0: list[float],
        radii: list[float],
        mesh_size: float | None = None,
        with_volume: bool = True,
        holes=None,
    )
return Ellipsoid(x0, radii, surface_loop, volume, mesh_size=mesh_size)
Creates an ellipsoid with radii around a given midpoint :math:`x_0`.
Creates an ellipsoid with radii around a given midpoint :math:`x_0`.
Creates an ellipsoid with radii around a given midpoint : math : x_0 .
def add_ellipsoid(
        self,
        x0: list[float],
        radii: list[float],
        mesh_size: float | None = None,
        with_volume: bool = True,
        holes=None,
    ):
        """Creates an ellipsoid with radii around a given midpoint :math:`x_0`."""
        if holes is None:
            holes = []

        if holes:
            assert with_volume

        # Add points.
        p = [
            self.add_point(x0, mesh_size=mesh_size),
            self.add_point([x0[0] + radii[0], x0[1], x0[2]], mesh_size=mesh_size),
            self.add_point([x0[0], x0[1] + radii[1], x0[2]], mesh_size=mesh_size),
            self.add_point([x0[0], x0[1], x0[2] + radii[2]], mesh_size=mesh_size),
            self.add_point([x0[0] - radii[0], x0[1], x0[2]], mesh_size=mesh_size),
            self.add_point([x0[0], x0[1] - radii[1], x0[2]], mesh_size=mesh_size),
            self.add_point([x0[0], x0[1], x0[2] - radii[2]], mesh_size=mesh_size),
        ]
        # Add skeleton.
        # Alternative for circles:
        # `self.add_circle_arc(a, b, c)`
        c = [
            self.add_ellipse_arc(p[1], p[0], p[6], p[6]),
            self.add_ellipse_arc(p[6], p[0], p[4], p[4]),
            self.add_ellipse_arc(p[4], p[0], p[3], p[3]),
            self.add_ellipse_arc(p[3], p[0], p[1], p[1]),
            self.add_ellipse_arc(p[1], p[0], p[2], p[2]),
            self.add_ellipse_arc(p[2], p[0], p[4], p[4]),
            self.add_ellipse_arc(p[4], p[0], p[5], p[5]),
            self.add_ellipse_arc(p[5], p[0], p[1], p[1]),
            self.add_ellipse_arc(p[6], p[0], p[2], p[2]),
            self.add_ellipse_arc(p[2], p[0], p[3], p[3]),
            self.add_ellipse_arc(p[3], p[0], p[5], p[5]),
            self.add_ellipse_arc(p[5], p[0], p[6], p[6]),
        ]

        # Add surfaces (1/8th of the ball surface).
        # Make sure the loops are oriented outwards!
        ll = [
            # one half
            self.add_curve_loop([c[4], c[9], c[3]]),
            self.add_curve_loop([c[8], -c[4], c[0]]),
            self.add_curve_loop([-c[9], c[5], c[2]]),
            self.add_curve_loop([-c[5], -c[8], c[1]]),
            # the other half
            self.add_curve_loop([c[7], -c[3], c[10]]),
            self.add_curve_loop([c[11], -c[0], -c[7]]),
            self.add_curve_loop([-c[10], -c[2], c[6]]),
            self.add_curve_loop([-c[1], -c[11], -c[6]]),
        ]

        # Create a surface for each line loop.
        s = [self.add_surface(l) for l in ll]

        # Combine the surfaces to avoid seams
        # <https://gitlab.onelab.info/gmsh/gmsh/-/issues/507>
        # Cannot enable those yet, <https://gitlab.onelab.info/gmsh/gmsh/-/issues/995>
        self._COMPOUND_ENTITIES.append((2, [surf._id for surf in s[:4]]))
        self._COMPOUND_ENTITIES.append((2, [surf._id for surf in s[4:]]))

        # Create the surface loop.
        surface_loop = self.add_surface_loop(s)
        # if holes:
        #     # Create an array of surface loops; the first entry is the outer
        #     # surface loop, the following ones are holes.
        #     surface_loop = self.add_array([surface_loop] + holes)
        # Create volume.
        volume = self.add_volume(surface_loop, holes) if with_volume else None

        class Ellipsoid:
            dim = 3

            def __init__(self, x0, radii, surface_loop, volume, mesh_size=None):
                self.x0 = x0
                self.mesh_size = mesh_size
                self.radii = radii
                self.surface_loop = surface_loop
                self.volume = volume
                return

        return Ellipsoid(x0, radii, surface_loop, volume, mesh_size=mesh_size)
def add_ellipsoid ( self , x0 : list [ float ] , radii : list [ float ] , mesh_size : float | None = None , with_volume : bool = True , holes = None , ) : if holes is None : holes = [ ] if holes : assert with_volume # Add points. p = [ self . add_point ( x0 , mesh_size = mesh_size ) , self . add_point ( [ x0 [ 0 ] + radii [ 0 ] , x0 [ 1 ] , x0 [ 2 ] ] , mesh_size = mesh_size ) , self . add_point ( [ x0 [ 0 ] , x0 [ 1 ] + radii [ 1 ] , x0 [ 2 ] ] , mesh_size = mesh_size ) , self . add_point ( [ x0 [ 0 ] , x0 [ 1 ] , x0 [ 2 ] + radii [ 2 ] ] , mesh_size = mesh_size ) , self . add_point ( [ x0 [ 0 ] - radii [ 0 ] , x0 [ 1 ] , x0 [ 2 ] ] , mesh_size = mesh_size ) , self . add_point ( [ x0 [ 0 ] , x0 [ 1 ] - radii [ 1 ] , x0 [ 2 ] ] , mesh_size = mesh_size ) , self . add_point ( [ x0 [ 0 ] , x0 [ 1 ] , x0 [ 2 ] - radii [ 2 ] ] , mesh_size = mesh_size ) , ] # Add skeleton. # Alternative for circles: # `self.add_circle_arc(a, b, c)` c = [ self . add_ellipse_arc ( p [ 1 ] , p [ 0 ] , p [ 6 ] , p [ 6 ] ) , self . add_ellipse_arc ( p [ 6 ] , p [ 0 ] , p [ 4 ] , p [ 4 ] ) , self . add_ellipse_arc ( p [ 4 ] , p [ 0 ] , p [ 3 ] , p [ 3 ] ) , self . add_ellipse_arc ( p [ 3 ] , p [ 0 ] , p [ 1 ] , p [ 1 ] ) , self . add_ellipse_arc ( p [ 1 ] , p [ 0 ] , p [ 2 ] , p [ 2 ] ) , self . add_ellipse_arc ( p [ 2 ] , p [ 0 ] , p [ 4 ] , p [ 4 ] ) , self . add_ellipse_arc ( p [ 4 ] , p [ 0 ] , p [ 5 ] , p [ 5 ] ) , self . add_ellipse_arc ( p [ 5 ] , p [ 0 ] , p [ 1 ] , p [ 1 ] ) , self . add_ellipse_arc ( p [ 6 ] , p [ 0 ] , p [ 2 ] , p [ 2 ] ) , self . add_ellipse_arc ( p [ 2 ] , p [ 0 ] , p [ 3 ] , p [ 3 ] ) , self . add_ellipse_arc ( p [ 3 ] , p [ 0 ] , p [ 5 ] , p [ 5 ] ) , self . add_ellipse_arc ( p [ 5 ] , p [ 0 ] , p [ 6 ] , p [ 6 ] ) , ] # Add surfaces (1/8th of the ball surface). # Make sure the loops are oriented outwards! ll = [ # one half self . add_curve_loop ( [ c [ 4 ] , c [ 9 ] , c [ 3 ] ] ) , self . add_curve_loop ( [ c [ 8 ] , - c [ 4 ] , c [ 0 ] ] ) , self . add_curve_loop ( [ - c [ 9 ] , c [ 5 ] , c [ 2 ] ] ) , self . add_curve_loop ( [ - c [ 5 ] , - c [ 8 ] , c [ 1 ] ] ) , # the other half self . add_curve_loop ( [ c [ 7 ] , - c [ 3 ] , c [ 10 ] ] ) , self . add_curve_loop ( [ c [ 11 ] , - c [ 0 ] , - c [ 7 ] ] ) , self . add_curve_loop ( [ - c [ 10 ] , - c [ 2 ] , c [ 6 ] ] ) , self . add_curve_loop ( [ - c [ 1 ] , - c [ 11 ] , - c [ 6 ] ] ) , ] # Create a surface for each line loop. s = [ self . add_surface ( l ) for l in ll ] # Combine the surfaces to avoid seams # <https://gitlab.onelab.info/gmsh/gmsh/-/issues/507> # Cannot enable those yet, <https://gitlab.onelab.info/gmsh/gmsh/-/issues/995> self . _COMPOUND_ENTITIES . append ( ( 2 , [ surf . _id for surf in s [ : 4 ] ] ) ) self . _COMPOUND_ENTITIES . append ( ( 2 , [ surf . _id for surf in s [ 4 : ] ] ) ) # Create the surface loop. surface_loop = self . add_surface_loop ( s ) # if holes: #     # Create an array of surface loops; the first entry is the outer #     # surface loop, the following ones are holes. #     surface_loop = self.add_array([surface_loop] + holes) # Create volume. volume = self . add_volume ( surface_loop , holes ) if with_volume else None class Ellipsoid : dim = 3 def __init__ ( self , x0 , radii , surface_loop , volume , mesh_size = None ) : self . x0 = x0 self . mesh_size = mesh_size self . radii = radii self . surface_loop = surface_loop self . volume = volume return return Ellipsoid ( x0 , radii , surface_loop , volume , mesh_size = mesh_size )