GLVis  v4.2
Accurate and flexible finite element visualization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
vssolution.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-443271.
4 //
5 // This file is part of the GLVis visualization tool and library. For more
6 // information and source code availability see https://glvis.org.
7 //
8 // GLVis is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef GLVIS_VSSOLUTION_HPP
13 #define GLVIS_VSSOLUTION_HPP
14 
15 #include "mfem.hpp"
16 using namespace mfem;
17 
18 #include "sdl.hpp"
19 #include "gl/types.hpp"
20 #include "vsdata.hpp"
21 
22 #include <map>
23 
24 // Visualization header file
25 
27 {
28 protected:
29  Vector *v_normals;
30  GridFunction *rsol;
31 
32  int drawmesh, drawelems, drawnums, draworder;
33  int drawbdr, draw_cp;
34 
35  int refine_func = 0;
36 
37  double minv_sol, maxv_sol;
38  bool have_sol_range = false; // true when minv_sol and maxv_sol are set
39 
40  int TimesToRefine, EdgeRefineFactor;
41 
43 
47 
52 
55 
56  void Init();
57 
58  void FindNewBox(double rx[], double ry[], double rval[]);
59 
60  void DrawCPLine(gl3::GlBuilder& bld,
61  DenseMatrix &pointmat, Vector &values, Array<int> &ind);
62 
63  void GetRefinedDetJ(int i, const IntegrationRule &ir,
64  Vector &vals, DenseMatrix &tr);
65 
66  // redefined for vector solution
67  virtual void GetRefinedValues(int i, const IntegrationRule &ir,
68  Vector &vals, DenseMatrix &tr);
69  virtual int GetRefinedValuesAndNormals(int i, const IntegrationRule &ir,
70  Vector &vals, DenseMatrix &tr,
71  DenseMatrix &normals);
72 
73  void DrawLevelCurves(gl3::GlBuilder& buf, Array<int> &RG, DenseMatrix &pointmat,
74  Vector &values, int sides, Array<double> &lvl,
75  int flat = 0);
76 
77  int GetAutoRefineFactor();
78 
79  // Used for drawing markers for element and vertex numbering
80  double GetElementLengthScale(int k);
81 
82 public:
83  int shading;
84 
85  int attr_to_show, bdr_attr_to_show;
86  Array<int> el_attr_to_show, bdr_el_attr_to_show;
87 
89  VisualizationSceneSolution(Mesh &m, Vector &s, Vector *normals = NULL);
90 
91  virtual ~VisualizationSceneSolution();
92 
93  virtual std::string GetHelpString() const;
94 
95  void SetGridFunction(GridFunction & u) { rsol = &u; }
96 
97  void NewMeshAndSolution(Mesh *new_m, Vector *new_sol,
98  GridFunction *new_u = NULL);
99 
100  virtual void SetNewScalingFromBox();
101  virtual void FindNewBox(bool prepare);
102  virtual void FindNewValueRange(bool prepare);
103  virtual void FindNewBoxAndValueRange(bool prepare)
104  { FindNewBox(prepare); }
105  virtual void FindMeshBox(bool prepare);
106 
107  virtual void ToggleLogscale(bool print);
108  virtual void EventUpdateBackground();
109  virtual void EventUpdateColors();
110  virtual void UpdateLevelLines() { PrepareLevelCurves(); }
111  virtual void UpdateValueRange(bool prepare);
112 
113  void PrepareWithNormals();
114  void PrepareFlat();
115  void PrepareFlat2();
116 
117  virtual void PrepareLines();
118  void PrepareLines2();
119  void PrepareLines3();
120 
121  virtual void Prepare();
122  void PrepareLevelCurves();
123  void PrepareLevelCurves2();
124 
125  void PrepareBoundary();
126 
127  void PrepareOrderingCurve();
128  void PrepareOrderingCurve1(gl3::GlDrawable& buf, bool arrows, bool color);
129 
130  void PrepareNumbering();
131  void PrepareElementNumbering();
132  void PrepareElementNumbering1();
133  void PrepareElementNumbering2();
134  void PrepareVertexNumbering();
135  void PrepareVertexNumbering1();
136  void PrepareVertexNumbering2();
137  void PrepareEdgeNumbering();
138 
139  void PrepareCP();
140 
141  virtual gl3::SceneInfo GetSceneObjs();
142 
143  void glTF_ExportBoundary(glTF_Builder &bld,
145  glTF_Builder::material_id black_mat);
146  virtual void glTF_Export();
147 
148  void ToggleDrawBdr();
149 
150  virtual void ToggleDrawElems();
151 
152  void ToggleDrawMesh() { drawmesh = (drawmesh+1)%3; }
153 
154  // 0 - none, 1 - no arrows (color), 2 - with arrows (color),
155  // 3 - no arrows (black), 4 - with arrows (black)
156  void ToggleDrawOrdering() { draworder = (draworder+1)%5; }
157 
158  // 0 - none, 1 - elements, 2 - edges, 3 - vertices
159  void ToggleDrawNumberings() { drawnums = (drawnums+1)%4; }
160 
161  virtual void SetShading(int, bool);
162  void ToggleShading();
163 
164  void ToggleDrawCP() { draw_cp = !draw_cp; PrepareCP(); }
165 
166  void ToggleRefinements();
167  void ToggleRefinementFunction();
168 
169  virtual void SetRefineFactors(int, int);
170  virtual void AutoRefine();
171  virtual void ToggleAttributes(Array<int> &attr_list);
172 
173  virtual void SetDrawMesh(int i) { drawmesh = i % 3; }
174  virtual int GetShading() { return shading; }
175  virtual int GetDrawMesh() { return drawmesh; }
176 };
177 
178 void DrawNumberedMarker(gl3::GlDrawable& buff, const double x[3], double dx,
179  int n);
180 
181 #endif
virtual void FindNewBoxAndValueRange(bool prepare)
Definition: vssolution.hpp:103
Array< int > el_attr_to_show
Definition: vssolution.hpp:86
gl3::GlDrawable e_nums_buf
Definition: vssolution.hpp:44
gl3::GlDrawable f_nums_buf
Definition: vssolution.hpp:46
gl3::GlDrawable lcurve_buf
Definition: vssolution.hpp:48
void DrawNumberedMarker(gl3::GlDrawable &buff, const double x[3], double dx, int n)
gl3::GlDrawable disp_buf
Definition: vssolution.hpp:42
virtual void UpdateLevelLines()
Definition: vssolution.hpp:110
gl3::GlDrawable v_nums_buf
Definition: vssolution.hpp:45
gl3::GlDrawable order_noarrow_buf
Definition: vssolution.hpp:54
gl3::GlDrawable order_buf
Definition: vssolution.hpp:53
Crude fixed-function OpenGL emulation helper.
Definition: types.hpp:261
void SetGridFunction(GridFunction &u)
Definition: vssolution.hpp:95
gl3::GlDrawable line_buf
Definition: vssolution.hpp:49
virtual void SetDrawMesh(int i)
Definition: vssolution.hpp:173
gl3::GlDrawable bdr_buf
Definition: vssolution.hpp:50
gl3::GlDrawable cp_buf
Definition: vssolution.hpp:51