How to use the pygmsh.built_in.line_base.LineBase 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 / pygmsh / built_in / spline.py View on Github external
from .line_base import LineBase
from .point import Point


class Spline(LineBase):
    """
    With the built-in geometry kernel this constructs a Catmull-Rom spline.

    Parameters
    ----------
    points : list
        List containing Point objects
    """

    def __init__(self, points):
        super().__init__()

        for c in points:
            assert isinstance(c, Point)
        assert len(points) > 1
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
# close command
        extrusion_string += "};"
        self._GMSH_CODE.append(extrusion_string)

        # From :
        #
        # > 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)):
github nschloe / pygmsh / pygmsh / built_in / circle_arc.py View on Github external
from .line_base import LineBase
from .point import Point


class CircleArc(LineBase):
    """
    Creates a circle arc.

    Parameters
    ----------
    start : Point
        Coordinates of start point needed to construct circle-arc.
    center : Point
        Coordinates of center point needed to construct circle-arc.
    end : Point
        Coordinates of end point needed to construct circle-arc.
    """

    def __init__(self, start, center, end):
        super().__init__()
github nschloe / pygmsh / pygmsh / built_in / ellipse_arc.py View on Github external
from .line_base import LineBase
from .point import Point


class EllipseArc(LineBase):
    """
    Creates an ellipse arc.

    Parameters
    ----------
    start : Point
        Coordinates of start point needed to construct elliptic arc.
    center : Point
        Coordinates of center point needed to construct elliptic arc.
    point_on_major_axis : Point
        Point on the center axis of ellipse.
    end : Point
        Coordinates of end point needed to construct elliptic arc.
    """

    def __init__(self, start, center, point_on_major_axis, end):
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
# > 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
            # points.
            lat = [
                SurfaceBase("{}[{}]".format(name, i + 2), 4)
github nschloe / pygmsh / pygmsh / built_in / line_base.py View on Github external
def __init__(self, id0=None):
        if id0:
            self.id = id0
        else:
            self.id = f"l{LineBase._ID}"
            LineBase._ID += 1
        return
github nschloe / pygmsh / pygmsh / built_in / line.py View on Github external
from .line_base import LineBase
from .point import Point


class Line(LineBase):
    """
    Creates a straight line segment.

    Parameters
    ----------
    p0 : Object
        Point object that represents the start of the line.
    p1 : Object
        Point object that represents the end of the line.

    Attributes
    ----------
    points : array-like[1][2]
        List containing the begin and end points of the line.
    """
github nschloe / pygmsh / pygmsh / built_in / geometry.py View on Github external
def add_physical(self, entities, label=None):
        if not isinstance(entities, list):
            entities = [entities]

        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])
            )