Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mesh/MeshSet.cpp
Go to the documentation of this file.
1 /* *****************************************************************
2  MESQUITE -- The Mesh Quality Improvement Toolkit
3 
4  Copyright 2004 Sandia Corporation and Argonne National
5  Laboratory. Under the terms of Contract DE-AC04-94AL85000
6  with Sandia Corporation, the U.S. Government 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  diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
24  pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
25 
26  ***************************************************************** */
27 // -*- Mode : c++; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 2 -*-
28 //
29 // SUMMARY:
30 // USAGE:
31 //
32 // ORIG-DATE: 16-May-02 at 10:26:21
33 // LAST-MOD: 22-Jun-04 at 14:31:34 by Thomas Leurent
34 //
45 #include "Mesquite.hpp"
46 #include "MeshSet.hpp"
47 #include "QualityImprover.hpp"
48 #include "MsqError.hpp"
49 #include "MsqDebug.hpp"
50 #include "TopologyInfo.hpp"
51 
52 #ifdef MSQ_USE_OLD_IO_HEADERS
53 #include <fstream.h>
54 #include <string.h>
55 #include <iomanip.h>
56 #else
57 #include <fstream>
58 #include <string>
59 #include <iomanip>
60 using namespace std;
61 #endif
62 
63 namespace Mesquite {
64 
65 MeshSet::MeshSet() :
66  vertexIterator(NULL),
67  spaceDim(0),
68  csrOffsets(0),
69 // csrData(0),
70 // vertArray(NULL),
71 // elemArray(NULL),
72  elemTopologies(0),
73  vertexOnBoundary(0),
74  csrOffsetsSize(0),
75 // csrDataSize(0),
76  vertArraySize(0),
77  elemArraySize(0),
78  mDomain(NULL)
79 {
81 }
82 
84 {
85  // Delete the vertex iterator
86  delete vertexIterator;
87  // Release all of our meshes
88  list<Mesquite::Mesh*>::iterator it = meshSet.begin();
89  while(!(it == meshSet.end()))
90  (*it++)->release();
91 
92  // Delete cache arrays
93  delete [] csrOffsets;
94 // delete [] csrData;
95 // delete [] vertArray;
96 // delete [] elemArray;
97  delete [] elemTopologies;
98  delete [] vertexOnBoundary;
99 }
100 
101 
109 {
110  // sets MeshSet::SpaceDim
111  int dim = mesh->get_geometric_dimension(err); MSQ_ERRRTN(err);
112  if (spaceDim == 0)
113  spaceDim = dim;
114  else if (dim != spaceDim)
115  {
116  MSQ_SETERR(err)( "Meshes of different dimensions added to the same MeshSet.",
118  return;
119  }
120 
121  // adds the Mesh* to the MeshSet.
122  meshSet.push_front(mesh);
123 }
124 
125 
132 {
133  // If we have at least one mesh...
134  if (meshSet.size())
135  {
136  // If we aren't already on the first mesh...
137  if (!vertexIterator || !(currentMesh == meshSet.begin()))
138  {
139  currentMesh = meshSet.begin();
140  delete vertexIterator;
141  vertexIterator = (*currentMesh)->vertex_iterator(err); MSQ_ERRRTN(err);
142  }
143  else // We ARE on the first mesh...
144  {
145  // ...so we can re-use the iterator.
147  }
148  }
149  else
150  {
151  // This is probably redundant...
152  vertexIterator = NULL;
153  }
154 }
155 
156 
158 {
159  mDomain = domain;
160 }
161 
162 
163 
176  PatchDataParameters &pd_params,
177  MsqError &err )
178 {
179  MSQ_FUNCTION_TIMER( "MeshSet::get_next_patch" );
180 
181  // get rid of previous Patch information (but keep memory allocated).
182  pd.clear();
183 
184  // Mark this MeshSet as the originator
185  pd.meshSet = this;
186  pd.domainSet = (mDomain != NULL);
187 
188  bool result = false;
189  switch (pd_params.get_patch_type())
190  {
192  result = get_next_elem_on_vert_patch( pd, pd_params, err );
193  break;
195  result = get_next_global_patch( pd, pd_params, err );
196  break;
197  default:
198  MSQ_SETERR(err)( "no implementation for specified patch type.",
200  result = false;
201  break;
202  }
203 
204  return !MSQ_CHKERR(err) && result;
205 }
206 
207 
209  PatchDataParameters &pd_params,
210  MsqError& err )
211 {
212  size_t i;
213 
214  // Get the patch parameters.
215  long unsigned int culling_method_bits = pd_params.get_culling_method_bits();
216 
217  //variable to store the center vertex's fixed flag
218  MsqVertex::FlagMask center_fixed_byte;
219  // Make sure we're only getting a patch depth of 1
220  int num_layers = pd_params.get_nb_layers(err);
221  if (MSQ_CHKERR(err)) return false;
222 
223  if ((unsigned)num_layers > (unsigned)1)
224  {
225  MSQ_SETERR(err)( "no implementation for patch depth > 1.",
227  return false;
228  }
229 
230  // Set the patch type
233  if (mDomain)
234  pd.domainHint = mDomain->hint();
235 
236  // If this is our first time through the mesh,
237  // initialize everything.
238  if (!vertexIterator)
239  {
240  reset(err);
241  if (MSQ_CHKERR(err)) return false;
242  }
243 
244  // currentVertex is pointing at next potential center vertex.
245  // Move forward in the list of vertices if necessary.
246  bool next_vertex_identified = false;
247  while (!next_vertex_identified)
248  {
249  // Move to next mesh if necessary
250  while (vertexIterator->is_at_end())
251  {
252  delete vertexIterator;
253  ++currentMesh;
254  if (currentMesh == meshSet.end())
255  {
256  vertexIterator = NULL;
257  return false;
258  }
259  vertexIterator = (*currentMesh)->vertex_iterator(err); MSQ_CHKERR(err);
260  }
261 
262  bool on_bnd = false;
263  bool is_mid = false;
265  (*currentMesh)->vertices_are_on_boundary(&vtx, &on_bnd, 1, err);
266  if (MSQ_CHKERR(err)) return false;
267  //(*currentMesh)->vertices_are_midnodes(&vtx, &is_mid, 1, err);
268  //if (MSQ_CHKERR(err)) return false;
269 
270  //always skip midnodes
271  if (is_mid)
272  {
273  vertexIterator->operator++();
274  }
275  //if this is a 'boundary' fixed flag, skip it now
276  else if ((culling_method_bits & PatchData::NO_BOUNDARY_VTX)
277  && (on_bnd==true))
278  {
279  ++(*vertexIterator);
280  }
281  else if ((culling_method_bits & PatchData::NO_INTERIOR_VTX)
282  && (on_bnd==false))
283  {
284  ++(*vertexIterator);
285  }
286  //otherwise we check to see if this vertex has been culled
287  else{
288  //get the fixed_bit_flag for the center vertex
289  (*currentMesh)->vertex_get_byte(**vertexIterator,&center_fixed_byte, err);
290  if (MSQ_CHKERR(err)) return false;
291 
292  //remove the hard fixed flag if it has been set
293  center_fixed_byte &= ~(MsqVertex::MSQ_HARD_FIXED);
294  //if it is culled, skip it
295  if(center_fixed_byte & cullFlag)
296  {
297  ++(*vertexIterator);
298  }
299  else
300  {
301  // We found the right one
302  next_vertex_identified = true;
303  }//end else (vertex was not fixed [boundary] or culled)
304  }//end else (iterator was not at the end and vertex was not boundary)
305  }//end while (!next_vertex_identified)
307  vertexIterator->operator++();
308  if(num_layers == 0 ){
309  pd.vertexArray.resize( 1 );
310  MsqVertex* pd_vert_array = pd.get_vertex_array(err);
311  (*currentMesh)->vertices_get_coordinates(&vertex,
312  pd_vert_array,
313  1,
314  err); MSQ_ERRZERO(err);
315  pd_vert_array[0].vertexBitFlags=center_fixed_byte;
316 
317  pd.vertexHandlesArray.resize(1);
318  pd.vertexHandlesArray[0]=vertex;
319 
320  pd.initialize_data( NULL, err ); MSQ_ERRZERO(err);
321  return true;
322  }
323  // Get the number of elements in this vertex
324  size_t num_elems =
325  (*currentMesh)->vertex_get_attached_element_count(vertex, err);
326  if (MSQ_CHKERR(err)) return false;
327  pd.elementHandlesArray.resize( num_elems );
328 
329  // Get the elements attached to this vertex
330  if (elemArraySize < num_elems)
331  {
332  delete [] elemTopologies;
333  elemTopologies = new EntityTopology[num_elems];
334  elemArraySize = num_elems;
335  }
336 
337  (*currentMesh)->vertex_get_attached_elements(vertex,
338  &pd.elementHandlesArray[0],
339  num_elems, err);
340  if (MSQ_CHKERR(err)) return false;
341 
342  // Get the topologies of those elements
343  (*currentMesh)->elements_get_topologies(&pd.elementHandlesArray[0],
345  num_elems, err);
346  if (MSQ_CHKERR(err)) return false;
347 
348  // Figure out how many vertices we need to allocate
349  //size_t num_vert_uses = 1;
350  //size_t i;
351  //for (i = 0; i < num_elems; ++i)
352  // num_vert_uses += vertices_in_topology(elemTopologies[i]);
353  size_t num_vert_uses = (*currentMesh)->
354  get_vertex_use_count( &pd.elementHandlesArray[0], num_elems, err );
355  MSQ_ERRZERO(err);
356 
357  // All elems share at least 1 vertex (the center vertex). The
358  // center vertex is used 1 time, but it was counted num_elems times.
359  size_t num_verts = num_vert_uses - num_elems + 1;
360  pd.vertexHandlesArray.resize( num_verts );
361  pd.elementArray.resize( num_elems );
362  pd.elemConnectivityArray.resize( num_vert_uses );
363 
364  // Get the vertices attached to those elements
365 
366  if (csrOffsetsSize < num_elems + 1)
367  {
368  delete [] csrOffsets;
369  csrOffsets = new size_t[num_elems + 1];
370  csrOffsetsSize = num_elems + 1;
371  }
372  (*currentMesh)->elements_get_attached_vertices(&pd.elementHandlesArray[0],
373  num_elems,
374  &pd.vertexHandlesArray[0],
375  num_verts,
376  &pd.elemConnectivityArray[0],
377  num_vert_uses,
378  csrOffsets,
379  err);
380  if (MSQ_CHKERR(err)) return false;
381 
382  // Update with actual vertex count
383  pd.vertexHandlesArray.resize( num_verts );
384 
385  // Put the elements into the PatchData
386  MsqMeshEntity* pd_elem_array = pd.get_element_array(err);
387  for (i = 0; i < num_elems; ++i)
388  pd_elem_array[i].set_element_type( elemTopologies[i] );
389  pd.initialize_data( csrOffsets, err ); MSQ_ERRZERO(err);
390 
391  // Get the coordinates of the vertices and its flags.
392  pd.vertexArray.resize( num_verts );
393  MsqVertex* pd_vert_array = pd.get_vertex_array(err);
394  //get the coordinates
395  (*currentMesh)->vertices_get_coordinates(&pd.vertexHandlesArray[0],
396  pd_vert_array,
397  num_verts,
398  err);
399  if (MSQ_CHKERR(err)) return false;
400  for (i = 0; i < num_verts; i++)
401  {
402 
403  // If it's not the center vertex, mark it as hard fixed
404  if (pd.vertexHandlesArray[i] != vertex)
405  {
406  // Get its flags
407  (*currentMesh)->vertex_get_byte(pd.vertexHandlesArray[i],
408  &(pd_vert_array[i].vertexBitFlags),
409  err);
410  if (MSQ_CHKERR(err)) return false;
411  pd_vert_array[i].vertexBitFlags |= MsqVertex::MSQ_HARD_FIXED;
412  }
413  //else it is the center vertex. We therefore already have
414  //the fixed flag stored center_fixed_byte. The hard fixed
415  //flag has already been removed (when flag was retreived).
416  else{
417  pd_vert_array[i].vertexBitFlags = (center_fixed_byte);
418  }
419  }
420 
421  return true;
422 }
423 
424 
426  PatchDataParameters& pd_params,
427  MsqError& err )
428 {
429  // We only support global patches for a single Mesh
430  if (meshSet.size() != 1)
431  {
432  MSQ_SETERR(err)(
433  "Global patches only supported for single-Mesh MeshSets.",
435  return false;
436  }
437 
440  if (mDomain)
441  pd.domainHint = mDomain->hint();
442 
443  // for a global patch, we always reset to start of the mesh.
444  reset(err);
445  if (MSQ_CHKERR(err)) return false;
446 
447  size_t i;
448 
449  // Get sizes for mesh data
450  size_t num_verts, num_elems, num_uses;
451  (*currentMesh)->get_all_sizes( num_verts, num_elems, num_uses, err ); MSQ_ERRZERO(err);
452 
453  // Get handles and connectivity
454  pd.vertexHandlesArray.resize( num_verts );
455  pd.elementHandlesArray.resize( num_elems );
456  pd.elemConnectivityArray.resize( num_uses );
457  msq_std::vector<size_t> offsets(num_elems+1);
458  (*currentMesh)->get_all_mesh( &pd.vertexHandlesArray[0], num_verts,
459  &pd.elementHandlesArray[0], num_elems,
460  &offsets[0], offsets.size(),
461  &pd.elemConnectivityArray[0],
463  err ); MSQ_ERRZERO(err);
464 
465  // Get element topologies
466  pd.elementArray.resize( num_elems );
467  msq_std::vector<EntityTopology> elem_topologies(num_elems);
468  (*currentMesh)->elements_get_topologies( &pd.elementHandlesArray[0],
469  &elem_topologies[0],
470  num_elems, err );MSQ_ERRZERO(err);
471 
472  // Put them into the patch
473  MsqMeshEntity* pd_elem_array = pd.get_element_array(err);MSQ_ERRZERO(err);
474  for (i = 0; i < num_elems; ++i)
475  pd_elem_array[i].set_element_type( elem_topologies[i] );
476 
477  // Complete connectivity data in patch
478  pd.initialize_data( &offsets[0], err ); MSQ_ERRZERO(err);
479 
480 
481  // Get vertex coordinates
482  pd.vertexArray.resize( num_verts );
483  MsqVertex* pd_vert_array = pd.get_vertex_array(err);MSQ_ERRZERO(err);
484  (*currentMesh)->vertices_get_coordinates(&pd.vertexHandlesArray[0],
485  pd_vert_array,
486  num_verts,
487  err); MSQ_ERRZERO(err);
488 
489  // Get vertex boundary flag
490  if (vertArraySize < num_verts)
491  {
492  delete [] vertexOnBoundary;
493  vertArraySize = num_verts;
494  vertexOnBoundary = new bool[vertArraySize];
495  }
496  (*currentMesh)->vertices_are_on_boundary( &pd.vertexHandlesArray[0],
498  num_verts,
499  err );MSQ_ERRZERO(err);
500 
501  for (i = 0; i < num_verts; i++)
502  {
503  // Get its flags
504  /*(*currentMesh)->vertex_get_byte(vertArray[i],
505  &(pd_vert_array[i].vertexBitFlags),
506  err); MSQ_CHKERR(err);*/
507  // Set its hard-fixed flag
508  if (/*(*currentMesh)->vertex_is_fixed(vertArray[i], err) ||*/
509  vertexOnBoundary[i])
510  {
511  pd_vert_array[i].vertexBitFlags |= MsqVertex::MSQ_HARD_FIXED;
512  }
513  else
514  {
515  pd_vert_array[i].vertexBitFlags &= ~(MsqVertex::MSQ_HARD_FIXED);
516  }
517  }
518 
519  return true;
520 }
521 
522 // Currently, the only thing supported is updating each vertices
523 // coordinates and flags. Connectivity changes aren't supported yet.
525 {
526  MSQ_FUNCTION_TIMER( "MeshSet::update_mesh" );
527  if (pd.num_nodes() == 0)
528  return;
529 
530  size_t i;
531 
532  switch (pd.type())
533  {
534  // If the patch type is marked as local,
535  // all handles belong to the currentMesh.
537  // For each vertex, update the coordinates
538  // and the "mesquite byte".
539  for (i = 0; i < pd.num_nodes(); i++)
540  {
541  if(!pd.vertexArray[i].is_flag_set( MsqVertex::MSQ_HARD_FIXED))
542  {
543  (*currentMesh)->vertex_set_coordinates(pd.vertexHandlesArray[i],
544  pd.vertexArray[i],
545  err); MSQ_ERRRTN(err);
546  }
547 
548  (*currentMesh)->vertex_set_byte(pd.vertexHandlesArray[i],
549  pd.vertexArray[i].vertexBitFlags,
550  err); MSQ_ERRRTN(err);
551  }
552  break;
553 
554  // If the patch type is marked as global,
555  // the handles may belong to more than
556  // one Mesh.
558  {
559  list<Mesquite::Mesh*>::iterator mesh_itr = meshSet.begin();
560  assert( mesh_itr != meshSet.end() );
561  Mesquite::Mesh* cur_mesh = *mesh_itr;
562  Mesquite::VertexIterator *vert_itr = cur_mesh->vertex_iterator(err);
563  MSQ_ERRRTN(err);
564  for (i = 0; i < pd.num_nodes(); i++)
565  {
566  if (vert_itr->is_at_end())
567  {
568  mesh_itr++;
569  if ( mesh_itr==meshSet.end() )
570  return;
571  cur_mesh = *mesh_itr;
572  delete vert_itr;
573  vert_itr = cur_mesh->vertex_iterator(err); MSQ_ERRRTN(err);
574  }
575  if(!pd.vertexArray[i].is_flag_set( MsqVertex::MSQ_HARD_FIXED))
576  {
577  cur_mesh->vertex_set_coordinates(pd.vertexHandlesArray[i],
578  pd.vertexArray[i],
579  err); MSQ_ERRRTN(err);
580  }
581  cur_mesh->vertex_set_byte(pd.vertexHandlesArray[i],
582  pd.vertexArray[i].vertexBitFlags,
583  err); MSQ_ERRRTN(err);
584  }
585  delete vert_itr;
586  }
587  break;
588  default:
589  {
590  MSQ_SETERR(err)("PatchData Type not accepted yet.", MsqError::NOT_IMPLEMENTED);
591  break;
592  }
593  }
594 }
595 
597 {
598  //variable to store the center vertex's fixed flag
599  MsqVertex::FlagMask fixed_byte;
600  bool finished_with_vertices=false;
601  // initialize everything.
602  if (!vertexIterator)
603  { reset(err); if(MSQ_CHKERR(err)) return false; }
604  // currentVertex is pointing at next potential center vertex.
605 
606  while(!finished_with_vertices){
607  // Move to next mesh if necessary
608  if (vertexIterator->is_at_end())
609  {
610  delete vertexIterator;
611  ++currentMesh;
612  if (currentMesh == meshSet.end())
613  {
614  vertexIterator = NULL;
615  finished_with_vertices=true;
616  }
617  if(!finished_with_vertices){
618  vertexIterator = (*currentMesh)->vertex_iterator(err);
619  if (MSQ_CHKERR(err)) return false;
620  }
621  }
622  //otherwise we check to see if this vertex has been culled
623  else{
624  //get the fixed_bit_flag
625  (*currentMesh)->vertex_get_byte(**vertexIterator,&fixed_byte, err);
626  if (MSQ_CHKERR(err)) return false;
627  fixed_byte &= (~MsqVertex::MSQ_SOFT_FIXED);
628  (*currentMesh)->vertex_set_byte(**vertexIterator,fixed_byte, err);
629  if (MSQ_CHKERR(err)) return false;
630  ++(*vertexIterator);
631  }
632  }
633  return true;
634 }
635 
636 
637 
638 /* ************************************************************************* */
639 /* ************* Mesh Files can be written directly from the MeshSet ******* */
640 /* ************* Various formats are available below ******* */
641 /* ************************************************************************* */
642 
643 
644 
651 void MeshSet::write_vtk(const char* out_filename,
652  Mesquite::MsqError &err)
653 {
654  // Open the file
655  msq_stdio::ofstream file(out_filename);
656  if (!file)
657  {
659  return;
660  }
661 
662  // loads a global patch
663  PatchData pd;
664  PatchDataParameters pd_params;
665  pd_params.set_patch_type(PatchData::GLOBAL_PATCH, err); MSQ_ERRRTN(err);
666  pd_params.no_culling_method();
667  get_next_patch(pd, pd_params, err); MSQ_ERRRTN(err);
668 
669  // Write a header
670  file << "# vtk DataFile Version 2.0\n";
671  file << "Mesquite Mesh " << out_filename << " .\n";
672  file << "ASCII\n";
673  file << "DATASET UNSTRUCTURED_GRID\n";
674 
675  // Write vertex coordinates
676  file << "POINTS " << pd.num_nodes() << " float\n";
677  size_t i;
678  for (i = 0; i < pd.num_nodes(); i++)
679  {
680  file << pd.vertexArray[i][0] << ' '
681  << pd.vertexArray[i][1] << ' '
682  << pd.vertexArray[i][2] << '\n';
683  }
684 
685  // Write out the connectivity table
686  size_t connectivity_size = 0;
687  for (i = 0; i < pd.num_elements(); ++i)
688  connectivity_size += pd.elementArray[i].node_count()+1;
689 
690  file << "CELLS " << pd.num_elements() << ' ' << connectivity_size << '\n';
691  for (i = 0; i < pd.num_elements(); i++)
692  {
693  std::vector<size_t> vtx_indices;
694  pd.elementArray[i].get_node_indices(vtx_indices);
695  file << vtx_indices.size();
696  for (msq_stdc::size_t j = 0; j < vtx_indices.size(); ++j)
697  {
698  file << ' ' << vtx_indices[j];
699  }
700  file << '\n';
701  }
702 
703  // Write out the element types
704  file << "CELL_TYPES " << pd.num_elements() << '\n';
705  for (i = 0; i < pd.num_elements(); i++)
706  {
707  unsigned char type_id = 0;
708  switch (pd.elementArray[i].get_element_type())
709  {
710  case Mesquite::TRIANGLE:
711  type_id = 5;
712  break;
714  type_id = 9;
715  break;
717  type_id = 10;
718  break;
720  type_id = 12;
721  break;
722  default:
723  MSQ_SETERR(err)("element type not implemented",MsqError::NOT_IMPLEMENTED);
724  break;
725  }
726  file << (int)type_id << '\n';
727  }
728 
729  // Write out which points are fixed.
730  file << "POINT_DATA " << pd.num_nodes()
731  << "\nSCALARS fixed float\nLOOKUP_TABLE default\n";
732  for (i = 0; i < pd.num_nodes(); ++i)
733  {
734  if (pd.vertexArray[i].is_free_vertex())
735  file << "0\n";
736  else
737  file << "1\n";
738  }
739 
740  // Close the file
741  file.close();
742 }
743 
744 
745 
755 void MeshSet::write_gnuplot(const char* out_filebase,
756  Mesquite::MsqError &err)
757 {
758  // Open the file
759  string out_filename = out_filebase;
760  out_filename += ".gpt";
761  ofstream file(out_filename.c_str());
762  if (!file)
763  {
765  return;
766  }
767 
768  // loads a global patch
769  PatchData pd;
770  PatchDataParameters pd_params;
771  pd_params.set_patch_type(PatchData::GLOBAL_PATCH, err); MSQ_ERRRTN(err);
772  pd_params.no_culling_method();
773  get_next_patch(pd, pd_params, err); MSQ_ERRRTN(err);
774 
775  // Write a header
776  file << "\n";
777 
778  for (size_t i=0; i<pd.num_elements(); ++i)
779  {
780  std::vector<size_t> vtx_indices;
781  pd.elementArray[i].get_node_indices(vtx_indices);
782  for (size_t j = 0; j < vtx_indices.size(); ++j)
783  {
784  file << pd.vertexArray[vtx_indices[j]][0] << ' '
785  << pd.vertexArray[vtx_indices[j]][1] << ' '
786  << pd.vertexArray[vtx_indices[j]][2] << '\n';
787  }
788  file << pd.vertexArray[vtx_indices[0]][0] << ' '
789  << pd.vertexArray[vtx_indices[0]][1] << ' '
790  << pd.vertexArray[vtx_indices[0]][2] << '\n';
791  file << '\n';
792  }
793 
794  // Close the file
795  file.close();
796 }
797 
798 } // namespace Mesquite
Iterates through a set of entities. An EntityIterator is typically obtained via Mesh::vertex_iterator...
msq_stdc::size_t elemArraySize
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
PatchDataMem< MsqVertex > vertexArray
void set_patch_type(PatchData::PatchType patch_type, MsqError &err, int patch_param1=0, int patch_param2=0)
Tells the MeshSet what kind of data the patches should include.
Used to hold the error state and return it to the application.
EntityTopology
Definition: Mesquite.hpp:92
void set_domain_constraint(MeshDomain *domain, MsqError &err)
Sets the geometrical domain for the MeshSet.
msq_stdc::size_t vertArraySize
Mesquite::VertexIterator * vertexIterator
Keeps track of where we are in the current mesh&#39;s vertex list.
requested functionality is not (yet) implemented
EntityHandle VertexHandle
vertex is fixed. This flag can be set on and off.
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
bool get_next_global_patch(PatchData &, PatchDataParameters &, MsqError &)
PatchDataMem< size_t > elemConnectivityArray
bool get_next_elem_on_vert_patch(PatchData &, PatchDataParameters &, MsqError &)
void write_vtk(const char *out_filebase, MsqError &err)
msq_stdc::size_t csrOffsetsSize
void initialize_data(size_t *elem_offset_array, MsqError &err)
Call after filling vertex handle and connectivity arrays to finish initializing the PatchData...
void update_mesh(const PatchData &pd, MsqError &err)
Updates the coordinates in the underlying mesh with the coordinates stored in PatchData.
size_t num_elements() const
number of elements in the Patch.
void clear()
Removes data.
msq_std::list< Mesquite::Mesh * >::iterator currentMesh
Keeps track of which Mesh* we&#39;re currently working with in get_next_patch().
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
int spaceDim
The number of coordinates in this mesh (2D or 3D)
int get_nb_layers(MsqError &err)
Returns numbers of layers for local patch.
msq_stdc::size_t * csrOffsets
These are arrays that we cache so we don&#39;t have to reallocate at every patch.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Mesquite::MeshDomain * mDomain
blockLoc i
Definition: read.cpp:79
virtual DomainHint hint() const =0
Give a hint about the nature of the domain for better performance.
long unsigned int get_culling_method_bits()
returns the bitset.
Mesquite::EntityTopology * elemTopologies
A Mesquite::Mesh is a collection of mesh elements which are composed of mesh vertices. Intermediate objects are not accessible through this interface (where intermediate objects include things like the faces of a hex, or an element&#39;s edges).
size_t num_nodes() const
Get number of nodes (vertex + higher-order nodes)
void no_culling_method()
No culling performed (sets off all culling criteria).
File cannot be opened/created.
void write_gnuplot(const char *out_filebase, MsqError &err)
PatchDataMem< MsqMeshEntity > elementArray
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
j indices j
Definition: Indexing.h:6
msq_std::list< Mesquite::Mesh * > meshSet
Meshes in this MeshSet.
PatchData::PatchType get_patch_type()
Returns Patch Type (local around vertices, local around elements, global)
vertex is always fixed. This can only be set on and never off.
object is in an invalid state
bool clear_all_soft_fixed_flags(MsqError &err)
Mesquite::MsqVertex::FlagMask cullFlag
PatchDataMem< Mesh::ElementHandle > elementHandlesArray
virtual bool is_at_end() const =0
Returns false until the iterator has been advanced PAST the last entity.
PatchDataMem< Mesh::VertexHandle > vertexHandlesArray
const MsqMeshEntity * get_element_array(MsqError &err) const
Returns a pointer to the start of the element array.
virtual void restart()=0
Moves the iterator back to the first entity in the list.
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
void add_mesh(Mesquite::Mesh *mesh, MsqError &err)
adds a mesh to the MeshSet.
virtual int get_geometric_dimension(MsqError &err)=0
Returns whether this mesh lies in a 2D or 3D coordinate system.
void reset(MsqError &err)
Resets the MeshSet object so that get_next_patch() will restart its iterations at the first vertex...
bool get_next_patch(PatchData &pd, PatchDataUser *pd_user, MsqError &err)
Gets the next PatchData.