diff --git a/cxxfem/src/femDOF.h b/cxxfem/src/femDOF.h index 2e2ad4fadbfc8b129bb4b3a49ff32688868c74eb..874e9a3329a25f28cea30a3b7c22d1801f5f60f8 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 a421fb3997faf9f372db711111767a7718179e48..2c8448161e3ad71ab34372ce2292bff086df27bc 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 124f4cd9fde71d5caf16908c7348c7b51dad4c18..5c0c5b720661733f37d95bc2cd5f59d25db9975a 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 9b7de33124e3e80bf389564480935b336488b025..dce01c1a56e5f84f5bb530360369840173b2b073 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 9cf1d86f6215bb3c69a2ea2cd802faba165cb8f8..187fb64ee6adb3e3e6ca18a0d315a144a36c99c3 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'])