Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mesh.cpp File Reference
#include <string.h>
#include "Mesh.hpp"
#include "Element.hpp"
#include "Face.hpp"
#include "Node.hpp"
#include "IntList.hpp"
#include "NodeList.hpp"
#include "ElementList.hpp"
#include "FaceList.hpp"
#include "FaceListList.hpp"
Include dependency graph for Mesh.cpp:

Go to the source code of this file.

Functions

ostream & operator<< (ostream &stream, Mesh &mesh)
 
istream & operator>> (istream &stream, Mesh &mesh)
 

Function Documentation

ostream& operator<< ( ostream &  stream,
Mesh mesh 
)

These output files are the augmented node/element file (now containing cohesive elements), and the surface node description file. Note that the ostream operators for other classes actually do much of the work (i.e., node << knows how to write a node, element << knows how to write an element, etc.).

Definition at line 359 of file Mesh.cpp.

References Mesh::d_elements, Mesh::d_nodes, Mesh::d_numElements, Mesh::d_numNodes, Node::e_unset_flag, Node::getFlag(), Node::getID(), Mesh::getMinEdge(), i, and j.

359  {
360 
361  int j;
362  int numcohesive = 0;
363  for (j=0; j<mesh.d_numElements; j++) {
364  if ((*mesh.d_elements[j]).isCohesive()) numcohesive += 1;
365  }
366 
367  stream << (mesh.d_numElements - numcohesive) << '\t' << mesh.d_numNodes
368  << '\t' << numcohesive << '\t' << mesh.getMinEdge() <<endl;
369 
370  stream.setf(ios::uppercase);
371  stream.setf(ios::scientific,ios::floatfield);
372  stream.precision(9);
373  int numbc_nodes = 0;
374  int i;
375  for( i = 0; i < mesh.d_numNodes;i++ ){
376  stream << (*mesh.d_nodes[i]);
377  if( mesh.d_nodes[i]->getFlag() != Node::e_unset_flag ){
378  numbc_nodes++;
379  }
380  }
381  stream << numbc_nodes << endl;
382  for( i = 0; i < mesh.d_numNodes;i++ ){
383  if( mesh.d_nodes[i]->getFlag() != Node::e_unset_flag ){
384  stream << mesh.d_nodes[i]->getID() << '\t' << mesh.d_nodes[i]->getFlag()<< endl;
385  }
386  }
387  for( i = 0; i < mesh.d_numElements; i++ ){
388  stream << (*mesh.d_elements[i]);
389  }
390 
391  return stream;
392 }
int getID()
Definition: Node.hpp:119
int d_numElements
Definition: Mesh.hpp:130
Node ** d_nodes
An ordered array of all nodes in the mesh.
Definition: Mesh.hpp:105
int getFlag() const
Definition: Node.hpp:150
Element ** d_elements
Array of all the Elements in the mesh.
Definition: Mesh.hpp:129
blockLoc i
Definition: read.cpp:79
int d_numNodes
The number of Nodes in the nodes array.
Definition: Mesh.hpp:110
j indices j
Definition: Indexing.h:6
double getMinEdge()
Definition: Mesh.hpp:155

Here is the call graph for this function:

istream& operator>> ( istream &  stream,
Mesh mesh 
)

This input file contains the node and element definitions for the mesh. Note that the instream operators for other classes actually do much of the work (i.e., node >> knows how to read a node, element >> knows how to read an element, etc.).

Definition at line 402 of file Mesh.cpp.

References Mesh::calcEdgeLength(), Element::create(), Face::create(), Mesh::d_elementArraySize, Mesh::d_elements, Mesh::d_faceArraySize, Mesh::d_faces, Mesh::d_nodeArraySize, Mesh::d_nodes, Mesh::d_numElements, Mesh::d_numNodes, FALSE, Mesh::getFace(), Mesh::getMinEdge(), Face::getNodes(), Mesh::getNumFaces(), Face::getNumNodes(), i, id(), j, k, Face::setFlag(), Node::setFlag(), Mesh::setMinEdge(), and TRUE.

402  {
403 
404  int numn;
405  int nume;
406  stream >> nume >> numn;
407 
408  mesh.d_nodeArraySize = numn;
409  mesh.d_nodes = new Node*[numn];
410  // read nodes
411  int i;
412  for( i = 0; i < numn;i++ ){
413  mesh.d_nodes[i] = new Node();
414  stream >> (*mesh.d_nodes[i]);
415  }
416  mesh.d_numNodes = numn;
417 
418  mesh.d_elementArraySize = nume;
419  mesh.d_elements = new Element*[nume];
420 
421  // assume ~ twice as elements
422 
423  mesh.d_faceArraySize = nume * 2;
424  mesh.d_faces = new Face*[mesh.d_faceArraySize];
425 
426 
427  for( i = 0; i < nume;i++ ){
428  int id, type;
429  double currentEdge;
430  stream >> id >> type;
431  mesh.d_elements[i] = Element::create( id, (Element::Type)type );
432  stream >> (*mesh.d_elements[i]);
433  currentEdge = (mesh.calcEdgeLength(i));
434  if (currentEdge < mesh.getMinEdge()) mesh.setMinEdge(currentEdge);
435  }
436  mesh.d_numElements = nume;
437  // read groups
438 
439  int numbcn;
440  stream >> numbcn;
441  // read nodes with flag
442  for( i = 0; i < numbcn; i++ ){
443  int num;
444  int flag;
445  stream >> num >> flag;
446  mesh.d_nodes[num-1]->setFlag( flag );
447  }
448 
449  //read faces with flag (three nodes and the flag)
450  int numFaceFlags, numFaceNodes, elementtype, theflag, totalFaces;
451 
452  stream >> numFaceFlags; //number of faces in input file with flags
453  totalFaces = mesh.getNumFaces(); //total number of existing faces in mesh
454 
455  for (i=0 ; i < numFaceFlags ; i++) {
456  stream >> elementtype; //type of element the face is associated with
457  //make a temporary working face to hold the node info
458  Face* theFace = Face::create((Face::eType)elementtype);
459  stream >> *theFace;
460  stream >> theflag;
461  numFaceNodes = theFace->getNumNodes(); //number of nodes in this face
462 
463  //take "theFace" and compare it's nodes against the nodes in every face in the
464  //Mesh list of faces until we find a match. When we find a match, set it's flag,
465  //and then go on to the next face in the list. This is very inefficient, but
466  //without knowing what element the supplied face is in, I don't know how else to
467  //go about it.
468  int j;
469  for (j=0; j < totalFaces; j++) {
470  Face* trialFace = mesh.getFace(j+1); //getFace assumes ID's starting with 1
471  Node** theNodes = theFace->getNodes();
472  Node** trialNodes = trialFace->getNodes();
473  boolean nodeFound;
474  int numFound;
475  numFound=0;
476 
477  //for each node in the face to be found...
478  int k;
479  for (k=0; k<numFaceNodes; k++) {
480  nodeFound=FALSE;
481  int numExistingFaceNodes;
482  numExistingFaceNodes = trialFace->getNumNodes();
483  if (numFaceNodes != numExistingFaceNodes) break; //faces aren't compatible
484 
485  //...see if it's in the current face in the mesh that we're looking at.
486  int m;
487  for (m=0; m<numExistingFaceNodes; m++) {
488  if(theNodes[k]==trialNodes[m]) {
489  nodeFound=TRUE;
490  numFound++;
491  break;
492  }
493  }
494  if(!nodeFound) break; //if we didn't find the node, try the next face
495  //if we found all the nodes in any face, then set the flag and read the next face in.
496  if(numFound==numFaceNodes) {
497  trialFace->setFlag(theflag);
498  break;
499  }
500  }
501  }
502  delete theFace;
503  }
504  return stream;
505 }
#define FALSE
Definition: vinci.h:133
static Element * create(int id, Type type)
Definition: Element.cpp:35
void setFlag(int theFlag)
Sets the flag for the face.
Definition: Face.hpp:179
Face ** d_faces
1..*
Definition: Mesh.hpp:121
This class encapsulate a node over a window manifold.
Definition: Manifold_2.h:370
j indices k indices k
Definition: Indexing.h:6
static Face * create(eType type)
Definition: Face.cpp:34
int d_faceArraySize
Definition: Mesh.hpp:123
int d_numElements
Definition: Mesh.hpp:130
int d_nodeArraySize
The current size of the nodes array (must be as big or bigger than numNodes).
Definition: Mesh.hpp:116
Node ** d_nodes
An ordered array of all nodes in the mesh.
Definition: Mesh.hpp:105
double calcEdgeLength(int elementID)
Definition: Mesh.cpp:396
Element ** d_elements
Array of all the Elements in the mesh.
Definition: Mesh.hpp:129
blockLoc i
Definition: read.cpp:79
#define TRUE
Definition: vinci.h:134
int getNumFaces()
Definition: Mesh.hpp:149
void setMinEdge(double me)
Definition: Mesh.hpp:158
int d_numNodes
The number of Nodes in the nodes array.
Definition: Mesh.hpp:110
Node ** getNodes()
Returns the array of nodes.
Definition: Face.hpp:185
j indices j
Definition: Indexing.h:6
unsigned long id(const Leda_like_handle &x)
Definition: Handle.h:107
Face * getFace(int ID)
Definition: Mesh.hpp:140
void setFlag(int flag)
Definition: Node.hpp:153
int d_elementArraySize
Definition: Mesh.hpp:131
The Face class is an abstract base class that supplies implemented general methods, as well as a vew virtual interface methods to child classes.
Definition: Face.hpp:19
eType
Definition: Face.hpp:24
double getMinEdge()
Definition: Mesh.hpp:155
virtual int getNumNodes() const =0
Retrieves the number of nodes that make up the face.

Here is the call graph for this function: