Skip to content

Commit 12f928d

Browse files
committed
making plotting in contact test optional.
1 parent 80d9b43 commit 12f928d

File tree

1 file changed

+36
-32
lines changed

1 file changed

+36
-32
lines changed

optimism/contact/test/test_IntegralPenaltyContact.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def p(x) :
5050

5151
class TestEdgeIntersection(TestFixture):
5252

53+
plotting = False
54+
5355
def setUp(self):
5456
self.penalty_length = 0.1
5557
self.edge_smoothing = 0.2
@@ -185,7 +187,8 @@ def test_plot_smoothness(self):
185187
N = 4000
186188
S = np.linspace(0.0, 13.0, N)
187189

188-
# fig, axs = pyplot.subplots(1, 3, gridspec_kw={'width_ratios' : [2.,1.,1.]})
190+
if self.plotting:
191+
fig, axs = pyplot.subplots(1, 3, gridspec_kw={'width_ratios' : [2.,1.,1.]})
189192

190193
def edge_0(step, edge0_mod):
191194
s = S[step]
@@ -260,37 +263,38 @@ def force_vs_time(step, e, n, d):
260263
def force_at_time(step, e, n, d):
261264
return [S[step]],[fs[n,d][step]]
262265

263-
# p = slide_plot(fig, axs, times)
264-
# p.plot(0, mesh0, 'ko-')
265-
# p.plot(0, mesh1, 'ko-')
266-
# p.plot(0, mesh2, 'ko-')
267-
# p.plot(0, mesh3, 'ko-')
268-
# p.arrow(0, arrows0)
269-
270-
# axs[0].set_aspect('equal')
271-
# axs[0].set_xlim([-1.0, 3.0])
272-
# axs[0].set_ylim([-0.81, 0.81])
273-
# axs[0].set_yticks(np.linspace(-0.8, 0.8, 17))
274-
275-
# p.plot(1, energy_vs_time, 'k')
276-
# p.plot(1, energy_at_time, 'go')
277-
278-
# #xlim = [2.0, 2.6]
279-
# #axs[1].set_xlim(xlim)
280-
# axs[1].legend(['energy'])
281-
282-
# p.plot(2, partial(force_vs_time,e=0,n=0,d=0), 'r--')
283-
# p.plot(2, partial(force_at_time,e=0,n=0,d=0), 'ro')
284-
# p.plot(2, partial(force_vs_time,e=0,n=0,d=1), 'r')
285-
# p.plot(2, partial(force_at_time,e=0,n=0,d=1), 'ro')
286-
# p.plot(2, partial(force_vs_time,e=0,n=1,d=0), 'g--')
287-
# p.plot(2, partial(force_at_time,e=0,n=1,d=0), 'go')
288-
# p.plot(2, partial(force_vs_time,e=0,n=1,d=1), 'g')
289-
# p.plot(2, partial(force_at_time,e=0,n=1,d=1), 'go')
290-
291-
# #axs[2].set_xlim(xlim)
292-
# axs[2].legend(['force_x r', '_nolegend_', 'force_y r', '_nolegend_', 'force_x l', '_nolegend_', 'force_y l', '_nolegend_'])
293-
# p.show()
266+
if self.plotting:
267+
p = slide_plot(fig, axs, times)
268+
p.plot(0, mesh0, 'ko-')
269+
p.plot(0, mesh1, 'ko-')
270+
p.plot(0, mesh2, 'ko-')
271+
p.plot(0, mesh3, 'ko-')
272+
p.arrow(0, arrows0)
273+
274+
axs[0].set_aspect('equal')
275+
axs[0].set_xlim([-1.0, 3.0])
276+
axs[0].set_ylim([-0.81, 0.81])
277+
axs[0].set_yticks(np.linspace(-0.8, 0.8, 17))
278+
279+
p.plot(1, energy_vs_time, 'k')
280+
p.plot(1, energy_at_time, 'go')
281+
282+
#xlim = [2.0, 2.6]
283+
#axs[1].set_xlim(xlim)
284+
axs[1].legend(['energy'])
285+
286+
p.plot(2, partial(force_vs_time,e=0,n=0,d=0), 'r--')
287+
p.plot(2, partial(force_at_time,e=0,n=0,d=0), 'ro')
288+
p.plot(2, partial(force_vs_time,e=0,n=0,d=1), 'r')
289+
p.plot(2, partial(force_at_time,e=0,n=0,d=1), 'ro')
290+
p.plot(2, partial(force_vs_time,e=0,n=1,d=0), 'g--')
291+
p.plot(2, partial(force_at_time,e=0,n=1,d=0), 'go')
292+
p.plot(2, partial(force_vs_time,e=0,n=1,d=1), 'g')
293+
p.plot(2, partial(force_at_time,e=0,n=1,d=1), 'go')
294+
295+
#axs[2].set_xlim(xlim)
296+
axs[2].legend(['force_x r', '_nolegend_', 'force_y r', '_nolegend_', 'force_x l', '_nolegend_', 'force_y l', '_nolegend_'])
297+
p.show()
294298

295299

296300
def untest_roundoff(self):

0 commit comments

Comments
 (0)