Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
misc_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__MISC_UTIL__
34#define __H__LIB_GRID__MISC_UTIL__
35
36#include "lib_grid/grid/grid.h"
39
40namespace ug
41{
53template <class TElem>
55typename TElem::side*
56GetSharedSide(Grid& grid, TElem* e1, TElem* e2);
57
58
60// CalculateGridObjectCenter
62template<class TAAPosVRT>
64inline
65typename TAAPosVRT::ValueType
66CalculateGridObjectCenter(const GridObject* o, TAAPosVRT& aaPosVRT);
67
68
71
74template<class TAAPosVRT, class TAAWeightVRT>
76inline
77typename TAAPosVRT::ValueType
78CalculateGridObjectCenter(const GridObject* o, TAAPosVRT& aaPosVRT,
79 TAAWeightVRT& aaWeight);
80
82// CalculateCenter
84
87template <class TIterator, class TAAPosVRT>
88UG_API
89typename TAAPosVRT::ValueType
90CalculateCenter(TIterator begin, TIterator end, TAAPosVRT& aaPos);
91
93// FindClosestByCoordinate
95
104template<class TElem, class TVertexPositionAttachmentAccessor>
105UG_API
106TElem* FindClosestByCoordinate(const typename TVertexPositionAttachmentAccessor::ValueType& coord,
107 typename geometry_traits<TElem>::iterator iterBegin,
108 typename geometry_traits<TElem>::iterator iterEnd,
109 TVertexPositionAttachmentAccessor& aaPosVRT);
110
113
118template<class vector_t, class TIterator, class TAAPos>
119UG_API
120void CalculateBoundingBox(vector_t& vMinOut, vector_t& vMaxOut,
121 TIterator begin, TIterator end,
122 TAAPos& aaPos);
123
125// NumSharedVertices
127
132template <class TElemPtr1, class TElemPtr2>
133UG_API
134size_t NumSharedVertices(Grid& grid, TElemPtr1 elem1, TElemPtr2 elem2);
135
137// EraseConnectingElements
139UG_API
140void EraseConnectingElements(Grid& grid, Vertex* v1, Vertex* v2);
141
143// EraseElements
145template <class TElem>
146UG_API
147void EraseElements(Grid& grid, typename geometry_traits<TElem>::iterator iterBegin,
148 typename geometry_traits<TElem>::iterator iterEnd);
149
151// ElementDiameter
153template <class TElem, class TAAPos>
154number ElementDiameterSq(Grid& grid,
155 TAAPos& aaPos,
156 TElem* elem);
157
159template <class TAAPos>
160number ElementDiameterSq(Grid& grid,
161 TAAPos& aaPos,
162 GridObject* elem);
163
165template <class TElem, class TAAPos>
166number ElementDiameter(Grid& grid,
167 TAAPos& aaPos,
168 TElem* elem);
169
171
172template <class TAAPos, class TIterator>
173number MaxElementDiameter(Grid& grid, TAAPos& aaPos,
174 TIterator iterBegin, TIterator iterEnd);
175
177
178template <class TAAPos, class TIterator>
179number MinElementDiameter(Grid& grid, TAAPos& aaPos,
180 TIterator iterBegin, TIterator iterEnd);
181
182
184template <class TElem1, class TElem2, class TAAPos>
185typename TAAPos::ValueType
186GetDirection (TElem1* e1, TElem2* e2, const TAAPos& aaPos);
187
189
192template <class TElem1, class TElem2, class TAAPos>
193bool CheckDirection (TElem1* e1,
194 TElem2* e2,
195 const TAAPos& aaPos,
196 const typename TAAPos::ValueType& dir,
197 number minAngle,
198 number maxAngle);
199
200
202}// end of namespace
203
205// include implementation of template methods.
206#include "misc_util_impl.hpp"
207
208#endif
number ElementDiameter(const TElem &elem, TDomain &domain)
returns the maximal distance between to element vertices
number ElementDiameterSq(const TElem &elem, TDomain &domain)
returns the maximal squared distance between to element vertices
number MinElementDiameter(TDomain &domain, int level)
returns the minimal diameter of all elements between iterBegin and iterEnd.
Definition domain_util.cpp:113
number MaxElementDiameter(TDomain &domain, int level)
returns the maximal diameter of all elements between iterBegin and iterEnd.
Definition domain_util.cpp:104
UG_API void EraseElements(Grid &grid, typename geometry_traits< TElem >::iterator iterBegin, typename geometry_traits< TElem >::iterator iterEnd)
erases all elements between iterBegin and iterEnd.
Definition misc_util_impl.hpp:222
void EraseConnectingElements(Grid &grid, Vertex *v1, Vertex *v2)
erases all elements that connect v1 and v2
Definition misc_util.cpp:42
TAAPos::ValueType GetDirection(TElem1 *e1, TElem2 *e2, const TAAPos &aaPos)
Returns the direction from the center of e1 to the center of e2.
Definition misc_util_impl.hpp:326
UG_API TAAPosVRT::ValueType CalculateGridObjectCenter(const GridObject *o, TAAPosVRT &aaPosVRT)
calculates the center for arbitrary geometric object
Definition misc_util_impl.hpp:81
UG_API TElem * FindClosestByCoordinate(const typename TVertexPositionAttachmentAccessor::ValueType &coord, typename geometry_traits< TElem >::iterator iterBegin, typename geometry_traits< TElem >::iterator iterEnd, TVertexPositionAttachmentAccessor &aaPosVRT)
returns the element of the given type, whose center is closest to coord.
Definition misc_util_impl.hpp:136
UG_API size_t NumSharedVertices(Grid &grid, TElemPtr1 elem1, TElemPtr2 elem2)
returns the number of vertices that are shared by two objects
Definition misc_util_impl.hpp:200
UG_API TElem::side * GetSharedSide(Grid &grid, TElem *e1, TElem *e2)
returns the shared side between the two elements or NULL if no such side exists.
Definition misc_util_impl.hpp:52
bool CheckDirection(TElem1 *e1, TElem2 *e2, const TAAPos &aaPos, const typename TAAPos::ValueType &dir, number minAngle, number maxAngle)
Checks whether the center of e2 can be reached from the center of e1 in the given direction.
Definition misc_util_impl.hpp:338
#define UG_API
Definition ug_config.h:65
double number
Definition types.h:124
void CalculateCenter(vector_t &centerOut, const vector_t *pointSet, size_t numPoints)
calculates the center of a point-set
Definition math_util_impl.hpp:98
the ug namespace
AABox< typename TAAPos::ValueType > CalculateBoundingBox(Vertex *e, TAAPos aaPos)
calculates the smallest axis aligned box that contains the given vertex
Definition bounding_box_util.h:43