Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
multi_grid_util_impl.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-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__UG__MULTI_GRID_UTIL_IMPL__
34#define __H__UG__MULTI_GRID_UTIL_IMPL__
35
36#include "subset_util.h"
37
38namespace ug
39{
40
41template <class TElem>
43 MultiGrid& mg,
45 bool clearContainer)
46{
47// some typedefs
48 typedef typename geometry_traits<TElem>::iterator ElemIter;
49
50// clear the target surfaceView
51 if(clearContainer)
52 surfaceViewOut.clear();
53
54// iterate through all levels of the mgsh
55 for(size_t level = 0; level < mgsh.num_levels(); ++level){
56// iterate through all subsets on that level
57 for(int si = 0; si < mgsh.num_subsets(); ++si){
58 // iterate through all elements in the subset on that level
59 for(ElemIter iter = mgsh.begin<TElem>(si, level);
60 iter != mgsh.end<TElem>(si, level); ++iter)
61 {
62 TElem* elem = *iter;
63 // check whether the element has children
64 if(!mg.has_children(elem)){
65 // the element is a part of the surface-view. add it to the handler
66 surfaceViewOut.assign_subset(elem, si);
67 }
68 }
69 }
70 }
71}
72
73template <class TSurfaceView>
74void CreateSurfaceView(TSurfaceView& surfaceViewOut,
75 MultiGrid& mg,
77{
78// This method clears the surfaceViewOut and assigns all objects of
79// which lie on the surface of the mg to the surface view.
80 CollectSurfaceViewElements<Vertex>(surfaceViewOut, mg, mgsh, true);
81 CollectSurfaceViewElements<Edge>(surfaceViewOut, mg, mgsh, false);
82 CollectSurfaceViewElements<Face>(surfaceViewOut, mg, mgsh, false);
83 CollectSurfaceViewElements<Volume>(surfaceViewOut, mg, mgsh, false);
84
85// assign associated elements of lower dimension to the surface view
86 bool assignSidesOnly = true;
88 assignSidesOnly = false;
89 else if(mgsh.num<Volume>() > 0 && !mg.option_is_enabled(VOLOPT_AUTOGENERATE_EDGES))
90 assignSidesOnly = false;
91 else if(mgsh.num<Face>() > 0 && !mg.option_is_enabled(FACEOPT_AUTOGENERATE_EDGES))
92 assignSidesOnly = false;
93
94 if(assignSidesOnly){
95 AssignAssociatedSidesToSubsets<Volume>(surfaceViewOut, mgsh);
96 AssignAssociatedSidesToSubsets<Face>(surfaceViewOut, mgsh);
97 AssignAssociatedSidesToSubsets<Edge>(surfaceViewOut, mgsh);
98 }
99 else
100 {
101 UG_LOG("INFO in CreateSurfaceView: Performing AssignAssociatedLowerDimElemsToSubsets ");
102 UG_LOG("for all elements (Small Performance drawback).\n");
103
104 AssignAssociatedLowerDimElemsToSubsets<Volume>(surfaceViewOut, mgsh);
105 AssignAssociatedLowerDimElemsToSubsets<Face>(surfaceViewOut, mgsh);
106 AssignAssociatedLowerDimElemsToSubsets<Edge>(surfaceViewOut, mgsh);
107 }
108}
109
110template <class TElem>
111bool IsSubSurfaceElement(MultiGrid& mg, TElem* e, bool checkSides)
112{
113 typedef typename TElem::grid_base_object TBaseElem;
114
115 size_t numChildren = mg.num_children<TBaseElem>(e);
116 for(size_t i = 0; i < numChildren; ++i){
117 TBaseElem* child = mg.get_child<TBaseElem>(e, i);
118 assert(child);
119 if(mg.num_children<TBaseElem>(child) != 0)
120 return false;
121 }
122
123// ok all children of the same base type are surface elements.
124 if(checkSides){
125 // Now we have to check whether all sides are surface elements, too.
126 // Since vertices do not have sides, this recursion will terminate.
127 for(size_t i = 0; i < e->num_sides(); ++i){
128 if(!IsSubSurfaceElement(mg, mg.get_side(e, i)))
129 return false;
130 }
131 }
132
133 return true;
134}
135
136}// end of namespace
137
138#endif
Faces are 2-dimensional objects.
Definition grid_base_objects.h:510
bool option_is_enabled(uint option) const
see set_options for a description of valid parameters.
Definition grid.cpp:721
Vertex::side * get_side(Vertex *obj, size_t side)
This method returns the i-th side of an Edge, Face or Volume.
Definition grid.cpp:1170
Definition subset_handler_interface.h:223
void assign_subset(TIterator iterBegin, TIterator iterEnd, int subsetIndex)
Definition subset_handler_interface_impl.hpp:170
void clear()
Definition subset_handler_interface.cpp:500
int num_subsets() const
returns the number of subset-infos (return value is int, since SubsetIndices are of type int)
Definition subset_handler_interface.h:317
Definition multi_grid.h:72
TChild * get_child(TElem *elem, size_t ind) const
returns the i-th child of the given child-type
Definition multi_grid.h:268
bool has_children(TElem *elem) const
Definition multi_grid.h:217
size_t num_children(TElem *elem) const
returns the number of children of the given child-type
Definition multi_grid.h:225
Handles subsets on a per level basis.
Definition subset_handler_multi_grid.h:60
uint num() const
returns the total number of elements
Definition subset_handler_multi_grid_impl.hpp:202
geometry_traits< TElem >::iterator end(int subsetIndex, int level)
returns the end-iterator for the elements of type TElem in the given subset.
Definition subset_handler_multi_grid_impl.hpp:64
uint num_levels() const
returns the number of levels
Definition subset_handler_multi_grid.h:80
geometry_traits< TElem >::iterator begin(int subsetIndex, int level)
returns the begin-iterator for the elements of type TElem in the given subset.
Definition subset_handler_multi_grid_impl.hpp:44
Volumes are 3-dimensional objects.
Definition grid_base_objects.h:754
Definition grid_base_object_traits.h:68
@ VOLOPT_AUTOGENERATE_EDGES
Definition grid_constants.h:82
@ VOLOPT_AUTOGENERATE_FACES
Definition grid_constants.h:83
@ FACEOPT_AUTOGENERATE_EDGES
Definition grid_constants.h:71
#define UG_LOG(msg)
Definition log.h:367
the ug namespace
bool IsSubSurfaceElement(MultiGrid &mg, TElem *e, bool checkSides=false)
returns true, if the element lies one level below the surface
Definition multi_grid_util_impl.hpp:111
void CreateSurfaceView(TSurfaceView &surfaceViewOut, MultiGrid &mg, MGSubsetHandler &mgsh)
void CollectSurfaceViewElements(ISubsetHandler &surfaceViewOut, MultiGrid &mg, MGSubsetHandler &mgsh, bool clearContainer=true)
Definition multi_grid_util_impl.hpp:42