Skip to content

Commit

Permalink
Merge branch 'ParallelNCFlex' into 3D_NCFlex
Browse files Browse the repository at this point in the history
ENH: Brought alpha backtracking feature onto 3D NCFlex branch
  • Loading branch information
Fraser-Birks committed Oct 25, 2023
2 parents 18cd409 + 17bf399 commit fbdbe53
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions matscipy/fracture_mechanics/crack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,8 @@ def arc_length_continuation(self, x0, x1, N=10, ds=0.01, ftol=1e-2,
opt_method='krylov',
cos_alpha_min=0.9,parallel=False,
pipe_output=None,data_queue=None,
kill_confirm_queue=None):
kill_confirm_queue=None,
allow_alpha_backtracking=False):
import h5py
assert self.variable_k # only makes sense if K can vary

Expand All @@ -1535,6 +1536,9 @@ def arc_length_continuation(self, x0, x1, N=10, ds=0.01, ftol=1e-2,
# ensure we start moving in the correct direction
if self.variable_alpha:
_, alphadot1, _ = self.unpack(xdot1)
#print(np.sign(alphadot1))
#print(direction)
#print(direction*np.sign(alphadot1))
if direction * np.sign(alphadot1) < 0:
xdot1 = -xdot1
row = 0
Expand Down Expand Up @@ -1581,13 +1585,13 @@ def arc_length_continuation(self, x0, x1, N=10, ds=0.01, ftol=1e-2,

x2 = self.get_dofs()
xdot2 = self.get_xdot(x1, x2, ds)

if self.variable_alpha:
# monitor sign of \dot{alpha} and flip if necessary
#udot1, alphadot1, kdot1 = self.unpack(xdot1)
udot2, alphadot2, kdot2 = self.unpack(xdot2)
if direction * np.sign(alphadot2) < 0:
xdot2 = -xdot2
if not allow_alpha_backtracking:
if self.variable_alpha:
# monitor sign of \dot{alpha} and flip if necessary
#udot1, alphadot1, kdot1 = self.unpack(xdot1)
udot2, alphadot2, kdot2 = self.unpack(xdot2)
if direction * np.sign(alphadot2) < 0:
xdot2 = -xdot2

# cos_alpha = np.dot(xdot1, xdot2) / np.linalg.norm(xdot1) / np.linalg.norm(xdot2)
# print(f'cos_alpha = {cos_alpha}')
Expand Down Expand Up @@ -1636,10 +1640,9 @@ def arc_length_continuation(self, x0, x1, N=10, ds=0.01, ftol=1e-2,
if pipe_output.poll():
kill = pipe_output.recv()
print(f'KILLING PROCESS,{os.getpid()}')
if kill == 1:
#kill the process
i = N
kill_confirm_queue.put(os.getpid())
#kill the process
kill_confirm_queue.put(os.getpid())
break
else:
#put data on queue
data_queue.put([os.getpid(),x2,direction],block=False)
Expand Down

0 comments on commit fbdbe53

Please sign in to comment.