MOAB: Mesh Oriented datABase  (version 5.2.1)
2d_formulation_test.cpp File Reference
#include "TestUtil.hpp"
#include "Mesquite.hpp"
#include "PMeanPTemplate.hpp"
#include "AffineMapMetric.hpp"
#include "ConjugateGradient.hpp"
#include "TerminationCriterion.hpp"
#include "ElementPMeanP.hpp"
#include "MsqError.hpp"
#include "TSquared.hpp"
#include "MeshImpl.hpp"
#include "PlanarDomain.hpp"
#include "InstructionQueue.hpp"
#include "TargetCalculator.hpp"
#include "MetricWeight.hpp"
#include "InverseMetricWeight.hpp"
#include "TargetWriter.hpp"
#include "WeightReader.hpp"
#include <iostream>
#include <stdlib.h>
+ Include dependency graph for 2d_formulation_test.cpp:

Go to the source code of this file.

Classes

class  IdentityTarget

Defines

#define USE_GLOBAL_PATCH
#define CHKERR(A)

Enumerations

enum  Grouping { SAMPLE, ELEMENT, QUADRANT, HALF }
enum  Weight { UNIT, METRIC, INV_METRIC }

Functions

void run_test (Grouping grouping, int of_power, Weight w, const string filename)
int main ()

Variables

const double epsilon = 2e-2
const bool write_results = true

Define Documentation

#define CHKERR (   A)
Value:
if( A )                    \
    {                          \
        cerr << ( A ) << endl; \
        exit( 1 );             \
    }

Definition at line 63 of file 2d_formulation_test.cpp.

Referenced by run_test().

Definition at line 33 of file 2d_formulation_test.cpp.


Enumeration Type Documentation

enum Grouping
Enumerator:
SAMPLE 
ELEMENT 
QUADRANT 
HALF 

Definition at line 70 of file 2d_formulation_test.cpp.

enum Weight
Enumerator:
UNIT 
METRIC 
INV_METRIC 

Definition at line 77 of file 2d_formulation_test.cpp.


Function Documentation

int main ( )

Definition at line 195 of file 2d_formulation_test.cpp.

References ELEMENT, INV_METRIC, METRIC, run_test(), SAMPLE, and UNIT.

{
    run_test( SAMPLE, 1, UNIT, "1-1" );
    run_test( SAMPLE, 2, UNIT, "1-2" );
    run_test( SAMPLE, 4, UNIT, "1-4" );
    run_test( SAMPLE, 8, UNIT, "1-8" );

    run_test( SAMPLE, 1, UNIT, "2-NW" );
    run_test( ELEMENT, 1, UNIT, "2-NE" );

    run_test( SAMPLE, 1, UNIT, "3-Left" );
    run_test( SAMPLE, 1, METRIC, "3-Mid" );
    run_test( SAMPLE, 1, INV_METRIC, "3-Right" );
}
void run_test ( Grouping  grouping,
int  of_power,
Weight  w,
const string  filename 
)

Definition at line 111 of file 2d_formulation_test.cpp.

References MBMesquite::TerminationCriterion::add_absolute_vertex_movement(), MBMesquite::TerminationCriterion::add_iteration_limit(), MBMesquite::InstructionQueue::add_target_calculator(), CHKERR, ELEMENT, INV_METRIC, mesh, METRIC, MBMesquite::MeshImpl::read_vtk(), MBMesquite::IQInterface::run_instructions(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::QualityImprover::set_outer_termination_criterion(), MBMesquite::AffineMapMetric::set_weight_calculator(), STRINGIFY, MBMesquite::PatchSetUser::use_element_on_vertex_patch(), MBMesquite::PatchSetUser::use_global_patch(), write_results, MBMesquite::MeshImpl::write_vtk(), and MBMesquite::PlanarDomain::XY.

{
    MsqError err;

    IdentityTarget target;
    TSquared target_metric;
    AffineMapMetric qual_metric( &target, &target_metric );
    ElementPMeanP elem_metric( of_power, &qual_metric );
    QualityMetric* qm_ptr = ( grouping == ELEMENT ) ? (QualityMetric*)&elem_metric : (QualityMetric*)&qual_metric;

    PMeanPTemplate OF( of_power, qm_ptr );
    ConjugateGradient solver( &OF );
    TerminationCriterion tc;
    TerminationCriterion itc;
    tc.add_absolute_vertex_movement( 1e-4 );
    itc.add_iteration_limit( 2 );
#ifdef USE_GLOBAL_PATCH
    solver.use_global_patch();
    solver.set_inner_termination_criterion( &tc );
#else
    solver.use_element_on_vertex_patch();
    solver.set_inner_termination_criterion( &itc );
    solver.set_outer_termination_criterion( &tc );
#endif

    MeshImpl mesh, expected_mesh;
    std::string initfname = std::string( STRINGIFY( SRCDIR ) ) + "/2d_formulation_initial.vtk";
    mesh.read_vtk( initfname.c_str(), err );CHKERR( err )
    //  expected_mesh.read_vtk( (filename + ".vtk").c_str(), err ); CHKERR(err)

    PlanarDomain plane( PlanarDomain::XY );

    MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &plane );

    MetricWeight mw( &qual_metric );
    InverseMetricWeight imw( &qual_metric );
    WeightReader reader;
    if( w == METRIC )
    {
        TargetWriter writer( 0, &mw );
        InstructionQueue tq;
        tq.add_target_calculator( &writer, err );
        tq.run_instructions( &mesh_and_domain, err );CHKERR( err );
        qual_metric.set_weight_calculator( &reader );
    }
    else if( w == INV_METRIC )
    {
        TargetWriter writer( 0, &imw );
        InstructionQueue tq;
        tq.add_target_calculator( &writer, err );
        tq.run_instructions( &mesh_and_domain, err );CHKERR( err );
        qual_metric.set_weight_calculator( &reader );
    }

    InstructionQueue q;
    q.set_master_quality_improver( &solver, err );
    q.run_instructions( &mesh_and_domain, err );CHKERR( err )
    /*
      vector<Mesh::VertexHandle> vemain.cpprts;
      vector<MsqVertex> mesh_coords, expected_coords;
      mesh.get_all_vertices( verts, err ); CHKERR(err)
      mesh_coords.resize(verts.size());
      mesh.vertices_get_coordinates( arrptr(verts), arrptr(mesh_coords), verts.size(), err
      );CHKERR(err) expected_mesh.get_all_vertices( verts, err ); CHKERR(err)
      expected_coords.resize(verts.size());
      expected_mesh.vertices_get_coordinates( arrptr(verts), arrptr(expected_coords), verts.size(),
      err ); CHKERR(err) if (expected_coords.size() != mesh_coords.size()) { cerr << "Invlid
      expected mesh.  Vertex count doesn't match" << endl; exit(1);
      }

      unsigned error_count = 0;
      for (size_t i = 0; i < mesh_coords.size(); ++i)
        if ((expected_coords[i] - mesh_coords[i]).length_squared() > epsilon*epsilon)
          ++error_count;

      if (!error_count)
        cout << filename << " : SUCCESS" << endl;
      else
        cout << filename << " : FAILURE (" << error_count
             << " vertices differ by more than " << epsilon << ")" << endl;
    */
    if( write_results ) mesh.write_vtk( ( filename + ".results.vtk" ).c_str(), err );CHKERR( err )
}

Variable Documentation

const double epsilon = 2e-2

Definition at line 60 of file 2d_formulation_test.cpp.

Referenced by moab::GeomUtil::box_hex_overlap(), moab::GeomUtil::box_linear_elem_overlap(), moab::GeomUtil::box_tet_overlap_edge(), moab::HiReconstruction::compute_weights(), moab::BSPTreePoly::cut_polyhedron(), MBMesquite::do_finite_difference(), MBMesquite::do_numerical_hessian(), CompareMetric::equal(), MBMesquite::BoundedCylinderDomain::evaluate(), MBMesquite::CylinderDomain::evaluate(), CompareMetric::evaluate(), moab::LinearTet::evaluate_reverse(), moab::LinearTri::evaluate_reverse(), moab::EvalSet::evaluate_reverse(), CompareMetric::evaluate_with_gradient(), CompareMetric::evaluate_with_Hessian(), CompareMetric::evaluate_with_Hessian_diagonal(), CompareMetric::evaluate_with_indices(), MBMesquite::SphericalDomain::fit_vertices(), MBMesquite::PlanarDomain::fit_vertices(), MBMesquite::geom_classify_elements(), MBMesquite::geom_classify_vertices(), CompareMetric::get_mask_axis(), moab::Element::Map::ievaluate(), MBMesquite::MsqLine::intersect(), limit_absolute_quality(), limit_absolute_sucessive(), main(), moab::Util::normal(), moab::LinearHex::normalFcn(), moab::LinearQuad::normalFcn(), moab::LinearTet::normalFcn(), moab::LinearTri::normalFcn(), MBMesquite::QuasiNewton::optimize_vertex_positions(), MBMesquite::FeasibleNewton::optimize_vertex_positions(), overlap_test_measure_area(), overlap_test_measure_volume(), moab::GeomUtil::plucker_edge_test(), quad_all_in_xy_plane(), quad_mid_edge_nodes_edge_center(), moab::GeomUtil::ray_box_intersect(), moab::ray_intersect_halfspaces(), moab::AffineXform::rotation(), moab::AffineXform::scale(), moab::BSPTree::set_split_plane(), MBMesquite::XYRectangle::setup(), moab::BSPTreeBoxIter::side_on_plane(), moab::ElemUtil::VolMap::solve_inverse(), moab::GeomUtil::VolMap::solve_inverse(), PlanarGeometryTest::test_fit_plane(), test_measure_area(), test_measure_volume(), test_real_arg(), test_real_opt(), test_value(), tet_mid_edge_nodes_edge_center(), tri_mid_edge_nodes_edge_center(), v_tet_minimum_angle(), and TreeValidator::visit().

const bool write_results = true

Definition at line 61 of file 2d_formulation_test.cpp.

Referenced by run_test().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines