Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
includeLinks/MeshImplTags.hpp
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 #ifndef MESQUITE_MESH_IMPL_TAGS_HPP
28 #define MSSQUITE_MESH_IMPL_TAGS_HPP
29 
30 #include "Mesquite.hpp"
31 #include "MeshInterface.hpp"
32 
33 #ifdef MSQ_USE_OLD_STD_HEADERS
34 # include <vector.h>
35 #else
36 # include <vector>
37 #endif
38 
39 namespace Mesquite {
40 
41  struct TagDescription {
42  // The VTK attribute type the data was read from, or NONE if not VTK data.
43  // This property is kept only so that when a vtk file is read and subseqquently
44  // written, it can be preserved for other potential readers that actually care
45  // about it.
47 
48  msq_std::string name;
51  size_t size;
52 
53  inline TagDescription( msq_std::string n, Mesh::TagType t, VtkType v, size_t s )
54  : name(n), type(t), vtkType(v), size(s) {}
55 
56  inline TagDescription( )
57  : type(Mesh::BYTE), vtkType(NONE), size(0) {}
58 
59  inline bool operator==(const TagDescription& o) const
60  { return name == o.name && type == o.type && vtkType == o.vtkType && size == o.size; }
61  inline bool operator!=(const TagDescription& o) const
62  { return name != o.name || type != o.type || vtkType != o.vtkType || size != o.size; }
63  };
64 
72 class MeshImplTags {
73  public:
74 
76 
80  struct TagData {
81 
84 
86  void* elementData;
87 
89  size_t elementCount;
90 
92  void* vertexData;
93 
95  size_t vertexCount;
96 
98  void* defaultValue;
99 
107  inline TagData( const msq_std::string& name,
108  Mesh::TagType type, unsigned length,
109  void* default_val = 0,
111  : desc(name, type, vtk_type, length*size_from_tag_type(type)),
112  elementData(0), elementCount(0),
113  vertexData(0), vertexCount(0),
114  defaultValue(default_val) {}
115 
119  inline TagData( const TagDescription& descr )
120  : desc(descr), elementData(0), elementCount(0),
121  vertexData(0), vertexCount(0),
122  defaultValue(0) {}
123 
124  ~TagData();
125  };
126 
128  static size_t size_from_tag_type( Mesh::TagType type );
129 
131  void clear();
132 
134  size_t handle( const msq_std::string& name, MsqError& err ) const;
135 
137  const TagDescription& properties( size_t tag_handle, MsqError& err ) const;
138 
147  size_t create( const msq_std::string& name,
148  Mesh::TagType type,
149  unsigned length,
150  const void* defval,
151  MsqError& err );
152 
157  size_t create( const TagDescription& desc, MsqError& err );
158 
160  void destroy( size_t tag_index, MsqError& err );
161 
163  void set_element_data( size_t tag_handle,
164  size_t num_indices,
165  const size_t* elem_indices,
166  const void* tag_data,
167  MsqError& err );
168 
170  void set_vertex_data( size_t tag_handle,
171  size_t num_indices,
172  const size_t* elem_indices,
173  const void* tag_data,
174  MsqError& err );
175 
177  void get_element_data( size_t tag_handle,
178  size_t num_indices,
179  const size_t* elem_indices,
180  void* tag_data,
181  MsqError& err ) const;
182 
184  void get_vertex_data( size_t tag_handle,
185  size_t num_indices,
186  const size_t* elem_indices,
187  void* tag_data,
188  MsqError& err ) const;
189 
194  class TagIterator
195  {
196  public:
197  TagIterator( MeshImplTags* d, size_t i ) : tags(d), index(i) {}
198  size_t operator*() const { return index+1; }
201  TagIterator operator++(int);
202  TagIterator operator--(int);
203  bool operator==(TagIterator other) const { return index == other.index; }
204  bool operator!=(TagIterator other) const { return index != other.index; }
205  private:
207  size_t index;
208  };
210  TagIterator tag_end() { return TagIterator(this,tagList.size()); }
211 
213  bool tag_has_vertex_data( size_t index, MsqError& err ) ;
215  bool tag_has_element_data( size_t index, MsqError& err ) ;
216 
217  private:
218 
220 
221  msq_std::vector<TagData*> tagList;
222 }; // class MeshImplTags
223 
224 } // namespace Mesquite
225 
226 #endif
227 
228 
size_t handle(const msq_std::string &name, MsqError &err) const
Get tag index from name.
void destroy(size_t tag_index, MsqError &err)
Remove a tag.
void clear()
Clear all data.
const NT & d
Used to hold the error state and return it to the application.
TagType
The type of a tag.
double s
Definition: blastest.C:80
TagDescription(msq_std::string n, Mesh::TagType t, VtkType v, size_t s)
msq_std::string name
Tag name.
VtkType vtkType
Attribute type from VTK file.
bool operator!=(const TagDescription &o) const
This file contains the Mesquite mesh interface. Many users will want to implement a concrete class de...
size_t vertexCount
number of entries in vertexData
TagData(const msq_std::string &name, Mesh::TagType type, unsigned length, void *default_val=0, TagDescription::VtkType vtk_type=TagDescription::NONE)
Construct tag.
TagData(const TagDescription &descr)
Construct tag.
size_t elementCount
number of entries in elementData
double length(Vector3D *const v, int n)
bool tag_has_vertex_data(size_t index, MsqError &err)
Check if any vertices have tag.
*********************************************************************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
bool operator==(const TagDescription &o) const
void get_vertex_data(size_t tag_handle, size_t num_indices, const size_t *elem_indices, void *tag_data, MsqError &err) const
Get tag data on vertices.
blockLoc i
Definition: read.cpp:79
size_t create(const msq_std::string &name, Mesh::TagType type, unsigned length, const void *defval, MsqError &err)
Create a new tag.
void * defaultValue
Default value for tag.
void * vertexData
per-vertex data, or NULL if none has been set.
const NT & n
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).
Iterate over list of valid tag handles.
msq_std::vector< TagData * > tagList
void * elementData
per-element data, or NULL if none has been set.
bool tag_has_element_data(size_t index, MsqError &err)
Check if any elements have tag.
static size_t size_from_tag_type(Mesh::TagType type)
Get the size of the passed data type.
const TagDescription & properties(size_t tag_handle, MsqError &err) const
Get tag properties.
void set_vertex_data(size_t tag_handle, size_t num_indices, const size_t *elem_indices, const void *tag_data, MsqError &err)
Set tag data on vertices.
void set_element_data(size_t tag_handle, size_t num_indices, const size_t *elem_indices, const void *tag_data, MsqError &err)
Set tag data on elements.
size_t size
Size of tag data (sizeof(type)*array_length)
const TagDescription desc
tag meta data
void get_element_data(size_t tag_handle, size_t num_indices, const size_t *elem_indices, void *tag_data, MsqError &err) const
Get tag data on elements.
Mesh::TagType type
Tag data type.
Store tags and tag data for Mesquite&#39;s native mesh representation.