simnibs.Msh¶
-
class
simnibs.
Msh
(nodes=None, elements=None, fn=None)¶ class to handle the meshes. Gatters Nodes, Elements and Data
- Parameters
nodes ((optional) simnibs.msh.Nodes) – Nodes structure
elements ((optional) simnibs.msh.Elements()) – Elements structure
fn (str (optional)) – Name of “.msh” file to be read. Overides nodes and elements
-
nodes
¶ a Nodes field
- Type
simnibs.msh.Nodes
-
elm
¶ A Elements field
- Type
simnibs.msh.Elements
-
nodedata
¶ list of NodeData filds
- Type
simnibs.msh.NodeData
-
elmdata
¶ list of ElementData fields
- Type
simnibs.msh.ElementData
-
fn
¶ name of file
- Type
str
-
binary
¶ wheather or not the mesh was in binary format
- Type
bool
-
__init__
(nodes=None, elements=None, fn=None)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
([nodes, elements, fn])Initialize self.
add_element_field
(field, field_name)Adds field defined in the elements
add_node_field
(field, field_name)Adds field defined in the nodes
calc_matsimnibs
(center, pos_ydir, distance)Calculate the matsimnibs matrix for TMS simulations
compact_ordering
(node_number)Changes the node and element ordering so that it goes from 1 to nr_nodes
crop_mesh
([tags, elm_type, nodes, elements])Crops the specified tags from the mesh Generates a new mesh, with only the specified tags The nodes are also reordered
elements_baricenters
()Calculates the baricenter of the elements
elements_volumes_and_areas
()Calculates the volumes of tetrahedra and areas of triangles
elm2node_matrix
([elm_indices])Calculates a sparse matrix to tranform from ElementData to NodeData Uses Superconvergent patch recovery for volumetric data.
elm_node_coords
([elm_nr, tag, elm_type])Returns the position of each of the element’s nodes
fields_summary
([roi, fields, percentiles, …])Creates a text summaty of the field
find_closest_element
(querry_points[, …])Finds the closest node to each point in p
find_corresponding_tetrahedra
()Finds the tetrahedra corresponding to each triangle
find_shared_nodes
(tags)Finds the nodes which are shared by all given tags
find_tetrahedron_with_points
(points[, …])Finds the tetrahedron that contains each of the described points using a stochastic walk algorithm
fix_surface_labels
()Fixels labels of surfaces
fix_th_node_ordering
()Fixes the node ordering of tetrahedra in-place
fix_thin_tetrahedra
([n_iter, step_length])Optimize the locations of the points by moving them towards the center of their patch.
fix_tr_node_ordering
()Fixes the node ordering of the triangles in-place
gaussian_curvature
()Calculates the Gaussian curvature at each node
intercept_ray
(near, far)Finds the triangle (if any) that intercepts a line segment
interp_matrix
(pos[, out_fill, th_indices, …])Calculates a matrix to perform interpolation y = M.dot(x)
join_mesh
(other)Join the current mesh with another
nodes_areas
()Areas for all nodes in a surface
nodes_normals
([smooth])Normals for all nodes in a surface
nodes_volumes_or_areas
()Return the volume (volume mesh) if area (surface mesh) of all nodes Only works for ordered values of mesh and node indices
open_in_gmsh
()Opens the mesh in gmsh
prepare_surface_tags
()read_hdf5
(hdf5_fn[, path, load_data])Reads mesh information from an hdf5 file
reconstruct_surfaces
([tags])Reconstruct the mhes surfaces for each label/connected component individually This function acts in-place, and will keep any surfaces already present in the mesh
remove_from_mesh
([tags, elm_type, nodes, …])Removes the specified tags from the mesh Generates a new mesh, with the specified tags removed The nodes are also reordered
test_inside_volume
(points)Tests if points are iside the volume using the Möller–Trumbore intersection algorithm
tetrahedra_quality
()calculates the quality measures of the tetrahedra
triangle_angles
()Calculates minimum angle of the mesh triangles
triangle_normals
([smooth])Calculates the normals of triangles
view
([visible_tags, visible_fields])Visualize mesh in Gmsh
write
(out_fn)Writes out the mesh as a “.msh” file
write_hdf5
(hdf5_fn[, path, compression])Writes a HDF5 file with mesh information
Attributes
field
Dictionary of fields indexed by their name