Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CornerTag< T > Class Template Reference

A class for caching and managing Tags on element corners. More...

#include <CornerTag.hpp>

Inheritance diagram for CornerTag< T >:
Collaboration diagram for CornerTag< T >:

Public Member Functions

 CornerTag (const char *name, Mesh::TagType type=Mesh::BYTE)
 Initialize. More...
 
 ~CornerTag ()
 
void clear ()
 Clear cached data. More...
 
const T * get_element_corner_tags (PatchData *pd, int elem_idx, MsqError &err)
 Get a pointer to the array of all corner tag values for a given element. More...
 
void set_element_corner_tags (PatchData *pd, int elem_idx, const T *data, MsqError &err)
 
 CornerTag (const char *name, Mesh::TagType type=Mesh::BYTE)
 Initialize. More...
 
 ~CornerTag ()
 
void clear ()
 Clear cached data. More...
 
const T * get_element_corner_tags (PatchData *pd, int elem_idx, MsqError &err)
 Get a pointer to the array of all corner tag values for a given element. More...
 
void set_element_corner_tags (PatchData *pd, int elem_idx, const T *data, MsqError &err)
 

Private Attributes

CornerTagHandles tagHandles
 
msq_std::vector< T * > tagData
 

Detailed Description

template<typename T>
class Mesquite::CornerTag< T >

A class for caching and managing Tags on element corners.

This class provides:

  • An abstraction of the mechanism for storing tags on element corners.
  • Management of accessing tag data in the Mesh
  • Caching of tag data for elements in a patch
  • Converting between tag data types and Mesquite objects

Due to limitations in accessing tag data (and for more efficient access to tag data) this class assumes that either all or none of the corner tags have been defined for the elements in a patch.

When creating new tags, first call allocate_new_tags to allocate a local cache of the tag data for all elements in the patch. Then use get_element_corner_tags to retrieve the allocated space for the corners of each element. Calling get_element_corner_tags without first calling allocate_new_tags will result in an attempt to read the tag data for all elements from the Mesh instance.

Tag data is not saved to the mesh unless save_tag_data is explicitly called.

Definition at line 110 of file includeLinks/CornerTag.hpp.

Constructor & Destructor Documentation

CornerTag ( const char *  name,
Mesh::TagType  type = Mesh::BYTE 
)

Initialize.

Parameters
meshA pointer to the Mesh instance.
nameThe tag name.
typeThe native tag type. If the type "T" can be cast to one or an array of some native type, specify that type here. Otherwise use Mesh::BYTE

Definition at line 147 of file includeLinks/CornerTag.hpp.

References CornerTagHandles::size().

148  : tagHandles( tag_name, type, sizeof(T) / CornerTagHandles::size(type) )
149 {
150  // We're going to assume this for all tag read/writes,
151  // so make sure its true now.
152  assert( (sizeof(T) % CornerTagHandles::size(type)) == 0 );
153 }
static size_t size(Mesh::TagType type)

Here is the call graph for this function:

~CornerTag ( )

Definition at line 156 of file includeLinks/CornerTag.hpp.

157 {
158  clear();
159 }
void clear()
Clear cached data.
CornerTag ( const char *  name,
Mesh::TagType  type = Mesh::BYTE 
)

Initialize.

Parameters
meshA pointer to the Mesh instance.
nameThe tag name.
typeThe native tag type. If the type "T" can be cast to one or an array of some native type, specify that type here. Otherwise use Mesh::BYTE
~CornerTag ( )

Member Function Documentation

void clear ( )
inline

Clear cached data.

Any changes will be lost if save_tag_data has not been called.

Definition at line 162 of file includeLinks/CornerTag.hpp.

References i.

163 {
164  for (typename msq_std::vector<T*>::iterator i = tagData.begin(); i != tagData.end(); ++i)
165  delete [] *i;
166  tagData.clear();
167 }
msq_std::vector< T * > tagData
blockLoc i
Definition: read.cpp:79
void clear ( )
inline

Clear cached data.

Any changes will be lost if save_tag_data has not been called.

const T* get_element_corner_tags ( PatchData pd,
int  elem_idx,
MsqError err 
)
inline

Get a pointer to the array of all corner tag values for a given element.

Parameters
pdThe PatchData
elem_idxThe element, specified as it's index in the PatchData.
const T * get_element_corner_tags ( PatchData pd,
int  elem_idx,
MsqError err 
)
inline

Get a pointer to the array of all corner tag values for a given element.

Parameters
pdThe PatchData
elem_idxThe element, specified as it's index in the PatchData.

Definition at line 170 of file includeLinks/CornerTag.hpp.

References MSQ_ERRZERO.

173 {
174  if (tagData.size() <= (unsigned)elem_index)
175  tagData.resize( elem_index+1, 0 );
176 
177  int num_corners = tagHandles.num_corners( pd, elem_index );
178  if (!tagData[elem_index]) {
179  tagData[elem_index] = new T[num_corners];
180  tagHandles.save_load_tags( true, pd, elem_index, tagData[elem_index], sizeof(T), err );
181  MSQ_ERRZERO(err);
182  }
183 
184  return tagData[elem_index];
185 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
msq_std::vector< T * > tagData
static int num_corners(PatchData *pd, int elem_index)
void save_load_tags(bool load, PatchData *pd, size_t elem_index, void *data, size_t tag_byes, MsqError &err)
void set_element_corner_tags ( PatchData pd,
int  elem_idx,
const T *  data,
MsqError err 
)
inline

Definition at line 188 of file includeLinks/CornerTag.hpp.

References MSQ_CHKERR.

192 {
193  if (tagData.size() <= (unsigned)elem_index)
194  tagData.resize( elem_index+1, 0 );
195 
196  int num_corners = tagHandles.num_corners( pd, elem_index );
197  if (!tagData[elem_index])
198  tagData[elem_index] = new T[num_corners];
199  memcpy( tagData[elem_index], data, num_corners * sizeof(T) );
200 
201  tagHandles.save_load_tags( false, pd, elem_index, (void*)data, sizeof(T), err );
202  MSQ_CHKERR(err);
203 }
msq_std::vector< T * > tagData
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
static int num_corners(PatchData *pd, int elem_index)
void save_load_tags(bool load, PatchData *pd, size_t elem_index, void *data, size_t tag_byes, MsqError &err)
void set_element_corner_tags ( PatchData pd,
int  elem_idx,
const T *  data,
MsqError err 
)
inline

Member Data Documentation

msq_std::vector< T * > tagData
private

Definition at line 142 of file includeLinks/CornerTag.hpp.

CornerTagHandles tagHandles
private

Definition at line 141 of file includeLinks/CornerTag.hpp.


The documentation for this class was generated from the following files: