Added getNeighbours functions to class Operation + moved UpdateMeshDensity to class...
[engrid.git] / gridsmoother.h
blob7e2f866caffb575440007c0c53409f1f28d5ac49
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 smooth_prisms;
41 QVector<bool> node_marked;
42 int N_marked_nodes;
43 bool dbg;
45 protected: // attributes
47 int N_iterations;
48 int N_relaxations;
49 int N_boundary_corrections;
50 int N_search;
52 double L_search;
53 double F_old;
54 double F_new;
55 double F_max_old;
56 double F_max_new;
58 double w_tet;
59 double w_tet_save;
60 double w_h;
61 double w_par;
62 double w_n;
63 double w_A;
64 double w_skew;
65 double w_orth;
66 double w_sharp1;
67 double e_sharp1;
68 double w_sharp2;
69 double e_sharp2;
70 double H;
72 struct stencil_node_t {
73 vec3_t x;
74 double C;
76 double V0;
77 double L0;
78 double sum_C;
79 int i_nodes_opt;
80 QList<stencil_node_t> stencil;
82 protected: // methods
84 virtual void operate();
85 virtual double func(vec3_t x);
87 double errThickness(double x);
89 bool setNewPosition(vtkIdType id_node, vec3_t x_new);
90 void resetStencil();
91 void addToStencil(double C, vec3_t x);
92 void correctDx(int i_nodes, vec3_t &Dx);
93 bool moveNode(int i_nodes, vec3_t &Dx);
94 void markNodes();
95 void setPrismWeighting() { w_tet_save = w_tet; w_tet = 0; };
96 void setAllWeighting() { w_tet = w_tet_save; };
98 public: // methods
100 GridSmoother();
101 void setNumIterations (int N) { N_iterations = N; };
102 void setNumRelaxations (int N) { N_relaxations = N; };
103 void setNumBoundaryCorrections(int N) { N_boundary_corrections = N; };
105 void prismsOn() { smooth_prisms = true; };
106 void prismsOff() { smooth_prisms = false; };
108 double improvement();
113 typedef GridSmoother SmoothVolumeGrid;
115 #endif