Contains the FEM mesh together with all utilities related to it.
Input and output is handled by the MeshIO class and subclasses. The Mesh class only contains the real mesh - nodes, connectivity, regions, plus methods for doing operations on this mesh.
Example of creating and working with a mesh:
In [1]: from sfepy.discrete.fem import Mesh
In [2]: m = Mesh.from_file("meshes/3d/cylinder.vtk")
sfepy: reading mesh (meshes/3d/cylinder.vtk)...
sfepy: ...done in 0.04 s
In [3]: m.coors
Out[3]:
array([[ 1.00000000e-01, 2.00000000e-02, -1.22460635e-18],
[ 1.00000000e-01, 1.80193774e-02, 8.67767478e-03],
[ 1.00000000e-01, 1.24697960e-02, 1.56366296e-02],
...,
[ 8.00298527e-02, 5.21598617e-03, -9.77772215e-05],
[ 7.02544004e-02, 3.61610291e-04, -1.16903153e-04],
[ 3.19633596e-02, -1.00335972e-02, 9.60460305e-03]])
In [4]: m.ngroups
Out[4]: array([0, 0, 0, ..., 0, 0, 0])
In [5]: m.conns
Out[5]:
[array([[ 28, 60, 45, 29],
[ 28, 60, 57, 45],
[ 28, 57, 27, 45],
...,
[353, 343, 260, 296],
[353, 139, 181, 140],
[353, 295, 139, 140]])]
In [6]: m.mat_ids
Out[6]: [array([6, 6, 6, ..., 6, 6, 6])]
In [7]: m.descs
Out[7]: ['3_4']
In [8]: m
Out[8]: Mesh:meshes/3d/cylinder
In [9]: print m
Mesh:meshes/3d/cylinder
conns:
[array([[ 28, 60, 45, 29],
[ 28, 60, 57, 45],
[ 28, 57, 27, 45],
...,
[353, 343, 260, 296],
[353, 139, 181, 140],
[353, 295, 139, 140]])]
coors:
[[ 1.00000000e-01 2.00000000e-02 -1.22460635e-18]
[ 1.00000000e-01 1.80193774e-02 8.67767478e-03]
[ 1.00000000e-01 1.24697960e-02 1.56366296e-02]
...,
[ 8.00298527e-02 5.21598617e-03 -9.77772215e-05]
[ 7.02544004e-02 3.61610291e-04 -1.16903153e-04]
[ 3.19633596e-02 -1.00335972e-02 9.60460305e-03]]
descs:
['3_4']
dim:
3
el_offsets:
[ 0 1348]
io:
None
mat_ids:
[array([6, 6, 6, ..., 6, 6, 6])]
n_e_ps:
[4]
n_el:
1348
n_els:
[1348]
n_nod:
354
name:
meshes/3d/cylinder
ngroups:
[0 0 0 ..., 0 0 0]
setup_done:
0
The Mesh().coors is an array of node coordinates and Mesh().conns is the list of elements of each type (see Mesh().desc), so for example if you want to know the coordinates of the nodes of the fifth finite element of the type 3_4 do:
In [10]: m.descs
Out[10]: ['3_4']
So now you know that the finite elements of the type 3_4 are in a.conns[0]:
In [11]: m.coors[m.conns[0][4]]
Out[11]:
array([[ 1.00000000e-01, 1.80193774e-02, -8.67767478e-03],
[ 1.00000000e-01, 1.32888539e-02, -4.35893200e-04],
[ 1.00000000e-01, 2.00000000e-02, -1.22460635e-18],
[ 9.22857574e-02, 1.95180454e-02, -4.36416134e-03]])
The element ids are of the form “<dimension>_<number of nodes>”, i.e.:
Create a graph of mesh connectivity.
Returns: | graph : csr_matrix
|
---|
Explode the mesh element groups by eps, i.e. split group interface nodes and shrink each group towards its centre by eps.
Parameters: | eps : float in [0.0, 1.0]
return_emap : bool, optional
|
---|---|
Returns: | mesh : Mesh
emap : spmatrix, optional
|
Create a mesh from mesh data.
Read a mesh from a file.
Parameters: | filename : string or function or MeshIO instance or Mesh instance
io : *MeshIO instance
prefix_dir : str
omit_facets : bool
|
---|
Create a mesh corresponding to a given region.
Create a mesh given a set of surface faces and the original mesh.
Get the coordinates of vertices elements in group ig.
Parameters: | ig : int, optional
|
---|---|
Returns: | coors : array
|
Strips nodes not in inod and remaps connectivities. Omits elements where remap[conn] contains -1...
Transform coordinates of the mesh by the given transformation matrix.
Parameters: | mtx_t : array
ref_coors : array, optional
|
---|
Write mesh + optional results in out to a file.
Parameters: | filename : str, optional
io : MeshIO instance or ‘auto’, optional
coors : array, optional
igs : array_like, optional
out : dict, optional
float_format : str, optional
**kwargs : dict, optional
|
---|
Find a mapping between common coordinates in x1 and x2, such that x1[cmap[:,0]] == x2[cmap[:,1]]
Detect and attempt fixing double nodes in a mesh.
The double nodes are nodes having the same coordinates w.r.t. precision given by eps.
Can miss the minimum, but is enough for our purposes.
For each mesh node referenced in the connectivity conns, make a list of elements it belongs to.