MOAB: Mesh Oriented datABase  (version 5.3.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) kraftche@cae.wisc.edu
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, ParallelMesh* pmesh, Settings* settings,
00056                                   QualityAssessor* qa, MsqError& err )
00057 {
00058     if( maxTime <= 0.0 && movementFactor <= 0.0 && iterationLimit <= 0 )
00059     {
00060         MSQ_SETERR( err )
00061         ( "No termination criterion set.  "
00062           "LaplaceWrapper will run forever.",
00063           MsqError::INVALID_STATE );
00064         return;
00065     }
00066 
00067     IdealWeightInverseMeanRatio qa_metric;
00068     qa->add_quality_assessment( &qa_metric );
00069 
00070     LaplacianSmoother smoother;
00071     TerminationCriterion outer( "<type:laplace_outer>" ), inner( "<type:laplace_inner>" );
00072     if( maxTime > 0.0 ) outer.add_cpu_time( maxTime );
00073     if( iterationLimit > 0 ) outer.add_iteration_limit( iterationLimit );
00074     if( doCulling && movementFactor > 0.0 )
00075     {
00076         inner.cull_on_absolute_vertex_movement_edge_length( movementFactor );
00077         smoother.set_inner_termination_criterion( &inner );
00078     }
00079     else if( movementFactor > 0.0 )
00080     {
00081         outer.add_absolute_vertex_movement_edge_length( movementFactor );
00082     }
00083     smoother.set_outer_termination_criterion( &outer );
00084 
00085     InstructionQueue q;
00086     q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
00087     q.set_master_quality_improver( &smoother, err );MSQ_ERRRTN( err );
00088     q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
00089     q.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
00090 }
00091 
00092 }  // namespace MBMesquite
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines