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

Several interface changes and updates

- Use local elements ids, not global element ids
  also, for connectivity info, use local vertex ids,
  which would correspond to index in the local range
- Add routine to return the total number of blocks, elements, vertices,
- The GetMeshInfo arrays are size 3, but right now only the total is returned
- Report local/owned and ghost vertices/elements
  * For vertices and elements
      vertices and elements are arranged in order, first local,
      and then ghosts
  * Vertices can be local and not owned (moab terminology)
    those are at the interface
  * For elements it is always owned = local.
    This corresponds to the index in the local range, for
    all possible elements; first in the range should be owned/local.
- Now pass the length of arrays by reference too.
  So we will not have to pass by value for fortran
  the only pass by value will be for length of
  character strings, which is an automatic pass by
  the compiler, in some cases.
parent e0accc78
......@@ -755,7 +755,8 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.
INPUT = ../src \
../src/moab
../src/moab \
../test
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
......@@ -777,6 +778,7 @@ INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.cpp \
*.hpp \
*.c \
*.h \
*.dox \
*.F90
......@@ -794,7 +796,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.
EXCLUDE =
EXCLUDE = ../src/moab/mhdf.h
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
......
This diff is collapsed.
......@@ -184,9 +184,8 @@ ErrCode GetMeshInfo( iMOAB_AppID pid, int* num_visible_vertices, int* num_visibl
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] vertices_length (int) The allocated size of array (typical <TT>size := num_visible_vertices</TT>)
\param[out] global_vertex_ID (iMOAB_GlobalID*) The global IDs for all locally visible vertices (array allocated by client)
\param[out] local_vertex_ID (iMOAB_LocalID*) (<I><TT>Optional</TT></I>) The local IDs for all locally visible vertices (array allocated by client)
*/
ErrCode GetVertexID( iMOAB_AppID pid, int vertices_length, iMOAB_GlobalID* global_vertex_ID, iMOAB_LocalID* local_vertex_ID );
ErrCode GetVertexID( iMOAB_AppID pid, int * vertices_length, iMOAB_GlobalID* global_vertex_ID );
/**
\fn ErrCode GetVertexOwnership( iMOAB_AppID pid, int vertices_length, int* visible_global_rank_ID )
......@@ -202,7 +201,7 @@ ErrCode GetVertexID( iMOAB_AppID pid, int vertices_length, iMOAB_GlobalID* globa
\param[in] vertices_length (int) The allocated size of array (typically <TT>size := num_visible_vertices</TT>)
\param[out] visible_global_rank_ID (int*) The processor rank owning each of the local vertices
*/
ErrCode GetVertexOwnership( iMOAB_AppID pid, int vertices_length, int* visible_global_rank_ID );
ErrCode GetVertexOwnership( iMOAB_AppID pid, int * vertices_length, int* visible_global_rank_ID );
/**
\fn ErrCode GetVisibleVerticesCoordinates( iMOAB_AppID pid, int coords_length, double* coordinates )
......@@ -214,7 +213,7 @@ ErrCode GetVertexOwnership( iMOAB_AppID pid, int vertices_length, int* visible_g
\param[in] coords_length (int) The size of the allocated coordinate array (array allocated by client, <TT>size := 3*num_visible_vertices</TT>)
\param[out] coordinates (double*) The pointer to client allocated memory that will be filled with interleaved coordinates (do need an option for blocked coordinates ?)
*/
ErrCode GetVisibleVerticesCoordinates( iMOAB_AppID pid, int coords_length, double* coordinates );
ErrCode GetVisibleVerticesCoordinates( iMOAB_AppID pid, int * coords_length, double* coordinates );
/**
\fn ErrCode GetBlockID( iMOAB_AppID pid, int block_length, iMOAB_GlobalID* global_block_IDs, iMOAB_LocalID* local_block_IDs )
......@@ -225,9 +224,8 @@ ErrCode GetVisibleVerticesCoordinates( iMOAB_AppID pid, int coords_length, doubl
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] block_length (int) The allocated size of array (typical <TT>size := num_visible_blocks</TT>)
\param[out] global_block_IDs (iMOAB_GlobalID*) The global IDs for all locally visible blocks (array allocated by client)
\param[out] local_block_IDs (iMOAB_LocalID*) (<I><TT>Optional</TT></I>) The local IDs for all locally visible blocks (array allocated by client)
*/
ErrCode GetBlockID( iMOAB_AppID pid, int block_length, iMOAB_GlobalID* global_block_IDs, iMOAB_LocalID* local_block_IDs );
ErrCode GetBlockID( iMOAB_AppID pid, int * block_length, iMOAB_GlobalID* global_block_IDs);
/**
\fn ErrCode GetBlockInfo(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int* vertices_per_element, int* num_elements_in_block)
......@@ -240,20 +238,23 @@ ErrCode GetBlockID( iMOAB_AppID pid, int block_length, iMOAB_GlobalID* global_bl
\param[out] vertices_per_element (int*) The number of vertices per element
\param[out] num_elements_in_block (int*) The number of elements in block
*/
ErrCode GetBlockInfo(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int* vertices_per_element, int* num_elements_in_block);
ErrCode GetBlockInfo(iMOAB_AppID pid, iMOAB_GlobalID * global_block_ID, int* vertices_per_element, int* num_elements_in_block);
/**
\fn ErrCode GetElementConnectivity(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int connectivity_length, int* element_connectivity)
\brief Get the connectivity for elements within a certain block, ordered based on global element IDs
\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_visible_elements</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 identifiers with global ID numbering
\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 GetElementConnectivity(iMOAB_AppID pid, iMOAB_GlobalID * global_block_ID, 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)
......@@ -266,7 +267,7 @@ ErrCode GetElementConnectivity(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID,
\param[in] num_elements_in_block (int) The allocated size of ownership array, same as <TT>num_elements_in_block</TT> returned from GetBlockInfo()
\param[out] element_ownership (int*) The ownership array to store processor ID for all elements (array allocated by client)
*/
ErrCode GetElementOwnership(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int num_elements_in_block, int* element_ownership);
ErrCode GetElementOwnership(iMOAB_AppID pid, iMOAB_GlobalID * global_block_ID, int * num_elements_in_block, int* element_ownership);
/**
\fn ErrCode GetElementID(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int num_elements_in_block, iMOAB_GlobalID* global_element_ID, iMOAB_LocalID* local_element_ID)
......@@ -278,9 +279,9 @@ ErrCode GetElementOwnership(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int
\param[in] global_block_ID (iMOAB_GlobalID) The global block ID of the set being queried
\param[in] num_elements_in_block (int) The allocated size of global element ID array, same as <TT>num_elements_in_block</TT> returned from GetBlockInfo()
\param[out] global_element_ID (iMOAB_GlobalID*) The global IDs for all locally visible elements (array allocated by client)
\param[out] local_element_ID (iMOAB_LocalID*) (<I><TT>Optional</TT></I>) The local IDs for all locally visible elements (array allocated by client)
\param[out] local_element_ID (iMOAB_LocalID*) (<I><TT>Optional</TT></I>) The local IDs for all locally visible elements (index in the range of all primary elements in the rank)
*/
ErrCode GetElementID(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int num_elements_in_block, iMOAB_GlobalID* global_element_ID, iMOAB_LocalID* local_element_ID);
ErrCode GetElementID(iMOAB_AppID pid, iMOAB_GlobalID * global_block_ID, int * num_elements_in_block, iMOAB_GlobalID* global_element_ID, iMOAB_LocalID* local_element_ID);
/**
\fn ErrCode GetPointerToSurfaceBC(iMOAB_AppID pid, int surface_BC_length, iMOAB_GlobalID* global_element_ID, int* reference_surface_ID, int* boundary_condition_value)
......@@ -290,11 +291,11 @@ ErrCode GetElementID(iMOAB_AppID pid, iMOAB_GlobalID global_block_ID, int num_el
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] surface_BC_length (int) The allocated size of surface boundary condition array, same as <TT>num_visible_surfaceBC</TT> returned by GetMeshInfo()
\param[out] global_element_ID (iMOAB_GlobalID*) The global element IDs that contains the side with the surface BC
\param[out] local_element_ID (iMOAB_LocalID*) The local element IDs that contains the side with the surface BC
\param[out] reference_surface_ID (int*) The surface number with the BC in the canonical reference element (e.g., 1 to 6 for HEX, 1-4 for TET)
\param[out] boundary_condition_value (int*) The boundary condition type as obtained from the mesh description (value of the NeumannSet defined on the element)
*/
ErrCode GetPointerToSurfaceBC(iMOAB_AppID pid, int surface_BC_length, iMOAB_GlobalID* global_element_ID, int* reference_surface_ID, int* boundary_condition_value);
ErrCode GetPointerToSurfaceBC(iMOAB_AppID pid, int * surface_BC_length, iMOAB_LocalID* local_element_ID, int* reference_surface_ID, int* boundary_condition_value);
/**
\fn ErrCode GetPointerToVertexBC(iMOAB_AppID pid, int vertex_BC_length, iMOAB_GlobalID* global_vertext_ID, int* num_vertex_BC, int* boundary_condition_value)
......@@ -304,10 +305,10 @@ ErrCode GetPointerToSurfaceBC(iMOAB_AppID pid, int surface_BC_length, iMOAB_Glob
\param[in] pid (iMOAB_AppID) The unique pointer to the application ID
\param[in] vertex_BC_length (int) The allocated size of vertex boundary condition array, same as <TT>num_visible_vertexBC</TT> returned by GetMeshInfo()
\param[out] global_vertext_ID (iMOAB_GlobalID*) The global vertex ID that has Dirichlet BC defined
\param[out] local_vertex_ID (iMOAB_LocalID*) The local vertex ID that has Dirichlet BC defined
\param[out] boundary_condition_value (int*) The boundary condition type as obtained from the mesh description (value of the DirichletSet defined on the vertex)
*/
ErrCode GetPointerToVertexBC(iMOAB_AppID pid, int vertex_BC_length, iMOAB_GlobalID* global_vertext_ID, int* boundary_condition_value);
ErrCode GetPointerToVertexBC(iMOAB_AppID pid, int * vertex_BC_length, iMOAB_LocalID* local_vertex_ID, int* boundary_condition_value);
/**
\fn ErrCode DefineTagStorage(iMOAB_AppID pid, iMOAB_String tag_storage_name, int* tag_type, int* components_per_entity, int tag_storage_name_length)
......
......@@ -44,26 +44,39 @@ int main(int argc, char * argv[])
rc = LoadMesh( pid, filen, read_opts, &num_ghost_layers, strlen(filen), strlen(read_opts) );
CHECKRC(rc, "failed to load mesh");
int nverts, nelem, nblocks, nsbc, ndbc;
rc = GetMeshInfo( pid, &nverts, &nelem, &nblocks, &nsbc, &ndbc);
// nverts[0]: number of local vertices (used to represent initial partition, before ghosting
// in moab terminology, nverts[0] has owned and shared vertices on the interfaces
// some of the shared vertices could be actually owned by another task
// nverts[1]: number of ghost vertices, appear after ghosting
// nverts[2]: total number of vertices, local + ghost
// we do not have that problem / terminology for elements
// elements are either owned (local, in the initial partition) or ghosted
// nblocks as the number of material sets( visible blocks) is different
// blocks[0] represent number of blocks completely owned by current partition
// blocks[1] is number of blocks with at least one ghost element in it
// blocks[2] is the total number of blocks visible on current rank
// any of the blocks [0] or blocks[1] can be 0
int nverts[3], nelem[3], nblocks[3], nsbc[3], ndbc[3];
rc = GetMeshInfo( pid, nverts, nelem, nblocks, nsbc, ndbc);
CHECKRC(rc, "failed to get mesh info");
iMOAB_GlobalID * vGlobalID = (iMOAB_GlobalID*)malloc(nverts*sizeof(iMOAB_GlobalID)) ;
iMOAB_LocalID * vLocalID = (iMOAB_LocalID*)malloc(nverts*sizeof(iMOAB_GlobalID)) ;
rc = GetVertexID(pid, nverts, vGlobalID, vLocalID );
iMOAB_GlobalID * vGlobalID = (iMOAB_GlobalID*)malloc(nverts[2]*sizeof(iMOAB_GlobalID)) ;
rc = GetVertexID(pid, &nverts[2], vGlobalID);
CHECKRC(rc, "failed to get vertex id info");
int * vranks = (int*)malloc(nverts*sizeof(int));
rc =GetVertexOwnership(pid, nverts, vranks );
int * vranks = (int*)malloc(nverts[2]*sizeof(int));
rc =GetVertexOwnership(pid, &nverts[2], vranks );
CHECKRC(rc, "failed to get vertex ranks");
double * coords = (double*) malloc(3*nverts*sizeof(double));
rc = GetVisibleVerticesCoordinates( pid, 3*nverts, coords);
double * coords = (double*) malloc(3*nverts[2]*sizeof(double));
int size_coords= 3*nverts[2];
rc = GetVisibleVerticesCoordinates( pid, &size_coords, coords);
CHECKRC(rc, "failed to get coordinates");
iMOAB_GlobalID * gbIDs = (iMOAB_GlobalID*) malloc(nblocks*sizeof(iMOAB_GlobalID));
iMOAB_LocalID * lbIDs = (iMOAB_LocalID*) malloc(nblocks*sizeof(iMOAB_LocalID));
rc = GetBlockID(pid, nblocks, gbIDs, lbIDs);
iMOAB_GlobalID * gbIDs = (iMOAB_GlobalID*) malloc(nblocks[2]*sizeof(iMOAB_GlobalID));
rc = GetBlockID(pid, &nblocks[2], gbIDs);
CHECKRC(rc, "failed to get block info");
for (int irank=0; irank<nprocs; irank++)
{
......@@ -71,41 +84,44 @@ int main(int argc, char * argv[])
{
// printf some of the block info
printf("on rank %d, there are \n"
" %d visible vertices\n"
" %d visible elements\n"
" %d visible blocks\n"
" %d visible neumann BCs\n"
" %d visible dirichlet BCs\n", rank, nverts, nelem, nblocks, nsbc, ndbc);
" %3d visible vertices of which %3d local %3d ghost \n"
" %3d visible elements of which %3d owned %3d ghost \n"
" %3d visible blocks\n"
" %3d visible neumann BCs\n"
" %3d visible dirichlet BCs\n", rank,
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
int numToPrint = nverts;
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",vLocalID[i], vranks[i], vGlobalID[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]);
for (int i=0; i<nblocks; i++)
for (int i=0; i<nblocks[2]; i++)
{
printf(" block index: %3d, block ID: %3d \n", lbIDs[i], gbIDs[i] );
printf(" block index: %3d, block ID: %3d \n", i, gbIDs[i] );
int vertices_per_element, num_elements_in_block;
rc = GetBlockInfo(pid, gbIDs[i] , &vertices_per_element, &num_elements_in_block);
rc = GetBlockInfo(pid, &gbIDs[i] , &vertices_per_element, &num_elements_in_block);
CHECKRC(rc, "failed to elem block info");
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_GlobalID * element_connectivity = (iMOAB_GlobalID*) malloc (sizeof(iMOAB_GlobalID)*size_conn);
rc = GetElementConnectivity(pid, gbIDs[i], size_conn, element_connectivity);
iMOAB_LocalID * element_connectivity = (iMOAB_LocalID*) malloc (sizeof(iMOAB_LocalID)*size_conn);
rc = GetElementConnectivity(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);
GetElementOwnership(pid, gbIDs[i], num_elements_in_block, element_ownership);
rc = GetElementOwnership(pid, &gbIDs[i], &num_elements_in_block, element_ownership);
CHECKRC(rc, "failed to get block elem ownership");
iMOAB_GlobalID* global_element_ID = (iMOAB_GlobalID*)malloc(sizeof(iMOAB_GlobalID)*num_elements_in_block);
iMOAB_LocalID* local_element_ID =(iMOAB_LocalID*)malloc(sizeof(iMOAB_LocalID)*num_elements_in_block);
rc = GetElementID(pid, gbIDs[i], num_elements_in_block, global_element_ID, local_element_ID);
rc = GetElementID(pid, &gbIDs[i], &num_elements_in_block, global_element_ID, local_element_ID);
CHECKRC(rc, "failed to get block elem IDs");
for (int j=0; j< num_elements_in_block; j++)
{
printf(" elem %3d owned by %d gid: %4d -- ", j, element_ownership[j], global_element_ID[j]);
printf(" elem %3d owned by %d gid: %4d lid: %4d -- ", j, element_ownership[j], global_element_ID[j], local_element_ID[j]);
for (int k=0; k<vertices_per_element; k++)
printf( " %5d", element_connectivity[j*vertices_per_element+k]);
printf("\n");
......@@ -116,26 +132,26 @@ int main(int argc, char * argv[])
free (element_ownership);
}
// query surface BCs
iMOAB_GlobalID * surfBC_ID = (iMOAB_GlobalID*) malloc (sizeof(iMOAB_GlobalID)*nsbc);
int * ref_surf = (int *) malloc (sizeof(int)*nsbc);
int * bc_value = (int *) malloc (sizeof(int)*nsbc);
rc = GetPointerToSurfaceBC(pid, nsbc, surfBC_ID, ref_surf, bc_value);
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]);
rc = GetPointerToSurfaceBC(pid, &nsbc[2], surfBC_ID, ref_surf, bc_value);
CHECKRC(rc, "failed to get surf boundary conditions");
printf(" Surface boundary conditions:\n");
for (int i=0; i<nsbc; i++)
for (int i=0; i<nsbc[2]; i++)
{
printf(" elemID %4d side:%d BC:%2d\n",surfBC_ID[i] ,ref_surf[i], bc_value[i] );
printf(" elem_localID %4d side:%d BC:%2d\n",surfBC_ID[i] ,ref_surf[i], bc_value[i] );
}
free(surfBC_ID);
free(ref_surf);
free(bc_value);
// query vertex BCs
iMOAB_GlobalID * vertBC_ID = (iMOAB_GlobalID*) malloc (sizeof(iMOAB_GlobalID)*ndbc);
int * vertBC_value = (int *) malloc (sizeof(int)*ndbc);
rc = GetPointerToVertexBC(pid, ndbc, vertBC_ID, vertBC_value);
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);
CHECKRC(rc, "failed to get vertex boundary conditions");
printf(" Vertex boundary conditions:\n");
for (int i=0; i<ndbc; i++)
for (int i=0; i<ndbc[2]; i++)
{
printf(" vertex %4d BC:%2d\n",vertBC_ID[i], vertBC_value[i] );
}
......@@ -148,7 +164,6 @@ int main(int argc, char * argv[])
// free allocated data
free(coords);
free (vGlobalID);
free (vLocalID);
free (vranks);
char outputFile[] = "fnew.h5m";
char writeOptions[] ="PARALLEL=WRITE_PART";
......
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