sfepy.discrete.fem.meshio module¶
-
class
sfepy.discrete.fem.meshio.
HDF5MeshIO
(filename, **kwargs)[source]¶ -
ch
= '\xfe'¶
-
format
= 'hdf5'¶
-
read_times
(filename=None)[source]¶ Read true time step data from individual time steps.
Returns: steps : array
The time steps.
times : array
The times of the time steps.
nts : array
The normalized times of the time steps, in [0, 1].
-
string
= <module 'string' from '/usr/lib/python2.7/string.pyc'>¶
-
-
class
sfepy.discrete.fem.meshio.
HypermeshAsciiMeshIO
(filename, **kwargs)[source]¶ -
format
= 'hmascii'¶
-
-
class
sfepy.discrete.fem.meshio.
MeshIO
(filename, **kwargs)[source]¶ The abstract class for importing and exporting meshes.
Read the docstring of the Mesh() class. Basically all you need to do is to implement the read() method:
def read(self, mesh, **kwargs): nodes = ... ngroups = ... conns = ... mat_ids = ... descs = ... mesh._set_io_data(nodes, ngroups, conns, mat_ids, descs) return mesh
See the Mesh class’ docstring how the nodes, ngroups, conns, mat_ids and descs should look like. You just need to read them from your specific format from disk.
To write a mesh to disk, just implement the write() method and use the information from the mesh instance (e.g. nodes, conns, mat_ids and descs) to construct your specific format.
The methods read_dimension(), read_bounding_box() should be implemented in subclasses, as it is often possible to get that kind of information without reading the whole mesh file.
Optionally, subclasses can implement read_data() to read also computation results. This concerns mainly the subclasses with implemented write() supporting the ‘out’ kwarg.
The default implementation od read_last_step() just returns 0. It should be reimplemented in subclasses capable of storing several steps.
-
static
any_from_filename
(filename, prefix_dir=None)¶ Create a MeshIO instance according to the kind of filename.
Parameters: filename : str, function or MeshIO subclass instance
The name of the mesh file. It can be also a user-supplied function accepting two arguments: mesh, mode, where mesh is a Mesh instance and mode is one of ‘read’,’write’, or a MeshIO subclass instance.
prefix_dir : str
The directory name to prepend to filename.
Returns: io : MeshIO subclass instance
The MeshIO subclass instance corresponding to the kind of filename.
-
call_msg
= 'called an abstract MeshIO instance!'¶
-
static
for_format
(filename, format=None, writable=False, prefix_dir=None)¶ Create a MeshIO instance for file filename with forced format.
Parameters: filename : str
The name of the mesh file.
format : str
One of supported formats. If None,
MeshIO.any_from_filename()
is called instead.writable : bool
If True, verify that the mesh format is writable.
prefix_dir : str
The directory name to prepend to filename.
Returns: io : MeshIO subclass instance
The MeshIO subclass instance corresponding to the format.
-
format
= None¶
-
static
-
class
sfepy.discrete.fem.meshio.
Msh2MeshIO
(filename, **kwargs)[source]¶ -
format
= 'msh_v2'¶
-
msh_cells
= {1: (2, 2), 2: (2, 3), 3: (2, 4), 4: (3, 4), 5: (3, 8), 6: (3, 6)}¶
-
prism2hexa
= array([0, 1, 2, 2, 3, 4, 5, 5])¶
-
-
class
sfepy.discrete.fem.meshio.
TetgenMeshIO
(filename, **kwargs)[source]¶ -
format
= 'tetgen'¶
-
static
getele
(fele)[source]¶ Reads t.1.ele, returns a list of elements.
Example:
>>> elements, regions = self.getele("t.1.ele") >>> elements [(20, 154, 122, 258), (86, 186, 134, 238), (15, 309, 170, 310), (146, 229, 145, 285), (206, 207, 125, 211), (99, 193, 39, 194), (185, 197, 158, 225), (53, 76, 74, 6), (19, 138, 129, 313), (23, 60, 47, 96), (119, 321, 1, 329), (188, 296, 122, 322), (30, 255, 177, 256), ...] >>> regions {100: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 7, ...], ...}
-
static
getnodes
(fnods)[source]¶ Reads t.1.nodes, returns a list of nodes.
Example:
>>> self.getnodes("t.1.node") [(0.0, 0.0, 0.0), (4.0, 0.0, 0.0), (0.0, 4.0, 0.0), (-4.0, 0.0, 0.0), (0.0, 0.0, 4.0), (0.0, -4.0, 0.0), (0.0, -0.0, -4.0), (-2.0, 0.0, -2.0), (-2.0, 2.0, 0.0), (0.0, 2.0, -2.0), (0.0, -2.0, -2.0), (2.0, 0.0, -2.0), (2.0, 2.0, 0.0), ... ]
-
-
class
sfepy.discrete.fem.meshio.
UserMeshIO
(filename, **kwargs)[source]¶ Special MeshIO subclass that enables reading and writing a mesh using a user-supplied function.
-
format
= 'function'¶
-
-
sfepy.discrete.fem.meshio.
convert_complex_output
(out_in)[source]¶ Convert complex values in the output dictionary out_in to pairs of real and imaginary parts.
-
sfepy.discrete.fem.meshio.
guess_format
(filename, ext, formats, io_table)[source]¶ Guess the format of filename, candidates are in formats.