Commit 56950bbf authored by Iulian Grindeanu's avatar Iulian Grindeanu Committed by vijaysm
Browse files

Add methods for tags and connectivities.

* TAGS: example is for int and double dense tags only
  example is for tag existing in the file already
  one of the tags is exchanged, the other one not
  (so the values on ghosts will be default, 0.0)

* Change the name of connectivity method
  instead of element connectivity, call it BlockElementConnectivity
  - add a connectivity method on single element
  - add info method on all visible elements
parent b3e5468d
This diff is collapsed.
......@@ -38,6 +38,17 @@ Comments from Mike and Emily:
#define iMOAB_LocalID int
#define ErrCode int
/*
* tag types can be: dense/sparse, int/ double/entityhandle , they could be on both elements and vertices
*/
enum MOAB_TAG_TYPE { DENSE_INTEGER = 0,
DENSE_DOUBLE ,
DENSE_ENTITYHANDLE,
SPARSE_INTEGER ,
SPARSE_DOUBLE ,
SPARSE_ENTITYHANDLE
};
/**
\fn ErrCode iMOABInitialize( int argc, iMOAB_String* argv )
\brief Initialize the iMOAB interface implementation and create the MOAB instance, if not created already (reference counted).
......@@ -240,21 +251,52 @@ ErrCode GetBlockID( iMOAB_AppID pid, int * block_length, iMOAB_GlobalID* global_
*/
ErrCode GetBlockInfo(iMOAB_AppID pid, iMOAB_GlobalID * global_block_ID, int* vertices_per_element, int* num_elements_in_block);
/**
\fn ErrCode GetVisibleElementsInfo(iMOAB_AppID pid, int* num_visible_elements, iMOAB_GlobalID * element_global_IDs, int * ranks, iMOAB_GlobalID * block_IDs)
\brief Get the elements information, global ids, ranks they belong to, block ids they belong to
<B>Operations:</B> Collective
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] num_visible_elements (int*) The global block ID of the set to be queried
\param[out] element_global_IDs (iMOAB_GlobalID*) The number of vertices per element
\param[out] ranks (int*) The owning ranks of elements
\param[out] block_IDs (iMOAB_GlobalID*) The block ids the elements belong
*/
ErrCode GetVisibleElementsInfo(iMOAB_AppID pid, int* num_visible_elements,
iMOAB_GlobalID * element_global_IDs, int * ranks, iMOAB_GlobalID * block_IDs);
/**
\fn ErrCode GetElementConnectivity(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int connectivity_length, int* element_connectivity)
\fn ErrCode GetBlockElementConnectivities(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int connectivity_length, int* element_connectivity)
\brief Get the connectivity for elements within a certain block;
<B>Operations:</B> Collective
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] global_block_ID (iMOAB_GlobalID) The global block ID of the set being queried
\param[in] connectivity_length (int) The allocated size of array (typical <TT>size := vertices_per_element*num_elements_in_block</TT>)
\param[in] global_block_ID (iMOAB_GlobalID*) The global block ID of the set being queried
\param[in] connectivity_length (int*) The allocated size of array (typical <TT>size := vertices_per_element*num_elements_in_block</TT>)
\param[out] element_connectivity (int*) The connectivity array to store element ordering in MOAB canonical numbering scheme (array allocated by client);
array contains vertex indices in the local numbering order for vertices
elements are in the same order as provided by GetElementOwnership and GetElementID
*/
ErrCode GetElementConnectivity(iMOAB_AppID pid, iMOAB_GlobalID * global_block_ID, int * connectivity_length, int* element_connectivity);
ErrCode GetBlockElementConnectivities(iMOAB_AppID pid, iMOAB_GlobalID * global_block_ID, int * connectivity_length, int* element_connectivity);
/**
\fn ErrCode GetElementConnectivity(iMOAB_AppID pid, iMOAB_LocalID * elem_index, int * connectivity_length, int* element_connectivity)
\brief Get the connectivity for one element
<B>Operations:</B> Collective
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] elem_index (iMOAB_LocalID *) Local element index
\param[in/out] connectivity_length (int *) The allocated size of array (max 27)
\param[out] element_connectivity (int*) The connectivity array to store connectivity in MOAB canonical numbering scheme
array contains vertex indices in the local numbering order for vertices
*/
ErrCode GetElementConnectivity(iMOAB_AppID pid, iMOAB_LocalID * elem_index, int * connectivity_length, int* element_connectivity);
/**
\fn ErrCode GetElementOwnership(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int num_elements_in_block, int* element_ownership)
......@@ -323,11 +365,12 @@ ErrCode GetPointerToVertexBC(iMOAB_AppID pid, int * vertex_BC_length, iMOAB_Loca
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] tag_storage_name (iMOAB_String) The tag name to store/retreive the data in MOAB
\param[in] tag_type (int*) The type of MOAB tag (Dense/Sparse on Vertices/Elements, Double/Int/EntityHandle)
\param[in] tag_type (int*) The type of MOAB tag (Dense/Sparse, Double/Int/EntityHandle)
\param[in] components_per_entity (int*) The total size of vector dimension per entity for the tag (e.g., number of doubles per entity)
\param[out] tag_storage_data (int*) The array data of type <I>int</I> to be copied from the internal tag memory; The data is assumed to be contiguous over the local set of visible entities (either vertices or elements)
\param[in] tag_storage_name_length (int) The length of the tag_storage_name string
*/
ErrCode DefineTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int* tag_type, int* components_per_entity, int tag_storage_name_length);
ErrCode DefineTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int* tag_type, int* components_per_entity, int * tag_index, int tag_storage_name_length);
/**
\fn ErrCode SetIntTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num_tag_storage_length, int* tag_storage_data, int tag_storage_name_length)
......@@ -337,11 +380,12 @@ ErrCode DefineTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int* ta
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] tag_storage_name (iMOAB_String) The tag name to store/retreive the data in MOAB
\param[in] num_tag_storage_length (int) The size of tag storage data (e.g., num_visible_vertices*components_per_entity or num_visible_elements*components_per_entity)
\param[in] num_tag_storage_length (int*) The size of tag storage data (e.g., num_visible_vertices*components_per_entity or num_visible_elements*components_per_entity)
\param[in] entity_type (int*) type 0 for vertices, 1 for primary elements
\param[out] tag_storage_data (int*) The array data of type <I>int</I> to replace the internal tag memory; The data is assumed to be contiguous over the local set of visible entities (either vertices or elements)
\param[in] tag_storage_name_length (iMOAB_String) The length of the tag_storage_name string
*/
ErrCode SetIntTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num_tag_storage_length, int* tag_storage_data, int tag_storage_name_length);
ErrCode SetIntTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int * num_tag_storage_length, int * ent_type, int* tag_storage_data, int tag_storage_name_length);
/**
\fn ErrCode GetIntTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num_tag_storage_length, int* tag_storage_data, int tag_storage_name_length)
......@@ -351,11 +395,12 @@ ErrCode SetIntTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] tag_storage_name (iMOAB_String) The tag name to store/retreive the data in MOAB
\param[in] num_tag_storage_length (int) The size of tag storage data (e.g., num_visible_vertices*components_per_entity or num_visible_elements*components_per_entity)
\param[in] num_tag_storage_length (int*) The size of tag storage data (e.g., num_visible_vertices*components_per_entity or num_visible_elements*components_per_entity)
\param[in] entity_type (int*) type 0 for vertices, 1 for primary elements
\param[out] tag_storage_data (int*) The array data of type <I>int</I> to be copied from the internal tag memory; The data is assumed to be contiguous over the local set of visible entities (either vertices or elements)
\param[in] tag_storage_name_length (iMOAB_String) The length of the tag_storage_name string
*/
ErrCode GetIntTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num_tag_storage_length, int* tag_storage_data, int tag_storage_name_length);
ErrCode GetIntTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int *num_tag_storage_length, int * ent_type, int* tag_storage_data, int tag_storage_name_length);
/**
\fn ErrCode SetDoubleTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num_tag_storage_length, double* tag_storage_data, int tag_storage_name_length)
......@@ -365,11 +410,12 @@ ErrCode GetIntTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] tag_storage_name (iMOAB_String) The tag name to store/retreive the data in MOAB
\param[in] num_tag_storage_length (int) The size of tag storage data (e.g., num_visible_vertices*components_per_entity or num_visible_elements*components_per_entity)
\param[in] num_tag_storage_length (int*) The size of tag storage data (e.g., num_visible_vertices*components_per_entity or num_visible_elements*components_per_entity)
\param[in] entity_type (int*) type 0 for vertices, 1 for primary elements
\param[out] tag_storage_data (double*) The array data of type <I>double</I> to replace the internal tag memory; The data is assumed to be contiguous over the local set of visible entities (either vertices or elements)
\param[in] tag_storage_name_length (iMOAB_String) The length of the tag_storage_name string
*/
ErrCode SetDoubleTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num_tag_storage_length, double* tag_storage_data, int tag_storage_name_length);
ErrCode SetDoubleTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int * num_tag_storage_length, int * ent_type, double* tag_storage_data, int tag_storage_name_length);
/**
\fn ErrCode GetDoubleTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num_tag_storage_length, double* tag_storage_data, int tag_storage_name_length)
......@@ -380,10 +426,24 @@ ErrCode SetDoubleTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] tag_storage_name (iMOAB_String) The tag name to store/retreive the data in MOAB
\param[in] num_tag_storage_length (int) The size of tag storage data (e.g., num_visible_vertices*components_per_entity or num_visible_elements*components_per_entity)
\param[in] entity_type (int*) type 0 for vertices, 1 for primary elements
\param[out] tag_storage_data (double*) The array data of type <I>double</I> to be copied from the internal tag memory; The data is assumed to be contiguous over the local set of visible entities (either vertices or elements)
\param[in] tag_storage_name_length (int) The length of the tag_storage_name string
*/
ErrCode GetDoubleTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int num_tag_storage_length, double* tag_storage_data, int tag_storage_name_length);
ErrCode GetDoubleTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int * num_tag_storage_length, int * ent_type, double* tag_storage_data, int tag_storage_name_length);
/**
\fn ErrCode SynchronizeTags(iMOAB_AppID pid, int * num_tags, int * tag_indices, int * ent_type )
\brief Exchange tag values for given tags
<B>Operations:</B> Collective
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] num_tags (int*) Number of tags to exchange
\param[in] tag_indices (int*) Array with tag indices of interest (size = *num_tags)
\param[in] ent_type (int*) type of entity for tag exchange
*/
ErrCode SynchronizeTags(iMOAB_AppID pid, int * num_tag, int * tag_indices, int * ent_type);
/**
\fn ErrCode GetNeighborElements(iMOAB_AppID pid, iMOAB_GlobalID global_element_ID, int* num_adjacent_elements, iMOAB_GlobalID* adjacent_element_IDs)
......
......@@ -78,11 +78,28 @@ int main(int argc, char * argv[])
iMOAB_GlobalID * gbIDs = (iMOAB_GlobalID*) malloc(nblocks[2]*sizeof(iMOAB_GlobalID));
rc = GetBlockID(pid, &nblocks[2], gbIDs);
CHECKRC(rc, "failed to get block info");
/* the 2 tags used in this example exist in the file, already */
int tagIndex[2];
int entTypes[2] = {0, 1}; /* first is on vertex, second is on elements; */
int tagTypes[2] = { DENSE_INTEGER, DENSE_DOUBLE } ;
int num_components = 1;
rc = DefineTagStorage(pid, "INTFIELD", &tagTypes[0], &num_components, &tagIndex[0], strlen("INTFIELD") );
CHECKRC(rc, "failed to get tag INTFIELD ");
rc = DefineTagStorage(pid, "DFIELD", &tagTypes[1], &num_components, &tagIndex[1], strlen("DFIELD") );
CHECKRC(rc, "failed to get tag DFIELD ");
// synchronize one of the tags only, just to see what happens
int num_tags_to_sync=1;
rc = SynchronizeTags(pid, &num_tags_to_sync, &tagIndex[0], &tagTypes[0] );
CHECKRC(rc, "failed to sync tag INTFIELD ");
for (int irank=0; irank<nprocs; irank++)
{
if (irank==rank)
{
// printf some of the block info
/* printf some of the block info */
printf("on rank %d, there are \n"
" %3d visible vertices of which %3d local %3d ghost \n"
" %3d visible elements of which %3d owned %3d ghost \n"
......@@ -92,13 +109,37 @@ int main(int argc, char * argv[])
nverts[2], nverts[0], nverts[1],
nelem[2], nelem[0], nelem[1],
nblocks[2], nsbc[2], ndbc[2]);
// printf some of the vertex id infos
/* printf some of the vertex id infos */
int numToPrint = nverts[2];
printf("on rank %d vertex info:\n", rank);
for (int i=0; i<numToPrint; i++)
printf(" vertex local id: %3d, rank ID:%d global ID: %3d coords: %g, %g, %g\n", i, vranks[i], vGlobalID[i],
coords[3*i], coords[3*i+1], coords[3*i+2]);
iMOAB_GlobalID * element_global_IDs = (iMOAB_GlobalID*)malloc(nelem[2]*sizeof(iMOAB_GlobalID));
iMOAB_GlobalID * block_IDs = (iMOAB_GlobalID*)malloc(nelem[2]*sizeof(iMOAB_GlobalID));
int * ranks = (int*)malloc(nelem[2]*sizeof(int));
rc = GetVisibleElementsInfo(pid, &nelem[2], element_global_IDs, ranks, block_IDs);
CHECKRC(rc, "failed to get all elem info");
for (int i=0; i<nelem[2]; i++)
printf(" element local id: %3d, global ID: %3d rank:%d block ID: %2d \n", i, element_global_IDs[i],
ranks[i], block_IDs[i]);
free(element_global_IDs);
free(ranks);
free(block_IDs);
// get first element connectivity
int conn[27];
int nv = 27;
int eindex = 0;
rc = GetElementConnectivity(pid, &eindex, &nv, conn);
CHECKRC(rc, "failed to get first element connectivity");
printf(" conn for first element: \n");
for (int i=0; i<nv; i++)
printf(" %3d", conn[i]);
printf("\n");
for (int i=0; i<nblocks[2]; i++)
{
printf(" block index: %3d, block ID: %3d \n", i, gbIDs[i] );
......@@ -108,7 +149,7 @@ int main(int argc, char * argv[])
printf(" has %4d elements with %d vertices per element\n", num_elements_in_block, vertices_per_element);
int size_conn= num_elements_in_block*vertices_per_element;
iMOAB_LocalID * element_connectivity = (iMOAB_LocalID*) malloc (sizeof(iMOAB_LocalID)*size_conn);
rc = GetElementConnectivity(pid, &gbIDs[i], &size_conn, element_connectivity);
rc = GetBlockElementConnectivities(pid, &gbIDs[i], &size_conn, element_connectivity);
CHECKRC(rc, "failed to get block elem connectivity");
int * element_ownership = (int*) malloc (sizeof(int)*num_elements_in_block);
......@@ -131,7 +172,41 @@ int main(int argc, char * argv[])
free (element_connectivity);
free (element_ownership);
}
// query surface BCs
/*
* query int tag values on vertices
*/
int * int_tag_vals = (int *) malloc (sizeof(int) * nverts[2]); // for all visible vertices on the rank
rc = GetIntTagStorage(pid, "INTFIELD", &nverts[2], &entTypes[0],
int_tag_vals, strlen("INTFIELD"));
CHECKRC(rc, "failed to get INTFIELD tag");
printf("INTFIELD tag values:\n");
for (int i=0; i<nverts[2]; i++)
{
printf(" %4d", int_tag_vals[i]);
if (i%20==19)
printf("\n");
}
printf("\n");
free(int_tag_vals);
/*
* query double tag values on elements
*/
double * double_tag_vals = (double *) malloc (sizeof(double) * nelem[2]); // for all visible elements on the rank
rc = GetDoubleTagStorage(pid, "DFIELD", &nelem[2], &entTypes[1],
double_tag_vals, strlen("DFIELD"));
CHECKRC(rc, "failed to get DFIELD tag");
printf("DFIELD tag values: (not exchanged) \n");
for (int i=0; i<nelem[2]; i++)
{
printf(" %f", double_tag_vals[i]);
if (i%8==7)
printf("\n");
}
printf("\n");
free(double_tag_vals);
/* query surface BCs */
iMOAB_LocalID * surfBC_ID = (iMOAB_LocalID*) malloc (sizeof(iMOAB_LocalID)*nsbc[2]);
int * ref_surf = (int *) malloc (sizeof(int)*nsbc[2]);
int * bc_value = (int *) malloc (sizeof(int)*nsbc[2]);
......@@ -145,7 +220,7 @@ int main(int argc, char * argv[])
free(surfBC_ID);
free(ref_surf);
free(bc_value);
// query vertex BCs
/* query vertex BCs */
iMOAB_LocalID * vertBC_ID = (iMOAB_LocalID*) malloc (sizeof(iMOAB_LocalID)*ndbc[2]);
int * vertBC_value = (int *) malloc (sizeof(int)*ndbc[2]);
rc = GetPointerToVertexBC(pid, &ndbc[2], vertBC_ID, vertBC_value);
......
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment