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: 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:10:35 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 "Mesquite.hpp" 00053 #include "MeshImpl.hpp" 00054 #include "MsqError.hpp" 00055 #include "Vector3D.hpp" 00056 #include "InstructionQueue.hpp" 00057 #include "PatchData.hpp" 00058 #include "TerminationCriterion.hpp" 00059 #include "QualityAssessor.hpp" 00060 00061 // algorithms 00062 #include "ConditionNumberQualityMetric.hpp" 00063 #include "NonSmoothDescent.hpp" 00064 00065 #include "MeshImpl.hpp" 00066 #include "TestUtil.hpp" 00067 using namespace MBMesquite; 00068 00069 int main() 00070 { 00071 /* Reads a Mesh file */ 00072 std::string file_name = TestDir + 00073 // "unittest/mesquite/2D/vtk/tris/untangled/equil_tri2.vtk"; 00074 // "unittest/mesquite/2D/vtk/tris/untangled/tri_20258.vtk"; 00075 // "unittest/mesquite/3D/vtk/tets/untangled/tet_1.vtk"; 00076 // "unittest/mesquite/3D/vtk/hexes/untangled/cube_tet_2.vtk"; 00077 "unittest/mesquite/3D/vtk/tets/untangled/tire.vtk"; 00078 printf( "Loading mesh set 1\n" ); 00079 MsqPrintError err( cout ); 00080 MBMesquite::MeshImpl mesh; 00081 mesh.read_vtk( file_name.c_str(), err ); 00082 if( err ) return 1; 00083 00084 // Creates an intruction queue 00085 // printf("Creating instruction queue\n"); 00086 InstructionQueue queue1; 00087 00088 // Creates a condition number quality metric 00089 // printf("Creating quality metric\n"); 00090 ConditionNumberQualityMetric cond_no; 00091 00092 // Create the NonSmooth Steepest Descent procedures 00093 // printf("creating optimizer\n"); 00094 NonSmoothDescent minmax_method( &cond_no ); 00095 00096 // Set a termination criterion 00097 TerminationCriterion tc2; 00098 tc2.add_iteration_limit( 1 ); 00099 minmax_method.set_outer_termination_criterion( &tc2 ); 00100 // Set up the quality assessor 00101 // printf("Setting up the quality assessor\n"); 00102 QualityAssessor quality_assessor = QualityAssessor( &cond_no ); 00103 00104 // assess the quality of the initial mesh 00105 queue1.add_quality_assessor( &quality_assessor, err ); 00106 if( err ) return 1; 00107 00108 // Set the max min method to be the master quality improver 00109 queue1.set_master_quality_improver( &minmax_method, err ); 00110 if( err ) return 1; 00111 00112 // assess the quality of the final mesh 00113 queue1.add_quality_assessor( &quality_assessor, err ); 00114 if( err ) return 1; 00115 00116 // write out the original mesh 00117 // printf("Writing out the original mesh\n"); 00118 mesh.write_vtk( "original_mesh.vtk", err ); 00119 if( err ) return 1; 00120 00121 // launches optimization on mesh_set1 00122 // printf("Running the instruction queue\n"); 00123 queue1.run_instructions( &mesh, err ); 00124 if( err ) return 1; 00125 00126 // write out the smoothed mesh 00127 // printf("Writing out the final mesh\n"); 00128 mesh.write_vtk( "smoothed_mesh.vtk", err ); 00129 if( err ) return 1; 00130 00131 return 0; 00132 }