pmgbergen / porepy

Python Simulation Tool for Fractured and Deformable Porous Media

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistency in fracture_network_2d with domain = None

OmarDuran opened this issue · comments

This issue is intended to record that, when one tries to generate an mdg with fracture_network_2d and domain = None, the method impose_external_boundary will generate an UnboundLocalError: "local variable 'dom_p' referenced before assignment".

At first, I thought I introduced this bug in #810. However, it seems that the issue was present before that.

My understanding is that the only usage for this case is DFN-type geometries, where we only care about the fracture set (and not the domain).

In that case, I suggest we impose a "fictitious" domain outside the bounding box span by the min/max coordinates of the fractures, so that the fracture set can be mesh when dfn=True is given as a flag to fracture_network.mesh().

My suggestion is to do something like this at the beginning of impose_internal_boundary:

        # Get min/max point of the domain. If no domain is given, a bounding box
        # using the `self.tol` will be imposed outside the fracture set
        if domain is None:
            # Sanity check
            if len(self.fractures) == 0:
                raise ValueError("No fractures given. Domain cannot be imposed.")
            # Loop through the fracture list and retrieve the pts
            x_pts = []
            y_pts = []
            for frac in self.fractures:
                # Append all start/end-points in the x-direction
                x_pts.append(frac.pts[0][0])
                x_pts.append(frac.pts[0][1])
                # Append all start/end-points in the y-direction
                y_pts.append(frac.pts[1][0])
                y_pts.append(frac.pts[1][1])
            # Get min/max points
            x_min = np.min(np.asarray(x_pts)) - self.tol
            x_max = np.max(np.asarray(x_pts)) + self.tol
            y_min = np.min(np.asarray(y_pts)) - self.tol
            y_max = np.max(np.asarray(y_pts)) + self.tol
        else:
            # First create lines that define the domain
            x_min = domain.bounding_box["xmin"]
            x_max = domain.bounding_box["xmax"]
            y_min = domain.bounding_box["ymin"]
            y_max = domain.bounding_box["ymax"]

@keileg : What do you think of this solution?

I believe this could be an acceptable workaround while we are waiting for the elusive root-and-branch cleanup of the fracture networks. DFNs are hardly used, but could come in handy at some point, so I prefer to keep the option as long as we don't sacrifice too much doing so.

@alessiofumagalli: Do you still use DFN networks these days?