Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SerialProgram Class Reference

Implementation of the basic parts of the serial program example. More...

#include <DriverProgram.H>

Inheritance diagram for SerialProgram:
Collaboration diagram for SerialProgram:

Public Member Functions

 SerialProgram ()
 Default constructor. More...
 
 SerialProgram (int nargs, char **args)
 Constructor designed to take the commandline args. More...
 
virtual int Initialize ()
 Initializes native data structures from commandline args. More...
 
int VerbLevel () const
 Returns verbosity level. More...
 
virtual ~SerialProgram ()
 Destructor. More...
 
virtual int Run ()
 This function implements the main function executed by the program. More...
 
virtual int ReadPatranInput ()
 This function parses a Patran format input file. More...
 
virtual int ReadStanfordInput ()
 This function parses a Stanford format input file. More...
 
virtual int HigherOrderTets (SolverUtils::Mesh::Connectivity elemEdgeToElems, SolverUtils::Mesh::Connectivity nodesToDomains)
 This function creates higher order tets from linear tets. More...
 
virtual int ConnectivityMaps (SolverUtils::Mesh::Connectivity nodesToElems)
 This function creates a few different connectivity maps that are needed. More...
 
virtual int WriteOutput ()
 This function writes the output grid file. More...
 

Protected Attributes

std::string output_name
 Name of file for output. More...
 
std::string input_name
 Name of input file. More...
 
std::string bc_input_name
 Name of bc input file. More...
 
int verblevel
 Verbosity level. More...
 
std::ofstream Ouf
 Outfile stream for output. More...
 
std::ifstream Inf
 Infile stream for input. More...
 
bool quadratic
 boolean for changing the elements to higher order More...
 
int numNodes
 number of nodes in mesh More...
 
std::vector< double > nodes
 vector for holding nodal coordinates read from input More...
 
std::vector< std::vector< int > > nodeBCs
 
std::vector< std::vector
< std::vector< double > > > 
nodeBCValues
 vector to hold list of node bc values (these are different for each bc type - see the Rocfrac documentation for more clarification) More...
 
SolverUtils::Mesh::Connectivity nodesToDomains
 
int numElemEdges
 number of element edges in mesh More...
 
std::vector< unsigned int > elemEdges
 vector for holding element edges More...
 
int numNodesPerElemEdge
 number of nodes per element edge More...
 
std::vector< unsigned int > elemToElemEdges
 map of elements to element edges More...
 
int numEdgesPerElem
 
int numElems
 number of elements in mesh More...
 
std::vector< std::vector
< unsigned int > > 
nodeToNode
 vector for holding node to node map More...
 
std::vector< unsigned int > elems
 vector for holding element connectivies read from input More...
 
std::vector< std::vector< int > > elemBCs
 vector to hold list of element bc values More...
 
std::vector< std::vector
< std::vector< double > > > 
elemBCValues
 vector to hold list of element bc values (these are different for each bc type - see the Rocfrac documentation for more clarification) More...
 
int numNodesPerElem
 number of nodes per element More...
 
std::vector< std::vector< int > > elemsToDomains
 vector to hold the domains for each element More...
 
int elemShape
 integer to denote the shape of elements used in the mesh More...
 
std::vector< std::string > shapes
 vector to hold the element shapes (only used for Patran input format) More...
 
int numDomains
 number of domains in mesh More...
 
std::vector< std::vector
< unsigned int > > 
domains
 vector of vectors to hold the domains More...
 
std::vector< std::vector< int > > domainBCs
 vector to hold list of domain bc flags More...
 
std::vector< std::vector
< std::vector< double > > > 
domainBCValues
 vector to hold list of domain bc values (these are different for each bc type - see the Rocfrac documentation for more clarification) More...
 
std::vector< std::vector< int > > edges
 vector of vectors to hold the edges More...
 
std::vector< std::vector< int > > edgeBCs
 vector to hold list of edge bc flags More...
 
std::vector< std::vector
< std::vector< double > > > 
edgeBCValues
 vector to hold list of edge bc values (these are different for each bc type - see the Rocfrac documentation for more clarification) More...
 

Detailed Description

Implementation of the basic parts of the serial program example.

This object encapsulates the example serial program. It inherits from the IRAD::Global::Program type.

The program itself just copies a specified input file to the specified output file (or stdout if no file is given). The command line usage goes:

       sep Usage:

       sep [-h] [-v [arg] -o <filename> ] <input> 

       -h,--help
          Prints this long version of help.

              -v,--verbosity [arg]

       -o,--output <filename>
          Specifies the name of the output file.

              <input>
          Mode-dependent input: input <filename> for serial example
          program, or <number of divisions> for parallel example.

Definition at line 178 of file DriverProgram.H.

Constructor & Destructor Documentation

SerialProgram ( )
inline

Default constructor.

Definition at line 255 of file DriverProgram.H.

255  :
257  {};
IRAD::Global::Program< GlobalType, ComLineType > SerialProgramType
Convenience type definition for the serial program.
SerialProgram ( int  nargs,
char **  args 
)
inline

Constructor designed to take the commandline args.

Definition at line 261 of file DriverProgram.H.

261  :
262  SerialProgramType(nargs,args)
263  {};
IRAD::Global::Program< GlobalType, ComLineType > SerialProgramType
Convenience type definition for the serial program.
virtual ~SerialProgram ( )
inlinevirtual

Destructor.

Definition at line 348 of file DriverProgram.H.

References SerialProgram::Ouf.

348  {
349  if(Ouf){
350  Ouf.close();
351  SetOutStream(std::cout);
352  }
353  };
std::ofstream Ouf
Outfile stream for output.

Member Function Documentation

int ConnectivityMaps ( SolverUtils::Mesh::Connectivity  nodesToElems)
virtual

This function creates a few different connectivity maps that are needed.

Definition at line 6 of file ConnectivityMaps.C.

References SerialProgram::elemEdges, SerialProgram::elems, SerialProgram::elemToElemEdges, i, j, k, SerialProgram::nodeToNode, SerialProgram::numEdgesPerElem, SerialProgram::numElemEdges, SerialProgram::numElems, SerialProgram::numNodes, SerialProgram::numNodesPerElem, SerialProgram::numNodesPerElemEdge, and SerialProgram::verblevel.

Referenced by SerialProgram::Run().

6  {
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
j indices k indices k
Definition: Indexing.h:6
int numElemEdges
number of element edges in mesh
std::vector< unsigned int > elemToElemEdges
map of elements to element edges
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

Here is the caller graph for this function:

int HigherOrderTets ( SolverUtils::Mesh::Connectivity  elemEdgeToElems,
SolverUtils::Mesh::Connectivity  nodesToDomains 
)
virtual

This function creates higher order tets from linear tets.

(For now it only takes 4 node tets and creates only 10 node tets.

Definition at line 6 of file HigherOrder.C.

References SerialProgram::domains, SerialProgram::elemEdges, SerialProgram::elems, SerialProgram::elemToElemEdges, i, j, k, SerialProgram::nodes, SerialProgram::numEdgesPerElem, SerialProgram::numElemEdges, SerialProgram::numElems, SerialProgram::numNodes, SerialProgram::numNodesPerElem, SerialProgram::numNodesPerElemEdge, SerialProgram::verblevel, x, y, and z.

Referenced by SerialProgram::Run().

7  {
8 
9  std::ostringstream Ostr;
10  std::stringstream ss;
11 
12  FunctionEntry("HigherOrderTets");
13 
14  //new numNodesPerElem
15  int newNumNPE=10;
16 
17  //a vector for the new elements
18  std::vector<unsigned int> newElems(numElems*newNumNPE,0);
19 
20  //Loop over every element
21  for(int i=0; i < numElems; i++){
22  std::cout << "elem " << i+1 << std::endl;
23  //loop over all the nodes for the element
24  for(int j=0; j < numNodesPerElem; j++){
25  //first populate the new element with the original nodes
26  newElems[i*newNumNPE + j] = elems[i*numNodesPerElem + j];
27  }//loop over nodes for the element
28  }//loop over all the elements
29 
30  //Loop over every edge (we want to add a node in the middle
31  //of each edge
32  double x, y, z;
33  unsigned int n1, n2;
34  for(int i=0; i < numElemEdges; i++){
35 
36  std::cout << "edge " << i+1 << std::endl;
37  //create the new node
38  numNodes++;
40  n2 = elemEdges[i*numNodesPerElemEdge + 1]-1;
41 
42  x = (nodes[3*n1 + 0] + nodes[3*n2 + 0])/2.0;
43  y = (nodes[3*n1 + 1] + nodes[3*n2 + 1])/2.0;
44  z = (nodes[3*n1 + 2] + nodes[3*n2 + 2])/2.0;
45 
46  nodes.push_back(x);
47  nodes.push_back(y);
48  nodes.push_back(z);
49 
50  std::cout << " new node " << numNodes << ": "
51  << x << " " << y << " " << z << std::endl;
52 
53  //add the new node to the appropriate domain
54  //if its on one
55  //loop over the domains for the first node
56  for(int j=0; j < nodesToDomains[n1].size(); j++){
57  //loop over the domains for the second node
58  for(int k=0; k < nodesToDomains[n2].size(); k++){
59  //If they share a domain this new node is also on it
60  if(nodesToDomains[n1][j] == nodesToDomains[n2][k]){
61  int domain = nodesToDomains[n1][j]-1;
62  domains[domain].push_back(numNodes);
63  }
64  }
65  }
66 
67  //now add the node to the appropriate places
68  //in the element connectivity
69 
70  //loop over every element for the edge
71  for(int j=0; j < elemEdgeToElems[i].size(); j++){
72  int elem = elemEdgeToElems[i][j];
73  std::cout << " element " << elem << std::endl;
74  //find which edge this edge is for the element
75  //(1st, 2nd, ... 6th edge)
76  //loop over the edges for the element
77  for(int k=0; k < numEdgesPerElem; k++){
78  std::cout << " edge " << elemToElemEdges[numEdgesPerElem*(elem-1) + k] << std::endl;
79  //if we found the edge number add the node
80  //to the element in the appropriate place
81  //(if it hasn't already been added)
82  if(elemToElemEdges[numEdgesPerElem*(elem-1) + k] == i+1){
83  switch (k) {
84  case 0:
85  //Add the node if it hasn't already been added
86  if(newElems[newNumNPE*(elem-1) + 4] == 0){
87  newElems[newNumNPE*(elem-1) + 4] = numNodes;
88  }
89  break;
90  case 1:
91  //Add the node if it hasn't already been added
92  if(newElems[newNumNPE*(elem-1) + 6] == 0){
93  newElems[newNumNPE*(elem-1) + 6] = numNodes;
94  }
95  break;
96  case 2:
97  //Add the node if it hasn't already been added
98  if(newElems[newNumNPE*(elem-1) + 7] == 0){
99  newElems[newNumNPE*(elem-1) + 7] = numNodes;
100  }
101  break;
102  case 3:
103  //Add the node if it hasn't already been added
104  if(newElems[newNumNPE*(elem-1) + 5] == 0){
105  newElems[newNumNPE*(elem-1) + 5] = numNodes;
106  }
107  break;
108  case 4:
109  //Add the node if it hasn't already been added
110  if(newElems[newNumNPE*(elem-1) + 8] == 0){
111  newElems[newNumNPE*(elem-1) + 8] = numNodes;
112  }
113  break;
114  case 5:
115  //Add the node if it hasn't already been added
116  if(newElems[newNumNPE*(elem-1) + 9] == 0){
117  newElems[newNumNPE*(elem-1) + 9] = numNodes;
118  }
119  break;
120  }//switch over k
121  }//if we found the edge
122  }//loop over edges for the element
123  }//loop over elements for the edge
124  }//loop over every edge
125 
126  std::cout << "line " << __LINE__ << std::endl;
127 
128  //print to check
129  if(verblevel > 3){
130  Ostr << "new elements: " << std::endl;
131  for(int i=0; i < numElems; i++){
132  Ostr << i+1 << ":" << std::endl;
133  for(int j=0; j < newNumNPE; j++){
134  Ostr << newElems[i*newNumNPE + j] << " ";
135  }
136  Ostr << std::endl;
137  }
138  }
139  StdOut(Ostr.str());
140  Ostr.str("");
141 
142  std::cout << "line " << __LINE__ << std::endl;
143  //save the new elements arrray to the old one
144  elems.resize(numElems*newNumNPE);
145  elems = newElems;
146  numNodesPerElem = newNumNPE;
147 
148  StdOut(Ostr.str());
149  Ostr.str("");
150 
151  std::cout << "line " << __LINE__ << std::endl;
152  FunctionExit("HigherOrderTets");
153 
154  std::cout << "line " << __LINE__ << std::endl;
155  return 0;
156 
157  } //HigherOrderTets function
j indices k indices k
Definition: Indexing.h:6
void int int REAL REAL * y
Definition: read.cpp:74
std::vector< std::vector< unsigned int > > domains
vector of vectors to hold the domains
int numElemEdges
number of element edges in mesh
std::vector< unsigned int > elemToElemEdges
map of elements to element edges
std::vector< unsigned int > elems
vector for holding element connectivies read from input
int numElems
number of elements in mesh
int numNodesPerElemEdge
number of nodes per element edge
void int int int REAL REAL REAL * z
Definition: write.cpp:76
SolverUtils::Mesh::Connectivity nodesToDomains
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
int numNodesPerElem
number of nodes per element
j indices j
Definition: Indexing.h:6
std::vector< unsigned int > elemEdges
vector for holding element edges
std::vector< double > nodes
vector for holding nodal coordinates read from input

Here is the caller graph for this function:

virtual int Initialize ( )
inlinevirtual

Initializes native data structures from commandline args.

Definition at line 267 of file DriverProgram.H.

References SerialProgram::bc_input_name, SerialProgram::elemShape, SerialProgram::input_name, SerialProgram::numDomains, SerialProgram::numElems, SerialProgram::numNodes, SerialProgram::numNodesPerElem, SerialProgram::output_name, SerialProgram::quadratic, SerialProgram::shapes, and SerialProgram::verblevel.

Referenced by GridConversion::ExampleProgram::Driver(), and GridConversion::DriverProgram::Driver().

268  {
269  int retval = SerialProgramType::Initialize();
270  if(!_command_line.GetOption("help").empty()){
271  std::ostringstream Ostr;
272  Ostr << _command_line.LongUsage() << std::endl;
273  StdOut(Ostr.str());
274  return(-1);
275  }
276  if(retval){
277  std::ostringstream Ostr;
278  Ostr << _command_line.ErrorReport() << std::endl
279  << std::endl << _command_line.ShortUsage() << std::endl;
280  ErrOut(Ostr.str());
281  return(retval);
282  }
283 
284  //Initialize mesh values to 0
285  numNodes = 0;
286  numElems = 0;
287  numDomains = 0;
288  numNodesPerElem = 0;
289  elemShape = 0;
290 
291  //Set element shape vector (shape numbers are those used in Patran grid files)
292  shapes.resize(10);
293  shapes[0] = shapes[1] = shapes[6] = "none";
294  shapes[2]= "bar";
295  shapes[3] = "triangle";
296  shapes[4] = "quadrilateral";
297  shapes[5] = "tetrahedron";
298  shapes[7] = "triangular prism";
299  shapes[8] = "hexahedron";
300  shapes[9] = "pyramid";
301 
302  // Check if we should create higher order elements
303  quadratic = false;
304  if(!_command_line.GetOption("quadratic").empty())
305  quadratic = true;
306 
307  // Check if output file is specified
308  output_name = _command_line.GetOption("output");
309 
310  // Set input file to first argument
311  std::vector<std::string> args(_command_line.GetArgs());
312  input_name = args[0];
313  bc_input_name = args[1];
314 
315  // Check the verbosity level
316  std::string sverb(_command_line.GetOption("verbosity"));
317  if(sverb.empty() || sverb == ".true.")
318  verblevel = 1;
319  else {
320  std::istringstream Vin(sverb);
321  Vin >> verblevel;
322  if(verblevel < 0)
323  verblevel = 1;
324  }
325 
326  // If high verbosity, stick a configuration blurb to stdout.
327  if(verblevel > 1){
328  std::ostringstream Ostr;
329  Ostr << "Configuration:" << std::endl
330  << "verbosity = " << verblevel << std::endl
331  << "input_name = " << input_name << std::endl
332  << "bc_input_name = " << bc_input_name << std::endl;
333  if(!output_name.empty())
334  Ostr << "output file = " << output_name << std::endl;
335  Ostr << std::endl;
336  StdOut(Ostr.str());
337  }
338 
339  return(0);
340  };
int numDomains
number of domains in mesh
int numElems
number of elements in mesh
std::string output_name
Name of file for output.
std::vector< std::string > shapes
vector to hold the element shapes (only used for Patran input format)
int numNodesPerElem
number of nodes per element
int elemShape
integer to denote the shape of elements used in the mesh
std::string bc_input_name
Name of bc input file.
std::string input_name
Name of input file.
bool quadratic
boolean for changing the elements to higher order

Here is the caller graph for this function:

int ReadPatranInput ( )
virtual

This function parses a Patran format input file.

Definition at line 5 of file ReadPatranInput.C.

References SerialProgram::bc_input_name, SerialProgram::domainBCs, SerialProgram::domainBCValues, SerialProgram::domains, SerialProgram::edgeBCs, SerialProgram::edgeBCValues, SerialProgram::edges, SerialProgram::elems, SerialProgram::elemShape, i, SerialProgram::Inf, SerialProgram::input_name, j, lines(), SerialProgram::nodes, SerialProgram::numElems, SerialProgram::numNodes, SerialProgram::numNodesPerElem, SerialProgram::shapes, and SerialProgram::verblevel.

5  {
6 
7  std::ostringstream Ostr;
8 
9  FunctionEntry("ReadPatranInput");
10  // Open the specified input file for reading
11  Inf.open(input_name.c_str());
12  if(!Inf){
13  // If the input file failed to open, notify to
14  // the error stream and return non-zero
15  std::ostringstream ErrOstr;
16  ErrOstr << "Could not open input file, '"
17  << input_name << "'.\n";
18  StdOut(Ostr.str());
19  Ostr.str("");
20  ErrOut(ErrOstr.str());
21  ErrOstr.str("");
22  // don't forget to tell the profiler/stacker the
23  // function is exiting.
24  FunctionExit("ReadPatranInput");
25  return(1);
26  }
27 
28  std::string line;
29  double valueD;
30  unsigned int valueI;
31  std::string valueS;
32  std::stringstream ss;
33 
34  //Read Input file in Como (Patran) format from Gridgen
35  std::getline(Inf,line);
36  std::getline(Inf,line);
37  std::getline(Inf,line);
38  ss << line;
39  ss >> valueD >> valueD >> valueD >> valueD >> numNodes >> numElems;
40  std::getline(Inf,line);
41 
42  //Resize nodes vector
43  nodes.resize(3*numNodes);
44 
45  //Print for check
46  if(verblevel > 1){
47  Ostr << "Number of nodes = " << numNodes << std::endl;
48  Ostr << "Number of elements = " << numElems << std::endl;
49  }
50 
51  for(int i=0; i < numNodes; i++){
52  std::getline(Inf,line);
53  std::getline(Inf,line);
54  ss.clear();
55  ss.str("");
56  ss << line;
57  ss >> nodes[3*i + 0] >> nodes[3*i + 1] >> nodes[3*i + 2];
58  std::getline(Inf,line);
59  }
60 
61  for(int i=0; i < numElems; i++){
62  std::getline(Inf,line);
63  ss.clear();
64  ss.str("");
65  ss << line;
66  ss >> valueI >> valueI >> valueI;
67 
68  //Check that valueI is a valid element shape
69  if(valueI <= 1 || valueI == 6 || valueI > 9){
70  std::ostringstream ErrOstr;
71  ErrOstr << "element shape value of " << valueI << " is invalid." << std::endl
72  << "Valid shape values:" << std::endl
73  << " 2: bar" << std::endl
74  << " 3: triangle" << std::endl
75  << " 4: quadrilateral" << std::endl
76  << " 5: tetrahedron" << std::endl
77  << " 7: triangular prism" << std::endl
78  << " 8: hexahedron" << std::endl
79  << " 9: pyramid" << std::endl;
80  StdOut(Ostr.str());
81  Ostr.str("");
82  ErrOut(ErrOstr.str());
83  ErrOstr.str("");
84  exit(1);
85  }
86 
87  //Make sure the elements all have the same shape
88  //For now we only support meshes with one shape of element
89  //(this is what Rocfrac requires as well).
90  if(i == 0){
91  elemShape = valueI;
92  //Print for check
93  if(verblevel > 1)
94  Ostr << "Element shape value " << elemShape << ": " << shapes[elemShape] << std::endl;
95  }
96  else{
97  if(valueI != elemShape){
98  std::ostringstream ErrOstr;
99  ErrOstr << "Meshes must have only one element shape!" << std::endl
100  << "Element " << i << " has shape value " << valueI << " but "
101  << "previous elements have shape value " << elemShape << std::endl;
102  StdOut(Ostr.str());
103  Ostr.str("");
104  ErrOut(ErrOstr.str());
105  ErrOstr.str("");
106  exit(1);
107  }
108  }
109 
110  std::getline(Inf,line);
111  ss.clear();
112  ss.str("");
113  ss << line;
114  ss >> valueI;
115 
116  //Check that valueI is a valid number of nodes per element
117  if(valueI < 2 || valueI == 7 || valueI == 9 || valueI > 10){
118  std::ostringstream ErrOstr;
119  ErrOstr << "Error: " << valueI << " number of nodes per element is invalid." << std::endl
120  << "Valid number of nodes:" << std::endl
121  << " 2: bar" << std::endl
122  << " 3: triangle" << std::endl
123  << " 4: quadrilateral or tetrahedron" << std::endl
124  << " 5: pyramid" << std::endl
125  << " 6: triangular prism" << std::endl
126  << " 8: hexahedron" << std::endl
127  << " 10: tehtrahedron (higher order)" << std::endl;
128  StdOut(Ostr.str());
129  Ostr.str("");
130  ErrOut(ErrOstr.str());
131  ErrOstr.str("");
132  exit(1);
133  }
134 
135  //Make sure the elements are all of the same type (number of nodes)
136  //For now we only support meshes with one type of element
137  //(this is what Rocfrac requires as well).
138  if(i == 0){
139  numNodesPerElem = valueI;
140  //Print for check
141  if(verblevel > 1)
142  Ostr << "Number of nodes per element " << numNodesPerElem << "." << std::endl;
143  }
144  else{
145  if(valueI != numNodesPerElem){
146  std::ostringstream ErrOstr;
147  ErrOstr << "Meshes must have elements with the same number of nodes!" << std::endl
148  << "Element " << i << " has " << valueI << " nodes but "
149  << "previous elements have " << numNodesPerElem << " nodes." << std::endl;
150  StdOut(Ostr.str());
151  Ostr.str("");
152  ErrOut(ErrOstr.str());
153  ErrOstr.str("");
154  exit(1);
155  }
156  }
157 
158  //Resize the elems array
159  elems.resize(numElems*numNodesPerElem);
160 
161  //Read in the nodes for the element
162  std::getline(Inf,line);
163  ss.clear();
164  ss.str("");
165  ss << line;
166  for(int j=0; j < numNodesPerElem; j++){
167  ss >> elems[i*numNodesPerElem + j];
168  }
169  }
170 
171  // Read the boundary domain info
172  while(getline(Inf,line)){
173  int packet, lines=0, domainNodes;
174  std::vector<unsigned int> oneDomain;
175 
176  ss.clear();
177  ss.str("");
178  ss << line;
179  ss >> packet >> valueI >> domainNodes >> lines;
180  if(packet == 99)//Patran exit criterion
181  break;
182 
183  // Read the nodes that are on the domain
184  std::getline(Inf,line);
185  for(int i=0; i < lines-1; i++){
186  std::getline(Inf,line);
187  ss.clear();
188  ss.str("");
189  ss << line;
190  int j=0;
191  while(ss >> valueI){
192  if(j%2 == 1)
193  oneDomain.push_back(valueI);
194  j++;
195  }
196  }
197  domains.push_back(oneDomain);
198  }
199 
200  //Close input file
201  Inf.close();
202 
203  // Open the bc input file for reading
204  Inf.open(bc_input_name.c_str());
205  if(!Inf){
206  // If the input file failed to open, notify to
207  // the error stream and return non-zero
208  std::ostringstream ErrOstr;
209  ErrOstr << "Could not open input file, '"
210  << bc_input_name << "'.\n";
211  StdOut(Ostr.str());
212  Ostr.str("");
213  ErrOut(ErrOstr.str());
214  ErrOstr.str("");
215  // don't forget to tell the profiler/stacker the
216  // function is exiting.
217  FunctionExit("ReadPatranInput");
218  return(1);
219  }
220 
221  domainBCs.resize(domains.size());
222  domainBCValues.resize(domains.size());
223  while(std::getline(Inf,line)){
224  int numFlags=0, domainNum;
225  std::string edgeOrDomain;
226  bool domain = true;
227  ss.clear();
228  ss.str("");
229  ss << line;
230  ss >> edgeOrDomain >> domainNum;
231  domainNum--;
232  std::cout << "edgeOrDomain = " << edgeOrDomain << std::endl;
233  //bcs for an edge
234  if(edgeOrDomain == "edge" || edgeOrDomain == "Edge"
235  || edgeOrDomain == "EDGE"){
236  domain = false;
237  ss >> valueI;
238  edges[domainNum].push_back(valueI);
239  ss >> valueI;
240  edges[domainNum].push_back(valueI);
241  }
242  //tell the total number of edges with a bc
243  else if(edgeOrDomain == "edges" || edgeOrDomain == "Edges"
244  || edgeOrDomain == "EDGES"){
245  edges.resize(domainNum+1);
246  edgeBCs.resize(domainNum+1);
247  edgeBCValues.resize(domainNum+1);
248  continue;
249  }
250  //bcs for a domain
251  else if(edgeOrDomain != "domain" && edgeOrDomain != "Domain"
252  && edgeOrDomain != "DOMAIN"){
253  std::ostringstream ErrOstr;
254  ErrOstr << "First word of every line in bc file must be 'domain,'"
255  << std::endl << "'edge', or 'edges.'" << std::endl;
256  StdOut(Ostr.str());
257  Ostr.str("");
258  ErrOut(ErrOstr.str());
259  ErrOstr.str("");
260  // don't forget to tell the profiler/stacker the
261  // function is exiting.
262  FunctionExit("ReadPatranInput");
263  return(1);
264  }
265 
266  std::cout << "edges.size() = " << edges.size() << std::endl;
267  std::cout << "edgeBCs.size() = " << edgeBCs.size() << std::endl;
268  std::cout << "edgeBCValues.size() = " << edgeBCValues.size() << std::endl;
269  std::cout << "domainNum = " << domainNum << std::endl;
270  ss >> numFlags;
271  if(domain)
272  domainBCValues[domainNum].resize(numFlags);
273  else
274  edgeBCValues[domainNum].resize(numFlags);
275 
276  std::cout << "line " << __LINE__ << std::endl;
277 
278  for(int j=0; j < numFlags; j++){
279  ss >> valueI;
280  if(domain)
281  domainBCs[domainNum].push_back(valueI);
282  else
283  edgeBCs[domainNum].push_back(valueI);
284 
285  std::cout << "line " << __LINE__ << std::endl;
286  if(valueI == 8){
287  for(int i=0; i < 6; i++){
288  ss >> valueD;
289  if(domain)
290  domainBCValues[domainNum][j].push_back(valueD);
291  else
292  edgeBCValues[domainNum][j].push_back(valueD);
293  }
294  }
295  else if(valueI == 6){
296  ss >> valueD;
297  if(domain)
298  domainBCValues[domainNum][j].push_back(valueD);
299  else
300  edgeBCValues[domainNum][j].push_back(valueD);
301  }
302  else{
303  // Error for invalid bc type
304  std::ostringstream ErrOstr;
305  ErrOstr << "Invalid boundary condition type of " << valueI
306  << " for boundary " << domainBCs.size() << "." << std::endl;
307  StdOut(Ostr.str());
308  Ostr.str("");
309  ErrOut(ErrOstr.str());
310  ErrOstr.str("");
311  // don't forget to tell the profiler/stacker the
312  // function is exiting.
313  FunctionExit("ReadPatranInput");
314  return(1);
315  }
316  std::cout << "line " << __LINE__ << std::endl;
317  }
318  }
319 
320  std::cout << "line " << __LINE__ << std::endl;
321  //Close the bc input file
322  Inf.close();
323 
324  StdOut(Ostr.str());
325  Ostr.str("");
326  FunctionExit("ReadPatranInput");
327 
328  return 0;
329 
330  } //ReadInput function
std::vector< std::vector< unsigned int > > domains
vector of vectors to hold the domains
std::vector< unsigned int > elems
vector for holding element connectivies read from input
int numElems
number of elements in mesh
std::vector< std::vector< int > > edgeBCs
vector to hold list of edge bc flags
C by Argonne National Laboratory and Mississipi State University!All rights reserved See COPYRIGHT in top level directory!user include file for MPI with no dependencies!It really is not possible to make a perfect include file that can!be used by both F77 and F90 but this is close We have removed!continuation lines(allows free form input in F90)
std::vector< std::string > shapes
vector to hold the element shapes (only used for Patran input format)
blockLoc i
Definition: read.cpp:79
int numNodesPerElem
number of nodes per element
std::vector< std::vector< int > > domainBCs
vector to hold list of domain bc flags
std::ifstream Inf
Infile stream for input.
std::vector< std::vector< int > > edges
vector of vectors to hold the edges
std::vector< std::vector< std::vector< double > > > domainBCValues
vector to hold list of domain bc values (these are different for each bc type - see the Rocfrac docum...
std::vector< std::vector< std::vector< double > > > edgeBCValues
vector to hold list of edge bc values (these are different for each bc type - see the Rocfrac documen...
j indices j
Definition: Indexing.h:6
int elemShape
integer to denote the shape of elements used in the mesh
std::string bc_input_name
Name of bc input file.
std::string input_name
Name of input file.
std::vector< double > nodes
vector for holding nodal coordinates read from input

Here is the call graph for this function:

int ReadStanfordInput ( )
virtual

This function parses a Stanford format input file.

Definition at line 5 of file ReadStanfordInput.C.

References SerialProgram::bc_input_name, SerialProgram::domainBCs, SerialProgram::domainBCValues, SerialProgram::domains, SerialProgram::edgeBCs, SerialProgram::edgeBCValues, SerialProgram::edges, SerialProgram::elems, SerialProgram::elemShape, i, SerialProgram::Inf, SerialProgram::input_name, j, k, lines(), SerialProgram::nodes, SerialProgram::numDomains, SerialProgram::numElems, SerialProgram::numNodes, SerialProgram::numNodesPerElem, and SerialProgram::verblevel.

Referenced by SerialProgram::Run().

5  {
6 
7  FunctionEntry("ReadStanfordInput");
8  std::ostringstream Ostr;
9 
10  // Open the specified input file for reading
11  Inf.open(input_name.c_str());
12  if(!Inf){
13  // If the input file failed to open, notify to
14  // the error stream and return non-zero
15  std::ostringstream ErrOstr;
16  ErrOstr << "Could not open input file, '"
17  << input_name << "'.\n";
18  StdOut(Ostr.str());
19  Ostr.str("");
20  ErrOut(ErrOstr.str());
21  ErrOstr.str("");
22  // don't forget to tell the profiler/stacker the
23  // function is exiting.
24  FunctionExit("ReadStanfordInput");
25  return(1);
26  }
27 
28  std::string line;
29  double valueD;
30  unsigned int valueI;
31  std::string valueS;
32  std::stringstream ss;
33 
34  //Read Input file in Stanford format from Poinwise
35  for(int i=0; i < 8; i++)
36  std::getline(Inf,line);
37  ss.clear();
38  ss.str("");
39  ss << line;
40  ss >> valueS >> numElems;
41 
42  //Print for check
43  if(verblevel > 1){
44  Ostr << "Number of nodes = " << numNodes << std::endl;
45  Ostr << "Number of elements = " << numElems << std::endl;
46  }
47  for(int i=0; i < numElems; i++){
48  std::getline(Inf,line);
49  ss.clear();
50  ss.str("");
51  ss << line;
52  ss >> valueI;
53 
54  //Make sure the elements all have the same shape
55  //For now we only support meshes with one shape of element
56  //(this is what Rocfrac requires as well).
57  if(i == 0){
58  elemShape = valueI;
59  //Print for check
60  if(verblevel > 1)
61  Ostr << "Element shape value: " << elemShape << std::endl;
62  if(elemShape == 10)
63  numNodesPerElem = 4;
64  else if(elemShape == 12)
65  numNodesPerElem = 8;
66  else{
67  std::ostringstream ErrOstr;
68  ErrOstr << "For Stanford format input only element shapes " << std::endl
69  << "10 and 12 are supported! Input file has shape "
70  << elemShape << "!" << std::endl;
71  StdOut(Ostr.str());
72  Ostr.str("");
73  ErrOut(ErrOstr.str());
74  ErrOstr.str("");
75  exit(1);
76  }
77  }
78  else{
79  if(valueI != elemShape){
80  std::ostringstream ErrOstr;
81  ErrOstr << "Meshes must have only one element shape!" << std::endl
82  << "Element " << i << " has shape value " << valueI << " but "
83  << "previous elements have shape value " << elemShape << std::endl;
84  StdOut(Ostr.str());
85  Ostr.str("");
86  ErrOut(ErrOstr.str());
87  ErrOstr.str("");
88  exit(1);
89  }
90  }
91 
92  //Read in 8 nodes for shape 12 (hexahedral) or 4 nodes for shape 10 (tetrahedral)
93  for(int j=0; j < numNodesPerElem; j++){
94  ss >> valueI;
95  //We are starting are node count at 1
96  valueI++;
97  elems.push_back(valueI);
98  }
99  }
100 
101  for(int i=0; i < 4; i++)
102  std::getline(Inf,line);
103  ss.clear();
104  ss.str("");
105  ss << line;
106  ss >> valueS >> numNodes;
107 
108  //Resize nodes vector
109  nodes.resize(3*numNodes);
110 
111  //Print for check
112  if(verblevel > 1){
113  Ostr << "Number of nodes = " << numNodes << std::endl;
114  Ostr << "Number of elements = " << numElems << std::endl;
115  }
116 
117  for(int i=0; i < numNodes; i++){
118  std::getline(Inf,line);
119  ss.clear();
120  ss.str("");
121  ss << line;
122  ss >> nodes[3*i + 0] >> nodes[3*i + 1] >> nodes[3*i + 2];
123  }
124 
125 
126  // Read the boundary domain info
127  for(int i=0; i < 4; i++)
128  getline(Inf,line);
129  ss.clear();
130  ss.str("");
131  ss << line;
132 
133  ss >> valueS >> numDomains;
134 
135  // loop over the domains
136  for(int i=0; i < numDomains; i++){
137  int packet, lines=0, domainNodes;
138  std::vector<unsigned int> oneDomain;
139  int numNodesPerFaceElem;
140 
141  getline(Inf,line);
142  getline(Inf,line);
143  ss.clear();
144  ss.str("");
145  ss << line;
146 
147  ss >> valueS >> lines;
148 
149  //loop over number of faces on domain
150  for(int j=0; j < lines; j++){
151  getline(Inf,line);
152  ss.clear();
153  ss.str("");
154  ss << line;
155 
156  ss >> valueI;
157  if(valueI == 9)
158  numNodesPerFaceElem = 4;
159  else if(valueI == 5)
160  numNodesPerFaceElem = 3;
161  else{
162  std::ostringstream ErrOstr;
163  ErrOstr << "Face elements must be of type 9 (quad) or 5 (tri)!" << std::endl
164  << "Face type " << valueI << " was read!" << std::endl;
165  StdOut(Ostr.str());
166  Ostr.str("");
167  ErrOut(ErrOstr.str());
168  ErrOstr.str("");
169  exit(1);
170  }
171 
172  //loop over the number of nodes for the face
173  for(int k=0; k < numNodesPerFaceElem; k++){
174  ss >> valueI;
175  //We are starting our node count at 1
176  valueI++;
177  //check to see if the node has been added to
178  //the domain already
179  bool newValue=true;
180  for(int l=0; l < oneDomain.size(); l++){
181  if(oneDomain[l] == valueI){
182  newValue=false;
183  break;
184  }
185  }
186  //Add the value to the domain if its new
187  if(newValue){
188  oneDomain.push_back(valueI);
189  }
190  }
191  }//faces on domain loop
192  //Add the one domain we read in to the vector of all the domains
193  domains.push_back(oneDomain);
194  }//domain loop
195 
196  //Close input file
197  Inf.close();
198 
199  // Open the bc input file for reading
200  Inf.open(bc_input_name.c_str());
201  if(!Inf){
202  // If the input file failed to open, notify to
203  // the error stream and return non-zero
204  std::ostringstream ErrOstr;
205  ErrOstr << "Could not open input file, '"
206  << bc_input_name << "'.\n";
207  StdOut(Ostr.str());
208  Ostr.str("");
209  ErrOut(ErrOstr.str());
210  ErrOstr.str("");
211  // don't forget to tell the profiler/stacker the
212  // function is exiting.
213  FunctionExit("ReadStanfordInput");
214  return(1);
215  }
216 
217  domainBCs.resize(domains.size());
218  domainBCValues.resize(domains.size());
219  while(std::getline(Inf,line)){
220  int numFlags=0, domainNum;
221  std::string edgeOrDomain;
222  bool domain = true;
223  ss.clear();
224  ss.str("");
225  ss << line;
226  ss >> edgeOrDomain >> domainNum;
227  //std::cout << "edgeOrDomain = " << edgeOrDomain << std::endl;
228  //std::cout << "domainNum = " << domainNum << std::endl;
229  domainNum--;
230  //bcs for an edge
231  if(edgeOrDomain == "edge" || edgeOrDomain == "Edge"
232  || edgeOrDomain == "EDGE"){
233  domain = false;
234  ss >> valueI;
235  edges[domainNum].push_back(valueI);
236  ss >> valueI;
237  edges[domainNum].push_back(valueI);
238  }
239  //tell the total number of edges with a bc
240  else if(edgeOrDomain == "edges" || edgeOrDomain == "Edges"
241  || edgeOrDomain == "EDGES"){
242  edges.resize(domainNum+1);
243  edgeBCs.resize(domainNum+1);
244  edgeBCValues.resize(domainNum+1);
245  continue;
246  }
247  //bcs for a domain
248  else if(edgeOrDomain != "domain" && edgeOrDomain != "Domain"
249  && edgeOrDomain != "DOMAIN"){
250  std::ostringstream ErrOstr;
251  ErrOstr << "First word of every line in bc file must be 'domain,'"
252  << std::endl << "'edge', or 'edges.'" << std::endl;
253  StdOut(Ostr.str());
254  Ostr.str("");
255  ErrOut(ErrOstr.str());
256  ErrOstr.str("");
257  // don't forget to tell the profiler/stacker the
258  // function is exiting.
259  FunctionExit("ReadStanfordInput");
260  return(1);
261  }
262 
263  ss >> numFlags;
264  //std::cout << "numFlags = " << numFlags << std::endl;
265  if(domain)
266  domainBCValues[domainNum].resize(numFlags);
267  else
268  edgeBCValues[domainNum].resize(numFlags);
269 
270  for(int j=0; j < numFlags; j++){
271  ss >> valueI;
272  //std::cout << "domain type = " << valueI << std::endl;
273  if(domain)
274  domainBCs[domainNum].push_back(valueI);
275  else
276  edgeBCs[domainNum].push_back(valueI);
277 
278  //std::cout << "values = " << std::endl;
279  if(valueI == 8){
280  for(int i=0; i < 7; i++){
281  ss >> valueD;
282  //std::cout << valueD << " ";
283  if(domain)
284  domainBCValues[domainNum][j].push_back(valueD);
285  else
286  edgeBCValues[domainNum][j].push_back(valueD);
287  }
288  }
289  else if(valueI == 6){
290  ss >> valueD;
291  //std::cout << valueD << " ";
292  if(domain)
293  domainBCValues[domainNum][j].push_back(valueD);
294  else
295  edgeBCValues[domainNum][j].push_back(valueD);
296  }
297  else{
298  // Error for invalid bc type
299  std::ostringstream ErrOstr;
300  ErrOstr << "Invalid boundary condition type of " << valueI
301  << " for boundary " << domainBCs.size() << "." << std::endl;
302  StdOut(Ostr.str());
303  Ostr.str("");
304  ErrOut(ErrOstr.str());
305  ErrOstr.str("");
306  // don't forget to tell the profiler/stacker the
307  // function is exiting.
308  FunctionExit("ReadStanfordInput");
309  return(1);
310  }
311  //std::cout << std::endl;
312  }
313  }
314 
315  //Close the bc input file
316  Inf.close();
317 
318  StdOut(Ostr.str());
319  Ostr.str("");
320 
321  FunctionExit("ReadStanfordInput");
322  return 0;
323 
324  } //ReadInput function
j indices k indices k
Definition: Indexing.h:6
std::vector< std::vector< unsigned int > > domains
vector of vectors to hold the domains
int numDomains
number of domains in mesh
std::vector< unsigned int > elems
vector for holding element connectivies read from input
int numElems
number of elements in mesh
std::vector< std::vector< int > > edgeBCs
vector to hold list of edge bc flags
C by Argonne National Laboratory and Mississipi State University!All rights reserved See COPYRIGHT in top level directory!user include file for MPI with no dependencies!It really is not possible to make a perfect include file that can!be used by both F77 and F90 but this is close We have removed!continuation lines(allows free form input in F90)
blockLoc i
Definition: read.cpp:79
int numNodesPerElem
number of nodes per element
std::vector< std::vector< int > > domainBCs
vector to hold list of domain bc flags
std::ifstream Inf
Infile stream for input.
std::vector< std::vector< int > > edges
vector of vectors to hold the edges
std::vector< std::vector< std::vector< double > > > domainBCValues
vector to hold list of domain bc values (these are different for each bc type - see the Rocfrac docum...
std::vector< std::vector< std::vector< double > > > edgeBCValues
vector to hold list of edge bc values (these are different for each bc type - see the Rocfrac documen...
j indices j
Definition: Indexing.h:6
int elemShape
integer to denote the shape of elements used in the mesh
std::string bc_input_name
Name of bc input file.
std::string input_name
Name of input file.
std::vector< double > nodes
vector for holding nodal coordinates read from input

Here is the call graph for this function:

Here is the caller graph for this function:

int Run ( )
virtual

This function implements the main function executed by the program.

Definition at line 16 of file DriverProgram.C.

References SerialProgram::ConnectivityMaps(), SerialProgram::domainBCs, SerialProgram::domainBCValues, SerialProgram::domains, SerialProgram::edgeBCs, SerialProgram::edgeBCValues, SerialProgram::edges, SerialProgram::elemBCs, SerialProgram::elemBCValues, SerialProgram::elems, SerialProgram::elemsToDomains, SerialProgram::elemToElemEdges, SerialProgram::HigherOrderTets(), i, j, k, SerialProgram::nodeBCs, SerialProgram::nodeBCValues, SerialProgram::nodes, SerialProgram::nodesToDomains, SerialProgram::numEdgesPerElem, SerialProgram::numElemEdges, SerialProgram::numElems, SerialProgram::numNodes, SerialProgram::numNodesPerElem, SerialProgram::quadratic, SerialProgram::ReadStanfordInput(), SerialProgram::verblevel, and SerialProgram::WriteOutput().

Referenced by GridConversion::ExampleProgram::Driver(), and GridConversion::DriverProgram::Driver().

17  {
18  // FunctionEntry("NAME"): Updates the user-defined stack and
19  // the program profiles with timing information. The placement
20  // of FunctionEntry and FunctionExit calls is at the developer's
21  // discretion.
22  FunctionEntry("Run");
23 
24  // ---------- The Program -----------------
25  // Drives the grid conversion process
26 
27  std::ostringstream Ostr;
28  int error=0;
29 
30  // Parse the input file
31  error = ReadStanfordInput();
32  if(error == 1){
33  std::ostringstream ErrOstr;
34  ErrOstr << "Error reading input file." << std::endl;
35  StdOut(Ostr.str());
36  Ostr.str("");
37  ErrOut(ErrOstr.str());
38  ErrOstr.str("");
39  exit(1);
40  }
41 
42  //Print to check nodes
43  if(verblevel > 3){
44  Ostr << "nodes: " << std::endl;
45  for(int i=0; i < numNodes; i++){
46  Ostr << i+1 << ":" << std::endl;
47  for(int j=0; j < 3; j++){
48  Ostr << nodes[i*3 + j] << " ";
49  }
50  Ostr << std::endl;
51  }
52  }
53  StdOut(Ostr.str());
54  Ostr.str("");
55 
56  //Print to check elems
57  if(verblevel > 3){
58  Ostr << "elements: " << std::endl;
59  for(int i=0; i < numElems; i++){
60  Ostr << i+1 << ":" << std::endl;
61  for(int j=0; j < numNodesPerElem; j++){
62  Ostr << elems[i*numNodesPerElem + j] << " ";
63  }
64  Ostr << std::endl;
65  }
66  }
67  StdOut(Ostr.str());
68  Ostr.str("");
69 
70  //Print to check domains
71  if(verblevel > 3){
72  Ostr << "domains: " << std::endl;
73  for(int i=0; i < domains.size(); i++){
74  Ostr << i+1 << ":" << std::endl;
75  for(int j=0; j < domains[i].size(); j++){
76  Ostr << domains[i][j] << " ";
77  }
78  Ostr << std::endl;
79  }
80  }
81 
82  StdOut(Ostr.str());
83  Ostr.str("");
84  std::cout << "line " << __LINE__ << std::endl;
85 
86  // Populate element connectivty with elems vector
87  SolverUtils::Mesh::Connectivity utilsElems;
88  utilsElems.AddElements(numElems, numNodesPerElem, elems);
89  std::cout << "line " << __LINE__ << std::endl;
90 
91  // Get a map of nodes to elements
92  SolverUtils::Mesh::Connectivity nodesToElems;
93  utilsElems.Sync();
94  utilsElems.Inverse(nodesToElems,numNodes);
95  std::cout << "line " << __LINE__ << std::endl;
96 
97  // Populate domain connectivity with domain vectors
98  SolverUtils::Mesh::Connectivity utilsDomains;
99  for(int i=0; i < domains.size(); i++){
100  utilsDomains.AddElement(domains[i]);
101  }
102  std::cout << "line " << __LINE__ << std::endl;
103 
104 
105  StdOut(Ostr.str());
106  Ostr.str("");
107  std::cout << "line " << __LINE__ << std::endl;
108 
109  //Print to check domain connectivity
110  if(verblevel > 3){
111  Ostr << "Domain connectivity: " << std::endl;
112  for(int i=0; i < utilsDomains.size(); i++){
113  Ostr << i << ":" << std::endl;
114  for(int j=0; j < utilsDomains[i].size(); j++){
115  Ostr << utilsDomains[i][j] << " ";
116  }
117  Ostr << std::endl;
118  }
119  }
120  StdOut(Ostr.str());
121  Ostr.str("");
122 
123  // Get a map of nodes to domains
124  utilsDomains.Sync();
125  utilsDomains.Inverse(nodesToDomains,numNodes);
126 
127  // Print to check the nodes to elements
128  if(verblevel > 3){
129  Ostr << "Nodes to elements: " << std::endl;
130  for(int i=0; i < nodesToElems.size(); i++){
131  Ostr << i+1 << ": ";
132  for(int j=0; j < nodesToElems[i].size(); j++){
133  Ostr << nodesToElems[i][j] << " ";
134  }
135  Ostr << std::endl;
136  }
137  }
138 
139  // Print to check the nodes to domains
140  if(verblevel > 3){
141  Ostr << "Nodes to domains: " << std::endl;
142  for(int i=0; i < nodesToDomains.size(); i++){
143  Ostr << i+1 << ": ";
144  for(int j=0; j < nodesToDomains[i].size(); j++){
145  Ostr << nodesToDomains[i][j] << " ";
146  }
147  Ostr << std::endl;
148  }
149  }
150  StdOut(Ostr.str());
151  Ostr.str("");
152 
153  //If we have tet elements and the user specifies higher
154  //order then we need to make the tets quadratic
155  //NOTE: This functionality is not complete!!!!!!!!!!!
156  if(quadratic){
157  if(numNodesPerElem != 4){
158  std::ostringstream ErrOstr;
159  ErrOstr << "Only 4 node tetrahedra can be made into" << std::endl
160  << "quadratic elements!" << std::endl;
161  StdOut(Ostr.str());
162  Ostr.str("");
163  ErrOut(ErrOstr.str());
164  ErrOstr.str("");
165  exit(1);
166  }
167 
168  //Create node to node map
169  ConnectivityMaps(nodesToElems);
170 
171  // Populate element to element edge for Solver Utils
172  SolverUtils::Mesh::Connectivity utilsElemToElemEdges;
173  utilsElemToElemEdges.AddElements(numElems, numEdgesPerElem, elemToElemEdges);
174  std::cout << "line " << __LINE__ << std::endl;
175 
176  // Get a map of nodes to elements
177  SolverUtils::Mesh::Connectivity elemEdgeToElems;
178  utilsElemToElemEdges.Sync();
179  utilsElemToElemEdges.Inverse(elemEdgeToElems,numElemEdges);
180 
181  //Print to check elemEdgesToElems
182  if(verblevel > 3){
183  Ostr << "Element edges to elements: " << std::endl;
184  for(int i=0; i < elemEdgeToElems.size(); i++){
185  Ostr << i+1 << ":" << std::endl;
186  for(int j=0; j < elemEdgeToElems[i].size(); j++){
187  Ostr << elemEdgeToElems[i][j] << " ";
188  }
189  Ostr << std::endl;
190  }
191  std::cout << "line " << __LINE__ << std::endl;
192  }
193 
194  //Create higher order tets
195  HigherOrderTets(elemEdgeToElems,nodesToDomains);
196 
197  //Print to check nodes
198  if(verblevel > 3){
199  Ostr << "(after higher order) nodes: " << std::endl;
200  for(int i=0; i < numNodes; i++){
201  Ostr << i+1 << ":" << std::endl;
202  for(int j=0; j < 3; j++){
203  Ostr << nodes[i*3 + j] << " ";
204  }
205  Ostr << std::endl;
206  }
207  }
208  StdOut(Ostr.str());
209  Ostr.str("");
210 
211  //Print to check elems
212  if(verblevel > 3){
213  Ostr << "(after higher order) elements: " << std::endl;
214  for(int i=0; i < numElems; i++){
215  Ostr << i+1 << ":" << std::endl;
216  for(int j=0; j < numNodesPerElem; j++){
217  Ostr << elems[i*numNodesPerElem + j] << " ";
218  }
219  Ostr << std::endl;
220  }
221  std::cout << "line " << __LINE__ << std::endl;
222  }
223  StdOut(Ostr.str());
224  Ostr.str("");
225  std::cout << "line " << __LINE__ << std::endl;
226 
227  //Print to check domains
228  if(verblevel > 3){
229  Ostr << "(after higher order) domains: " << std::endl;
230  for(int i=0; i < domains.size(); i++){
231  Ostr << i+1 << ":" << std::endl;
232  for(int j=0; j < domains[i].size(); j++){
233  Ostr << domains[i][j] << " ";
234  }
235  Ostr << std::endl;
236  }
237  }
238 
239  // Populate element connectivty with elems vector
240  SolverUtils::Mesh::Connectivity newUtilsElems;
241  newUtilsElems.AddElements(numElems, numNodesPerElem, elems);
242  std::cout << "line " << __LINE__ << std::endl;
243 
244  // Get a map of nodes to elements
245  nodesToElems.clear();
246  newUtilsElems.Sync();
247  newUtilsElems.Inverse(nodesToElems,numNodes);
248  std::cout << "line " << __LINE__ << std::endl;
249 
250  // Populate domain connectivity with domain vectors
251  SolverUtils::Mesh::Connectivity newUtilsDomains;
252  for(int i=0; i < domains.size(); i++){
253  newUtilsDomains.AddElement(domains[i]);
254  }
255  std::cout << "line " << __LINE__ << std::endl;
256 
257 
258  StdOut(Ostr.str());
259  Ostr.str("");
260  std::cout << "line " << __LINE__ << std::endl;
261 
262  // Get a map of nodes to domains
263  nodesToDomains.clear();
264  newUtilsDomains.Sync();
265  newUtilsDomains.Inverse(nodesToDomains,numNodes);
266 
267  // Print to check the nodes to elements
268  if(verblevel > 3){
269  Ostr << "Nodes to elements: " << std::endl;
270  for(int i=0; i < nodesToElems.size(); i++){
271  Ostr << i+1 << ": ";
272  for(int j=0; j < nodesToElems[i].size(); j++){
273  Ostr << nodesToElems[i][j] << " ";
274  }
275  Ostr << std::endl;
276  }
277  }
278 
279  // Print to check the nodes to domains
280  if(verblevel > 3){
281  Ostr << "Nodes to domains: " << std::endl;
282  for(int i=0; i < nodesToDomains.size(); i++){
283  Ostr << i+1 << ": ";
284  for(int j=0; j < nodesToDomains[i].size(); j++){
285  Ostr << nodesToDomains[i][j] << " ";
286  }
287  Ostr << std::endl;
288  }
289  }
290  StdOut(Ostr.str());
291  Ostr.str("");
292 
293 
294  }//creating higher order tets
295 
296  //Populate elems to domains vector using nodes to domains
297  //loop over all the elements
298  elemsToDomains.resize(numElems);
299 
300 
301  for(int i=0; i < numElems; i++){
302  std::map<int, int>domCount;
303  std::cout << "elem " << i+1 << std::endl;
304  //loop over the nodes for the element
305  for(int j=0; j < numNodesPerElem; j++){
306  int node = elems[numNodesPerElem*i + j];
307  std::cout << "node " << j+1 << " (" << node << ")" << std::endl;
308  node--;
309  //loop over the domains for that node
310  for(int k=0; k < nodesToDomains[node].size(); k++){
311  std::cout << "domain " << k+1 << " ("
312  << nodesToDomains[node][k] << ")" << std::endl;
313  int domain = nodesToDomains[node][k];
314  //We only want to add the domain if 3 or more of the element's
315  //nodes reside on it (i.e., an entire face of the element)
316  if( domCount.find(domain) == domCount.end() )
317  domCount[domain] = 1;
318  else
319  domCount[domain]++;
320 
321  std::cout << "domCount = " << domCount[domain] << std::endl;
322 
323  bool newValue=true;
324  //See if the domain has been added yet
325  for(int l=0; l < elemsToDomains[i].size(); l++){
326  if(elemsToDomains[i][l] == nodesToDomains[node][k]){
327  newValue=false;
328  break;
329  }
330  }//loop over domains for elem
331  //add the domain to the elem
332  if(newValue && domCount[domain] > 2){
333  std::cout << "Adding domain" << std::endl;
334  elemsToDomains[i].push_back(nodesToDomains[node][k]);
335  }
336  }//loop over domains for node
337  }// loop over nodes for elem
338  }//loop over elements
339 
340  // Print to check elems to domains
341  if(verblevel > 3){
342  Ostr << "Elems to domains: " << std::endl;
343  for(int i=0; i < elemsToDomains.size(); i++){
344  Ostr << i+1 << ": ";
345  for(int j=0; j < elemsToDomains[i].size(); j++){
346  Ostr << elemsToDomains[i][j] << " ";
347  }
348  Ostr << std::endl;
349  }
350  }
351 
352  // Print the domain bcs to check
353  if(verblevel > 3){
354  Ostr << "domain bcs: " << std::endl;
355  for(int i=0; i < domainBCs.size(); i++){
356  Ostr << i+1 << ": ";
357  for(int j=0; j < domainBCs[i].size(); j++){
358  Ostr << domainBCs[i][j] << " ";
359  }
360  Ostr << std::endl;
361  }
362  }
363 
364  // Print the domain bc values to check
365  if(verblevel > 3){
366  Ostr << "domain bc values: " << std::endl;
367  for(int i=0; i < domainBCValues.size(); i++){
368  Ostr << i+1 << ": " << std::endl;
369  for(int j=0; j < domainBCValues[i].size(); j++){
370  for(int k=0; k < domainBCValues[i][j].size(); k++){
371  Ostr << " " << domainBCValues[i][j][k] << " ";
372  }
373  Ostr << std::endl;
374  }
375  }
376  }
377 
378 
379  // Print the edges to check
380  if(verblevel > 3){
381  Ostr << "edges: " << std::endl;
382  for(int i=0; i < edges.size(); i++){
383  Ostr << i+1 << ": ";
384  for(int j=0; j < edges[i].size(); j++){
385  Ostr << edges[i][j] << " ";
386  }
387  Ostr << std::endl;
388  }
389  }
390 
391  // Print the edge bcs to check
392  if(verblevel > 3){
393  Ostr << "edge bcs: " << std::endl;
394  for(int i=0; i < edgeBCs.size(); i++){
395  Ostr << i+1 << ": ";
396  for(int j=0; j < edgeBCs[i].size(); j++){
397  Ostr << edgeBCs[i][j] << " ";
398  }
399  Ostr << std::endl;
400  }
401  }
402 
403  // Print the edge bc values to check
404  if(verblevel > 3){
405  Ostr << "edge bc values: " << std::endl;
406  for(int i=0; i < edgeBCValues.size(); i++){
407  Ostr << i+1 << ": " << std::endl;
408  for(int j=0; j < edgeBCValues[i].size(); j++){
409  for(int k=0; k < edgeBCValues[i][j].size(); k++){
410  Ostr << " " << edgeBCValues[i][j][k] << " ";
411  }
412  Ostr << std::endl;
413  }
414  }
415  }
416  StdOut(Ostr.str());
417  Ostr.str("");
418 
419  std::cout << "line " << __LINE__ << std::endl;
420  // Populate the nodal bc vectors from the domain bc vectors
421  nodeBCs.resize(numNodes);
422  nodeBCValues.resize(numNodes);
423  //loop over all domains
424  for(int i=0; i < domains.size(); i++){
425  // loop over all nodes in the domain
426  for(int j=0; j < domains[i].size(); j++){
427  int node;
428  node = domains[i][j]-1;
429  // they are on
430  // loop over all the bc flags for this domain
431  for(int k=0; k < domainBCs[i].size(); k++){
432  bool newValue = true;
433  int type8BC=-1;
434  // loop over all the bc flags for this node
435  for(int l=0; l < nodeBCs[node].size(); l++){
436  // if the node already has this bc & value skip it
437  if(nodeBCs[node][l] == domainBCs[i][k]){
438  type8BC=l;
439  for(int m=0; m < domainBCValues[i][k].size(); m++){
440  if(domainBCValues[i][k][m] != nodeBCValues[node][l][m])
441  break;
442  else if(m == domainBCValues[i][k].size()-1)
443  newValue = false;
444  }
445  }
446  }// node bc flags
447  // if it is a new flag add it and its values to
448  // the node's vectors
449  if(newValue){
450  //nodes can have as many type 6 bcs as needed
451  if(domainBCs[i][k] == 6){
452  nodeBCs[node].push_back(domainBCs[i][k]);
453  nodeBCValues[node].push_back(domainBCValues[i][k]);
454  }
455  //nodes can only have one type 8 bc which is determined
456  //by a "priority" number that is the last bc value number
457  if(domainBCs[i][k] == 8){
458  //the node doesn't have any type 8 bcs yet
459  int last = domainBCValues[i][k].size()-1;
460  if(type8BC == -1){
461  nodeBCs[node].push_back(domainBCs[i][k]);
462  nodeBCValues[node].push_back(domainBCValues[i][k]);
463  }
464  //it does have a type 8 bc already & we should keep the one
465  //with the highest priority (here a higher priority means a
466  //lower number in the last value position)
467  else if(nodeBCValues[node][type8BC][last] > domainBCValues[i][k][last]){
468  for(int l=0; l < nodeBCValues[node][type8BC].size(); l++)
469  nodeBCValues[node][type8BC][l] = domainBCValues[i][k][l];
470  }
471  }//new type 8 bc
472  }//it was a new bc flag for the node
473  }//domain bc flag loop
474  }// loop over nodes in domain
475  } //loop over all domains
476 
477  std::cout << "line " << __LINE__ << std::endl;
478  // Populate the nodal bc vectors from the edge bc vectors
479  //loop over all edges
480  for(int i=0; i < edges.size(); i++){
481  //loop over all nodes
482  for(int j=0; j < nodesToDomains.size(); j++){
483  int onEdge=0;
484  int node=j;
485 
486  //check to see if the node is on the domains of the edge
487  for(int k=0; k < nodesToDomains[node].size(); k++){
488  if(nodesToDomains[node][k] == edges[i][0]
489  || nodesToDomains[node][k] == edges[i][1])
490  onEdge++;
491  }
492 
493  // If the node is on the edge add the edge bcs to the node's bcs
494  if(onEdge == 2){
495  bool newValue = true;
496  //loop over all the bc flags for this edge
497  for(int k=0; k < edgeBCs[i].size(); k++){
498  int type8BC=-1;
499  // loop over all the bc flags for this node
500  for(int l=0; l < nodeBCs[node].size(); l++){
501  // if the node already has this bc & value skip it
502  if(nodeBCs[node][l] == edgeBCs[i][k]){
503  type8BC=l;
504  for(int m=0; m < edgeBCValues[i][k].size(); m++){
505  if(edgeBCValues[i][k][m] != nodeBCValues[node][l][m])
506  break;
507  else if(m == edgeBCValues[i][k].size()-1)
508  newValue = false;
509  }
510  }
511  }// node bc flags
512  // if it is a new flag add it and its values to
513  // the node's vectors
514  if(newValue){
515  //nodes can have as many type 6 bcs as needed
516  if(edgeBCs[i][k] == 6){
517  nodeBCs[node].push_back(edgeBCs[i][k]);
518  nodeBCValues[node].push_back(edgeBCValues[i][k]);
519  }
520  //nodes can only have one type 8 bc which is determined
521  //by a "priority" number that is the last bc value number
522  if(edgeBCs[i][k] == 8){
523  int last = edgeBCValues[i][k].size()-1;
524  //the node doesn't have any type 8 bcs yet
525  if(type8BC == -1){
526  nodeBCs[node].push_back(edgeBCs[i][k]);
527  nodeBCValues[node].push_back(edgeBCValues[i][k]);
528  }
529  //it does have a type 8 bc already & we should keep the one
530  //with the highest priority (here a higher priority means a
531  //lower number in the last value position)
532  else if(nodeBCValues[node][type8BC][last] > edgeBCValues[i][k][last]){
533  for(int l=0; l < nodeBCValues[node][type8BC].size(); l++)
534  nodeBCValues[node][type8BC][l] = edgeBCValues[i][k][l];
535  }
536  }//new type 8 bc
537  }//it was a new bc flag for the node
538  }//loop over the bcs for the edge
539  } //if the node is on the edge
540  } //loop over all the nodes
541  } //loop over all edges
542 
543  std::cout << "line " << __LINE__ << std::endl;
544  // Print the nodal bcs to check
545  if(verblevel > 3){
546  Ostr << "nodal bcs: " << std::endl;
547  for(int i=0; i < numNodes; i++){
548  Ostr << i+1 << ": ";
549  for(int j=0; j < nodeBCs[i].size(); j++){
550  Ostr << nodeBCs[i][j] << " ";
551  }
552  Ostr << std::endl;
553  }
554  }
555 
556  std::cout << "line " << __LINE__ << std::endl;
557  // Print the nodal bc values to check
558  if(verblevel > 3){
559  Ostr << "nodal bc values: " << std::endl;
560  for(int i=0; i < numNodes; i++){
561  Ostr << i+1 << ": " << std::endl;
562  for(int j=0; j < nodeBCValues[i].size(); j++){
563  for(int k=0; k < nodeBCValues[i][j].size(); k++){
564  Ostr << " " << nodeBCValues[i][j][k] << " ";
565  }
566  Ostr << std::endl;
567  }
568  }
569  }
570  StdOut(Ostr.str());
571  Ostr.str("");
572 
573 
574  std::cout << "line " << __LINE__ << std::endl;
575  // Populate the element bc vectors from the nodal bc vectors
576  elemBCs.resize(numElems);
577  elemBCValues.resize(numElems);
578  //loop over all nodes
579  for(int i=0; i < numNodes; i++){
580  std::cout << "node " << i+1 << std::endl;
581  // loop over all elements for the node
582  for(int j=0; j < nodesToElems[i].size(); j++){
583  int elem;
584  elem = nodesToElems[i][j]-1;
585  std::cout << "elem " << elem+1 << std::endl;
586  // elems will get all bc flags for all the nodes
587  // they contain
588  // loop over all the bc flags for this node
589  std::cout << "line " << __LINE__ << std::endl;
590  for(int k=0; k < nodeBCs[i].size(); k++){
591  bool newValue = true;
592  std::cout << "nodeBC " << nodeBCs[i][k] << std::endl;
593  // loop over all the bc flags for this elem
594  for(int l=0; l < elemBCs[elem].size(); l++){
595  std::cout << "elemBC " << elemBCs[elem][l] << std::endl;
596  // if the elem already has this bc & value skip it
597  if(elemBCs[elem][l] == nodeBCs[i][k]){
598  for(int m=0; m < nodeBCValues[i][k].size(); m++){
599  if(nodeBCValues[i][k][m] != elemBCValues[elem][l][m])
600  break;
601  else if(m == nodeBCValues[i][k].size()-1)
602  newValue = false;
603  }
604  }
605  }// elem bc flags
606  // if it is a new flag add it and its values to
607  // the elem's vectors
608  if(newValue){
609  std::cout << "newValue" << std::endl;
610  elemBCs[elem].push_back(nodeBCs[i][k]);
611  elemBCValues[elem].push_back(nodeBCValues[i][k]);
612  }//it was a new bc flag for the elem
613  }//node bc flag loop
614  std::cout << "line " << __LINE__ << std::endl;
615  }// loop over elements for the node
616  } //loop over all nodes
617 
618 
619  std::cout << "line " << __LINE__ << std::endl;
620  // Print the element bcs for a check
621  if(verblevel > 3){
622  Ostr << "elemBCs:" << std::endl;
623  for(int i=0; i < numElems; i++){
624  Ostr << i+1 << ": ";
625  for(int j=0; j < elemBCs[i].size(); j++){
626  Ostr << elemBCs[i][j] << " ";
627  }
628  Ostr << std::endl;
629  }
630  }
631  StdOut(Ostr.str());
632  Ostr.str("");
633  std::cout << "line " << __LINE__ << std::endl;
634 
635  // Print the element bc values for a check
636  if(verblevel > 3){
637  Ostr << "elem BC values:" << std::endl;
638  for(int i=0; i < numElems; i++){
639  Ostr << i+1 << ": " << std::endl;
640  for(int j=0; j < elemBCValues[i].size(); j++){
641  for(int k=0; k < elemBCValues[i][j].size(); k++){
642  Ostr << " " << elemBCValues[i][j][k] << " ";
643  }
644  Ostr << std::endl;
645  }
646  }
647  }
648  StdOut(Ostr.str());
649  Ostr.str("");
650 
651  std::cout << "line " << __LINE__ << std::endl;
652  //Write the output file
653  error = WriteOutput();
654  std::cout << "line " << __LINE__ << std::endl;
655  if(error == 1){
656  std::ostringstream ErrOstr;
657  ErrOstr << "Error writing output file." << std::endl;
658  StdOut(Ostr.str());
659  Ostr.str("");
660  ErrOut(ErrOstr.str());
661  ErrOstr.str("");
662  exit(1);
663  }
664  StdOut(Ostr.str());
665  Ostr.str("");
666  //
667  // ---------- Program End -----------------
668 
669 
670  // Update the stacker/profiler that we are exiting
671  // this function.
672  FunctionExit("Run");
673  std::cout << "line " << __LINE__ << std::endl;
674  // return 0 for success
675  return(0);
676  };
virtual int WriteOutput()
This function writes the output grid file.
Definition: WriteOutput.C:6
virtual int HigherOrderTets(SolverUtils::Mesh::Connectivity elemEdgeToElems, SolverUtils::Mesh::Connectivity nodesToDomains)
This function creates higher order tets from linear tets.
Definition: HigherOrder.C:6
j indices k indices k
Definition: Indexing.h:6
std::vector< std::vector< unsigned int > > domains
vector of vectors to hold the domains
std::vector< std::vector< int > > elemBCs
vector to hold list of element bc values
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
std::vector< unsigned int > elems
vector for holding element connectivies read from input
Definition: adj.h:150
int numElems
number of elements in mesh
std::vector< std::vector< int > > edgeBCs
vector to hold list of edge bc flags
std::vector< std::vector< int > > elemsToDomains
vector to hold the domains for each element
std::vector< std::vector< int > > nodeBCs
SolverUtils::Mesh::Connectivity nodesToDomains
blockLoc i
Definition: read.cpp:79
int numNodesPerElem
number of nodes per element
std::vector< std::vector< int > > domainBCs
vector to hold list of domain bc flags
virtual int ReadStanfordInput()
This function parses a Stanford format input file.
std::vector< std::vector< int > > edges
vector of vectors to hold the edges
std::vector< std::vector< std::vector< double > > > domainBCValues
vector to hold list of domain bc values (these are different for each bc type - see the Rocfrac docum...
std::vector< std::vector< std::vector< double > > > edgeBCValues
vector to hold list of edge bc values (these are different for each bc type - see the Rocfrac documen...
j indices j
Definition: Indexing.h:6
std::vector< double > nodes
vector for holding nodal coordinates read from input
std::vector< std::vector< std::vector< double > > > elemBCValues
vector to hold list of element bc values (these are different for each bc type - see the Rocfrac docu...
std::vector< std::vector< std::vector< double > > > nodeBCValues
vector to hold list of node bc values (these are different for each bc type - see the Rocfrac documen...
bool quadratic
boolean for changing the elements to higher order

Here is the call graph for this function:

Here is the caller graph for this function:

int VerbLevel ( ) const
inline

Returns verbosity level.

Definition at line 344 of file DriverProgram.H.

References SerialProgram::verblevel.

Referenced by GridConversion::ExampleProgram::Driver(), and GridConversion::DriverProgram::Driver().

344 { return verblevel;};

Here is the caller graph for this function:

int WriteOutput ( )
virtual

This function writes the output grid file.

Definition at line 6 of file WriteOutput.C.

References SerialProgram::domainBCs, SerialProgram::domainBCValues, SerialProgram::elems, SerialProgram::elemShape, SerialProgram::elemsToDomains, i, j, k, SerialProgram::nodeBCs, SerialProgram::nodeBCValues, SerialProgram::nodes, SerialProgram::nodesToDomains, SerialProgram::numElems, SerialProgram::numNodes, SerialProgram::numNodesPerElem, SerialProgram::Ouf, and SerialProgram::output_name.

Referenced by SerialProgram::Run().

6  {
7 
8  std::ostringstream Ostr;
9  std::stringstream ss;
10 
11 
12  // Open the specified output file for writing
13  bool use_outfile = false;
14  if(!output_name.empty()){
15  use_outfile = true;
16  Ouf.open(output_name.c_str());
17  if(!Ouf){
18  // If the output file failed to open, notify
19  // to error stream and return non-zero
20  std::ostringstream ErrOstr;
21  ErrOstr << "Error: Unable to open output file, " << output_name << ".";
22  StdOut(Ostr.str());
23  Ostr.str("");
24  ErrOut(ErrOstr.str());
25  ErrOstr.str("");
26  // don't forget to tell the profiler/stacker the
27  // function is exiting.
28  FunctionExit("Run");
29  return(1);
30  }
31  }
32 
33  // Write mesh info to output file or screen
34  ss.clear();
35  ss.str("");
36 
37  //Write Patran packet 25 Intro (unused)
38  ss << "unused line" << std::endl;
39  ss << "unused line" << std::endl;
40  //Write Patran packet 26
41  ss << "26 1 1 1 " << numNodes << " " << numElems << " 1 1 1" << std::endl;
42  ss << "unused line" << std::endl;
43 
44  unsigned int ePos, expPos;
45  std::stringstream numSS;
46  std::string output, exponent;
47  //Write Patran packet 1 node coordinates
48  for(int i=0; i < numNodes; i++){
49  ss << "1 " << i+1 << std::endl;
50 
51  if(fabs(nodes[3*i+0]) > 1.0e-10 || nodes[3*i+0] == 0.0){
52  numSS << std::setprecision(9) << std::scientific << nodes[3*i + 0];
53  ePos = numSS.str().find("e");
54  expPos = numSS.str().find_last_of("0");
55  //std::cout << "numSS.str() = " << numSS.str() << std::endl;
56  //std::cout << "expPos = " << expPos << std::endl;
57  //std::cout << "numSS.str().size() = " << numSS.str().size() << std::endl;
58  if(expPos == numSS.str().size()-1)
59  exponent = "0";
60  else
61  exponent = numSS.str().substr(expPos+1,numSS.str().size());
62  output = numSS.str().substr(0,ePos+2) + exponent;
63  }
64  else{//we have to be careful with numbers that have two digit exponents
65  //in scientific notation because Rocfrac expects all numbers to take a
66  //specific number of columns.
67  if(nodes[3*i+0] < 0.0)
68  numSS << std::setprecision(8) << std::scientific << nodes[3*i + 0];
69  else
70  numSS << std::setprecision(9) << std::scientific << nodes[3*i + 0];
71 
72  output = numSS.str();
73  }
74  ss << std::setw(16) << output;
75  numSS.str("");
76  numSS.clear();
77 
78  if(fabs(nodes[3*i+1]) > 1.0e-10 || nodes[3*i+1] == 0.0){
79  numSS << std::setprecision(9) << std::scientific << nodes[3*i + 1];
80  ePos = numSS.str().find("e");
81  expPos = numSS.str().find_last_of("0");
82  //std::cout << "numSS.str() = " << numSS.str() << std::endl;
83  //std::cout << "expPos = " << expPos << std::endl;
84  //std::cout << "numSS.str().size() = " << numSS.str().size() << std::endl;
85  if(expPos == numSS.str().size()-1)
86  exponent = "0";
87  else
88  exponent = numSS.str().substr(expPos+1,numSS.str().size());
89  output = numSS.str().substr(0,ePos+2) + exponent;
90  }
91  else{//we have to be careful with numbers that have two digit exponents
92  //in scientific notation because Rocfrac expects all numbers to take a
93  //specific number of columns.
94  if(nodes[3*i+1] < 0.0)
95  numSS << std::setprecision(8) << std::scientific << nodes[3*i + 1];
96  else
97  numSS << std::setprecision(9) << std::scientific << nodes[3*i + 1];
98 
99  output = numSS.str();
100  }
101  ss << std::setw(16) << output;
102  numSS.str("");
103  numSS.clear();
104 
105  if(fabs(nodes[3*i+2]) > 1.0e-10 || nodes[3*i+2] == 0.0){
106  numSS << std::setprecision(9) << std::scientific << nodes[3*i + 2];
107  ePos = numSS.str().find("e");
108  expPos = numSS.str().find_last_of("0");
109  //std::cout << "numSS.str() = " << numSS.str() << std::endl;
110  //std::cout << "expPos = " << expPos << std::endl;
111  //std::cout << "numSS.str().size() = " << numSS.str().size() << std::endl;
112  if(expPos == numSS.str().size()-1)
113  exponent = "0";
114  else
115  exponent = numSS.str().substr(expPos+1,numSS.str().size());
116  output = numSS.str().substr(0,ePos+2) + exponent;
117  }
118  else{//we have to be careful with numbers that have two digit exponents
119  //in scientific notation because Rocfrac expects all numbers to take a
120  //specific number of columns.
121  if(nodes[3*i+2] < 0.0)
122  numSS << std::setprecision(8) << std::scientific << nodes[3*i + 2];
123  else
124  numSS << std::setprecision(9) << std::scientific << nodes[3*i + 2];
125 
126  output = numSS.str();
127  }
128  ss << std::setw(16) << output << std::endl;
129  numSS.str("");
130  numSS.clear();
131 
132  ss << "unused line" << std::endl;
133  }
134 
135  //Write Patran packet 2 element connectivities
136  for(int i=0; i < numElems; i++){
137  ss << "2 " << i+1 << " " << elemShape << std::endl
138  << " " << numNodesPerElem << " 0"
139  << " 0" << std::endl;
140  for(int j=0; j < numNodesPerElem; j++){
141  ss << elems[i*numNodesPerElem + j] << " ";
142  }
143  ss << std::endl;
144  }
145 
146  //Write Patran packet 8 (all nodes with this boundary type)
147  for(int i=0; i < numNodes; i++){
148  for(int k=0; k < nodeBCs[i].size(); k++){
149  if(nodeBCs[i][k] == 8){
150  ss << "8 " << i+1 << " 1 2" << std::endl;
151  ss << " 0";
152  for(int j=0; j < 3; j++)
153  ss << int(nodeBCValues[i][k][j]);
154  ss << "000" << std::endl;
155  for(int j=3; j < 6; j++){
156  if(nodeBCValues[i][k][j-3] != 0)
157  ss << " " << nodeBCValues[i][k][j];
158  }
159  ss << std::endl;
160  }
161  }
162  }
163 
164 
165  //Write Patran packet 6 (all elements with this boundary type)
166  //loop over all the elements
167  //std::cout << "bcs of type 6: " << std::endl;
168  for(int i=0; i < numElems; i++){
169  //std::cout << "elem " << i+1 << ": " << std::endl;
170  //loop over the domains for that element (we only want
171  //to print one domain's bcs for the element at a time
172  for(int doms=0; doms < elemsToDomains[i].size(); doms++){
173  int domain=elemsToDomains[i][doms]-1;
174  //std::cout << "domain " << domain+1 << std::endl;
175  //loop over the boundary flags for that domain
176  for(int j=0; j < domainBCs[domain].size(); j++){
177  int bcCount=0;
178  if(domainBCs[domain][j] == 6){
179  //std::cout << "bc " << j+1 << ": " << std::endl;
180  ss << "6 " << i+1 << " 1 2 0 0 0 0 0" << std::endl;
181  ss << "111100000";
182  //loop over the nodes for that element
183  for(int k=0; k < numNodesPerElem; k++){
184  bool onBC=false;
185  int node = elems[i*numNodesPerElem + k]-1;
186  //std::cout << "node " << k+1 << " (" << node+1 << ")" << std::endl;
187  //loop over the bc flags for that node
188  for(int l=0; l < nodeBCs[node].size(); l++){
189  if(nodeBCs[node][l] == 6){
190  //check if the bcs have the same values
191  for(int m=0; m < nodeBCValues[node][l].size(); m++){
192  if(nodeBCValues[node][l][m] != domainBCValues[domain][j][m])
193  break;
194  else if(m == nodeBCValues[node][l].size()-1){
195  onBC=true;
196  bcCount++;
197  //std::cout << "has bc" << std::endl;
198  }
199  }
200  }
201  }//loop over node bcs
202  if(onBC){
203  //now check that the node is on that domain
204  int domCount;
205  for(domCount=0; domCount < nodesToDomains[node].size(); domCount++){
206  if(nodesToDomains[node][domCount] == domain+1){
207  //std::cout << "node on domain (writing it)" << std::endl;
208  ss << "1";
209  break;
210  }
211  }
212  if(domCount == nodesToDomains[node].size())
213  ss << "0";
214  }
215  else
216  ss << "0";
217  }//loop over nodes for the element
218  //Fill in with 0's at the end if we are using tet elements
219  if(numNodesPerElem == 4)
220  ss << "0000";
221  ss << std::endl;
222  for(int m=0; m < domainBCValues[domain][j].size(); m++)
223  ss << domainBCValues[domain][j][m] << " ";
224  ss << std::endl;
225  }//if it is bc type 6
226  }//loop over bc flags for domain
227  }//loop over the domains for the element
228  }//loop over all elements
229  ss << "99 0 0 1";
230 
231  if(use_outfile){
232  Ouf << ss.str();
233  }
234  else
235  StdOut(ss.str());
236  // Close output file
237  Ouf.close();
238 
239  StdOut(Ostr.str());
240  Ostr.str("");
241 
242  return 0;
243 
244  } //ReadOutput function
j indices k indices k
Definition: Indexing.h:6
std::vector< unsigned int > elems
vector for holding element connectivies read from input
Definition: adj.h:150
int numElems
number of elements in mesh
std::vector< std::vector< int > > elemsToDomains
vector to hold the domains for each element
std::vector< std::vector< int > > nodeBCs
std::string output_name
Name of file for output.
SolverUtils::Mesh::Connectivity nodesToDomains
std::ofstream Ouf
Outfile stream for output.
blockLoc i
Definition: read.cpp:79
int numNodesPerElem
number of nodes per element
std::vector< std::vector< int > > domainBCs
vector to hold list of domain bc flags
std::vector< std::vector< std::vector< double > > > domainBCValues
vector to hold list of domain bc values (these are different for each bc type - see the Rocfrac docum...
j indices j
Definition: Indexing.h:6
int elemShape
integer to denote the shape of elements used in the mesh
std::vector< double > nodes
vector for holding nodal coordinates read from input
std::vector< std::vector< std::vector< double > > > nodeBCValues
vector to hold list of node bc values (these are different for each bc type - see the Rocfrac documen...

Here is the caller graph for this function:

Member Data Documentation

std::string bc_input_name
protected

Name of bc input file.

Definition at line 186 of file DriverProgram.H.

Referenced by SerialProgram::Initialize(), SerialProgram::ReadPatranInput(), and SerialProgram::ReadStanfordInput().

std::vector< std::vector<int> > domainBCs
protected

vector to hold list of domain bc flags

Definition at line 240 of file DriverProgram.H.

Referenced by SerialProgram::ReadPatranInput(), SerialProgram::ReadStanfordInput(), SerialProgram::Run(), and SerialProgram::WriteOutput().

std::vector< std::vector< std::vector<double> > > domainBCValues
protected

vector to hold list of domain bc values (these are different for each bc type - see the Rocfrac documentation for more clarification)

Definition at line 243 of file DriverProgram.H.

Referenced by SerialProgram::ReadPatranInput(), SerialProgram::ReadStanfordInput(), SerialProgram::Run(), and SerialProgram::WriteOutput().

std::vector< std::vector<unsigned int> > domains
protected

vector of vectors to hold the domains

Definition at line 238 of file DriverProgram.H.

Referenced by SerialProgram::HigherOrderTets(), SerialProgram::ReadPatranInput(), SerialProgram::ReadStanfordInput(), and SerialProgram::Run().

std::vector< std::vector<int> > edgeBCs
protected

vector to hold list of edge bc flags

Definition at line 247 of file DriverProgram.H.

Referenced by SerialProgram::ReadPatranInput(), SerialProgram::ReadStanfordInput(), and SerialProgram::Run().

std::vector< std::vector< std::vector<double> > > edgeBCValues
protected

vector to hold list of edge bc values (these are different for each bc type - see the Rocfrac documentation for more clarification)

Definition at line 250 of file DriverProgram.H.

Referenced by SerialProgram::ReadPatranInput(), SerialProgram::ReadStanfordInput(), and SerialProgram::Run().

std::vector< std::vector<int> > edges
protected

vector of vectors to hold the edges

Definition at line 245 of file DriverProgram.H.

Referenced by SerialProgram::ReadPatranInput(), SerialProgram::ReadStanfordInput(), and SerialProgram::Run().

std::vector< std::vector<int> > elemBCs
protected

vector to hold list of element bc values

Definition at line 223 of file DriverProgram.H.

Referenced by SerialProgram::Run().

std::vector< std::vector< std::vector<double> > > elemBCValues
protected

vector to hold list of element bc values (these are different for each bc type - see the Rocfrac documentation for more clarification)

Definition at line 226 of file DriverProgram.H.

Referenced by SerialProgram::Run().

std::vector<unsigned int> elemEdges
protected

vector for holding element edges

Definition at line 209 of file DriverProgram.H.

Referenced by SerialProgram::ConnectivityMaps(), and SerialProgram::HigherOrderTets().

std::vector<unsigned int> elems
protected
int elemShape
protected

integer to denote the shape of elements used in the mesh

Definition at line 232 of file DriverProgram.H.

Referenced by SerialProgram::Initialize(), SerialProgram::ReadPatranInput(), SerialProgram::ReadStanfordInput(), and SerialProgram::WriteOutput().

std::vector< std::vector<int> > elemsToDomains
protected

vector to hold the domains for each element

Definition at line 230 of file DriverProgram.H.

Referenced by SerialProgram::Run(), and SerialProgram::WriteOutput().

std::vector<unsigned int> elemToElemEdges
protected

map of elements to element edges

Definition at line 213 of file DriverProgram.H.

Referenced by SerialProgram::ConnectivityMaps(), SerialProgram::HigherOrderTets(), and SerialProgram::Run().

std::ifstream Inf
protected

Infile stream for input.

Definition at line 192 of file DriverProgram.H.

Referenced by SerialProgram::ReadPatranInput(), and SerialProgram::ReadStanfordInput().

std::string input_name
protected

Name of input file.

Definition at line 184 of file DriverProgram.H.

Referenced by SerialProgram::Initialize(), SerialProgram::ReadPatranInput(), and SerialProgram::ReadStanfordInput().

std::vector< std::vector<int> > nodeBCs
protected

Definition at line 200 of file DriverProgram.H.

Referenced by SerialProgram::Run(), and SerialProgram::WriteOutput().

std::vector< std::vector< std::vector<double> > > nodeBCValues
protected

vector to hold list of node bc values (these are different for each bc type - see the Rocfrac documentation for more clarification)

Definition at line 203 of file DriverProgram.H.

Referenced by SerialProgram::Run(), and SerialProgram::WriteOutput().

std::vector<double> nodes
protected

vector for holding nodal coordinates read from input

Definition at line 198 of file DriverProgram.H.

Referenced by SerialProgram::HigherOrderTets(), SerialProgram::ReadPatranInput(), SerialProgram::ReadStanfordInput(), SerialProgram::Run(), and SerialProgram::WriteOutput().

SolverUtils::Mesh::Connectivity nodesToDomains
protected

Definition at line 205 of file DriverProgram.H.

Referenced by SerialProgram::Run(), and SerialProgram::WriteOutput().

std::vector< std::vector<unsigned int> > nodeToNode
protected

vector for holding node to node map

Definition at line 219 of file DriverProgram.H.

Referenced by SerialProgram::ConnectivityMaps().

int numDomains
protected

number of domains in mesh

Definition at line 236 of file DriverProgram.H.

Referenced by SerialProgram::Initialize(), and SerialProgram::ReadStanfordInput().

int numEdgesPerElem
protected
int numElemEdges
protected

number of element edges in mesh

Definition at line 207 of file DriverProgram.H.

Referenced by SerialProgram::ConnectivityMaps(), SerialProgram::HigherOrderTets(), and SerialProgram::Run().

int numNodesPerElemEdge
protected

number of nodes per element edge

Definition at line 211 of file DriverProgram.H.

Referenced by SerialProgram::ConnectivityMaps(), and SerialProgram::HigherOrderTets().

std::ofstream Ouf
protected

Outfile stream for output.

Definition at line 190 of file DriverProgram.H.

Referenced by SerialProgram::WriteOutput(), and SerialProgram::~SerialProgram().

std::string output_name
protected

Name of file for output.

Definition at line 182 of file DriverProgram.H.

Referenced by SerialProgram::Initialize(), and SerialProgram::WriteOutput().

bool quadratic
protected

boolean for changing the elements to higher order

Definition at line 194 of file DriverProgram.H.

Referenced by SerialProgram::Initialize(), and SerialProgram::Run().

std::vector<std::string> shapes
protected

vector to hold the element shapes (only used for Patran input format)

Definition at line 234 of file DriverProgram.H.

Referenced by SerialProgram::Initialize(), and SerialProgram::ReadPatranInput().


The documentation for this class was generated from the following files: