MOAB: Mesh Oriented datABase  (version 5.4.1)
LaplaceWrapper.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2010 Sandia National Laboratories.  Developed at the
00005     University of Wisconsin--Madison under SNL contract number
00006     624796.  The U.S. Government and the University of Wisconsin
00007     retain certain rights to 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     (2010) [email protected]
00024 
00025   ***************************************************************** */
00026 
00027 /** \file LaplaceWrapper.cpp
00028  *  \brief Implement LaplaceWrapper class
00029  *  \author Jason Kraftcheck
00030  */
00031 
00032 #include "LaplaceWrapper.hpp"
00033 #include "IdealWeightInverseMeanRatio.hpp"
00034 #include "LaplacianSmoother.hpp"
00035 #include "QualityAssessor.hpp"
00036 #include "InstructionQueue.hpp"
00037 #include "TerminationCriterion.hpp"
00038 #include "MsqError.hpp"
00039 
00040 namespace MBMesquite
00041 {
00042 
00043 const double DEFAULT_MOVEMENT_FACTOR = 0.001;
00044 const bool CULLING_DEFAULT           = true;
00045 const int DEFAULT_ITERATION_LIMIT    = 100;
00046 
00047 LaplaceWrapper::LaplaceWrapper()
00048     : maxTime( -1.0 ), movementFactor( DEFAULT_MOVEMENT_FACTOR ), iterationLimit( DEFAULT_ITERATION_LIMIT ),
00049       doCulling( CULLING_DEFAULT )
00050 {
00051 }
00052 
00053 LaplaceWrapper::~LaplaceWrapper() {}
00054 
00055 void LaplaceWrapper::run_wrapper( MeshDomainAssoc* mesh_and_domain,
00056                                   ParallelMesh* pmesh,
00057                                   Settings* settings,
00058                                   QualityAssessor* qa,
00059                                   MsqError& err )
00060 {
00061     if( maxTime <= 0.0 && movementFactor <= 0.0 && iterationLimit <= 0 )
00062     {
00063         MSQ_SETERR( err )
00064         ( "No termination criterion set.  "
00065           "LaplaceWrapper will run forever.",
00066           MsqError::INVALID_STATE );
00067         return;
00068     }
00069 
00070     IdealWeightInverseMeanRatio qa_metric;
00071     qa->add_quality_assessment( &qa_metric );
00072 
00073     LaplacianSmoother smoother;
00074     TerminationCriterion outer( "<type:laplace_outer>" ), inner( "<type:laplace_inner>" );
00075     if( maxTime > 0.0 ) outer.add_cpu_time( maxTime );
00076     if( iterationLimit > 0 ) outer.add_iteration_limit( iterationLimit );
00077     if( doCulling && movementFactor > 0.0 )
00078     {
00079         inner.cull_on_absolute_vertex_movement_edge_length( movementFactor );
00080         smoother.set_inner_termination_criterion( &inner );
00081     }
00082     else if( movementFactor > 0.0 )
00083     {
00084         outer.add_absolute_vertex_movement_edge_length( movementFactor );
00085     }
00086     smoother.set_outer_termination_criterion( &outer );
00087 
00088     InstructionQueue q;
00089     q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
00090     q.set_master_quality_improver( &smoother, err );MSQ_ERRRTN( err );
00091     q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
00092     q.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
00093 }
00094 
00095 }  // namespace MBMesquite
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines