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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef SURFACEOPERATION_H
24 #define SURFACEOPERATION_H
26 #include <operation.h>
28 //==============================================
29 /// Special structure for working on two linked cells
34 bool sameBC
;//do both cells have the same BCs?
35 bool twocells
;//Do we have 2 cells?
36 char neighbour_type
;//What's the type of the neighbour cell?
38 /// Prints out stencil information
39 ostream
& operator<<( ostream
&out
, stencil_t S
);
40 //==============================================
42 class SurfaceOperation
: public Operation
46 ///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
47 QVector
< QVector
<vtkIdType
> > m_PotentialSnapPoints
;
51 ///@@@ TODO: Remove useless attributes
52 //attributes for determining node types and for smoothing operations
54 int NumberOfIterations
;
55 double RelaxationFactor
;
56 int m_AllowFeatureEdgeVertices
; ///< if set to 0, feature edge vertices will be deactivated. Use setm_AllowFeatureEdgeVertices(int) to set it.
59 int BoundarySmoothing
;
63 virtual void operate();
65 QVector
<vtkIdType
> getPotentialSnapPoints( vtkIdType id_node
); ///< Returns a QVector containing neighbour points to which the point id_node can snap.
67 int UpdateCurrentMeshDensity();
69 /// Updates the m_PotentialSnapPoints structure + updates node types if desired (faster than loop through nodes with getNodeType)
70 int UpdatePotentialSnapPoints( bool update_node_types
, bool allow_feature_edge_vertices
= false );
72 /// deletes node DeadNode
73 // bool DeletePoint( vtkIdType DeadNode, int& N_newpoints, int& N_newcells );
75 //--------------------------------------
76 //Special for UpdatePotentialSnapPoints
77 void setConvergence( double C
) { Convergence
= C
; }
78 void setNumberOfIterations( int N
) { NumberOfIterations
= N
; }
79 void setRelaxationFactor( double RF
) { RelaxationFactor
= RF
; }
80 void setAllowFeatureEdgeVertices( int x
) { m_AllowFeatureEdgeVertices
= x
; } ///< If x = 0, feature edge vertices will be deactivated.
81 int getAllowFeatureEdgeVertices() { return( m_AllowFeatureEdgeVertices
); }
82 void setFeatureAngle( double FA
) { FeatureAngle
= FA
; }
83 void setEdgeAngle( double EA
) { EdgeAngle
= EA
; }
84 void setBoundarySmoothing( int BS
) { BoundarySmoothing
= BS
; }
85 //--------------------------------------
87 /// Returns the average distance of id_node to its neighbours
88 double CurrentVertexAvgDist( vtkIdType id_node
);
90 /// Returns 1/CurrentVertexAvgDist(id_node)
91 double CurrentMeshDensity( vtkIdType id_node
);
93 /// Returns the average of 1./node_meshdensity_desired of the neighbours of id_node
94 double DesiredVertexAvgDist( vtkIdType id_node
);
96 /// Returns the average of node_meshdensity_desired of the neighbours of id_node
97 double DesiredMeshDensity( vtkIdType id_node
);
99 /// Returns the set of boundary codes next to this node
100 QSet
<int> getBCset( vtkIdType a_node
);
102 /// Returns the node type
103 char getNodeType( vtkIdType a_node
, bool allow_feature_edge_vertices
= false );
105 /// Returns the type of the edge [a_node1,a_node2] based on the topology
106 char getEdgeType( vtkIdType a_node1
, vtkIdType a_node2
, bool allow_feature_edge_vertices
);
108 /// Returns the type of the edge [a_node1,a_node2] based on the the type of the two nodes
109 char getEdgeType_from_nodes( vtkIdType a_node1
, vtkIdType a_node2
);
111 /// passes a vector containing the cells surrounding edge [id_node1,id_node2] by reference and returns its size
112 int getEdgeCells( vtkIdType id_node1
, vtkIdType id_node2
, QVector
<vtkIdType
> &EdgeCells
);
114 /// passes a set containing the cells surrounding edge [id_node1,id_node2] by reference and returns its size
115 int getEdgeCells( vtkIdType id_node1
, vtkIdType id_node2
, QSet
<vtkIdType
> &EdgeCells
);
117 /// Get VertexMeshDensity object
118 VertexMeshDensity
getVMD( vtkIdType node
);
120 /// returns the stencil containing id_cell1 and the neighbour cell on side j1 of id_cell1
121 stencil_t
getStencil( vtkIdType id_cell1
, int j1
);
123 /// returns the closest neighbour node of id_node
124 vtkIdType
getClosestNode( vtkIdType id_node
);
126 /// returns the farthest neighbour node of id_node
127 vtkIdType
getFarthestNode( vtkIdType id_node
);
129 //---------------------------------------------------
130 //Utility functions used in Roland's formulas
133 double perimeter( vtkIdType id_cell
);
135 /// desired edge length for id_node
136 double desiredEdgeLength( vtkIdType id_node
);
138 /// mean desired edge length for id_cell
139 double meanDesiredEdgeLength( vtkIdType id_cell
);
141 /// perimeter / sum of the desired edge lengths
142 double Q_L( vtkIdType id_cell
);
144 /// sum(2*edgelength,edges(id_node))/sum(desired edgelengths of each edgepoint,edges(id_node))
145 double Q_L1( vtkIdType id_node
);
147 /// minimum of sum(2*edgelength)/sum(desired edgelengths of each edgepoint) for each edge of id_node
148 double Q_L2( vtkIdType id_node
);
150 /// Value to minimize for mesh smoothing. w allows putting more weight on the form or the area of triangles.
151 double T_min( int w
);
153 //---------------------------------------------------