Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
40namespace ug
41{
42
51// FindFirstFreeSubset
53
59template <class TElem>
61
65int GetFirstFreeSubset(const ISubsetHandler& sh);
66
68// MakeSubsetsConsecutive
70
76template <class TElem>
78
81
84void AssignGridToSubset(Grid& g, ISubsetHandler& sh, int subsetInd);
85
88
92void AssignSelectionToSubset(ISelector& sel, ISubsetHandler& sh, int subsetInd);
93
95// AssignFaceInterfaceEdgesToSubsets
97
101UG_API
103
105// AssignVolumeInterfaceFacesToSubsets
107
111UG_API
113
115// AssignAssociatedVerticesToSubset
117
121template <class TIterator>
122void AssignAssociatedVerticesToSubset(ISubsetHandler& sh, TIterator elemsBegin,
123 TIterator elemsEnd, int subsetIndex);
124
125
128
129template <class TIterator>
130void CopySubsetIndicesToSides(ISubsetHandler& sh, TIterator elemsBegin,
131 TIterator elemsEnd, bool toUnassignedOnly);
132
135
139UG_API
140void CopySubsetIndicesToSides(ISubsetHandler& sh, GridObjectCollection goc,
141 bool toUnassignedOnly);
142
145
149UG_API
150void CopySubsetIndicesToSides(ISubsetHandler& sh, ISelector& sel,
151 bool toUnassignedOnly);
152
155
159UG_API
160void CopySubsetIndicesToSides(ISubsetHandler& sh, bool toUnassignedOnly);
161
163// AdjustSubsetsForLgmNg
165
179UG_API
180void AdjustSubsetsForLgmNg(Grid& grid, SubsetHandler& sh,
181 bool keepExistingInterfaceSubsets = false);
182
184// SplitIrregularManifoldSubset
186
198UG_API
199bool SplitIrregularManifoldSubset(SubsetHandler& sh, int srcIndex,
200 int targetIndex, bool strictSplitting = false);
201
203// SeparateFaceSubsetsByNormal
205
220UG_API
221void SeparateFaceSubsetsByNormal(Grid& grid, SubsetHandler& sh,
222 APosition aPos = aPosition,
223 ANormal* paNorm = NULL,
224 int applyToSubset = -2);
225
227// SeparateFaceSubsetsByNormal
229
245UG_API
246void SeparateFaceSubsetsByNormal(Grid& grid, SubsetHandler& sh,
247 std::vector<vector3> vNormals,
248 APosition aPos = aPosition,
249 ANormal* paNorm = NULL,
250 int applyToSubset = -2);
251
254
269UG_API
270void AssignRegionToSubset(Grid& grid, ISubsetHandler& shVolsOut,
271 const ISubsetHandler& shFaces,
272 Volume* proxyVol, int newSubsetIndex);
273
276
287UG_API
288bool SeparateRegions(Grid& grid, ISubsetHandler& shVolsOut,
289 const ISubsetHandler& shFaces,
290 const MarkerPointManager& mpm,
291 int firstSubsetIndex);
292
294// SeparateSubsetsByLowerDimSubsets
296
301template <class TElem>
303 bool appendAtEnd = false);
304
306// SeparateSubsetsByLowerDimSelection
308
313template <class TElem>
315 Selector& sel, bool appendAtEnd = false);
316
318// SeparateSubsetsByLowerDimSeparators
320
332template <class TElem>
334 bool appendAtEnd,
335 boost::function<bool (typename TElem::lower_dim_base_object*)>
336 cbIsSeparator);
337
339// AssignInnerAndBoundarySubsets
341UG_API
342void AssignInnerAndBoundarySubsets(Grid& grid, ISubsetHandler& shOut,
343 int inSubset, int bndSubset);
344
345
348//todo: Move this method to common/util or something like that.
349UG_API
351
353// AssignSubsetColors
355UG_API
356void AssignSubsetColors(ISubsetHandler& sh);
357
358
359
362
373template <class TElem>
374void AssignSidesToSubsets(ISubsetHandler& sh, ISelector* psel = NULL);
375
378template <class TElem, class TSubsetHandler>
379void AssignUnassignedElemsToSubset(TSubsetHandler& sh, int si);
380
381
384
396template <class TSubsetHandler>
397void AdjustSubsetsForSimulation(TSubsetHandler& sh,
398 bool preserveExistingSubsets);
399
402
403UG_API
404void AssignSubsetsByElementType(ISubsetHandler& sh);
405
406UG_API
407void AssignSubsetsByElementType(ISubsetHandler& sh, GridObjectCollection g);
412// FaceArea
414
422template <class TAAPosVRT>
423UG_API
424number FaceArea(ISubsetHandler& sh, int si, size_t lvl, TAAPosVRT& aaPos);
425
426
428// AssignAssociatedVerticesToSubsets
430
442template <class TElem, class TSubsetHandler>
443void AssignAssociatedVerticesToSubsets(TSubsetHandler& sh,
444 const ISubsetHandler& srcIndHandler);
445
447// AssignAssociatedEdgesToSubsets
449
461template <class TElem, class TSubsetHandler>
462void AssignAssociatedEdgesToSubsets(TSubsetHandler& sh,
463 const ISubsetHandler& srcIndHandler);
464
466// AssignAssociatedFacesToSubsets
468
480template <class TElem, class TSubsetHandler>
481void AssignAssociatedFacesToSubsets(TSubsetHandler& sh,
482 const ISubsetHandler& srcIndHandler);
483
485// AssignAssociatedFacesToSubsets
487
497template <class TElem, class TSubsetHandlerDest, class TSubsetHandlerSrc>
498void AssignAssociatedSidesToSubsets(TSubsetHandlerDest& sh,
499 const TSubsetHandlerSrc& srcIndHandler);
500
502// AssignAssociatedLowerDimElems
504
517template <class TElem, class TSubsetHandlerDest, class TSubsetHandlerSrc>
518void AssignAssociatedLowerDimElemsToSubsets(TSubsetHandlerDest& sh,
519 const TSubsetHandlerSrc& srcIndHandler);
520
524
544template <typename TBaseObj>
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
568UG_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