ug4
grid_util.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2015: 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__LIB_GRID__GRID_UTIL__
34 #define __H__LIB_GRID__GRID_UTIL__
35 
36 #include <vector>
37 #include "grid_base_objects.h"
38 
39 namespace ug
40 {
41 
42 class Grid;
43 
44 
46 // CompareVertices
48 
55 UG_API
56 bool CompareVertices(const EdgeVertices* ev1,
57  const EdgeVertices* ev2);
58 
60 
70 UG_API
71 bool CompareVertices(const FaceVertices* fv1,
72  const FaceVertices* fv2);
73 
75 
85 UG_API
86 bool CompareVertices(const VolumeVertices* vv1,
87  const VolumeVertices* vv2);
88 
89 
100 UG_API
101 bool VertexGroupsMatch(const IVertexGroup* elem, const IVertexGroup& desc);
102 
104 UG_API
105 bool VertexGroupsMatch(const Vertex* elem, const IVertexGroup& desc);
106 
107 
109 // CompareVertexContainer
111 
129 template <class TVrtContainer1, class TVrtContainer2>
130 UG_API
131 bool CompareVertexContainer(const TVrtContainer1& con1,
132  const TVrtContainer2& con2);
133 
134 
139 
141 // CollectVertices
143 UG_API
144 inline void CollectAssociated(std::vector<Vertex*>& vVertexOut, Grid& grid,
145  GridObject* obj, bool clearContainer = true);
146 UG_API
147 inline void CollectVertices(std::vector<Vertex*>& vVertexOut, Grid& grid,
148  GridObject* obj, bool clearContainer = true);
149 
151 
155 UG_API
156 void CollectVertices(std::vector<Vertex*>& vVertexOut, Grid& grid,
157  Vertex* v, bool clearContainer = true);
158 
159 UG_API
160 inline void CollectAssociated(std::vector<Vertex*>& vVertexOut,
161  Grid& grid, Vertex* v, bool clearContainer = true);
165 
169 UG_API
170 void CollectVertices(std::vector<Vertex*>& vVertexOut, Grid& grid,
171  Edge* e, bool clearContainer = true);
172 
173 UG_API
174 inline void CollectAssociated(std::vector<Vertex*>& vVertexOut,
175  Grid& grid, Edge* e, bool clearContainer = true);
179 
183 UG_API
184 void CollectVertices(std::vector<Vertex*>& vVertexOut, Grid& grid,
185  Face* f, bool clearContainer = true);
186 
187 UG_API
188 inline void CollectAssociated(std::vector<Vertex*>& vVertexOut,
189  Grid& grid, Face* f, bool clearContainer = true);
193 
197 UG_API
198 void CollectVertices(std::vector<Vertex*>& vVertexOut, Grid& grid,
199  Volume* v, bool clearContainer = true);
200 
201 inline void CollectAssociated(std::vector<Vertex*>& vVertexOut,
202  Grid& grid, Volume* v, bool clearContainer = true);
206 // GetVertex
208 
210 
216 inline Vertex* GetVertex(Vertex* v, size_t i);
217 
219 
224 inline Vertex* GetVertex(Edge* e, size_t i);
225 
227 
232 inline Vertex* GetVertex(Face* f, size_t i);
233 
235 
240 inline Vertex* GetVertex(Volume* v, size_t i);
241 
243 // NumVertices
245 
247 
253 inline size_t NumVertices(Vertex* elem);
254 inline size_t NumVertices(Edge* elem);
255 inline size_t NumVertices(Face* elem);
256 inline size_t NumVertices(Volume* elem);
261 // CollectEdgesSorted
263 
264 inline void CollectEdgesSorted(std::vector<Edge*>& vEdgesOut, Grid& grid,
265  GridObject* obj, bool clearContainer = true);
266 
267 UG_API
268 void CollectEdgesSorted(std::vector<Edge*>& vEdgesOut, Grid& grid,
269  Vertex* v, bool clearContainer = true);
270 
272 
275 UG_API
276 void CollectEdgesSorted(std::vector<Edge*>& vEdgesOut, Grid& grid,
277  Edge* e, bool clearContainer = true);
278 
280 
283 UG_API
284 void CollectEdgesSorted(std::vector<Edge*>& vEdgesOut, Grid& grid,
285  Face* f, bool clearContainer = true);
286 
288 
291 UG_API
292 void CollectEdgesSorted(std::vector<Edge*>& vEdgesOut, Grid& grid,
293  Volume* v, bool clearContainer = true);
294 
296 // CollectEdges
298 
299 inline void CollectAssociated(std::vector<Edge*>& vEdgesOut, Grid& grid,
300  GridObject* obj, bool clearContainer = true);
301 
303 
305 UG_API
306 void CollectEdges(std::vector<Edge*>& vEdgesOut, Grid& grid,
307  Vertex* vrt, bool clearContainer = true);
308 
309 inline void CollectAssociated(std::vector<Edge*>& vEdgesOut,
310  Grid& grid, Vertex* vrt, bool clearContainer = true);
314 
318 UG_API
319 void CollectEdges(std::vector<Edge*>& vEdgesOut, Grid& grid,
320  Edge* e, bool clearContainer = true);
321 
322 inline void CollectAssociated(std::vector<Edge*>& vEdgesOut,
323  Grid& grid, Edge* e, bool clearContainer = true);
327 
335 UG_API
336 void CollectEdges(std::vector<Edge*>& vEdgesOut, Grid& grid,
337  Face* f, bool clearContainer = true);
338 
339 inline void CollectAssociated(std::vector<Edge*>& vEdgesOut,
340  Grid& grid, Face* f, bool clearContainer = true);
344 
352 UG_API
353 void CollectEdges(std::vector<Edge*>& vEdgesOut, Grid& grid,
354  Volume* v, bool clearContainer = true);
355 
356 inline void CollectAssociated(std::vector<Edge*>& vEdgesOut,
357  Grid& grid, Volume* v, bool clearContainer = true);
361 // EdgeContains
363 
366 inline bool EdgeContains(EdgeVertices* e, Vertex* vrt);
367 
370 inline bool EdgeContains(EdgeVertices* e, Vertex* vrt1, Vertex* vrt2);
371 
373 // CollectFacesSorted
375 
376 inline void CollectFacesSorted(std::vector<Face*>& vFacesOut, Grid& grid,
377  GridObject* obj, bool clearContainer = true);
378 
379 
380 UG_API
381 void CollectFacesSorted(std::vector<Face*>& vFacesOut, Grid& grid,
382  Vertex* v, bool clearContainer = true);
383 
385 UG_API
386 void CollectFacesSorted(std::vector<Face*>& vFacesOut, Grid& grid,
387  Edge* e, bool clearContainer = true);
388 
390 UG_API
391 void CollectFacesSorted(std::vector<Face*>& vFacesOut, Grid& grid,
392  Face* f, bool clearContainer = true);
393 
395 
398 UG_API
399 void CollectFacesSorted(std::vector<Face*>& vFacesOut, Grid& grid,
400  Volume* v, bool clearContainer = true);
401 
403 // CollectFaces
405 
406 inline void CollectAssociated(std::vector<Face*>& vFacesOut, Grid& grid,
407  GridObject* obj, bool clearContainer = true);
408 
409 UG_API
410 void CollectFaces(std::vector<Face*>& vFacesOut, Grid& grid,
411  Vertex* vrt, bool clearContainer = true);
412 
413 inline void CollectAssociated(std::vector<Face*>& vFacesOut,
414  Grid& grid, Vertex* vrt, bool clearContainer = true);
415 
417 
424 UG_API
425 void CollectFaces(std::vector<Face*>& vFacesOut, Grid& grid,
426  Edge* e, bool clearContainer = true);
427 
428 inline void CollectAssociated(std::vector<Face*>& vFacesOut,
429  Grid& grid, Edge* e, bool clearContainer = true);
433 UG_API
434 void CollectFaces(std::vector<Face*>& vFacesOut, Grid& grid,
435  Face* v, bool clearContainer = true);
436 
438 inline void CollectAssociated(std::vector<Face*>& vFacesOut,
439  Grid& grid, Face* vol, bool clearContainer = true);
440 
442 
450 UG_API
451 void CollectFaces(std::vector<Face*>& vFacesOut, Grid& grid,
452  Volume* v, bool clearContainer = true);
453 
454 inline void CollectAssociated(std::vector<Face*>& vFacesOut,
455  Grid& grid, Volume* v, bool clearContainer = true);
456 
460 // FaceMatches
462 //bool FaceMatches(Face* f, FaceDescriptor& fd);
463 
465 // FaceContains
468 bool FaceContains(FaceVertices* f, Vertex* v);
469 
471 // FaceContains
474 UG_API
475 bool FaceContains(Face* f, EdgeVertices* ev);
476 
478 // CollectVolumes
480 
481 // CollectVolumes
482 inline void CollectAssociated(std::vector<Volume*>& vVolumesOut, Grid& grid,
483  GridObject* obj, bool clearContainer = true);
484 
486 UG_API
487 void CollectVolumes(std::vector<Volume*>& vVolumesOut, Grid& grid, Vertex* vrt, bool clearContainer = true);
488 
489 inline void CollectAssociated(std::vector<Volume*>& vVolumesOut,
490  Grid& grid, Vertex* vrt, bool clearContainer = true);
491 
493 
500 UG_API
501 void CollectVolumes(std::vector<Volume*>& vVolumesOut, Grid& grid, Edge* e, bool clearContainer = true);
502 
503 inline void CollectAssociated(std::vector<Volume*>& vVolumesOut,
504  Grid& grid, Edge* e, bool clearContainer = true);
508 
515 void CollectVolumes(std::vector<Volume*>& vVolumesOut, Grid& grid, Face* f, bool clearContainer = true, bool ignoreAssociatedVolumes = false);
516 inline void CollectAssociated(std::vector<Volume*>& vVolumesOut,
517  Grid& grid, Face* f, bool clearContainer = true,
518  bool ignoreAssociatedVolumes = false);
519 
520 UG_API
521 void CollectVolumes(std::vector<Volume*>& vVolumesOut, Grid& grid, FaceDescriptor& fd, bool clearContainer = true);
522 inline void CollectAssociated(std::vector<Volume*>& vVolumesOut,
523  Grid& grid, FaceDescriptor& fd, bool clearContainer = true);
525 
527 UG_API
528 void CollectVolumes(std::vector<Volume*>& vVolumesOut, Grid& grid, Volume* v, bool clearContainer = true);
529 
531 inline void CollectAssociated(std::vector<Volume*>& vVolumesOut,
532  Grid& grid, Volume* vol, bool clearContainer = true);
533 
534 
536 // VolumeContains
539 bool VolumeContains(VolumeVertices* v, Vertex* vrt);
540 
543 UG_API
544 bool VolumeContains(Volume* v, EdgeVertices* ev);
545 
548 UG_API
549 bool VolumeContains(Volume* v, FaceVertices* f);
550 
551 // end of group lib_grid_algorithms_neighborhood_util
553 }// end of namespace libGrid
554 
555 // include template implementation
556 #include "grid_util_impl.hpp"
557 
558 #endif
bool EdgeContains(EdgeVertices *e, Vertex *vrt)
Definition: grid_util_impl.hpp:45
bool CompareVertices(const FaceVertices *fv1, const FaceVertices *fv2)
Checks whether fv1 and fv2 contain the same vertices.
Definition: grid_util.cpp:44
bool FaceContains(Face *f, EdgeVertices *ev)
returns true if the given face contains the two given vertices
Definition: grid_util.cpp:561
void CollectVolumes(std::vector< Volume * > &vVolumesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all volumes that exist in the given grid which contain the given vertex.
Definition: grid_util.cpp:592
void CollectEdgesSorted(vector< Edge * > &vEdgesOut, Grid &grid, Vertex *v, bool clearContainer)
Collects all edges of a vertex, thus, none.
Definition: grid_util.cpp:205
void CollectEdges(std::vector< Edge * > &vEdgesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all edges which exist in the given grid and which are part of the given vertex.
Definition: grid_util.cpp:295
void CollectFacesSorted(vector< Face * > &vFacesOut, Grid &grid, Vertex *v, bool clearContainer)
Collects all Faces of a Vertex, thus, none.
Definition: grid_util.cpp:401
void CollectFaces(std::vector< Face * > &vFacesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all faces that exist in the given grid which contain the given vertex.
Definition: grid_util.cpp:458
void CollectVertices(std::vector< Vertex * > &vVertexOut, Grid &grid, Vertex *v, bool clearContainer)
Collects all vertices.
Definition: grid_util.cpp:141
UG_API void CollectAssociated(std::vector< Vertex * > &vVertexOut, Grid &grid, GridObject *obj, bool clearContainer=true)
Definition: grid_util_impl.hpp:169
UG_API bool CompareVertexContainer(const TVrtContainer1 &con1, const TVrtContainer2 &con2)
compares vertices in a container
Definition: grid_util_impl.hpp:62
Vertex * GetVertex(Vertex *v, size_t i)
returns the i'th vertex of a vertex
Definition: grid_util_impl.hpp:99
bool VolumeContains(VolumeVertices *v, Vertex *vrt)
returns true if the given volume contains the given vertex
Definition: grid_util.cpp:748
size_t NumVertices(Vertex *elem)
Returns the number of vertices of the given geometric object.
Definition: grid_util_impl.hpp:123
#define UG_API
Definition: ug_config.h:65
the ug namespace
bool VertexGroupsMatch(const IVertexGroup *elem, const IVertexGroup &desc)
Checks whether two vertex groups contain the same vertices.
Definition: grid_util.cpp:101