How to use the pygmsh.built_in.volume_base.VolumeBase function in pygmsh

To help you get started, we’ve selected a few pygmsh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / pygmsh / test / test_translations.py View on Github external
def test_translation3d():
    """Translation of a volume object."""
    geom = pygmsh.opencascade.Geometry(0.2, 0.2)
    ball = geom.add_ball([0, 0, 0], 1)
    ball2 = geom.add_ball([1.5, 0, 0], 1)
    geom.translate(ball, [1.5, 0, 0])
    geom.boolean_union([ball2, ball])

    mesh = pygmsh.generate_mesh(geom)
    surf = 4 / 3 * np.pi
    assert isinstance(ball, pygmsh.opencascade.volume_base.VolumeBase)
    assert isinstance(ball, pygmsh.built_in.volume_base.VolumeBase)

    assert np.abs(compute_volume(mesh) - surf) < 2e-2 * surf
    return
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
d = {0: "Point", 1: "Line", 2: "Surface", 3: "Volume"}
        tpe = d[entities[0].dimension]

        for e in entities:
            assert isinstance(
                e,
                (
                    Point,
                    PointBase,
                    LineBase,
                    Surface,
                    PlaneSurface,
                    SurfaceBase,
                    Volume,
                    VolumeBase,
                ),
            ), "Can add physical groups only for Points, Lines, Surfaces, Volumes, not {}.".format(
                type(e)
            )
            assert d[e.dimension] == tpe

        label = self._new_physical_group(label)
        self._GMSH_CODE.append(
            "Physical {}({}) = {{{}}};".format(
                tpe, label, ", ".join([e.id for e in entities])
            )
        )
        return
github nschloe / pygmsh / pygmsh / built_in / volume_base.py View on Github external
def __init__(self, id0=None):
        if id0:
            self.id = id0
        else:
            self.id = f"vol{VolumeBase._ID}"
            VolumeBase._ID += 1
        return
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
#
        # > In this last extrusion command we retrieved the volume number
        # > programatically by saving the output of the command into a
        # > list. This list will contain the "top" of the extruded surface (in
        # > out[0]) as well as the newly created volume (in out[1]).
        #
        top = f"{name}[0]"
        extruded = f"{name}[1]"

        if isinstance(input_entity, LineBase):
            top = LineBase(top)
            # A surface extruded from a single line has always 4 edges
            extruded = SurfaceBase(extruded, 4)
        elif isinstance(input_entity, (SurfaceBase, self.Polygon)):
            top = SurfaceBase(top, input_entity.num_edges)
            extruded = VolumeBase(extruded)
        elif isinstance(input_entity, PointBase):
            top = PointBase(top)
            extruded = LineBase(extruded)
        else:
            top = Dummy(top)
            extruded = Dummy(extruded)

        lat = []
        # lateral surfaces can be deduced only if we start from a SurfaceBase
        # or a Polygon
        if isinstance(input_entity, (SurfaceBase, self.Polygon)):
            # out[0]` is the surface, out[1] the top, and everything after that
            # the sides, cf.
            # . Each
            # lateral surface has 4 edges: the one from input_entity, the one
            # from top, and the two lines (or splines) connecting their extreme
github nschloe / pygmsh / pygmsh / built_in / volume.py View on Github external
from .volume_base import VolumeBase


class Volume(VolumeBase):
    """
    Creates a volume.

    Parameters
    ----------
    surface_loop : list
        Contain the identification numbers of all the surface
        loops defining the volume.
    holes : list
        List containing surface loop objects that represents polygon holes.

    Notes
    -----
    The first surface loop defines the exterior boundary of the volume;
    all other surface loops define holes in the volume.
github nschloe / pygmsh / pygmsh / opencascade / volume_base.py View on Github external
from .. import built_in


class VolumeBase(built_in.volume_base.VolumeBase):
    """
    Increments the Volume ID every time a new volume object
    is created. Inherits from built_in VolumeBase.
    """

    _ID = 0
    dimension = 3

    def __init__(self, is_list=False, id0=None):
        super().__init__(id0=id0)

        self.is_list = is_list
        if is_list:
            self.id += "[]"
        return