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

Class Mesh is the main class that holds all information to describe the current state of the mesh. More...

#include <Mesh.hpp>

Collaboration diagram for Mesh:

Classes

struct  Border
 
struct  BorderData
 Border data in CSR format. More...
 
class  BSExtent
 Simple Block Structured Mesh object. More...
 
class  Connectivity
 General connectivity object. More...
 
class  GenericCell_2
 
class  GenericElement
 
class  GeometricEntity
 Connects continuous to discrete. More...
 
class  MeshUtilityObject
 
class  NeighborHood
 
class  NodalCoordinates
 
struct  PartInfo
 
class  Partition
 
class  SolnMetaData
 
class  TestFace
 
struct  UnstructuredMesh
 

Public Types

typedef IRAD::Primitive::IndexType IndexType
 
typedef IRAD::Primitive::ubyte CellEntityIDType
 
typedef std::pair< IndexType,
CellEntityIDType
SubEntityId
 
typedef std::pair< SubEntityId,
SubEntityId
SymbolicFace
 
typedef std::vector< IndexTypeIndexVec
 
typedef
IRAD::Primitive::MultiContainer
< IndexType >::VecVec 
MultiVec
 
typedef
IRAD::Primitive::MultiContainer
< IndexType, IndexType >
::VecMap 
VecMap
 
typedef IRAD::Primitive::ubyte GeoDimType
 
typedef std::string GeoNameType
 

Public Member Functions

 Mesh ()
 
 ~Mesh ()
 
void addNode (Node *node)
 The following add/remove/get methods are utility methods to add, remove, or return instances of nodes, faces or elements. More...
 
void addFace (Face *face)
 
void addElement (Element *element)
 
void removeNode (Node *node)
 
void removeFace (Face *face)
 
void removeElement (Element *element)
 
NodegetNode (int ID)
 The following get methods return a node, face or element. More...
 
FacegetFace (int ID)
 
ElementgetElement (int ID)
 
int getNumNodes ()
 The following get methods return the number of nodes, faces, or elements currently in the model. More...
 
int getNumFaces ()
 
int getNumElements ()
 
boolean addCohesive (int material1, int material2, int new_material=-1)
 The addCohesive method is the driver for the entire process of adding cohesive elements to the mesh. More...
 
void replaceNode (Node *node, Node *new_node, ElementList *sep_elements, int new_material)
 
void write_boundary (ostream &stream)
 

Public Attributes

const double TOL = 1e-9
 
const double LTOL = 0.0 - TOL
 
const double HTOL = 1.0 + TOL
 

Private Member Functions

double calcEdgeLength (int elementID)
 
double getMinEdge ()
 
void setMinEdge (double me)
 

Private Attributes

Node ** d_nodes
 An ordered array of all nodes in the mesh. More...
 
int d_numNodes
 The number of Nodes in the nodes array. More...
 
int d_nodeArraySize
 The current size of the nodes array (must be as big or bigger than numNodes). More...
 
Face ** d_faces
 1..* More...
 
int d_numFaces
 
int d_faceArraySize
 
Element ** d_elements
 Array of all the Elements in the mesh. More...
 
int d_numElements
 
int d_elementArraySize
 
double minEdge
 

Friends

istream & operator>> (istream &stream, Mesh &mesh)
 The mesh instream operator is used to drive the reading of the one input file to the code. More...
 
ostream & operator<< (ostream &stream, Mesh &mesh)
 The mesh ostream operator is used to drive the writing of both output fils from the code. More...
 

Detailed Description

Class Mesh is the main class that holds all information to describe the current state of the mesh.

It has several arrays that are arrays of node, face, and element objects. It contains the main work method for the cohesive insertion algorithm "addCohesive" that will be called from the main program.

Definition at line 19 of file Mesh.hpp.

Member Typedef Documentation

typedef IRAD::Primitive::ubyte CellEntityIDType

Definition at line 58 of file Mesh.H.

typedef IRAD::Primitive::ubyte GeoDimType

Definition at line 64 of file Mesh.H.

typedef std::string GeoNameType

Definition at line 65 of file Mesh.H.

typedef IRAD::Primitive::IndexType IndexType

Definition at line 57 of file Mesh.H.

typedef std::vector<IndexType> IndexVec

Definition at line 61 of file Mesh.H.

typedef IRAD::Primitive::MultiContainer<IndexType>::VecVec MultiVec

Definition at line 62 of file Mesh.H.

Definition at line 59 of file Mesh.H.

typedef std::pair<SubEntityId,SubEntityId> SymbolicFace

Definition at line 60 of file Mesh.H.

typedef IRAD::Primitive::MultiContainer<IndexType,IndexType>::VecMap VecMap

Definition at line 63 of file Mesh.H.

Constructor & Destructor Documentation

Mesh ( )

Definition at line 14 of file Mesh.cpp.

References minEdge, Element::setMesh(), and Face::setMesh().

14  :
15  d_nodes(0),
16  d_numNodes(0),
17  d_nodeArraySize(0),
18  d_faces(0),
19  d_numFaces(0),
20  d_faceArraySize(0),
21  d_elements(0),
22  d_numElements(0),
24 {
25 
26  Element::setMesh( this );
27  Face::setMesh( this );
28  minEdge = 1E+25;
29 
30 }
int d_numFaces
Definition: Mesh.hpp:122
Face ** d_faces
1..*
Definition: Mesh.hpp:121
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
Element ** d_elements
Array of all the Elements in the mesh.
Definition: Mesh.hpp:129
double minEdge
Definition: Mesh.hpp:133
int d_numNodes
The number of Nodes in the nodes array.
Definition: Mesh.hpp:110
static void setMesh(Mesh *emesh)
Definition: Element.hpp:124
static void setMesh(Mesh *emesh)
Definition: Face.hpp:215
int d_elementArraySize
Definition: Mesh.hpp:131

Here is the call graph for this function:

~Mesh ( )

Definition at line 32 of file Mesh.cpp.

References d_elements, d_faces, d_nodes, d_numElements, d_numFaces, d_numNodes, and i.

32  {
33 
34  if( d_elements ){
35  int i;
36  for( i = 0; i < d_numElements; i++ ){
37  delete d_elements[i];
38  }
39  delete [] d_elements;
40  }
41 
42  if( d_faces ){
43  int i;
44  for( i = 0; i < d_numFaces; i++ ){
45  delete d_faces[i];
46  }
47  delete [] d_faces;
48  }
49 
50  if( d_nodes ){
51  int i;
52  for( i = 0; i < d_numNodes; i++ ){
53  delete d_nodes[i];
54  }
55  delete [] d_nodes;
56  }
57 }
int d_numFaces
Definition: Mesh.hpp:122
Face ** d_faces
1..*
Definition: Mesh.hpp:121
int d_numElements
Definition: Mesh.hpp:130
Node ** d_nodes
An ordered array of all nodes in the mesh.
Definition: Mesh.hpp:105
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

Member Function Documentation

boolean addCohesive ( int  material1,
int  material2,
int  new_material = -1 
)

The addCohesive method is the driver for the entire process of adding cohesive elements to the mesh.

Currently, it relies on the input of three integers: material 1 and material 2 are the element material types that should have cohesive elements inserted between them (they can be the same number if it is desired to insert cohesive elements between elements of the same type). new_material defaults to -1, and is the material type that cohesive elements will be assigned.

Definition at line 167 of file Mesh.cpp.

References d_faces, d_numFaces, FALSE, FaceList::get(), FaceListList::get(), NodeList::get(), Face::getElement1(), Face::getElement2(), Element::getMaterialType(), Face::getNodes(), Face::getNumNodes(), i, NodeList::index(), FaceListList::index(), FaceList::insert_first(), NodeList::insert_first(), FaceListList::insert_first(), Element::isCohesive(), j, NodeList::move_to(), FaceListList::next(), FaceList::next(), NodeList::next(), NodeList::reset(), FaceListList::reset(), FaceList::reset(), Node::separate(), FaceList::size(), NodeList::size(), and TRUE.

167  {
168 
169  // go over all faces & for each one which has two elems
170  // with the mat1 & mat2 - generate a cohesive (if neither of
171  // the two elems is cohesive) - have a list of those (to split
172  // at nodes later)
173 
174  FaceList faces;
175 
176  // collect the faces
177  int i;
178  for( i = 0; i < d_numFaces; i++ ){
179  Element *e1 = d_faces[i]->getElement1();
180  Element *e2 = d_faces[i]->getElement2();
181  if( e1 && e2 && !e1->isCohesive()
182  && !e2->isCohesive()
183  && ( ( e1->getMaterialType() == material1
184  && e2->getMaterialType() == material2 )
185  || ( e1->getMaterialType() == material2
186  && e2->getMaterialType() == material1 ) ) ){
187  // fits
188  faces.insert_first( d_faces[i] );
189  }
190  }
191 
192  // Collect nodes & their faces
193 
194  NodeList sep_nodes;
195  FaceListList node_faces;
196  int size = faces.size();
197  faces.reset();
198  for( i = 0; i < size; i++ ){
199  Face* face = faces.get();
200  faces.next();
201  int num = face->getNumNodes();
202  Node** fnodes = face->getNodes();
203  int j;
204  for( j = 0; j < num; j++ ){
205  if( sep_nodes.move_to( fnodes[j] ) ){
206  int ind = sep_nodes.index();
207  node_faces.index( ind );
208  node_faces.get()->insert_first( face );
209  }
210  else {
211  sep_nodes.insert_first( fnodes[j] );
212  FaceList* newlist = new FaceList;
213  newlist->insert_first( face );
214  node_faces.insert_first( newlist );
215  }
216  }
217  }
218 
219  // now go over the nodes & check if separable...
220 
221  // check at each node
222  // if have two element groups separated by cohesives (or our faces)
223  // if yes separate the two.
224 
225  int sep_count = 0;
226  int node_size = sep_nodes.size();
227  sep_nodes.reset();
228  node_faces.reset();
229  for( i = 0; i < node_size; i++ ) {
230  int j = i;
231  Node* node = sep_nodes.get();
232  FaceList* flist = node_faces.get();
233  sep_nodes.next();
234  node_faces.next();
235  boolean separated = node->separate( this, flist, new_material );
236  if( separated ) sep_count++;
237  delete flist;
238  }
239  cerr << " separated " << sep_count << " nodes, out of " << node_size
240  << " involved" << endl;
241 
242  return ( sep_count >0 ? TRUE : FALSE );
243 }
#define FALSE
Definition: vinci.h:133
boolean separate(Mesh *mesh, FaceList *list, int new_material)
Definition: Node.cpp:162
void insert_first(FaceList *val)
int d_numFaces
Definition: Mesh.hpp:122
int size()
Definition: NodeList.hpp:95
int getMaterialType() const
Definition: Element.hpp:118
Face ** d_faces
1..*
Definition: Mesh.hpp:121
void next()
Definition: NodeList.hpp:80
This class encapsulate a node over a window manifold.
Definition: Manifold_2.h:370
Definition: face.h:90
int index() const
Node * get()
Definition: NodeList.hpp:87
Element * getElement2()
Get the pointer to the second element that this face is associated with.
Definition: Face.hpp:197
Definition: adj.h:150
FaceList * get()
int size()
Definition: FaceList.hpp:95
void reset()
Definition: NodeList.hpp:76
void next()
Definition: FaceList.hpp:80
blockLoc i
Definition: read.cpp:79
#define TRUE
Definition: vinci.h:134
void reset()
Definition: FaceList.hpp:76
Node ** getNodes()
Returns the array of nodes.
Definition: Face.hpp:185
boolean isCohesive() const
Definition: Element.hpp:112
j indices j
Definition: Indexing.h:6
int index() const
Definition: NodeList.cpp:110
Face * get()
Definition: FaceList.hpp:87
boolean move_to(Node *val)
Definition: NodeList.cpp:102
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
Element * getElement1()
Get the pointer to the first element that this face is associated with.
Definition: Face.hpp:191
virtual int getNumNodes() const =0
Retrieves the number of nodes that make up the face.
void insert_first(Node *val)
Definition: NodeList.hpp:69
void insert_first(Face *val)
Definition: FaceList.hpp:69

Here is the call graph for this function:

void addElement ( Element element)

Definition at line 131 of file Mesh.cpp.

References d_elementArraySize, d_elements, d_numElements, and Element::setID().

Referenced by replaceNode().

131  {
132 
134  d_elementArraySize = (int)( d_elementArraySize * 1.25 + 3);
135  Element **new_arr = new Element*[d_elementArraySize];
136  if( d_numElements > 0 ){
137  memcpy(new_arr, d_elements, d_numElements * sizeof(Element*) );
138  delete [] d_elements;
139  }
140  d_elements = new_arr;
141  }
142  d_elements[d_numElements] = element;
143  element->setID(d_numElements + 1);
144  d_numElements++;
145 
146 }
int d_numElements
Definition: Mesh.hpp:130
Element ** d_elements
Array of all the Elements in the mesh.
Definition: Mesh.hpp:129
void setID(int theID)
Definition: Element.hpp:100
int d_elementArraySize
Definition: Mesh.hpp:131

Here is the call graph for this function:

Here is the caller graph for this function:

void addFace ( Face face)

Definition at line 96 of file Mesh.cpp.

References d_faceArraySize, d_faces, d_numFaces, face, and Face::setID().

Referenced by HexElement::setFaceFromNodes(), TetElement::setFaceFromNodes(), TCoElement::setFaceFromNodes(), and QCoElement::setFaceFromNodes().

96  {
97 
98  if( d_faceArraySize == d_numFaces ){
99  d_faceArraySize = (int)( d_faceArraySize * 1.25 + 3);
100  Face **new_arr = new Face*[d_faceArraySize];
101  if( d_numFaces > 0 ){
102  memcpy(new_arr, d_faces, d_numFaces * sizeof(Face*) );
103  delete [] d_faces;
104  }
105  d_faces = new_arr;
106  }
108  face->setID(d_numFaces + 1);
109  d_numFaces++;
110 }
int d_numFaces
Definition: Mesh.hpp:122
Face ** d_faces
1..*
Definition: Mesh.hpp:121
int d_faceArraySize
Definition: Mesh.hpp:123
static T_VertexSet * face
Definition: vinci_lass.c:79
void setID(int theID)
Sets the serial ID for the face.
Definition: Face.hpp:173
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

Here is the call graph for this function:

Here is the caller graph for this function:

void addNode ( Node node)

The following add/remove/get methods are utility methods to add, remove, or return instances of nodes, faces or elements.

Pointers to the node, face, or element to be added or removed must be provided.

Definition at line 60 of file Mesh.cpp.

References d_nodeArraySize, d_nodes, d_numNodes, and Node::setID().

Referenced by Node::separate().

60  {
61 
62  if( d_nodeArraySize == d_numNodes ){
63  d_nodeArraySize = (int)( d_nodeArraySize * 1.25 + 3);
64  Node **new_arr = new Node*[d_nodeArraySize];
65  if( d_numNodes > 0 ){
66  memcpy(new_arr, d_nodes, d_numNodes * sizeof(Node*) );
67  delete [] d_nodes;
68  }
69  d_nodes = new_arr;
70  }
71  d_nodes[d_numNodes] = node;
72  node->setID(d_numNodes + 1);
73  d_numNodes++;
74 
75 }
This class encapsulate a node over a window manifold.
Definition: Manifold_2.h:370
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
int d_numNodes
The number of Nodes in the nodes array.
Definition: Mesh.hpp:110
void setID(int theID)
Definition: Node.hpp:116

Here is the call graph for this function:

Here is the caller graph for this function:

double calcEdgeLength ( int  elementID)
private

Definition at line 396 of file Mesh.cpp.

References d_elements.

Referenced by operator>>().

396  {
397 
398  return(d_elements[elementID]->getMinEdgeLength());
399 
400 }
Element ** d_elements
Array of all the Elements in the mesh.
Definition: Mesh.hpp:129

Here is the caller graph for this function:

Element * getElement ( int  ID)
inline

Definition at line 143 of file Mesh.hpp.

References d_elements.

144 { return d_elements[ID-1];}
Element ** d_elements
Array of all the Elements in the mesh.
Definition: Mesh.hpp:129
Face * getFace ( int  ID)
inline

Definition at line 140 of file Mesh.hpp.

References d_faces.

Referenced by operator>>().

141 {return d_faces[ID-1];}
Face ** d_faces
1..*
Definition: Mesh.hpp:121

Here is the caller graph for this function:

double getMinEdge ( )
inlineprivate

Definition at line 155 of file Mesh.hpp.

References minEdge.

Referenced by operator<<(), and operator>>().

156 { return minEdge; }
double minEdge
Definition: Mesh.hpp:133

Here is the caller graph for this function:

Node * getNode ( int  ID)
inline

The following get methods return a node, face or element.

To return one of these objects, it's ID must be supplied. Note: in the input file, all nodes and elements are given IDs by the file author. However, this code assumes that the nodes and elements are supplied in "ID" order, and it just returns the array element [ID-1]. Thus, if you skip an ID in the input file, and then ask for element ID=50 (assume you skipped 40), you will actually get element 51 back (51 as listed in the input file, but it will be the 50th element that was in the input file).

Definition at line 137 of file Mesh.hpp.

References d_nodes.

Referenced by operator>>().

138 { return d_nodes[ID-1]; }
Node ** d_nodes
An ordered array of all nodes in the mesh.
Definition: Mesh.hpp:105

Here is the caller graph for this function:

int getNumElements ( )
inline

Definition at line 152 of file Mesh.hpp.

References d_numElements.

153 { return d_numElements; }
int d_numElements
Definition: Mesh.hpp:130
int getNumFaces ( )
inline

Definition at line 149 of file Mesh.hpp.

References d_numFaces.

Referenced by operator>>().

150 { return d_numFaces; }
int d_numFaces
Definition: Mesh.hpp:122

Here is the caller graph for this function:

int getNumNodes ( )
inline

The following get methods return the number of nodes, faces, or elements currently in the model.

These may not be the same as the sizes of the corresponding arrays in the Mesh class (d_nodes, etc. )

Definition at line 146 of file Mesh.hpp.

References d_numNodes.

147 { return d_numNodes; }
int d_numNodes
The number of Nodes in the nodes array.
Definition: Mesh.hpp:110
void removeElement ( Element element)

Definition at line 148 of file Mesh.cpp.

References d_elements, d_numElements, i, and Element::setID().

148  {
149 
150  int i;
151  int dif = 0;
152  for( i = 0; i < d_numElements; i++ ){
153  if( d_elements[i] == element ){
154  dif++;
155  continue;
156  }
157  if( dif > 0 ){
158  d_elements[i - dif] = d_elements[i];
159  d_elements[i - dif]->setID( i - dif + 1 );
160  }
161  }
162  d_numElements -= dif;
163 
164 }
int d_numElements
Definition: Mesh.hpp:130
Element ** d_elements
Array of all the Elements in the mesh.
Definition: Mesh.hpp:129
blockLoc i
Definition: read.cpp:79
void setID(int theID)
Definition: Element.hpp:100

Here is the call graph for this function:

void removeFace ( Face face)

Definition at line 112 of file Mesh.cpp.

References d_faces, d_numFaces, i, and Face::setID().

112  {
113 
114  int i;
115  int dif = 0;
116  for( i = 0; i < d_numFaces; i++ ){
117  if( d_faces[i] == face ){
118  dif++;
119  continue;
120  }
121  if( dif > 0 ){
122  d_faces[i - dif] = d_faces[i];
123  d_faces[i - dif]->setID( i - dif + 1 );
124  }
125  }
126  d_numFaces -= dif;
127 
128 
129 }
int d_numFaces
Definition: Mesh.hpp:122
Face ** d_faces
1..*
Definition: Mesh.hpp:121
blockLoc i
Definition: read.cpp:79
void setID(int theID)
Sets the serial ID for the face.
Definition: Face.hpp:173

Here is the call graph for this function:

void removeNode ( Node node)

Definition at line 77 of file Mesh.cpp.

References d_nodes, d_numNodes, i, and Node::setID().

77  {
78 
79  int i;
80  int dif = 0;
81  for( i = 0; i < d_numNodes; i++ ){
82  if( d_nodes[i] == node ){
83  dif++;
84  continue;
85  }
86  if( dif > 0 ){
87  d_nodes[i - dif] = d_nodes[i];
88  d_nodes[i - dif]->setID( i - dif + 1 );
89  }
90  }
91  d_numNodes -= dif;
92 
93 }
Node ** d_nodes
An ordered array of all nodes in the mesh.
Definition: Mesh.hpp:105
blockLoc i
Definition: read.cpp:79
int d_numNodes
The number of Nodes in the nodes array.
Definition: Mesh.hpp:110
void setID(int theID)
Definition: Node.hpp:116

Here is the call graph for this function:

void replaceNode ( Node node,
Node new_node,
ElementList sep_elements,
int  new_material 
)

Definition at line 245 of file Mesh.cpp.

References addElement(), ElementList::append(), Face::buildCohesive(), Face::containsNode(), ElementList::get(), FaceList::get(), Face::getElement1(), Face::getElement2(), Element::getFaces(), Element::getNumFaces(), i, ElementList::index(), FaceList::insert_first(), Element::isCohesive(), j, ElementList::move_to(), FaceList::next(), ElementList::next(), Element::replaceFaceNode(), Element::replaceNode(), ElementList::reset(), Element::setMaterialType(), ElementList::size(), and FaceList::size().

Referenced by Node::separate().

246  {
247 
248  // add any cohesives which have one side inside the sep_elements
249 
250  int size = sep_elements->size();
251  //out_faces will ultimately contain the list of faces that form the outside
252  //of the sep_elements group of elements.
253  FaceList out_faces;
254  int i;
255  //for each element in the sep_elements list...
256  for( i = 0; i < size; i++ ) {
257  sep_elements->index(i);
258  Element* elem = sep_elements->get();
259  int numf = elem->getNumFaces();
260  Face** faces = elem->getFaces();
261  int j;
262  //for each face in each element...
263  for( j = 0; j < numf; j++ ){
264  Face* face = faces[j];
265 
266  //see of this face contains the node we're working on...
267  if( !face->containsNode( node ) ){
268  continue; //try next face
269  }
270 
271  //if yes, get the element on the other side of this face...
272  Element* oelem= (face->getElement1() == elem
273  ? face->getElement2()
274  : face->getElement1() );
275 
276  //if its an outside face (no second element), then go to the next face...
277  if( !oelem ){
278  continue;
279  }
280 
281  //if the second element is already on our element list, go to next face...
282  if( sep_elements->move_to( oelem ) ){
283  continue;
284  }
285 
286  //otherwise, if it's a cohesive element on the other side of the face...
287  if( oelem->isCohesive() ) {
288  //get the second face of the cohesive element (first is in "face")
289  Face** cofaces = oelem->getFaces();
290  Face* oface = ( cofaces[0] == face ? cofaces[1] : cofaces[0] );
291  //now get the element that is on the other side of the cohesive element
292  Element* other = (oface->getElement1() == oelem
293  ? oface->getElement2()
294  : oface->getElement1() );
295  //if that other element is already on our list of elements, then append
296  //the first one to the list (it wasn't on our list - we checked above).
297  if( sep_elements->move_to( other ) ) {
298  sep_elements->append( oelem );
299  }
300  else {
301  //otherwise add the face we're working with to the out_faces list.
302  //(if the opposite element does not belong in our element list, then it is
303  //an outside "separator" face)
304  out_faces.insert_first( face );
305  }
306  } // if( oelem->isCohesive() )
307  else { //if the other element is not cohesive, and is not in the sep_elements list,
308  //then it is a boundary.
309  out_faces.insert_first( face );
310  }
311 
312  } //for( j = 0 ...
313  } // for( i = 0 ...
314 
315  int num_out_faces = out_faces.size();
316 
317  //Task: if the face does not belong to a cohesive element, then we have to make one.
318  //Otherwise, we need to replace the node in the current face. Somewhere here there
319  //is a bug right now (8/13/01)
320 
321  //for each face in the out_faces array, get the elements on either side.
322  for( i = 0; i < num_out_faces; i++ ){
323  Face *face = out_faces.get();
324  out_faces.next();
325  Element* e1 = face->getElement1();
326  Element* e2 = face->getElement2();
327  if( !e2 ) { // the sep replacement will handle
328  continue;
329  }
330  //if neither of them are cohesive, add a cohesive element between them.
331  if( !e1->isCohesive() && !e2->isCohesive() ){
332  //elem is used to ensure correct direction of the normals.
333  Element* elem = ( sep_elements->move_to( e1 ) ? e1 : e2 );
334  Element* new_elem = face->buildCohesive( elem, node, new_node );
335  new_elem->setMaterialType( new_material );
336  addElement( new_elem );
337  }
338  else if( e1->isCohesive() ){ // e2 is in sep
339  e1->replaceFaceNode( node, new_node, face );
340  }
341  else {
342  e2->replaceFaceNode( node, new_node, face );
343  }
344  }
345 
346  // go and replace in all the elements
347  // including inside the faces
348  //replace nodes in the elements in the sep_element list. Bug may be here as well.
349  sep_elements->reset();
350  size = sep_elements->size();
351  for( i = 0; i < size; i++ ){
352 
353  sep_elements->get()->replaceNode( node, new_node );
354  sep_elements->next();
355  }
356 }
virtual void replaceFaceNode(Node *node, Node *new_node, Face *face)
Definition: Element.cpp:168
Definition: face.h:90
Element * get()
Definition: ElementList.hpp:87
void replaceNode(Node *node, Node *new_node)
Definition: Element.cpp:138
void setMaterialType(int mtype)
Definition: Element.hpp:121
Element * getElement2()
Get the pointer to the second element that this face is associated with.
Definition: Face.hpp:197
virtual int getNumFaces() const =0
void reset()
Definition: ElementList.hpp:76
int size()
Definition: FaceList.hpp:95
boolean containsNode(Node *node) const
Definition: Face.cpp:108
void addElement(Element *element)
Definition: Mesh.cpp:131
Face ** getFaces()
Definition: Element.hpp:106
virtual Element * buildCohesive(Element *side_elem, Node *node, Node *new_node)=0
void next()
Definition: FaceList.hpp:80
blockLoc i
Definition: read.cpp:79
int index() const
boolean isCohesive() const
Definition: Element.hpp:112
j indices j
Definition: Indexing.h:6
Face * get()
Definition: FaceList.hpp:87
boolean move_to(Element *val)
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
Element * getElement1()
Get the pointer to the first element that this face is associated with.
Definition: Face.hpp:191
void append(Element *val)
Definition: ElementList.cpp:58
void insert_first(Face *val)
Definition: FaceList.hpp:69

Here is the call graph for this function:

Here is the caller graph for this function:

void setMinEdge ( double  me)
inlineprivate

Definition at line 158 of file Mesh.hpp.

References minEdge.

Referenced by operator>>().

159 { minEdge = me ; }
double minEdge
Definition: Mesh.hpp:133

Here is the caller graph for this function:

void write_boundary ( ostream &  stream)

Definition at line 507 of file Mesh.cpp.

References d_faces, d_numFaces, Face::getElement1(), Element::getFaces(), Face::getFlag(), Element::getID(), Element::getNumFaces(), i, and j.

507  {
508 
509  int count = 0;
510  int i;
511  for( i = 0; i < d_numFaces; i++ ){
512  if( d_faces[i]->isExterior() ){
513  count++;
514  }
515  }
516  stream << count << endl;
517 
518  for( i = 0; i < d_numFaces; i++ ){
519  if( d_faces[i]->isExterior() ){
520  Element* e1 = d_faces[i]->getElement1();
521  stream << e1->getID() << '\t';
522  int numf = e1->getNumFaces();
523  Face** efaces = e1->getFaces();
524  int j;
525  for( j = 0; j < numf; j++ ){
526  if( d_faces[i] == efaces[j] ){
527  stream << j + 1 << '\t' << d_faces[i]->getFlag() << endl;
528  break;
529  }
530  }
531  }
532  }
533 }
int d_numFaces
Definition: Mesh.hpp:122
Face ** d_faces
1..*
Definition: Mesh.hpp:121
int getFlag() const
Gets the flag for the face.
Definition: Face.hpp:182
virtual int getNumFaces() const =0
Face ** getFaces()
Definition: Element.hpp:106
blockLoc i
Definition: read.cpp:79
int getID() const
Definition: Element.hpp:97
j indices j
Definition: Indexing.h:6
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
Element * getElement1()
Get the pointer to the first element that this face is associated with.
Definition: Face.hpp:191

Here is the call graph for this function:

Friends And Related Function Documentation

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

The mesh ostream operator is used to drive the writing of both output fils from the code.

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.

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
istream& operator>> ( istream &  stream,
Mesh mesh 
)
friend

The mesh instream operator is used to drive the reading of the one input file to the code.

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.

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.

Member Data Documentation

int d_elementArraySize
private

Definition at line 131 of file Mesh.hpp.

Referenced by addElement(), and operator>>().

Element** d_elements
private

Array of all the Elements in the mesh.

1..*

Definition at line 129 of file Mesh.hpp.

Referenced by addElement(), calcEdgeLength(), getElement(), operator<<(), operator>>(), removeElement(), and ~Mesh().

int d_faceArraySize
private

Definition at line 123 of file Mesh.hpp.

Referenced by addFace(), and operator>>().

Face** d_faces
private

1..*

Definition at line 121 of file Mesh.hpp.

Referenced by addCohesive(), addFace(), getFace(), operator>>(), removeFace(), write_boundary(), and ~Mesh().

int d_nodeArraySize
private

The current size of the nodes array (must be as big or bigger than numNodes).

Used for dynamic allocation of space for the array.

Definition at line 116 of file Mesh.hpp.

Referenced by addNode(), and operator>>().

Node** d_nodes
private

An ordered array of all nodes in the mesh.

The index of each Node in the array is also stored as the ID in the Node object. 1..*

Definition at line 105 of file Mesh.hpp.

Referenced by addNode(), getNode(), operator<<(), operator>>(), removeNode(), and ~Mesh().

int d_numElements
private

Definition at line 130 of file Mesh.hpp.

Referenced by addElement(), getNumElements(), operator<<(), operator>>(), removeElement(), and ~Mesh().

int d_numFaces
private

Definition at line 122 of file Mesh.hpp.

Referenced by addCohesive(), addFace(), getNumFaces(), removeFace(), write_boundary(), and ~Mesh().

int d_numNodes
private

The number of Nodes in the nodes array.

Definition at line 110 of file Mesh.hpp.

Referenced by addNode(), getNumNodes(), operator<<(), operator>>(), removeNode(), and ~Mesh().

const double HTOL = 1.0 + TOL

Definition at line 55 of file Mesh.H.

const double LTOL = 0.0 - TOL

Definition at line 54 of file Mesh.H.

double minEdge
private

Definition at line 133 of file Mesh.hpp.

Referenced by getMinEdge(), Mesh(), and setMinEdge().

const double TOL = 1e-9

Definition at line 53 of file Mesh.H.


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