MOAB: Mesh Oriented datABase  (version 5.4.1)
quality.cpp
Go to the documentation of this file.
00001 #include "CLArgs.hpp"
00002 #include "QualityAssessor.hpp"
00003 #include "IdealWeightInverseMeanRatio.hpp"
00004 #include "SizeMetric.hpp"
00005 #include "TQualityMetric.hpp"
00006 #include "IdealShapeTarget.hpp"
00007 #include "TShapeNB1.hpp"
00008 #include "InstructionQueue.hpp"
00009 #include "MsqError.hpp"
00010 #include "MeshImpl.hpp"
00011 //#include "QuadLagrangeShape.hpp"
00012 //#include "TetLagrangeShape.hpp"
00013 //#include "TriLagrangeShape.hpp"
00014 #include "ElementMaxQM.hpp"
00015 #include "domain.hpp"
00016 
00017 using namespace MBMesquite;
00018 
00019 #include <vector>
00020 #include <algorithm>
00021 
00022 int main( int argc, char* argv[] )
00023 {
00024     int two;
00025     CLArgs::ToggleArg freeonly;
00026     CLArgs::IntRangeArg histogram( &two );
00027     CLArgs args( "msqquality", "Assess mesh quality",
00028                  "Caculate various quality metrics for a mesh,"
00029                  "and optinally export a VTK file for which quality "
00030                  "values are stored as attribute data." );
00031     args.int_flag( 'H', "ints", "Print histograms with specified number of intervals", &histogram );
00032     args.toggle_flag( 'f', "Assess quality only for elements with at least one free vertex", &freeonly );
00033     args.add_required_arg( "input_file" );
00034     args.add_optional_arg( "output_file" );
00035     add_domain_args( args );
00036     std::vector< std::string > files;
00037     if( !args.parse_options( argc, argv, files, std::cerr ) )
00038     {
00039         args.print_usage( std::cerr );
00040         return 1;
00041     }
00042 
00043     MsqError err;
00044     MeshImpl mesh;
00045     mesh.read_vtk( files.front().c_str(), err );
00046     if( err )
00047     {
00048         std::cerr << err << std::endl << "Failed to read file: " << files.front() << std::endl;
00049         return 2;
00050     }
00051 
00052     MeshDomain* domain = process_domain_args( &mesh );
00053 
00054     QualityAssessor qa( true, freeonly.value(), "INVERTED" );
00055     IdealWeightInverseMeanRatio imr;
00056     SizeMetric size;
00057     IdealShapeTarget tc;
00058     TShapeNB1 tm;
00059     TQualityMetric tmp( &tc, &tm );
00060     ElementMaxQM max_tmp( &tmp );
00061 
00062     int intervals = histogram.seen() ? histogram.value() : 0;
00063     qa.add_quality_assessment( &imr, intervals, 0.0, "InverseMeanRatio" );
00064     qa.add_quality_assessment( &size, intervals, 0.0, "Size" );
00065     qa.add_quality_assessment( &max_tmp, intervals, 0.0, "TMP_Shape" );
00066     qa.tag_fixed_elements( "FIXED_ELEMS" );
00067 
00068     //  QuadLagrangeShape quad;
00069     //  TriLagrangeShape tri;
00070     //  TetLagrangeShape tet;
00071     InstructionQueue q;
00072     //  q.set_mapping_function( &quad );
00073     //  q.set_mapping_function( &tri );
00074     //  q.set_mapping_function( &tet );
00075 
00076     q.add_quality_assessor( &qa, err );
00077     MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, domain );
00078     q.run_instructions( &mesh_and_domain, err );
00079     delete domain;
00080     if( err )
00081     {
00082         std::cerr << err << std::endl;
00083         return 3;
00084     }
00085 
00086     if( files.size() > 1 )
00087     {
00088         mesh.write_vtk( files[1].c_str(), err );
00089         if( err )
00090         {
00091             std::cerr << err << std::endl << "Failed to write file: " << files[1] << std::endl;
00092             return 2;
00093         }
00094     }
00095 
00096     return 0;
00097 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines