I want to define an interior boundary (a fault) inside a rectangular domain. I would like for the boundary to be defined piecewise as straight lines connecting various points (so I would have some jagged interior boundary inside the domain). I would also like the option of defining multiple faults within the domain. I'm not sure what is the best way to accomplish this but I have decided to define a Fault class that has an initializer which takes as input the points which define the fault and then constructs a class for that particular fault. For the simple case of a vertical fault I can write the code pretty easily and have included the snippet below. Obviously when I generalize to zig-zag faults the input won't just be a location but an array of points. Drawing straight lines between these points defines the fault. I can write the initializer just fine but I'm wondering if there's a convenient way to define the inside routine. When the fault is vertical or horizontal and just consists of one line it's fairly easy. But when there are multiple connected line segments which may run diagonally (not just vertically or horizontally) the definition becomes much trickier. I'm sure I could do it with some work but I'm just wondering if anyone knows of a convenient way to write something like this.
Sorry for the lengthy question, it's a bit difficult to put into words. The gist of it is that I'd like to define an interior boundary which can "zig zag" through the interior of the domain" and I'd like to be able to specify the geometry as input to the python script.
Below is the code snippet for the case of vertical faults which take as input the x-location of the fault. I would like to generalize it in an elegant way:
class Fault(SubDomain):
def __init__(self, fault_loc):
# Look into why I need this...
self.fault_loc=fault_loc
SubDomain.__init__(self)
def inside(self, x, on_boundary):
return near(x[0], self.fault_loc) and between(x[1], (0.4, 0.6))
fault1 = Fault(0.25)
fault2 = Fault(0.75)
One last thing: if anyone has advice for a better way to do this please let me know. I decided to write a general class for fault boundaries because that was all I could think of, but I would certainly be open to simpler suggestions.
Thanks!