diff --git a/cxxfem/tests/beam2d.py b/cxxfem/tests/beam2d.py index 891407ab21223ee7fbe2f70b43579b0637008b76..1e75f332b227e8cc10f7fa530e63a801c5772c28 100644 --- a/cxxfem/tests/beam2d.py +++ b/cxxfem/tests/beam2d.py @@ -96,7 +96,10 @@ if __name__ == "__main__": post.build_views() post.show_views( [ "stress_tensor", "force_vector" ] ) post.deform(5) - post.probe("force_vector", 1) - post.view() + post.probe("force_vector", 1) + + args = fem.parseargs() + if not args.nogui: + post.view() \ No newline at end of file diff --git a/cxxfem/tests/beam3d.py b/cxxfem/tests/beam3d.py index 6e8f6f14997227909f09ebcb8634c85f218b6243..ad4b9327e12e92f36d216a377d12ebb0a1b255fe 100644 --- a/cxxfem/tests/beam3d.py +++ b/cxxfem/tests/beam3d.py @@ -69,5 +69,8 @@ if __name__ == "__main__": post.set_camera_3D() # post.write() post.deform() - post.view() + + args = fem.parseargs() + if not args.nogui: + post.view() diff --git a/fossils.py b/fossils.py index dda22a3bbb128fff87575e3882e40ebdf49e9df5..dd98ac4fc82775ddb4e7049e990c409a6584611a 100644 --- a/fossils.py +++ b/fossils.py @@ -110,6 +110,7 @@ if __name__ == "__main__": # ask for a file if not given if not args.file: + # QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) app = QApplication(sys.argv) app.setOrganizationName("ULiege") app.setApplicationName("fossils") @@ -125,7 +126,7 @@ if __name__ == "__main__": testname = os.path.abspath(args.file) print(f'action={action}') - if action=='run': + if action=='run' or action=='post': testname = os.path.normcase(testname) # F:/ => f:/ on Windows print(f'testname = {testname}') @@ -135,13 +136,45 @@ if __name__ == "__main__": resdir, ext = os.path.splitext(resdir) wdir = os.path.join('workspace', resdir) print('workspace=', wdir) + if not os.path.isdir(wdir): os.makedirs(wdir) os.chdir(wdir) tee = cxxfem.Tee('stdout.txt') # split streams - if ext == '.py': - # run python script - __file__ = testname - exec(open(testname, encoding='utf-8').read()) + if action == 'run': + if ext == '.py': + # run python script + __file__ = testname + exec(open(testname, encoding='utf-8').read()) + elif action == 'post': + import gmsh + gmsh.initialize() + # gmsh.merge('mesh.msh') + # print('loading options...') + # gmsh.merge('mesh.opt') + gmsh.option.setNumber("General.Verbosity", 3) + views = [] + with open('mesh.opt') as f: + import re + viewregex = re.compile('View\[(.+)\].FileName = "(.+)";') + for l in f.readlines(): + match = viewregex.search(l) + if match: + g = match.groups() + views.append(g) + for v in views: + print(f'loading "{v[1]}"') + gmsh.merge(v[1]) + + # gmsh.view.combine("elements", + # "all", + # True, + # True) + print('loading options...') + gmsh.merge('mesh.opt') + print('please wait...') + # for f in os.listdir(): + # print(f) + gmsh.fltk.run()