Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mesh/MeshImplData.cpp
Go to the documentation of this file.
1 /* *****************************************************************
2  MESQUITE -- The Mesh Quality Improvement Toolkit
3 
4  Copyright 2004 Lawrence Livermore National Laboratory. Under
5  the terms of Contract B545069 with the University of Wisconsin --
6  Madison, Lawrence Livermore National Laboratory retains certain
7  rights in this software.
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  (lgpl.txt) along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 
23  kraftche@cae.wisc.edu
24 
25  ***************************************************************** */
26 
27 #include "MeshImplData.hpp"
28 #include "TopologyInfo.hpp"
29 #include "MsqError.hpp"
30 
31 // NOTE: If this is defined, the normal vertex query functions
32 // will not return mid-nodes.
33 #undef SEPARATE_MID_NODES
34 
35 namespace Mesquite {
36 
37 const msq_std::vector<size_t> dummy_list;
39 
41 {
42  size_t count = 0;
43  for (msq_std::vector<Vertex>::const_iterator iter = vertexList.begin();
44  iter != vertexList.end(); ++iter)
45 #ifdef SEPARATE_MID_NODES
46  if (iter->valid && iter->midcount < iter->adjacencies.size())
47 #else
48  if (iter->valid)
49 #endif
50  ++count;
51  return count;
52 }
53 
55  { return elementList.size() - deletedElementList.size(); }
56 
58 {
59  size_t result = 0;
60  for (msq_std::vector<Element>::const_iterator iter = elementList.begin();
61  iter != elementList.end(); ++iter)
62  {
63 #ifdef SEPARATE_MID_NODES
64  unsigned from_topo = TopologyInfo::corners( iter->topology );
65  result += from_topo ? from_topo : iter->connectivity.size();
66 #else
67  result += iter->connectivity.size();
68 #endif
69  }
70  return result;
71 }
72 
73 const Vector3D& MeshImplData::get_vertex_coords( size_t index, MsqError& err ) const
74 {
75  if (!is_vertex_valid( index ))
76  {
77  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
78  return dummy_vtx;
79  }
80 
81  return vertexList[index].coords;
82 }
83 
84 bool MeshImplData::vertex_is_fixed( size_t index, MsqError& err ) const
85 {
86  if (!is_vertex_valid( index ))
87  {
88  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
89  return false;
90  }
91 
92  return vertexList[index].fixed;
93 }
94 
95 void MeshImplData::fix_vertex( size_t index, bool flag, MsqError& err )
96 {
97  if (!is_vertex_valid( index ))
98  {
99  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
100  return;
101  }
102 
103  vertexList[index].fixed = flag;
104 }
105 
106 
107 unsigned char MeshImplData::get_vertex_byte( size_t index, MsqError& err ) const
108 {
109  if (!is_vertex_valid( index ))
110  {
111  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
112  return 0;
113  }
114 
115  return vertexList[index].byte;
116 }
117 
118 void MeshImplData::set_vertex_byte( size_t index, unsigned char value, MsqError& err )
119 {
120  if (!is_vertex_valid( index ))
121  {
122  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
123  return;
124  }
125 
126  vertexList[index].byte = value;
127 }
128 
130 {
131  if (!is_element_valid( index ))
132  {
133  MSQ_SETERR(err)("Invalid element handle", MsqError::INVALID_ARG);
134  return MIXED;
135  }
136 
137  return elementList[index].topology;
138 }
139 
141 {
142  if (!is_element_valid( index ))
143  {
144  MSQ_SETERR(err)("Invalid element handle", MsqError::INVALID_ARG);
145  return ;
146  }
147 
148  unsigned i, numvert;
149 
150  numvert = TopologyInfo::corners( elementList[index].topology );
151  if (numvert)
152  for (i = numvert; i < elementList[index].connectivity.size(); ++i)
153  --vertexList[elementList[index].connectivity[i]].midcount;
154 
155  elementList[index].topology = type;
156 
157  numvert = TopologyInfo::corners( elementList[index].topology );
158  if (numvert)
159  for (i = numvert; i < elementList[index].connectivity.size(); ++i)
160  ++vertexList[elementList[index].connectivity[i]].midcount;
161 }
162 
163 
164 const msq_std::vector<size_t>& MeshImplData::element_connectivity( size_t index, MsqError& err ) const
165 {
166  if (!is_element_valid( index ))
167  {
168  MSQ_SETERR(err)("Invalid element handle", MsqError::INVALID_ARG);
169  return dummy_list;
170  }
171 
172  return elementList[index].connectivity;
173 }
174 
175 const msq_std::vector<size_t>& MeshImplData::vertex_adjacencies( size_t index, MsqError& err ) const
176 {
177  if (!is_vertex_valid( index ))
178  {
179  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
180  return dummy_list;
181  }
182 
183  return vertexList[index].adjacencies;
184 }
185 
187 {
188  vertexList.clear();
189  elementList.clear();
190  deletedVertexList.clear();
191  deletedElementList.clear();
192 }
193 
194 void MeshImplData::allocate_vertices( size_t count, MsqError& err )
195 {
196  if (vertexList.size())
197  {
199  return;
200  }
201 
202  vertexList.resize(count);
203 }
204 
205 void MeshImplData::allocate_elements( size_t count, MsqError& err )
206 {
207  if (elementList.size())
208  {
210  return;
211  }
212 
213  elementList.resize( count );
214 }
215 
217  const Vector3D& coords,
218  MsqError& err )
219 {
220  if (!is_vertex_valid( index ))
221  {
222  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
223  return;
224  }
225 
226  vertexList[index].coords = coords;
227 }
228 
229 void MeshImplData::reset_vertex( size_t index,
230  const Vector3D& coords,
231  bool fixed,
232  MsqError& err )
233 {
234  if (index >= vertexList.size())
235  {
236  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
237  return;
238  }
239 
240  Vertex& vert = vertexList[index];
241 
242  if (!vert.adjacencies.empty())
243  {
244  MSQ_SETERR(err)("Cannot overwrite referenced vertex", MsqError::INVALID_STATE);
245  return;
246  }
247 
248  vert.coords = coords;
249  vert.fixed = fixed;
250  vert.valid = true;
251 }
252 
253 void MeshImplData::reset_element( size_t index,
254  const msq_std::vector<size_t>& vertices,
255  EntityTopology topology,
256  MsqError& err )
257 {
258  clear_element( index, err ); MSQ_ERRRTN(err);
259  set_element( index, vertices, topology, err ); MSQ_ERRRTN(err);
260 }
261 
262 
263 void MeshImplData::clear_element( size_t index, MsqError& err )
264 {
265  if (index >= elementList.size())
266  {
267  MSQ_SETERR(err)("Invalid element handle", MsqError::INVALID_ARG);
268  return;
269  }
270 
271  unsigned numvert = TopologyInfo::corners( elementList[index].topology );
272  if (numvert)
273  for (unsigned i = numvert; i < elementList[index].connectivity.size(); ++i)
274  --vertexList[elementList[index].connectivity[i]].midcount;
275 
276  msq_std::vector<size_t>& conn = elementList[index].connectivity;
277  for (msq_std::vector<size_t>::iterator iter = conn.begin();
278  iter != conn.end(); ++iter)
279  {
280  msq_std::vector<size_t>& adj = vertexList[*iter].adjacencies;
281  for (msq_std::vector<size_t>::iterator iter2 = adj.begin();
282  iter2 != adj.end(); ++iter2)
283  {
284  if (*iter2 == index)
285  {
286  adj.erase(iter2);
287  break;
288  }
289  }
290  }
291  conn.clear();
292 }
293 
294 void MeshImplData::set_element( size_t index,
295  const msq_std::vector<size_t>& vertices,
296  EntityTopology topology,
297  MsqError& err )
298 {
299  if (index >= elementList.size())
300  {
301  MSQ_SETERR(err)("Invalid element handle", MsqError::INVALID_ARG);
302  return;
303  }
304 
305  msq_std::vector<size_t>& conn = elementList[index].connectivity;
306  conn = vertices;
307  elementList[index].topology = topology;
308 
309  for (msq_std::vector<size_t>::iterator iter = conn.begin();
310  iter != conn.end(); ++iter)
311  {
312  if (!is_vertex_valid( *iter ))
313  {
314  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
315  return;
316  }
317 
318  msq_std::vector<size_t>& adj = vertexList[*iter].adjacencies;
319  for (msq_std::vector<size_t>::iterator iter2 = adj.begin();
320  iter2 != adj.end(); ++iter2)
321  if (*iter2 == index)
322  return;
323 
324  adj.push_back( index );
325  }
326 
327  unsigned numvert = TopologyInfo::corners( elementList[index].topology );
328  if (numvert)
329  for (unsigned i = numvert; i < elementList[index].connectivity.size(); ++i)
330  ++vertexList[elementList[index].connectivity[i]].midcount;
331 }
332 
333 size_t MeshImplData::add_vertex( const Vector3D& coords, bool fixed, MsqError& err )
334 {
335  size_t index;
336 
337  if (!deletedVertexList.empty())
338  {
339  index = deletedVertexList[deletedVertexList.size()-1];
340  deletedVertexList.pop_back();
341  reset_vertex( index, coords, fixed, err ); MSQ_ERRZERO(err);
342  }
343  else
344  {
345  index = vertexList.size();
346  vertexList.push_back( Vertex(coords, fixed ) );
347  }
348 
349  return index;
350 }
351 
352 size_t MeshImplData::add_element( const msq_std::vector<size_t>& vertices,
353  EntityTopology topology,
354  MsqError& err )
355 {
356  size_t index;
357  if (!deletedElementList.empty())
358  {
359  index = deletedElementList[deletedElementList.size()-1];
360  deletedElementList.pop_back();
361  }
362  else
363  {
364  index = elementList.size();
365  elementList.resize( elementList.size() + 1 );
366  }
367 
368  set_element( index, vertices, topology, err ); MSQ_ERRZERO(err);
369  return index;
370 }
371 
372 void MeshImplData::delete_vertex( size_t index, MsqError& err )
373 {
374  if (!is_vertex_valid( index ))
375  {
376  MSQ_SETERR(err)("Invalid vertex handle", MsqError::INVALID_ARG);
377  return;
378  }
379 
380  vertexList[index].valid = false;
381  deletedVertexList.push_back( index );
382 }
383 
384 void MeshImplData::delete_element( size_t index, MsqError& err )
385 {
386  clear_element( index, err ); MSQ_ERRRTN(err);
387  deletedElementList.push_back( index );
388 }
389 
390 void MeshImplData::copy_mesh( size_t* vertex_handle_array,
391  size_t* element_handle_array,
392  size_t* element_conn_offsets,
393  size_t* element_conn_indices )
394 {
395  msq_std::vector<size_t> vertex_map( vertexList.size() );
396  size_t vh_index = 0;
397  for (size_t v = 0; v < vertexList.size(); ++v)
398  {
399  if (vertexList[v].valid
400 #ifdef SEPARATE_MID_NODES
401  && vertexList[v].midcount < vertexList[v].adjacencies.size()
402 #endif
403  )
404  {
405  vertex_handle_array[vh_index] = v;
406  vertex_map[v] = vh_index;
407  ++vh_index;
408  }
409  else
410  {
411  vertex_map[v] = vertexList.size();
412  }
413  }
414 
415  size_t offset = 0;
416  for (size_t e = 0; e < elementList.size(); ++e)
417  {
418  Element& elem = elementList[e];
419  size_t cl;
420 #ifdef SEPARATE_MID_NODES
421  cl = TopologyInfo::corners( elem.topology );
422  if (!cl)
423 #endif
424  cl = elem.connectivity.size();
425  if (cl)
426  {
427  *element_handle_array = e;
428  ++element_handle_array;
429 
430  *element_conn_offsets = offset;
431  ++element_conn_offsets;
432  offset += cl;
433 
434  msq_std::vector<size_t>::iterator conn = elem.connectivity.begin();
435  msq_std::vector<size_t>::iterator end = conn + cl;
436  while (conn != end)
437  {
438  *element_conn_indices = vertex_map[*conn];
439  ++element_conn_indices;
440  ++conn;
441  }
442  }
443  }
444  *element_conn_offsets = offset;
445 }
446 
447 void MeshImplData::copy_higher_order( msq_std::vector<size_t>& mid_nodes,
448  msq_std::vector<size_t>& vertices,
449  msq_std::vector<size_t>& vertex_indices,
450  msq_std::vector<size_t>& index_offsets,
451  MsqError& err )
452 {
453  mid_nodes.clear();
454  vertices.clear();
455  vertex_indices.clear();
456  index_offsets.clear();
457 
458  // Create a map of from vertex handle to index in "vertices"
459  // Use vertexList.size() to mean uninitialized.
460  size_t v;
461  msq_std::vector<size_t> vert_map( vertexList.size() );
462  for (v = 0; v < vertexList.size(); ++v)
463  vert_map[v] = vertexList.size();
464 
465  // Loop over all mid-side vertices
466  for (v = 0; v < vertexList.size(); ++v)
467  {
468  const Vertex& vert = vertexList[v];
469 
470  // Not a mid-side vertex, skip it
471  if (!vert.valid || !vert.midcount)
472  continue;
473 
474  // Populate "verts" with the handles of all adjacent corner vertices
475  assert( vert.adjacencies.size() ); // shouldn't be able to fail if vert.midcount > 0
476  int elem_indx = vert.adjacencies[0];
477  Element& elem = elementList[elem_indx];
478 
479  // Find index of node in elem's connectivity list
480  unsigned index;
481  for (index = 0; index < elem.connectivity.size(); ++index)
482  if (elem.connectivity[index] == v)
483  break;
484  if (index == elem.connectivity.size())
485  {
486  MSQ_SETERR(err)("Inconsistent data.", MsqError::INTERNAL_ERROR);
487  return;
488  }
489 
490  // Given the index in the element's connectivity list,
491  // get the side of the element containing the mid-node.
492  unsigned side_dim, side_num;
494  index, side_dim, side_num, err ); MSQ_ERRRTN(err);
495 
496  if (!side_dim) // Not a mid-side node
497  {
498  MSQ_SETERR(err)(MsqError::INVALID_STATE,"Improperly connected mesh.");
499  return;
500  }
501 
502  // Get the adjacent corner vertices from the element side.
503  unsigned num_corners;
504  const unsigned* corner_indices = TopologyInfo::side_vertices(
505  elem.topology, side_dim, side_num, num_corners, err ); MSQ_ERRRTN(err);
506 
507  // Add the mid-side node to the output list
508  mid_nodes.push_back( v );
509  // Store offset at which the indices of the corner
510  // vertices adjacent to this mid-side node will be
511  // stored in "vertex_indices".
512  index_offsets.push_back( vertex_indices.size() );
513  // For each adjacent corner vertex, if the vertex is not
514  // already in "vertices" add it, and add the index to
515  // the adjacency list for this mid-side node.
516  for (unsigned i = 0; i < num_corners; ++i)
517  {
518  size_t vert_idx = elem.connectivity[corner_indices[i]];
519  assert( is_vertex_valid(vert_idx) );
520 
521  if (vert_map[vert_idx] == vertexList.size())
522  {
523  vert_map[vert_idx] = vertices.size();
524  vertices.push_back( vert_idx );
525  }
526  vertex_indices.push_back( vert_map[vert_idx] );
527  }
528  }
529  index_offsets.push_back( vertex_indices.size() );
530 }
531 
532 bool MeshImplData::is_mid_node( size_t index ) const
533 {
534  return is_vertex_valid(index) && vertexList[index].midcount > 0;
535 }
536 
537 bool MeshImplData::is_corner_node( size_t index ) const
538 {
539  return is_vertex_valid(index) && vertexList[index].midcount < vertexList[index].adjacencies.size();
540 }
541 
542 
543 
544 void MeshImplData::all_vertices( msq_std::vector<size_t>& list, MsqError& ) const
545 {
546  list.clear();
547  for (size_t idx = 0; idx < vertexList.size(); ++idx)
548  if (vertexList[idx].valid)
549  list.push_back( idx );
550 }
551 
552 void MeshImplData::all_elements( msq_std::vector<size_t>& list, MsqError& err ) const
553 {
554  list.clear();
555  for (size_t idx = 0; idx < elementList.size(); ++idx)
556  if (!elementList[idx].connectivity.empty())
557  list.push_back( idx );
558 }
559 
561  msq_std::vector<size_t>::const_iterator node_iter,
562  msq_std::vector<size_t>::const_iterator node_end,
563  msq_std::vector<size_t>& elems, MsqError& err )
564 {
565  if (node_iter == node_end || !is_vertex_valid( *node_iter ))
566  {
568  return;
569  }
570 
571  // Get list of elements adjacent to first node
572  elems = vertexList[*node_iter].adjacencies;
573 
574  // For each aditional node, intersect elems with elements adjacent to node
575  for (++node_iter; node_iter != node_end; ++node_iter)
576  {
577  msq_std::vector<size_t>::iterator elem_iter = elems.begin();
578  while (elem_iter != elems.end())
579  {
580  msq_std::vector<size_t>::const_iterator adj_iter = vertexList[*node_iter].adjacencies.begin();
581  const msq_std::vector<size_t>::const_iterator adj_end = vertexList[*node_iter].adjacencies.end();
582  for (; adj_iter != adj_end; ++adj_iter)
583  if (*elem_iter == *adj_iter)
584  break;
585 
586  if (adj_iter == adj_end)
587  {
588  *elem_iter = elems[elems.size()-1];
589  elems.pop_back();
590  }
591  else
592  {
593  ++elem_iter;
594  }
595  }
596  }
597 }
598 
600  size_t elem,
601  const msq_std::vector<size_t>& nodes,
602  MsqError& err )
603 {
604  msq_std::vector<size_t> adj_elems;
605  const unsigned dim = TopologyInfo::dimension( elementList[elem].topology );
606  get_adjacent_elements( nodes.begin(), nodes.end(), adj_elems, err );
607 
608  msq_std::vector<size_t>::iterator iter;
609  for (iter = adj_elems.begin(); iter != adj_elems.end(); ++iter)
610  if (*iter != elem &&
611  TopologyInfo::dimension( elementList[*iter].topology ) == dim )
612  break;
613 
614  return iter != adj_elems.end();
615 }
616 
617 void MeshImplData::skin( msq_std::vector<size_t>& sides, MsqError& err )
618 {
619  msq_std::vector<size_t> side_nodes;
620 
621  // For each element in mesh
622  for (size_t elem = 0; elem < elementList.size(); ++elem)
623  {
624  if (!is_element_valid(elem))
625  continue;
626 
627  // For each side of the element, check if there
628  // are any adjacent elements.
629  const EntityTopology topo = elementList[elem].topology;
630  msq_std::vector<size_t>& conn = elementList[elem].connectivity;
631  switch (topo)
632  {
633  // For normal elements (not poly****)
634  default:
635  {
636  unsigned num = TopologyInfo::sides( topo );
637  unsigned dim = TopologyInfo::dimension( topo ) - 1;
638  // For each side
639  for (unsigned side = 0; side < num; ++side)
640  {
641  // Get list of vertices defining the side
642  unsigned count;
643  const unsigned* indices = TopologyInfo::side_vertices( topo, dim, side, count, err );
644  MSQ_ERRRTN(err);
645  side_nodes.clear();
646  for (unsigned k = 0; k < count; ++k)
647  side_nodes.push_back( conn[indices[k]] );
648 
649  // If no adjacent element, add side to output list
650  bool adj = has_adjacent_elements( elem, side_nodes, err );
651  MSQ_ERRRTN(err);
652  if ( !adj )
653  {
654  sides.push_back( elem );
655  sides.push_back( side );
656  }
657  }
658  }
659  break;
660 
661  case POLYGON:
662  {
663  for (unsigned side = 0, next = 1; next < conn.size(); ++side, ++next)
664  {
665  side_nodes.clear();
666  side_nodes.push_back( conn[side] );
667  side_nodes.push_back( conn[next] );
668 
669  // If no adjacent element, add side to output list
670  bool adj = has_adjacent_elements( elem, side_nodes, err );
671  MSQ_ERRRTN(err);
672  if ( !adj )
673  {
674  sides.push_back( elem );
675  sides.push_back( side );
676  }
677  }
678  }
679  break;
680 
681  case POLYHEDRON:
682  {
683  for (unsigned side = 0; side < conn.size(); ++side)
684  {
685  side_nodes = elementList[conn[side]].connectivity;
686 
687  // If no adjacent element, add side to output list
688  bool adj = has_adjacent_elements( elem, side_nodes, err );
689  MSQ_ERRRTN(err);
690  if ( !adj )
691  {
692  sides.push_back( elem );
693  sides.push_back( side );
694  }
695  }
696  }
697  break;
698  } // switch(topo)
699  } // for (elementList)
700 }
701 
702 
704  {}
705 
707 {
708  index = 0;
709  if (!mesh->is_vertex_valid( index ))
710  operator++();
711 }
712 
714 {
715  ++index;
716  while (index < mesh->max_vertex_index() &&
717  (!mesh->is_vertex_valid(index) ||
719  ++index;
720 }
721 
723 {
724  return reinterpret_cast<Mesh::VertexHandle>(index);
725 }
726 
728 {
729  return index >= mesh->max_vertex_index();
730 }
731 
732 
733 
735  {}
736 
738 {
739  index = 0;
740  if (!mesh->is_element_valid( index ))
741  operator++();
742 }
743 
745 {
746  ++index;
747  while (index < mesh->max_element_index() && !mesh->is_element_valid(index))
748  ++index;
749 }
750 
752 {
753  return reinterpret_cast<Mesh::ElementHandle>(index);
754 }
755 
757 {
758  return index >= mesh->max_element_index();
759 }
760 
761 
762 
763 } // namespace Mesquite
764 
765 
unsigned char get_vertex_byte(size_t index, MsqError &err) const
Get vertex byte.
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
void all_elements(msq_std::vector< size_t > &list, MsqError &err) const
Get all elements.
void fix_vertex(size_t index, bool flag, MsqError &err)
Set vertex fixed flag.
j indices k indices k
Definition: Indexing.h:6
Used to hold the error state and return it to the application.
virtual bool is_at_end() const
Returns false until the iterator has been advanced PAST the last entity.
EntityTopology
Definition: Mesquite.hpp:92
virtual void operator++()
++iterator
void copy_higher_order(msq_std::vector< size_t > &mid_nodes, msq_std::vector< size_t > &vertices, msq_std::vector< size_t > &vertex_indices, msq_std::vector< size_t > &index_offsets, MsqError &err)
Get all mid-nodes and their adjacent corner vertices.
virtual Mesh::VertexHandle operator*() const
*iterator.
const msq_std::vector< size_t > & element_connectivity(size_t index, MsqError &err) const
Get element connectivity list, including mid-nodes.
msq_std::vector< Element > elementList
Array of elements.
EntityHandle VertexHandle
size_t num_vertices() const
Get number of vertices, does not include mid-nodes.
EntityHandle ElementHandle
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
unsigned midcount
num elements referencing this as a mid-node
void get_adjacent_elements(msq_std::vector< size_t >::const_iterator nodes, msq_std::vector< size_t >::const_iterator nodes_end, msq_std::vector< size_t > &elems_out, MsqError &err)
Get elements adjacent to ALL of the passed nodes.
void reset_element(size_t index, const msq_std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)
Clear element at specified index (if any) including connectivity and adjacency data, and re-initialize with passed data.
real *8 function offset(vNorm, x2, y2, z2)
Definition: PlaneNorm.f90:211
msq_std::vector< size_t > deletedElementList
List of unused indices in element list.
virtual void operator++()
++iterator
void allocate_vertices(size_t count, MsqError &err)
Allocate space for specified number of vertices.
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
size_t add_vertex(const Vector3D &coords, bool fixed, MsqError &err)
Add a new vertex.
static unsigned sides(EntityTopology topo)
Get number of sides a given topology type has.
void clear()
Clear all data.
virtual void restart()
Moves the iterator back to the first entity in the list.
bool has_adjacent_elements(size_t elem, const msq_std::vector< size_t > &nodes, MsqError &err)
helper function for skinning
EntityTopology element_topology(size_t index, MsqError &err) const
Get element type.
invalid function argument passed
const msq_std::vector< size_t > & vertex_adjacencies(size_t index, MsqError &err) const
Get vertex adjacency list.
static unsigned dimension(EntityTopology topo)
Dimension of element topology.
const msq_std::vector< size_t > dummy_list
void skin(msq_std::vector< size_t > &sides, MsqError &err)
Skin mesh.
virtual Mesh::ElementHandle operator*() const
*iterator.
virtual bool is_at_end() const
Returns false until the iterator has been advanced PAST the last entity.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
static unsigned corners(EntityTopology topo)
Get the number of defining vertices for a given element topology.
void set_vertex_coords(size_t index, const Vector3D &coords, MsqError &err)
Set vertex coordinates.
msq_std::vector< size_t > deletedVertexList
List of unused indices in vertex list.
bool is_vertex_valid(size_t index) const
Check if passed vertex index is valid.
blockLoc i
Definition: read.cpp:79
const Vector3D dummy_vtx
bool valid
is a valid (initialized) array entry
size_t add_element(const msq_std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)
Add a new element.
const Vector3D & get_vertex_coords(size_t index, MsqError &err) const
Get vertex coordinates.
msq_std::vector< size_t > adjacencies
indices of adjacent elements
void set_vertex_byte(size_t index, unsigned char value, MsqError &err)
Set vertex byte.
static const unsigned * side_vertices(EntityTopology topo, unsigned side_dimension, unsigned side_number, unsigned &num_verts_out, MsqError &err)
Get corner indices of side.
bool vertex_is_fixed(size_t index, MsqError &err) const
Get vertex fixed flag.
msq_std::vector< size_t > connectivity
list of vertex indices
virtual void restart()
Moves the iterator back to the first entity in the list.
void delete_vertex(size_t index, MsqError &err)
Delete a vertex - may not be referenced by any element.
object is in an invalid state
bool is_mid_node(size_t index) const
Check if the specified node is used as a mid-node on any element.
void allocate_elements(size_t count, MsqError &err)
Allocate space for specified number of elements.
void reset_vertex(size_t index, const Vector3D &coords, bool fixed, MsqError &err)
Set allocated but unset veretx to specified values.
void copy_mesh(size_t *vertex_handle_array, size_t *element_hanlde_array, size_t *element_conn_offsets, size_t *element_conn_indices)
Copy internal representation into CSR rep Does not include mid-nodes.
void all_vertices(msq_std::vector< size_t > &list, MsqError &err) const
Get all vertices, including mid-nodes.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
msq_std::vector< Vertex > vertexList
Array of vertices.
void clear_element(size_t index, MsqError &err)
Clear existing element data.
size_t num_vertex_uses() const
Get number of vertex uses (sum of connectivity length for all elements) Does not count mid-nodes...
void set_element(size_t index, const msq_std::vector< size_t > &vertices, EntityTopology topology, MsqError &err)
Set cleared element.
void delete_element(size_t index, MsqError &err)
Delete an element.
static void side_number(EntityTopology topo, unsigned connectivity_length, unsigned node_index, unsigned &side_dimension_out, unsigned &side_number_out, MsqError &err)
Return which side the specified mid-node lies on.
bool is_corner_node(size_t index) const
Check if the specified node is used as a corner vertex on any element.
bool is_element_valid(size_t index) const
Check if passed element index is valid.
size_t num_elements() const
Get number of elements.