Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pane_ghost_connectivity.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: Pane_ghost_connectivity.h,v 1.5 2008/12/06 08:43:20 mtcampbe Exp $
24 
28 /* Initial version by P. Alexander, 3/14/2006
29  */
30 
31 #include <iostream>
32 #include <iomanip>
33 #include <algorithm>
34 #include <deque>
35 #include "mapbasic.h"
36 #include "Rocmap.h"
37 #include "Roccom_base.h"
38 #include "Pane_connectivity.h"
39 #include "Pane.h"
40 
42 
43 class Pane_friend : public COM::Pane {
44  explicit Pane_friend( COM::Pane&);
45 public:
46  using COM::Pane::new_attribute;
47  using COM::Pane::delete_attribute;
48  using COM::Pane::inherit;
49  using COM::Pane::set_size;
50  using COM::Pane::reinit_attr;
51  using COM::Pane::reinit_conn;
52  using COM::Pane::connectivity;
53 };
54 
55 using COM::Connectivity;
56 using COM::Attribute;
57 using COM::Window;
58 using COM::Pane;
59 
60 using std::vector;
61 using std::multimap;
62 using std::map;
63 using std::set;
64 using std::pair;
65 using std::make_pair;
66 using std::deque;
67 using std::string;
68 using std::cout;
69 using std::endl;
70 using std::setw;
71 using std::setfill;
72 
74 
75 public:
77  explicit Pane_ghost_connectivity(COM::Window *window){
78  _buf_window = window;
79  init();
80  }
81 
83  ;
84  }
85 
86  void
87  build_pconn();
88 
89  void
90  init();
91 
92  // Get a total ordering of nodes
93  void
95 
106  void
107  get_ents_to_send(vector<vector<vector<int> > > &gelem_lists,
108  vector<vector<map<pair<int,int>,int> > > &nodes_to_send,
109  vector<vector<deque<int> > > &elems_to_send,
110  vector<vector<int> > &comm_sizes);
111 
112  // Determine # of ghost nodes to receive and map (P,N) to ghost node ids
113  // Also determine # ghost elements of each type to receive
114  void
116  vector<vector<vector<int> > > &recv_info,
117  vector<vector<int> > &elem_renumbering,
118  vector<vector<map<pair<int,int>,int> > > &nodes_to_recv);
119 
120  // Take the data we've collected and turn it into the pconn
121  // Remember that there are 5 blocks in the pconn:
122  // 1) Shared node info - already exists
123  // Simply Copy into the buffer
124  // 2) Real Nodes to Send
125  // Data in nodes_to_send.. should be in correct order
126  // 3) Ghost Nodes to Receive
127  // Data in nodes_to_recv
128  // 4) Real Cells to Send
129  // In elems_to_send
130  // 5) Ghost Cells to Receive
131  // Combine elem_renumbering with recv_info
132  //
133  // Also need to calculate the connectivity tables for the
134  // new ghost elements. Do this while looking through recv_info
135  // for GCR
136 
137  void
138  finalize_pconn(vector<vector<map<pair<int,int>,int> > > &nodes_to_send,
139  vector<vector<map<pair<int,int>,int> > > &nodes_to_recv,
140  vector<vector<deque<int> > > &elems_to_send,
141  vector<vector<int> > &elem_renumbering,
142  vector<vector<vector<int> > > &recv_info);
143 
144  // Determine communicating panes for shared nodes.
145  void
146  get_cpanes();
147 
148  // send_gelem_lists
149  void
150  send_gelem_lists(vector<vector<vector<int> > > &gelem_lists,
151  vector<vector<vector<int> > > &recv_info,
152  vector<vector<int> > &comm_sizes);
153 
154  // Send arbitrary amount of data to another pane.
155  // send_info = data to send
156  // recv_info = buffer for receiving data
157  // comm_sizes = amount of data to receive
158  void
159  send_pane_info(vector<vector<vector<int> > > &send_info,
160  vector<vector<vector<int> > > &recv_info,
161  vector<vector<int> > &comm_sizes);
162 
163 private:
164 
166 
167  void
168  mark_elems_from_nodes(std::vector<std::vector<bool> > &marked_nodes,
169  std::vector<std::vector<bool> > &marked_elems);
170 
171 private:
172 
173  // Is node shared?
174  std::vector<std::vector<bool> > _is_shared_node;
175 
176  // Is the elem shared?
177  std::vector<std::vector<bool> > _is_shared_elem;
178 
179  // List of communicating panes.
180  std::vector<std::vector<int> > _cpanes;
181 
182  COM::Window* _buf_window;
183 
184  // Maps element type to element type string
185  string _etype_str[COM::Connectivity::TYPE_MAX_CONN];
186 
187  // data structures for total node ordering
188  vector<vector<int> > _p_gorder;
190 
191  // mapping from total ordering to local node id
192  vector<map<pair<int,int>,int> > _local_nodes;
193 
194  // pointers to all local panes
195  vector<Pane*> _panes;
196 
197  // number of local panes
198  int _npanes;
199 };
200 
202 
203 
204 
205 
206 
207 
#define MAP_END_NAMESPACE
Definition: mapbasic.h:29
void send_gelem_lists(vector< vector< vector< int > > > &gelem_lists, vector< vector< vector< int > > > &recv_info, vector< vector< int > > &comm_sizes)
Utility for constructing pane connectivities in parallel.
void process_received_data(vector< vector< vector< int > > > &recv_info, vector< vector< int > > &elem_renumbering, vector< vector< map< pair< int, int >, int > > > &nodes_to_recv)
std::vector< std::vector< int > > _cpanes
Contains the prototypes for the Pane object.
An Attribute object is a data member of a window.
Definition: Attribute.h:51
void finalize_pconn(vector< vector< map< pair< int, int >, int > > > &nodes_to_send, vector< vector< map< pair< int, int >, int > > > &nodes_to_recv, vector< vector< deque< int > > > &elems_to_send, vector< vector< int > > &elem_renumbering, vector< vector< vector< int > > > &recv_info)
string _etype_str[COM::Connectivity::TYPE_MAX_CONN]
void send_pane_info(vector< vector< vector< int > > > &send_info, vector< vector< vector< int > > > &recv_info, vector< vector< int > > &comm_sizes)
vector< vector< int > > _p_gorder
std::vector< std::vector< bool > > _is_shared_elem
std::vector< std::vector< bool > > _is_shared_node
vector< map< pair< int, int >, int > > _local_nodes
Pane_friend(COM::Pane &)
void mark_elems_from_nodes(std::vector< std::vector< bool > > &marked_nodes, std::vector< std::vector< bool > > &marked_elems)
#define MAP_BEGIN_NAMESPACE
Definition: mapbasic.h:28
void get_ents_to_send(vector< vector< vector< int > > > &gelem_lists, vector< vector< map< pair< int, int >, int > > > &nodes_to_send, vector< vector< deque< int > > > &elems_to_send, vector< vector< int > > &comm_sizes)
Determine elements/nodes to be ghosted on adjacent panes.
Pane_ghost_connectivity(COM::Window *window)
Constructors.
Contains declaration of the base class for Roccom implementations.