MOAB: Mesh Oriented datABase  (version 5.3.0)
synchronous_test.cpp File Reference
#include "Mesquite.hpp"
#include "ConditionNumberQualityMetric.hpp"
#include "IdealWeightInverseMeanRatio.hpp"
#include "LPtoPTemplate.hpp"
#include "InstructionQueue.hpp"
#include "ConjugateGradient.hpp"
#include "FeasibleNewton.hpp"
#include "MeshImpl.hpp"
#include "QualityAssessor.hpp"
#include "XYRectangle.hpp"
#include <iostream>
#include <fstream>
#include <cstdlib>
+ Include dependency graph for synchronous_test.cpp:

Go to the source code of this file.

Functions

void create_input_mesh (double mid_x, MBMesquite::MeshImpl &mesh, MBMesquite::MsqError &)
void usage (const char *argv0, bool brief=true)
void parse_options (char *argv[], int argc)
int main (int argc, char *argv[])

Variables

const double min_x = 0.0
const double max_x = 2.0
const double min_y = 0.0
const double mid_y = 1.0
const double max_y = 2.0
const double z = 0.0
const char default_out_file [] = "synchronous.vtk"
double default_x = 0.25
char mSolver = '\0'
char mMetric = '\0'
const char * outputFile = default_out_file
double input_x = default_x
const char * temp_file = "syncrononous_input.vtk"

Function Documentation

void create_input_mesh ( double  mid_x,
MBMesquite::MeshImpl mesh,
MBMesquite::MsqError err 
)

Definition at line 212 of file synchronous_test.cpp.

References max_x, max_y, mid_y, min_x, min_y, MBMesquite::MeshImpl::read_vtk(), temp_file, and z.

{
    std::ofstream vtkfile( temp_file );
    vtkfile << "# vtk DataFile Version 3.0" << std::endl
            << "Mesquite Syncronous Boundary test" << std::endl
            << "ASCII" << std::endl
            << "DATASET UNSTRUCTURED_GRID" << std::endl
            << "POINTS 9 float" << std::endl
            << min_x << ' ' << max_y << ' ' << z << std::endl
            << mid_x << ' ' << max_y << ' ' << z << std::endl
            << max_x << ' ' << max_y << ' ' << z << std::endl
            << min_x << ' ' << mid_y << ' ' << z << std::endl
            << mid_x << ' ' << mid_y << ' ' << z << std::endl
            << max_x << ' ' << mid_y << ' ' << z << std::endl
            << min_x << ' ' << min_y << ' ' << z << std::endl
            << mid_x << ' ' << min_y << ' ' << z << std::endl
            << max_x << ' ' << min_y << ' ' << z << std::endl
            << "CELLS 4 20" << std::endl
            << "4 1 0 3 4" << std::endl
            << "4 2 1 4 5" << std::endl
            << "4 4 3 6 7" << std::endl
            << "4 5 4 7 8" << std::endl
            << "CELL_TYPES 4" << std::endl
            << "9 9 9 9" << std::endl
            << "POINT_DATA 9" << std::endl
            << "SCALARS fixed int" << std::endl
            << "LOOKUP_TABLE default" << std::endl
            << "1 0 1" << std::endl
            << "1 0 1" << std::endl
            << "1 0 1" << std::endl;
    vtkfile.close();

    mesh.read_vtk( temp_file, err );
    remove( temp_file );
}
int main ( int  argc,
char *  argv[] 
)

Definition at line 142 of file synchronous_test.cpp.

References MBMesquite::TerminationCriterion::add_absolute_vertex_movement(), MBMesquite::InstructionQueue::add_quality_assessor(), create_input_mesh(), MBMesquite::TerminationCriterion::GNUPLOT, MBMesquite::inner(), input_x, max_x, max_y, mesh, min_x, min_y, mMetric, mSolver, MSQ_CHKERR, outputFile, parse_options(), MBMesquite::IQInterface::run_instructions(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::XYRectangle::setup(), MBMesquite::TerminationCriterion::write_mesh_steps(), and MBMesquite::MeshImpl::write_vtk().

{
    parse_options( argv, argc );

    MeshImpl mesh;
    XYRectangle domain( max_x - min_x, max_y - min_y, min_x, min_y );
    MsqError err;

    create_input_mesh( input_x, mesh, err );
    if( MSQ_CHKERR( err ) )
    {
        std::cerr << err << std::endl;
        return 2;
    }

    domain.setup( &mesh, err );
    if( MSQ_CHKERR( err ) )
    {
        std::cerr << err << std::endl;
        return 2;
    }

    QualityMetric* metric = 0;
    if( mMetric == 'c' )
        metric = new ConditionNumberQualityMetric;
    else
        metric = new IdealWeightInverseMeanRatio;

    LPtoPTemplate function( 1, metric );

    VertexMover* solver = 0;
    if( mSolver == 'j' )
        solver = new ConjugateGradient( &function );
    else
        solver = new FeasibleNewton( &function );

    if( PatchSetUser* psu = dynamic_cast< PatchSetUser* >( solver ) ) psu->use_global_patch();

    TerminationCriterion inner;
    inner.add_absolute_vertex_movement( 1e-4 );
    inner.write_mesh_steps( "synchronous", TerminationCriterion::GNUPLOT );
    solver->set_inner_termination_criterion( &inner );

    InstructionQueue q;
    QualityAssessor qa( metric, 10 );
    q.add_quality_assessor( &qa, err );
    q.set_master_quality_improver( solver, err );
    q.add_quality_assessor( &qa, err );
    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &domain );
    q.run_instructions( &mesh_and_domain, err );
    delete solver;
    delete metric;

    if( MSQ_CHKERR( err ) )
    {
        std::cerr << err << std::endl;
        return 3;
    }

    mesh.write_vtk( outputFile, err );
    if( MSQ_CHKERR( err ) )
    {
        std::cerr << err << std::endl;
        return 2;
    }

    return 0;
}
void parse_options ( char *  argv[],
int  argc 
)

Definition at line 87 of file synchronous_test.cpp.

References default_out_file, input_x, mMetric, mSolver, outputFile, and usage.

{
    bool next_arg_is_x = false;
    for( int i = 1; i < argc; ++i )
    {
        if( next_arg_is_x )
        {
            next_arg_is_x = false;
            char* endptr  = 0;
            input_x       = std::strtod( argv[i], &endptr );
            if( endptr && *endptr ) usage( argv[0] );
            continue;
        }

        if( argv[i][0] != '-' )
        {
            if( outputFile != default_out_file ) usage( argv[0] );
            outputFile = argv[i];
            continue;
        }

        for( const char* p = argv[i] + 1; *p; ++p )
        {
            switch( *p )
            {
                case 'x':
                    next_arg_is_x = true;
                    break;

                case 'j':
                case 'n':
                    if( mSolver ) usage( argv[0] );
                    mSolver = *p;
                    break;

                case 'r':
                case 'c':
                    if( mMetric ) usage( argv[0] );
                    mMetric = *p;
                    break;

                default:
                    usage( argv[0], *p != 'h' );
                    break;
            }
        }
    }

    if( next_arg_is_x ) usage( argv[0] );

    // default values
    if( !mMetric ) mMetric = 'c';
    if( !mSolver ) mSolver = 'j';
}
void usage ( const char *  argv0,
bool  brief = true 
)

Definition at line 59 of file synchronous_test.cpp.

References default_out_file, and default_x.

{
    std::ostream& str = brief ? std::cerr : std::cout;

    str << "Usage: " << argv0 << " [-x <coord>]"
        << " [-j|-n|-d]"
        << " [-r|-c]"
        << " [<output_file>]" << std::endl;
    if( brief )
    {
        str << "       " << argv0 << " -h" << std::endl;
        std::exit( 1 );
    }

    str << "  -x  Specify X coordinate value for mesh (default is " << default_x << ")" << std::endl
        << "  -j  Use ConjugateGradient solver (default)" << std::endl
        << "  -n  Use FeasibleNewton solver" << std::endl
        << "  -r  Use IdealWeightInverseMeanRation metric" << std::endl
        << "  -c  Use ConditionNumber metric (default)" << std::endl
        << "Default output file is \"" << default_out_file << '"' << std::endl;

    std::exit( 0 );
}

Variable Documentation

const char default_out_file[] = "synchronous.vtk"

Definition at line 54 of file synchronous_test.cpp.

double default_x = 0.25

Definition at line 55 of file synchronous_test.cpp.

Referenced by usage().

double input_x = default_x

Definition at line 85 of file synchronous_test.cpp.

Referenced by main(), and parse_options().

const double max_x = 2.0
const double max_y = 2.0
const double mid_y = 1.0

Definition at line 51 of file synchronous_test.cpp.

Referenced by create_input_mesh().

char mMetric = '\0'

Definition at line 83 of file synchronous_test.cpp.

Referenced by AddQualityMetricTest::AddQualityMetricTest(), BCDTest::compare_bcd(), FauxAbsShapeMetric::evaluate(), NumericalMetric< typename AWQualityMetric::MetricType >::evaluate(), MetricLogger::evaluate(), MetricLogger::get_evaluations(), MetricLogger::get_metric_type(), FauxAbsShapeMetric::get_name(), NumericalMetric< typename AWQualityMetric::MetricType >::get_name(), MetricLogger::get_name(), MetricLogger::get_negate_flag(), main(), MultiplyQualityMetricTest::MultiplyQualityMetricTest(), parse_options(), PowerQualityMetricTest< POWER >::PowerQualityMetricTest(), ScalarAddMetricTest< OFFSET >::ScalarAddMetricTest(), ScalarMultiplyMetricTest< SCALE >::ScalarMultiplyMetricTest(), EdgeLengthMetricTest::test_degenerate_elements(), AspectRatioGammaTest::test_degenerate_elements(), VertexConditionNumberTest::test_degenerate_elements(), ConditionNumberTest::test_degenerate_elements(), CompositeMetricTestBase::test_degenerate_elements(), IdealWeightInverseMeanRatioTest::test_degenerate_elements(), IdealWeightMeanRatioTest::test_degenerate_elements(), UntangleBetaTest::test_degenerate_elements(), ConditionNumberTest::test_domain_deviation(), CompositeMetricTestBase::test_domain_deviation(), IdealWeightInverseMeanRatioTest::test_domain_deviation(), IdealWeightMeanRatioTest::test_domain_deviation(), EdgeLengthMetricTest::test_eval_with_gradient(), CompositeMetricTestBase::test_eval_with_gradient(), IdealWeightInverseMeanRatioTest::test_eval_with_gradient(), IdealWeightMeanRatioTest::test_eval_with_gradient(), CompositeMetricTestBase::test_eval_with_hessian(), IdealWeightInverseMeanRatioTest::test_eval_with_hessian(), IdealWeightMeanRatioTest::test_eval_with_hessian(), IdealWeightInverseMeanRatioTest::test_eval_with_hessian_diagonal(), IdealWeightMeanRatioTest::test_eval_with_hessian_diagonal(), EdgeLengthMetricTest::test_eval_with_indices(), AspectRatioGammaTest::test_eval_with_indices(), VertexConditionNumberTest::test_eval_with_indices(), ConditionNumberTest::test_eval_with_indices(), CompositeMetricTestBase::test_eval_with_indices(), IdealWeightInverseMeanRatioTest::test_eval_with_indices(), IdealWeightMeanRatioTest::test_eval_with_indices(), UntangleBetaTest::test_eval_with_indices(), CompositeMetricTestBase::test_evaluate(), EdgeLengthMetricTest::test_get_edge_indices(), AspectRatioGammaTest::test_get_element_indices(), VertexConditionNumberTest::test_get_element_indices(), ConditionNumberTest::test_get_element_indices(), CompositeMetricTestBase::test_get_element_indices(), IdealWeightInverseMeanRatioTest::test_get_element_indices(), IdealWeightMeanRatioTest::test_get_element_indices(), UntangleBetaTest::test_get_element_indices(), EdgeLengthMetricTest::test_get_evaluations(), AspectRatioGammaTest::test_get_evaluations(), VertexConditionNumberTest::test_get_evaluations(), ConditionNumberTest::test_get_evaluations(), CompositeMetricTestBase::test_get_evaluations(), IdealWeightInverseMeanRatioTest::test_get_evaluations(), IdealWeightMeanRatioTest::test_get_evaluations(), UntangleBetaTest::test_get_evaluations(), EdgeLengthMetricTest::test_get_fixed_indices(), AspectRatioGammaTest::test_get_fixed_indices(), VertexConditionNumberTest::test_get_fixed_indices(), ConditionNumberTest::test_get_fixed_indices(), CompositeMetricTestBase::test_get_fixed_indices(), IdealWeightMeanRatioTest::test_get_fixed_indices(), IdealWeightInverseMeanRatioTest::test_get_fixed_indices(), UntangleBetaTest::test_get_fixed_indices(), EdgeLengthMetricTest::test_get_vertex_indices(), AspectRatioGammaTest::test_gradient_reflects_quality(), VertexConditionNumberTest::test_gradient_reflects_quality(), ConditionNumberTest::test_gradient_reflects_quality(), CompositeMetricTestBase::test_gradient_reflects_quality(), IdealWeightInverseMeanRatioTest::test_gradient_reflects_quality(), IdealWeightMeanRatioTest::test_gradient_reflects_quality(), EdgeLengthMetricTest::test_ideal_element_eval(), VertexConditionNumberTest::test_ideal_element_eval(), AspectRatioGammaTest::test_ideal_element_eval(), UntangleBetaTest::test_ideal_element_eval(), ConditionNumberTest::test_ideal_element_eval(), IdealWeightInverseMeanRatioTest::test_ideal_element_eval(), IdealWeightMeanRatioTest::test_ideal_element_eval(), AspectRatioGammaTest::test_ideal_element_grad(), VertexConditionNumberTest::test_ideal_element_grad(), ConditionNumberTest::test_ideal_element_grad(), CompositeMetricTestBase::test_ideal_element_grad(), IdealWeightInverseMeanRatioTest::test_ideal_element_grad(), IdealWeightMeanRatioTest::test_ideal_element_grad(), ConditionNumberTest::test_ideal_element_hess(), CompositeMetricTestBase::test_ideal_element_hess(), IdealWeightInverseMeanRatioTest::test_ideal_element_hess(), IdealWeightMeanRatioTest::test_ideal_element_hess(), EdgeLengthMetricTest::test_inverted_elements(), UntangleBetaTest::test_inverted_elements(), AspectRatioGammaTest::test_inverted_elements(), VertexConditionNumberTest::test_inverted_elements(), ConditionNumberTest::test_inverted_elements(), CompositeMetricTestBase::test_inverted_elements(), IdealWeightInverseMeanRatioTest::test_inverted_elements(), IdealWeightMeanRatioTest::test_inverted_elements(), EdgeLengthMetricTest::test_location_invariant(), AspectRatioGammaTest::test_location_invariant(), VertexConditionNumberTest::test_location_invariant(), ConditionNumberTest::test_location_invariant(), CompositeMetricTestBase::test_location_invariant(), IdealWeightInverseMeanRatioTest::test_location_invariant(), IdealWeightMeanRatioTest::test_location_invariant(), UntangleBetaTest::test_location_invariant(), BCDTest::test_lp_to_p_hex(), BCDTest::test_lp_to_p_tet(), AspectRatioGammaTest::test_measures_quality(), VertexConditionNumberTest::test_measures_quality(), ConditionNumberTest::test_measures_quality(), CompositeMetricTestBase::test_measures_quality(), IdealWeightInverseMeanRatioTest::test_measures_quality(), IdealWeightMeanRatioTest::test_measures_quality(), EdgeLengthMetricTest::test_orient_invariant(), VertexConditionNumberTest::test_orient_invariant(), AspectRatioGammaTest::test_orient_invariant(), ConditionNumberTest::test_orient_invariant(), CompositeMetricTestBase::test_orient_invariant(), IdealWeightInverseMeanRatioTest::test_orient_invariant(), IdealWeightMeanRatioTest::test_orient_invariant(), UntangleBetaTest::test_orient_invariant(), BCDTest::test_p_mean_p_hex(), BCDTest::test_p_mean_p_tet(), AspectRatioGammaTest::test_scale_invariant(), ConditionNumberTest::test_scale_invariant(), CompositeMetricTestBase::test_scale_invariant(), IdealWeightInverseMeanRatioTest::test_scale_invariant(), IdealWeightMeanRatioTest::test_scale_invariant(), EdgeLengthMetricTest::test_supported_types(), CompositeMetricTestBase::test_supported_types(), VertexConditionNumberTest::test_supported_types(), AspectRatioGammaTest::test_supported_types(), UntangleBetaTest::test_supported_types(), ConditionNumberTest::test_supported_types(), IdealWeightMeanRatioTest::test_supported_types(), IdealWeightInverseMeanRatioTest::test_supported_types(), EdgeLengthMetricTest::test_valid_hessian(), CompositeMetricTestBase::test_valid_hessian(), IdealWeightMeanRatioTest::test_valid_hessian(), and IdealWeightInverseMeanRatioTest::test_valid_hessian().

char mSolver = '\0'

Definition at line 83 of file synchronous_test.cpp.

Referenced by main(), and parse_options().

Examples:
ComputeTriDual.cpp.

Definition at line 84 of file synchronous_test.cpp.

Referenced by main(), and parse_options().

const char* temp_file = "syncrononous_input.vtk"

Definition at line 211 of file synchronous_test.cpp.

const double z = 0.0

Definition at line 52 of file synchronous_test.cpp.

Referenced by MBMesquite::CompareQM::GradStat::add_diff(), moab::MeshGeneration::BrickInstance(), VtkTest::check_8hex_block(), MBMesquite::ParallelHelperImpl::comm_smoothed_vtx_b(), MBMesquite::ParallelHelperImpl::comm_smoothed_vtx_b_no_all(), MBMesquite::ParallelHelperImpl::comm_smoothed_vtx_nb(), MBMesquite::ParallelHelperImpl::comm_smoothed_vtx_nb_no_all(), MBMesquite::ParallelHelperImpl::comm_smoothed_vtx_tnb(), MBMesquite::ParallelHelperImpl::comm_smoothed_vtx_tnb_no_all(), moab::NestedRefine::compute_coordinates(), moab::corners_from_box(), create(), create_input_mesh(), create_regular_mesh(), create_simple_grid(), create_structured_quad_mesh(), moab::ReadIDEAS::create_vertices(), create_vertices_block(), do_test(), element_conn(), moab::EdgeSizeSimpleImplicit::evaluate_edge(), exact_error_torus(), FBiGeom_getVtxArrCoords(), field_2(), field_3(), find_rotation(), moab::NestedRefine::find_shortest_diagonal_octahedron(), find_z10_extreme_elements(), forward_order_query_element_verts(), forward_order_query_elements(), forward_order_query_vertices(), moab::TempestRemapper::GenerateMeshMetadata(), moab::Core::get_coords(), get_planar_example(), moab::FBEngine::getEntTgntU(), hash_getbb_2(), hash_getbb_3(), moab::ElemUtil::hex_eval(), moab::ElemUtil::hex_findpt(), MBMesquite::MeshWriter::Projection::init(), moab::IntxUtils::intersect_great_circle_arc_with_clat_arc(), lagrange_setup(), moab::ReadGmsh::load_file(), moab::ReadSTL::load_file(), lob_bnd_base_setup(), localize_hex_coordinates(), main(), make_mesh(), mb_vertex_coordinate_test(), MBMesquite::MsqCommonIGeom::move_to(), obbvis_create(), OffsetHexCenterNodes::OffsetHexCenterNodes(), MBMesquite::TrustRegion::optimize_vertex_positions(), PartMap::part_from_coords(), physField(), moab::ParallelMergeMesh::PopulateMyTup(), project_exact_torus(), quad_all_in_xy_plane(), ray_test(), read_cube_vertex_pos_test(), moab::ReadTemplate::read_vertices(), moab::ReadVtk::read_vertices(), reverse_order_query_element_verts(), reverse_order_query_elements(), reverse_order_query_vertices(), MBMesquite::MeshWriter::Projection::rotation(), MBMesquite::QualityAssessor::round_to_3_significant_digits(), moab::VertexSequence::set_coordinates(), moab::element_utility::Spectral_hex_map< moab::Matrix3 >::set_gl_points(), moab::Element::SpectralHex::set_gl_points(), moab::Element::SpectralQuad::set_gl_points(), MBMesquite::QuasiNewton::solve(), moab::Element::SpectralHex::SpectralHex(), moab::Element::SpectralQuad::SpectralQuad(), moab::ReadABAQUS::sph2rect(), split_test(), split_test_across(), MBMesquite::surface_to_2d(), MBMesquite::CircleDomainTest::test_arc_length(), GeomPrimTest::test_circle_closest_with_tangent(), test_closest_triangle(), CylinderDomainTest::test_domain_DoF(), TMPQualityMetricTest< QMType >::test_gradient_3D(), TargetCalculatorTest::test_new_orientatin_2D(), TargetCalculatorTest::test_new_orientatin_3D(), GeomPrimTest::test_plane_closest_to_point(), GeomPrimTest::test_plane_distance(), MBMesquite::CircleDomainTest::test_position_from_length(), MBMesquite::CircleDomainTest::test_snap_to(), test_sphere_intersect_triangles(), CylinderDomainTest::test_z_basic(), CylinderDomainTest::test_z_closest_point(), CylinderDomainTest::test_z_normal_at(), CylinderDomainTest::test_z_snap_to(), transform_point(), v_edge_length(), vert_index(), vertex_tag(), volume_test(), moab::ReadVtk::vtk_create_structured_elems(), MBMesquite::MeshImpl::vtk_create_structured_elems(), moab::ReadVtk::vtk_read_rectilinear_grid(), moab::ReadVtk::vtk_read_structured_points(), MBMesquite::MeshImpl::write_exodus(), and MBMesquite::XYRectangle::XYRectangle().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines