Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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])
# > 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
# points.
lat = [
def __init__(self, id0=None):
if id0:
self.id = id0
else:
self.id = f"p{PointBase._ID}"
PointBase._ID += 1
return
from .point_base import PointBase
class Point(PointBase):
"""
Creates an elementary point.
x : array-like[3]
Give the three X, Y and Z coordinates of the
point in the three-dimensional Euclidean space.
lcar : float
The prescribed mesh element size at this point.
"""
def __init__(self, x, lcar=None):
super().__init__()
self.x = x
self.lcar = lcar
# > 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
# points.