utilities#
The EasyFEA/utilities/ module in EasyFEA provides essential tools for post processing.
Module containing functions used to display simulations and meshes with matplotlib (https://matplotlib.org/). |
|
Module containing functions used to facilitate folder and file creation using (os). |
|
Module providing an interface with meshio (https://pypi.org/project/meshio/). |
|
Numba functions to speed up calculations. |
|
This module allows you to save a simulation's results on Paraview (https://www.paraview.org/). |
|
Module providing an interface with PyVista (https://docs.pyvista.org/version/stable/). |
|
Module providing functions used to save FEM-solutions for vizir (https://pyamg.saclay.inria.fr/vizir4.html). |
Detailed utilities API#
Module containing functions used to display simulations and meshes with matplotlib (https://matplotlib.org/).
- EasyFEA.utilities.Display.Init_Axes(dim=2, elev=105, azim=-90)[source]#
Initialize 2d or 3d axes.
- Return type:
Union[Axes,Axes3D]
- EasyFEA.utilities.Display.Movie_Simu(simu, result, folder, filename='video.gif', N=200, deformFactor=0.0, coef=1.0, nodeValues=True, plotMesh=False, edgecolor='black', fps=30, **kwargs)[source]#
Generates a movie from a simulation’s result.
- Parameters:
simu (_Simu) – simulation
result (str) – result that you want to plot
folder (str) – folder where you want to save the video
filename (str, optional) – filename of the video with the extension (gif, mp4), by default ‘video.gif’
N (int, optional) – Maximal number of iterations displayed, by default 200
deformFactor (int, optional) – deformation factor, by default 0.0
coef (float, optional) – Coef to apply to the solution, by default 1.0
nodeValues (bool, optional) – Displays result to nodes otherwise displays it to elements, by default True
plotMesh (bool, optional) – Plot the mesh, by default False
edgecolor (str, optional) – Color used to plot the mesh, by default ‘black’
fps (int, optional) – frames per second, by default 30
- Return type:
None
- EasyFEA.utilities.Display.Movie_func(func, fig, N, folder, filename='video.gif', fps=30, dpi=200, show=True)[source]#
Generates the movie for the specified function.
This function will peform a loop in range(N).
- Parameters:
func (Callable[[plt.Figure, int], None]) –
The function that will use in first argument the plotter and in second argument the iter step such that.
def func(fig, i) -> None
fig (Figure) – Figure used to make the video
N (int) – number of iteration
folder (str) – folder where you want to save the video
filename (str, optional) – filename of the video with the extension (eg. .gif, .mp4), by default ‘video.gif’
fps (int, optional) – frames per second, by default 30
dpi (int, optional) – Dots per Inch, by default 200
show (bool, optional) – shows the movie, by default True
- EasyFEA.utilities.Display.MyPrint(text, color='cyan', bold=False, italic=False, underLine=False, end='')[source]#
- Return type:
str
- EasyFEA.utilities.Display.Plot_BoundaryConditions(simu, ax=None)[source]#
Plots simulation’s boundary conditions.
- Parameters:
simu (_Simu) – simulation
ax (_types.Axes, optional) – Axis to use, default None
- Return type:
_types.Axes
- EasyFEA.utilities.Display.Plot_Elements(obj, nodes=[], dimElem=None, showId=False, alpha=1.0, color='red', edgecolor='black', ax=None)[source]#
Plots the mesh’s elements corresponding to the given nodes.
- Parameters:
obj (_Simu | Mesh | _GroupElem) – object containing the mesh
nodes (list, optional) – node numbers, by default []
dimElem (int, optional) – dimension of elements, by default None
showId (bool, optional) – display numbers, by default False
alpha (float, optional) – transparency of faces, by default 1.0
color (str, optional) – color used to display faces, by default ‘red
edgecolor (str, optional) – color used to display segments, by default ‘black’
ax (_types.Axes, optional) – Axis to use, default None
- Return type:
_types.Axes
- EasyFEA.utilities.Display.Plot_Energy(simu, load=array([], dtype=float64), displacement=array([], dtype=float64), plotSolMax=True, N=200, folder='')[source]#
Plots the energy for each iteration.
- Parameters:
simu (_Simu) – simulation
load (_types.FloatArray, optional) – array of values, by default np.array([])
displacement (_types.FloatArray, optional) – array of values, by default np.array([])
plotSolMax (bool, optional) – displays the evolution of the maximul solution over iterations. (max damage for damage simulation), by default True
N (int, optional) – number of iterations for which energy will be calculated, by default 200
folder (str, optional) – save folder, by default “”
- Return type:
None
- EasyFEA.utilities.Display.Plot_Force_Displacement(force, displacement, xlabel='u', ylabel='f', folder='', ax=None)[source]#
Plots the force displacement curve.
- Parameters:
force (_types.FloatArray) – array of values for force
displacement (_types.FloatArray) – array of values for displacements
xlabel (str, optional) – x-axis title, by default ‘u’.
ylabel (str, optional) – y-axis title, by default ‘f’ folder : str, optional
folder (str, optional) – save folder, by default “”
ax (_types.Axes, optional) – ax in which to plot the figure, by default None
- Returns:
returns figure and ax
- Return type:
tuple[plt.Figure, _types.Axes]
- EasyFEA.utilities.Display.Plot_Iter_Summary(simu, folder='', iterMin=None, iterMax=None)[source]#
Plots a summary of iterations between iterMin and iterMax.
- Parameters:
simu (_Simu) – Simulation
folder (str, optional) – backup folder, by default “”
iterMin (int, optional) – lower bound, by default None
iterMax (int, optional) – upper bound, by default None
- Return type:
None
- EasyFEA.utilities.Display.Plot_Mesh(obj, deformFactor=0.0, alpha=1.0, facecolors='c', edgecolor='black', lw=0.5, ax=None, folder='', title='')[source]#
Plots the mesh.
- Parameters:
obj (_Simu | Mesh | _GroupElem) – object containing the mesh
deformFactor (float, optional) – Factor used to display the deformed solution (0 means no deformations), default 0.0
alpha (float, optional) – face transparency, default 1.0
facecolors (str, optional) – facecolors, default ‘c’ (cyan)
edgecolor (str, optional) – edgecolor, default ‘black’
lw (float, optional) – line width, default 0.5
ax (_types.Axes, optional) – Axis to use, default None
folder (str, optional) – save folder, default “”.
title (str, optional) – figure title, by default “”
- Return type:
_types.Axes
- EasyFEA.utilities.Display.Plot_Nodes(obj, nodes=None, showId=False, marker='.', color='red', ax=None)[source]#
Plots the mesh’s nodes.
- Parameters:
obj (_Simu | Mesh | _GroupElem) – object containing the mesh
nodes (_types.IntArray, optional) – nodes to display, default []
showId (bool, optional) – display numbers, default False
marker (str, optional) – marker type (matplotlib.markers), default ‘.’
color (str, optional) – color, default ‘red’
ax (_types.Axes, optional) – Axis to use, default None, default None
- Return type:
_types.Axes
- EasyFEA.utilities.Display.Plot_Result(obj, result, deformFactor=0.0, coef=1.0, nodeValues=True, plotMesh=False, edgecolor='black', title='', cmap='jet', ncolors=256, clim=(None, None), colorbarIsClose=False, colorbarLabel='', ax=None, folder='', filename='')[source]#
Plots a simulation’s result.
- Parameters:
result (str | _types.FloatArray) – Result you want to display. Must be included in simu.Get_Results() or be a numpy array of size (Nn, Ne).
deformFactor (float, optional) – factor used to display the deformed solution (0 means no deformations), default 0.0
coef (float, optional) – coef to apply to the solution, by default 1.0
nodeValues (bool, optional) – displays result to nodes otherwise displays it to elements, by default True
plotMesh (bool, optional) – displays mesh, by default False
edgecolor (str, optional) – Color used to plot the mesh, by default ‘black’
title (str, optional) – figure title, by default “”
cmap (str, optional) –
the color map used near the figure, by default “jet”
[“jet”, “seismic”, “binary”, “viridis”] -> https://matplotlib.org/stable/tutorials/colors/colormaps.html
ncolors (int, optional) – number of colors for colorbar, by default 21
clim (sequence[float], optional) – Two item color bar range for scalars. Defaults to minimum and maximum of scalars array. Example: (-1, 2), by default (None, None)
colorbarIsClose (bool, optional) – color bar is displayed close to the figure, by default False
colorbarLabel (str, optional) – colorbar label, by default “”
ax (axis, optional) – Axis to use, default None, by default None
folder (str, optional) – save folder, by default “”.
filename (str, optional) – filename, by default “”
- Return type:
_types.Axis
- EasyFEA.utilities.Display.Plot_Tags(obj, showId=True, folder='', alpha=1.0, ax=None)[source]#
Plots the mesh’s elements tags (from 2d elements to points) but do not plot the 3d elements tags.
- Parameters:
- Return type:
_types.Axes
- EasyFEA.utilities.Display.Save_fig(folder, filename, transparent=False, extension='pdf', dpi='figure')[source]#
Saves the current figure.
- Parameters:
folder (str) – save folder
filename (str) – filename
transparent (bool, optional) – transparent background, by default False
extension (str, optional) – extension, by default ‘pdf’, [pdf, png]
dpi (str, optional) – dpi, by default ‘figure’
- Return type:
None
- EasyFEA.utilities.Display.Section(text, verbosity=True)[source]#
Creates a new section in the terminal.
- Return type:
str
Module containing functions used to facilitate folder and file creation using (os).
- EasyFEA.utilities.Folder.Dir(path, depth=1)[source]#
Returns the directory of the specified path.
- Return type:
str
- EasyFEA.utilities.Folder.Exists(path)[source]#
Test whether a path exists. Returns False for broken symbolic links
- Return type:
bool
- EasyFEA.utilities.Folder.Join(*args, mkdir=False)[source]#
Joins two or more pathname components and create (or not) the path.
- Return type:
str
- EasyFEA.utilities.Folder.PhaseField_Folder(folder, material, split, regu, simpli2D, tolConv, solver, test, optimMesh=False, closeCrack=False, nL=0, theta=0.0)[source]#
Creates a phase field folder based on the specified arguments.
- Return type:
str
- EasyFEA.utilities.Folder.RESULTS_DIR = '/home/docs/checkouts/readthedocs.org/user_builds/easyfea/envs/v1.5.4/lib/python3.11/site-packages/results'#
EASYFEA_DIR/results
Module providing an interface with meshio (https://pypi.org/project/meshio/).
- EasyFEA.utilities.MeshIO.DICT_ELEMTYPE_TO_ENSIGHT: dict[ElemType, str] = {ElemType.HEXA20: 'hexa20', ElemType.HEXA8: 'hexa8', ElemType.POINT: 'point', ElemType.PRISM15: 'wedge15', ElemType.PRISM6: 'wedge6', ElemType.QUAD4: 'quad4', ElemType.QUAD8: 'quad8', ElemType.SEG2: 'bar2', ElemType.SEG3: 'bar3', ElemType.TETRA10: 'tetra10', ElemType.TETRA4: 'tetra4', ElemType.TRI3: 'tria3', ElemType.TRI6: 'tria6'}#
Ensight
- Type:
- EasyFEA.utilities.MeshIO.DICT_ELEMTYPE_TO_MESHIO = {ElemType.HEXA20: 'hexahedron20', ElemType.HEXA27: 'hexahedron27', ElemType.HEXA8: 'hexahedron', ElemType.POINT: 'vertex', ElemType.PRISM15: 'wedge15', ElemType.PRISM18: 'wedge18', ElemType.PRISM6: 'wedge', ElemType.QUAD4: 'quad', ElemType.QUAD8: 'quad8', ElemType.QUAD9: 'quad9', ElemType.SEG2: 'line', ElemType.SEG3: 'line3', ElemType.SEG4: 'line4', ElemType.SEG5: 'line5', ElemType.TETRA10: 'tetra10', ElemType.TETRA4: 'tetra', ElemType.TRI10: 'triangle10', ElemType.TRI15: 'triangle15', ElemType.TRI3: 'triangle', ElemType.TRI6: 'triangle6'}#
meshioType
- Type:
- EasyFEA.utilities.MeshIO.DICT_ELEMTYPE_TO_VTK: dict[ElemType, CellType] = {ElemType.HEXA20: CellType.QUADRATIC_HEXAHEDRON, ElemType.HEXA27: CellType.TRIQUADRATIC_HEXAHEDRON, ElemType.HEXA8: CellType.HEXAHEDRON, ElemType.POINT: CellType.VERTEX, ElemType.PRISM15: CellType.QUADRATIC_WEDGE, ElemType.PRISM18: CellType.BIQUADRATIC_QUADRATIC_WEDGE, ElemType.PRISM6: CellType.WEDGE, ElemType.QUAD4: CellType.QUAD, ElemType.QUAD8: CellType.QUADRATIC_QUAD, ElemType.QUAD9: CellType.BIQUADRATIC_QUAD, ElemType.SEG2: CellType.LINE, ElemType.SEG3: CellType.QUADRATIC_EDGE, ElemType.SEG4: CellType.CUBIC_LINE, ElemType.SEG5: CellType.HIGHER_ORDER_EDGE, ElemType.TETRA10: CellType.QUADRATIC_TETRA, ElemType.TETRA4: CellType.TETRA, ElemType.TRI10: CellType.LAGRANGE_TRIANGLE, ElemType.TRI15: CellType.LAGRANGE_TRIANGLE, ElemType.TRI3: CellType.TRIANGLE, ElemType.TRI6: CellType.QUADRATIC_TRIANGLE}#
CellType
- Type:
- EasyFEA.utilities.MeshIO.DICT_ENSIGHT_TO_ELEMTYPE: dict[str, ElemType] = {'bar2': ElemType.SEG2, 'bar3': ElemType.SEG3, 'hexa20': ElemType.HEXA20, 'hexa8': ElemType.HEXA8, 'point': ElemType.POINT, 'quad4': ElemType.QUAD4, 'quad8': ElemType.QUAD8, 'tetra10': ElemType.TETRA10, 'tetra4': ElemType.TETRA4, 'tria3': ElemType.TRI3, 'tria6': ElemType.TRI6, 'wedge15': ElemType.PRISM15, 'wedge6': ElemType.PRISM6}#
ElemType
- Type:
Ensight
- EasyFEA.utilities.MeshIO.DICT_ENSIGHT_TO_GMSH_INDEXES: dict[str, list[int]] = {'bar3': [0, 2, 1], 'hexa20': [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 13, 9, 16, 18, 19, 17, 10, 12, 14, 15], 'tetra10': [0, 1, 2, 3, 4, 5, 6, 7, 9, 8], 'wedge15': [0, 1, 2, 3, 4, 5, 6, 9, 7, 12, 14, 13, 8, 10, 11]}#
list[int]
- Type:
Ensight
- EasyFEA.utilities.MeshIO.DICT_GMSH_TO_ENSIGHT_INDEXES: dict[ElemType, list[int]] = {ElemType.HEXA20: [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 16, 9, 17, 10, 18, 19, 12, 15, 13, 14], ElemType.PRISM15: [0, 1, 2, 3, 4, 5, 6, 8, 12, 7, 13, 14, 9, 11, 10], ElemType.SEG3: [0, 2, 1], ElemType.TETRA10: [0, 1, 2, 3, 4, 5, 6, 7, 9, 8]}#
list[int]
- Type:
- EasyFEA.utilities.MeshIO.DICT_GMSH_TO_VTK_INDEXES: dict[ElemType, list[int]] = {ElemType.HEXA20: [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 13, 9, 16, 18, 19, 17, 10, 12, 14, 15], ElemType.HEXA27: [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 13, 9, 16, 18, 19, 17, 10, 12, 14, 15, 22, 23, 21, 24, 20, 25, 26], ElemType.PRISM15: [0, 1, 2, 3, 4, 5, 6, 9, 7, 12, 14, 13, 8, 10, 11], ElemType.PRISM18: [0, 1, 2, 3, 4, 5, 6, 9, 7, 12, 14, 13, 8, 10, 11, 15, 17, 16], ElemType.TETRA10: [0, 1, 2, 3, 4, 5, 6, 7, 9, 8]}#
list[int]
- Type:
- EasyFEA.utilities.MeshIO.DICT_MESHIO_TO_ELEMTYPE: dict[str, ElemType] = {'hexahedron': ElemType.HEXA8, 'hexahedron20': ElemType.HEXA20, 'hexahedron27': ElemType.HEXA27, 'line': ElemType.SEG2, 'line3': ElemType.SEG3, 'line4': ElemType.SEG4, 'line5': ElemType.SEG5, 'quad': ElemType.QUAD4, 'quad8': ElemType.QUAD8, 'quad9': ElemType.QUAD9, 'tetra': ElemType.TETRA4, 'tetra10': ElemType.TETRA10, 'triangle': ElemType.TRI3, 'triangle10': ElemType.TRI10, 'triangle15': ElemType.TRI15, 'triangle6': ElemType.TRI6, 'vertex': ElemType.POINT, 'wedge': ElemType.PRISM6, 'wedge15': ElemType.PRISM15, 'wedge18': ElemType.PRISM18}#
ElemType
- Type:
CellType
- EasyFEA.utilities.MeshIO.DICT_PYVISTA_TO_ELEMTYPE: dict[CellType, ElemType] = {CellType.VERTEX: ElemType.POINT, CellType.LINE: ElemType.SEG2, CellType.TRIANGLE: ElemType.TRI3, CellType.QUAD: ElemType.QUAD4, CellType.TETRA: ElemType.TETRA4, CellType.HEXAHEDRON: ElemType.HEXA8, CellType.WEDGE: ElemType.PRISM6, CellType.QUADRATIC_EDGE: ElemType.SEG3, CellType.QUADRATIC_TRIANGLE: ElemType.TRI6, CellType.QUADRATIC_QUAD: ElemType.QUAD8, CellType.QUADRATIC_TETRA: ElemType.TETRA10, CellType.QUADRATIC_HEXAHEDRON: ElemType.HEXA20, CellType.QUADRATIC_WEDGE: ElemType.PRISM15, CellType.BIQUADRATIC_QUAD: ElemType.QUAD9, CellType.TRIQUADRATIC_HEXAHEDRON: ElemType.HEXA27, CellType.BIQUADRATIC_QUADRATIC_WEDGE: ElemType.PRISM18, CellType.CUBIC_LINE: ElemType.SEG4, CellType.HIGHER_ORDER_EDGE: ElemType.SEG5, CellType.LAGRANGE_TRIANGLE: ElemType.TRI15}#
ElemType
- Type:
CellType
- EasyFEA.utilities.MeshIO.DICT_VTK_TO_GMSH_INDEXES: dict[CellType, list[int]] = {CellType.QUADRATIC_TETRA: [0, 1, 2, 3, 4, 5, 6, 7, 9, 8], CellType.QUADRATIC_HEXAHEDRON: [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 16, 9, 17, 10, 18, 19, 12, 15, 13, 14], CellType.QUADRATIC_WEDGE: [0, 1, 2, 3, 4, 5, 6, 8, 12, 7, 13, 14, 9, 11, 10], CellType.TRIQUADRATIC_HEXAHEDRON: [0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 16, 9, 17, 10, 18, 19, 12, 15, 13, 14, 24, 22, 20, 21, 23, 25, 26], CellType.BIQUADRATIC_QUADRATIC_WEDGE: [0, 1, 2, 3, 4, 5, 6, 8, 12, 7, 13, 14, 9, 11, 10, 15, 17, 16]}#
list[int]
- Type:
CellType
- EasyFEA.utilities.MeshIO.EasyFEA_to_Ensight(mesh, folder, name)[source]#
Converts EasyFEA mesh to Gmsh format.
- Parameters:
mesh (Mesh) – EasyFEA mesh object.
folder (str) – Directory to save the Ensight .geo file.
name (str) – The name of the Ensight .geo file, without the extension.
- Returns:
Path to the saved Ensight .geo file.
- Return type:
str
- EasyFEA.utilities.MeshIO.EasyFEA_to_Gmsh(mesh, folder, name, useBinary=False)[source]#
Converts EasyFEA mesh to Gmsh format.
- Parameters:
mesh (Mesh) – EasyFEA mesh object.
folder (str) – Directory to save the Gmsh file.
name (str) – The name of the Gmsh file, without the extension.
useBinary (bool, optional) – Whether to save as binary (default is False).
- Returns:
Path to the saved Gmsh file.
- Return type:
str
- EasyFEA.utilities.MeshIO.EasyFEA_to_Medit(mesh, folder, name, dict_tags_converter={}, useBinary=False)[source]#
Converts EasyFEA mesh to Medit format.
- Parameters:
mesh (Mesh) – EasyFEA mesh object.
folder (str) – Directory to save the Medit file.
name (str) – The name of the Medit file, without the extension.
dict_tags_converter (dict[str, int], optional) – Dictionary converting string tags to integers (default is {}).
useBinary (bool, optional) – Whether to save as binary (default is False).
- Returns:
Path to the saved Medit file.
- Return type:
str
- EasyFEA.utilities.MeshIO.EasyFEA_to_PyVista(mesh, coord=None, useAllElements=True)[source]#
Converts EasyFEA mesh to PyVista Multiblock format.
- Parameters:
mesh (Mesh) – EasyFEA mesh object.
coord (_types.FloatArray, optional) – mesh coordinates, by default None
useAllElements (bool, optional) – Use all group of elements, by default True Uses only the main group of elements if set to False.
- Returns:
pyvista mesh
- Return type:
pv.UnstructuredGrid
- EasyFEA.utilities.MeshIO.Ensight_to_EasyFEA(geoFile)[source]#
Converts Ensight mesh to EasyFEA format.
- Parameters:
geoFile (str) – Path to the Ensight geo file.
- Returns:
Converted EasyFEA mesh object.
- Return type:
- EasyFEA.utilities.MeshIO.Gmsh_to_EasyFEA(gmshMesh)[source]#
Converts Gmsh mesh to EasyFEA format.
- Parameters:
gmshMesh (str) – Path to the Gmsh mesh file.
- Returns:
Converted EasyFEA mesh object.
- Return type:
- EasyFEA.utilities.MeshIO.Medit_to_EasyFEA(meditMesh)[source]#
Converts Medit mesh to EasyFEA format.
- Parameters:
meditMesh (str) – Path to the Medit mesh file.
- Returns:
Converted EasyFEA mesh object.
- Return type:
- EasyFEA.utilities.MeshIO.PyVista_to_EasyFEA(pyVistaMesh)[source]#
Converts PyVista mesh to EasyFEA format.
- Parameters:
pyVistaMesh (pv.UnstructuredGrid | pv.MultiBlock) – PyVista mesh object.
- Returns:
Converted EasyFEA mesh object.
- Return type:
- EasyFEA.utilities.MeshIO.Surface_reconstruction(mesh)[source]#
Reconstructs the missing surfaces in a mesh.
- Return type:
- EasyFEA.utilities.MeshIO._Meshio_to_EasyFEA(meshioMesh)[source]#
Converts meshio mesh to EasyFEA format.
- Parameters:
meshioMesh (meshio.Mesh) – Meshio mesh object.
- Returns:
Converted EasyFEA mesh object.
- Return type:
Numba functions to speed up calculations.
- EasyFEA.utilities.Numba.Get_Anisot_C(Cp_e_pg, mat, Cm_e_pg)[source]#
- Return type:
tuple[ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]]]
- EasyFEA.utilities.Numba.Get_Cp_Cm_Stress(c, sP_e_pg, sM_e_pg)[source]#
- Return type:
tuple[ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]]]
- EasyFEA.utilities.Numba.Get_G12_G13_G23(M1, M2, M3)[source]#
- Return type:
tuple[ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]]]
- EasyFEA.utilities.Numba.Get_projP_projM_2D(BetaP, gammap, BetaM, gammam, m1, m2)[source]#
- Return type:
tuple[ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]]]
- EasyFEA.utilities.Numba.Get_projP_projM_3D(dvalp, dvalm, thetap, thetam, list_mi, list_Gab)[source]#
- Return type:
tuple[ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]]]
This module allows you to save a simulation’s results on Paraview (https://www.paraview.org/).
- EasyFEA.utilities.Paraview.Save_simu(simu, folder, N=200, details=False, nodeFields=[], elementFields=[])[source]#
Generates the paraview (.pvd and .pvu files) with a simu.
- Parameters:
simulation (_Simu) – Simulation
folder (str) – folder in which we will create the Paraview folder
N (int, optional) – Maximal number of iterations displayed, by default 200
details (bool, optional) – details of nodesField and elementsField used in the .vtu
nodesField (list, optional) – Additional nodesField, by default []
elementsField (list, optional) – Additional elementsField, by default []
Module providing an interface with PyVista (https://docs.pyvista.org/version/stable/).
https://docs.pyvista.org/api/plotting/plotting.html
- EasyFEA.utilities.PyVista.Movie_func(func, N, folder, filename='video.gif')[source]#
Generates the movie for the specified function.
This function will peform a loop in range(N).
- Parameters:
func (Callable[[pv.Plotter, int], None]) –
The function that will use in first argument the plotter and in second argument the iter step such that.
def func(plotter, i) -> None
N (int) – number of iteration
folder (str) – folder where you want to save the video
filename (str, optional) – filename of the video with the extension (gif, mp4), by default ‘video.gif’
- EasyFEA.utilities.PyVista.Movie_simu(simu, result, folder, filename='video.gif', N=200, deformFactor=0.0, coef=1.0, nodeValues=True, **kwargs)[source]#
Generates a movie from a simulation’s result.
- Parameters:
simu (_Simu) – simulation
result (str) – result that you want to plot
folder (str) – folder where you want to save the video
filename (str, optional) – filename of the video with the extension (gif, mp4), by default ‘video.gif’
N (int, optional) – Maximal number of iterations displayed, by default 200
deformFactor (float, optional) – Factor used to display the deformed solution (0 means no deformations), default 0.0
coef (float, optional) – Coef to apply to the solution, by default 1.0
nodeValues (bool, optional) – Displays result to nodes otherwise displays it to elements, by default True
- Return type:
None
- EasyFEA.utilities.PyVista.Plot(obj, result=None, deformFactor=0.0, coef=1.0, nodeValues=True, color=None, plotMesh=False, edgecolor='k', linewidth=None, plotNodes=False, point_size=None, alpha=1.0, style='surface', cmap='jet', nColors=256, clim=None, plotter=None, show_grid=False, colorbarTitle=None, verticalColobar=True, **kwargs)[source]#
Plots the object obj that can be either a simu, mesh, MultiBlock, PolyData.
If you want to plot the solution use plotter.show().
- Parameters:
obj (_Simu | Mesh | _GroupElem | MultiBlock | PolyData | UnstructuredGrid) – The object to plot and will be transformed to a mesh
result (Union[str,_types.FloatArray], optional) – Scalars used to “color” the mesh, by default None
deformFactor (float, optional) – Factor used to display the deformed solution (0 means no deformations), default 0.0
coef (float, optional) – Coef to apply to the solution, by default 1.0
nodeValues (bool, optional) – Displays result to nodes otherwise displays it to elements, by default True
color (str, optional) – Use to make the entire mesh have a single solid color, by default None
plotMesh (bool, optional) – Shows the edges of a mesh. Does not apply to a wireframe representation, by default False
edgecolor (str, optional) – The solid color to give the edges when show_edges=True, by default ‘k’
linewidth (float, optional) – Thickness of lines. Only valid for wireframe and surface representations, by default None
plotNodes (bool, optional) – Shows the nodes, by default False
point_size (float, optional) – Point size of any nodes in the dataset plotted when plotNodes=True, by default None
alpha (float | str | ndarray, optional) – Opacity of the mesh, by default 1.0
style (str, optional) – Visualization style of the mesh. One of the following: [‘surface’, ‘wireframe’, ‘points’, ‘points_gaussian’], by default ‘surface’
cmap (str, optional) –
If a string, this is the name of the matplotlib colormap to use when mapping the scalars, by default “jet”
[“jet”, “seismic”, “binary”] -> https://matplotlib.org/stable/tutorials/colors/colormaps.html
nColors (int, optional) – Number of colors to use when displaying scalars, by default 256
clim (sequence[float], optional) – Two item color bar range for scalars. Defaults to minimum and maximum of scalars array. Example: [-1, 2], by default None
plotter (pv.Plotter, optional) – The pyvista plotter, by default None and create a new Plotter instance
show_grid (bool, optionnal) – Show the grid, by default False
colorbarTitle (str, optionnal) – colorbar title, by default None
verticalColobar (bool, optionnal) – color bar is vertical, by default True
**kwargs – Everything that can goes in add_mesh function https://docs.pyvista.org/version/stable/api/plotting/_autosummary/pyvista.Plotter.add_mesh.html#pyvista.Plotter.add_mesh
- Returns:
The pyvista plotter
- Return type:
pv.Plotter
- EasyFEA.utilities.PyVista.Plot_BoundaryConditions(simu, deformFactor=0.0, plotter=None)[source]#
Plots simulation’s boundary conditions.
- Parameters:
simu (Simu) – simulation
deformFactor (float, optional) – Factor used to display the deformed solution (0 means no deformations), default 0.0
plotter (pv.Plotter, optional) – The pyvista plotter, by default None and create a new Plotter instance, default None
- Returns:
The pyvista plotter
- Return type:
pv.Plotter
- EasyFEA.utilities.PyVista.Plot_Elements(obj, nodes=None, dimElem=None, showId=False, deformFactor=0.0, alpha=1.0, color='red', edgecolor='black', linewidth=None, label=None, plotter=None)[source]#
Plots the mesh elements corresponding to the given nodes.
- Parameters:
nodes (_types.IntArray, optional) – nodes used by elements, default None
dimElem (int, optional) – dimension of elements, by default None (mesh.dim)
showId (bool, optional) – display numbers, by default False
deformFactor (float, optional) – Factor used to display the deformed solution (0 means no deformations), default 0.0
alpha (float, optional) – transparency of faces, by default 1.0
color (str, optional) – color used to display faces, by default ‘red
edgecolor (str, optional) – color used to display segments, by default ‘black’
linewidth (float, optional) – Thickness of lines, by default None
label (str, optional) – label, by default None
plotter (pv.Plotter, optional) – The pyvista plotter, by default None and create a new Plotter instance
- Returns:
The pyvista plotter
- Return type:
pv.Plotter
- EasyFEA.utilities.PyVista.Plot_Geoms(geoms, line_width=2, plotLegend=True, plotter=None, **kwargs)[source]#
Plots _Geom objects
- Parameters:
geoms (list[_Geom]) – list of geom object
plotLegend (bool,) – plot the legend, by default True
line_width (float, optional) – Thickness of lines, by default 2
plotter (pv.Plotter, optional) – The pyvista plotter, by default None and create a new Plotter instance
**kwargs – Everything that can goes in Plot() and add_mesh function https://docs.pyvista.org/version/stable/api/plotting/_autosummary/pyvista.Plotter.add_mesh.html#pyvista.Plotter.add_mesh
- Returns:
The pyvista plotter
- Return type:
pv.Plotter
- EasyFEA.utilities.PyVista.Plot_Mesh(obj, deformFactor=0.0, alpha=1.0, color='cyan', edgecolor='black', linewidth=0.5, plotter=None)[source]#
Plots the mesh.
- Parameters:
obj (_Simu | Mesh | MultiBlock | PolyData | UnstructuredGrid) – object containing the mesh
deformFactor (float, optional) – Factor used to display the deformed solution (0 means no deformations), default 0.0
alpha (float, optional) – face opacity, default 1.0
color (str, optional) – face colors, default ‘cyan’
edgecolor (str, optional) – edge color, default ‘black’
line_width (float, optional) – line width, default 0.5
plotter (pv.Plotter, optional) – The pyvista plotter, by default None and create a new Plotter instance
- Returns:
The pyvista plotter
- Return type:
pv.Plotter
- EasyFEA.utilities.PyVista.Plot_Nodes(obj, nodes=None, showId=False, deformFactor=0, color='red', folder='', label=None, plotter=None)[source]#
Plots mesh’s nodes.
- Parameters:
nodes (_types.IntArray, optional) – nodes to display, default None
showId (bool, optional) – display node numbers, default False
deformFactor (float, optional) – Factor used to display the deformed solution (0 means no deformations), default 0.0
color (str, optional) – color, default ‘red’
label (str, optional) – label, by default None
plotter (pv.Plotter, optional) – The pyvista plotter, by default None and create a new Plotter instance
- Returns:
The pyvista plotter
- Return type:
pv.Plotter
- EasyFEA.utilities.PyVista.Plot_Tags(obj, plotter=None)[source]#
Plots the mesh’s elements tags (from 2d elements to points) but do not plot the 3d elements tags.
Module providing functions used to save FEM-solutions for vizir (https://pyamg.saclay.inria.fr/vizir4.html).
- EasyFEA.utilities.Vizir.Save_simu(simu, results, types, folder, N=None)[source]#
Saves simulation results to files and prepares a command for visualization.
- Parameters:
simu (_Simu) – The simulation object containing the results to be saved.
results (list[str]) – A list of result names to be saved.
types (list[int]) – A list of types corresponding to each result.
folder (str) – The directory where the results will be saved.
N (Optional[int], optional) – The number of iterations to sample from the simulation. If None, all iterations are used.
- Returns:
A command string for visualizing the saved results using vizir.
- Return type:
str