Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConnectivityMaps.C
Go to the documentation of this file.
1 #include <iomanip>
2 #include "DriverProgram.H"
3 
4 namespace GridConversion{ namespace DriverProgram{
5 
6  int SerialProgram::ConnectivityMaps(SolverUtils::Mesh::Connectivity nodesToElems){
7 
8  std::ostringstream Ostr;
9  std::stringstream ss;
10 
11  FunctionEntry("ConnectivityMaps");
12 
13  std::cout << "In ConnectivityMaps function" << std::endl;
14 
15  //resize nodeToNode map
16  nodeToNode.resize(numNodes);
17 
18  int elem, node;
19 
20  //Generate node to node map
21  //loop over every node
22  for(int i=0; i < numNodes; i++){
23  std::cout << "node " << i+1 << ":" << std::endl;
24  //loop over every element for that node
25  for(int j=0; j < nodesToElems[i].size(); j++){
26  std::cout << "element " << nodesToElems[i][j] << ":" << std::endl;
27  elem = nodesToElems[i][j]-1;
28  //loop over every node for that element
29  for(int k=0; k < numNodesPerElem; k++){
30  node = elems[numNodesPerElem*elem + k];
31  //don't add the node to its own list
32  if(node == i+1)
33  continue;
34  //loop over all the entries for the nodeToNode map and
35  //see if this node has been added yet
36  bool newValue=true;
37  for(int l=0; l < nodeToNode[i].size(); l++){
38  if(node == nodeToNode[i][l]){
39  newValue=false;
40  break;
41  }
42  }
43  //if its a new value add it
44  if(newValue){
45  nodeToNode[i].push_back(node);
46  }
47  }
48  }//element around node loop
49  }//node lope
50 
51  //print nodeToNode to check
52  if(verblevel > 3){
53  Ostr << "Node to node map:" << std::endl;
54  for(int i=0; i < nodeToNode.size(); i++){
55  Ostr << i+1 << ":" << std::endl;
56  for(int j=0; j < nodeToNode[i].size(); j++){
57  Ostr << nodeToNode[i][j] << " ";
58  }
59  Ostr << std::endl;
60  }
61  }
62 
63  //Generate list of element edges from node to node map
64  //loop over every node
66  numElemEdges = 0;
67  for(int i=0; i < numNodes; i++){
68  //loop over every node connected to that node
69  for(int j=0; j < nodeToNode[i].size(); j++){
70  node = nodeToNode[i][j];
71  //if the node # is greater than the current node then it
72  //hasn't been processed yet so its a new edge
73  if(node > i+1){
74  elemEdges.push_back(i+1);
75  elemEdges.push_back(node);
76  numElemEdges++;
77  }
78  }//nodes around node loop
79  }//node loop
80 
81  //print nodeToNode to check
82  if(verblevel > 3){
83  Ostr << "Element edges:" << std::endl;
84  for(int i=0; i < numElemEdges; i++){
85  Ostr << i+1 << ":" << std::endl;
86  for(int j=0; j < numNodesPerElemEdge; j++){
87  Ostr << elemEdges[i*numNodesPerElemEdge + j] << " ";
88  }
89  Ostr << std::endl;
90  }
91  }
92 
93  //Genereate a map from elements to element edges
94  numEdgesPerElem = 6; //Everything is pretty much hard coded
95  //for linear tets right now
96  //loop over every element
97  for(int i=0; i < numElems; i++){
98  //loop over every node for the element
99  for(int j=0; j < numNodesPerElem; j++){
100  int n1, n2;
101  n1 = elems[i*numNodesPerElem + j];
102  //loop over every other node for the element
103  for(int k=j+1; k < numNodesPerElem; k++){
104  n2 = elems[i*numNodesPerElem + k];
105  //loop over every element edge to find what edge
106  //these two nodes are
107  for(int l=0; l < numElemEdges; l++){
108  if(n1 == elemEdges[l*numNodesPerElemEdge] &&
109  n2 == elemEdges[l*numNodesPerElemEdge + 1])
110  elemToElemEdges.push_back(l+1);
111  else if(n2 == elemEdges[l*numNodesPerElemEdge] &&
112  n1 == elemEdges[l*numNodesPerElemEdge + 1])
113  elemToElemEdges.push_back(l+1);
114  }//loop over every element edge
115  }//loop over every other node for the element
116  }//loop over every node for the element
117  }//loop over every element
118 
119  //print elemToElemEdges to check
120  if(verblevel > 3){
121  Ostr << "Element to element edges:" << std::endl;
122  for(int i=0; i < numElems; i++){
123  Ostr << i+1 << ":" << std::endl;
124  for(int j=0; j < numEdgesPerElem; j++){
125  Ostr << elemToElemEdges[i*numEdgesPerElem + j] << " ";
126  }
127  Ostr << std::endl;
128  }
129  }
130 
131  StdOut(Ostr.str());
132  Ostr.str("");
133 
134  FunctionExit("ConnectivityMaps");
135 
136  return 0;
137 
138  } //HigherOrderTets function
139 
140 }; //DriverProgram namespace
141 }; //GridConversion namespace
j indices k indices k
Definition: Indexing.h:6
int numElemEdges
number of element edges in mesh
virtual int ConnectivityMaps(SolverUtils::Mesh::Connectivity nodesToElems)
This function creates a few different connectivity maps that are needed.
std::vector< unsigned int > elemToElemEdges
map of elements to element edges
GridConversion interface.
std::vector< unsigned int > elems
vector for holding element connectivies read from input
Definition: adj.h:150
int numElems
number of elements in mesh
int numNodesPerElemEdge
number of nodes per element edge
blockLoc i
Definition: read.cpp:79
int numNodesPerElem
number of nodes per element
j indices j
Definition: Indexing.h:6
std::vector< std::vector< unsigned int > > nodeToNode
vector for holding node to node map
std::vector< unsigned int > elemEdges
vector for holding element edges