MOAB: Mesh Oriented datABase
(version 5.4.1)
|
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 [email protected], [email protected], [email protected], 00024 [email protected], [email protected], [email protected] 00025 00026 ***************************************************************** */ 00027 // -*- Mode : c++; tab-width: 2; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 2 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:04:37 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 <iostream> 00048 using std::cout; 00049 using std::endl; 00050 #include <cstdlib> 00051 00052 #include "TestUtil.hpp" 00053 #include "Mesquite.hpp" 00054 #include "MsqError.hpp" 00055 #include "MeshImpl.hpp" 00056 #include "Vector3D.hpp" 00057 #include "InstructionQueue.hpp" 00058 #include "PatchData.hpp" 00059 #include "TerminationCriterion.hpp" 00060 #include "QualityAssessor.hpp" 00061 #include "PlanarDomain.hpp" 00062 #include "MsqTimer.hpp" 00063 00064 // algorythms 00065 #include "ConditionNumberQualityMetric.hpp" 00066 #include "LInfTemplate.hpp" 00067 #include "SteepestDescent.hpp" 00068 #include "LaplacianSmoother.hpp" 00069 #include "EdgeLengthQualityMetric.hpp" 00070 using namespace MBMesquite; 00071 00072 std::string DEFAULT_INPUT = TestDir + "unittest/mesquite/2D/vtk/N-Polygonal/poly1.vtk"; 00073 00074 void help( const char* argv0 ) 00075 { 00076 std::cerr << "Usage: " << argv0 << " [<input_file>] [<output_file>]" << std::endl 00077 << " default input file is: " << DEFAULT_INPUT << std::endl 00078 << " defualt is no output file" << std::endl; 00079 exit( 1 ); 00080 } 00081 00082 int main( int argc, char* argv[] ) 00083 { 00084 const char* input_file = DEFAULT_INPUT.c_str(); 00085 const char* output_file = NULL; 00086 switch( argc ) 00087 { 00088 default: 00089 help( argv[0] ); 00090 case 3: 00091 if( !strcmp( argv[2], "-h" ) ) help( argv[0] ); 00092 output_file = argv[2]; 00093 case 2: 00094 if( !strcmp( argv[1], "-h" ) ) help( argv[0] ); 00095 input_file = argv[1]; 00096 case 1:; 00097 } 00098 00099 /* Read a VTK Mesh file */ 00100 MsqPrintError err( cout ); 00101 MBMesquite::MeshImpl mesh; 00102 mesh.read_vtk( input_file, err ); 00103 if( err ) return 1; 00104 00105 // creates an intruction queue 00106 InstructionQueue queue1; 00107 00108 // creates a mean ratio quality metric ... 00109 ConditionNumberQualityMetric shape_metric; 00110 EdgeLengthQualityMetric lapl_met; 00111 lapl_met.set_averaging_method( QualityMetric::RMS ); 00112 00113 // creates the laplacian smoother procedures 00114 LaplacianSmoother lapl1; 00115 QualityAssessor stop_qa = QualityAssessor( &shape_metric ); 00116 stop_qa.add_quality_assessment( &lapl_met ); 00117 00118 //**************Set stopping criterion**************** 00119 TerminationCriterion sc2; 00120 sc2.add_iteration_limit( 10 ); 00121 if( err ) return 1; 00122 lapl1.set_outer_termination_criterion( &sc2 ); 00123 00124 // adds 1 pass of pass1 to mesh_set1 00125 // queue1.add_quality_assessor(&stop_qa,err); 00126 if( err ) return 1; 00127 queue1.set_master_quality_improver( &lapl1, err ); 00128 if( err ) return 1; 00129 // queue1.add_quality_assessor(&stop_qa,err); 00130 if( err ) return 1; 00131 00132 PlanarDomain plane( Vector3D( 0, 0, 1 ), Vector3D( 0, 0, 0 ) ); 00133 00134 // launches optimization on mesh_set1 00135 MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &plane ); 00136 Timer t; 00137 queue1.run_instructions( &mesh_and_domain, err ); 00138 if( err ) return 1; 00139 double secs = t.since_birth(); 00140 std::cout << "Optimization completed in " << secs << " seconds" << std::endl; 00141 00142 if( output_file ) 00143 { 00144 mesh.write_vtk( output_file, err ); 00145 if( err ) return 1; 00146 std::cout << "Wrote file: " << output_file << std::endl; 00147 } 00148 00149 return 0; 00150 }