moved manual to OpenOffice
[engrid.git] / src / surfaceoperation.h
blobcad0400d59e6a7b1d1d65c41ec4de257a3472a5a
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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef SURFACEOPERATION_H
24 #define SURFACEOPERATION_H
26 #include <operation.h>
28 //==============================================
30 /// Special structure for working on two (or more) linked cells
31 struct stencil_t
33 QVector<vtkIdType> id_cell;
34 QVector<vtkIdType> id_node;
35 QVector<vtkIdType> type_cell;
36 vtkIdType p1, p2;
37 bool sameBC; ///< do all cells have the same BCs?
40 /// Prints out stencil information
41 ostream& operator<<( ostream &out, stencil_t S );
43 //==============================================
45 class SurfaceOperation : public Operation
48 private:
50 ///Vector used to store the "Potential Snap Points" of each point, i.e. the neighbour points belonging to the same edge (boundary or feature) in case of edge points, all neighbour points in case of simple points and the points belonging to edges in case of fixed points
51 QVector < QVector <vtkIdType> > m_PotentialSnapPoints;
54 protected:
56 ///\todo Remove useless attributes
57 //attributes for determining node types and for smoothing operations
58 double m_Convergence;
59 int m_NumberOfIterations;
60 double m_RelaxationFactor;
61 // int m_AllowFeatureEdgeVertices; ///< if set to 0, feature edge vertices will be deactivated. Use setm_AllowFeatureEdgeVertices(int) to set it.
62 double m_FeatureAngle;
63 double m_EdgeAngle;
64 int m_BoundarySmoothing;
67 public:
69 SurfaceOperation();
70 virtual void operate();
72 QVector <vtkIdType> getPotentialSnapPoints( vtkIdType id_node ); ///< Returns a QVector containing neighbour points to which the point id_node can snap.
74 int UpdateCurrentMeshDensity();
76 /// Updates the m_PotentialSnapPoints structure + updates node types if desired (faster than loop through nodes with getNodeType)
77 int UpdatePotentialSnapPoints(bool update_node_types, bool fix_unselected = true);
79 //--------------------------------------
80 //Special for UpdatePotentialSnapPoints
81 void setConvergence( double C ) { m_Convergence = C; }
82 void setNumberOfIterations( int N ) { m_NumberOfIterations = N; }
83 void setRelaxationFactor( double RF ) { m_RelaxationFactor = RF; }
84 //void setAllowFeatureEdgeVertices( int x ) { = x; } ///< If x = 0, feature edge vertices will be deactivated.
85 //int getAllowFeatureEdgeVertices() { return( m_AllowFeatureEdgeVertices ); }
86 void setFeatureAngle(double FA) { m_FeatureAngle = FA; }
87 void setEdgeAngle(double EA) { m_EdgeAngle = EA; }
88 void setBoundarySmoothing(int BS) { m_BoundarySmoothing = BS; }
89 //--------------------------------------
91 /// Returns the average distance of id_node to its neighbours
92 double CurrentVertexAvgDist( vtkIdType id_node );
94 /// Returns 1/CurrentVertexAvgDist(id_node)
95 double CurrentMeshDensity( vtkIdType id_node );
97 /// Returns the average of 1./node_meshdensity_desired of the neighbours of id_node
98 double DesiredVertexAvgDist( vtkIdType id_node );
100 /// Returns the average of node_meshdensity_desired of the neighbours of id_node
101 double DesiredMeshDensity( vtkIdType id_node );
103 /// Returns the set of boundary codes next to this node
104 QSet <int> getBCset( vtkIdType a_node );
106 /// Returns the node type
107 char getNodeType(vtkIdType a_node, bool fix_unselected = true);
109 /// Returns the type of the edge [a_node1,a_node2] based on the topology
110 char getEdgeType(vtkIdType a_node1, vtkIdType a_node2, bool fix_unselected);
112 // Returns the type of the edge [a_node1,a_node2] based on the the type of the two nodes
113 // deprecated?
114 // char getEdgeType_from_nodes( vtkIdType a_node1, vtkIdType a_node2 );
116 /// passes a vector containing the cells surrounding edge [id_node1,id_node2] by reference and returns its size
117 int getEdgeCells( vtkIdType id_node1, vtkIdType id_node2, QVector <vtkIdType> &EdgeCells );
119 /// passes a set containing the cells surrounding edge [id_node1,id_node2] by reference and returns its size
120 int getEdgeCells( vtkIdType id_node1, vtkIdType id_node2, QSet <vtkIdType> &EdgeCells );
122 /// Get VertexMeshDensity object
123 VertexMeshDensity getVMD( vtkIdType node );
125 /// returns the stencil containing id_cell1 and the neighbour cell on side j1 of id_cell1
126 stencil_t getStencil( vtkIdType id_cell1, int j1 );
128 /// returns the closest neighbour node of id_node
129 vtkIdType getClosestNode( vtkIdType id_node );
131 /// returns the farthest neighbour node of id_node
132 vtkIdType getFarthestNode( vtkIdType id_node );
134 //---------------------------------------------------
135 //Utility functions used in Roland's formulas
137 /// perimeter
138 double perimeter( vtkIdType id_cell );
140 /// desired edge length for id_node
141 double desiredEdgeLength( vtkIdType id_node );
143 /// mean desired edge length for id_cell
144 double meanDesiredEdgeLength( vtkIdType id_cell );
146 /// perimeter / sum of the desired edge lengths
147 double Q_L( vtkIdType id_cell );
149 /// sum(2*edgelength,edges(id_node))/sum(desired edgelengths of each edgepoint,edges(id_node))
150 double Q_L1( vtkIdType id_node );
152 /// minimum of sum(2*edgelength)/sum(desired edgelengths of each edgepoint) for each edge of id_node
153 double Q_L2( vtkIdType id_node );
155 /// Value to minimize for mesh smoothing. w allows putting more weight on the form or the area of triangles.
156 double T_min( int w );
158 //---------------------------------------------------
161 #endif