2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
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. +
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. +
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/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26 // This file is part of enGrid.
28 // enGrid is free software: you can redistribute it and/or modify
29 // it under the terms of the GNU General Public License as published by
30 // the Free Software Foundation, either version 3 of the License, or
31 // (at your option) any later version.
33 // enGrid is distributed in the hope that it will be useful,
34 // but WITHOUT ANY WARRANTY; without even the implied warranty of
35 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 // GNU General Public License for more details.
38 // You should have received a copy of the GNU General Public License
39 // along with Foobar. If not, see <http://www.gnu.org/licenses/>.
41 #ifndef gridsmoother_H
42 #define gridsmoother_H
46 #include "operation.h"
47 #include "optimisation.h"
49 #include <vtkCellLocator.h>
51 class GridSmoother
: public Operation
, public Optimisation
54 private: // attributes
57 QVector
<bool> node_marked
;
61 protected: // attributes
65 int N_boundary_corrections
;
87 struct stencil_node_t
{
95 QList
<stencil_node_t
> stencil
;
99 virtual void operate();
100 virtual double func(vec3_t x
);
102 double errThickness(double x
);
104 bool setNewPosition(vtkIdType id_node
, vec3_t x_new
);
106 void addToStencil(double C
, vec3_t x
);
107 void correctDx(int i_nodes
, vec3_t
&Dx
);
108 bool moveNode(int i_nodes
, vec3_t
&Dx
);
110 void setPrismWeighting() { w_tet_save
= w_tet
; w_tet
= 0; };
111 void setAllWeighting() { w_tet
= w_tet_save
; };
116 void setNumIterations (int N
) { N_iterations
= N
; };
117 void setNumRelaxations (int N
) { N_relaxations
= N
; };
118 void setNumBoundaryCorrections(int N
) { N_boundary_corrections
= N
; };
119 void setNumSmoothLayers (int N
) { N_smooth_layers
= N
; };
121 void setRelaxationFactor(double v
) { relax
= v
; };
123 void prismsOn() { smooth_prisms
= true; };
124 void prismsOff() { smooth_prisms
= false; };
126 double funcOld() { return F_old
; };
127 double funcNew() { return F_new
; };
128 double improvement();
130 void setWSharp1(double w
) { w_sharp1
= w
; };
131 void setWSharp2(double w
) { w_sharp2
= w
; };
136 typedef GridSmoother SmoothVolumeGrid
;