def exportMshOpt(): optFile = open(onelab.path(__file__, "pend.msh.opt"),'w') optFile.write('n = PostProcessing.NbViews - 1;\n') optFile.write('If(n >= 0)\nView[n].ShowScale = 0;\nView[n].VectorType = 5;\n') optFile.write('View[n].ExternalView = 0;\nView[n].DisplacementFactor = 1 ;\n') optFile.write('View[n].PointType = 1;\nView[n].PointSize = 5;\n') optFile.write('View[n].LineWidth = 2;\nEndIf\n') optFile.close()
def exportMsh(le1,le2): mshFile = open(onelab.path(__file__, "pend.msh"),'w') mshFile.write('$MeshFormat\n2.2 0 8\n$EndMeshFormat\n') mshFile.write('$Nodes\n3\n1 0 0 0\n2 0 %s 0\n3 0 %s 0\n$EndNodes\n' %(-le1, -le1-le2)) mshFile.write('$Elements\n3\n1 1 2 0 1 1 2\n2 1 2 0 1 2 3\n3 15 2 0 2 3\n$EndElements\n') mshFile.close()
def exportIter(iter,t,x1,y1,x2,y2): mshFile = open(onelab.path(__file__, "pend.msh"),'a') mshFile.write('$NodeData\n1\n"motion"\n1\n\t%f\n3\n\t%d\n3\n' % (t, iter)) mshFile.write('\t3\n\t1 0 0 0\n\t2 %f %f 0\n\t3 %f %f 0\n$EndNodeData\n' %(x1,y1,x2,y2)) mshFile.close()
refr += dt exportMshOpt() if refr >= refresh: refr = 0 c.setNumber(c.name + '/Progress', value=time, min=0, max=tmax, visible=0) c.setNumber('Dyna/time [s]', value=time) c.setNumber('Solu/phi', value=phi) c.addNumberChoice('Solu/phi', phi) c.setNumber('Solu/theta', value=theta) c.addNumberChoice('Solu/theta', theta) c.setNumber('Solu/phi dot', value=phi_dot) c.addNumberChoice('Solu/phi dot', phi_dot) c.setNumber('Solu/theta dot', value=theta_dot) c.addNumberChoice('Solu/theta dot', theta_dot) # ask Gmsh to refresh c.setString('Gmsh/Action', value='refresh') # stop if we are asked to (by Gmsh) if(c.getString(c.name + '/Action') == 'stop'): break; exportMsh(l1, l2) exportIter(iter, time, x1, y1+l1, x2, y2+l1+l2) c.mergeFile(onelab.path(__file__, 'pend.msh')) iter += 1 c.setNumber(c.name + '/Progress', value=0)