Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MeshInterface.hpp
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  kraftche@cae.wisc.edu
26 
27  ***************************************************************** */
39 #ifndef MESQUITE_INTERFACE_HPP
40 #define MESQUITE_INTERFACE_HPP
41 
42 #include "Mesquite.hpp"
43 #include "TopologyInfo.hpp"
44 
45 #ifdef MSQ_USE_OLD_C_HEADERS
46 # include <stddef.h>
47 #else
48 # include <cstddef>
49 #endif
50 
51 #include <string>
52 
53 namespace Mesquite
54 {
55  class EntityIterator;
56  class MsqError;
57  class MsqVertex;
58  class Vector3D;
61 
63  typedef void* TagHandle;
64 
65  inline size_t vertices_in_topology(EntityTopology);
66 
73  class Mesh
74  {
75  public:
76 //************ Type Definitions **************
78  typedef void* EntityHandle;
79 
80 
81  // We typedef specific types of EntityHandles just
82  // to make it clear what kind of entity is to be
83  // returned or used as a function parameter, but the
84  // different handle types are not actually distinct.
87 
88 //************ Operations on entire mesh ****************
90  virtual int get_geometric_dimension(MsqError &err) = 0;
91 
102  virtual void get_all_sizes( size_t& vertex_count,
103  size_t& element_count,
104  size_t& vertex_use_count,
105  MsqError& err ) = 0;
106 
125  virtual void get_all_mesh( VertexHandle* vert_array, size_t vert_len,
126  ElementHandle* elem_array, size_t elem_len,
127  size_t* elem_conn_offsets, size_t offset_len,
128  size_t* elem_conn_indices, size_t index_len,
129  MsqError& err ) = 0;
130 
136  virtual VertexIterator* vertex_iterator(MsqError &err) = 0;
137 
143  virtual ElementIterator* element_iterator(MsqError &err) = 0;
144 
145 //************ Vertex Properties ********************
151  virtual bool vertex_is_fixed(VertexHandle vertex, MsqError &err) = 0;
152 
159  virtual void vertices_are_on_boundary(VertexHandle vert_array[], bool on_bnd[],
160  size_t num_vtx, MsqError &err) = 0;
161 
163  virtual void vertices_get_coordinates(const VertexHandle vert_array[],
164  MsqVertex* coordinates,
165  size_t num_vtx,
166  MsqError &err) = 0;
167  virtual void vertex_set_coordinates(VertexHandle vertex,
168  const Vector3D &coordinates,
169  MsqError &err) = 0;
170 
175  virtual void vertex_set_byte (VertexHandle vertex,
176  unsigned char byte, MsqError &err) = 0;
177  virtual void vertices_set_byte (VertexHandle *vert_array,
178  unsigned char *byte_array,
179  size_t array_size, MsqError &err) = 0;
180 
184  virtual void vertex_get_byte(VertexHandle vertex,
185  unsigned char *byte, MsqError &err) = 0;
186  virtual void vertices_get_byte(VertexHandle *vertex,
187  unsigned char *byte_array,
188  size_t array_size, MsqError &err) = 0;
189 
190 //**************** Vertex Topology *****************
194  virtual size_t vertex_get_attached_element_count(VertexHandle vertex,
195  MsqError &err) = 0;
196 
198  virtual void vertex_get_attached_elements(VertexHandle vertex,
199  ElementHandle* elem_array,
200  size_t sizeof_elem_array,
201  MsqError &err) = 0;
202 
203 //*************** Element Topology *************
204 
210  MsqError &err) = 0;
211  virtual size_t get_vertex_use_count( ElementHandle* handle_array,
212  size_t num_handles,
213  MsqError& err ) = 0;
214 
251  virtual void elements_get_attached_vertices(ElementHandle *elem_handles,
252  size_t num_elems,
253  VertexHandle *vert_handles,
254  size_t &sizeof_vert_handles,
255  size_t *csr_data,
256  size_t &sizeof_csr_data,
257  size_t *csr_offsets,
258  MsqError &err) = 0;
259 
260 
262  virtual EntityTopology element_get_topology(ElementHandle entity_handle,
263  MsqError &err) = 0;
266  virtual void elements_get_topologies(ElementHandle *element_handle_array,
267  EntityTopology *element_topologies,
268  size_t num_elements, MsqError &err) = 0;
269 
270 
271 //*************** Tags ***********
272 
275 
288  virtual TagHandle tag_create( const msq_std::string& tag_name,
289  TagType type, unsigned length,
290  const void* default_value,
291  MsqError &err) = 0;
292 
297  virtual void tag_delete( TagHandle handle, MsqError& err ) = 0;
298 
299 
307  virtual TagHandle tag_get( const msq_std::string& name,
308  MsqError& err ) = 0;
309 
318  virtual void tag_properties( TagHandle handle,
319  msq_std::string& name_out,
320  TagType& type_out,
321  unsigned& length_out,
322  MsqError& err ) = 0;
323 
334  virtual void tag_set_element_data( TagHandle handle,
335  size_t num_elems,
336  const ElementHandle* elem_array,
337  const void* tag_data,
338  MsqError& err ) = 0;
339 
350  virtual void tag_set_vertex_data ( TagHandle handle,
351  size_t num_elems,
352  const VertexHandle* node_array,
353  const void* tag_data,
354  MsqError& err ) = 0;
355 
356 
367  virtual void tag_get_element_data( TagHandle handle,
368  size_t num_elems,
369  const ElementHandle* elem_array,
370  void* tag_data,
371  MsqError& err ) = 0;
372 
383  virtual void tag_get_vertex_data ( TagHandle handle,
384  size_t num_elems,
385  const VertexHandle* node_array,
386  void* tag_data,
387  MsqError& err ) = 0;
388 
389 
390 
391 //**************** Memory Management ****************
394  virtual void release_entity_handles(EntityHandle *handle_array,
395  size_t num_handles, MsqError &err) = 0;
396 
402  virtual void release() = 0;
403 
404  protected:
406  virtual ~Mesh()
407  {}
408  };
409 
417  {
418  public:
419  virtual ~EntityIterator()
420  {}
421 
424  virtual void restart() = 0;
425 
428  virtual Mesh::EntityHandle operator*() const = 0;
429 
431  virtual void operator++() = 0;
432 
437  virtual bool is_at_end() const = 0;
438  };
439 
440 
446  enum DomainHint {
447  NO_DOMAIN_HINT, //< Do not make any assumptions about the domain.
448  PLANAR_DOMAIN, //< Domain is planar
449  LOCAL_PALANAR, //< Domain is close to planar
450  SMOOTH_DOMAIN //< Domain is C1-continuous
451  };
458  {
459  public:
460  virtual ~MeshDomain()
461  {}
462 
468  virtual DomainHint hint() const = 0;
469 
474  virtual void snap_to(Mesh::EntityHandle entity_handle,
475  Vector3D &coordinate) const = 0;
476 
490  virtual void normal_at(Mesh::EntityHandle entity_handle,
491  Vector3D &coordinate) const = 0;
492 
504  virtual void normal_at( Mesh::EntityHandle handle,
505  Vector3D coordinates[],
506  unsigned count,
507  MsqError& err ) const = 0;
508 
521  virtual void closest_point( Mesh::EntityHandle handle,
522  const Vector3D& position,
523  Vector3D& closest,
524  Vector3D& normal,
525  MsqError& err ) const = 0;
526 
527  };
528 }
529 
531 {
532  return TopologyInfo::corners( topo );
533 }
534 
535 #endif
Iterates through a set of entities. An EntityIterator is typically obtained via Mesh::vertex_iterator...
EntityIterator VertexIterator
virtual void tag_delete(TagHandle handle, MsqError &err)=0
Remove a tag and all corresponding data.
Used to hold the error state and return it to the application.
virtual void get_all_sizes(size_t &vertex_count, size_t &element_count, size_t &vertex_use_count, MsqError &err)=0
get sizes for calling get_all_mesh
TagType
The type of a tag.
EntityTopology
Definition: Mesquite.hpp:92
virtual ElementIterator * element_iterator(MsqError &err)=0
Returns a pointer to an iterator that iterates over the set of all top-level elements in this mesh...
virtual void closest_point(Mesh::EntityHandle handle, const Vector3D &position, Vector3D &closest, Vector3D &normal, MsqError &err) const =0
evaluate closest point and normal
virtual TagHandle tag_get(const msq_std::string &name, MsqError &err)=0
Get handle for existing tag, by name.
virtual void tag_set_element_data(TagHandle handle, size_t num_elems, const ElementHandle *elem_array, const void *tag_data, MsqError &err)=0
Set tag values on elements.
DomainHint
A hint on the characteristics of the domain that Mesquite may use to determine what, if any, scheme to use to cache characteristics of the geometric domain.
EntityHandle VertexHandle
virtual void elements_get_attached_vertices(ElementHandle *elem_handles, size_t num_elems, VertexHandle *vert_handles, size_t &sizeof_vert_handles, size_t *csr_data, size_t &sizeof_csr_data, size_t *csr_offsets, MsqError &err)=0
Returns the vertices that are part of the topological definition of each element in the &quot;elem_handles...
EntityHandle ElementHandle
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
virtual Mesh::EntityHandle operator*() const =0
*iterator.
void * EntityHandle
Opaque EntityHandle type and tag type.
virtual VertexIterator * vertex_iterator(MsqError &err)=0
Returns a pointer to an iterator that iterates over the set of all vertices in this mesh...
virtual void tag_get_vertex_data(TagHandle handle, size_t num_elems, const VertexHandle *node_array, void *tag_data, MsqError &err)=0
Get tag values on vertices.
virtual void get_all_mesh(VertexHandle *vert_array, size_t vert_len, ElementHandle *elem_array, size_t elem_len, size_t *elem_conn_offsets, size_t offset_len, size_t *elem_conn_indices, size_t index_len, MsqError &err)=0
Get entities and connectivity.
double length(Vector3D *const v, int n)
virtual void vertices_set_byte(VertexHandle *vert_array, unsigned char *byte_array, size_t array_size, MsqError &err)=0
virtual EntityTopology element_get_topology(ElementHandle entity_handle, MsqError &err)=0
Returns the topology of the given entity.
virtual TagHandle tag_create(const msq_std::string &tag_name, TagType type, unsigned length, const void *default_value, MsqError &err)=0
Create a tag.
virtual void vertex_get_byte(VertexHandle vertex, unsigned char *byte, MsqError &err)=0
Retrieve the byte value for the specified vertex or vertices.
virtual void elements_get_topologies(ElementHandle *element_handle_array, EntityTopology *element_topologies, size_t num_elements, MsqError &err)=0
Returns the topologies of the given entities.
virtual void release()=0
Instead of deleting a Mesh when you think you are done, call release().
virtual void tag_set_vertex_data(TagHandle handle, size_t num_elems, const VertexHandle *node_array, const void *tag_data, MsqError &err)=0
Set tag values on vertices.
virtual void vertex_set_byte(VertexHandle vertex, unsigned char byte, MsqError &err)=0
Each vertex has a byte-sized flag that can be used to store flags.
virtual void snap_to(Mesh::EntityHandle entity_handle, Vector3D &coordinate) const =0
Modifies &quot;coordinate&quot; so that it lies on the domain to which &quot;entity_handle&quot; is constrained.
size_t vertices_in_topology(EntityTopology)
virtual size_t vertex_get_attached_element_count(VertexHandle vertex, MsqError &err)=0
Gets the number of elements attached to this vertex.
virtual DomainHint hint() const =0
Give a hint about the nature of the domain for better performance.
virtual void release_entity_handles(EntityHandle *handle_array, size_t num_handles, MsqError &err)=0
Tells the mesh that the client is finished with a given entity handle.
virtual void vertex_get_attached_elements(VertexHandle vertex, ElementHandle *elem_array, size_t sizeof_elem_array, MsqError &err)=0
Gets the elements attached to this vertex.
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).
virtual size_t element_get_attached_vertex_count(ElementHandle elem, MsqError &err)=0
Gets the number of vertices in this element.
virtual void vertices_are_on_boundary(VertexHandle vert_array[], bool on_bnd[], size_t num_vtx, MsqError &err)=0
Returns true or false, indicating whether the vertex is on the boundary.
virtual void vertices_get_byte(VertexHandle *vertex, unsigned char *byte_array, size_t array_size, MsqError &err)=0
virtual void vertex_set_coordinates(VertexHandle vertex, const Vector3D &coordinates, MsqError &err)=0
virtual ~Mesh()
Don&#39;t allow a Mesh to be deleted directly.
virtual void tag_properties(TagHandle handle, msq_std::string &name_out, TagType &type_out, unsigned &length_out, MsqError &err)=0
Get properites of tag.
void * TagHandle
Type used to refer to a tag defintion.
virtual bool is_at_end() const =0
Returns false until the iterator has been advanced PAST the last entity.
virtual void vertices_get_coordinates(const VertexHandle vert_array[], MsqVertex *coordinates, size_t num_vtx, MsqError &err)=0
Get/set location of a vertex.
virtual size_t get_vertex_use_count(ElementHandle *handle_array, size_t num_handles, MsqError &err)=0
virtual void normal_at(Mesh::EntityHandle entity_handle, Vector3D &coordinate) const =0
Returns the normal of the domain to which &quot;entity_handle&quot; is constrained.
EntityIterator ElementIterator
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...
virtual void operator++()=0
++iterator
virtual bool vertex_is_fixed(VertexHandle vertex, MsqError &err)=0
Returns true or false, indicating whether the vertex is allowed to be repositioned.
virtual void tag_get_element_data(TagHandle handle, size_t num_elems, const ElementHandle *elem_array, void *tag_data, MsqError &err)=0
Get tag values on elements.
virtual int get_geometric_dimension(MsqError &err)=0
Returns whether this mesh lies in a 2D or 3D coordinate system.