Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CornerTagHandles Class Reference

Utility class to manage tag handles for corner tags. More...

#include <CornerTag.hpp>

Public Member Functions

 CornerTagHandles (const char *tag_name, Mesh::TagType type, unsigned tag_len)
 
TagHandle get_handle (Mesh *mesh, unsigned num_corners, MsqError &err)
 Get the tag handle for storing this tag type with the specified number of values (corners). More...
 
void save_load_tags (bool load, PatchData *pd, size_t elem_index, void *data, size_t tag_byes, MsqError &err)
 
 CornerTagHandles (const char *tag_name, Mesh::TagType type, unsigned tag_len)
 
TagHandle get_handle (Mesh *mesh, unsigned num_corners, MsqError &err)
 Get the tag handle for storing this tag type with the specified number of values (corners). More...
 
void save_load_tags (bool load, PatchData *pd, size_t elem_index, void *data, size_t tag_byes, MsqError &err)
 

Static Public Member Functions

static Meshget_current_mesh (PatchData *pd)
 
static size_t size (Mesh::TagType type)
 
static int num_corners (PatchData *pd, int elem_index)
 
static Meshget_current_mesh (PatchData *pd)
 
static size_t size (Mesh::TagType type)
 
static int num_corners (PatchData *pd, int elem_index)
 

Private Attributes

const msq_std::string tagName
 
const Mesh::TagType tagType
 
const unsigned tagLen
 
msq_std::vector< TagHandlecornerHandles
 

Detailed Description

Utility class to manage tag handles for corner tags.

Tags on corners are saved as an array of values on the corresponding element. As tags must be of a constant size, this necessitates using different tags for elements with different numbers of corners. This class manages the set of all tag handles for a given corner tag, where the specific tag handle can be retrieved by specifying the number of corners in the element.

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

Constructor & Destructor Documentation

CornerTagHandles ( const char *  tag_name,
Mesh::TagType  type,
unsigned  tag_len 
)
inline

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

60  : tagName( tag_name ),
61  tagType(type),
62  tagLen(tag_len)
63  {}
CornerTagHandles ( const char *  tag_name,
Mesh::TagType  type,
unsigned  tag_len 
)
inline

Definition at line 57 of file src/Mesh/CornerTag.hpp.

60  : tagName( tag_name ),
61  tagType(type),
62  tagLen(tag_len)
63  {}

Member Function Documentation

Mesh * get_current_mesh ( PatchData pd)
static

Definition at line 50 of file Mesh/CornerTag.cpp.

References MeshSet::get_current_mesh(), and PatchData::get_mesh_set().

Referenced by CornerTagHandles::save_load_tags().

51 {
52  return pd->get_mesh_set() ? pd->get_mesh_set()->get_current_mesh() : 0;
53 }

Here is the call graph for this function:

Here is the caller graph for this function:

static Mesh* get_current_mesh ( PatchData pd)
static
TagHandle get_handle ( Mesh mesh,
unsigned  num_corners,
MsqError err 
)

Get the tag handle for storing this tag type with the specified number of values (corners).

Definition at line 55 of file Mesh/CornerTag.cpp.

References CornerTagHandles::cornerHandles, MsqError::INVALID_ARG, MSQ_ERRZERO, MSQ_SETERR, CornerTagHandles::size(), Mesh::tag_create(), Mesh::tag_get(), Mesh::tag_properties(), CornerTagHandles::tagLen, CornerTagHandles::tagName, and CornerTagHandles::tagType.

Referenced by CornerTagHandles::save_load_tags().

56 {
57  // Resize vector as necessary
58  if (corners >= cornerHandles.size())
59  {
60  cornerHandles.resize( corners+1, 0 );
61  }
62 
63  // Get handle if we don't already have it
64  if (!cornerHandles[corners])
65  {
66  // Construct tag name
67  char numbuf[16];
68  sprintf(numbuf, "%d", corners );
69  msq_std::string name = tagName + numbuf;
70 
71  // Try to get existing handle
72  cornerHandles[corners] = mesh->tag_get( name, err ); MSQ_ERRZERO(err);
73  // If got handle, make sure type is correct
74  if (cornerHandles[corners])
75  {
76  Mesh::TagType type;
77  unsigned size;
78  mesh->tag_properties( cornerHandles[corners], name, type, size, err );
79  MSQ_ERRZERO(err);
80 
81  if (type != tagType || size != corners*tagLen)
82  {
83  MSQ_SETERR(err)("Invalid tag type", MsqError::INVALID_ARG );
84  return 0;
85  }
86  }
87  // If didn't get handle, try to create it
88  else
89  {
90  cornerHandles[corners] = mesh->tag_create( name, tagType, tagLen * corners, 0, err );
91  MSQ_ERRZERO(err);
92  }
93  }
94 
95  return cornerHandles[corners];
96 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
static size_t size(Mesh::TagType type)
TagType
The type of a tag.
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
msq_std::vector< TagHandle > cornerHandles

Here is the call graph for this function:

Here is the caller graph for this function:

TagHandle get_handle ( Mesh mesh,
unsigned  num_corners,
MsqError err 
)

Get the tag handle for storing this tag type with the specified number of values (corners).

int num_corners ( PatchData pd,
int  elem_index 
)
static

Definition at line 44 of file Mesh/CornerTag.cpp.

References PatchData::element_by_index(), and MsqMeshEntity::vertex_count().

Referenced by CornerTagHandles::save_load_tags().

45 {
46  return pd->element_by_index(elem_index).vertex_count();
47 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int num_corners ( PatchData pd,
int  elem_index 
)
static
void save_load_tags ( bool  load,
PatchData pd,
size_t  elem_index,
void *  data,
size_t  tag_byes,
MsqError err 
)

Definition at line 98 of file Mesh/CornerTag.cpp.

References CornerTagHandles::get_current_mesh(), PatchData::get_element_array(), PatchData::get_element_handles_array(), CornerTagHandles::get_handle(), MSQ_CHKERR, MSQ_ERRRTN, CornerTagHandles::num_corners(), Mesh::tag_get_element_data(), Mesh::tag_set_element_data(), and MsqMeshEntity::vertex_count().

101 {
102  Mesh* mesh = get_current_mesh( pd );
103  if (!mesh) // this happens for some tests in the test suite.
104  return;
105 
106  MsqMeshEntity* elem_array = pd->get_element_array( err );
107  unsigned num_corners = elem_array[elem_index].vertex_count();
108  const Mesh::ElementHandle handle = pd->get_element_handles_array()[elem_index];
109  TagHandle tag = get_handle( mesh, num_corners, err ); MSQ_ERRRTN(err);
110  if (load)
111  mesh->tag_get_element_data( tag, 1, &handle, data, err );
112  else
113  mesh->tag_set_element_data( tag, 1, &handle, data, err );
114  MSQ_CHKERR(err);
115 }
static Mesh * get_current_mesh(PatchData *pd)
EntityHandle ElementHandle
Class Mesh is the main class that holds all information to describe the current state of the mesh...
Definition: Mesh.hpp:19
#define MSQ_CHKERR(err)
Mesquite&#39;s Error Checking macro.
static int num_corners(PatchData *pd, int elem_index)
void * TagHandle
Type used to refer to a tag defintion.
TagHandle get_handle(Mesh *mesh, unsigned num_corners, MsqError &err)
Get the tag handle for storing this tag type with the specified number of values (corners).
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

void save_load_tags ( bool  load,
PatchData pd,
size_t  elem_index,
void *  data,
size_t  tag_byes,
MsqError err 
)
static size_t size ( Mesh::TagType  type)
static
size_t size ( Mesh::TagType  type)
static

Definition at line 32 of file Mesh/CornerTag.cpp.

References Mesh::BOOL, Mesh::BYTE, Mesh::DOUBLE, Mesh::HANDLE, and Mesh::INT.

Referenced by CornerTag< T >::CornerTag(), and CornerTagHandles::get_handle().

33 {
34  switch (type) {
35  case Mesh::BYTE: return 1;
36  case Mesh::BOOL: return sizeof(bool);
37  case Mesh::INT: return sizeof(int);
38  case Mesh::DOUBLE: return sizeof(double);
39  case Mesh::HANDLE: return sizeof(Mesh::EntityHandle);
40  default: return 0;
41  }
42 }
void * EntityHandle
Opaque EntityHandle type and tag type.

Here is the caller graph for this function:

Member Data Documentation

msq_std::vector< TagHandle > cornerHandles
private

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

Referenced by CornerTagHandles::get_handle().

const unsigned tagLen
private

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

Referenced by CornerTagHandles::get_handle().

const msq_std::string tagName
private

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

Referenced by CornerTagHandles::get_handle().

const Mesh::TagType tagType
private

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

Referenced by CornerTagHandles::get_handle().


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