@@ -19,9 +19,7 @@ class FaultSegment(StructuralFrame):
1919 Class for representing a slip event of a fault
2020 """
2121
22- def __init__ (
23- self , features , name , faultfunction = None , steps = 3 , displacement = 1.0 , fold = None
24- ):
22+ def __init__ (self , features , name , faultfunction = None , steps = 10 , displacement = 1.0 , fold = None ):
2523 """
2624 A slip event of a fault
2725
@@ -263,7 +261,7 @@ def evaluate_displacement(self, points):
263261 d [mask ] = self .faultfunction (gx [mask ], gy [mask ], gz [mask ])
264262 return d * self .displacement
265263
266- def apply_to_points (self , points ):
264+ def apply_to_points (self , points , reverse = False ):
267265 """
268266 Unfault the array of points
269267
@@ -308,6 +306,13 @@ def apply_to_points(self, points):
308306 mask = np .abs (d ) > 0.0
309307
310308 d *= self .displacement
309+ if reverse :
310+ d *= - 1.0
311+ # calculate the anglee and vector to rotate the points
312+ axis = np .zeros ((points .shape [0 ], steps , 3 ))
313+ axis [:] = np .nan
314+ angle = np .zeros ((points .shape [0 ], steps ))
315+ angle [:] = np .nan
311316 # calculate the fault frame for the evaluation points
312317 for i in range (steps ):
313318 gx = None
@@ -318,18 +323,10 @@ def apply_to_points(self, points):
318323 with ThreadPoolExecutor (max_workers = 8 ) as executor :
319324 # all of these operations should be
320325 # independent so just run as different threads
321- gx_future = executor .submit (
322- self .__getitem__ (0 ).evaluate_value , newp [mask , :]
323- )
324- g_future = executor .submit (
325- self .__getitem__ (1 ).evaluate_gradient , newp [mask , :]
326- )
327- gy_future = executor .submit (
328- self .__getitem__ (1 ).evaluate_value , newp [mask , :]
329- )
330- gz_future = executor .submit (
331- self .__getitem__ (2 ).evaluate_value , newp [mask , :]
332- )
326+ gx_future = executor .submit (self .__getitem__ (0 ).evaluate_value , newp [mask , :])
327+ g_future = executor .submit (self .__getitem__ (1 ).evaluate_gradient , newp [mask , :])
328+ gy_future = executor .submit (self .__getitem__ (1 ).evaluate_value , newp [mask , :])
329+ gz_future = executor .submit (self .__getitem__ (2 ).evaluate_value , newp [mask , :])
333330 gx = gx_future .result ()
334331 g = g_future .result ()
335332 gy = gy_future .result ()
@@ -363,10 +360,18 @@ def apply_to_points(self, points):
363360 # multiply displacement vector by the displacement magnitude for
364361 # step
365362 g *= (1.0 / steps ) * d [:, None ]
366-
363+ prev_p = newp [ mask , :]. copy ()
367364 # apply displacement
368365 newp [mask , :] += g
369- return newp
366+ # axis[mask, i, :] = np.cross(prev_p, newp[mask, :], axisa=1, axisb=1)
367+ # angle[mask, i] = 2 * np.arctan(
368+ # 0.5 * (np.linalg.norm(prev_p - newp[mask, :], axis=1))
369+ # )
370+ # calculate the angle between the previous and new points
371+ # and the axis of rotation
372+ # g /= np.linalg.norm(g, axis=1)[:, None]
373+ axis [mask , i , :] /= np .linalg .norm (axis [mask , i , :], axis = 1 )[:, None ]
374+ return newp , axis , angle
370375
371376 def add_abutting_fault (self , abutting_fault_feature , positive = None ):
372377
0 commit comments