MOAB: Mesh Oriented datABase  (version 5.2.1)
simple_hybrid_test.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2004 Sandia Corporation and Argonne National
00005     Laboratory.  Under the terms of Contract DE-AC04-94AL85000
00006     with Sandia Corporation, the U.S. Government retains certain
00007     rights in this software.
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     (lgpl.txt) along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov,
00024     pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov
00025 
00026   ***************************************************************** */
00027 // -*- Mode : c++; tab-width: 3; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 3
00028 // -*-
00029 //
00030 //   SUMMARY:
00031 //     USAGE:
00032 //
00033 // ORIG-DATE: 19-Feb-02 at 10:57:52
00034 //  LAST-MOD: 23-Jul-03 at 18:11:05 by Thomas Leurent
00035 //
00036 //
00037 // DESCRIPTION:
00038 // ============
00039 /*! \file main.cpp
00040 
00041 describe main.cpp here
00042 
00043  */
00044 // DESCRIP-END.
00045 //
00046 
00047 #include "TestUtil.hpp"
00048 #include "Mesquite.hpp"
00049 #include "MeshImpl.hpp"
00050 #include "PlanarDomain.hpp"
00051 #include "InstructionQueue.hpp"
00052 #include "TerminationCriterion.hpp"
00053 #include "QualityAssessor.hpp"
00054 #include "MsqError.hpp"
00055 #include "ShapeImprovementWrapper.hpp"
00056 // algorythms
00057 #include "IdealWeightInverseMeanRatio.hpp"
00058 #include "EdgeLengthQualityMetric.hpp"
00059 #include "LPtoPTemplate.hpp"
00060 #include "SteepestDescent.hpp"
00061 #include "ConjugateGradient.hpp"
00062 
00063 #include <iostream>
00064 using std::cout;
00065 using std::endl;
00066 #include <cstdlib>
00067 
00068 using namespace MBMesquite;
00069 
00070 int main()
00071 {
00072     MBMesquite::MeshImpl mesh;
00073     MsqPrintError err( cout );
00074     // create geometry: plane z=0, normal (0,0,1)
00075     Vector3D pnt( 0, 0, 0 );
00076     Vector3D s_norm( 0, 0, 1 );
00077     MBMesquite::PlanarDomain msq_geom( s_norm, pnt );
00078 
00079     std::string default_file_name = TestDir + "/2D/vtk/mixed/untangled/hybrid_3quad_1tri.vtk";
00080     mesh.read_vtk( default_file_name.c_str(), err );
00081     if( err ) return 1;
00082 
00083     // creates an intruction queue
00084     InstructionQueue queue1;
00085 
00086     // creates a mean ratio quality metric ...
00087     IdealWeightInverseMeanRatio mean_ratio( err );
00088     if( err ) return 1;
00089     //   mean_ratio->set_gradient_type(QualityMetric::NUMERICAL_GRADIENT);
00090     //   mean_ratio->set_hessian_type(QualityMetric::NUMERICAL_HESSIAN);
00091     // mean_ratio->set_averaging_method(QualityMetric::SUM, err);
00092     // MSQ_CHKERR(err);
00093 
00094     // ... and builds an objective function with it
00095     LPtoPTemplate obj_func( &mean_ratio, 2, err );
00096     if( err ) return 1;
00097     ;
00098 
00099     // creates the steepest descent, feas newt optimization procedures
00100     // ConjugateGradient* pass1 = new ConjugateGradient( &obj_func, err );
00101     SteepestDescent pass1( &obj_func );
00102     pass1.use_global_patch();
00103     if( err ) return 1;
00104     ;
00105 
00106     QualityAssessor qa = QualityAssessor( &mean_ratio );
00107     if( err ) return 1;
00108     ;
00109 
00110     // **************Set termination criterion****************
00111     TerminationCriterion tc_inner;
00112     tc_inner.add_iteration_limit( 1 );
00113     //_inner.add_absolute_quality_improvement( OF_value );
00114     // tc_inner.add_absolute_gradient_L2_norm( OF_value );
00115     TerminationCriterion tc_outer;
00116     // tc_outer.add_iteration_limit( 1 );
00117     tc_outer.add_iteration_limit( 1 );
00118 
00119     pass1.set_inner_termination_criterion( &tc_inner );
00120     pass1.set_outer_termination_criterion( &tc_outer );
00121 
00122     queue1.add_quality_assessor( &qa, err );
00123     if( err ) return 1;
00124     // adds 1 pass of pass1 to mesh_set1
00125     queue1.set_master_quality_improver( &pass1, err );
00126     if( err ) return 1;
00127     queue1.add_quality_assessor( &qa, err );
00128     if( err ) return 1;
00129     mesh.write_vtk( "original_mesh.vtk", err );
00130     if( err ) return 1;
00131 
00132     MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &msq_geom );
00133     queue1.run_instructions( &mesh_and_domain, err );
00134     if( err ) return 1;
00135     mesh.write_vtk( "smoothed_mesh.vtk", err );
00136     if( err ) return 1;
00137     // std::cout<<"\n\nNow running the shape wrapper.\n=n";
00138     // ShapeImprovementWrapper wrap(100);
00139     // wrap.run_instructions(mesh_set1, err); MSQ_CHKERR(err);
00140     print_timing_diagnostics( cout );
00141     return 0;
00142 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines