MOAB: Mesh Oriented datABase  (version 5.3.0)
iMOAB.h File Reference
#include "imoab_protos.h"
+ Include dependency graph for iMOAB.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define iMOAB_AppID   int*
#define iMOAB_String   char*
#define iMOAB_GlobalID   int
#define iMOAB_LocalID   int
#define ErrCode   int

Enumerations

enum  MOAB_TAG_TYPE {
  DENSE_INTEGER = 0, DENSE_DOUBLE, DENSE_ENTITYHANDLE, SPARSE_INTEGER,
  SPARSE_DOUBLE, SPARSE_ENTITYHANDLE
}
enum  MOAB_TAG_OWNER_TYPE { TAG_VERTEX = 0, TAG_EDGE, TAG_FACE, TAG_ELEMENT }

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_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_ResolveSharedEntities (iMOAB_AppID pid, int *num_verts, int *marker)
 resolve shared entities using global markers on shared vertices.
ErrCode iMOAB_DetermineGhostEntities (iMOAB_AppID pid, int *ghost_dim, int *num_ghost_layers, int *bridge_dim)
 create ghost layers.
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 *entity_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 *entity_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 *entity_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 *entity_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_GetNeighborVertices (iMOAB_AppID pid, iMOAB_LocalID *local_vertex_ID, int *num_adjacent_vertices, iMOAB_LocalID *adjacent_vertex_IDs)
 Get the adjacencies for the vertex entities. (not implemented yet)
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.

Detailed Description

iMOAB: a language-agnostic, lightweight interface to MOAB

Supports usage from C/C++, Fortran (77/90/2003), Python

Remarks:
1) All data in the interface are exposed via POD-types.
2) Pass everything by reference, so we do not have to use VAL()
3) Arrays are allocated by the client code. No concerns about de-allocation of the data will be taken up by the interface.
4) Always pass the pointer to the start of array along with the total allocated size for the array.
5) Return the filled array requested by client along with optionally the actual length of the array that was filled. (for typical cases, should be the allocated length)

Definition in file iMOAB.h.


Define Documentation

#define ErrCode   int

Definition at line 42 of file iMOAB.h.

Referenced by main().

#define iMOAB_AppID   int*

1) Fortran MPI_Comm won't work. Take an integer argument and use MPI_F2C calls to get the C-Comm object 2) ReadHeaderInfo - Does it need the pid ? 3) Reuse the comm object from the registration for both load and write operations. Do not take comm objects again to avoid confusion and retain consistency. 4) Decipher the global comm object and the subset partioning for each application based on the comm object 5) GetMeshInfo - return separately the owned and ghosted vertices/elements -- not together in visible_** but rather owned_** and ghosted_**. Make these arrays of size 2. 6) Should we sort the vertices after ghosting, such that the locally owned is first, and the ghosted appended next. 7) RCM only for the owned part of the mesh -- do not screw with the ghosted layers 8) GetBlockID - identical to GetVertexID -- return the global numbering for block 9) GetVertexID -- remember that the order of vertices returned have an implicit numbering embedded in it. DO NOT CHANGE THIS ORDERING... 10) GetBlockInfo takes global Block ID; Remove blockname unless there is a separate use case for it.. 11) GetElementConnectivity - clarify whether we return global or local vertex numbering. Preferably local numbering else lot of deciphering for global.

Definition at line 38 of file iMOAB.h.

Referenced by commgraphtest(), main(), migrate(), and migrate_smart().

#define iMOAB_GlobalID   int

Definition at line 40 of file iMOAB.h.

Referenced by main().

#define iMOAB_LocalID   int

Definition at line 41 of file iMOAB.h.

Referenced by main().

#define iMOAB_String   char*

Definition at line 39 of file iMOAB.h.


Enumeration Type Documentation

Enumerator:
TAG_VERTEX 
TAG_EDGE 
TAG_FACE 
TAG_ELEMENT 

Definition at line 57 of file iMOAB.h.

Enumerator:
DENSE_INTEGER 
DENSE_DOUBLE 
DENSE_ENTITYHANDLE 
SPARSE_INTEGER 
SPARSE_DOUBLE 
SPARSE_ENTITYHANDLE 

Definition at line 47 of file iMOAB.h.


Function Documentation

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

Parameters:
[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 1671 of file iMOAB.cpp.

References moab::Interface::add_entities(), GlobalContext::appDatas, CHKERRVAL, context, moab::Interface::create_meshset(), moab::Range::empty(), ErrorCode, appData::file_set, moab::ReadUtilIface::get_element_connect(), moab::Interface::get_entities_by_type_and_tag(), appData::local_verts, GlobalContext::material_tag, MBENTITYSET, GlobalContext::MBI, moab::Range::merge(), MESHSET_SET, appData::primary_elems, moab::Interface::query_interface(), moab::Interface::tag_set_data(), 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

Parameters:
[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 1650 of file iMOAB.cpp.

References moab::Interface::add_entities(), appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, moab::Interface::create_vertices(), dim, moab::Range::empty(), ErrorCode, 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.

Note:
In MOAB, for most solution vectors, we only need to create a "Dense", "Double" Tag. A sparse tag can be created too. If the tag is already existing in the file, it will not be created. If it is a new tag, memory will be allocated when setting the values. Default values are 0 for for integer tags, 0.0 for double tags, 0 for entity handle tags.

Operations: Collective

Parameters:
[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 1229 of file iMOAB.cpp.

References GlobalContext::appDatas, context, ErrorCode, 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, moab::Interface::tag_get_handle(), appData::tagList, appData::tagMap, and TagType.

{
    // 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

Parameters:
[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::Interface::delete_entities(), moab::Range::empty(), ErrorCode, appData::file_set, moab::Interface::get_adjacencies(), moab::Interface::get_connectivity(), moab::Interface::get_entities_by_handle(), moab::Interface::get_entities_by_type(), appData::global_id, moab::Range::insert(), MBENTITYSET, GlobalContext::MBI, MBVERTEX, appData::name, moab::ParallelComm::rank(), moab::Range::subset_by_type(), moab::subtract(), moab::Interface::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;
}
ErrCode iMOAB_DetermineGhostEntities ( iMOAB_AppID  pid,
int *  ghost_dim,
int *  num_ghost_layers,
int *  bridge_dim 
)

create ghost layers.

Note:
it assumes that the shared entities were resolved successfully, and that the mesh is properly distributed on separate tasks

Operations: Collective .

Parameters:
[in]pid(iMOAB_AppID) The unique pointer to the application ID
[in]ghost_dim(int*) Desired ghost dimension (2 or 3, most of the time)
[in]num_ghost_layers(int*) Number of ghost layers requested
[in]bridge_dim(int*) Bridge dimension (0 for vertices, 1 for edges, 2 for faces)

Referenced by main().

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.

Note:
input is the block ID. Should we change to visible block local index?

Operations: Not Collective

Parameters:
[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 998 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_entities_by_handle(), 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

Parameters:
[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 900 of file iMOAB.cpp.

References GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, GlobalContext::material_tag, GlobalContext::MBI, moab::Range::size(), and moab::Interface::tag_get_data().

{
    // 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

Parameters:
[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 921 of file iMOAB.cpp.

References moab::Range::all_of_type(), GlobalContext::appDatas, CHKERRVAL, conn, context, moab::Range::empty(), ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_entities_by_handle(), MB_SUCCESS, GlobalContext::MBI, moab::Range::size(), and moab::Interface::type_from_handle().

{
    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

Parameters:
[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 1496 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, MB_TYPE_DOUBLE, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), moab::Interface::tag_get_data(), moab::Interface::tag_get_data_type(), moab::Interface::tag_get_length(), 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.

Note:
it was added for convenience, it should not be needed.

Operations: Not Collective

Parameters:
[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 1032 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, conn, context, ErrorCode, moab::Interface::get_connectivity(), 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

Parameters:
[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 1097 of file iMOAB.cpp.

References GlobalContext::appDatas, CHKERRVAL, context, moab::Range::empty(), ErrorCode, moab::Interface::get_entities_by_handle(), GlobalContext::globalID_tag, moab::Range::index(), appData::mat_sets, appData::matIndex, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), and moab::Interface::tag_get_data().

{
    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.

Note:
: Should we use local block index for input, instead of the global block ID ?

Operations: Not Collective

Parameters:
[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 1061 of file iMOAB.cpp.

References GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, moab::Range::empty(), moab::Range::end(), ErrorCode, moab::Interface::get_entities_by_handle(), 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.

Parameters:
[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 1740 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

Parameters:
[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 1398 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, MB_TYPE_INTEGER, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), moab::Interface::tag_get_data(), moab::Interface::tag_get_data_type(), moab::Interface::tag_get_length(), 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

Parameters:
[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 760 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(), ErrorCode, appData::file_set, moab::Interface::get_adjacencies(), moab::Interface::get_entities_by_dimension(), moab::Interface::get_entities_by_type_and_tag(), 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 moab::Interface::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

Parameters:
[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 1617 of file iMOAB.cpp.

References GlobalContext::appDatas, CHKERRVAL, context, appData::dimension, ErrorCode, 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_GetNeighborVertices ( iMOAB_AppID  pid,
iMOAB_LocalID local_vertex_ID,
int *  num_adjacent_vertices,
iMOAB_LocalID adjacent_vertex_IDs 
)

Get the adjacencies for the vertex entities. (not implemented yet)

Operations: Not Collective

Parameters:
[in]pid(iMOAB_AppID) The unique pointer to the application ID
[in]local_vertex_ID(iMOAB_LocalID*) The local vertex ID for which adjacency information is needed
[out]num_adjacent_vertices(int*) The total number of adjacent vertices
[out]adjacent_vertex_IDs(iMOAB_LocalID*) The local element IDs of all adjacent vertices to the current one (typically, num_total_sides for internal elements or num_total_sides-num_sides_on_boundary for boundary elements)
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

Parameters:
[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 1129 of file iMOAB.cpp.

References GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, appData::dimension, moab::Range::end(), ErrorCode, moab::Interface::get_adjacencies(), moab::Interface::get_entities_by_dimension(), moab::Range::index(), GlobalContext::MBI, appData::neu_sets, GlobalContext::neumann_tag, appData::primary_elems, moab::side_number(), moab::Interface::side_number(), moab::Range::size(), and moab::Interface::tag_get_data().

{
    // 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

Parameters:
[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 1188 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, appData::diri_sets, GlobalContext::dirichlet_tag, moab::Range::end(), ErrorCode, moab::Interface::get_entities_by_dimension(), moab::Range::index(), GlobalContext::MBI, moab::Range::size(), and moab::Interface::tag_get_data().

{
    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

Parameters:
[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 848 of file iMOAB.cpp.

References GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, GlobalContext::globalID_tag, GlobalContext::MBI, moab::Range::size(), and moab::Interface::tag_get_data().

{
    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)

Note:
Shared vertices could be owned by different tasks. Local and shared vertices are first, ghost vertices are next in the array. Ghost vertices are always owned by a different process ID. Array allocated by the client with total size of visible vertices.

Operations: Not Collective

Parameters:
[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 860 of file iMOAB.cpp.

References GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, moab::Range::end(), ErrorCode, 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.

Note:
: should we return also the index for each block?

Operations: Not Collective

Parameters:
[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 950 of file iMOAB.cpp.

References GlobalContext::appDatas, moab::Range::begin(), CHKERRVAL, context, moab::Range::end(), ErrorCode, moab::Interface::get_entities_by_handle(), moab::ParallelComm::get_owner(), GlobalContext::globalID_tag, moab::Range::index(), appData::mat_sets, GlobalContext::material_tag, GlobalContext::MBI, appData::primary_elems, and moab::Interface::tag_get_data().

{
    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.

Note:
coordinates are returned in an array allocated by client, interleaved. (do need an option for blocked coordinates ?) size of the array is dimension times number of visible vertices. The local ordering is implicit, owned/shared vertices are first, then ghosts.

Operations: Not Collective

Parameters:
[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 888 of file iMOAB.cpp.

References GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, moab::Interface::get_coords(), GlobalContext::MBI, and moab::Range::size().

{
    Range& verts = context.appDatas[*pid].all_verts;

    // interleaved coordinates, so that means deep copy anyway
    if( *coords_length != 3 * (int)verts.size() ) { return 1; }

    ErrorCode rval = context.MBI->get_coords( verts, coordinates );CHKERRVAL( rval );

    return 0;
}
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

Parameters:
[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, ErrorCode, 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, moab::Interface::tag_get_handle(), 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.

Note:
This will also exchange ghost cells and vertices, as requested. The default bridge dimension is 0 (vertices), and all additional lower dimensional sub-entities are exchanged (mesh edges and faces). The tags in the file are not exchanged by default. Default tag information for GLOBAL_ID, MATERIAL_SET, NEUMANN_SET and DIRICHLET_SET is exchanged. Global ID tag is exchanged for all cells and vertices. Material sets, Neumann sets and Dirichlet sets are all augmented with the ghost entities.

Operations: Collective

Parameters:
[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 530 of file iMOAB.cpp.

References GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, iMOAB_UpdateMeshInfo, moab::Interface::load_file(), GlobalContext::MBI, GlobalContext::MPI_initialized, outfile, rank, read_options, GlobalContext::worldprocs, and moab::Interface::write_file().

{
    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";
                }
            }
        }
    }
#else
    assert( num_ghost_layers == nullptr );
#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

    // Update mesh information
    return iMOAB_UpdateMeshInfo( pid );
}
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

Parameters:
[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 425 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

Parameters:
[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 1583 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, 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.

Note:
Internally, a mesh set will be associated with the application ID and all subsequent queries on the MOAB instance will be directed to this mesh/file set.

Operations: Collective

Parameters:
[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, moab::Interface::create_meshset(), ErrorCode, 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.

Note:
Internally, the comm object, usually a 32 bit integer in Fortran, will be converted using MPI_Comm_f2c and stored as MPI_Comm. A mesh set will be associated with the application ID and all subsequent queries on the MOAB instance will be directed to this mesh/file set.

Operations: Collective

Parameters:
[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_ResolveSharedEntities ( iMOAB_AppID  pid,
int *  num_verts,
int *  marker 
)

resolve shared entities using global markers on shared vertices.

Note:
global markers can be a global node id, for example, or a global dof (as for homme)

Operations: Collective .

Parameters:
[in]pid(iMOAB_AppID) The unique pointer to the application ID
[in]num_verts(int*) Number of vertices
[in]marker(int*) resolving marker (global id marker)

Referenced by main().

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

Parameters:
[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 1448 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, MB_SUCCESS, MB_TYPE_DOUBLE, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), moab::Interface::tag_get_data_type(), moab::Interface::tag_get_length(), moab::Interface::tag_set_data(), 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.

Parameters:
[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 1732 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

Note:
we could change the api to accept as input the tag index, as returned by iMOAB_DefineTagStorage.

Operations: Collective

Parameters:
[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 1346 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, MB_SUCCESS, MB_TYPE_INTEGER, GlobalContext::MBI, appData::primary_elems, moab::Range::size(), moab::Interface::tag_get_data_type(), moab::Interface::tag_get_length(), moab::Interface::tag_set_data(), 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_tag,
int *  tag_indices,
int *  ent_type 
)

Exchange tag values for given tags.

Operations: Collective

Parameters:
[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 1544 of file iMOAB.cpp.

References appData::all_verts, GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, 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

Parameters:
[in]pid(iMOAB_AppID) The unique pointer to the application ID

Definition at line 670 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(), ErrorCode, appData::file_set, moab::ParallelComm::filter_pstatus(), moab::Interface::get_entities_by_dimension(), moab::Interface::get_entities_by_type(), moab::Interface::get_entities_by_type_and_tag(), 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 moab::Interface::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.

Note:
The interface will write one single file (H5M) and for serial files (VTK/Exodus), it will write one file per task. Write options include parallel write options, if needed. Only the mesh set and solution data associated to the application will be written to the file.

Operations: Collective for parallel write, non collective for serial write.

Parameters:
[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 626 of file iMOAB.cpp.

References GlobalContext::appDatas, CHKERRVAL, context, ErrorCode, GlobalContext::MBI, and moab::Interface::write_file().

{
    // 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;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines