Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
quadrialteral_util_impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016: G-CSC, Goethe University Frankfurt
3 * Author: Sebastian Reiter
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __H__UG_quadrialteral_util_impl
34#define __H__UG_quadrialteral_util_impl
35
36#include <set>
37#include "boost/iterator/transform_iterator.hpp"
38#include "quadrilateral_util.h"
40#include "common/util/hash.h"
41
42namespace ug{
43
44template <class face_iter_t, class TAAPos>
46 Grid& g,
47 face_iter_t facesBegin,
48 face_iter_t facesEnd,
49 TAAPos aaPos)
50{
51 std::vector<Edge*> edges;
52 GetInnerEdgesOfFaceSoup(edges, g, facesBegin, facesEnd);
53
54 if(!edges.empty())
55 {
57 g,
58 edges.begin(),
59 edges.end(),
60 aaPos);
61 }
62}
63
64namespace detail{
65 namespace quadUtil{
67 EdgeToQuadInfo () : e(NULL), quality(-1) {};
68 EdgeToQuadInfo (Edge* _e, number _q) : e(_e), quality(_q) {};
69
70 typedef Edge* result_type;
71
74
75 bool operator < (const EdgeToQuadInfo& other) const
76 {return quality > other.quality;}
77
78 inline Edge* operator() (const EdgeToQuadInfo& v) const
79 {return v.e;}
80 };
81 }// end of namespace
82}// end of namespace detail
83
84template <class edge_iter_t, class TAAPos>
86 Grid& g,
87 edge_iter_t edgesBegin,
88 edge_iter_t edgesEnd,
89 TAAPos aaPos)
90{
91 using namespace detail::quadUtil;
92
94 FaceDescriptor fd(4);
95 std::multiset<EdgeToQuadInfo> ms;
96
97 for(edge_iter_t eiter = edgesBegin; eiter != edgesEnd; ++eiter){
98 Edge* e = *eiter;
99 g.associated_elements(faces, e);
100 if( faces.size() == 2
101 && faces[0]->num_vertices() == 3
102 && faces[1]->num_vertices() == 3)
103 {
104 int i0 = GetConnectedVertexIndex(faces[0], e);
105 if(i0 != -1){
106 fd.set_vertex(0, faces[0]->vertex(i0));
107 fd.set_vertex(1, faces[0]->vertex((i0+1)%3));
108 fd.set_vertex(2, GetConnectedVertex(e, faces[1]));
109 fd.set_vertex(3, faces[0]->vertex((i0+2)%3));
110
111 ms.insert(EdgeToQuadInfo(e, FaceQuality(&fd, aaPos)));
112 }
113 }
114 }
115
116 typedef boost::transform_iterator<
117 EdgeToQuadInfo,
118 std::multiset<EdgeToQuadInfo>::iterator>
119 trans_iter_t;
120
122 g,
123 trans_iter_t(ms.begin()),
124 trans_iter_t(ms.end()));
125}
126
127
128template <class face_iter_t>
130 Grid& g,
131 face_iter_t facesBegin,
132 face_iter_t facesEnd)
133{
134 std::vector<Edge*> edges;
135 GetInnerEdgesOfFaceSoup(edges, g, facesBegin, facesEnd);
136
137 if(!edges.empty())
138 {
140 g,
141 edges.begin(),
142 edges.end());
143 }
144}
145
146
147template <class edge_iter_t>
149 Grid& g,
150 edge_iter_t edgesBegin,
151 edge_iter_t edgesEnd)
152{
154 for(edge_iter_t eiter = edgesBegin; eiter != edgesEnd;)
155 {
156 Edge* e = *eiter;
157 ++eiter;
158 g.associated_elements(faces, e);
159 if(faces.size() == 2) {
160 try{
161 //NOTE: This may fail. faces[0] and faces[1] don't have to be
162 // triangles or may be identical etc. This would, however,
163 // raise an UGError.
164 ReplaceByQuadrilateral(g, faces[0], faces[1]);
165 }
166 catch(UGError&) {}
167 }
168 }
169}
170
171}// end of namespace
172
173#endif //__H__UG_quadrialteral_util_impl
Base-class for edges.
Definition grid_base_objects.h:397
Can be queried for the edges and vertices of a face.
Definition grid_base_objects.h:684
void set_vertex(uint index, Vertex *vrt)
Definition grid_base_objects.h:706
Manages the elements of a grid and their interconnection.
Definition grid.h:132
geometry_traits< TGeomObj >::iterator begin()
Definition grid_impl.hpp:164
void associated_elements(traits< Vertex >::secure_container &elemsOut, TElem *e)
Puts all elements of type TAss which are contained in 'e' or which contain 'e' into elemsOut.
Definition grid_impl.hpp:466
Instances of this class or of derived classes are thrown if errors arise.
Definition error.h:104
void GetInnerEdgesOfFaceSoup(std::vector< Edge * > &edgesOut, Grid &g, face_iter_t facesBegin, face_iter_t facesEnd)
Definition edge_util_impl.hpp:47
number FaceQuality(FaceVertices *f, Grid::VertexAttachmentAccessor< APosition > aaPos)
a simple measure for the quality of a face
Definition face_util.cpp:203
int GetConnectedVertexIndex(Face *f, const EdgeDescriptor &ed)
returns the index of the first vertex that is contained in the specified face and is not contained in...
Definition vertex_util.cpp:101
Vertex * GetConnectedVertex(Edge *e, Vertex *v)
returns the vertex that is connected to v via e.
Definition vertex_util.cpp:78
double number
Definition types.h:124
the ug namespace
void ReplaceByQuadrilaterals_EdgeBased(Grid &g, edge_iter_t edgesBegin, edge_iter_t edgesEnd, TAAPos aaPos)
Attempts to replace triangles associated with the given set of edges by a set of quadrilaterals.
Definition quadrialteral_util_impl.h:85
void ReplaceByQuadrilaterals_FaceBasedNoSort(Grid &g, face_iter_t facesBegin, face_iter_t facesEnd)
Attempts to replace the given set of faces by a set of quadrilaterals.
Definition quadrialteral_util_impl.h:129
Quadrilateral * ReplaceByQuadrilateral(Grid &g, Face *tri1, Face *tri2)
Replaces the specified triangles by one quadrilateral.
Definition quadrilateral_util.cpp:69
void ReplaceByQuadrilaterals_EdgeBasedNoSort(Grid &g, edge_iter_t edgesBegin, edge_iter_t edgesEnd)
Attempts to replace triangles associated with the given set of edges by a set of quadrilaterals.
Definition quadrialteral_util_impl.h:148
void ReplaceByQuadrilaterals_FaceBased(Grid &g, face_iter_t facesBegin, face_iter_t facesEnd, TAAPos aaPos)
Attempts to replace the given set of triangles by a set of quadrilaterals.
Definition quadrialteral_util_impl.h:45
PointerConstArray< Face * > secure_container
Definition grid.h:146
Definition quadrialteral_util_impl.h:66
Edge * operator()(const EdgeToQuadInfo &v) const
Definition quadrialteral_util_impl.h:78
Edge * result_type
Definition quadrialteral_util_impl.h:70
Edge * e
Definition quadrialteral_util_impl.h:72
number quality
Definition quadrialteral_util_impl.h:73
bool operator<(const EdgeToQuadInfo &other) const
Definition quadrialteral_util_impl.h:75
EdgeToQuadInfo()
Definition quadrialteral_util_impl.h:67
EdgeToQuadInfo(Edge *_e, number _q)
Definition quadrialteral_util_impl.h:68