pmgbergen / porepy

Python Simulation Tool for Fractured and Deformable Porous Media

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unify type of domain object

jhabriel opened this issue · comments

Currently, to define a domain (also called a bounding box in many places) one can either define a dictionary or a numpy array. This poses several problems for mypy (and development in general).

We have reached the decision to restrict domain to be purely a dictionary, e.g., domain: dict[str, pp.number]. If needed as an numpy array, a method that converts it from dictionary to array should be employed.

[Update]

Things are uglier than I anticipated. I turns out a bounding box can currently be 3 things:

  • A dictionary with strings as keys and numbers as values.
  • A 2-tuple of ndarrays containing the min/max node coordinates. The shape of the arrays are not consistent either, e.g., bounding boxes inferred from 2d and 3d grids will have different shapes.
  • A point cloud in the form of numpy array of shape = (nd, num_points).

[Update]

It turns out that there is value in representing a domain as numpy array. Unifying the domain representation as a dictionary was a hopeless (but fair) attempt. One very rapidly encounters all sorts of inconsistencies when taking this path.

This motivated taking a few steps back and rethinking the definition of a domain in PorePy. Currently, a domain is many things, e.g., the bounding box, a list of arrays describing a polyhedron, a numpy array describing a polygon, a tuple describing the minimum and maximum node coordinates of a point cloud, grid, or mdg.

The proposed definition of a domain is the following one:

An instance of the class pp.Domain (which can be constructed either by giving a bounding box or, for general domains, as a list of numpy arrays representing a polytope) containing all the geometric information necessary to fully describe a domain.

Based on the above definition, I will soon make a PR that will fix the previously mentioned inconsistencies.