MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::Instruction Class Reference

Base class for all objects inserted into InstructionQueue. More...

#include <Instruction.hpp>

+ Inheritance diagram for MBMesquite::Instruction:

Public Member Functions

virtual ~Instruction ()
virtual void initialize_queue (MeshDomainAssoc *mesh_and_domain, const Settings *settings, MsqError &err)=0
virtual double loop_over_mesh (MeshDomainAssoc *mesh_and_domain, const Settings *settings, MsqError &err)=0
virtual double loop_over_mesh (ParallelMesh *mesh, MeshDomain *domain, const Settings *settings, MsqError &err)
virtual std::string get_name () const =0
 Get string name for use in diagnostic and status output.

Static Public Member Functions

static void initialize_vertex_byte (MeshDomainAssoc *mesh_and_domain, const Settings *settings, MsqError &err)

Detailed Description

Base class for all objects inserted into InstructionQueue.

Definition at line 45 of file Instruction.hpp.


Constructor & Destructor Documentation

Definition at line 47 of file Instruction.cpp.

{}

Member Function Documentation

virtual void MBMesquite::Instruction::initialize_queue ( MeshDomainAssoc mesh_and_domain,
const Settings settings,
MsqError err 
) [pure virtual]

Called for all instructions in queue before loop_over_mesh is called for any insetruction in queue. Default behavior is to do nothing.

Implemented in MBMesquite::QualityAssessor, DummyVertexSlaver, MBMesquite::TagVertexMesh, MBMesquite::SlaveBoundaryVertices, MBMesquite::QualityImprover, MBMesquite::MeshTransform, MBMesquite::TargetWriter, and MBMesquite::VertexMover.

void Instruction::initialize_vertex_byte ( MeshDomainAssoc mesh_and_domain,
const Settings settings,
MsqError err 
) [static]

Using data from query methods in MeshInterface or calculating as necessary depending on values in Settings, initialize MSQ_HARD_FIXED and MSQ_SLAVED flags on vertices, and clear MSQ_CULLED flag on all vertices. SLAVE_ALL setting is handled in PatchData rather than here for efficiency.

Definition at line 55 of file Instruction.cpp.

References MBMesquite::arrptr(), corners, dim, dof(), MBMesquite::MeshDomain::domain_DoF(), MBMesquite::Mesh::elements_get_attached_vertices(), MBMesquite::Mesh::elements_get_topologies(), mhdf_FileDesc::elems, MBMesquite::Settings::FIXED_FLAG, MBMesquite::Mesh::get_all_elements(), MBMesquite::Mesh::get_all_vertices(), MBMesquite::MeshDomainAssoc::get_domain(), MBMesquite::Settings::get_fixed_vertex_mode(), MBMesquite::MeshDomainAssoc::get_mesh(), MBMesquite::Settings::get_slaved_ho_node_mode(), MBMesquite::MsqError::INVALID_STATE, mesh, MBMesquite::MsqVertex::MSQ_DEPENDENT, MSQ_ERRRTN, MBMesquite::MsqVertex::MSQ_HARD_FIXED, MSQ_SETERR, MBMesquite::POLYGON, MBMesquite::Settings::SLAVE_ALL, MBMesquite::Settings::SLAVE_CALCULATED, MBMesquite::Settings::SLAVE_FLAG, u, MBMesquite::Mesh::vertices_get_byte(), MBMesquite::Mesh::vertices_get_fixed_flag(), MBMesquite::Mesh::vertices_get_slaved_flag(), and MBMesquite::Mesh::vertices_set_byte().

Referenced by check_global_patch_slaved(), PatchDataTest::check_higher_order_vertices_slaved(), MBMesquite::VertexMover::loop_over_mesh(), MBMesquite::QualityAssessor::loop_over_mesh_internal(), MBMesquite::UntangleWrapper::run_wrapper(), VtkTest::test_elements(), and PatchDataTest::test_fixed_by_geom_dim().

{
    std::vector< Mesh::VertexHandle > verts;
    std::vector< unsigned char > bytes;

    Mesh* mesh         = mesh_and_domain->get_mesh();
    MeshDomain* domain = mesh_and_domain->get_domain();

    // Handle SLAVE_ALL first because we want to work with vertices
    // in element connectivity lists rather than one big array of
    // vertex handles.
    bool use_existing_slaved_flag = false;
    if( !settings || settings->get_slaved_ho_node_mode() == Settings::SLAVE_ALL )
    {
        std::vector< Mesh::ElementHandle > elems;
        std::vector< size_t > junk;
        mesh->get_all_elements( elems, err );MSQ_ERRRTN( err );
        for( size_t i = 0; i < elems.size(); ++i )
        {
            EntityTopology type;
            mesh->elements_get_topologies( &elems[i], &type, 1, err );MSQ_ERRRTN( err );
            unsigned ncorner = TopologyInfo::corners( type );

            verts.clear();
            junk.clear();
            mesh->elements_get_attached_vertices( &elems[i], 1, verts, junk, err );MSQ_ERRRTN( err );
            if( ncorner < verts.size() && type != POLYGON ) use_existing_slaved_flag = true;

            bytes.clear();
            bytes.resize( verts.size(), 0 );
            std::fill( bytes.begin() + TopologyInfo::corners( type ), bytes.end(), MsqVertex::MSQ_DEPENDENT );
            mesh->vertices_set_byte( arrptr( verts ), arrptr( bytes ), verts.size(), err );MSQ_ERRRTN( err );
        }
    }
    else if( settings && settings->get_slaved_ho_node_mode() == Settings::SLAVE_CALCULATED )
        use_existing_slaved_flag = true;

    std::vector< bool > flags;
    verts.clear();
    mesh->get_all_vertices( verts, err );MSQ_ERRRTN( err );
    bytes.clear();
    bytes.resize( verts.size(), 0 );

    // Normally we start out with all bits cleared.  However, if
    // we're doing SLAVE_CALCULATED mode then we need to perserve
    // the exinsting value of that bit because it was presumably
    // set by a previous tool in the InstructionQueue.  Also, if doing
    // SLAVE_ALL, preserve the value we just set.
    if( use_existing_slaved_flag )
    {
        mesh->vertices_get_byte( arrptr( verts ), arrptr( bytes ), verts.size(), err );MSQ_ERRRTN( err );
        for( size_t i = 0; i < bytes.size(); ++i )
            bytes[i] &= (unsigned char)MsqVertex::MSQ_DEPENDENT;
    }
    // If getting slaved flag for higher-order nodes from application,
    // copy it into vertex byte now.
    else if( settings && settings->get_slaved_ho_node_mode() == Settings::SLAVE_FLAG )
    {
        mesh->vertices_get_slaved_flag( arrptr( verts ), flags, verts.size(), err );MSQ_ERRRTN( err );
        for( size_t i = 0; i < bytes.size(); ++i )
            if( flags[i] ) bytes[i] |= (unsigned char)MsqVertex::MSQ_DEPENDENT;
    }

    // If using application-specified fixed flag, copy that into
    // vertex byte now.
    if( !settings || settings->get_fixed_vertex_mode() == Settings::FIXED_FLAG )
    {
        mesh->vertices_get_fixed_flag( arrptr( verts ), flags, verts.size(), err );MSQ_ERRRTN( err );
        for( size_t i = 0; i < bytes.size(); ++i )
            if( flags[i] ) bytes[i] |= (unsigned char)MsqVertex::MSQ_HARD_FIXED;
    }
    // otherwise need to mark vertices as fixed based on geometric domain
    else
    {
        if( !domain )
        {
            MSQ_SETERR( err )
            ( "Request to fix vertices by domain classification "
              "requres a domain.",
              MsqError::INVALID_STATE );
            return;
        }
        const unsigned short dim = settings->get_fixed_vertex_mode();
        assert( dim < 4u );
        std::vector< unsigned short > dof( verts.size() );
        domain->domain_DoF( arrptr( verts ), arrptr( dof ), verts.size(), err );MSQ_ERRRTN( err );
        for( size_t i = 0; i < bytes.size(); ++i )
            if( dof[i] <= dim ) bytes[i] |= (unsigned char)MsqVertex::MSQ_HARD_FIXED;
    }

    // Copy flag values back to mesh instance
    mesh->vertices_set_byte( arrptr( verts ), arrptr( bytes ), verts.size(), err );MSQ_ERRRTN( err );
}
virtual double MBMesquite::Instruction::loop_over_mesh ( MeshDomainAssoc mesh_and_domain,
const Settings settings,
MsqError err 
) [pure virtual]
double Instruction::loop_over_mesh ( ParallelMesh mesh,
MeshDomain domain,
const Settings settings,
MsqError err 
) [virtual]

Virtual fuction implementing primary functionaliy of instruction instance for parallel mesh.

Reimplemented in MBMesquite::QualityAssessor, and MBMesquite::VertexMover.

Definition at line 49 of file Instruction.cpp.

References loop_over_mesh().

{
    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( (Mesh*)mesh, domain, false, true );
    return loop_over_mesh( &mesh_and_domain, settings, err );
}

List of all members.


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