File: vssolution3d.hpp

package info (click to toggle)
glvis 4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,780 kB
  • sloc: cpp: 35,217; ansic: 5,695; sh: 340; makefile: 301; python: 193
file content (206 lines) | stat: -rw-r--r-- 8,198 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// Copyright (c) 2010-2026, Lawrence Livermore National Security, LLC. Produced
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
// LICENSE and NOTICE for details. LLNL-CODE-443271.
//
// This file is part of the GLVis visualization tool and library. For more
// information and source code availability see https://glvis.org.
//
// GLVis is free software; you can redistribute it and/or modify it under the
// terms of the BSD-3 license. We welcome feedback and contributions, see file
// CONTRIBUTING.md for details.

#ifndef GLVIS_VSSOLUTION_3D_HPP
#define GLVIS_VSSOLUTION_3D_HPP

#include <mfem.hpp>
#include "gl/types.hpp"
#include "vsdata.hpp"

class VisualizationSceneSolution3d : public VisualizationSceneScalarData
{
protected:

   int drawmesh, drawelems, draworder;
   int cplane;
   int cp_drawmesh, cp_drawelems, drawlsurf;
   // Algorithm used to draw the cutting plane when shading is 2 and cplane is 1
   // 0 - slower, more accurate algorithm for curved meshes (default)
   // 1 - faster algorithm suitable for meshes with planar faces
   int cp_algo;

   gl3::GlDrawable disp_buf;
   gl3::GlDrawable line_buf;
   gl3::GlDrawable cplane_buf;
   gl3::GlDrawable cplines_buf;
   gl3::GlDrawable lsurf_buf;
   gl3::GlDrawable other_buf;
   gl3::GlDrawable order_buf, order_noarrow_buf;

   double *node_pos;

   int nlevels;
   mfem::Array<double> levels;

   mfem::GridFunction *GridF{};

   void Init();

   void NewMeshAndSolution(mfem::Mesh *new_m, mfem::Mesh *new_mc,
                           mfem::Vector *new_sol,
                           mfem::GridFunction *new_u = nullptr);

   void GetFaceNormals(const int FaceNo, const int side,
                       const mfem::IntegrationRule &ir, mfem::DenseMatrix &normals);

   void DrawRefinedSurf (int n, double *points, int elem, int func,
                         int part = -1);
   void DrawRefinedSurf (int n, mfem::DenseMatrix &pointmat,
                         mfem::Vector &values, mfem::Array<int> &RefGeoms);
   void DrawRefinedSurfLevelLines (int n, mfem::DenseMatrix &pointmat,
                                   mfem::Vector &values, mfem::Array<int> &RefGeoms);
   void DrawRefinedSurfEdges (int n, mfem::DenseMatrix &pointmat,
                              mfem::Vector &values, mfem::Array<int> &RefEdges,
                              int part = -1);
   void DrawBdrElCoarseSurfEdges(gl3::GlBuilder &line, int be,
                                 mfem::DenseMatrix &pointmat, const mfem::IntegrationRule *ir = NULL,
                                 mfem::Array<int> *idxs = NULL);
   void DrawFaceCoarseSurfEdges(gl3::GlBuilder &line, int f,
                                mfem::DenseMatrix &pointmat,
                                const mfem::IntegrationRule *ir = NULL, mfem::Array<int> *idxs = NULL);
   void DrawCoarseSurfEdges(gl3::GlBuilder &line, int f, int e1, int e2,
                            mfem::DenseMatrix &pointmat, const mfem::IntegrationRule *ir = NULL,
                            mfem::Array<int> *idxs = NULL);
   void LiftRefinedSurf (int n, mfem::DenseMatrix &pointmat,
                         mfem::Vector &values, int *RG);
   void DrawTetLevelSurf(gl3::GlDrawable& target, const mfem::DenseMatrix &verts,
                         const mfem::Vector &vals,
                         const int *ind, const mfem::Array<double> &levels,
                         const mfem::DenseMatrix *grad = NULL);

   static int GetPyramidFaceSplits(const mfem::Array<bool> &quad_diag,
                                   const mfem::Array<int> &faces,
                                   const mfem::Array<int> &ofaces);
   void DrawRefinedPyramidLevelSurf(gl3::GlDrawable& target,
                                    const mfem::DenseMatrix &verts,
                                    const mfem::Vector &vals, const int *RG,
                                    const int np, const int face_splits,
                                    const mfem::DenseMatrix *grad = NULL);

   static int GetWedgeFaceSplits(const mfem::Array<bool> &quad_diag,
                                 const mfem::Array<int> &faces,
                                 const mfem::Array<int> &ofaces);
   void DrawRefinedWedgeLevelSurf(gl3::GlDrawable& target,
                                  const mfem::DenseMatrix &verts,
                                  const mfem::Vector &vals, const int *RG,
                                  const int np, const int face_splits,
                                  const mfem::DenseMatrix *grad = NULL);

   static int GetHexFaceSplits(const mfem::Array<bool> &quad_diag,
                               const mfem::Array<int> &faces,
                               const mfem::Array<int> &ofaces);
   void DrawRefinedHexLevelSurf(gl3::GlDrawable& target,
                                const mfem::DenseMatrix &verts,
                                const mfem::Vector &vals, const int *RG,
                                const int nh, const int face_splits,
                                const mfem::DenseMatrix *grad = NULL);

   int GetFunctionAutoRefineFactor() override;

   bool CheckPositions(mfem::Array<int> &vertices) const
   {
      int n = 0;
      for (int j = 0; j < vertices.Size(); j++)
      {
         if (node_pos[vertices[j]] >= 0.0) { n++; }
      }
      return (n < vertices.Size());
   }

public:
   int TimesToRefine;
   double FaceShiftScale;

   mfem::Array<int> bdr_attr_to_show;

   VisualizationSceneSolution3d(Window &win, bool init = true);

   void NewMeshAndSolution(const DataState &s) override;

   virtual ~VisualizationSceneSolution3d();

   std::string GetHelpString() const override;

   void FindNewBox(bool prepare) override;
   void FindNewValueRange(bool prepare) override;

   void PrepareRuler() override
   { VisualizationSceneScalarData::PrepareRuler(false); }
   virtual void PrepareFlat();
   void PrepareLines() override;
   void Prepare() override;
   virtual void PrepareOrderingCurve();
   virtual void PrepareOrderingCurve1(gl3::GlDrawable& buf, bool arrows,
                                      bool color);
   gl3::SceneInfo GetSceneObjs() override;

   void glTF_Export() override;

   void ToggleDrawElems()
   { drawelems = !drawelems; Prepare(); }

   void ToggleDrawMesh();

   // 0 - none, 1 - no arrows (color), 2 - with arrows (color),
   //           3 - no arrows (black), 4 - with arrows (black)
   void ToggleDrawOrdering() { draworder = (draworder+1)%5; }

   void SetShading(Shading, bool) override;
   void ToggleShading() override;
   void SetRefineFactors(int, int) override;
   void AutoRefine() override;
   void ToggleAttributes(mfem::Array<int> &attr_list) override;

   void FindNodePos();

   void CuttingPlaneFunc (int type);
   // func: 0 - draw surface, 1 - draw level lines
   void CutRefinedElement(gl3::GlDrawable& target,
                          const mfem::DenseMatrix &verts, const mfem::Vector &vert_dist,
                          const mfem::Vector &vals, const mfem::Geometry::Type geom,
                          const int *elems, int num_elems, int func);
   void CutRefinedFace(gl3::GlDrawable& target,
                       const mfem::DenseMatrix &verts, const mfem::Vector &vert_dist,
                       const mfem::Vector &vals, const mfem::Geometry::Type geom,
                       const int *faces, int num_faces);
   void CPPrepare();
   void CPMoved();
   void PrepareFlat2();
   void PrepareLines2();
   virtual void PrepareCuttingPlane();
   void PrepareCuttingPlane2();
   void PrepareCuttingPlaneLines();
   void PrepareCuttingPlaneLines2();
   void PrepareLevelSurf();
   void ToggleCuttingPlane();
   void ToggleCPDrawElems();
   void ToggleCPDrawMesh();
   void ToggleCPAlgorithm();
   void MoveLevelSurf(int);
   void NumberOfLevelSurf(int);
   void EventUpdateColors() override;
   void UpdateLevelLines() override
   { PrepareLines(); PrepareCuttingPlaneLines(); }
   void UpdateValueRange(bool prepare) override;

   virtual void SetDrawMesh(int i)
   {
      if (drawmesh != i % 3)
      {
         drawmesh = i % 3;
         PrepareLines();
      }
   }
   virtual int GetDrawMesh() { return drawmesh; }
};

#endif