ug4
distributed_grid_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__LIB_GRID__DISTRIBUTED_GRID_IMPL__
34 #define __H__LIB_GRID__DISTRIBUTED_GRID_IMPL__
35 
36 #include <vector>
37 #include <utility>
38 
39 namespace ug
40 {
41 
42 template <class TElem>
44 is_interface_element(TElem* elem)
45 {
46  return elem_info(elem).get_status() & ES_IN_INTERFACE;
47 }
48 
49 template<class TElem>
51 is_in_horizontal_interface(TElem* elem) const
52 {
53  byte status = get_status(elem);
54  return (status & (ES_H_MASTER | ES_H_SLAVE)) != 0;
55 }
56 
57 template<class TElem>
59 is_in_vertical_interface(TElem* elem) const
60 {
61  byte status = get_status(elem);
62  return (status & (ES_V_MASTER | ES_V_SLAVE)) != 0;
63 }
64 
65 template<class TElem>
67 is_ghost(TElem* elem) const
68 {
69  byte status = get_status(elem);
70  return (status & (ES_V_MASTER | ES_H_MASTER | ES_H_SLAVE))
71  == ES_V_MASTER;
72 
73  //would require update_ghost_states
74  //return contains_status(elem, ES_GHOST);
75 }
76 
77 template <class TElem>
80  std::vector<std::pair<int, size_t> >& vEntriesOut,
81  TElem* elem, byte statusType, bool clearContainer)
82 {
83 //TODO: make sure that the localIDs match the position at which
84 // an element is stored in the interface
85  typedef ElementInfo<TElem> ElemInfo;
86  ElemInfo& info = elem_info(elem);
87 
88  if(clearContainer)
89  vEntriesOut.clear();
90 
91  for(typename ElemInfo::EntryIterator iter = info.entries_begin();
92  iter != info.entries_end(); ++iter)
93  {
94  if((info.get_interface_type(iter) & statusType) == statusType){
95  vEntriesOut.push_back(std::make_pair(info.get_target_proc(iter),
96  info.get_local_id(iter)));
97  }
98  }
99 }
100 
101 }// end of namespace
102 
103 #endif
Be careful when creating copies of ElementInfo.
Definition: distributed_grid.h:298
byte get_status() const
Definition: distributed_grid.h:373
void collect_interface_entries(std::vector< std::pair< int, size_t > > &vEntriesOut, TElem *elem, byte statusType, bool clearContainer=true)
Definition: distributed_grid_impl.hpp:79
bool is_in_horizontal_interface(TElem *elem) const
returns true if the element is contained in a horizontal interface
Definition: distributed_grid_impl.hpp:51
byte get_status(GridObject *go) const
returns the status of the given object.
Definition: distributed_grid.cpp:379
ElemInfoVrt & elem_info(Vertex *ele)
Definition: distributed_grid.h:437
bool is_interface_element(TElem *elem)
returns true if an element is in one or more interfaces
Definition: distributed_grid_impl.hpp:44
bool is_ghost(TElem *elem) const
returns true if the element is a ghost
Definition: distributed_grid_impl.hpp:67
bool is_in_vertical_interface(TElem *elem) const
returns true if the element is contained in a vertical interface
Definition: distributed_grid_impl.hpp:59
@ ES_V_SLAVE
Definition: distributed_grid.h:61
@ ES_IN_INTERFACE
Definition: distributed_grid.h:65
@ ES_H_MASTER
Definition: distributed_grid.h:58
@ ES_V_MASTER
Definition: distributed_grid.h:60
@ ES_H_SLAVE
Definition: distributed_grid.h:59
the ug namespace