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. See Create a mesh for practical examples.
With this module, you can construct:
|
Point class. |
|
Points class. |
|
Domain (2d or 3d domain) class. |
|
Line class. |
|
Circle class. |
|
CircleArc class. |
|
Contour class. |
Once the geometric objects are created, you can manipulate them using copy(), Translate(), Rotate(), or Symmetry() (see the example for details).
Creating a Line#
from EasyFEA.Geoms import Line
line = Line((0,0), (1,1))
line.Plot()
<Axes: >
Creating a Domain#
2D Domain#
from EasyFEA.Geoms import Domain
domain = Domain((0, 0), (1, 1))
domain.Plot()
<Axes: >
3D Domain#
from EasyFEA.Geoms import Domain
domain = Domain((0, 0, 0), (1, 1, 1))
domain.Plot()
<Axes3D: >
Creating a Circle#
from EasyFEA.Geoms import Circle
circle = Circle((0, 0), 1.0)
circle.Plot()
<Axes: >
Using an axis normal to the circle#
from EasyFEA.Geoms import Circle
circle = Circle((0, 0), 1.0, n=(0.5, 0.5, 0.5))
circle.Plot()
<Axes3D: >
Creating a CircleArc#
From 2 Point and a Center#
from EasyFEA.Geoms import CircleArc
circleArc = CircleArc((1, 0), (0, 1), center=(0, 0))
circleArc.Plot()
<Axes: >
From 2 Point and a Radius#
from EasyFEA.Geoms import CircleArc
circleArc = CircleArc((1, 0), (0, 1), R=0.5)
circleArc.Plot()
<Axes: >
From 2 Point and a Point#
from EasyFEA.Geoms import CircleArc
circleArc = CircleArc((1, 0), (0, 1), P=(0.8, 0.8))
circleArc.Plot()
<Axes: >
Creating a Contour from Points#
from EasyFEA.Geoms import Points
contour = Points([(0, 0), (1,0), (1,1), (0,1)]).Get_Contour()
contour.Plot()
<Axes: >
Add a fillet#
from EasyFEA.Geoms import Point, Points
contour = Points([Point(0, 0, r=0.5), (1,0), (1,1), (0,1)]).Get_Contour()
contour.Plot()
<Axes: >
from EasyFEA.Geoms import Point, Points
contour = Points([Point(0, 0, r=-0.5), (1,0), (1,1), (0,1)]).Get_Contour()
contour.Plot()
<Axes: >
Creating a Contour with Line, CircleArc and Points#
from EasyFEA.Geoms import Line, CircleArc, Points, Contour
line = Line((0, 0), (1, 0))
points = Points([(1,0), (1.5, 0.5), (1, 1)])
circleArc = CircleArc((1,1), (0,0), center=(1,0))
contour = Contour([line, points, circleArc])
contour.Plot()
<Axes: >
Manipulate a _Geom object using the copy(), Translate(), Rotate(), and Symmetry() functions#
from EasyFEA.Geoms import Points
contour1 = Points([(0,0), (1,0), (1,1), (0,1)]).Get_Contour()
contour2 = contour1.copy(); contour2.Translate(dx=4)
contour3 = contour2.copy(); contour3.Rotate(90, (0,0), (0,0,1))
contour4 = contour3.copy(); contour4.Symmetry((0,0), (0,1))
ax = contour1.Plot_Geoms([contour1, contour2, contour3, contour4], plotPoints=False)
ax.legend(["contour1", "contour2", "contour3", "contour4"])
<matplotlib.legend.Legend at 0x616f68f5450>
See also
Create a geometric object — build geometry objects step by step with worked examples.
Create a mesh — pass geometry to the mesher to produce a Mesh.
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,
- isHollow: bool = True,
- isOpen: bool = False,
- n: ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float] = (0, 0, 1),
Bases:
_GeomCircle class.
- Get_coord_for_plot(
- N: int = 40,
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
- 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,
Bases:
_GeomCircleArc class.
- Get_coord_for_plot(
- N: int = 11,
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
- class EasyFEA.Geoms.Contour( )[source]#
Bases:
_GeomContour class.
- Get_coord_for_plot(
- N: int = None,
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
- 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,
- isHollow: bool = True,
Bases:
_GeomDomain (2d or 3d domain) class.
- Get_coord_for_plot(
- N: int = None,
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
- 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,
Bases:
_GeomLine class.
- static get_unitVector( ) ndarray[tuple[Any, ...], dtype[floating]][source]#
Creates the unit vector between two points.
- Get_coord_for_plot(
- N: int = 2,
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
- 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,
Bases:
objectPoint class.
- Check(
- coord: Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float],
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),
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),
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)
- isOpen: bool#
point is open
- r: float#
radius used for fillet
- class EasyFEA.Geoms.Points(
- points: Collection[Point | ndarray[tuple[Any, ...], dtype[Any]] | Collection[int | float]],
- meshSize: int | float = 0.0,
- isHollow: bool = True,
- isOpen: bool = False,
Bases:
_GeomPoints 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,
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
- class EasyFEA.Geoms._Geom(
- points: list[Point],
- meshSize: int | float,
- name: str,
- isHollow: bool,
- isOpen: bool,
Bases:
ABCGeometric class.
- static Plot_Geoms(
- geoms: list[_Geom],
- ax: Axes | None = None,
- color: str = '',
- name: str = '',
- plotPoints: bool = True,
- plotLegend: bool = True,
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 Get_coord_for_plot(
- N: int = None,
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='',
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_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='',
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_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='',
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:
- Plot(
- ax: Axes | None = None,
- color: str = '',
- name: str = '',
- lw: int | float | None = None,
- ls: str | None = None,
- plotPoints: bool = True,
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: tuple = (0, 0, 0),
- direction: tuple = (0, 0, 1),
Rotates the object coordinates around an axis.
- Parameters:
theta (float) – rotation angle in [deg]
center (tuple, optional) – rotation center, by default (0,0,0)
direction (tuple, 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),
Reflects the geometry with respect to a plane.
- Parameters:
point (Coords, optional) – A point on the reflection plane, by default (0, 0, 0).
n (Coords, optional) – Normal vector of the plane, by default (1, 0, 0).
- Translate(dx: float = 0.0, dy: float = 0.0, dz: float = 0.0) 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.
- property coord: ndarray[tuple[Any, ...], dtype[floating]][source]#
Returns the coordinates of all points as a NumPy array.
- isHollow: bool#
Indicates whether the formed geometry is hollow.
- 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.
- EasyFEA.Geoms.Angle_Between(
- a: ndarray[tuple[Any, ...], dtype[Any]],
- b: ndarray[tuple[Any, ...], dtype[Any]],
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,
- 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],
- 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],
Returns center from coordinates a radius and and a vector normal to the circle.
return center
- EasyFEA.Geoms.Circle_Triangle(
- p1,
- p2,
- p3,
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,
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],
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],
Must be a vector or matrix.
- EasyFEA.Geoms.Points_Intersect_Circles(
- circle1,
- circle2,
Computes the coordinates at the intersection of the two circles (i,3).
This only works if they’re on the same plane.
- 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),
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),
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