MOAB: Mesh Oriented datABase  (version 5.2.1)
analytical_grad3D_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:09:13 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 #include <cstdlib>
00049 
00050 #include "Mesquite.hpp"
00051 #include "MeshImpl.hpp"
00052 #include "MsqError.hpp"
00053 #include "Vector3D.hpp"
00054 #include "InstructionQueue.hpp"
00055 #include "PatchData.hpp"
00056 #include "TerminationCriterion.hpp"
00057 #include "QualityAssessor.hpp"
00058 
00059 // algorithms
00060 #include "IdealWeightInverseMeanRatio.hpp"
00061 #include "ConditionNumberQualityMetric.hpp"
00062 #include "LPtoPTemplate.hpp"
00063 #include "LInfTemplate.hpp"
00064 #include "SteepestDescent.hpp"
00065 #include "TestUtil.hpp"
00066 
00067 using namespace MBMesquite;
00068 
00069 int main()
00070 {
00071     MsqPrintError err( std::cout );
00072     MBMesquite::MeshImpl mesh;
00073 
00074     std::string file_name = TestDir + "/3D/vtk/hexes/untangled/hexes_4by2by2.vtk";
00075     mesh.read_vtk( file_name.c_str(), err );
00076 
00077     // creates an intruction queue
00078     InstructionQueue queue1;
00079 
00080     // creates a mean ratio quality metric ...
00081     IdealWeightInverseMeanRatio mean_ratio( err );
00082     if( err ) return 1;
00083     ConditionNumberQualityMetric cond_num;
00084     mean_ratio.set_averaging_method( QualityMetric::LINEAR );
00085 
00086     // ... and builds an objective function with it
00087     // LInfTemplate* obj_func = new LInfTemplate(mean_ratio);
00088     LPtoPTemplate obj_func( &mean_ratio, 2, err );
00089     if( err ) return 1;
00090     // creates the steepest descent optimization procedures
00091     SteepestDescent pass1( &obj_func );
00092     pass1.use_global_patch();
00093     // if (err) return 1;
00094     // pass1.set_maximum_iteration(6);
00095 
00096     QualityAssessor stop_qa = QualityAssessor( &mean_ratio );
00097     if( err ) return 1;
00098     stop_qa.add_quality_assessment( &cond_num );
00099     if( err ) return 1;
00100 
00101     //**************Set stopping criterion****************
00102     // StoppingCriterion sc1(&stop_qa,1.0,1.8);
00103     // StoppingCriterion sc2(StoppingCriterion::NUMBER_OF_PASSES,1);
00104     TerminationCriterion tc2;
00105     tc2.add_iteration_limit( 1 );
00106     // CompositeAndStoppingCriterion sc(&sc1,&sc2);
00107     pass1.set_inner_termination_criterion( &tc2 );
00108 
00109     // adds 1 pass of pass1 to mesh_set1
00110     //  queue1.add_preconditioner(pass1, err);
00111     //  if (err) return 1;
00112     queue1.add_quality_assessor( &stop_qa, err );
00113     queue1.set_master_quality_improver( &pass1, err );
00114     if( err ) return 1;
00115     queue1.add_quality_assessor( &stop_qa, err );
00116     if( err ) return 1;
00117     // adds 1 passes of pass2 to mesh_set1
00118     //  mesh_set1.add_quality_pass(pass2);
00119 
00120     mesh.write_vtk( "original_mesh.vtk", err );
00121     if( err ) return 1;
00122 
00123     // launches optimization on mesh_set1
00124     queue1.run_instructions( &mesh, err );
00125     if( err ) return 1;
00126 
00127     mesh.write_vtk( "smoothed_mesh.vtk", err );
00128     if( err ) return 1;
00129 
00130     return 0;
00131 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines