MOAB: Mesh Oriented datABase  (version 5.2.1)
ParShapeImprover Class Reference

Classes

class  ParShapeImprovementWrapper

Public Member Functions

 ParShapeImprover (int inner_iterations=100, double grad_norm=1.e-8)
void run (Mesh &mesh, MeshDomain *domain, MsqError &err, bool always_smooth=true, int debug=0)

Static Public Member Functions

static int count_invalid_elements (Mesh &mesh, MeshDomain *domain=0)

Private Attributes

int innerIter
double gradNorm

Detailed Description

Definition at line 111 of file par_hex_untangle_shape.cpp.


Constructor & Destructor Documentation

ParShapeImprover::ParShapeImprover ( int  inner_iterations = 100,
double  grad_norm = 1.e-8 
) [inline]

Definition at line 117 of file par_hex_untangle_shape.cpp.

        : innerIter( inner_iterations ), gradNorm( grad_norm )
    {
    }

Member Function Documentation

int ParShapeImprover::count_invalid_elements ( Mesh mesh,
MeshDomain domain = 0 
) [static]

Definition at line 315 of file par_hex_untangle_shape.cpp.

References MBMesquite::InstructionQueue::add_quality_assessor(), MBMesquite::QualityAssessor::Assessor::get_invalid_element_count(), MBMesquite::QualityAssessor::get_results(), MBMesquite::QualityMetric::LINEAR, mesh, MSQ_ERRZERO, MBMesquite::InstructionQueue::run_common(), MBMesquite::AveragingQM::set_averaging_method(), and settings.

{
    MsqError err;
    InstructionQueue q;

    IdealWeightInverseMeanRatio metric;
    metric.set_averaging_method( QualityMetric::LINEAR );

    // Check for inverted elements in the mesh
    QualityAssessor inv_check( &metric );
    // inv_check.disable_printing_results();
    q.add_quality_assessor( &inv_check, err );
    MSQ_ERRZERO( err );
    Settings settings;
    // bug?  should we pass in pmesh?
    Mesh* mesh_ptr                  = &mesh;
    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( mesh_ptr, domain );
    q.run_common( &mesh_and_domain, 0, &settings, err );
    MSQ_ERRZERO( err );
    const QualityAssessor::Assessor* inv_b = inv_check.get_results( &metric );
    int num_invalid                        = inv_b->get_invalid_element_count();
    return num_invalid;
}
void ParShapeImprover::run ( Mesh mesh,
MeshDomain domain,
MsqError err,
bool  always_smooth = true,
int  debug = 0 
)

Definition at line 339 of file par_hex_untangle_shape.cpp.

References MBMesquite::MsqDebug::enable(), ParShapeImprover::ParShapeImprovementWrapper::m_do_untangle_only, mesh, MPI_COMM_WORLD, MSQ_ERRRTN, rank, and MBMesquite::IQInterface::run_instructions().

Referenced by test().

{
    int rank, nprocs;
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    MPI_Comm_size( MPI_COMM_WORLD, &nprocs );

    if( debug )
    {
        MsqDebug::enable( 1 );
        if( debug > 1 ) MsqDebug::enable( 2 );
        if( debug > 2 ) MsqDebug::enable( 3 );
    }

    ParallelMesh* pmesh = dynamic_cast< ParallelMesh* >( &mesh );
    std::cout << "P[" << rank << "] "
              << " ParShapeImprover::run: pmesh= " << pmesh << std::endl;

    MsqError mErr;
    int num_invalid    = 0;
    bool check_quality = true;
    if( check_quality )
    {
        num_invalid = count_invalid_elements( mesh, domain );
        std::cout << "\nP[" << rank << "] "
                  << " ParShapeImprover num_invalid before= " << num_invalid
                  << ( num_invalid
                           ? " WARNING: invalid elements exist before MBMesquite smoothing"
                           : ( !always_smooth ? "WARNING: no smoothing requested since always_smooth=false" : " " ) )
                  << std::endl;
    }

    if( num_invalid || always_smooth )
    {
        bool use_canned_wrapper = false;
        if( use_canned_wrapper )
        {
            ShapeImprovementWrapper siw( mErr );
            if( pmesh )
                siw.run_instructions( pmesh, domain, mErr );
            else
            {
                MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, domain );
                siw.run_instructions( &mesh_and_domain, mErr );
            }
        }
        else
        {
            // int  msq_debug             = debug; // 1,2,3 for more debug info
            // bool always_smooth_local   = false;

            bool do_untangle_only = false;
            ParShapeImprover::ParShapeImprovementWrapper siw( innerIter, 0.0, gradNorm, 100 );
            siw.m_do_untangle_only = do_untangle_only;
            if( pmesh )
                siw.run_instructions( pmesh, domain, mErr );
            else
            {
                MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, domain );
                siw.run_instructions( &mesh_and_domain, mErr );
            }
        }

        std::cout << "\nP[" << rank << "] "
                  << " ParShapeImprover: MsqError after ShapeImprovementWrapper: " << mErr << std::endl;

        if( check_quality )
        {
            num_invalid = count_invalid_elements( mesh, domain );
            std::cout << "\nP[" << rank << "] "
                      << " ParShapeImprover num_invalid after= " << num_invalid << " "
                      << ( num_invalid ? " ERROR still have invalid elements after MBMesquite smoothing"
                                       : " SUCCESS: smoothed and removed invalid elements " )
                      << std::endl;
        }

        MSQ_ERRRTN( mErr );
    }
}

Member Data Documentation

double ParShapeImprover::gradNorm [private]

Definition at line 114 of file par_hex_untangle_shape.cpp.

Definition at line 113 of file par_hex_untangle_shape.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