MOAB: Mesh Oriented datABase
(version 5.2.1)
|
#include "moab/MOABConfig.h"
#include "moab/Core.hpp"
#include "DebugOutput.hpp"
#include "moab/iMOAB.h"
#include "moab/CartVect.hpp"
#include "MBTagConventions.hpp"
#include "moab/MeshTopoUtil.hpp"
#include "moab/ReadUtilIface.hpp"
#include "moab/MergeMesh.hpp"
#include <cassert>
#include <sstream>
#include <iostream>
Go to the source code of this file.
Classes | |
struct | appData |
struct | GlobalContext |
Defines | |
#define | CHKERRVAL(ierr) |
#define | CHKIERRVAL(ierr) |
Functions | |
ErrCode | iMOAB_Initialize (int argc, iMOAB_String *argv) |
Initialize the iMOAB interface implementation. | |
ErrCode | iMOAB_InitializeFortran () |
Initialize the iMOAB interface implementation from Fortran driver. | |
ErrCode | iMOAB_Finalize () |
Finalize the iMOAB interface implementation. | |
ErrCode | iMOAB_RegisterApplication (const iMOAB_String app_name, int *compid, iMOAB_AppID pid) |
Register application - Create a unique application ID and bootstrap interfaces for further queries. | |
ErrCode | iMOAB_RegisterFortranApplication (const iMOAB_String app_name, int *compid, iMOAB_AppID pid, int app_name_length) |
Register a Fortran-based application - Create a unique application ID and bootstrap interfaces for further queries. | |
ErrCode | iMOAB_DeregisterApplication (iMOAB_AppID pid) |
De-Register application: delete mesh (set) associated with the application ID. | |
ErrCode | iMOAB_ReadHeaderInfo (const iMOAB_String filename, int *num_global_vertices, int *num_global_elements, int *num_dimension, int *num_parts, int filename_length) |
Get global information from the file. | |
ErrCode | iMOAB_LoadMesh (iMOAB_AppID pid, const iMOAB_String filename, const iMOAB_String read_options, int *num_ghost_layers, int filename_length, int read_options_length) |
Load a MOAB mesh file in parallel and exchange ghost layers as requested. | |
ErrCode | iMOAB_WriteMesh (iMOAB_AppID pid, iMOAB_String filename, iMOAB_String write_options, int filename_length, int write_options_length) |
Write a MOAB mesh along with the solution tags to a file. | |
ErrCode | iMOAB_UpdateMeshInfo (iMOAB_AppID pid) |
Update local mesh data structure, from file information. | |
ErrCode | iMOAB_GetMeshInfo (iMOAB_AppID pid, int *num_visible_vertices, int *num_visible_elements, int *num_visible_blocks, int *num_visible_surfaceBC, int *num_visible_vertexBC) |
retrieve mesh information. Number of visible vertices and cells include ghost entities. All arrays returned have size 3. Local entities are first, then ghost entities are next. Shared vertices can be owned in MOAB sense by different tasks. Ghost vertices and cells are always owned by other tasks. | |
ErrCode | iMOAB_GetVertexID (iMOAB_AppID pid, int *vertices_length, iMOAB_GlobalID *global_vertex_ID) |
Get the global vertex IDs for all locally visible (owned and shared/ghosted) vertices. | |
ErrCode | iMOAB_GetVertexOwnership (iMOAB_AppID pid, int *vertices_length, int *visible_global_rank_ID) |
Get vertex ownership information. | |
ErrCode | iMOAB_GetVisibleVerticesCoordinates (iMOAB_AppID pid, int *coords_length, double *coordinates) |
Get vertex coordinates for all local (owned and ghosted) vertices. | |
ErrCode | iMOAB_GetBlockID (iMOAB_AppID pid, int *block_length, iMOAB_GlobalID *global_block_IDs) |
Get the global block IDs for all locally visible (owned and shared/ghosted) blocks. | |
ErrCode | iMOAB_GetBlockInfo (iMOAB_AppID pid, iMOAB_GlobalID *global_block_ID, int *vertices_per_element, int *num_elements_in_block) |
Get the global block information and number of visible elements of belonging to a block (MATERIAL SET). | |
ErrCode | iMOAB_GetVisibleElementsInfo (iMOAB_AppID pid, int *num_visible_elements, iMOAB_GlobalID *element_global_IDs, int *ranks, iMOAB_GlobalID *block_IDs) |
Get the visible elements information. | |
ErrCode | iMOAB_GetBlockElementConnectivities (iMOAB_AppID pid, iMOAB_GlobalID *global_block_ID, int *connectivity_length, int *element_connectivity) |
Get the connectivities for elements within a certain block. | |
ErrCode | iMOAB_GetElementConnectivity (iMOAB_AppID pid, iMOAB_LocalID *elem_index, int *connectivity_length, int *element_connectivity) |
Get the connectivity for one element only. | |
ErrCode | iMOAB_GetElementOwnership (iMOAB_AppID pid, iMOAB_GlobalID *global_block_ID, int *num_elements_in_block, int *element_ownership) |
Get the element ownership within a certain block i.e., processor ID of the element owner. | |
ErrCode | iMOAB_GetElementID (iMOAB_AppID pid, iMOAB_GlobalID *global_block_ID, int *num_elements_in_block, iMOAB_GlobalID *global_element_ID, iMOAB_LocalID *local_element_ID) |
Get the global IDs for all locally visible elements belonging to a particular block. | |
ErrCode | iMOAB_GetPointerToSurfaceBC (iMOAB_AppID pid, int *surface_BC_length, iMOAB_LocalID *local_element_ID, int *reference_surface_ID, int *boundary_condition_value) |
Get the surface boundary condition information. | |
ErrCode | iMOAB_GetPointerToVertexBC (iMOAB_AppID pid, int *vertex_BC_length, iMOAB_LocalID *local_vertex_ID, int *boundary_condition_value) |
Get the vertex boundary condition information. | |
ErrCode | iMOAB_DefineTagStorage (iMOAB_AppID pid, const iMOAB_String tag_storage_name, int *tag_type, int *components_per_entity, int *tag_index, int tag_storage_name_length) |
Define a MOAB Tag corresponding to the application depending on requested types. | |
ErrCode | iMOAB_SetIntTagStorage (iMOAB_AppID pid, const iMOAB_String tag_storage_name, int *num_tag_storage_length, int *ent_type, int *tag_storage_data, int tag_storage_name_length) |
Store the specified values in a MOAB integer Tag. | |
ErrCode | iMOAB_GetIntTagStorage (iMOAB_AppID pid, const iMOAB_String tag_storage_name, int *num_tag_storage_length, int *ent_type, int *tag_storage_data, int tag_storage_name_length) |
Get the specified values in a MOAB integer Tag. | |
ErrCode | iMOAB_SetDoubleTagStorage (iMOAB_AppID pid, const iMOAB_String tag_storage_name, int *num_tag_storage_length, int *ent_type, double *tag_storage_data, int tag_storage_name_length) |
Store the specified values in a MOAB double Tag. | |
ErrCode | iMOAB_GetDoubleTagStorage (iMOAB_AppID pid, const iMOAB_String tag_storage_name, int *num_tag_storage_length, int *ent_type, double *tag_storage_data, int tag_storage_name_length) |
Retrieve the specified values in a MOAB double Tag. | |
ErrCode | iMOAB_SynchronizeTags (iMOAB_AppID pid, int *num_tag, int *tag_indices, int *ent_type) |
Exchange tag values for given tags. | |
ErrCode | iMOAB_ReduceTagsMax (iMOAB_AppID pid, int *tag_index, int *ent_type) |
reduce max tag for a given tag | |
ErrCode | iMOAB_GetNeighborElements (iMOAB_AppID pid, iMOAB_LocalID *local_index, int *num_adjacent_elements, iMOAB_LocalID *adjacent_element_IDs) |
retrieve the adjacencies for the element entities. | |
ErrCode | iMOAB_CreateVertices (iMOAB_AppID pid, int *coords_len, int *dim, double *coordinates) |
Create vertices for an app; it assumes no other vertices. | |
ErrCode | iMOAB_CreateElements (iMOAB_AppID pid, int *num_elem, int *type, int *num_nodes_per_element, int *connectivity, int *block_ID) |
Create elements for an app; it assumes connectivity from local vertices, in order. | |
ErrCode | iMOAB_SetGlobalInfo (iMOAB_AppID pid, int *num_global_verts, int *num_global_elems) |
Set global information for number of vertices and number of elements it is usually available from hdf5 file or it can be computed with MPI_Reduce. | |
ErrCode | iMOAB_GetGlobalInfo (iMOAB_AppID pid, int *num_global_verts, int *num_global_elems) |
Get global information about number of vertices and number of elements. | |
static void | split_tag_names (std::string input_names, std::string &separator, std::vector< std::string > &list_tag_names) |
Variables | |
static struct GlobalContext | context |
Definition in file iMOAB.cpp.
{ \ if( moab::MB_SUCCESS != ierr ) return 1; \ }
Definition at line 53 of file iMOAB.cpp.
Referenced by iMOAB_CreateElements(), iMOAB_CreateVertices(), iMOAB_DeregisterApplication(), iMOAB_GetBlockElementConnectivities(), iMOAB_GetBlockID(), iMOAB_GetBlockInfo(), iMOAB_GetDoubleTagStorage(), iMOAB_GetElementConnectivity(), iMOAB_GetElementID(), iMOAB_GetElementOwnership(), iMOAB_GetIntTagStorage(), iMOAB_GetMeshInfo(), iMOAB_GetNeighborElements(), iMOAB_GetPointerToSurfaceBC(), iMOAB_GetPointerToVertexBC(), iMOAB_GetVertexID(), iMOAB_GetVertexOwnership(), iMOAB_GetVisibleElementsInfo(), iMOAB_GetVisibleVerticesCoordinates(), iMOAB_Initialize(), iMOAB_LoadMesh(), iMOAB_ReduceTagsMax(), iMOAB_RegisterApplication(), iMOAB_SetDoubleTagStorage(), iMOAB_SetIntTagStorage(), iMOAB_SynchronizeTags(), iMOAB_UpdateMeshInfo(), and iMOAB_WriteMesh().
#define CHKIERRVAL | ( | ierr | ) |
ErrCode iMOAB_CreateElements | ( | iMOAB_AppID | pid, |
int * | num_elem, | ||
int * | type, | ||
int * | num_nodes_per_element, | ||
int * | connectivity, | ||
int * | block_ID | ||
) |
Create elements for an app; it assumes connectivity from local vertices, in order.
Operations: Not collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | num_elem | (int*) number of elements |
[in] | type | (int*) type of element (moab type) |
[in] | num_nodes_per_element | (int*) number of nodes per element |
[in] | connectivity | (int *) connectivity array, with respect to vertices; assumes vertices contiguous |
[in] | block_ID | (int *) block_ID to which the elements will be added to |
add the new ents to the clock set
Definition at line 1632 of file iMOAB.cpp.
References GlobalContext::appDatas, CHKERRVAL, context, moab::Range::empty(), appData::file_set, moab::ReadUtilIface::get_element_connect(), appData::local_verts, GlobalContext::material_tag, MB_FAILURE, MBENTITYSET, GlobalContext::MBI, moab::Range::merge(), MESHSET_SET, appData::primary_elems, and moab::ReadUtilIface::update_adjacencies().
{ // Create elements appData& data = context.appDatas[*pid]; ReadUtilIface* read_iface; ErrorCode rval = context.MBI->query_interface( read_iface );CHKERRVAL( rval ); EntityType mbtype = ( EntityType )( *type ); EntityHandle actual_start_handle; EntityHandle* array = NULL; rval = read_iface->get_element_connect( *num_elem, *num_nodes_per_element, mbtype, 1, actual_start_handle, array );CHKERRVAL( rval ); // fill up with actual connectivity from input; assume the vertices are in order, and start // vertex is the first in the current data vertex range EntityHandle firstVertex = data.local_verts[0]; for( int j = 0; j < *num_elem * ( *num_nodes_per_element ); j++ ) { array[j] = connectivity[j] + firstVertex - 1; } // assumes connectivity uses 1 based array (from fortran, mostly) Range new_elems( actual_start_handle, actual_start_handle + *num_elem - 1 ); rval = context.MBI->add_entities( data.file_set, new_elems );CHKERRVAL( rval ); data.primary_elems.merge( new_elems ); // add to adjacency rval = read_iface->update_adjacencies( actual_start_handle, *num_elem, *num_nodes_per_element, array );CHKERRVAL( rval ); // organize all new elements in block, with the given block ID; if the block set is not // existing, create a new mesh set; Range sets; int set_no = *block_ID; const void* setno_ptr = &set_no; rval = context.MBI->get_entities_by_type_and_tag( data.file_set, MBENTITYSET, &context.material_tag, &setno_ptr, 1, sets ); EntityHandle block_set; if( MB_FAILURE == rval || sets.empty() ) { // create a new set, with this block ID rval = context.MBI->create_meshset( MESHSET_SET, block_set );CHKERRVAL( rval ); rval = context.MBI->tag_set_data( context.material_tag, &block_set, 1, &set_no );CHKERRVAL( rval ); // add the material set to file set rval = context.MBI->add_entities( data.file_set, &block_set, 1 );CHKERRVAL( rval ); } else { block_set = sets[0]; } // first set is the one we want /// add the new ents to the clock set rval = context.MBI->add_entities( block_set, new_elems );CHKERRVAL( rval ); return 0; }
ErrCode iMOAB_CreateVertices | ( | iMOAB_AppID | pid, |
int * | coords_len, | ||
int * | dim, | ||
double * | coordinates | ||
) |
Create vertices for an app; it assumes no other vertices.
Operations: Not collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | coords_len | (int*) size of the coords array (nverts * dim) |
[in] | dim | (int*) dimension (usually 3) |
[in] | coordinates | (double*) coordinates of all vertices, interleaved |
Definition at line 1613 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, dim, moab::Range::empty(), appData::file_set, appData::local_verts, GlobalContext::MBI, and moab::Range::merge().
{ ErrorCode rval; appData& data = context.appDatas[*pid]; if( !data.local_verts.empty() ) // we should have no vertices in the app { return 1; } int nverts = *coords_len / *dim; rval = context.MBI->create_vertices( coordinates, nverts, data.local_verts );CHKERRVAL( rval ); rval = context.MBI->add_entities( data.file_set, data.local_verts );CHKERRVAL( rval ); // also add the vertices to the all_verts range data.all_verts.merge( data.local_verts ); return 0; }
ErrCode iMOAB_DefineTagStorage | ( | iMOAB_AppID | pid, |
const iMOAB_String | tag_storage_name, | ||
int * | tag_type, | ||
int * | components_per_entity, | ||
int * | tag_index, | ||
int | tag_storage_name_length | ||
) |
Define a MOAB Tag corresponding to the application depending on requested types.
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | tag_storage_name | (iMOAB_String) The tag name to store/retrieve the data in MOAB |
[in] | tag_type | (int*) The type of MOAB tag (Dense/Sparse, Double/Int/EntityHandle), enum MOAB_TAG_TYPE |
[in] | components_per_entity | (int*) The total size of vector dimension per entity for the tag (e.g., number of doubles per entity) |
[out] | tag_index | (int*) The tag index which can be used as identifier in synchronize methods |
[in] | tag_storage_name_length | (int) The length of the tag_storage_name string |
Definition at line 1208 of file iMOAB.cpp.
References GlobalContext::appDatas, context, MB_ALREADY_ALLOCATED, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TAG_NOT_FOUND, MB_TAG_SPARSE, MB_TYPE_DOUBLE, MB_TYPE_HANDLE, MB_TYPE_INTEGER, GlobalContext::MBI, appData::tagList, and appData::tagMap.
{ // see if the tag is already existing, and if yes, check the type, length if( *tag_type < 0 || *tag_type > 5 ) { return 1; } // we have 6 types of tags supported so far DataType tagDataType; TagType tagType; void* defaultVal = NULL; int* defInt = new int[*components_per_entity]; double* defDouble = new double[*components_per_entity]; EntityHandle* defHandle = new EntityHandle[*components_per_entity]; for( int i = 0; i < *components_per_entity; i++ ) { defInt[i] = 0; defDouble[i] = -1e+10; defHandle[i] = (EntityHandle)0; } switch( *tag_type ) { case 0: tagDataType = MB_TYPE_INTEGER; tagType = MB_TAG_DENSE; defaultVal = defInt; break; case 1: tagDataType = MB_TYPE_DOUBLE; tagType = MB_TAG_DENSE; defaultVal = defDouble; break; case 2: tagDataType = MB_TYPE_HANDLE; tagType = MB_TAG_DENSE; defaultVal = defHandle; break; case 3: tagDataType = MB_TYPE_INTEGER; tagType = MB_TAG_SPARSE; defaultVal = defInt; break; case 4: tagDataType = MB_TYPE_DOUBLE; tagType = MB_TAG_SPARSE; defaultVal = defDouble; break; case 5: tagDataType = MB_TYPE_HANDLE; tagType = MB_TAG_SPARSE; defaultVal = defHandle; break; default: { delete[] defInt; delete[] defDouble; delete[] defHandle; return 1; } // error } std::string tag_name( tag_storage_name ); if( tag_storage_name_length < (int)strlen( tag_storage_name ) ) { tag_name = tag_name.substr( 0, tag_storage_name_length ); } Tag tagHandle; ErrorCode rval = context.MBI->tag_get_handle( tag_name.c_str(), *components_per_entity, tagDataType, tagHandle, tagType, defaultVal ); if( MB_TAG_NOT_FOUND == rval ) { rval = context.MBI->tag_get_handle( tag_name.c_str(), *components_per_entity, tagDataType, tagHandle, tagType | MB_TAG_CREAT, defaultVal ); } // we don't need default values anymore, avoid leaks delete[] defInt; delete[] defDouble; delete[] defHandle; appData& data = context.appDatas[*pid]; if( MB_ALREADY_ALLOCATED == rval ) { std::map< std::string, Tag >& mTags = data.tagMap; std::map< std::string, Tag >::iterator mit = mTags.find( tag_name ); if( mit == mTags.end() ) { // add it to the map mTags[tag_name] = tagHandle; // push it to the list of tags, too *tag_index = (int)data.tagList.size(); data.tagList.push_back( tagHandle ); } return 0; // OK, we found it, and we have it stored in the map tag } else if( MB_SUCCESS == rval ) { data.tagMap[tag_name] = tagHandle; *tag_index = (int)data.tagList.size(); data.tagList.push_back( tagHandle ); return 0; } else return 1; // some error, maybe the tag was not created }
De-Register application: delete mesh (set) associated with the application ID.
The associated communicator will be released, and all associated mesh entities and sets will be deleted from the mesh data structure. Associated tag storage data will be freed too.
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
Definition at line 309 of file iMOAB.cpp.
References GlobalContext::appDatas, GlobalContext::appIdCompMap, GlobalContext::appIdMap, CHKERRVAL, context, moab::Range::empty(), appData::file_set, appData::global_id, moab::Range::insert(), MBENTITYSET, GlobalContext::MBI, MBVERTEX, appData::name, moab::ParallelComm::rank(), moab::Range::subset_by_type(), moab::subtract(), smoab::UNION, and GlobalContext::unused_pid.
{ // the file set , parallel comm are all in vectors indexed by *pid // assume we did not delete anything yet // *pid will not be reused if we register another application appData& data = context.appDatas[*pid]; int rankHere = 0; #ifdef MOAB_HAVE_MPI ParallelComm* pco = context.pcomms[*pid]; rankHere = pco->rank(); #endif if( !rankHere ) std::cout << " application with ID: " << *pid << " global id: " << data.global_id << " name: " << data.name << " is de-registered now \n"; EntityHandle fileSet = data.file_set; // get all entities part of the file set Range fileents; ErrorCode rval = context.MBI->get_entities_by_handle( fileSet, fileents, /*recursive */ true );CHKERRVAL( rval ); fileents.insert( fileSet ); rval = context.MBI->get_entities_by_type( fileSet, MBENTITYSET, fileents );CHKERRVAL( rval ); // append all mesh sets #ifdef MOAB_HAVE_TEMPESTREMAP if( data.tempestData.remapper ) delete data.tempestData.remapper; if( data.tempestData.weightMaps.size() ) data.tempestData.weightMaps.clear(); #endif #ifdef MOAB_HAVE_MPI // we could get the pco also with // ParallelComm * pcomm = ParallelComm::get_pcomm(context.MBI, *pid); std::map< int, ParCommGraph* >& pargs = data.pgraph; // free the parallel comm graphs associated with this app for( std::map< int, ParCommGraph* >::iterator mt = pargs.begin(); mt != pargs.end(); mt++ ) { ParCommGraph* pgr = mt->second; delete pgr; pgr = NULL; } if( pco ) delete pco; #endif // delete first all except vertices Range vertices = fileents.subset_by_type( MBVERTEX ); Range noverts = subtract( fileents, vertices ); rval = context.MBI->delete_entities( noverts );CHKERRVAL( rval ); // now retrieve connected elements that still exist (maybe in other sets, pids?) Range adj_ents_left; rval = context.MBI->get_adjacencies( vertices, 1, false, adj_ents_left, Interface::UNION );CHKERRVAL( rval ); rval = context.MBI->get_adjacencies( vertices, 2, false, adj_ents_left, Interface::UNION );CHKERRVAL( rval ); rval = context.MBI->get_adjacencies( vertices, 3, false, adj_ents_left, Interface::UNION );CHKERRVAL( rval ); if( !adj_ents_left.empty() ) { Range conn_verts; rval = context.MBI->get_connectivity( adj_ents_left, conn_verts );CHKERRVAL( rval ); vertices = subtract( vertices, conn_verts ); } rval = context.MBI->delete_entities( vertices );CHKERRVAL( rval ); std::map< std::string, int >::iterator mit; for( mit = context.appIdMap.begin(); mit != context.appIdMap.end(); mit++ ) { int pidx = mit->second; if( *pid == pidx ) { break; } } context.appIdMap.erase( mit ); std::map< int, int >::iterator mit1; for( mit1 = context.appIdCompMap.begin(); mit1 != context.appIdCompMap.end(); mit1++ ) { int pidx = mit1->second; if( *pid == pidx ) { break; } } context.appIdCompMap.erase( mit1 ); context.unused_pid--; // we have to go backwards always TODO context.appDatas.pop_back(); #ifdef MOAB_HAVE_MPI context.pcomms.pop_back(); #endif return 0; }
Finalize the iMOAB interface implementation.
It will delete the internally reference counted MOAB instance, if the reference count reaches 0.
Operations: Collective
Definition at line 190 of file iMOAB.cpp.
References context, MB_SUCCESS, GlobalContext::MBI, and GlobalContext::refCountMB.
{ context.refCountMB--; if( 0 == context.refCountMB ) { delete context.MBI; } return MB_SUCCESS; }
ErrCode iMOAB_GetBlockElementConnectivities | ( | iMOAB_AppID | pid, |
iMOAB_GlobalID * | global_block_ID, | ||
int * | connectivity_length, | ||
int * | element_connectivity | ||
) |
Get the connectivities for elements within a certain block.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | global_block_ID | (iMOAB_GlobalID*) The global block ID of the set being queried |
[in] | connectivity_length | (int*) The allocated size of array (typical size := vertices_per_element*num_elements_in_block ) |
[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 |
Definition at line 977 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, moab::Range::index(), appData::mat_sets, appData::matIndex, and GlobalContext::MBI.
{ appData& data = context.appDatas[*pid]; std::map< int, int >& matMap = data.matIndex; std::map< int, int >::iterator it = matMap.find( *global_block_ID ); if( it == matMap.end() ) { return 1; } // error in finding block with id int blockIndex = matMap[*global_block_ID]; EntityHandle matMeshSet = data.mat_sets[blockIndex]; std::vector< EntityHandle > elems; ErrorCode rval = context.MBI->get_entities_by_handle( matMeshSet, elems );CHKERRVAL( rval ); if( elems.empty() ) { return 1; } std::vector< EntityHandle > vconnect; rval = context.MBI->get_connectivity( &elems[0], elems.size(), vconnect );CHKERRVAL( rval ); if( *connectivity_length != (int)vconnect.size() ) { return 1; } // mismatched sizes for( int i = 0; i < *connectivity_length; i++ ) { int inx = data.all_verts.index( vconnect[i] ); if( -1 == inx ) { return 1; } // error, vertex not in local range element_connectivity[i] = inx; } return 0; }
ErrCode iMOAB_GetBlockID | ( | iMOAB_AppID | pid, |
int * | block_length, | ||
iMOAB_GlobalID * | global_block_IDs | ||
) |
Get the global block IDs for all locally visible (owned and shared/ghosted) blocks.
Block IDs are corresponding to MATERIAL_SET tags for material sets. Usually the block ID is exported from Cubit as a unique integer value. First blocks are local, and next blocks are fully ghosted. First blocks have at least one owned cell/element, ghost blocks have only ghost cells. Internally, a block corresponds to a mesh set with a MATERIAL_SET tag value equal to the block ID.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | block_length | (int*) The allocated size of array (typical size := num_visible_blocks ) |
[out] | global_block_IDs | (iMOAB_GlobalID*) The global IDs for all locally visible blocks (array allocated by client) |
Definition at line 879 of file iMOAB.cpp.
References GlobalContext::appDatas, CHKERRVAL, context, GlobalContext::material_tag, GlobalContext::MBI, and moab::Range::size().
{ // local id blocks? they are counted from 0 to number of visible blocks ... // will actually return material set tag value for global Range& matSets = context.appDatas[*pid].mat_sets; if( *block_length != (int)matSets.size() ) { return 1; } // return material set tag gtags[0 is material set tag ErrorCode rval = context.MBI->tag_get_data( context.material_tag, matSets, global_block_IDs );CHKERRVAL( rval ); // populate map with index std::map< int, int >& matIdx = context.appDatas[*pid].matIndex; for( unsigned i = 0; i < matSets.size(); i++ ) { matIdx[global_block_IDs[i]] = i; } return 0; }
ErrCode iMOAB_GetBlockInfo | ( | iMOAB_AppID | pid, |
iMOAB_GlobalID * | global_block_ID, | ||
int * | vertices_per_element, | ||
int * | num_elements_in_block | ||
) |
Get the global block information and number of visible elements of belonging to a block (MATERIAL SET).
A block has to be homogeneous, it can contain elements of a single type
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | global_block_ID | (iMOAB_GlobalID) The global block ID of the set to be queried |
[out] | vertices_per_element | (int*) The number of vertices per element |
[out] | num_elements_in_block | (int*) The number of elements in block |
Definition at line 900 of file iMOAB.cpp.
References moab::Range::all_of_type(), GlobalContext::appDatas, CHKERRVAL, conn, context, moab::Range::empty(), MB_SUCCESS, GlobalContext::MBI, and moab::Range::size().
{ std::map< int, int >& matMap = context.appDatas[*pid].matIndex; std::map< int, int >::iterator it = matMap.find( *global_block_ID ); if( it == matMap.end() ) { return 1; } // error in finding block with id int blockIndex = matMap[*global_block_ID]; EntityHandle matMeshSet = context.appDatas[*pid].mat_sets[blockIndex]; Range blo_elems; ErrorCode rval = context.MBI->get_entities_by_handle( matMeshSet, blo_elems ); if( MB_SUCCESS != rval || blo_elems.empty() ) { return 1; } EntityType type = context.MBI->type_from_handle( blo_elems[0] ); if( !blo_elems.all_of_type( type ) ) { return 1; } // not all of same type const EntityHandle* conn = NULL; int num_verts = 0; rval = context.MBI->get_connectivity( blo_elems[0], conn, num_verts );CHKERRVAL( rval ); *vertices_per_element = num_verts; *num_elements_in_block = (int)blo_elems.size(); return 0; }
ErrCode iMOAB_GetDoubleTagStorage | ( | iMOAB_AppID | pid, |
const iMOAB_String | tag_storage_name, | ||
int * | num_tag_storage_length, | ||
int * | entity_type, | ||
double * | tag_storage_data, | ||
int | tag_storage_name_length | ||
) |
Retrieve the specified values in a MOAB double Tag.
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | tag_storage_name | (iMOAB_String) The tag name to store/retreive the data in MOAB |
[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) |
[in] | entity_type | (int*) type 0 for vertices, 1 for primary elements |
[out] | tag_storage_data | (double*) The array data of type double 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) |
[in] | tag_storage_name_length | (int) The length of the tag_storage_name string |
Definition at line 1461 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, MB_TYPE_DOUBLE, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), and appData::tagMap.
{ ErrorCode rval; // exactly the same code, except tag type check std::string tag_name( tag_storage_name ); if( tag_storage_name_length < (int)tag_name.length() ) { tag_name = tag_name.substr( 0, tag_storage_name_length ); } appData& data = context.appDatas[*pid]; if( data.tagMap.find( tag_name ) == data.tagMap.end() ) { return 1; } // tag not defined Tag tag = data.tagMap[tag_name]; int tagLength = 0; rval = context.MBI->tag_get_length( tag, tagLength );CHKERRVAL( rval ); DataType dtype; rval = context.MBI->tag_get_data_type( tag, dtype );CHKERRVAL( rval ); if( dtype != MB_TYPE_DOUBLE ) { return 1; } // set it on a subset of entities, based on type and length Range* ents_to_get = NULL; if( *ent_type == 0 ) // vertices { ents_to_get = &data.all_verts; } else if( *ent_type == 1 ) { ents_to_get = &data.primary_elems; } int nents_to_get = *num_tag_storage_length / tagLength; if( nents_to_get > (int)ents_to_get->size() || nents_to_get < 1 ) { return 1; } // to many entities to get // restrict the range; everything is contiguous; or not? // Range contig_range ( * ( ents_to_get->begin() ), * ( ents_to_get->begin() + nents_to_get - 1 // ) ); rval = context.MBI->tag_get_data( tag, *ents_to_get, tag_storage_data );CHKERRVAL( rval ); return 0; // no error }
ErrCode iMOAB_GetElementConnectivity | ( | iMOAB_AppID | pid, |
iMOAB_LocalID * | elem_index, | ||
int * | connectivity_length, | ||
int * | element_connectivity | ||
) |
Get the connectivity for one element only.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID. |
[in] | elem_index | (iMOAB_LocalID *) Local element index. |
[in,out] | connectivity_length | (int *) On input, maximum length of connectivity. On output, actual length. |
[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 |
Definition at line 1011 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, conn, context, moab::Range::index(), GlobalContext::MBI, appData::primary_elems, and moab::Range::size().
{ appData& data = context.appDatas[*pid]; assert( ( *elem_index >= 0 ) && ( *elem_index < (int)data.primary_elems.size() ) ); int num_nodes; const EntityHandle* conn; EntityHandle eh = data.primary_elems[*elem_index]; ErrorCode rval = context.MBI->get_connectivity( eh, conn, num_nodes );CHKERRVAL( rval ); if( *connectivity_length < num_nodes ) { return 1; } // wrong number of vertices for( int i = 0; i < num_nodes; i++ ) { int index = data.all_verts.index( conn[i] ); if( -1 == index ) { return 1; } element_connectivity[i] = index; } *connectivity_length = num_nodes; return 0; }
ErrCode iMOAB_GetElementID | ( | iMOAB_AppID | pid, |
iMOAB_GlobalID * | global_block_ID, | ||
int * | num_elements_in_block, | ||
iMOAB_GlobalID * | global_element_ID, | ||
iMOAB_LocalID * | local_element_ID | ||
) |
Get the global IDs for all locally visible elements belonging to a particular block.
The method will return also the local index of each element, in the local range that contains all visible elements
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | global_block_ID | (iMOAB_GlobalID*) The global block ID of the set being queried |
[in] | num_elements_in_block | (int*) The allocated size of global element ID array, same as num_elements_in_block returned from GetBlockInfo() |
[out] | global_element_ID | (iMOAB_GlobalID*) The global IDs for all locally visible elements (array allocated by client) |
[out] | local_element_ID | (iMOAB_LocalID*) (Optional ) The local IDs for all locally visible elements (index in the range of all primary elements in the rank) |
Definition at line 1076 of file iMOAB.cpp.
References GlobalContext::appDatas, CHKERRVAL, context, moab::Range::empty(), GlobalContext::globalID_tag, moab::Range::index(), appData::mat_sets, appData::matIndex, GlobalContext::MBI, appData::primary_elems, and moab::Range::size().
{ appData& data = context.appDatas[*pid]; std::map< int, int >& matMap = data.matIndex; std::map< int, int >::iterator it = matMap.find( *global_block_ID ); if( it == matMap.end() ) { return 1; } // error in finding block with id int blockIndex = matMap[*global_block_ID]; EntityHandle matMeshSet = data.mat_sets[blockIndex]; Range elems; ErrorCode rval = context.MBI->get_entities_by_handle( matMeshSet, elems );CHKERRVAL( rval ); if( elems.empty() ) { return 1; } if( *num_elements_in_block != (int)elems.size() ) { return 1; } // bad memory allocation rval = context.MBI->tag_get_data( context.globalID_tag, elems, global_element_ID );CHKERRVAL( rval ); // check that elems are among primary_elems in data for( int i = 0; i < *num_elements_in_block; i++ ) { local_element_ID[i] = data.primary_elems.index( elems[i] ); if( -1 == local_element_ID[i] ) { return 1; } // error, not in local primary elements } return 0; }
ErrCode iMOAB_GetElementOwnership | ( | iMOAB_AppID | pid, |
iMOAB_GlobalID * | global_block_ID, | ||
int * | num_elements_in_block, | ||
int * | element_ownership | ||
) |
Get the element ownership within a certain block i.e., processor ID of the element owner.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | global_block_ID | (iMOAB_GlobalID) The global block ID of the set being queried |
[in] | num_elements_in_block | (int*) The allocated size of ownership array, same as num_elements_in_block returned from GetBlockInfo() |
[out] | element_ownership | (int*) The ownership array to store processor ID for all elements (array allocated by client) |
Definition at line 1040 of file iMOAB.cpp.
References GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, moab::Range::empty(), moab::Range::end(), moab::ParallelComm::get_owner(), GlobalContext::MBI, and moab::Range::size().
{ std::map< int, int >& matMap = context.appDatas[*pid].matIndex; std::map< int, int >::iterator it = matMap.find( *global_block_ID ); if( it == matMap.end() ) { return 1; } // error in finding block with id int blockIndex = matMap[*global_block_ID]; EntityHandle matMeshSet = context.appDatas[*pid].mat_sets[blockIndex]; Range elems; ErrorCode rval = context.MBI->get_entities_by_handle( matMeshSet, elems );CHKERRVAL( rval ); if( elems.empty() ) { return 1; } if( *num_elements_in_block != (int)elems.size() ) { return 1; } // bad memory allocation int i = 0; #ifdef MOAB_HAVE_MPI ParallelComm* pco = context.pcomms[*pid]; #endif for( Range::iterator vit = elems.begin(); vit != elems.end(); vit++, i++ ) { #ifdef MOAB_HAVE_MPI rval = pco->get_owner( *vit, element_ownership[i] );CHKERRVAL( rval ); #else element_ownership[i] = 0; /* owned by 0 */ #endif } return 0; }
ErrCode iMOAB_GetGlobalInfo | ( | iMOAB_AppID | pid, |
int * | num_global_verts, | ||
int * | num_global_elems | ||
) |
Get global information about number of vertices and number of elements.
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | num_global_verts | (int*) number of total vertices |
[in] | global | (MPI_Comm) number of total elements |
Definition at line 1701 of file iMOAB.cpp.
References GlobalContext::appDatas, context, appData::num_global_elements, and appData::num_global_vertices.
{ appData& data = context.appDatas[*pid]; if( NULL != num_global_verts ) { *num_global_verts = data.num_global_vertices; } if( NULL != num_global_elems ) { *num_global_elems = data.num_global_elements; } return 0; }
ErrCode iMOAB_GetIntTagStorage | ( | iMOAB_AppID | pid, |
const iMOAB_String | tag_storage_name, | ||
int * | num_tag_storage_length, | ||
int * | entity_type, | ||
int * | tag_storage_data, | ||
int | tag_storage_name_length | ||
) |
Get the specified values in a MOAB integer Tag.
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | tag_storage_name | (iMOAB_String) The tag name to store/retreive the data in MOAB |
[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) |
[in] | entity_type | (int*) type 0 for vertices, 1 for primary elements |
[out] | tag_storage_data | (int*) The array data of type int 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) |
[in] | tag_storage_name_length | (iMOAB_String) The length of the tag_storage_name string |
Definition at line 1369 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, MB_TYPE_INTEGER, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), and appData::tagMap.
{ ErrorCode rval; std::string tag_name( tag_storage_name ); if( tag_storage_name_length < (int)tag_name.length() ) { tag_name = tag_name.substr( 0, tag_storage_name_length ); } appData& data = context.appDatas[*pid]; if( data.tagMap.find( tag_name ) == data.tagMap.end() ) { return 1; } // tag not defined Tag tag = data.tagMap[tag_name]; int tagLength = 0; rval = context.MBI->tag_get_length( tag, tagLength );CHKERRVAL( rval ); DataType dtype; rval = context.MBI->tag_get_data_type( tag, dtype );CHKERRVAL( rval ); if( dtype != MB_TYPE_INTEGER ) { return 1; } // set it on a subset of entities, based on type and length Range* ents_to_get; if( *ent_type == 0 ) // vertices { ents_to_get = &data.all_verts; } else // if (*ent_type == 1) { ents_to_get = &data.primary_elems; } int nents_to_get = *num_tag_storage_length / tagLength; if( nents_to_get > (int)ents_to_get->size() || nents_to_get < 1 ) { return 1; } // to many entities to get, or too little // restrict the range; everything is contiguous; or not? // Range contig_range ( * ( ents_to_get->begin() ), * ( ents_to_get->begin() + nents_to_get - 1 // ) ); rval = context.MBI->tag_get_data( tag, *ents_to_get, tag_storage_data );CHKERRVAL( rval ); return 0; // no error }
ErrCode iMOAB_GetMeshInfo | ( | iMOAB_AppID | pid, |
int * | num_visible_vertices, | ||
int * | num_visible_elements, | ||
int * | num_visible_blocks, | ||
int * | num_visible_surfaceBC, | ||
int * | num_visible_vertexBC | ||
) |
retrieve mesh information. Number of visible vertices and cells include ghost entities. All arrays returned have size 3. Local entities are first, then ghost entities are next. Shared vertices can be owned in MOAB sense by different tasks. Ghost vertices and cells are always owned by other tasks.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[out] | num_visible_vertices | (int*) The number of vertices in the current partition/process arranged as: owned/shared only, ghosted, total_visible (array allocated by client, size := 3 ) |
[out] | num_visible_elements | (int*) The number of elements in current partition/process arranged as: owned only, ghosted/shared, total_visible (array allocated by client, size := 3 ) |
[out] | num_visible_blocks | (int*) The number of material sets in local mesh in current partition/process arranged as: owned only, ghosted/shared, total_visible (array allocated by client, size := 3 ) |
[out] | num_visible_surfaceBC | (int*) The number of mesh surfaces that have a NEUMANN_SET BC defined in local mesh in current partition/process arranged as: owned only, ghosted/shared, total_visible (array allocated by client, size := 3 ) |
[out] | num_visible_vertexBC | (int*) The number of vertices that have a DIRICHLET_SET BC defined in local mesh in current partition/process arranged as: owned only, ghosted/shared, total_visible (array allocated by client, size := 3 ) |
Definition at line 739 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, appData::dimension, appData::diri_sets, GlobalContext::dirichlet_tag, moab::Range::end(), appData::file_set, appData::ghost_elems, appData::ghost_vertices, appData::mat_sets, GlobalContext::material_tag, MBENTITYSET, GlobalContext::MBI, appData::neu_sets, GlobalContext::neumann_tag, appData::owned_elems, appData::primary_elems, moab::Range::size(), and smoab::UNION.
{ ErrorCode rval; appData& data = context.appDatas[*pid]; EntityHandle fileSet = data.file_set; // this will include ghost elements // first clear all data ranges; this can be called after ghosting if( num_visible_elements ) { num_visible_elements[2] = (int)data.primary_elems.size(); // separate ghost and local/owned primary elements num_visible_elements[0] = (int)data.owned_elems.size(); num_visible_elements[1] = (int)data.ghost_elems.size(); } if( num_visible_vertices ) { num_visible_vertices[2] = (int)data.all_verts.size(); num_visible_vertices[1] = (int)data.ghost_vertices.size(); num_visible_vertices[0] = num_visible_vertices[2] - num_visible_vertices[1]; // local are those that are not ghosts } if( num_visible_blocks ) { rval = context.MBI->get_entities_by_type_and_tag( fileSet, MBENTITYSET, &( context.material_tag ), 0, 1, data.mat_sets, Interface::UNION );CHKERRVAL( rval ); num_visible_blocks[2] = data.mat_sets.size(); num_visible_blocks[0] = num_visible_blocks[2]; num_visible_blocks[1] = 0; } if( num_visible_surfaceBC ) { rval = context.MBI->get_entities_by_type_and_tag( fileSet, MBENTITYSET, &( context.neumann_tag ), 0, 1, data.neu_sets, Interface::UNION );CHKERRVAL( rval ); num_visible_surfaceBC[2] = 0; // count how many faces are in each neu set, and how many regions are // adjacent to them; int numNeuSets = (int)data.neu_sets.size(); for( int i = 0; i < numNeuSets; i++ ) { Range subents; EntityHandle nset = data.neu_sets[i]; rval = context.MBI->get_entities_by_dimension( nset, data.dimension - 1, subents );CHKERRVAL( rval ); for( Range::iterator it = subents.begin(); it != subents.end(); ++it ) { EntityHandle subent = *it; Range adjPrimaryEnts; rval = context.MBI->get_adjacencies( &subent, 1, data.dimension, false, adjPrimaryEnts );CHKERRVAL( rval ); num_visible_surfaceBC[2] += (int)adjPrimaryEnts.size(); } } num_visible_surfaceBC[0] = num_visible_surfaceBC[2]; num_visible_surfaceBC[1] = 0; } if( num_visible_vertexBC ) { rval = context.MBI->get_entities_by_type_and_tag( fileSet, MBENTITYSET, &( context.dirichlet_tag ), 0, 1, data.diri_sets, Interface::UNION );CHKERRVAL( rval ); num_visible_vertexBC[2] = 0; int numDiriSets = (int)data.diri_sets.size(); for( int i = 0; i < numDiriSets; i++ ) { Range verts; EntityHandle diset = data.diri_sets[i]; rval = context.MBI->get_entities_by_dimension( diset, 0, verts );CHKERRVAL( rval ); num_visible_vertexBC[2] += (int)verts.size(); } num_visible_vertexBC[0] = num_visible_vertexBC[2]; num_visible_vertexBC[1] = 0; } return 0; }
ErrCode iMOAB_GetNeighborElements | ( | iMOAB_AppID | pid, |
iMOAB_LocalID * | local_index, | ||
int * | num_adjacent_elements, | ||
iMOAB_LocalID * | adjacent_element_IDs | ||
) |
retrieve the adjacencies for the element entities.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | local_index | (iMOAB_LocalID*) The local element ID for which adjacency information is needed |
[out] | num_adjacent_elements | (int*) The total number of adjacent elements |
[out] | adjacent_element_IDs | (iMOAB_LocalID*) The local element IDs of all adjacent elements to the current one (typically, num_total_sides for internal elements or num_total_sides-num_sides_on_boundary for boundary elements) |
Definition at line 1580 of file iMOAB.cpp.
References GlobalContext::appDatas, CHKERRVAL, context, appData::dimension, moab::MeshTopoUtil::get_bridge_adjacencies(), moab::Range::index(), GlobalContext::MBI, appData::primary_elems, and moab::Range::size().
{ ErrorCode rval; // one neighbor for each subentity of dimension-1 MeshTopoUtil mtu( context.MBI ); appData& data = context.appDatas[*pid]; EntityHandle eh = data.primary_elems[*local_index]; Range adjs; rval = mtu.get_bridge_adjacencies( eh, data.dimension - 1, data.dimension, adjs );CHKERRVAL( rval ); if( *num_adjacent_elements < (int)adjs.size() ) { return 1; } // not dimensioned correctly *num_adjacent_elements = (int)adjs.size(); for( int i = 0; i < *num_adjacent_elements; i++ ) { adjacent_element_IDs[i] = data.primary_elems.index( adjs[i] ); } return 0; }
ErrCode iMOAB_GetPointerToSurfaceBC | ( | iMOAB_AppID | pid, |
int * | surface_BC_length, | ||
iMOAB_LocalID * | local_element_ID, | ||
int * | reference_surface_ID, | ||
int * | boundary_condition_value | ||
) |
Get the surface boundary condition information.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | surface_BC_length | (int*) The allocated size of surface boundary condition array, same as num_visible_surfaceBC returned by GetMeshInfo() |
[out] | local_element_ID | (iMOAB_LocalID*) The local element IDs that contains the side with the surface BC |
[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) |
[out] | boundary_condition_value | (int*) The boundary condition type as obtained from the mesh description (value of the NeumannSet defined on the element) |
Definition at line 1108 of file iMOAB.cpp.
References GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, appData::dimension, moab::Range::end(), moab::Range::index(), GlobalContext::MBI, appData::neu_sets, GlobalContext::neumann_tag, appData::primary_elems, moab::side_number(), and moab::Range::size().
{ // we have to fill bc data for neumann sets;/ ErrorCode rval; // it was counted above, in GetMeshInfo appData& data = context.appDatas[*pid]; int numNeuSets = (int)data.neu_sets.size(); int index = 0; // index [0, surface_BC_length) for the arrays returned for( int i = 0; i < numNeuSets; i++ ) { Range subents; EntityHandle nset = data.neu_sets[i]; rval = context.MBI->get_entities_by_dimension( nset, data.dimension - 1, subents );CHKERRVAL( rval ); int neuVal; rval = context.MBI->tag_get_data( context.neumann_tag, &nset, 1, &neuVal );CHKERRVAL( rval ); for( Range::iterator it = subents.begin(); it != subents.end(); ++it ) { EntityHandle subent = *it; Range adjPrimaryEnts; rval = context.MBI->get_adjacencies( &subent, 1, data.dimension, false, adjPrimaryEnts );CHKERRVAL( rval ); // get global id of the primary ents, and side number of the quad/subentity // this is moab ordering for( Range::iterator pit = adjPrimaryEnts.begin(); pit != adjPrimaryEnts.end(); pit++ ) { EntityHandle primaryEnt = *pit; // get global id /*int globalID; rval = context.MBI->tag_get_data(gtags[3], &primaryEnt, 1, &globalID); if (MB_SUCCESS!=rval) return 1; global_element_ID[index] = globalID;*/ // get local element id local_element_ID[index] = data.primary_elems.index( primaryEnt ); if( -1 == local_element_ID[index] ) { return 1; } // did not find the element locally int side_number, sense, offset; rval = context.MBI->side_number( primaryEnt, subent, side_number, sense, offset );CHKERRVAL( rval ); reference_surface_ID[index] = side_number + 1; // moab is from 0 to 5, it needs 1 to 6 boundary_condition_value[index] = neuVal; index++; } } } if( index != *surface_BC_length ) { return 1; } // error in array allocations return 0; }
ErrCode iMOAB_GetPointerToVertexBC | ( | iMOAB_AppID | pid, |
int * | vertex_BC_length, | ||
iMOAB_LocalID * | local_vertex_ID, | ||
int * | boundary_condition_value | ||
) |
Get the vertex boundary condition information.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | vertex_BC_length | (int) The allocated size of vertex boundary condition array, same as num_visible_vertexBC returned by GetMeshInfo() |
[out] | local_vertex_ID | (iMOAB_LocalID*) The local vertex ID that has Dirichlet BC defined |
[out] | boundary_condition_value | (int*) The boundary condition type as obtained from the mesh description (value of the Dirichlet_Set tag defined on the vertex) |
Definition at line 1167 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, appData::diri_sets, GlobalContext::dirichlet_tag, moab::Range::end(), moab::Range::index(), GlobalContext::MBI, and moab::Range::size().
{ ErrorCode rval; // it was counted above, in GetMeshInfo appData& data = context.appDatas[*pid]; int numDiriSets = (int)data.diri_sets.size(); int index = 0; // index [0, *vertex_BC_length) for the arrays returned for( int i = 0; i < numDiriSets; i++ ) { Range verts; EntityHandle diset = data.diri_sets[i]; rval = context.MBI->get_entities_by_dimension( diset, 0, verts );CHKERRVAL( rval ); int diriVal; rval = context.MBI->tag_get_data( context.dirichlet_tag, &diset, 1, &diriVal );CHKERRVAL( rval ); for( Range::iterator vit = verts.begin(); vit != verts.end(); ++vit ) { EntityHandle vt = *vit; /*int vgid; rval = context.MBI->tag_get_data(gtags[3], &vt, 1, &vgid); if (MB_SUCCESS!=rval) return 1; global_vertext_ID[index] = vgid;*/ local_vertex_ID[index] = data.all_verts.index( vt ); if( -1 == local_vertex_ID[index] ) { return 1; } // vertex was not found boundary_condition_value[index] = diriVal; index++; } } if( *vertex_BC_length != index ) { return 1; } // array allocation issue return 0; }
ErrCode iMOAB_GetVertexID | ( | iMOAB_AppID | pid, |
int * | vertices_length, | ||
iMOAB_GlobalID * | global_vertex_ID | ||
) |
Get the global vertex IDs for all locally visible (owned and shared/ghosted) vertices.
The array should be allocated by the client, sized with the total number of visible vertices from iMOAB_GetMeshInfo method.
Operations: Not collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | vertices_length | (int*) The allocated size of array (typical size := num_visible_vertices ) |
[out] | global_vertex_ID | (iMOAB_GlobalID*) The global IDs for all locally visible vertices (array allocated by client) |
Definition at line 827 of file iMOAB.cpp.
References GlobalContext::appDatas, CHKERRVAL, context, GlobalContext::globalID_tag, GlobalContext::MBI, and moab::Range::size().
{ Range& verts = context.appDatas[*pid].all_verts; if( (int)verts.size() != *vertices_length ) { return 1; } // problem with array length // global id tag is context.globalID_tag ErrorCode rval = context.MBI->tag_get_data( context.globalID_tag, verts, global_vertex_ID );CHKERRVAL( rval ); return 0; }
ErrCode iMOAB_GetVertexOwnership | ( | iMOAB_AppID | pid, |
int * | vertices_length, | ||
int * | visible_global_rank_ID | ||
) |
Get vertex ownership information.
For each vertex based on the local ID, return the process that owns the vertex (local, shared or ghost)
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | vertices_length | (int*) The allocated size of array (typically size := num_visible_vertices ) |
[out] | visible_global_rank_ID | (int*) The processor rank owning each of the local vertices |
Definition at line 839 of file iMOAB.cpp.
References GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, moab::Range::end(), moab::ParallelComm::get_owner(), and moab::Range::size().
{ Range& verts = context.appDatas[*pid].all_verts; int i = 0; #ifdef MOAB_HAVE_MPI ParallelComm* pco = context.pcomms[*pid]; for( Range::iterator vit = verts.begin(); vit != verts.end(); vit++, i++ ) { ErrorCode rval = pco->get_owner( *vit, visible_global_rank_ID[i] );CHKERRVAL( rval ); } if( i != *vertices_length ) { return 1; } // warning array allocation problem #else /* everything owned by proc 0 */ if( (int)verts.size() != *vertices_length ) { return 1; } // warning array allocation problem for( Range::iterator vit = verts.begin(); vit != verts.end(); vit++, i++ ) { visible_global_rank_ID[i] = 0; } // all vertices are owned by processor 0, as this is serial run #endif return 0; }
ErrCode iMOAB_GetVisibleElementsInfo | ( | iMOAB_AppID | pid, |
int * | num_visible_elements, | ||
iMOAB_GlobalID * | element_global_IDs, | ||
int * | ranks, | ||
iMOAB_GlobalID * | block_IDs | ||
) |
Get the visible elements information.
Return for all visible elements the global IDs, ranks they belong to, block ids they belong to.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | num_visible_elements | (int*) The number of visible elements (returned by GetMeshInfo) |
[out] | element_global_IDs | (iMOAB_GlobalID*) element global ids |
[out] | ranks | (int*) The owning ranks of elements |
[out] | block_IDs | (iMOAB_GlobalID*) The block ids the elements belong to |
Definition at line 929 of file iMOAB.cpp.
References GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, moab::Range::end(), moab::ParallelComm::get_owner(), GlobalContext::globalID_tag, moab::Range::index(), appData::mat_sets, GlobalContext::material_tag, GlobalContext::MBI, and appData::primary_elems.
{ appData& data = context.appDatas[*pid]; #ifdef MOAB_HAVE_MPI ParallelComm* pco = context.pcomms[*pid]; #endif ErrorCode rval = context.MBI->tag_get_data( context.globalID_tag, data.primary_elems, element_global_IDs );CHKERRVAL( rval ); int i = 0; for( Range::iterator eit = data.primary_elems.begin(); eit != data.primary_elems.end(); ++eit, ++i ) { #ifdef MOAB_HAVE_MPI rval = pco->get_owner( *eit, ranks[i] );CHKERRVAL( rval ); #else /* everything owned by task 0 */ ranks[i] = 0; #endif } for( Range::iterator mit = data.mat_sets.begin(); mit != data.mat_sets.end(); ++mit ) { EntityHandle matMeshSet = *mit; Range elems; rval = context.MBI->get_entities_by_handle( matMeshSet, elems );CHKERRVAL( rval ); int valMatTag; rval = context.MBI->tag_get_data( context.material_tag, &matMeshSet, 1, &valMatTag );CHKERRVAL( rval ); for( Range::iterator eit = elems.begin(); eit != elems.end(); ++eit ) { EntityHandle eh = *eit; int index = data.primary_elems.index( eh ); if( -1 == index ) { return 1; } if( -1 >= *num_visible_elements ) { return 1; } block_IDs[index] = valMatTag; } } return 0; }
ErrCode iMOAB_GetVisibleVerticesCoordinates | ( | iMOAB_AppID | pid, |
int * | coords_length, | ||
double * | coordinates | ||
) |
Get vertex coordinates for all local (owned and ghosted) vertices.
Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | coords_length | (int*) The size of the allocated coordinate array (array allocated by client, size := 3*num_visible_vertices ) |
[out] | coordinates | (double*) The pointer to client allocated memory that will be filled with interleaved coordinates |
Definition at line 867 of file iMOAB.cpp.
References GlobalContext::appDatas, CHKERRVAL, context, GlobalContext::MBI, and moab::Range::size().
ErrCode iMOAB_Initialize | ( | int | argc, |
iMOAB_String * | argv | ||
) |
Initialize the iMOAB interface implementation.
Will create the MOAB instance, if not created already (reference counted).
Operations: Collective
[in] | argc | (int) Number of command line arguments |
[in] | argv | (iMOAB_String*) Command line arguments |
Definition at line 141 of file iMOAB.cpp.
References CHKERRVAL, context, DIRICHLET_SET_TAG_NAME, GlobalContext::dirichlet_tag, GLOBAL_ID_TAG_NAME, GlobalContext::globalID_tag, GlobalContext::globalrank, GlobalContext::iArgc, GlobalContext::iArgv, MATERIAL_SET_TAG_NAME, GlobalContext::material_tag, MB_TAG_ANY, MB_TYPE_INTEGER, GlobalContext::MBI, MPI_COMM_WORLD, GlobalContext::MPI_initialized, NEUMANN_SET_TAG_NAME, GlobalContext::neumann_tag, GlobalContext::refCountMB, and GlobalContext::worldprocs.
{ context.iArgc = argc; context.iArgv = argv; // shallow copy if( 0 == context.refCountMB ) { context.MBI = new( std::nothrow ) moab::Core; // retrieve the default tags const char* const shared_set_tag_names[] = { MATERIAL_SET_TAG_NAME, NEUMANN_SET_TAG_NAME, DIRICHLET_SET_TAG_NAME, GLOBAL_ID_TAG_NAME }; // blocks, visible surfaceBC(neumann), vertexBC (Dirichlet), global id, parallel partition Tag gtags[4]; for( int i = 0; i < 4; i++ ) { ErrorCode rval = context.MBI->tag_get_handle( shared_set_tag_names[i], 1, MB_TYPE_INTEGER, gtags[i], MB_TAG_ANY );CHKERRVAL( rval ); } context.material_tag = gtags[0]; context.neumann_tag = gtags[1]; context.dirichlet_tag = gtags[2]; context.globalID_tag = gtags[3]; } context.MPI_initialized = false; #ifdef MOAB_HAVE_MPI int flagInit; MPI_Initialized( &flagInit ); if( flagInit && !context.MPI_initialized ) { MPI_Comm_size( MPI_COMM_WORLD, &context.worldprocs ); MPI_Comm_rank( MPI_COMM_WORLD, &context.globalrank ); context.MPI_initialized = true; } #endif context.refCountMB++; return 0; }
Initialize the iMOAB interface implementation from Fortran driver.
It will create the MOAB instance, if not created already (reference counted).
Operations: Collective
Definition at line 185 of file iMOAB.cpp.
References iMOAB_Initialize.
{ return iMOAB_Initialize( 0, 0 ); }
ErrCode iMOAB_LoadMesh | ( | iMOAB_AppID | pid, |
const iMOAB_String | filename, | ||
const iMOAB_String | read_options, | ||
int * | num_ghost_layers, | ||
int | filename_length, | ||
int | read_options_length | ||
) |
Load a MOAB mesh file in parallel and exchange ghost layers as requested.
All communication is MPI-based, and read options include parallel loading information, resolving shared entities. Local MOAB instance is populated with mesh cells and vertices in the corresponding local partitions.
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | filename | (iMOAB_String) The MOAB mesh file (H5M) to load onto the internal application mesh set |
[in] | read_options | (iMOAB_String) Additional options for reading the MOAB mesh file in parallel |
[in] | num_ghost_layers | (int*) The total number of ghost layers to exchange during mesh loading |
[in] | filename_length | (int) Length of the filename string |
[in] | read_options_length | (int) Length of the read options string |
Definition at line 509 of file iMOAB.cpp.
References GlobalContext::appDatas, CHKERRVAL, context, iMOAB_UpdateMeshInfo, GlobalContext::MBI, GlobalContext::MPI_initialized, outfile, rank, read_options, and GlobalContext::worldprocs.
{ assert( filename_length != 0 ); if( (int)strlen( filename ) > filename_length ) { std::cout << " filename length issue\n"; return 1; } if( (int)strlen( read_options ) > read_options_length ) { std::cout << " read options length issue\n"; return 1; } // make sure we use the file set and pcomm associated with the *pid std::ostringstream newopts; newopts << read_options; #ifdef MOAB_HAVE_MPI if( context.MPI_initialized ) { if( context.worldprocs > 1 ) { std::string opts( read_options ); std::string pcid( "PARALLEL_COMM=" ); std::size_t found = opts.find( pcid ); if( found != std::string::npos ) { std::cerr << " cannot specify PARALLEL_COMM option, it is implicit \n"; return 1; } // in serial, apply PARALLEL_COMM option only for h5m files; it does not work for .g // files (used in test_remapping) std::string filen( filename ); std::string::size_type idx = filen.rfind( '.' ); if( idx != std::string::npos ) { std::string extension = filen.substr( idx + 1 ); if( extension == std::string( "h5m" ) ) newopts << ";;PARALLEL_COMM=" << *pid; } if( *num_ghost_layers >= 1 ) { // if we want ghosts, we will want additional entities, the last .1 // because the addl ents can be edges, faces that are part of the neumann sets std::string pcid2( "PARALLEL_GHOSTS=" ); std::size_t found2 = opts.find( pcid2 ); if( found2 != std::string::npos ) { std::cout << " PARALLEL_GHOSTS option is already specified, ignore passed " "number of layers \n"; } else { // dimension of primary entities is 3 here, but it could be 2 for climate // meshes; we would need to pass PARALLEL_GHOSTS explicitly for 2d meshes, for // example: ";PARALLEL_GHOSTS=2.0.1" newopts << ";PARALLEL_GHOSTS=3.0." << *num_ghost_layers << ".3"; } } } } #endif // Now let us actually load the MOAB file with the appropriate read options ErrorCode rval = context.MBI->load_file( filename, &context.appDatas[*pid].file_set, newopts.str().c_str() );CHKERRVAL( rval ); #ifdef VERBOSE // some debugging stuff std::ostringstream outfile; #ifdef MOAB_HAVE_MPI int rank = context.pcomms[*pid]->rank(); int nprocs = context.pcomms[*pid]->size(); outfile << "TaskMesh_n" << nprocs << "." << rank << ".h5m"; #else outfile << "TaskMesh_n1.0.h5m"; #endif // the mesh contains ghosts too, but they are not part of mat/neumann set // write in serial the file, to see what tags are missing rval = context.MBI->write_file( outfile.str().c_str() );CHKERRVAL( rval ); // everything on current task, written in serial #endif int rc = iMOAB_UpdateMeshInfo( pid ); return rc; }
ErrCode iMOAB_ReadHeaderInfo | ( | const iMOAB_String | filename, |
int * | num_global_vertices, | ||
int * | num_global_elements, | ||
int * | num_dimension, | ||
int * | num_parts, | ||
int | filename_length | ||
) |
Get global information from the file.
It should be called on master task only, and information obtained could be broadcasted by the user. It is a fast lookup in the header of the file.
Operations: Not collective
[in] | filename | (iMOAB_String) The MOAB mesh file (H5M) to probe for header information |
[out] | num_global_vertices | (int*) The total number of vertices in the mesh file |
[out] | num_global_elements | (int*) The total number of elements (of highest dimension only) |
[out] | num_dimension | (int*) The highest dimension of elements in the mesh (Edge=1, Tri/Quad=2, Tet/Hex/Prism/Pyramid=3) |
[out] | num_parts | (int*) The total number of partitions available in the mesh file, typically partitioned with mbpart during pre-processing |
[in] | filename_length | (int) Length of the file name string |
Definition at line 404 of file iMOAB.cpp.
References mhdf_EntDesc::count, mhdf_ElemDesc::desc, edges, mhdf_FileDesc::elems, MBMesquite::faces, mdhf_HEX_TYPE_NAME, mdhf_KNIFE_TYPE_NAME, mhdf_closeFile(), mhdf_EDGE_TYPE_NAME, mhdf_getFileSummary(), mhdf_isError(), mhdf_message(), mhdf_openFile(), mhdf_POLYGON_TYPE_NAME, mhdf_POLYHEDRON_TYPE_NAME, mhdf_PRISM_TYPE_NAME, mhdf_PYRAMID_TYPE_NAME, mhdf_QUAD_TYPE_NAME, mhdf_SEPTAHEDRON_TYPE_NAME, mhdf_TET_TYPE_NAME, mhdf_TRI_TYPE_NAME, mhdf_FileDesc::nodes, mhdf_FileDesc::num_elem_desc, mhdf_FileDesc::numEntSets, mhdf_ElemDesc::type, and mhdf_EntDesc::vals_per_ent.
{ assert( filename_length != 0 ); #ifdef MOAB_HAVE_HDF5 std::string filen( filename ); if( filename_length < (int)strlen( filename ) ) { filen = filen.substr( 0, filename_length ); } *num_global_vertices = 0; int edges = 0; int faces = 0; int regions = 0; *num_global_elements = 0; *num_dimension = 0; *num_parts = 0; mhdf_FileHandle file; mhdf_Status status; unsigned long max_id; struct mhdf_FileDesc* data; file = mhdf_openFile( filen.c_str(), 0, &max_id, -1, &status ); if( mhdf_isError( &status ) ) { fprintf( stderr, "%s: %s\n", filename, mhdf_message( &status ) ); return 1; } data = mhdf_getFileSummary( file, H5T_NATIVE_ULONG, &status, 1 ); // will use extra set info; will get parallel partition tag info too! if( mhdf_isError( &status ) ) { fprintf( stderr, "%s: %s\n", filename, mhdf_message( &status ) ); return 1; } *num_dimension = data->nodes.vals_per_ent; *num_global_vertices = (int)data->nodes.count; for( int i = 0; i < data->num_elem_desc; i++ ) { struct mhdf_ElemDesc* el_desc = &( data->elems[i] ); struct mhdf_EntDesc* ent_d = &( el_desc->desc ); if( 0 == strcmp( el_desc->type, mhdf_EDGE_TYPE_NAME ) ) { edges += ent_d->count; } if( 0 == strcmp( el_desc->type, mhdf_TRI_TYPE_NAME ) ) { faces += ent_d->count; } if( 0 == strcmp( el_desc->type, mhdf_QUAD_TYPE_NAME ) ) { faces += ent_d->count; } if( 0 == strcmp( el_desc->type, mhdf_POLYGON_TYPE_NAME ) ) { faces += ent_d->count; } if( 0 == strcmp( el_desc->type, mhdf_TET_TYPE_NAME ) ) { regions += ent_d->count; } if( 0 == strcmp( el_desc->type, mhdf_PYRAMID_TYPE_NAME ) ) { regions += ent_d->count; } if( 0 == strcmp( el_desc->type, mhdf_PRISM_TYPE_NAME ) ) { regions += ent_d->count; } if( 0 == strcmp( el_desc->type, mdhf_KNIFE_TYPE_NAME ) ) { regions += ent_d->count; } if( 0 == strcmp( el_desc->type, mdhf_HEX_TYPE_NAME ) ) { regions += ent_d->count; } if( 0 == strcmp( el_desc->type, mhdf_POLYHEDRON_TYPE_NAME ) ) { regions += ent_d->count; } if( 0 == strcmp( el_desc->type, mhdf_SEPTAHEDRON_TYPE_NAME ) ) { regions += ent_d->count; } } *num_parts = data->numEntSets[0]; // is this required? if( edges > 0 ) { *num_dimension = 1; // I don't think it will ever return 1 *num_global_elements = edges; } if( faces > 0 ) { *num_dimension = 2; *num_global_elements = faces; } if( regions > 0 ) { *num_dimension = 3; *num_global_elements = regions; } mhdf_closeFile( file, &status ); free( data ); #else std::cout << filename << ": Please reconfigure with HDF5. Cannot retrieve header information for file " "formats other than a h5m file.\n"; *num_global_vertices = *num_global_elements = *num_dimension = *num_parts = 0; #endif return 0; }
ErrCode iMOAB_ReduceTagsMax | ( | iMOAB_AppID | pid, |
int * | tag_index, | ||
int * | ent_type | ||
) |
reduce max tag for a given tag
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | tag_index | (int*) tag index of interest |
[in] | ent_type | (int*) type of entity for tag reduce 0 verts, 1 elems |
Definition at line 1546 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, appData::primary_elems, moab::ParallelComm::reduce_tags(), and appData::tagList.
{ #ifdef MOAB_HAVE_MPI appData& data = context.appDatas[*pid]; Range ent_exchange; if( *tag_index < 0 || *tag_index >= (int)data.tagList.size() ) { return 1; } // error in tag index Tag tagh = data.tagList[*tag_index]; if( *ent_type == 0 ) { ent_exchange = data.all_verts; } else if( *ent_type == 1 ) { ent_exchange = data.primary_elems; } else { return 1; } // unexpected type ParallelComm* pco = context.pcomms[*pid]; // we could do different MPI_Op; do not bother now, we will call from fortran ErrorCode rval = pco->reduce_tags( tagh, MPI_MAX, ent_exchange );CHKERRVAL( rval ); #else /* do nothing if serial */ // just silence the warning // do not call sync tags in serial! int k = *pid + *tag_index + *ent_type; k++; // just do junk, to avoid complaints #endif return 0; }
ErrCode iMOAB_RegisterApplication | ( | const iMOAB_String | app_name, |
int * | compid, | ||
iMOAB_AppID | pid | ||
) |
Register application - Create a unique application ID and bootstrap interfaces for further queries.
Operations: Collective
[in] | app_name | (iMOAB_String) Application name (PROTEUS, NEK5000, etc) |
[in] | comm | (MPI_Comm*) MPI communicator to be used for all mesh-related queries originating from this application |
[in] | compid | (int*) external component id, unique identifier |
[out] | pid | (iMOAB_AppID) The unique pointer to the application ID |
Definition at line 199 of file iMOAB.cpp.
References GlobalContext::appDatas, GlobalContext::appIdCompMap, GlobalContext::appIdMap, CHKERRVAL, context, appData::file_set, moab::ParallelComm::get_id(), appData::global_id, GlobalContext::MBI, MESHSET_SET, appData::name, appData::point_cloud, and GlobalContext::unused_pid.
{ // will create a parallel comm for this application too, so there will be a // mapping from *pid to file set and to parallel comm instances std::string name( app_name ); if( context.appIdMap.find( name ) != context.appIdMap.end() ) { std::cout << " application " << name << " already registered \n"; return 1; } *pid = context.unused_pid++; context.appIdMap[name] = *pid; int rankHere = 0; #ifdef MOAB_HAVE_MPI MPI_Comm_rank( *comm, &rankHere ); #endif if( !rankHere ) std::cout << " application " << name << " with ID = " << *pid << " is registered now \n"; if( *compid <= 0 ) { std::cout << " convention for external application is to have its id positive \n"; return 1; } if( context.appIdCompMap.find( *compid ) != context.appIdCompMap.end() ) { std::cout << " external application with comp id " << *compid << " is already registered\n"; return 1; } context.appIdCompMap[*compid] = *pid; // now create ParallelComm and a file set for this application #ifdef MOAB_HAVE_MPI if( comm ) { ParallelComm* pco = new ParallelComm( context.MBI, *comm ); #ifndef NDEBUG int index = pco->get_id(); // it could be useful to get app id from pcomm instance ... assert( index == *pid ); // here, we assert the the pid is the same as the id of the ParallelComm instance // useful for writing in parallel #endif context.pcomms.push_back( pco ); } else { context.pcomms.push_back( 0 ); } #endif // create now the file set that will be used for loading the model in EntityHandle file_set; ErrorCode rval = context.MBI->create_meshset( MESHSET_SET, file_set );CHKERRVAL( rval ); appData app_data; app_data.file_set = file_set; app_data.global_id = *compid; // will be used mostly for par comm graph app_data.name = name; // save the name of application #ifdef MOAB_HAVE_TEMPESTREMAP app_data.tempestData.remapper = NULL; // Only allocate as needed #endif app_data.point_cloud = false; context.appDatas.push_back( app_data ); // it will correspond to app_FileSets[*pid] will be the file set of interest return 0; }
ErrCode iMOAB_RegisterFortranApplication | ( | const iMOAB_String | app_name, |
int * | compid, | ||
iMOAB_AppID | pid, | ||
int | app_name_length | ||
) |
Register a Fortran-based application - Create a unique application ID and bootstrap interfaces for further queries.
Operations: Collective
[in] | app_name | (iMOAB_String) Application name (PROTEUS, NEK5000, etc) |
[in] | comm | (int*) Fortran MPI communicator to be used for all mesh-related queries originating from this application |
[in] | compid | (int*) external component id, unique identifier |
[out] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | app_name_length | (int) Length of application name string. |
Definition at line 276 of file iMOAB.cpp.
References iMOAB_RegisterApplication.
{ std::string name( app_name ); if( (int)strlen( app_name ) > app_name_length ) { std::cout << " length of string issue \n"; return 1; } #ifdef MOAB_HAVE_MPI MPI_Comm ccomm; if( comm ) { // convert from Fortran communicator to a C communicator // see transfer of handles // http://www.mpi-forum.org/docs/mpi-2.2/mpi22-report/node361.htm ccomm = MPI_Comm_f2c( (MPI_Fint)*comm ); } #endif // now call C style registration function: return iMOAB_RegisterApplication( app_name, #ifdef MOAB_HAVE_MPI &ccomm, #endif compid, pid ); }
ErrCode iMOAB_SetDoubleTagStorage | ( | iMOAB_AppID | pid, |
const iMOAB_String | tag_storage_name, | ||
int * | num_tag_storage_length, | ||
int * | entity_type, | ||
double * | tag_storage_data, | ||
int | tag_storage_name_length | ||
) |
Store the specified values in a MOAB double Tag.
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | tag_storage_name | (iMOAB_String) The tag name to store/retreive the data in MOAB |
[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) |
[in] | entity_type | (int*) type 0 for vertices, 1 for primary elements |
[out] | tag_storage_data | (double*) The array data of type double to replace the internal tag memory; The data is assumed to be contiguous over the local set of visible entities (either vertices or elements) |
[in] | tag_storage_name_length | (iMOAB_String) The length of the tag_storage_name string |
Definition at line 1415 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, MB_SUCCESS, MB_TYPE_DOUBLE, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), and appData::tagMap.
{ ErrorCode rval; // exactly the same code as for int tag :) maybe should check the type of tag too std::string tag_name( tag_storage_name ); if( tag_storage_name_length < (int)tag_name.length() ) { tag_name = tag_name.substr( 0, tag_storage_name_length ); } appData& data = context.appDatas[*pid]; if( data.tagMap.find( tag_name ) == data.tagMap.end() ) { return 1; } // tag not defined Tag tag = data.tagMap[tag_name]; int tagLength = 0; rval = context.MBI->tag_get_length( tag, tagLength );CHKERRVAL( rval ); DataType dtype; rval = context.MBI->tag_get_data_type( tag, dtype ); if( MB_SUCCESS != rval || dtype != MB_TYPE_DOUBLE ) { return 1; } // set it on a subset of entities, based on type and length Range* ents_to_set = NULL; if( *ent_type == 0 ) // vertices { ents_to_set = &data.all_verts; } else if( *ent_type == 1 ) { ents_to_set = &data.primary_elems; } int nents_to_be_set = *num_tag_storage_length / tagLength; if( nents_to_be_set > (int)ents_to_set->size() || nents_to_be_set < 1 ) { return 1; } // to many entities to be set // restrict the range; everything is contiguous; or not? // Range contig_range ( * ( ents_to_set->begin() ), * ( ents_to_set->begin() + nents_to_be_set - // 1 ) ); rval = context.MBI->tag_set_data( tag, *ents_to_set, tag_storage_data );CHKERRVAL( rval ); return 0; // no error }
ErrCode iMOAB_SetGlobalInfo | ( | iMOAB_AppID | pid, |
int * | num_global_verts, | ||
int * | num_global_elems | ||
) |
Set global information for number of vertices and number of elements it is usually available from hdf5 file or it can be computed with MPI_Reduce.
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | num_global_verts | (int*) number of total vertices |
[in] | global | (MPI_Comm) number of total elements |
Definition at line 1693 of file iMOAB.cpp.
References GlobalContext::appDatas, context, appData::num_global_elements, and appData::num_global_vertices.
{ appData& data = context.appDatas[*pid]; data.num_global_vertices = *num_global_verts; data.num_global_elements = *num_global_elems; return 0; }
ErrCode iMOAB_SetIntTagStorage | ( | iMOAB_AppID | pid, |
const iMOAB_String | tag_storage_name, | ||
int * | num_tag_storage_length, | ||
int * | entity_type, | ||
int * | tag_storage_data, | ||
int | tag_storage_name_length | ||
) |
Store the specified values in a MOAB integer Tag.
Values are set on vertices or elements, depending on entity_type
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | tag_storage_name | (iMOAB_String) The tag name to store/retreive the data in MOAB |
[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) |
[in] | entity_type | (int*) type 0 for vertices, 1 for primary elements |
[out] | tag_storage_data | (int*) The array data of type int to replace the internal tag memory; The data is assumed to be contiguous over the local set of visible entities (either vertices or elements) |
[in] | tag_storage_name_length | (iMOAB_String) The length of the tag_storage_name string |
Definition at line 1323 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, MB_SUCCESS, MB_TYPE_INTEGER, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), and appData::tagMap.
{ std::string tag_name( tag_storage_name ); if( tag_storage_name_length < (int)strlen( tag_storage_name ) ) { tag_name = tag_name.substr( 0, tag_storage_name_length ); } appData& data = context.appDatas[*pid]; if( data.tagMap.find( tag_name ) == data.tagMap.end() ) { return 1; } // tag not defined Tag tag = data.tagMap[tag_name]; int tagLength = 0; ErrorCode rval = context.MBI->tag_get_length( tag, tagLength );CHKERRVAL( rval ); DataType dtype; rval = context.MBI->tag_get_data_type( tag, dtype ); if( MB_SUCCESS != rval || dtype != MB_TYPE_INTEGER ) { return 1; } // set it on a subset of entities, based on type and length Range* ents_to_set; if( *ent_type == 0 ) // vertices { ents_to_set = &data.all_verts; } else // if (*ent_type == 1) // *ent_type can be 0 (vertices) or 1 (elements) { ents_to_set = &data.primary_elems; } int nents_to_be_set = *num_tag_storage_length / tagLength; if( nents_to_be_set > (int)ents_to_set->size() || nents_to_be_set < 1 ) { return 1; } // to many entities to be set or too few // restrict the range; everything is contiguous; or not? // Range contig_range ( * ( ents_to_set->begin() ), * ( ents_to_set->begin() + nents_to_be_set - // 1 ) ); rval = context.MBI->tag_set_data( tag, *ents_to_set, tag_storage_data );CHKERRVAL( rval ); return 0; // no error }
ErrCode iMOAB_SynchronizeTags | ( | iMOAB_AppID | pid, |
int * | num_tags, | ||
int * | tag_indices, | ||
int * | ent_type | ||
) |
Exchange tag values for given tags.
Operations: Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | num_tags | (int*) Number of tags to exchange |
[in] | tag_indices | (int*) Array with tag indices of interest (size = *num_tags) |
[in] | ent_type | (int*) type of entity for tag exchange |
Definition at line 1507 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, moab::ParallelComm::exchange_tags(), appData::primary_elems, and appData::tagList.
{ #ifdef MOAB_HAVE_MPI appData& data = context.appDatas[*pid]; Range ent_exchange; std::vector< Tag > tags; for( int i = 0; i < *num_tag; i++ ) { if( tag_indices[i] < 0 || tag_indices[i] >= (int)data.tagList.size() ) { return 1; } // error in tag index tags.push_back( data.tagList[tag_indices[i]] ); } if( *ent_type == 0 ) { ent_exchange = data.all_verts; } else if( *ent_type == 1 ) { ent_exchange = data.primary_elems; } else { return 1; } // unexpected type ParallelComm* pco = context.pcomms[*pid]; ErrorCode rval = pco->exchange_tags( tags, tags, ent_exchange );CHKERRVAL( rval ); #else /* do nothing if serial */ // just silence the warning // do not call sync tags in serial! int k = *pid + *num_tag + *tag_indices + *ent_type; k++; #endif return 0; }
Update local mesh data structure, from file information.
The method should be called after mesh modifications, for example reading a file or creating mesh in memory Operations: Not Collective
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
Definition at line 649 of file iMOAB.cpp.
References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, moab::Range::clear(), context, appData::dimension, appData::diri_sets, GlobalContext::dirichlet_tag, moab::Range::empty(), appData::file_set, moab::ParallelComm::filter_pstatus(), appData::ghost_elems, appData::ghost_vertices, appData::local_verts, appData::mat_sets, GlobalContext::material_tag, MBENTITYSET, GlobalContext::MBI, MBVERTEX, GlobalContext::MPI_initialized, appData::neu_sets, GlobalContext::neumann_tag, appData::owned_elems, appData::point_cloud, appData::primary_elems, PSTATUS_GHOST, PSTATUS_NOT, moab::Range::size(), moab::subtract(), and smoab::UNION.
{ // this will include ghost elements info // appData& data = context.appDatas[*pid]; EntityHandle fileSet = data.file_set; // first clear all data ranges; this can be called after ghosting data.all_verts.clear(); data.primary_elems.clear(); data.local_verts.clear(); data.ghost_vertices.clear(); data.owned_elems.clear(); data.ghost_elems.clear(); data.mat_sets.clear(); data.neu_sets.clear(); data.diri_sets.clear(); // Let us get all the vertex entities ErrorCode rval = context.MBI->get_entities_by_type( fileSet, MBVERTEX, data.all_verts, true );CHKERRVAL( rval ); // recursive // Let us check first entities of dimension = 3 data.dimension = 3; rval = context.MBI->get_entities_by_dimension( fileSet, data.dimension, data.primary_elems, true );CHKERRVAL( rval ); // recursive if( data.primary_elems.empty() ) { // Now 3-D elements. Let us check entities of dimension = 2 data.dimension = 2; rval = context.MBI->get_entities_by_dimension( fileSet, data.dimension, data.primary_elems, true );CHKERRVAL( rval ); // recursive if( data.primary_elems.empty() ) { // Now 3-D/2-D elements. Let us check entities of dimension = 1 data.dimension = 1; rval = context.MBI->get_entities_by_dimension( fileSet, data.dimension, data.primary_elems, true );CHKERRVAL( rval ); // recursive if( data.primary_elems.empty() ) { // no elements of dimension 1 or 2 or 3; it could happen for point clouds data.dimension = 0; } } } // check if the current mesh is just a point cloud data.point_cloud = ( ( data.primary_elems.size() == 0 && data.all_verts.size() > 0 ) || data.dimension == 0 ); #ifdef MOAB_HAVE_MPI if( context.MPI_initialized ) { ParallelComm* pco = context.pcomms[*pid]; // filter ghost vertices, from local rval = pco->filter_pstatus( data.all_verts, PSTATUS_GHOST, PSTATUS_NOT, -1, &data.local_verts );CHKERRVAL( rval ); // Store handles for all ghosted entities data.ghost_vertices = subtract( data.all_verts, data.local_verts ); // filter ghost elements, from local rval = pco->filter_pstatus( data.primary_elems, PSTATUS_GHOST, PSTATUS_NOT, -1, &data.owned_elems );CHKERRVAL( rval ); data.ghost_elems = subtract( data.primary_elems, data.owned_elems ); } else { data.local_verts = data.all_verts; data.owned_elems = data.primary_elems; } #else data.local_verts = data.all_verts; data.owned_elems = data.primary_elems; #endif // Get the references for some standard internal tags such as material blocks, BCs, etc rval = context.MBI->get_entities_by_type_and_tag( fileSet, MBENTITYSET, &( context.material_tag ), 0, 1, data.mat_sets, Interface::UNION );CHKERRVAL( rval ); rval = context.MBI->get_entities_by_type_and_tag( fileSet, MBENTITYSET, &( context.neumann_tag ), 0, 1, data.neu_sets, Interface::UNION );CHKERRVAL( rval ); rval = context.MBI->get_entities_by_type_and_tag( fileSet, MBENTITYSET, &( context.dirichlet_tag ), 0, 1, data.diri_sets, Interface::UNION );CHKERRVAL( rval ); return 0; }
ErrCode iMOAB_WriteMesh | ( | iMOAB_AppID | pid, |
iMOAB_String | filename, | ||
iMOAB_String | write_options, | ||
int | filename_length, | ||
int | write_options_length | ||
) |
Write a MOAB mesh along with the solution tags to a file.
Operations: Collective for parallel write, non collective for serial write.
[in] | pid | (iMOAB_AppID) The unique pointer to the application ID |
[in] | filename | (iMOAB_String) The MOAB mesh file (H5M) to write all the entities contained in the internal application mesh set |
[in] | write_options | (iMOAB_String) Additional options for writing the MOAB mesh in parallel |
[in] | filename_length | (int) Length of the filename string |
[in] | write_options_length | (int) Length of the write options string |
Definition at line 605 of file iMOAB.cpp.
References GlobalContext::appDatas, CHKERRVAL, context, and GlobalContext::MBI.
{ // maybe do some processing of strings and lengths if( (int)strlen( filename ) > filename_length ) { std::cout << " file name length issue\n"; return 1; } if( (int)strlen( write_options ) > write_options_length ) { std::cout << " write options issue\n"; return 1; } std::ostringstream newopts; #ifdef MOAB_HAVE_MPI std::string write_opts( write_options ); std::string pcid( "PARALLEL_COMM=" ); std::size_t found = write_opts.find( pcid ); if( found != std::string::npos ) { std::cerr << " cannot specify PARALLEL_COMM option, it is implicit \n"; return 1; } // if write in parallel, add pc option, to be sure about which ParallelComm instance is used std::string pw( "PARALLEL=WRITE_PART" ); found = write_opts.find( pw ); if( found != std::string::npos ) { newopts << "PARALLEL_COMM=" << *pid << ";"; } #endif newopts << write_options; // Now let us actually write the file to disk with appropriate options ErrorCode rval = context.MBI->write_file( filename, 0, newopts.str().c_str(), &context.appDatas[*pid].file_set, 1 );CHKERRVAL( rval ); return 0; }
static void split_tag_names | ( | std::string | input_names, |
std::string & | separator, | ||
std::vector< std::string > & | list_tag_names | ||
) | [static] |
Definition at line 1710 of file iMOAB.cpp.
{ size_t pos = 0; std::string token; while( ( pos = input_names.find( separator ) ) != std::string::npos ) { token = input_names.substr( 0, pos ); list_tag_names.push_back( token ); // std::cout << token << std::endl; input_names.erase( 0, pos + separator.length() ); } if( !input_names.empty() ) { // if leftover something, or if not ended with delimiter list_tag_names.push_back( input_names ); } return; }
struct GlobalContext context [static] |
Definition at line 139 of file iMOAB.cpp.
Referenced by iMOAB_CreateElements(), iMOAB_CreateVertices(), iMOAB_DefineTagStorage(), iMOAB_DeregisterApplication(), iMOAB_Finalize(), iMOAB_GetBlockElementConnectivities(), iMOAB_GetBlockID(), iMOAB_GetBlockInfo(), iMOAB_GetDoubleTagStorage(), iMOAB_GetElementConnectivity(), iMOAB_GetElementID(), iMOAB_GetElementOwnership(), iMOAB_GetGlobalInfo(), iMOAB_GetIntTagStorage(), iMOAB_GetMeshInfo(), iMOAB_GetNeighborElements(), iMOAB_GetPointerToSurfaceBC(), iMOAB_GetPointerToVertexBC(), iMOAB_GetVertexID(), iMOAB_GetVertexOwnership(), iMOAB_GetVisibleElementsInfo(), iMOAB_GetVisibleVerticesCoordinates(), iMOAB_Initialize(), iMOAB_LoadMesh(), iMOAB_ReduceTagsMax(), iMOAB_RegisterApplication(), iMOAB_SetDoubleTagStorage(), iMOAB_SetGlobalInfo(), iMOAB_SetIntTagStorage(), iMOAB_SynchronizeTags(), iMOAB_UpdateMeshInfo(), iMOAB_WriteMesh(), main(), and migrate_smart().