46 #include "MeshSet.hpp"
47 #include "QualityImprover.hpp"
48 #include "MsqError.hpp"
49 #include "MsqDebug.hpp"
50 #include "TopologyInfo.hpp"
52 #ifdef MSQ_USE_OLD_IO_HEADERS
88 list<Mesquite::Mesh*>::iterator it =
meshSet.begin();
116 MSQ_SETERR(err)(
"Meshes of different dimensions added to the same MeshSet.",
176 PatchDataParameters &pd_params,
186 pd.domainSet = (
mDomain != NULL);
189 switch (pd_params.get_patch_type())
198 MSQ_SETERR(err)(
"no implementation for specified patch type.",
209 PatchDataParameters &pd_params,
215 long unsigned int culling_method_bits = pd_params.get_culling_method_bits();
220 int num_layers = pd_params.get_nb_layers(err);
223 if ((
unsigned)num_layers > (
unsigned)1)
225 MSQ_SETERR(err)(
"no implementation for patch depth > 1.",
246 bool next_vertex_identified =
false;
247 while (!next_vertex_identified)
265 (*currentMesh)->vertices_are_on_boundary(&vtx, &on_bnd, 1, err);
289 (*currentMesh)->vertex_get_byte(**
vertexIterator,¢er_fixed_byte, err);
302 next_vertex_identified =
true;
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,
315 pd_vert_array[0].vertexBitFlags=center_fixed_byte;
317 pd.vertexHandlesArray.resize(1);
318 pd.vertexHandlesArray[0]=vertex;
325 (*currentMesh)->vertex_get_attached_element_count(vertex, err);
327 pd.elementHandlesArray.resize( num_elems );
337 (*currentMesh)->vertex_get_attached_elements(vertex,
338 &pd.elementHandlesArray[0],
343 (*currentMesh)->elements_get_topologies(&pd.elementHandlesArray[0],
353 size_t num_vert_uses = (*currentMesh)->
354 get_vertex_use_count( &pd.elementHandlesArray[0], num_elems, err );
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 );
372 (*currentMesh)->elements_get_attached_vertices(&pd.elementHandlesArray[0],
374 &pd.vertexHandlesArray[0],
376 &pd.elemConnectivityArray[0],
383 pd.vertexHandlesArray.resize( num_verts );
386 MsqMeshEntity* pd_elem_array = pd.get_element_array(err);
387 for (i = 0; i < num_elems; ++
i)
392 pd.vertexArray.resize( num_verts );
393 MsqVertex* pd_vert_array = pd.get_vertex_array(err);
395 (*currentMesh)->vertices_get_coordinates(&pd.vertexHandlesArray[0],
400 for (i = 0; i < num_verts; i++)
404 if (pd.vertexHandlesArray[i] != vertex)
407 (*currentMesh)->vertex_get_byte(pd.vertexHandlesArray[i],
408 &(pd_vert_array[i].vertexBitFlags),
417 pd_vert_array[
i].vertexBitFlags = (center_fixed_byte);
426 PatchDataParameters& pd_params,
433 "Global patches only supported for single-Mesh MeshSets.",
450 size_t num_verts, num_elems, num_uses;
451 (*currentMesh)->get_all_sizes( num_verts, num_elems, num_uses, err );
MSQ_ERRZERO(err);
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],
462 pd.elemConnectivityArray.size(),
466 pd.elementArray.resize( num_elems );
467 msq_std::vector<EntityTopology> elem_topologies(num_elems);
468 (*currentMesh)->elements_get_topologies( &pd.elementHandlesArray[0],
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] );
478 pd.initialize_data( &offsets[0], err );
MSQ_ERRZERO(err);
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],
496 (*currentMesh)->vertices_are_on_boundary( &pd.vertexHandlesArray[0],
501 for (i = 0; i < num_verts; i++)
527 if (pd.num_nodes() == 0)
539 for (i = 0; i < pd.num_nodes(); i++)
543 (*currentMesh)->vertex_set_coordinates(pd.vertexHandlesArray[i],
548 (*currentMesh)->vertex_set_byte(pd.vertexHandlesArray[i],
549 pd.vertexArray[i].vertexBitFlags,
559 list<Mesquite::Mesh*>::iterator mesh_itr = meshSet.begin();
560 assert( mesh_itr != meshSet.end() );
564 for (i = 0; i < pd.num_nodes(); i++)
569 if ( mesh_itr==meshSet.end() )
571 cur_mesh = *mesh_itr;
573 vert_itr = cur_mesh->vertex_iterator(err);
MSQ_ERRRTN(err);
577 cur_mesh->vertex_set_coordinates(pd.vertexHandlesArray[i],
581 cur_mesh->vertex_set_byte(pd.vertexHandlesArray[i],
582 pd.vertexArray[i].vertexBitFlags,
600 bool finished_with_vertices=
false;
606 while(!finished_with_vertices){
615 finished_with_vertices=
true;
617 if(!finished_with_vertices){
625 (*currentMesh)->vertex_get_byte(**
vertexIterator,&fixed_byte, err);
627 fixed_byte &= (~MsqVertex::MSQ_SOFT_FIXED);
628 (*currentMesh)->vertex_set_byte(**
vertexIterator,fixed_byte, err);
655 msq_stdio::ofstream file(out_filename);
664 PatchDataParameters pd_params;
666 pd_params.no_culling_method();
670 file <<
"# vtk DataFile Version 2.0\n";
671 file <<
"Mesquite Mesh " << out_filename <<
" .\n";
673 file <<
"DATASET UNSTRUCTURED_GRID\n";
676 file <<
"POINTS " << pd.num_nodes() <<
" float\n";
678 for (i = 0; i < pd.num_nodes(); i++)
680 file << pd.vertexArray[
i][0] <<
' '
681 << pd.vertexArray[
i][1] <<
' '
682 << pd.vertexArray[
i][2] <<
'\n';
686 size_t connectivity_size = 0;
687 for (i = 0; i < pd.num_elements(); ++
i)
688 connectivity_size += pd.elementArray[i].node_count()+1;
690 file <<
"CELLS " << pd.num_elements() <<
' ' << connectivity_size <<
'\n';
691 for (i = 0; i < pd.num_elements(); i++)
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)
698 file <<
' ' << vtx_indices[
j];
704 file <<
"CELL_TYPES " << pd.num_elements() <<
'\n';
705 for (i = 0; i < pd.num_elements(); i++)
707 unsigned char type_id = 0;
708 switch (pd.elementArray[i].get_element_type())
726 file << (int)type_id <<
'\n';
730 file <<
"POINT_DATA " << pd.num_nodes()
731 <<
"\nSCALARS fixed float\nLOOKUP_TABLE default\n";
732 for (i = 0; i < pd.num_nodes(); ++
i)
734 if (pd.vertexArray[i].is_free_vertex())
759 string out_filename = out_filebase;
760 out_filename +=
".gpt";
761 ofstream file(out_filename.c_str());
770 PatchDataParameters pd_params;
772 pd_params.no_culling_method();
778 for (
size_t i=0; i<pd.num_elements(); ++
i)
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)
784 file << pd.vertexArray[vtx_indices[
j]][0] <<
' '
785 << pd.vertexArray[vtx_indices[
j]][1] <<
' '
786 << pd.vertexArray[vtx_indices[
j]][2] <<
'\n';
788 file << pd.vertexArray[vtx_indices[0]][0] <<
' '
789 << pd.vertexArray[vtx_indices[0]][1] <<
' '
790 << pd.vertexArray[vtx_indices[0]][2] <<
'\n';
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.
Used to hold the error state and return it to the application.
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's vertex list.
requested functionality is not (yet) implemented
EntityHandle VertexHandle
vertex is fixed. This flag can be set on and off.
bool get_next_global_patch(PatchData &, PatchDataParameters &, MsqError &)
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 update_mesh(const PatchData &pd, MsqError &err)
Updates the coordinates in the underlying mesh with the coordinates stored in PatchData.
msq_std::list< Mesquite::Mesh * >::iterator currentMesh
Keeps track of which Mesh* we're currently working with in get_next_patch().
#define MSQ_CHKERR(err)
Mesquite's Error Checking macro.
int spaceDim
The number of coordinates in this mesh (2D or 3D)
msq_stdc::size_t * csrOffsets
These are arrays that we cache so we don't have to reallocate at every patch.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Mesquite::MeshDomain * mDomain
virtual DomainHint hint() const =0
Give a hint about the nature of the domain for better performance.
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's edges).
File cannot be opened/created.
void write_gnuplot(const char *out_filebase, MsqError &err)
msq_std::list< Mesquite::Mesh * > meshSet
Meshes in this MeshSet.
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
#define MSQ_FUNCTION_TIMER(NAME)
virtual bool is_at_end() const =0
Returns false until the iterator has been advanced PAST the last entity.
virtual void restart()=0
Moves the iterator back to the first entity in the list.
#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.