From d332e64c756ca12c1e1d79992e8da70fde9723e8 Mon Sep 17 00:00:00 2001 From: Romain Boman <r.boman@uliege.be> Date: Sun, 29 May 2022 17:29:53 +0200 Subject: [PATCH] add postpro --- cxxfem/tests/beam2d.py | 7 +++++-- cxxfem/tests/beam3d.py | 5 ++++- fossils.py | 43 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/cxxfem/tests/beam2d.py b/cxxfem/tests/beam2d.py index 891407a..1e75f33 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 6e8f6f1..ad4b932 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 dda22a3..dd98ac4 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() -- GitLab