moved gridsmoother.* from master branch
[engrid.git] / src / gridsmoother.h
blobc7e80a313d32af504387242967057d5bd8a7c557
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 #ifndef gridsmoother_H
25 #define gridsmoother_H
27 class GridSmoother;
29 #include "operation.h"
30 #include "optimisation.h"
32 #include <vtkCellLocator.h>
33 #include <QSettings>
35 class GridSmoother : public Operation, public Optimisation
38 private: // attributes
40 bool m_SmoothPrisms;
41 QVector<bool> m_NodeMarked;
42 QVector<bool> m_CriticalTetra;
43 int m_NumMarkedNodes;
45 protected: // attributes
47 int m_NumIterations;
48 int m_NumRelaxations;
49 int m_NumBoundaryCorrections;
50 int m_NumSearch;
52 double m_LSearch;
53 double m_FOld;
54 double m_FNew;
55 double m_FMaxOld;
56 double m_FMaxNew;
57 double m_ReductionFactor;
58 double m_PostSmoothingStrength;
60 double m_WTet;
61 double m_ETet;
62 double m_WTetSave;
63 double m_WH;
64 double m_WPar;
65 double m_WN;
66 double m_WA;
67 double m_WSkew;
68 double m_WOrth;
69 double m_WSharp1;
70 double m_ESharp1;
71 double m_WSharp2;
72 double m_ESharp2;
73 double m_H;
75 bool m_StrictPrismChecking;
77 QVector<vtkIdType> m_FootToField;
78 QVector<bool> m_IsSharpNode;
79 QVector<bool> m_IsTripleNode;
80 MeshPartition m_BPart;
82 double m_RelativeHeight;
83 double m_CritAngle;
85 bool m_SimpleOperation;
86 bool m_PostOperation;
88 struct stencil_node_t {
89 vec3_t x;
90 double C;
92 double m_V0;
93 double m_L0;
94 double m_SumC;
95 int m_INodesOpt;
97 QList<stencil_node_t> m_Stencil;
98 QVector<vtkIdType> m_IdFoot;
99 QVector<double> m_L;
100 QVector<vec3_t> m_NodeNormal;
102 protected: // methods
104 virtual void operate();
105 virtual double func(vec3_t x);
107 double errThickness(double x);
109 bool setNewPosition(vtkIdType id_node, vec3_t x_new);
110 void resetStencil();
111 void addToStencil(double C, vec3_t x);
112 void correctDx(int i_nodes, vec3_t &Dx);
113 bool moveNode(int i_nodes, vec3_t &Dx);
114 void markNodes();
115 void findCriticalTetras();
116 void setPrismWeighting() { m_WTetSave = m_WTet; m_WTet = 0; };
117 void setAllWeighting() { m_WTet = m_WTetSave; };
118 void computeNormals();
119 void computeFeet();
120 void simpleNodeMovement(int i_nodes);
122 void operateOptimisation();
123 void operateSimple();
124 void operatePostSmoothing();
126 public: // methods
128 GridSmoother();
129 void setNumIterations (int N) { m_NumIterations = N; };
130 void setNumRelaxations (int N) { m_NumRelaxations = N; };
131 void setNumBoundaryCorrections(int N) { m_NumBoundaryCorrections = N; };
132 void setRelativeHeight (double h) { m_RelativeHeight = h; }
134 void prismsOn() { m_SmoothPrisms = true; };
135 void prismsOff() { m_SmoothPrisms = false; };
136 void simpleOn() { m_SimpleOperation = true; }
137 void simpleOff() { m_SimpleOperation = false; }
138 void postOn() { simpleOff(); m_PostOperation = true; }
139 void postOff() { m_PostOperation = false; }
141 double improvement();
146 typedef GridSmoother SmoothVolumeGrid;
148 #endif