MOAB: Mesh Oriented datABase  (version 5.2.1)
VertexCullingRegressionTest.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: 2; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 2
00028 // -*-
00029 //
00030 //   SUMMARY:
00031 //     USAGE:
00032 //
00033 //    AUTHOR: Michael Brewer
00034 //       ORG: Sandia National Labs
00035 //    E-MAIL: mbrewer@sandia.gov
00036 //
00037 // ORIG-DATE: May 8, 2003
00038 //  LAST-MOD: 23-Jul-03 at 17:44:57 by Thomas Leurent
00039 //
00040 // DESCRIPTION:
00041 // ============
00042 /*! \file VertexCullingRegressionTest.cpp
00043 
00044 Regression testing using the vertex culling algorithms.
00045  */
00046 // DESCRIP-END.
00047 //
00048 
00049 #include "meshfiles.h"
00050 
00051 #include "PatchDataInstances.hpp"
00052 #include "cppunit/extensions/HelperMacros.h"
00053 #include <math.h>
00054 
00055 #include "Mesquite.hpp"
00056 #include "MsqError.hpp"
00057 #include "Vector3D.hpp"
00058 #include "InstructionQueue.hpp"
00059 #include "PatchData.hpp"
00060 #include "QualityAssessor.hpp"
00061 
00062 #include "EdgeLengthQualityMetric.hpp"
00063 #include "ConditionNumberQualityMetric.hpp"
00064 #include "LaplacianSmoother.hpp"
00065 #include "PlanarDomain.hpp"
00066 #include "TerminationCriterion.hpp"
00067 #include "MeshImpl.hpp"
00068 
00069 #include "IdealWeightInverseMeanRatio.hpp"
00070 #include "LPtoPTemplate.hpp"
00071 
00072 #include <iostream>
00073 using std::cout;
00074 using std::endl;
00075 using namespace MBMesquite;
00076 
00077 class VertexCullingRegressionTest : public CppUnit::TestFixture
00078 {
00079   private:
00080     CPPUNIT_TEST_SUITE( VertexCullingRegressionTest );
00081     CPPUNIT_TEST( test_laplacian_smoothing_with_cull );
00082     CPPUNIT_TEST_SUITE_END();
00083 
00084   private:
00085     int pF;  // PRINT_FLAG
00086   public:
00087     void setUp()
00088     {
00089         // pF=1;//PRINT_FLAG IS ON
00090         pF = 0;  // PRINT_FLAG IS OFF
00091     }
00092 
00093     void tearDown() {}
00094 
00095   public:
00096     VertexCullingRegressionTest() {}
00097 
00098     void test_laplacian_smoothing_with_cull()
00099     {
00100         /* Read a VTK Mesh file */
00101         MsqPrintError err( cout );
00102         MBMesquite::MeshImpl mesh;
00103         mesh.read_vtk( MESH_FILES_DIR "2D/vtk/quads/untangled/square_quad_10_rand.vtk", err );
00104         CPPUNIT_ASSERT( !err );
00105 
00106         Vector3D pnt( 0, 0, 5 );
00107         Vector3D s_norm( 0, 0, 1 );
00108         MBMesquite::PlanarDomain msq_geom( s_norm, pnt );
00109 
00110         // create an objective function for use in termination criteria
00111         IdealWeightInverseMeanRatio metric;
00112         LPtoPTemplate of( 2, &metric );
00113 
00114         // creates an intruction queue
00115         InstructionQueue queue1;
00116 
00117         // creates a mean ratio quality metric ...
00118         ConditionNumberQualityMetric shape_metric;
00119         EdgeLengthQualityMetric lapl_met;
00120         lapl_met.set_averaging_method( QualityMetric::RMS );
00121 
00122         // creates the laplacian smoother  procedures
00123         LaplacianSmoother lapl1( &of );
00124         LaplacianSmoother lapl2( &of );
00125         QualityAssessor stop_qa = QualityAssessor( &shape_metric );
00126         stop_qa.add_quality_assessment( &lapl_met );
00127 
00128         //**************Set termination criterion****************
00129         TerminationCriterion sc2;
00130         sc2.add_iteration_limit( 1000 );
00131         sc2.add_absolute_successive_improvement( 0.0 );
00132         // set a criterion with a culling method for the inner criterion
00133         TerminationCriterion sc_cull;
00134         sc_cull.cull_on_absolute_vertex_movement( 0.1 );
00135         CPPUNIT_ASSERT( !err );
00136         TerminationCriterion sc_cull_2;
00137         sc_cull_2.cull_on_absolute_vertex_movement( 0.000001 );
00138         CPPUNIT_ASSERT( !err );
00139         // Make sure no errors
00140         CPPUNIT_ASSERT( !err );
00141         lapl1.set_outer_termination_criterion( &sc2 );
00142         lapl2.set_outer_termination_criterion( &sc2 );
00143         lapl1.set_inner_termination_criterion( &sc_cull );
00144         lapl2.set_inner_termination_criterion( &sc_cull_2 );
00145         // adds 1 pass of pass1 to mesh_set1
00146         queue1.add_quality_assessor( &stop_qa, err );
00147         // Make sure no errors
00148         CPPUNIT_ASSERT( !err );
00149         queue1.add_preconditioner( &lapl1, err );
00150         // Make sure no errors
00151         CPPUNIT_ASSERT( !err );
00152         queue1.set_master_quality_improver( &lapl2, err );
00153         // Make sure no errors
00154         CPPUNIT_ASSERT( !err );
00155         queue1.add_quality_assessor( &stop_qa, err );
00156         // Make sure no errors
00157         CPPUNIT_ASSERT( !err );
00158         MeshDomainAssoc mesh_and_domain = MeshDomainAssoc( &mesh, &msq_geom );
00159         queue1.run_instructions( &mesh_and_domain, err );
00160         CPPUNIT_ASSERT( !err );
00161     }
00162 };
00163 
00164 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VertexCullingRegressionTest, "VertexCullingRegressionTest" );
00165 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( VertexCullingRegressionTest, "Regression" );
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines