From 52e48513a412e3bc40aebe609686a5e8feb6793b Mon Sep 17 00:00:00 2001 From: Romain Boman <r.boman@uliege.be> Date: Sat, 4 Jun 2022 17:26:30 +0200 Subject: [PATCH] improve postprocessing --- cxxfem/src/femDOF.h | 2 +- cxxfem/src/femPost.cpp | 11 +++++++++++ cxxfem/src/femProblem.cpp | 3 ++- fossils.py | 18 ++++++------------ models/bonemodel2.py | 2 -- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/cxxfem/src/femDOF.h b/cxxfem/src/femDOF.h index 2e2ad4f..874e9a3 100644 --- a/cxxfem/src/femDOF.h +++ b/cxxfem/src/femDOF.h @@ -53,7 +53,7 @@ class FEM_API DOFMask size_t v; ///< mask public: /// create a mask from a single dof (implicitly if needed) - DOFMask(DOF const &dof) : dofs(dof.dofs), v(1 << dof.index()) {} + DOFMask(DOF const &dof) : dofs(dof.dofs), v(1ULL << dof.index()) {} /// combine masks & other dofs DOFMask operator|(DOFMask const &obj) const { diff --git a/cxxfem/src/femPost.cpp b/cxxfem/src/femPost.cpp index a421fb3..2c84481 100644 --- a/cxxfem/src/femPost.cpp +++ b/cxxfem/src/femPost.cpp @@ -5,6 +5,7 @@ #include "femGroup.h" #include "femEntity.h" #include <numeric> +#include <fstream> namespace fem { @@ -226,6 +227,7 @@ int Post::add_view(std::string const &name) // sview = 1 for the first view although it is named Views[0] in the GUI and the options!! views[name] = sview; configure(sview); + //set_viridis(sview); // <= already present in gmsh with 'F4' key (View.ColormapNumber=23) return sview; } @@ -269,6 +271,9 @@ void Post::configure(int sview) gmsh::option::setNumber("View[" + std::to_string(sview - 1) + "].GlyphLocation", 2); // at the node (default=barycenter) gmsh::option::setNumber("View[" + std::to_string(sview - 1) + "].VectorType", 2); // simple Arrow (default=3D arrow) + gmsh::option::setNumber("View[" + std::to_string(sview - 1) + "].ColormapNumber", 23); // Viridis colormap + gmsh::option::setNumber("View[" + std::to_string(sview - 1) + "].LightLines", 0); // disable lighting for lines + gmsh::option::setNumber("View[" + std::to_string(sview - 1) + "].LightTwoSide", 0); // disable 2-sided lighting gmsh::option::setNumber("View[" + std::to_string(sview - 1) + "].ShowElement", 1); // view black mesh outline gmsh::option::setNumber("View[" + std::to_string(sview - 1) + "].DrawSkinOnly", 1); // display skin only (should be faster) gmsh::option::setNumber("View[" + std::to_string(sview - 1) + "].Visible", 0); // hide all views @@ -302,6 +307,11 @@ void Post::write() gmsh::write("mesh.opt"); // save the options gmsh::write("mesh.msh"); // only save the mesh + + // save the views (without the mesh) + gmsh::option::setNumber("PostProcessing.SaveMesh", 0); + gmsh::option::setNumber("PostProcessing.SaveInterpolationMatrices", 0); + for (auto const &[name, sview] : views) { // gmsh::view::write(sview, name+".pos"); // pos format: list-based data (indep. of any model) @@ -406,4 +416,5 @@ operator<<(std::ostream &out, Post const &obj) return out; } + } // namespace fem diff --git a/cxxfem/src/femProblem.cpp b/cxxfem/src/femProblem.cpp index 124f4cd..5c0c5b7 100644 --- a/cxxfem/src/femProblem.cpp +++ b/cxxfem/src/femProblem.cpp @@ -13,7 +13,8 @@ namespace fem Problem::Problem() : quadrature("Gauss2") { - gmsh::initialize(); + if(!gmsh::isInitialized()) + gmsh::initialize(); // General.Verbosity // (0: silent except for fatal errors, 1: +errors, 2: +warnings, 3: +direct, 4: +information, 5: +status (default), 99: +debug) gmsh::option::setNumber("General.Verbosity", 2); diff --git a/fossils.py b/fossils.py index 9b7de33..dce01c1 100644 --- a/fossils.py +++ b/fossils.py @@ -150,11 +150,12 @@ if __name__ == "__main__": 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') + if not gmsh.isInitialized(): + gmsh.initialize() + # load empty mesh + gmsh.merge('mesh.msh') gmsh.option.setNumber("General.Verbosity", 3) + # load views from the option file views = [] with open('mesh.opt') as f: import re @@ -167,14 +168,7 @@ if __name__ == "__main__": 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) + print('starting Gmsh GUI, please wait...') gmsh.fltk.run() diff --git a/models/bonemodel2.py b/models/bonemodel2.py index 9cf1d86..187fb64 100644 --- a/models/bonemodel2.py +++ b/models/bonemodel2.py @@ -85,8 +85,6 @@ def solve(p={}): pbl = fem.Problem() - gmsh.initialize() - gmsh.option.setNumber("General.Terminal", 1) # load main mandible mesh (volume or surface - it will be meshed in 3D) import_mesh(p['bone']) -- GitLab