1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* ***************************************************************** 
    MESQUITE -- The Mesh Quality Improvement Toolkit

    Copyright 2010 Sandia National Laboratories.  Developed at the
    University of Wisconsin--Madison under SNL contract number
    624796.  The U.S. Government and the University of Wisconsin
    retain certain rights to this software.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License 
    (lgpl.txt) along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    (2010) [email protected]    

  ***************************************************************** */


/** \file SmartLaplaceWrapper.cpp
 *  \brief Implement SmartLaplaceWrapper class
 *  \author Jason Kraftcheck, modified by Shengyong Cai 
 */

#include "SmartLaplaceWrapper.hpp"
#include "IdealWeightInverseMeanRatio.hpp" 
#include "SmartLaplacianSmoother.hpp"
#include "QualityAssessor.hpp"
#include "InstructionQueue.hpp"
#include "TerminationCriterion.hpp"
#include "MsqError.hpp"

namespace MESQUITE_NS {

const double DEFAULT_MOVEMENT_FACTOR = 0.001;
const bool CULLING_DEFAULT = true;
const int DEFAULT_ITERATION_LIMIT = 100;

SmartLaplaceWrapper::SmartLaplaceWrapper() 
  : maxTime(-1.0),
    movementFactor(DEFAULT_MOVEMENT_FACTOR),
    iterationLimit(DEFAULT_ITERATION_LIMIT),
    doCulling(CULLING_DEFAULT)
{}

SmartLaplaceWrapper::~SmartLaplaceWrapper()
{}

void SmartLaplaceWrapper::run_wrapper( Mesh* mesh,<--- The function 'run_wrapper' is never used.
                                  ParallelMesh* pmesh,
                                  MeshDomain* geom,
                                  Settings* settings,
                                  QualityAssessor* qa,
                                  MsqError& err )
{
  if (maxTime <= 0.0 && movementFactor <= 0.0 && iterationLimit <= 0) {
    MSQ_SETERR(err)("No termination criterion set.  "
                    "LaplaceWrapper will run forever.", 
                    MsqError::INVALID_STATE);
    return;
  }
  
  IdealWeightInverseMeanRatio qa_metric;
  qa->add_quality_assessment( &qa_metric );
  
  SmartLaplacianSmoother smoother;
  TerminationCriterion outer, inner;
  if (maxTime > 0.0)
    outer.add_cpu_time( maxTime );
  if (iterationLimit > 0)
    outer.add_iteration_limit( iterationLimit );
  if (doCulling && movementFactor > 0.0) {
    inner.cull_on_absolute_vertex_movement_edge_length( movementFactor );
    smoother.set_inner_termination_criterion( &inner );
  }
  else if (movementFactor > 0.0) {
    outer.add_absolute_vertex_movement_edge_length( movementFactor );
  }
  smoother.set_outer_termination_criterion( &outer );
  
  InstructionQueue q;
  q.add_quality_assessor( qa, err ); MSQ_ERRRTN(err);
  q.set_master_quality_improver( &smoother, err ); MSQ_ERRRTN(err);
  q.add_quality_assessor( qa, err ); MSQ_ERRRTN(err);
  q.run_common( mesh, pmesh, geom, settings, err ); MSQ_ERRRTN(err);
}

} // namespace MESQUITE_NS