Geoms#

The EasyFEA.Geoms module provides essential tools for creating and managing _Geom objects. These geometric objects are used to construct Mesh using the Mesher.

In the simulation workflow, Geoms is the first step: you describe the domain shape here before passing it to the mesher.

With this module, you can construct:

Point([x, y, z, isOpen, r])

Point class.

Points(points[, meshSize, isFilled, isOpen])

Points class.

Domain(pt1, pt2[, meshSize, isFilled])

Domain (2d or 3d domain) class.

Line(pt1, pt2[, meshSize, isOpen])

Line class.

Circle(center, diam[, meshSize, isFilled, ...])

Circle class.

CircleArc(pt1, pt2[, center, R, P, ...])

CircleArc class.

Contour(geoms[, isFilled, isOpen])

Contour class.

Once the geometric objects are created, you can manipulate them using copy(), Translate(), Rotate(), or Symmetry() (see the examples for details).

Geoms API#

Module containing the geometric functions used to build meshes.

class EasyFEA.Geoms.Circle(
center: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
diam: float,
meshSize: float = 0.0,
isFilled: bool = False,
isOpen: bool = False,
n: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 1),
)[source]#

Bases: _Geom

Circle class.

Get_Contour()[source]#

Creates the contour object associated with the circle

Get_coord_for_plot(
N: int = 40,
) tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]][source]#

Returns lines and points coordinates for plotting.

Parameters:

N (int, optional) – Number of coordinates for lines, by default None.

Returns:

Lines and points coordinates as NumPy arrays.

Return type:

tuple of ndarray

_Init_Ninstance()[source]#

Initializes the instance number.

property diam: float[source]#

circle’s diameter

property length: float[source]#

circle perimeter

property n: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float][source]#

axis normal to the circle

class EasyFEA.Geoms.CircleArc(
pt1: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
pt2: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
center: Point | None = None,
R: int | float | None = None,
P: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] | None = None,
meshSize: int | float = 0.0,
n: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 1),
isOpen: bool = False,
coef: int = 1,
)[source]#

Bases: _Geom

CircleArc class.

Get_coord_for_plot(
N: int = 11,
) tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]][source]#

Returns lines and points coordinates for plotting.

Parameters:

N (int, optional) – Number of coordinates for lines, by default None.

Returns:

Lines and points coordinates as NumPy arrays.

Return type:

tuple of ndarray

_Init_Ninstance()[source]#

Initializes the instance number.

property angle[source]#

circular arc angle [rad]

property length: float[source]#

circular arc length

property n: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float][source]#

axis normal to the circle arc

property r[source]#

circular arc radius

class EasyFEA.Geoms.Contour(
geoms: list[Line | CircleArc | Points],
isFilled: bool = False,
isOpen: bool = False,
)[source]#

Bases: _Geom

Contour class.

Get_coord_for_plot(
N: int = None,
) tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]][source]#

Returns lines and points coordinates for plotting.

Parameters:

N (int, optional) – Number of coordinates for lines, by default None.

Returns:

Lines and points coordinates as NumPy arrays.

Return type:

tuple of ndarray

_Init_Ninstance()[source]#

Initializes the instance number.

property length: float[source]#
class EasyFEA.Geoms.Domain(
pt1: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
pt2: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
meshSize: int | float = 0.0,
isFilled: bool = False,
)[source]#

Bases: _Geom

Domain (2d or 3d domain) class.

Get_coord_for_plot(
N: int = None,
) tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]][source]#

Returns lines and points coordinates for plotting.

Parameters:

N (int, optional) – Number of coordinates for lines, by default None.

Returns:

Lines and points coordinates as NumPy arrays.

Return type:

tuple of ndarray

_Init_Ninstance()[source]#

Initializes the instance number.

class EasyFEA.Geoms.Line(
pt1: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
pt2: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
meshSize: int | float = 0.0,
isOpen: bool = False,
)[source]#

Bases: _Geom

Line class.

static distance(
pt1: Point,
pt2: Point,
) float[source]#

Computes the distance between two points.

static get_unitVector(
pt1: Point,
pt2: Point,
) ndarray[tuple[Any, ...], dtype[floating]][source]#

Creates the unit vector between two points.

Get_coord_for_plot(
N: int = 2,
) tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]][source]#

Returns lines and points coordinates for plotting.

Parameters:

N (int, optional) – Number of coordinates for lines, by default None.

Returns:

Lines and points coordinates as NumPy arrays.

Return type:

tuple of ndarray

_Init_Ninstance()[source]#

Initializes the instance number.

property length: float[source]#

distance between the two points of the line

property unitVector: ndarray[tuple[Any, ...], dtype[floating]][source]#

The unit vector for the two points on the line (p2-p1)

class EasyFEA.Geoms.Point(
x: int | float = 0.0,
y: int | float = 0.0,
z: int | float = 0.0,
isOpen: bool = False,
r: int | float = 0.0,
)[source]#

Bases: object

Point class.

Check(
coord: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
) bool[source]#

Checks if coordinates are identical

Rotate(
theta: float,
center: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 0),
direction: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 1),
) None[source]#

Rotates the point with around an axis.

Parameters:
  • theta (float) – rotation angle [deg]

  • center (_types.Coords, optional) – rotation center, by default (0,0,0)

  • direction (_types.Coords, optional) – rotation direction, by default (0,0,1)

Symmetry(
point: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 0),
n: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (1, 0, 0),
) None[source]#

Symmetrizes the point coordinates with a plane.

Parameters:
  • point (_types.Coords, optional) – a point belonging to the plane, by default (0,0,0)

  • n (_types.Coords, optional) – normal to the plane, by default (1,0,0)

Translate(dx: float = 0.0, dy: float = 0.0, dz: float = 0.0) None[source]#

Translates the point.

copy()[source]#
property coord: ndarray[tuple[Any, ...], dtype[floating]][source]#

[x,y,z] coordinates

isOpen: bool#

point is open

r: float#

radius used for fillet

property x: float[source]#

x coordinate

property y: float[source]#

y coordinate

property z: float[source]#

z coordinate

class EasyFEA.Geoms.Points(
points: Collection[Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float]],
meshSize: int | float = 0.0,
isFilled: bool = False,
isOpen: bool = False,
)[source]#

Bases: _Geom

Points class.

Get_Contour()[source]#

Creates a contour from the points.

Creates a fillet if a point has a radius which is not 0.

Get_coord_for_plot(
N: int = None,
) tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]][source]#

Returns lines and points coordinates for plotting.

Parameters:

N (int, optional) – Number of coordinates for lines, by default None.

Returns:

Lines and points coordinates as NumPy arrays.

Return type:

tuple of ndarray

_Init_Ninstance()[source]#

Initializes the instance number.

property length: float[source]#
class EasyFEA.Geoms._Geom(
points: list[Point],
meshSize: int | float,
name: str,
isFilled: bool,
isOpen: bool,
)[source]#

Bases: ABC

Geometric class.

static Plot_Geoms(
geoms: list[_Geom],
ax: Axes | None = None,
color: str = '',
name: str = '',
plotPoints: bool = True,
plotLegend: bool = True,
) Axes[source]#

Plots a list of geometric objects on the same axis.

Parameters:
  • geoms (list of _Geom) – Geometries to plot.

  • ax (matplotlib axis, optional) – Axis to use. If None, a new one is created.

  • color (str, optional) – Line color.

  • name (str, optional) – Label for the geometries.

  • plotPoints (bool, optional) – Whether to plot defining points.

  • plotLegend (bool, optional) – Whether to display the legend.

Returns:

The axis with the plotted geometries.

Return type:

Axes

abstractmethod static _Init_Ninstance()[source]#

Initializes the instance number.

abstractmethod Get_coord_for_plot(
N: int = None,
) tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]][source]#

Returns lines and points coordinates for plotting.

Parameters:

N (int, optional) – Number of coordinates for lines, by default None.

Returns:

Lines and points coordinates as NumPy arrays.

Return type:

tuple of ndarray

Mesh_2D(
inclusions: list[GeomCompatible] = [],
elemType: ElemType = ElemType.TRI3,
cracks: list['CrackCompatible'] = [],
refineGeoms: list['RefineCompatible'] = [],
isOrganised=False,
additionalSurfaces: list[GeomCompatible] = [],
additionalLines: list['Line' | 'CircleArc'] = [],
additionalPoints: list['Point'] = [],
path='',
)[source]#

Creates a 2D mesh from a contour and inclusions that must form a closed plane surface.

Parameters:
  • inclusions (list[Domain, Circle, Points, Contour], optional) – list of hollow and filled geom objects inside the domain

  • elemType (ElemType, optional) – element type, by default “TRI3” [“TRI3”, “TRI6”, “TRI10”, “TRI15”, “QUAD4”, “QUAD8”, “QUAD9”]

  • cracks (list[Line | Points | Contour | CircleArc]) – list of geom object used to create open or closed cracks

  • refineGeoms (list[Domain|Circle|str], optional) – list of geom object for mesh refinement, by default []

  • isOrganised (bool, optional) – mesh is organized, by default False

  • additionalSurfaces (list[Domain, Circle, Points, Contour]) – additional surfaces that will be added to or removed from the surfaces created by the contour and the inclusions. (e.g Domain, Circle, Contour, Points). Tip: if the mesh is not well generated, you can also give the inclusions.

  • additionalLines (list[Union[Line,CircleArc]]) – additional lines that will be added to the surfaces created by the contour and the inclusions. (e.g Domain, Circle, Contour, Points). WARNING: lines must be within the domain.

  • additionalPoints (list[Point]) – additional points that will be added to the surfaces created by the contour and the inclusions. WARNING: points must be within the domain.

  • path (str, optional) – path used to save the meshfile, by default “” does not save the mesh

Returns:

Created mesh

Return type:

Mesh

Mesh_Extrude(
inclusions: list[GeomCompatible] = [],
extrude: _types.Coords = (0, 0, 1),
layers: list[int] = [],
elemType: ElemType = ElemType.TETRA4,
cracks: list['CrackCompatible'] = [],
refineGeoms: list['RefineCompatible'] = [],
isOrganised=False,
additionalSurfaces: list[GeomCompatible] = [],
additionalLines: list['Line' | 'CircleArc'] = [],
additionalPoints: list['Point'] = [],
path='',
)[source]#

Creates a 3D mesh by extruding a surface constructed from a contour and inclusions.

Parameters:
  • inclusions (list[Domain, Circle, Points, Contour], optional) – list of hollow and filled geom objects inside the domain

  • extrude (Coords, optional) – extrusion vector, by default [0,0,1]

  • layers (list[int], optional) – layers in the extrusion, by default []

  • elemType (ElemType, optional) – element type, by default “TETRA4” [“TETRA4”, “TETRA10”, “HEXA8”, “HEXA20”, “HEXA27”, “PRISM6”, “PRISM15”, “PRISM18”]

  • cracks (list[Line | Points | Contour | CircleArc]) – list of geom object used to create open or closed cracks

  • refineGeoms (list[Domain|Circle|str], optional) – list of geom object for mesh refinement, by default []

  • isOrganised (bool, optional) – mesh is organized, by default False

  • additionalSurfaces (list[Domain, Circle, Points, Contour]) – additional surfaces that will be added to or removed from the surfaces created by the contour and the inclusions. (e.g Domain, Circle, Contour, Points). Tip: if the mesh is not well generated, you can also give the inclusions.

  • additionalLines (list[Union[Line,CircleArc]]) – additional lines that will be added to the surfaces created by the contour and the inclusions. (e.g Domain, Circle, Contour, Points). WARNING: lines must be within the domain.

  • additionalPoints (list[Point]) – additional points that will be added to the surfaces created by the contour and the inclusions. WARNING: points must be within the domain.

  • path (str, optional) – path used to save the meshfile, by default “” does not save the mesh

Returns:

Created mesh

Return type:

Mesh

Mesh_Revolve(
inclusions: list[GeomCompatible] = [],
axis: 'Line' | None = None,
angle=360,
layers: list[int] = [30],
elemType: ElemType = ElemType.TETRA4,
cracks: list['CrackCompatible'] = [],
refineGeoms: list['RefineCompatible'] = [],
isOrganised=False,
additionalSurfaces: list[GeomCompatible] = [],
additionalLines: list['Line' | 'CircleArc'] = [],
additionalPoints: list['Point'] = [],
path='',
)[source]#

Creates a 3D mesh by rotating a surface along an axis.

Parameters:
  • inclusions (list[Domain, Circle, Points, Contour], optional) – list of hollow and filled geom objects inside the domain

  • axis (Line, optional) – revolution axis, by default Line((0, 0), (0, 1))

  • angle (float|int, optional) – revolution angle in [deg], by default 360

  • layers (list[int], optional) – layers in extrusion, by default [30]

  • elemType (ElemType, optional) – element type, by default “TETRA4” [“TETRA4”, “TETRA10”, “HEXA8”, “HEXA20”, “HEXA27”, “PRISM6”, “PRISM15”, “PRISM18”]

  • cracks (list[Line | Points | Contour | CircleArc]) – list of geom object used to create open or closed cracks

  • refineGeoms (list[Domain|Circle|str], optional) – list of geom object for mesh refinement, by default []

  • isOrganised (bool, optional) – mesh is organized, by default False

  • additionalSurfaces (list[Domain, Circle, Points, Contour]) – additional surfaces that will be added to or removed from the surfaces created by the contour and the inclusions. (e.g Domain, Circle, Contour, Points). Tip: if the mesh is not well generated, you can also give the inclusions.

  • additionalLines (list[Union[Line,CircleArc]]) – additional lines that will be added to the surfaces created by the contour and the inclusions. (e.g Domain, Circle, Contour, Points). WARNING: lines must be within the domain.

  • additionalPoints (list[Point]) – additional points that will be added to the surfaces created by the contour and the inclusions. WARNING: points must be within the domain.

  • path (str, optional) – path used to save the meshfile, by default “” does not save the mesh

Returns:

Created mesh

Return type:

Mesh

Plot(
ax: Axes | None = None,
color: str = '',
name: str = '',
lw: int | float | None = None,
ls: str | None = None,
plotPoints: bool = True,
) Axes[source]#

Plots the geometry using Matplotlib.

Parameters:
  • ax (matplotlib axis, optional) – Axis to plot on. If None, a new one is created.

  • color (str, optional) – Line color.

  • name (str, optional) – Label for the object.

  • lw (float, optional) – Line width.

  • ls (str, optional) – Line style.

  • plotPoints (bool, optional) – If True, display the object’s defining points.

Returns:

The axis with the plotted geometry.

Return type:

Axes

Rotate(
theta: float,
center: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 0),
direction: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 1),
copy: bool = False,
) _Geom | None[source]#

Rotates the geometry around an axis defined by a center and a direction.

Parameters:
  • theta (float) – rotation angle [deg]

  • center (_types.Coords, optional) – point on the rotation axis, by default (0,0,0)

  • direction (_types.Coords, optional) – unit vector defining the rotation axis, by default (0,0,1) (z-axis)

  • copy (bool, optional) – if True, returns a new rotated object leaving the original unchanged, by default False

Returns:

a new rotated object if copy=True, otherwise None

Return type:

_Geom | None

Symmetry(
point: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 0),
n: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (1, 0, 0),
copy: bool = False,
) _Geom | None[source]#

Reflects the geometry through a plane defined by a point and a normal vector.

Parameters:
  • point (_types.Coords, optional) – a point on the reflection plane, by default (0,0,0)

  • n (_types.Coords, optional) – normal vector to the reflection plane, by default (1,0,0) (yz-plane)

  • copy (bool, optional) – if True, returns a new reflected object leaving the original unchanged, by default False

Returns:

a new reflected object if copy=True, otherwise None

Return type:

_Geom | None

Translate(
dx: float = 0.0,
dy: float = 0.0,
dz: float = 0.0,
copy: bool = False,
) _Geom | None[source]#

Translates the geometry in 3D space.

Parameters:
  • dx (float, optional) – translation along the x-axis, by default 0.0

  • dy (float, optional) – translation along the y-axis, by default 0.0

  • dz (float, optional) – translation along the z-axis, by default 0.0

  • copy (bool, optional) – if True, returns a new translated object leaving the original unchanged, by default False

Returns:

a new translated object if copy=True, otherwise None

Return type:

_Geom | None

copy()[source]#
property coord: ndarray[tuple[Any, ...], dtype[floating]][source]#

Returns the coordinates of all points as a NumPy array.

isFilled: bool#

True if the enclosed region is filled (solid inclusion).

isOpen: bool#

Indicates whether the geometry is open, typically to model cracks.

meshSize: float#

Element size used for meshing.

name: str#

Name of the geometric object.

property points: list[Point][source]#

The list of points used to build the geometric object.

EasyFEA.Geoms.Angle_Between(
a: ndarray[tuple[Any, ...], dtype[Any]],
b: ndarray[tuple[Any, ...], dtype[Any]],
) float[source]#

Computes the angle between vectors a and b (rad). https://math.stackexchange.com/questions/878785/how-to-find-an-angle-in-range0-360-between-2-vectors

EasyFEA.Geoms.AsCoords(
value: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] | int | float | Point,
) ndarray[tuple[Any, ...], dtype[floating]][source]#
EasyFEA.Geoms.AsCoords(value: Point)
EasyFEA.Geoms.AsCoords(value: Iterable)
EasyFEA.Geoms.AsCoords(value: int)
EasyFEA.Geoms.AsCoords(value: float)

Returns value as a 3D vector

EasyFEA.Geoms.AsPoint(
coords: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
) Point[source]#
EasyFEA.Geoms.AsPoint(coords: Point)
EasyFEA.Geoms.AsPoint(coords: Iterable)

Returns coords as a point.

EasyFEA.Geoms.Circle_Coords(
coord: ndarray[tuple[Any, ...], dtype[Any]],
R: float,
n: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
) ndarray[tuple[Any, ...], dtype[floating]][source]#

Returns center from coordinates a radius and and a vector normal to the circle.

return center

EasyFEA.Geoms.Circle_Triangle(
p1,
p2,
p3,
) ndarray[tuple[Any, ...], dtype[floating]][source]#

Returns triangle’s center for the circumcicular arc formed by 3 points.

returns center

EasyFEA.Geoms.Fillet(
P0: ndarray[tuple[Any, ...], dtype[Any]],
P1: ndarray[tuple[Any, ...], dtype[Any]],
P2: ndarray[tuple[Any, ...], dtype[Any]],
r: float,
) tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]][source]#

Computes fillet in a corner P0.

returns A, B, C

Parameters:
  • P0 (_types.AnyArray) – coordinates of point with radius

  • P1 (_types.AnyArray) – coordinates before P0 coordinates

  • P2 (_types.AnyArray) – coordinates after P0 coordinates

  • r (float) – radius (or fillet) at point P0

Returns:

coordinates calculated to construct the radius

Return type:

tuple[_types.FloatArray, _types.FloatArray, _types.FloatArray]

EasyFEA.Geoms.Jacobian_Matrix(
i: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
k: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
) ndarray[tuple[Any, ...], dtype[floating]][source]#

Computes the Jacobian matrix to transform local coordinates (i,j,k) to global (x,y,z) coordinates.

p(x,y,z) = J • p(i,j,k) and p(i,j,k) = inv(J) • p(x,y,z)

ix jx kx

iy jy ky

iz jz kz

Parameters:
  • i (_types.Coords) – i vector

  • k (_types.Coords) – k vector

EasyFEA.Geoms.Normalize(
array: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
) ndarray[tuple[Any, ...], dtype[floating]][source]#

Must be a vector or matrix.

EasyFEA.Geoms.Points_Intersect_Circles(
circle1,
circle2,
) ndarray[tuple[Any, ...], dtype[Any]][source]#

Computes the coordinates at the intersection of the two circles (i,3).

This only works if they’re on the same plane.

Parameters:
  • circle1 (Circle) – circle 1

  • circle2 (Circle) – circle 2

EasyFEA.Geoms.Rotate(
coord: ndarray[tuple[Any, ...], dtype[Any]],
theta: float,
center: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 0),
direction: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 1),
) ndarray[tuple[Any, ...], dtype[floating]][source]#

Rotates the coordinates arround a specified center and axis.

Parameters:
  • coord (_types.AnyArray) – coordinates to rotate (n,3)

  • theta (float) – rotation angle [deg]

  • center (_types.Iterable, optional) – rotation center, by default (0,0,0)

  • direction (_types.Iterable, optional) – rotation direction, by default (0,0,1)

Returns:

rotated coordinates

Return type:

_types.FloatArray

EasyFEA.Geoms.Symmetry(
coord: ndarray[tuple[Any, ...], dtype[Any]],
point=(0, 0, 0),
n=(1, 0, 0),
) ndarray[tuple[Any, ...], dtype[floating]][source]#

Symmetrizes coordinates with a plane.

Parameters:
  • coord (_types.AnyArray) – coordinates that we want to symmetrise

  • point (tuple, optional) – a point belonging to the plane, by default (0,0,0)

  • n (tuple, optional) – normal to the plane, by default (1,0,0)

Returns:

the new coordinates

Return type:

_types.FloatArray

EasyFEA.Geoms.Translate(
coord: ndarray[tuple[Any, ...], dtype[Any]],
dx: float = 0.0,
dy: float = 0.0,
dz: float = 0.0,
) ndarray[tuple[Any, ...], dtype[floating]][source]#

Translates the coordinates.

EasyFEA.Geoms._Init_Geoms_NInstance()[source]#

Initalizes the number of instance for each geom classes.