FEM.Geometry package#
Meshing and geometry definitions
Submodules#
FEM.Geometry.Geometry module#
Geometry definitions.
- class FEM.Geometry.Geometry.Delaunay(vertices: list, params: str, nvn: int = 1, holes_dict=None, fillets=None, fast=False)#
Bases:
FEM.Geometry.Geometry.Geometry2D
Generate Delaunay triangulation using Triangle
- Parameters
vertices (list) – matrix containing the domain vertices coordinates
params (str) – Triangulation parameters, use the aux function _strdelaunay
nvn (int, optional) – Number of variables per node. Defaults to 1.
holes_dict (list, optional) – A list of holes dicts. Defaults to None.
fillets (list, optional) – A list of fillets. Defaults to None.
fast (bool, optional) – If True, the created elements will have have the fast propertie (see Element class docs)
- extrude(h: float = 1.0, m: int = 5, **kargs) FEM.Geometry.Geometry.Geometry3D #
- class FEM.Geometry.Geometry.Geometry(dictionary: list, gdls: list, types: list, nvn: int = 1, regions: Optional[list[FEM.Geometry.Region.Region]] = None, fast=False)#
Bases:
object
Define a general geometry structure
- Parameters
dictionary (list) – Matrix with element definitions. Each row is an element. The gdl are defined in columns
gdls (list) – List of domain coordinates
types (list) – Types of each element
nvn (int, optional) – Nunmber of variables per node. Defaults to 1.
regions (list, optional) – List of domain regions. Defaults to [].
fast (bool) – If True, the created elements will have have the fast propertie (see Element class docs)
- addRegions(regions: list[FEM.Geometry.Region.Region]) None #
Adds regions to an already created geometry
- Parameters
regions (list[Region]) – Regions to be created
- calculateCentroids() None #
Calculate elements centroids
- calculateRegions() None #
Calculates the nodes of the geometry regions
- cbFromRegion(region: int, value: float, nv: int = 1) list #
Generate a list of border conditions from specified border.
- Parameters
region (int) – region number
value (float) – Value of the bc
nv (int, optional) – Variable number, starts with 1. Defaults to 1.
- Returns
List of border conditions that can be concatenated or assigned to the geometry
- Return type
list
- cbeAllRegions(value: float) None #
Set all regions border conditions to the specified value to all the variables.
- Parameters
value (float) – Value of the border condition
- detectNonLocal(lr: float) list #
Detect adjacent elements between a distance Lr
- Parameters
lr (float) – Distance to detect adjacent elements
- Returns
Non local element dictionary
- Return type
list
- exportJSON(filename: Optional[str] = None) str #
Export geometry definition as JSON file or JSON string
- Parameters
filename (str, optional) – If given, a JSON file is created. Defaults to None.
- Returns
JSON string
- Return type
str
- generateElements() None #
Generate elements structure
- giveElementsOfRegion(region: int) list #
Give elements over a region
- Parameters
region (int) – region number. Start with 0
- Returns
List of elements in the specified region
- Return type
list
- giveNodesOfRegion(region: int) numpy.ndarray #
Give nodes over a region
- Parameters
region (int) – region number. Start with 0
- Returns
List of nodes in the specified region
- Return type
np.ndarray
- giveRegions() list #
Returns a list of regions coordinates matrix
- Returns
List of regions coordinates matrix
- Return type
list
- classmethod importJSON(filename: str, **kargs) FEM.Geometry.Geometry.Geometry #
Import geometry definition from JSON file
- Parameters
filename (str) – Path to the JSON file
- Returns
Geometry generated using the JSON file
- Return type
- initialize() None #
Calculates the total number of GDL’s and generates the elements structure
- maskFromRegions() None #
Create the display mask from geometry regions
- setCbe(cbe: list) None #
This method have to be used to assign essential boundary conditions. Thes method prevents to assign duplicated border conditions
- Parameters
cbe (list) – Border conditions to be applied
- show() None #
Creates a geometry graph
- class FEM.Geometry.Geometry.Geometry1D(dictionary: list, gdls: list, types: list, nvn: int = 1, fast=False)#
Bases:
FEM.Geometry.Geometry.Geometry
Define an 1D geometry structure
- Parameters
dictionary (list) – Matrix with element definitions. Each row is an element. The gdl are defined in columns
gdls (list) – List of domain coordinates
types (list) – Types of each element
nvn (int, optional) – Nunmber of variables per node. Defaults to 1.
fast (bool, optional) – If True, the created elements will have have the fast propertie (see Element class docs)
- generateElements() None #
Generate elements structure
- show() None #
Create a geometry graph
- class FEM.Geometry.Geometry.Geometry2D(dictionary: list, gdls: list, types: list, nvn: int = 1, regions: Optional[list[FEM.Geometry.Region.Region]] = None, fast=False)#
Bases:
FEM.Geometry.Geometry.Geometry
Creates a 2D geometry
- Parameters
dictionary (list) – Matrix with element definitions. Each row is an element. The gdl are defined in columns
gdls (list) – List of domain coordinates
types (list) – Types of each element
nvn (int, optional) – Nunmber of variables per node. Defaults to 1.
regions (list[Region], optional) – List of regions to apply in the geometry. Defaults to None.
fast (bool, optional) – If True, the created elements will have have the fast propertie (see Element class docs)
- cbOnHole(hole: int, value: float, nv: int = 1, sa: float = 0, ea: float = 6.283185307179586) list #
Generate a list of border conditions from specified hole.
- Parameters
hole (int) – Hole index in wich load will be applied
value (float) – Value of the bc
nv (int, optional) – Variable number, starts with 1. Defaults to 1.
sa (float, optional) – Start face angle. Defaults to 0.
ea (float, optional) – Finish face angle. Defaults to \(2\pi\).
- Returns
List of border conditions that can be concatenated or assigned to the geometry
- Return type
list
- generateBCFromCoords(x: float, y: float, value: float = 0, nv: int = 1) list #
Generates border conditions by coordinates. The border condition is applied to the nearest node
- Parameters
x (float) – X coordinate of point
y (float) – Y coordinate of point
value (float, optional) – Value of the border condition. Defaults to 0.
nv (int, optional) – Variable number. The first variable is 1. Defaults to 1.
- Returns
Matrix of border coordinates that can be concatenated
- Return type
list
- generateRegionFromCoords(p0: list, p1: list) None #
Generates a geometry Region1D by specified coordinates
- Parameters
p0 (list) – region start point
p1 (list) – region end point
- loadOnHole(hole: int, sa: float = 0, ea: float = 6.283185307179586, fx: Optional[Callable] = None, fy: Optional[Callable] = None) None #
Assign loads over a hole.
- Parameters
hole (int) – Hole index in wich load will be applied
sa (float, optional) – Start face angle. Defaults to 0.
ea (float, optional) – Finish face angle. Defaults to \(2\pi\).
fx (Callable, optional) – Load Function x component. Defaults to None.
fy (Callable, optional) – Load Function y component. Defaults to None.
- loadOnRegion(region: int, fx: Optional[Callable] = None, fy: Optional[Callable] = None, add=None) None #
Assign a load over a geometry region.
The start point of region is the 0 point of load The end point of region is the end point of load
Load must be defined as a function (normal or lambda)
- Parameters
region (int) – region in wich load will be applied
fx (Callable, optional) – Load Function x component. Defaults to None.
fy (Callable, optional) – Load Function y component. Defaults to None.
- loadOnRegionVF(region: int, f: Optional[Callable] = None, add=None) None #
Assign a load over a geometry region.
The start point of region is the 0 point of load The end point of region is the end point of load
Load must be defined as a function (normal or lambda)
- Parameters
region (int) – region in wich load will be applied
f (Callable, optional) – Load Function. Defaults to None.
- show(texto: int = 10, bolita: int = 0, draw_segs: bool = True, draw_labels: bool = False, draw_bc: bool = False, label_bc: bool = False) None #
Create a geometry graph
- Parameters
texto (int, optional) – Text size. Defaults to 10.
bolita (int, optional) – Node size. Defaults to 0.
draw_segs (bool, optional) – To draw or not draw the regions. Defaults to True.
draw_labels (bool, optional) – To draw or not draw element labels. Defaults to False.
draw_bc (bool, optional) – To draw border conditions. Defaults to False.
label_bc (bool, optional) – To draw labels on border conditions. Defaults to False.
- class FEM.Geometry.Geometry.Geometry3D(dictionary: list, gdls: list, types: list, nvn: int = 1, regions: Optional[list[FEM.Geometry.Region.Region]] = None, fast=False)#
Bases:
FEM.Geometry.Geometry.Geometry
Creates a 2D geometry
- Parameters
dictionary (list) – Matrix with element definitions. Each row is an element. The gdl are defined in columns
gdls (list) – List of domain coordinates
types (list) – Types of each element
nvn (int, optional) – Nunmber of variables per node. Defaults to 1.
regions (list[Region], optional) – List of regions to apply in the geometry. Defaults to None.
fast (bool, optional) – If True, the created elements will have have the fast propertie (see Element class docs)
- show() None #
Creates a geometry graph
- class FEM.Geometry.Geometry.Lineal(lenght: float, n: int, o: int, nvn: int = 1)#
Bases:
FEM.Geometry.Geometry.Geometry1D
Generate a evenly spaced elements domain
- Parameters
lenght (float) – Domain lenght
n (int) – Number of elements
o (int) – Element order, can be 1 or 2
nvn (int, optional) – Number of variables per node. Defaults to 1.
FEM.Geometry.Region module#
Defines geometry region. Regions are used to set border conditions and loads to 2D and 3D problems
- class FEM.Geometry.Region.Region(coords: numpy.ndarray)#
Bases:
object
Creates a general region
- Parameters
coords (np.ndarray) – Coordinates matrix of therefion. Each row is a coordinate, each column is a dimension.
- class FEM.Geometry.Region.Region1D(coords: numpy.ndarray)#
Bases:
FEM.Geometry.Region.Region
Creates a line region (1D element)
- Parameters
coords (np.ndarray) – Coordinate matrix. Must be of two rows and 2 or 3 columns. 2 columns for 2D region, 3 columns for 3D region.
- isBetween(p: numpy.ndarray, tol: float = 1e-05) bool #
Check if a given point is inside the region.
- Parameters
p (np.ndarray) – Point to be tested
tol (float, optional) – Tolerance for check. Defaults to 1*10**(-5).
- Returns
True if the point is inside the region
- Return type
bool
- class FEM.Geometry.Region.Region2D(coords: numpy.ndarray)#
Bases:
FEM.Geometry.Region.Region
Creates a square region (2D element)
- Parameters
coords (np.ndarray) – Coordinate matrix. Must be of four rows and 3 columns.
- isBetween(p: numpy.ndarray, tol: float = 1e-05) bool #
Check if a given point is inside the region.
- Parameters
p (np.ndarray) – Point to be tested
tol (float, optional) – Tolerance for check. Defaults to 1*10**(-5).
- Returns
True if the point is inside the region
- Return type
bool
- pointToPlaneDistance(p: numpy.ndarray) float #
Calculates the distance from a given point to the region.
- Parameters
p (np.ndarray) – Point to be tested
- Returns
Distance between the plane and the point
- Return type
float