242 |
if self.getDim()==2: |
if self.getDim()==2: |
243 |
self.__depth[tag]=0. |
self.__depth[tag]=0. |
244 |
else: |
else: |
245 |
self.__depth[tag]=sum([numpy.linalg.norm(faults[1][i]-faults[0][i]) for i in xrange(len_faults)])/len_faults |
self.__depth[tag]=float(sum([numpy.linalg.norm(faults[1][i]-faults[0][i]) for i in xrange(len_faults)])/len_faults) |
246 |
if w1_max==None or self.getDim()==2: w1_max=self.__depth[tag] |
if w1_max==None or self.getDim()==2: w1_max=self.__depth[tag] |
247 |
self.__length[tag]=sum([numpy.linalg.norm(faults[0][i]-faults[0][i-1]) for i in xrange(1,len_faults)]) |
self.__length[tag]=float(sum([numpy.linalg.norm(faults[0][i]-faults[0][i-1]) for i in xrange(1,len_faults)])) |
248 |
self.__w1_max[tag]=w1_max |
self.__w1_max[tag]=w1_max |
249 |
# |
# |
250 |
# |
# |
254 |
else: |
else: |
255 |
self.__offsets[tag]=[0.] |
self.__offsets[tag]=[0.] |
256 |
for i in xrange(1,len_faults): |
for i in xrange(1,len_faults): |
257 |
self.__offsets[tag].append(self.__offsets[tag][-1]+numpy.linalg.norm(faults[0][i]-faults[0][i-1])) |
self.__offsets[tag].append(self.__offsets[tag][-1]+float(numpy.linalg.norm(faults[0][i]-faults[0][i-1]))) |
258 |
w0_max=max(self.__offsets[tag]) |
w0_max=max(self.__offsets[tag]) |
259 |
self.__w0_max[tag]=w0_max |
self.__w0_max[tag]=w0_max |
260 |
|
|
338 |
raise ValueError,"3D is not supported yet." |
raise ValueError,"3D is not supported yet." |
339 |
|
|
340 |
return p, updated |
return p, updated |
341 |
|
|
342 |
|
def __getSignedDistance(self,x,tag=None): |
343 |
|
""" |
344 |
|
returns the signed distance at ``x`` from the fault ``tag`` where the first and the last segments are extended to infinity. |
345 |
|
|
346 |
|
:param x: location(s) |
347 |
|
:type x: `escript.Data` object or `numpy.ndarray` |
348 |
|
:param tag: the tage of the fault |
349 |
|
""" |
350 |
|
p=x[0]*0 |
351 |
|
if self.getDim()==2: |
352 |
|
mat=numpy.array([[0., -1.], [1., 0.] ]) |
353 |
|
# |
354 |
|
# |
355 |
|
s=self.getFaultSegments(tag)[0] |
356 |
|
for i in xrange(1,len(s)): |
357 |
|
d=(s[i]-s[i-1]) |
358 |
|
h=x-s[i-1] |
359 |
|
d_l=length(d) |
360 |
|
if not d_l>0: |
361 |
|
raise ValueError,"segement %s in fault %s has zero length."%(i,tag) |
362 |
|
dt=numpy.dot(mat,d)/d_l |
363 |
|
a=numpy.dot(h,dt) |
364 |
|
p=maximum(a,p) |
365 |
|
else: |
366 |
|
raise ValueError,"3D is not supported yet." |
367 |
|
return p |
368 |
|
|
369 |
|
|
370 |
def patchMap(v,v1,v2,v3,v4,x_offset,x_length,depth): |
def patchMap(v,v1,v2,v3,v4,x_offset,x_length,depth): |
410 |
s=numpy.dot(h,d4-st*numpy.dot(v3-v4,d4))/numpy.dot(v4-v1,d4) |
s=numpy.dot(h,d4-st*numpy.dot(v3-v4,d4))/numpy.dot(v4-v1,d4) |
411 |
t=numpy.dot(h,d2-st*numpy.dot(v3-v2,d2))/numpy.dot(v2-v1,d2) |
t=numpy.dot(h,d2-st*numpy.dot(v3-v2,d2))/numpy.dot(v2-v1,d2) |
412 |
return x_offset+s*x_length, -depth*t |
return x_offset+s*x_length, -depth*t |
413 |
|
|