Skip to content

API – io

HOMER.io.save_mesh(obj_mesh, file_location)

Serialise a mesh to a JSON file.

Parameters:

Name Type Description Default
obj_mesh Mesh

The :class:~HOMER.mesher.Mesh to save.

required
file_location PathLike

Destination path. A .json extension is recommended.

required

HOMER.io.load_mesh(file_location)

Load a mesh from a JSON file produced by :func:save_mesh.

Parameters:

Name Type Description Default
file_location PathLike

Path to the .json mesh file.

required

Returns:

Type Description
Mesh

A fully initialised :class:~HOMER.mesher.Mesh object.


HOMER.io.dump_mesh_to_dict(obj_mesh)

Serialise a :class:~HOMER.mesher.Mesh to a plain Python dictionary.

The resulting dict has two top-level keys:

  • 'nodes' – ordered dict of node definitions, each with 'loc' and any derivative arrays ('du', 'dv', …).
  • 'elements' – ordered dict of element definitions, each with 'nodes' (list of node indexes/ids), 'basis' (list of basis class name strings), and 'used_index' (bool).

Parameters:

Name Type Description Default
obj_mesh Mesh

The mesh to serialise.

required

Returns:

Type Description
dict

JSON-serialisable dictionary representation of the mesh.


HOMER.io.parse_mesh_from_dict(dict_rep)

Deserialise a :class:~HOMER.mesher.Mesh from a plain Python dictionary.

Reconstructs nodes (with all derivative arrays), elements (looking up basis classes by name), and calls :meth:~HOMER.mesher.MeshField.generate_mesh before returning.

Parameters:

Name Type Description Default
dict_rep dict

Dictionary in the format produced by :func:dump_mesh_to_dict.

required

Returns:

Type Description
Mesh

A fully initialised :class:~HOMER.mesher.Mesh object.