ug4
subset_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__SUBSET_UTIL__
34 #define __H__LIB_GRID__SUBSET_UTIL__
35 
36 #include <vector>
37 #include "lib_grid/lg_base.h"
38 #include "common/ug_config.h"
39 
40 namespace ug
41 {
42 
51 // FindFirstFreeSubset
53 
59 template <class TElem>
61 
64 UG_API
65 int GetFirstFreeSubset(const ISubsetHandler& sh);
66 
68 // MakeSubsetsConsecutive
70 
76 template <class TElem>
78 
81 
83 UG_API
84 void AssignGridToSubset(Grid& g, ISubsetHandler& sh, int subsetInd);
85 
88 
91 UG_API
92 void AssignSelectionToSubset(ISelector& sel, ISubsetHandler& sh, int subsetInd);
93 
95 // AssignFaceInterfaceEdgesToSubsets
97 
101 UG_API
103 
105 // AssignVolumeInterfaceFacesToSubsets
107 
111 UG_API
113 
115 // AssignAssociatedVerticesToSubset
117 
121 template <class TIterator>
122 void AssignAssociatedVerticesToSubset(ISubsetHandler& sh, TIterator elemsBegin,
123  TIterator elemsEnd, int subsetIndex);
124 
125 
128 
129 template <class TIterator>
130 void CopySubsetIndicesToSides(ISubsetHandler& sh, TIterator elemsBegin,
131  TIterator elemsEnd, bool toUnassignedOnly);
132 
135 
139 UG_API
140 void CopySubsetIndicesToSides(ISubsetHandler& sh, GridObjectCollection goc,
141  bool toUnassignedOnly);
142 
145 
149 UG_API
150 void CopySubsetIndicesToSides(ISubsetHandler& sh, ISelector& sel,
151  bool toUnassignedOnly);
152 
155 
159 UG_API
160 void CopySubsetIndicesToSides(ISubsetHandler& sh, bool toUnassignedOnly);
161 
163 // AdjustSubsetsForLgmNg
165 
179 UG_API
180 void AdjustSubsetsForLgmNg(Grid& grid, SubsetHandler& sh,
181  bool keepExistingInterfaceSubsets = false);
182 
184 // SplitIrregularManifoldSubset
186 
198 UG_API
199 bool SplitIrregularManifoldSubset(SubsetHandler& sh, int srcIndex,
200  int targetIndex, bool strictSplitting = false);
201 
203 // SeparateFaceSubsetsByNormal
205 
220 UG_API
221 void SeparateFaceSubsetsByNormal(Grid& grid, SubsetHandler& sh,
222  APosition aPos = aPosition,
223  ANormal* paNorm = NULL,
224  int applyToSubset = -2);
225 
227 // SeparateFaceSubsetsByNormal
229 
245 UG_API
246 void SeparateFaceSubsetsByNormal(Grid& grid, SubsetHandler& sh,
247  std::vector<vector3> vNormals,
248  APosition aPos = aPosition,
249  ANormal* paNorm = NULL,
250  int applyToSubset = -2);
251 
254 
269 UG_API
270 void AssignRegionToSubset(Grid& grid, ISubsetHandler& shVolsOut,
271  const ISubsetHandler& shFaces,
272  Volume* proxyVol, int newSubsetIndex);
273 
276 
287 UG_API
288 bool SeparateRegions(Grid& grid, ISubsetHandler& shVolsOut,
289  const ISubsetHandler& shFaces,
290  const MarkerPointManager& mpm,
291  int firstSubsetIndex);
292 
294 // SeparateSubsetsByLowerDimSubsets
296 
301 template <class TElem>
303  bool appendAtEnd = false);
304 
306 // SeparateSubsetsByLowerDimSelection
308 
313 template <class TElem>
315  Selector& sel, bool appendAtEnd = false);
316 
318 // SeparateSubsetsByLowerDimSeparators
320 
332 template <class TElem>
334  bool appendAtEnd,
335  boost::function<bool (typename TElem::lower_dim_base_object*)>
336  cbIsSeparator);
337 
339 // AssignInnerAndBoundarySubsets
341 UG_API
342 void AssignInnerAndBoundarySubsets(Grid& grid, ISubsetHandler& shOut,
343  int inSubset, int bndSubset);
344 
345 
348 //todo: Move this method to common/util or something like that.
349 UG_API
351 
353 // AssignSubsetColors
355 UG_API
356 void AssignSubsetColors(ISubsetHandler& sh);
357 
358 
359 
362 
373 template <class TElem>
374 void AssignSidesToSubsets(ISubsetHandler& sh, ISelector* psel = NULL);
375 
378 template <class TElem, class TSubsetHandler>
379 void AssignUnassignedElemsToSubset(TSubsetHandler& sh, int si);
380 
381 
384 
396 template <class TSubsetHandler>
397 void AdjustSubsetsForSimulation(TSubsetHandler& sh,
398  bool preserveExistingSubsets);
399 
402 
403 UG_API
404 void AssignSubsetsByElementType(ISubsetHandler& sh);
405 
406 UG_API
407 void AssignSubsetsByElementType(ISubsetHandler& sh, GridObjectCollection g);
412 // FaceArea
414 
422 template <class TAAPosVRT>
423 UG_API
424 number FaceArea(ISubsetHandler& sh, int si, size_t lvl, TAAPosVRT& aaPos);
425 
426 
428 // AssignAssociatedVerticesToSubsets
430 
442 template <class TElem, class TSubsetHandler>
443 void AssignAssociatedVerticesToSubsets(TSubsetHandler& sh,
444  const ISubsetHandler& srcIndHandler);
445 
447 // AssignAssociatedEdgesToSubsets
449 
461 template <class TElem, class TSubsetHandler>
462 void AssignAssociatedEdgesToSubsets(TSubsetHandler& sh,
463  const ISubsetHandler& srcIndHandler);
464 
466 // AssignAssociatedFacesToSubsets
468 
480 template <class TElem, class TSubsetHandler>
481 void AssignAssociatedFacesToSubsets(TSubsetHandler& sh,
482  const ISubsetHandler& srcIndHandler);
483 
485 // AssignAssociatedFacesToSubsets
487 
497 template <class TElem, class TSubsetHandlerDest, class TSubsetHandlerSrc>
498 void AssignAssociatedSidesToSubsets(TSubsetHandlerDest& sh,
499  const TSubsetHandlerSrc& srcIndHandler);
500 
502 // AssignAssociatedLowerDimElems
504 
517 template <class TElem, class TSubsetHandlerDest, class TSubsetHandlerSrc>
518 void AssignAssociatedLowerDimElemsToSubsets(TSubsetHandlerDest& sh,
519  const TSubsetHandlerSrc& srcIndHandler);
520 
524 
544 template <typename TBaseObj>
545 void FindSubsetGroups(
546  std::vector<int> & minCondInd,
547  const std::vector<bool> & isMarked,
548  const ISubsetHandler & sh,
549  const NeighborhoodType nbhType = NHT_VERTEX_NEIGHBORS);
550 
551 
554 
568 UG_API
570  ISubsetHandler& sh,
571  AChar aDimension,
572  bool includeUnassigned);
573  // end of doxygen defgroup command
575 }// end of namespace
576 
578 // include implementations of template methods.
579 #include "subset_util_impl.hpp"
580 
581 #endif
static number FaceArea(TDomain &dom, ISubsetHandler &sh, int si, size_t lvl)
Definition: domain_bridge.cpp:262
NeighborhoodType
Constants to specify a neighborhood.
Definition: neighborhood.h:53
@ NHT_VERTEX_NEIGHBORS
Definition: neighborhood.h:55
void AdjustSubsetsForSimulation(TSubsetHandler &sh, bool preserveExistingSubsets)
Adjust the grid so that it is ready for simulation with ug4.
Definition: subset_util_impl.hpp:252
void SeparateSubsetsByLowerDimSubsets(Grid &grid, SubsetHandler &sh, bool appendAtEnd=false)
Assigns all elements of the given type to subsets.
Definition: subset_util_impl.hpp:97
void CopySubsetIndicesToSides(ISubsetHandler &sh, GridObjectCollection goc, bool toUnassignedOnly)
copies subset-indices to sides of the specified elements
Definition: subset_util.cpp:306
void AssignVolumeInterfaceFacesToSubsets(Grid &grid, SubsetHandler &sh)
assigns faces which belong to no subset and are adjacent to volumes of different subsets to new subse...
Definition: subset_util.cpp:178
void AssignSelectionToSubset(ISelector &sel, ISubsetHandler &sh, int subsetInd)
Assigns all selected elements to the specified subset.
Definition: subset_util.cpp:97
bool SplitIrregularManifoldSubset(SubsetHandler &sh, int srcIndex, int targetIndex, bool strictSplitting)
Keeps a regular part in the subset and assigns all other faces to another one.
Definition: subset_util.cpp:583
void AdjustSubsetsForLgmNg(Grid &grid, SubsetHandler &sh, bool keepExistingInterfaceSubsets)
reorders subsets in a way that allows for easy export to lgm-ng.
Definition: subset_util.cpp:354
void AssignRegionToSubset(Grid &grid, ISubsetHandler &shVolsOut, const ISubsetHandler &shFaces, Volume *proxyVol, int newSubsetIndex)
assigns a region of volumes to a subset.
Definition: subset_util.cpp:914
vector3 GetColorFromStandardPalette(int index)
Returns an rgb vector (values ranging from 0 to 1), with the i-th default color.
Definition: subset_util.cpp:1084
void AssignSidesToSubsets(ISubsetHandler &sh, ISelector *psel)
Assigns all sides of elements of the given type to a separate subset.
Definition: subset_util.cpp:1098
bool SeparateRegions(Grid &grid, ISubsetHandler &shVolsOut, const ISubsetHandler &shFaces, const MarkerPointManager &mpm, int firstSubsetIndex)
finds regions by marker-points
Definition: subset_util.cpp:967
void AssignFaceInterfaceEdgesToSubsets(Grid &grid, SubsetHandler &sh)
assigns edges which belong to no subset and are adjacent to faces of different subsets to new subsets...
Definition: subset_util.cpp:118
void AssignAssociatedVerticesToSubsets(TSubsetHandler &sh, const ISubsetHandler &srcIndHandler)
Assigns associated vertices of elements of type TElem in sh to sh.
Definition: subset_util_impl.hpp:365
void AssignInnerAndBoundarySubsets(Grid &grid, ISubsetHandler &shOut, int inSubset, int bndSubset)
assigns objects to subsets depending on whether they are inner or boundary objects.
Definition: subset_util.cpp:1003
void AssignSubsetsByElementType(ISubsetHandler &sh)
Assigns subset depending on the element type.
Definition: subset_util.cpp:1216
void SeparateSubsetsByLowerDimSeparators(Grid &grid, SubsetHandler &sh, bool appendAtEnd, boost::function< bool(typename TElem::lower_dim_base_object *)> cbIsSeparator)
Assigns all elements of the given type to subsets.
Definition: subset_util_impl.hpp:113
void AssignUnassignedElemsToSubset(TSubsetHandler &sh, int si)
Assigns all elements of type TElem with subset index -1 to subset at index si.
Definition: subset_util_impl.hpp:226
void MakeSubsetsConsecutive(SubsetHandler &sh)
moves subsets so that no empty subset of type TElem is between filled ones.
Definition: subset_util_impl.hpp:66
void SeparateSubsetsByLowerDimSelection(Grid &grid, SubsetHandler &sh, Selector &sel, bool appendAtEnd=false)
Assigns all elements of the given type to subsets.
Definition: subset_util_impl.hpp:105
void SeparateFaceSubsetsByNormal(Grid &grid, SubsetHandler &sh, APosition aPos, ANormal *paNorm, int applyToSubset)
separates faces by orthogonal axis-aligned normals.
Definition: subset_util.cpp:721
void AssignAssociatedFacesToSubsets(TSubsetHandler &sh, const ISubsetHandler &srcIndHandler)
Assigns associated faces of elements of type TElem in sh to sh.
Definition: subset_util_impl.hpp:413
void AssignSubsetColors(ISubsetHandler &sh)
assigns a different color to each subset
Definition: subset_util.cpp:1090
void ComputeLocalSubsetDimensions(ISubsetHandler &sh, AChar aDimension, bool includeUnassigned)
Computes the local subset dimension for each element and stores it in the given attachment.
Definition: subset_util.cpp:1338
void AssignAssociatedEdgesToSubsets(TSubsetHandler &sh, const ISubsetHandler &srcIndHandler)
Assigns associated edges of elements of type TElem in sh to sh.
Definition: subset_util_impl.hpp:387
void AssignAssociatedSidesToSubsets(TSubsetHandlerDest &sh, const TSubsetHandlerSrc &srcIndHandler)
Assigns associated sides of elements of type TElem in sh to sh.
Definition: subset_util_impl.hpp:438
void AssignAssociatedLowerDimElemsToSubsets(TSubsetHandlerDest &sh, const TSubsetHandlerSrc &srcIndHandler)
Assigns associated elements of elements of type TElem in sh to sh.
Definition: subset_util_impl.hpp:505
void AssignAssociatedVerticesToSubset(ISubsetHandler &sh, TIterator elemsBegin, TIterator elemsEnd, int subsetIndex)
assigns vertices of the given elements to the subset at subsetIndex
Definition: subset_util_impl.hpp:349
int GetMaxSubsetIndex(SubsetHandler &sh)
returns the index of the last subset, that contains elements of type TElem.
Definition: subset_util_impl.hpp:47
void AssignGridToSubset(Grid &g, ISubsetHandler &sh, int subsetInd)
Assigns all elements of the given grid to the given subset.
Definition: subset_util.cpp:85
void FindSubsetGroups(std::vector< int > &minCondInd, const std::vector< bool > &isMarked, const ISubsetHandler &sh, const NeighborhoodType nbhType=NHT_VERTEX_NEIGHBORS)
Definition: subset_util_impl.hpp:515
int GetFirstFreeSubset(const ISubsetHandler &sh)
returns the first subset, which does not contain any elements at all
Definition: subset_util.cpp:49
#define UG_API
Definition: ug_config.h:65
double number
Definition: types.h:124
MathVector< 3, number > vector3
a 3d vector
Definition: ugmath_types.h:72
the ug namespace
GridSubsetHandler SubsetHandler
Definition: subset_handler_grid.h:376
APosition3 APosition
Definition: common_attachments.h:76
ANormal3 ANormal
Definition: common_attachments.h:77
APosition aPosition("position", true)
The standard 3d position type.
Definition: common_attachments.h:84
Attachment< char > AChar
Definition: common_attachments.h:53