ug4
subset_assemble_util.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3  * Author: Andreas Vogel
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__LIB_DISC__SPATIAL_DISC__SUBSET_ASSEMBLE_UTIL__
34 #define __H__UG__LIB_DISC__SPATIAL_DISC__SUBSET_ASSEMBLE_UTIL__
35 
36 // extern includes
37 #include <iostream>
38 #include <vector>
39 
40 // other ug4 modules
41 #include "common/common.h"
46 
47 namespace ug {
48 
58 template <typename TElemIn>
59 void CreateSubsetGroups(std::vector<SubsetGroup>& vSSGrp,
60  SubsetGroup& unionSSGrp,
61  std::vector<TElemIn*> vElemDisc,
63 {
64  PROFILE_FUNC_GROUP("discretization");
65 // resize subset group vector
66  vSSGrp.resize(vElemDisc.size());
67 
68 // if empty, nothing to do
69  if(vSSGrp.empty()) {unionSSGrp.clear(); return;}
70 
71 // create subset group for each elem disc
72  for(size_t i = 0; i < vSSGrp.size(); ++i)
73  {
74  vSSGrp[i].set_subset_handler(pSH);
75  vSSGrp[i].add(vElemDisc[i]->symb_subsets());
76  }
77 
78 // set underlying subsetHandler
79  unionSSGrp.set_subset_handler(pSH);
80 
81 // add all Subset groups of the element discs
82  for(size_t i = 0; i < vSSGrp.size(); ++i)
83  {
84  // add subset group of elem disc
85  try{
86  unionSSGrp.add(vSSGrp[i]);
87  }UG_CATCH_THROW("Cannot add subsets of the Elem Disc "<<i<<" to union of Subsets.");
88  }
89 }
90 
91 
92 
93 
106 template <typename TElemOut, typename TElemIn>
107 void GetElemDiscItemOnSubset(std::vector<TElemOut*>& vSubsetElemDiscOut,
108  const std::vector<TElemIn*>& vElemDiscIn,
109  const std::vector<SubsetGroup>& vSSGrp,
110  int si, bool clearVec=true)
111 {
112 // clear Vector
113  if(clearVec) vSubsetElemDiscOut.clear();
114 
115 // loop elem discs
116  for(size_t i = 0; i < vElemDiscIn.size(); ++i)
117  {
118  // if subset is used, add elem disc to Subset Elem Discs
119  if(vSSGrp[i].contains(si))
120  vSubsetElemDiscOut.push_back(static_cast<TElemOut*>(vElemDiscIn[i]));
121  }
122 }
123 
127 template <typename TDomain>
128 void GetElemDiscOnSubset(std::vector<IElemDisc<TDomain>*>& vSubsetElemDisc,
129  const std::vector<IElemDisc<TDomain>*>& vElemDisc,
130  const std::vector<SubsetGroup>& vSSGrp,
131  int si, bool clearVec = true);
132 
133 
134 } // end namespace ug
135 
136 #endif /* __H__UG__LIB_DISC__SPATIAL_DISC__SUBSET_ASSEMBLE_UTIL__ */
Definition: smart_pointer.h:296
Group of subsets.
Definition: subset_group.h:51
void clear()
clear all subsets
Definition: subset_group.h:116
void set_subset_handler(ConstSmartPtr< ISubsetHandler > sh)
set an underlying subset handler
Definition: subset_group.h:69
void add(int si)
adds a subset by number to this group
Definition: subset_group.cpp:64
function table contains(t, value)
#define UG_CATCH_THROW(msg)
Definition: error.h:64
the ug namespace
void GetElemDiscItemOnSubset(std::vector< TElemOut * > &vSubsetElemDiscOut, const std::vector< TElemIn * > &vElemDiscIn, const std::vector< SubsetGroup > &vSSGrp, int si, bool clearVec=true)
Definition: subset_assemble_util.h:107
void GetElemDiscOnSubset(std::vector< IElemDisc< TDomain > * > &vSubsetElemDisc, const std::vector< IElemDisc< TDomain > * > &vElemDisc, const std::vector< SubsetGroup > &vSSGrp, int si, bool clearVec)
Definition: subset_assemble_util.cpp:40
void CreateSubsetGroups(std::vector< SubsetGroup > &vSSGrp, SubsetGroup &unionSSGrp, std::vector< TElemIn * > vElemDisc, ConstSmartPtr< ISubsetHandler > pSH)
Definition: subset_assemble_util.h:59
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258