MOAB: Mesh Oriented datABase  (version 5.4.1)
DeformMeshRemap Class Reference
+ Collaboration diagram for DeformMeshRemap:

Public Types

enum  { MASTER = 0, SLAVE, SOLID, FLUID }
 Enumerator for solid/fluid, master/slave. More...

Public Member Functions

 DeformMeshRemap (Interface *impl, ParallelComm *master=NULL, ParallelComm *slave=NULL)
 ~DeformMeshRemap ()
 Destructor.
ErrorCode execute ()
 Execute the deformed mesh process.
ErrorCode add_set_no (int m_or_s, int fluid_or_solid, int set_no)
 Add a set number.
ErrorCode remove_set_no (int m_or_s, int fluid_or_solid, int set_no)
 Remove a set number.
ErrorCode get_set_nos (int m_or_s, int fluid_or_solid, set< int > &set_nos) const
 Get the set numbers.
Tag x_new () const
 Get the xNew tag handle.
string x_new_name () const
 Get the tag name.
void x_new_name (const string &name)
 Set the tag name.
string get_file_name (int m_or_s) const
 Get/set the file name.
void set_file_name (int m_or_s, const string &name)
 Get/set the file name.
string xdisp_name (int idx=0)
 Get/set the x displacement tag names.
void xdisp_name (const string &nm, int idx=0)

Private Member Functions

ErrorCode deform_master (Range &fluid_elems, Range &solid_elems, const char *tag_name=NULL)
ErrorCode read_file (int m_or_s, string &fname, EntityHandle &seth)
 Read a file and establish proper ranges.
ErrorCode write_to_coords (Range &elems, Tag tagh, Tag tmp_tag=0)
ErrorCode write_and_save (Range &ents, EntityHandle seth, Tag tagh, const char *filename, bool restore_coords=false)
ErrorCode find_other_sets (int m_or_s, EntityHandle file_set)
 Find fluid/solid sets from complement of solid/fluid sets.

Private Attributes

InterfacembImpl
 moab interface
set< int > fluidSetNos [2]
 Material set numbers for fluid materials, for master/slave.
set< int > solidSetNos [2]
 Material set numbers for solid materials, for master/slave.
EntityHandle masterSet
 Sets defining master/slave meshes.
EntityHandle slaveSet
Range fluidSets [2]
 Sets in master/slave meshes.
Range solidSets [2]
Range fluidElems [2]
 Elements in master/slave meshes.
Range solidElems [2]
string masterFileName
 Filenames for master/slave meshes.
string slaveFileName
Tag xDisp [3]
 Tag from file, might be 3.
Tag xNew
 Tag used for new positions.
string xDispNames [3]
 Tag name used to read disps from file.
string xNewName
 Tag name used for new positions.

Detailed Description

Examples:
DeformMeshRemap.cpp.

Definition at line 56 of file DeformMeshRemap.cpp.


Member Enumeration Documentation

anonymous enum

Enumerator for solid/fluid, master/slave.

Enumerator:
MASTER 
SLAVE 
SOLID 
FLUID 

Definition at line 60 of file DeformMeshRemap.cpp.

    {
        MASTER = 0,
        SLAVE,
        SOLID,
        FLUID
    };

Constructor & Destructor Documentation

DeformMeshRemap::DeformMeshRemap ( Interface impl,
ParallelComm master = NULL,
ParallelComm slave = NULL 
)

Constructor If master is NULL, the MOAB part is run in serial; If slave is NULL but the master isn't, the slave is copied from the master Create communicators using moab::ParallelComm::get_pcomm

Examples:
DeformMeshRemap.cpp.

Definition at line 417 of file DeformMeshRemap.cpp.

References xDisp.

    : mbImpl( impl ), pcMaster( master ), pcSlave( slave ), masterSet( 0 ), slaveSet( 0 ), xNew( 0 ), xNewName( "xnew" )
{
    xDisp[0] = xDisp[1] = xDisp[2] = 0;

    if( !pcSlave && pcMaster ) pcSlave = pcMaster;
}

Destructor.

Examples:
DeformMeshRemap.cpp.

Definition at line 425 of file DeformMeshRemap.cpp.

{}

Member Function Documentation

ErrorCode DeformMeshRemap::add_set_no ( int  m_or_s,
int  fluid_or_solid,
int  set_no 
) [inline]

Add a set number.

Examples:
DeformMeshRemap.cpp.

Definition at line 180 of file DeformMeshRemap.cpp.

References MB_INDEX_OUT_OF_RANGE, MB_SUCCESS, and SOLID.

Referenced by main().

{
    set< int >* this_set;
    assert( ( m_or_s == MASTER || m_or_s == SLAVE ) && "m_or_s should be MASTER or SLAVE." );
    if( m_or_s != MASTER && m_or_s != SLAVE ) return MB_INDEX_OUT_OF_RANGE;

    switch( f_or_s )
    {
        case FLUID:
            this_set = &fluidSetNos[m_or_s];
            break;
        case SOLID:
            this_set = &solidSetNos[m_or_s];
            break;
        default:
            assert( false && "f_or_s should be FLUID or SOLID." );
            return MB_FAILURE;
    }

    this_set->insert( set_no );

    return MB_SUCCESS;
}
ErrorCode DeformMeshRemap::deform_master ( Range fluid_elems,
Range solid_elems,
const char *  tag_name = NULL 
) [private]

Apply a known deformation to the solid elements, putting the results in the xNew tag; also write current coordinates to the xNew tag for fluid elements

Examples:
DeformMeshRemap.cpp.

Definition at line 563 of file DeformMeshRemap.cpp.

References moab::BoundBox::bMax, moab::BoundBox::bMin, box(), moab::debug, deform_func(), ErrorCode, fluidElems, moab::Interface::get_adjacencies(), moab::Interface::get_coords(), moab::CartVect::length_squared(), MASTER, masterSet, MB_CHK_ERR, MB_CHK_SET_ERR, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_DOUBLE, mbImpl, moab::Range::merge(), moab::Range::size(), solidElems, moab::subtract(), moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), smoab::UNION, moab::BoundBox::update(), write_and_save(), xDisp, xDispNames, and xNew.

{
    // Deform elements with an analytic function
    ErrorCode rval;

    // Get all the vertices and coords in the solid
    Range solid_verts, fluid_verts;
    rval = mbImpl->get_adjacencies( solid_elems, 0, false, solid_verts, Interface::UNION );MB_CHK_SET_ERR( rval, "Failed to get vertices" );
    vector< double > coords( 3 * solid_verts.size() ), new_coords( 3 * solid_verts.size() );
    rval = mbImpl->get_coords( solid_verts, &coords[0] );MB_CHK_SET_ERR( rval, "Failed to get vertex coords" );
    unsigned int num_verts = solid_verts.size();

    // Get or create the tag
    if( !xDispNames[0].empty() && !xDispNames[1].empty() && !xDispNames[2].empty() )
    {
        // 3 tags, specifying xyz individual data, integrate into one tag
        rval = mbImpl->tag_get_handle( ( tag_name ? tag_name : "" ), 3, MB_TYPE_DOUBLE, xNew,
                                       MB_TAG_CREAT | MB_TAG_DENSE );MB_CHK_SET_ERR( rval, "Failed to create xnew tag" );
        vector< double > disps( num_verts );
        for( int i = 0; i < 3; i++ )
        {
            rval = mbImpl->tag_get_handle( xDispNames[0].c_str(), 1, MB_TYPE_DOUBLE, xDisp[i] );MB_CHK_SET_ERR( rval, "Failed to get xDisp tag" );
            rval = mbImpl->tag_get_data( xDisp[i], solid_verts, &disps[0] );MB_CHK_SET_ERR( rval, "Failed to get xDisp tag values" );
            for( unsigned int j = 0; j < num_verts; j++ )
                new_coords[3 * j + i] = coords[3 * j + i] + disps[j];
        }
    }
    else if( !xDispNames[0].empty() )
    {
        rval = mbImpl->tag_get_handle( xDispNames[0].c_str(), 3, MB_TYPE_DOUBLE, xDisp[0] );MB_CHK_SET_ERR( rval, "Failed to get first xDisp tag" );
        xNew = xDisp[0];
        vector< double > disps( 3 * num_verts );
        rval = mbImpl->tag_get_data( xDisp[0], solid_verts, &disps[0] );
        for( unsigned int j = 0; j < 3 * num_verts; j++ )
            new_coords[j] = coords[j] + disps[j];
    }
    else
    {
        // Get the bounding box of the solid mesh
        BoundBox bbox;
        bbox.update( *mbImpl, solid_elems );

        for( unsigned int j = 0; j < num_verts; j++ )
            deform_func( bbox, &coords[3 * j], &new_coords[3 * j] );
    }

    if( debug )
    {
        double len = 0.0;
        for( unsigned int i = 0; i < num_verts; i++ )
        {
            CartVect dx    = CartVect( &new_coords[3 * i] ) - CartVect( &coords[3 * i] );
            double tmp_len = dx.length_squared();
            if( tmp_len > len ) len = tmp_len;
        }
        Range tmp_elems( fluid_elems );
        tmp_elems.merge( solid_elems );
        BoundBox box;
        box.update( *mbImpl, tmp_elems );
        double max_len =
            std::max( box.bMax[2] - box.bMin[2], std::max( box.bMax[1] - box.bMin[1], box.bMax[0] - box.bMin[0] ) );

        cout << "Max displacement = " << len << " (" << 100.0 * len / max_len << "% of max box length)" << endl;
    }

    if( !xNew )
    {
        rval = mbImpl->tag_get_handle( ( tag_name ? tag_name : "" ), 3, MB_TYPE_DOUBLE, xDisp[0],
                                       MB_TAG_CREAT | MB_TAG_DENSE );MB_CHK_SET_ERR( rval, "Failed to get xNew tag" );
        xNew = xDisp[0];
    }

    // Set the new tag to those coords
    rval = mbImpl->tag_set_data( xNew, solid_verts, &new_coords[0] );MB_CHK_SET_ERR( rval, "Failed to set tag data" );

    // Get all the vertices and coords in the fluid, set xnew to them
    rval = mbImpl->get_adjacencies( fluid_elems, 0, false, fluid_verts, Interface::UNION );MB_CHK_SET_ERR( rval, "Failed to get vertices" );
    fluid_verts = subtract( fluid_verts, solid_verts );

    if( coords.size() < 3 * fluid_verts.size() ) coords.resize( 3 * fluid_verts.size() );
    rval = mbImpl->get_coords( fluid_verts, &coords[0] );MB_CHK_SET_ERR( rval, "Failed to get vertex coords" );
    rval = mbImpl->tag_set_data( xNew, fluid_verts, &coords[0] );MB_CHK_SET_ERR( rval, "Failed to set xnew tag on fluid verts" );

    if( debug )
    {
        // Save deformed mesh coords to new file for visualizing
        Range tmp_range( fluidElems[MASTER] );
        tmp_range.merge( solidElems[MASTER] );
        rval = write_and_save( tmp_range, masterSet, xNew, "deformed_master.h5m", true );MB_CHK_ERR( rval );
    }

    return MB_SUCCESS;
}

Execute the deformed mesh process.

Examples:
DeformMeshRemap.cpp.

Definition at line 266 of file DeformMeshRemap.cpp.

References moab::debug, deform_master(), ErrorCode, moab::Skinner::find_skin(), moab::SpatialLocator::get_tree(), moab::DataCoupler::interpolate(), moab::SpatialLocator::local_num_located(), moab::DataCoupler::locate_points(), MB_CHK_ERR, MB_CHK_SET_ERR, MB_SUCCESS, moab::Range::merge(), MESHSET_SET, moab::LloydSmoother::num_its(), moab::LloydSmoother::perform_smooth(), moab::TreeStats::print(), read_file(), moab::Range::size(), skin(), moab::DataCoupler::spatial_locator(), moab::Tree::tree_stats(), moab::Interface::UNION, moab::DataCoupler::VOLUME, and write_to_coords().

Referenced by main().

{
    // Read master/slave files and get fluid/solid material sets
    ErrorCode rval = read_file( MASTER, masterFileName, masterSet );MB_CHK_ERR( rval );

    if( solidSetNos[MASTER].empty() || fluidSetNos[MASTER].empty() )
    {
        rval = find_other_sets( MASTER, masterSet );MB_CHK_SET_ERR( rval, "Failed to find other sets in master mesh" );
    }

    bool have_slave = !( slaveFileName == "none" );
    if( have_slave )
    {
        rval = read_file( SLAVE, slaveFileName, slaveSet );MB_CHK_ERR( rval );

        if( solidSetNos[SLAVE].empty() || fluidSetNos[SLAVE].empty() )
        {
            rval = find_other_sets( SLAVE, slaveSet );MB_CHK_SET_ERR( rval, "Failed to find other sets in slave mesh" );
        }
    }

    if( debug ) cout << "Constructing data coupler/search tree on master mesh..." << endl;

    Range src_elems = solidElems[MASTER];
    src_elems.merge( fluidElems[MASTER] );

    // Initialize data coupler on source elements
    DataCoupler dc_master( mbImpl, src_elems, 0, NULL );

    Range tgt_verts;
    if( have_slave )
    {
        // Locate slave vertices in master, orig coords; do this with a data coupler, so you can
        // later interpolate
        Range tmp_range = solidElems[SLAVE];
        tmp_range.merge( fluidElems[SLAVE] );
        rval = mbImpl->get_adjacencies( tmp_range, 0, false, tgt_verts, Interface::UNION );MB_CHK_SET_ERR( rval, "Failed to get target verts" );

        // Locate slave vertices, caching results in dc
        if( debug ) cout << "Locating slave vertices in master mesh..." << endl;
        rval = dc_master.locate_points( tgt_verts );MB_CHK_SET_ERR( rval, "Point location of tgt verts failed" );
        int num_located = dc_master.spatial_locator()->local_num_located();
        if( num_located != (int)tgt_verts.size() )
        {
            rval = MB_FAILURE;
            cout << "Only " << num_located << " out of " << tgt_verts.size() << " target points successfully located."
                 << endl;
            return rval;
        }
    }

    // Deform the master's solid mesh, put results in a new tag
    if( debug ) cout << "Deforming fluid elements in master mesh..." << endl;
    rval = deform_master( fluidElems[MASTER], solidElems[MASTER], "xnew" );MB_CHK_ERR( rval );

    {  // To isolate the lloyd smoother & delete when done
        if( debug )
        {
            // Output the skin of smoothed elems, as a check
            // Get the skin; get facets, because we might need to filter on shared entities
            Skinner skinner( mbImpl );
            Range skin;
            rval = skinner.find_skin( 0, fluidElems[MASTER], false, skin );MB_CHK_SET_ERR( rval, "Unable to find skin" );
            EntityHandle skin_set;
            cout << "Writing skin_mesh.g and fluid_mesh.g." << endl;
            rval = mbImpl->create_meshset( MESHSET_SET, skin_set );MB_CHK_SET_ERR( rval, "Failed to create skin set" );
            rval = mbImpl->add_entities( skin_set, skin );MB_CHK_SET_ERR( rval, "Failed to add skin entities to set" );
            rval = mbImpl->write_file( "skin_mesh.vtk", NULL, NULL, &skin_set, 1 );MB_CHK_SET_ERR( rval, "Failure to write skin set" );
            rval = mbImpl->remove_entities( skin_set, skin );MB_CHK_SET_ERR( rval, "Failed to remove skin entities from set" );
            rval = mbImpl->add_entities( skin_set, fluidElems[MASTER] );MB_CHK_SET_ERR( rval, "Failed to add fluid entities to set" );
            rval = mbImpl->write_file( "fluid_mesh.vtk", NULL, NULL, &skin_set, 1 );MB_CHK_SET_ERR( rval, "Failure to write fluid set" );
            rval = mbImpl->delete_entities( &skin_set, 1 );MB_CHK_SET_ERR( rval, "Failed to delete skin set" );
        }

        // Smooth the master mesh
        if( debug ) cout << "Smoothing fluid elements in master mesh..." << endl;
        LloydSmoother ll( mbImpl, NULL, fluidElems[MASTER], xNew );
        rval = ll.perform_smooth();MB_CHK_SET_ERR( rval, "Failed in lloyd smoothing" );
        cout << "Lloyd smoothing required " << ll.num_its() << " iterations." << endl;
    }

    // Transfer xNew to coords, for master
    if( debug ) cout << "Transferring coords tag to vertex coordinates in master mesh..." << endl;
    rval = write_to_coords( solidElems[MASTER], xNew );MB_CHK_SET_ERR( rval, "Failed writing tag to master fluid verts" );
    rval = write_to_coords( fluidElems[MASTER], xNew );MB_CHK_SET_ERR( rval, "Failed writing tag to master fluid verts" );

    if( have_slave )
    {
        // Map new locations to slave
        // Interpolate xNew to slave points
        if( debug ) cout << "Interpolating new coordinates to slave vertices..." << endl;
        rval = dc_master.interpolate( (int)DataCoupler::VOLUME, "xnew" );MB_CHK_SET_ERR( rval, "Failed to interpolate target solution" );
        // Transfer xNew to coords, for slave
        if( debug ) cout << "Transferring coords tag to vertex coordinates in slave mesh..." << endl;
        rval = write_to_coords( tgt_verts, xNew );MB_CHK_SET_ERR( rval, "Failed writing tag to slave verts" );
    }

    if( debug )
    {
        string str;
#ifdef USE_MPI
        if( pcMaster && pcMaster->size() > 1 ) str = "PARALLEL=WRITE_PART";
#endif
        if( debug ) cout << "Writing smoothed_master.h5m..." << endl;
        rval = mbImpl->write_file( "smoothed_master.h5m", NULL, str.c_str(), &masterSet, 1 );

        if( have_slave )
        {
#ifdef USE_MPI
            str.clear();
            if( pcSlave && pcSlave->size() > 1 ) str = "PARALLEL=WRITE_PART";
#endif
            if( debug ) cout << "Writing slave_interp.h5m..." << endl;
            rval = mbImpl->write_file( "slave_interp.h5m", NULL, str.c_str(), &slaveSet, 1 );
        }  // if have_slave
    }      // if debug

    if( debug ) dc_master.spatial_locator()->get_tree()->tree_stats().print();

    return MB_SUCCESS;
}
ErrorCode DeformMeshRemap::find_other_sets ( int  m_or_s,
EntityHandle  file_set 
) [private]

Find fluid/solid sets from complement of solid/fluid sets.

Examples:
DeformMeshRemap.cpp.

Definition at line 743 of file DeformMeshRemap.cpp.

References moab::debug, dim, moab::Interface::dimension_from_handle(), moab::Range::empty(), ErrorCode, fluidElems, fluidSets, moab::Interface::get_entities_by_handle(), moab::Interface::get_entities_by_type_and_tag(), MASTER, MATERIAL_SET_TAG_NAME, MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MBENTITYSET, mbImpl, moab::Range::rbegin(), solidElems, solidSets, moab::Range::subset_by_dimension(), moab::subtract(), and moab::Interface::tag_get_handle().

{
    // Solid or fluid sets are missing; find the other
    Range *filled_sets = NULL, *unfilled_sets = NULL, *unfilled_elems = NULL;

    if( fluidSets[m_or_s].empty() && !solidSets[m_or_s].empty() )
    {
        unfilled_sets  = &fluidSets[m_or_s];
        filled_sets    = &solidSets[m_or_s];
        unfilled_elems = &fluidElems[m_or_s];
        if( debug )
            cout << "Finding unspecified fluid elements in " << ( m_or_s == MASTER ? "master" : "slave" ) << " mesh...";
    }
    else if( !fluidSets[m_or_s].empty() && solidSets[m_or_s].empty() )
    {
        filled_sets    = &fluidSets[m_or_s];
        unfilled_sets  = &solidSets[m_or_s];
        unfilled_elems = &solidElems[m_or_s];
        if( debug )
            cout << "Finding unspecified solid elements in " << ( m_or_s == MASTER ? "master" : "slave" ) << " mesh...";
    }

    // Ok, we know the filled sets, now fill the unfilled sets, and the elems from those
    Tag tagh;
    ErrorCode rval = mbImpl->tag_get_handle( MATERIAL_SET_TAG_NAME, tagh );MB_CHK_SET_ERR( rval, "Couldn't get material set tag name" );
    Range matsets;
    rval = mbImpl->get_entities_by_type_and_tag( file_set, MBENTITYSET, &tagh, NULL, 1, matsets );
    if( MB_SUCCESS != rval || matsets.empty() )
    {
        MB_SET_ERR( MB_FAILURE, "Couldn't get any material sets" );
    }
    *unfilled_sets = subtract( matsets, *filled_sets );
    if( unfilled_sets->empty() )
    {
        MB_SET_ERR( MB_FAILURE, "Failed to find any unfilled material sets" );
    }
    Range tmp_range;
    for( Range::iterator rit = unfilled_sets->begin(); rit != unfilled_sets->end(); ++rit )
    {
        rval = mbImpl->get_entities_by_handle( *rit, tmp_range, true );MB_CHK_SET_ERR( rval, "Failed to get entities in unfilled set" );
    }
    int dim = mbImpl->dimension_from_handle( *tmp_range.rbegin() );
    assert( dim > 0 && dim < 4 );
    *unfilled_elems = tmp_range.subset_by_dimension( dim );
    if( unfilled_elems->empty() )
    {
        MB_SET_ERR( MB_FAILURE, "Failed to find any unfilled set entities" );
    }

    if( debug )
        cout << "found " << unfilled_sets->size() << " sets and " << unfilled_elems->size() << " elements." << endl;

    return MB_SUCCESS;
}
string DeformMeshRemap::get_file_name ( int  m_or_s) const

Get/set the file name.

Examples:
DeformMeshRemap.cpp.

Definition at line 388 of file DeformMeshRemap.cpp.

{
    switch( m_or_s )
    {
        case MASTER:
            return masterFileName;
        case SLAVE:
            return slaveFileName;
        default:
            assert( false && "m_or_s should be MASTER or SLAVE." );
            return string();
    }
}
ErrorCode DeformMeshRemap::get_set_nos ( int  m_or_s,
int  fluid_or_solid,
set< int > &  set_nos 
) const [inline]

Get the set numbers.

Examples:
DeformMeshRemap.cpp.

Definition at line 233 of file DeformMeshRemap.cpp.

References MB_INDEX_OUT_OF_RANGE, MB_SUCCESS, and SOLID.

{
    const set< int >* this_set;
    assert( ( m_or_s == MASTER || m_or_s == SLAVE ) && "m_or_s should be MASTER or SLAVE." );
    if( m_or_s != MASTER && m_or_s != SLAVE ) return MB_INDEX_OUT_OF_RANGE;
    switch( f_or_s )
    {
        case FLUID:
            this_set = &fluidSetNos[m_or_s];
            break;
        case SOLID:
            this_set = &solidSetNos[m_or_s];
            break;
        default:
            assert( false && "f_or_s should be FLUID or SOLID." );
            return MB_FAILURE;
    }

    set_nos = *this_set;

    return MB_SUCCESS;
}
ErrorCode DeformMeshRemap::read_file ( int  m_or_s,
string &  fname,
EntityHandle seth 
) [private]

Read a file and establish proper ranges.

Examples:
DeformMeshRemap.cpp.

Definition at line 657 of file DeformMeshRemap.cpp.

References moab::Range::clear(), moab::Interface::create_meshset(), moab::debug, dim, moab::Interface::dimension_from_handle(), moab::Range::empty(), moab::Range::end(), ErrorCode, fluidElems, fluidSetNos, fluidSets, moab::Interface::get_entities_by_handle(), moab::Interface::get_entities_by_type_and_tag(), moab::ParallelComm::get_id(), moab::Interface::load_file(), MASTER, MATERIAL_SET_TAG_NAME, MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MBENTITYSET, mbImpl, moab::Range::merge(), moab::Range::rbegin(), moab::Range::size(), moab::ParallelComm::size(), solidElems, solidSetNos, solidSets, moab::Range::subset_by_dimension(), and moab::Interface::tag_get_handle().

{
    // Create meshset
    ErrorCode rval = mbImpl->create_meshset( 0, seth );MB_CHK_SET_ERR( rval, "Couldn't create master/slave set" );
    ostringstream options;
#ifdef USE_MPI
    ParallelComm* pc = ( m_or_s == MASTER ? pcMaster : pcSlave );
    if( pc && pc->size() > 1 )
    {
        if( debug ) options << "DEBUG_IO=1;CPUTIME;";
        options << "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;"
                << "PARALLEL_GHOSTS=2.0.1;PARALLEL_COMM=" << pc->get_id();
    }
#endif
    rval = mbImpl->load_file( fname.c_str(), &seth, options.str().c_str() );MB_CHK_SET_ERR( rval, "Couldn't load master/slave mesh" );

    if( *solidSetNos[m_or_s].begin() == -1 || *fluidSetNos[m_or_s].begin() == -1 ) return MB_SUCCESS;

    // Get material sets for solid/fluid
    Tag tagh;
    rval = mbImpl->tag_get_handle( MATERIAL_SET_TAG_NAME, tagh );MB_CHK_SET_ERR( rval, "Couldn't get material set tag name" );
    for( set< int >::iterator sit = solidSetNos[m_or_s].begin(); sit != solidSetNos[m_or_s].end(); ++sit )
    {
        Range sets;
        int set_no            = *sit;
        const void* setno_ptr = &set_no;
        rval                  = mbImpl->get_entities_by_type_and_tag( seth, MBENTITYSET, &tagh, &setno_ptr, 1, sets );
        if( MB_SUCCESS != rval || sets.empty() )
        {
            MB_SET_ERR( MB_FAILURE, "Couldn't find solid set #" << *sit );
        }
        else
            solidSets[m_or_s].merge( sets );
    }

    // Get solid entities, and dimension
    Range tmp_range;
    for( Range::iterator rit = solidSets[m_or_s].begin(); rit != solidSets[m_or_s].end(); ++rit )
    {
        rval = mbImpl->get_entities_by_handle( *rit, tmp_range, true );MB_CHK_SET_ERR( rval, "Failed to get entities in solid" );
    }
    if( !tmp_range.empty() )
    {
        int dim = mbImpl->dimension_from_handle( *tmp_range.rbegin() );
        assert( dim > 0 && dim < 4 );
        solidElems[m_or_s] = tmp_range.subset_by_dimension( dim );
    }

    if( debug )
        cout << "Read " << solidElems[m_or_s].size() << " solid elements from " << solidSets[m_or_s].size()
             << " sets in " << ( m_or_s == MASTER ? "master" : "slave" ) << " mesh." << endl;

    for( set< int >::iterator sit = fluidSetNos[m_or_s].begin(); sit != fluidSetNos[m_or_s].end(); ++sit )
    {
        Range sets;
        int set_no            = *sit;
        const void* setno_ptr = &set_no;
        rval                  = mbImpl->get_entities_by_type_and_tag( seth, MBENTITYSET, &tagh, &setno_ptr, 1, sets );
        if( MB_SUCCESS != rval || sets.empty() )
        {
            MB_SET_ERR( MB_FAILURE, "Couldn't find fluid set #" << *sit );
        }
        else
            fluidSets[m_or_s].merge( sets );
    }

    // Get fluid entities, and dimension
    tmp_range.clear();
    for( Range::iterator rit = fluidSets[m_or_s].begin(); rit != fluidSets[m_or_s].end(); ++rit )
    {
        rval = mbImpl->get_entities_by_handle( *rit, tmp_range, true );MB_CHK_SET_ERR( rval, "Failed to get entities in fluid" );
    }
    if( !tmp_range.empty() )
    {
        int dim = mbImpl->dimension_from_handle( *tmp_range.rbegin() );
        assert( dim > 0 && dim < 4 );
        fluidElems[m_or_s] = tmp_range.subset_by_dimension( dim );
    }

    if( debug )
        cout << "Read " << fluidElems[m_or_s].size() << " fluid elements from " << fluidSets[m_or_s].size()
             << " sets in " << ( m_or_s == MASTER ? "master" : "slave" ) << " mesh." << endl;

    return rval;
}
ErrorCode DeformMeshRemap::remove_set_no ( int  m_or_s,
int  fluid_or_solid,
int  set_no 
) [inline]

Remove a set number.

Examples:
DeformMeshRemap.cpp.

Definition at line 205 of file DeformMeshRemap.cpp.

References MB_INDEX_OUT_OF_RANGE, MB_SUCCESS, and SOLID.

{
    set< int >* this_set;
    assert( ( m_or_s == MASTER || m_or_s == SLAVE ) && "m_or_s should be MASTER or SLAVE." );
    if( m_or_s != MASTER && m_or_s != SLAVE ) return MB_INDEX_OUT_OF_RANGE;
    switch( f_or_s )
    {
        case FLUID:
            this_set = &fluidSetNos[m_or_s];
            break;
        case SOLID:
            this_set = &solidSetNos[m_or_s];
            break;
        default:
            assert( false && "f_or_s should be FLUID or SOLID." );
            return MB_FAILURE;
    }
    set< int >::iterator sit = this_set->find( set_no );
    if( sit != this_set->end() )
    {
        this_set->erase( *sit );
        return MB_SUCCESS;
    }

    return MB_FAILURE;
}
void DeformMeshRemap::set_file_name ( int  m_or_s,
const string &  name 
)

Get/set the file name.

Examples:
DeformMeshRemap.cpp.

Definition at line 402 of file DeformMeshRemap.cpp.

Referenced by main().

{
    switch( m_or_s )
    {
        case MASTER:
            masterFileName = name;
            break;
        case SLAVE:
            slaveFileName = name;
            break;
        default:
            assert( false && "m_or_s should be MASTER or SLAVE." );
    }
}
ErrorCode DeformMeshRemap::write_and_save ( Range ents,
EntityHandle  seth,
Tag  tagh,
const char *  filename,
bool  restore_coords = false 
) [private]

Write the tag to the vertices, then save to the specified file If restore_coords is true, coords are restored to their initial state after file is written

Examples:
DeformMeshRemap.cpp.

Definition at line 504 of file DeformMeshRemap.cpp.

References ErrorCode, MB_CHK_ERR, MB_TAG_CREAT, MB_TAG_DENSE, MB_TYPE_DOUBLE, mbImpl, moab::Interface::tag_delete(), moab::Interface::tag_get_handle(), moab::Interface::write_file(), and write_to_coords().

Referenced by deform_master().

{
    Tag tmp_tag = 0;
    ErrorCode rval;
    if( restore_coords ) rval = mbImpl->tag_get_handle( "", 3, MB_TYPE_DOUBLE, tmp_tag, MB_TAG_CREAT | MB_TAG_DENSE );

    rval = write_to_coords( ents, tagh, tmp_tag );MB_CHK_ERR( rval );
    rval = mbImpl->write_file( filename, NULL, NULL, &seth, 1 );MB_CHK_ERR( rval );
    if( restore_coords )
    {
        rval = write_to_coords( ents, tmp_tag );MB_CHK_ERR( rval );
        rval = mbImpl->tag_delete( tmp_tag );MB_CHK_ERR( rval );
    }

    return rval;
}
ErrorCode DeformMeshRemap::write_to_coords ( Range elems,
Tag  tagh,
Tag  tmp_tag = 0 
) [private]

Write the input tag to the coordinates for the vertices in the input elems If non-zero tmp_tag is input, save coords to tmp_tag before over-writing with tag value

Examples:
DeformMeshRemap.cpp.

Definition at line 525 of file DeformMeshRemap.cpp.

References ErrorCode, moab::Interface::get_adjacencies(), moab::Interface::get_coords(), MB_CHK_SET_ERR, MB_SUCCESS, mbImpl, moab::Interface::set_coords(), moab::Range::size(), moab::Interface::tag_get_data(), moab::Interface::tag_set_data(), and smoab::UNION.

Referenced by write_and_save().

{
    // Write the tag to coordinates
    Range verts;
    ErrorCode rval = mbImpl->get_adjacencies( elems, 0, false, verts, Interface::UNION );MB_CHK_SET_ERR( rval, "Failed to get adj vertices" );
    vector< double > coords( 3 * verts.size() );

    if( tmp_tag )
    {
        // Save the coords to tmp_tag first
        rval = mbImpl->get_coords( verts, &coords[0] );MB_CHK_SET_ERR( rval, "Failed to get tmp copy of coords" );
        rval = mbImpl->tag_set_data( tmp_tag, verts, &coords[0] );MB_CHK_SET_ERR( rval, "Failed to save tmp copy of coords" );
    }

    rval = mbImpl->tag_get_data( tagh, verts, &coords[0] );MB_CHK_SET_ERR( rval, "Failed to get tag data" );
    rval = mbImpl->set_coords( verts, &coords[0] );MB_CHK_SET_ERR( rval, "Failed to set coordinates" );
    return MB_SUCCESS;
}
Tag DeformMeshRemap::x_new ( ) const [inline]

Get the xNew tag handle.

Definition at line 90 of file DeformMeshRemap.cpp.

    {
        return xNew;
    }
string DeformMeshRemap::x_new_name ( ) const [inline]

Get the tag name.

Definition at line 96 of file DeformMeshRemap.cpp.

    {
        return xNewName;
    }
void DeformMeshRemap::x_new_name ( const string &  name) [inline]

Set the tag name.

Definition at line 102 of file DeformMeshRemap.cpp.

    {
        xNewName = name;
    }
string DeformMeshRemap::xdisp_name ( int  idx = 0) [inline]

Get/set the x displacement tag names.

Examples:
DeformMeshRemap.cpp.

Definition at line 256 of file DeformMeshRemap.cpp.

Referenced by main().

{
    return xDispNames[idx];
}
void DeformMeshRemap::xdisp_name ( const string &  nm,
int  idx = 0 
)

Definition at line 261 of file DeformMeshRemap.cpp.

{
    xDispNames[idx] = nm;
}

Member Data Documentation

Elements in master/slave meshes.

Examples:
DeformMeshRemap.cpp.

Definition at line 161 of file DeformMeshRemap.cpp.

Referenced by deform_master(), find_other_sets(), and read_file().

set< int > DeformMeshRemap::fluidSetNos[2] [private]

Material set numbers for fluid materials, for master/slave.

Examples:
DeformMeshRemap.cpp.

Definition at line 149 of file DeformMeshRemap.cpp.

Referenced by read_file().

Sets in master/slave meshes.

Examples:
DeformMeshRemap.cpp.

Definition at line 158 of file DeformMeshRemap.cpp.

Referenced by find_other_sets(), and read_file().

Filenames for master/slave meshes.

Definition at line 164 of file DeformMeshRemap.cpp.

Sets defining master/slave meshes.

Examples:
DeformMeshRemap.cpp.

Definition at line 155 of file DeformMeshRemap.cpp.

Referenced by deform_master().

Definition at line 164 of file DeformMeshRemap.cpp.

Definition at line 155 of file DeformMeshRemap.cpp.

Examples:
DeformMeshRemap.cpp.

Definition at line 161 of file DeformMeshRemap.cpp.

Referenced by deform_master(), find_other_sets(), and read_file().

set< int > DeformMeshRemap::solidSetNos[2] [private]

Material set numbers for solid materials, for master/slave.

Examples:
DeformMeshRemap.cpp.

Definition at line 152 of file DeformMeshRemap.cpp.

Referenced by read_file().

Examples:
DeformMeshRemap.cpp.

Definition at line 158 of file DeformMeshRemap.cpp.

Referenced by find_other_sets(), and read_file().

Tag from file, might be 3.

Examples:
DeformMeshRemap.cpp.

Definition at line 167 of file DeformMeshRemap.cpp.

Referenced by deform_master(), and DeformMeshRemap().

string DeformMeshRemap::xDispNames[3] [private]

Tag name used to read disps from file.

Examples:
DeformMeshRemap.cpp.

Definition at line 173 of file DeformMeshRemap.cpp.

Referenced by deform_master().

Tag used for new positions.

Examples:
DeformMeshRemap.cpp.

Definition at line 170 of file DeformMeshRemap.cpp.

Referenced by deform_master().

string DeformMeshRemap::xNewName [private]

Tag name used for new positions.

Definition at line 176 of file DeformMeshRemap.cpp.

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines