Meshes#

class pybamm.Mesh(geometry, submesh_types, var_pts)[source]#

Mesh contains a list of submeshes on each subdomain.

Parameters:
  • geometry – contains the geometry of the problem.

  • submesh_types (dict) – contains the types of submeshes to use (e.g. Uniform1DSubMesh)

  • submesh_pts (dict) – contains the number of points on each subdomain

Extends: builtins.dict

add_ghost_meshes()[source]#

Create meshes for potential ghost nodes on either side of each submesh, using self.submeshclass This will be useful for calculating the gradient with Dirichlet BCs.

combine_submeshes(*submeshnames)[source]#

Combine submeshes into a new submesh, using self.submeshclass Raises pybamm.DomainError if submeshes to be combined do not match up (edges are not aligned).

Parameters:

submeshnames (list of str) – The names of the submeshes to be combined

Returns:

submesh – A new submesh with the class defined by self.submeshclass

Return type:

self.submeshclass

class pybamm.SubMesh[source]#

Base submesh class. Contains the position of the nodes, the number of mesh points, and (optionally) information about the tab locations. Subclasses that accept limits depending on input parameters set supports_symbolic_limits = True.

classmethod from_config(data: dict)[source]#

Deserialise a SubMesh class from a dict (class only, not instance).

classmethod to_config() → dict[source]#

Serialise this SubMesh class to a JSON-serialisable dict (for submesh_types).

class pybamm.MeshGenerator(submesh_type, submesh_params=None)[source]#

Base class for mesh generator objects that are used to generate submeshes.

Parameters:
  • submesh_type (pybamm.SubMesh) – The type of submesh to use (e.g. Uniform1DSubMesh).

  • submesh_params (dict, optional) – Contains any parameters required by the submesh.

static from_config(data: dict)[source]#

Deserialise a MeshGenerator from a dict.

to_config() → dict[source]#

Serialise this MeshGenerator to a JSON-serialisable dict (for submesh_types).