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 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:09:51 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 #include <iostream> 00047 using std::cout; 00048 using std::endl; 00049 #include <cstdlib> 00050 00051 #include "Mesquite.hpp" 00052 #include "MeshImpl.hpp" 00053 #include "MsqError.hpp" 00054 #include "Vector3D.hpp" 00055 #include "InstructionQueue.hpp" 00056 #include "PatchData.hpp" 00057 #include "TerminationCriterion.hpp" 00058 #include "QualityAssessor.hpp" 00059 00060 // algorythms 00061 #include "IdealWeightInverseMeanRatio.hpp" 00062 #include "ConditionNumberQualityMetric.hpp" 00063 #include "LPtoPTemplate.hpp" 00064 #include "LInfTemplate.hpp" 00065 #include "FeasibleNewton.hpp" 00066 #include "ConjugateGradient.hpp" 00067 #include "TestUtil.hpp" 00068 using namespace MBMesquite; 00069 00070 int main() 00071 { 00072 MsqPrintError err( cout ); 00073 MBMesquite::MeshImpl mesh; 00074 00075 std::string file_name = TestDir + "unittest/mesquite/3D/vtk/tets/untangled/tire.vtk"; 00076 mesh.read_vtk( file_name.c_str(), err ); 00077 if( err ) return 1; 00078 00079 // creates an intruction queue 00080 InstructionQueue queue1; 00081 00082 // creates a mean ratio quality metric ... 00083 IdealWeightInverseMeanRatio mean( err ); 00084 if( err ) return 1; 00085 00086 LPtoPTemplate obj_func( &mean, 1, err ); 00087 if( err ) return 1; 00088 00089 // creates the optimization procedures 00090 // ConjugateGradient* pass1 = new ConjugateGradient( obj_func, err ); 00091 FeasibleNewton pass1( &obj_func ); 00092 00093 // perform optimization globally 00094 pass1.use_global_patch(); 00095 if( err ) return 1; 00096 00097 QualityAssessor mean_qa = QualityAssessor( &mean ); 00098 00099 //**************Set termination criterion**************** 00100 00101 // perform 1 pass of the outer loop (this line isn't essential as it is 00102 // the default behavior). 00103 TerminationCriterion tc_outer; 00104 tc_outer.add_iteration_limit( 1 ); 00105 pass1.set_outer_termination_criterion( &tc_outer ); 00106 00107 // perform the inner loop until a certain objective function value is 00108 // reached. The exact value needs to be determined (about 18095). 00109 // As a safety, also stop if the time exceeds 10 minutes (600 seconds). 00110 TerminationCriterion tc_inner; 00111 tc_inner.add_absolute_quality_improvement( 13975 ); 00112 // tc_inner.add_absolute_quality_improvement( 13964.93818 ); 00113 tc_inner.add_cpu_time( 1800 ); 00114 00115 pass1.set_inner_termination_criterion( &tc_inner ); 00116 00117 // used for cg to get some info 00118 // pass1->set_debugging_level(2); 00119 00120 // adds 1 pass of pass1 to mesh_set1 00121 queue1.add_quality_assessor( &mean_qa, err ); 00122 if( err ) return 1; 00123 queue1.set_master_quality_improver( &pass1, err ); 00124 if( err ) return 1; 00125 queue1.add_quality_assessor( &mean_qa, err ); 00126 if( err ) return 1; 00127 mesh.write_vtk( "original_mesh.vtk", err ); 00128 if( err ) return 1; 00129 00130 // launches optimization on mesh_set1 00131 queue1.run_instructions( &mesh, err ); 00132 if( err ) return 1; 00133 00134 mesh.write_vtk( "smoothed_mesh.vtk", err ); 00135 if( err ) return 1; 00136 print_timing_diagnostics( cout ); 00137 return 0; 00138 }