MeshKit  1.0
SmartLaplaceWrapper.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 
00033 #include "SmartLaplaceWrapper.hpp"
00034 #include "moab/mesquite/IdealWeightInverseMeanRatio.hpp" 
00035 #include "moab/mesquite/SmartLaplacianSmoother.hpp"
00036 #include "moab/mesquite/QualityAssessor.hpp"
00037 #include "moab/mesquite/InstructionQueue.hpp"
00038 #include "moab/mesquite/TerminationCriterion.hpp"
00039 #include "moab/mesquite/MsqError.hpp"
00040 
00041 namespace MESQUITE_NS {
00042 
00043 const double DEFAULT_MOVEMENT_FACTOR = 0.001;
00044 const bool CULLING_DEFAULT = true;
00045 const int DEFAULT_ITERATION_LIMIT = 100;
00046 
00047 SmartLaplaceWrapper::SmartLaplaceWrapper() 
00048   : maxTime(-1.0),
00049     movementFactor(DEFAULT_MOVEMENT_FACTOR),
00050     iterationLimit(DEFAULT_ITERATION_LIMIT),
00051     doCulling(CULLING_DEFAULT)
00052 {}
00053 
00054 SmartLaplaceWrapper::~SmartLaplaceWrapper()
00055 {}
00056 
00057 void SmartLaplaceWrapper::run_wrapper( Mesh* mesh,
00058                                   ParallelMesh* pmesh,
00059                                   MeshDomain* geom,
00060                                   Settings* settings,
00061                                   QualityAssessor* qa,
00062                                   MsqError& err )
00063 {
00064   if (maxTime <= 0.0 && movementFactor <= 0.0 && iterationLimit <= 0) {
00065     MSQ_SETERR(err)("No termination criterion set.  "
00066                     "LaplaceWrapper will run forever.", 
00067                     MsqError::INVALID_STATE);
00068     return;
00069   }
00070   
00071   IdealWeightInverseMeanRatio qa_metric;
00072   qa->add_quality_assessment( &qa_metric );
00073   
00074   SmartLaplacianSmoother smoother;
00075   TerminationCriterion outer, inner;
00076   if (maxTime > 0.0)
00077     outer.add_cpu_time( maxTime );
00078   if (iterationLimit > 0)
00079     outer.add_iteration_limit( iterationLimit );
00080   if (doCulling && movementFactor > 0.0) {
00081     inner.cull_on_absolute_vertex_movement_edge_length( movementFactor );
00082     smoother.set_inner_termination_criterion( &inner );
00083   }
00084   else if (movementFactor > 0.0) {
00085     outer.add_absolute_vertex_movement_edge_length( movementFactor );
00086   }
00087   smoother.set_outer_termination_criterion( &outer );
00088   
00089   InstructionQueue q;
00090   q.add_quality_assessor( qa, err ); MSQ_ERRRTN(err);
00091   q.set_master_quality_improver( &smoother, err ); MSQ_ERRRTN(err);
00092   q.add_quality_assessor( qa, err ); MSQ_ERRRTN(err);
00093   MeshDomainAssoc mesh_and_domain(mesh, geom);
00094   q.run_common( &mesh_and_domain, pmesh, settings, err ); MSQ_ERRRTN(err);
00095 }
00096 
00097 } // namespace MESQUITE_NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines