Branch data Line data Source code
1 : : /* *****************************************************************
2 : : MESQUITE -- The Mesh Quality Improvement Toolkit
3 : :
4 : : Copyright 2010 Sandia National Laboratories. Developed at the
5 : : University of Wisconsin--Madison under SNL contract number
6 : : 624796. The U.S. Government and the University of Wisconsin
7 : : retain certain rights to this software.
8 : :
9 : : This library is free software; you can redistribute it and/or
10 : : modify it under the terms of the GNU Lesser General Public
11 : : License as published by the Free Software Foundation; either
12 : : version 2.1 of the License, or (at your option) any later version.
13 : :
14 : : This library is distributed in the hope that it will be useful,
15 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : Lesser General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU Lesser General Public License
20 : : (lgpl.txt) along with this library; if not, write to the Free Software
21 : : Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : :
23 : : (2010) [email protected]
24 : :
25 : : ***************************************************************** */
26 : :
27 : : /** \file LaplaceWrapper.cpp
28 : : * \brief Implement LaplaceWrapper class
29 : : * \author Jason Kraftcheck
30 : : */
31 : :
32 : : #include "LaplaceWrapper.hpp"
33 : : #include "IdealWeightInverseMeanRatio.hpp"
34 : : #include "LaplacianSmoother.hpp"
35 : : #include "QualityAssessor.hpp"
36 : : #include "InstructionQueue.hpp"
37 : : #include "TerminationCriterion.hpp"
38 : : #include "MsqError.hpp"
39 : :
40 : : namespace MBMesquite
41 : : {
42 : :
43 : : const double DEFAULT_MOVEMENT_FACTOR = 0.001;
44 : : const bool CULLING_DEFAULT = true;
45 : : const int DEFAULT_ITERATION_LIMIT = 100;
46 : :
47 : 2 : LaplaceWrapper::LaplaceWrapper()
48 : : : maxTime( -1.0 ), movementFactor( DEFAULT_MOVEMENT_FACTOR ), iterationLimit( DEFAULT_ITERATION_LIMIT ),
49 : 2 : doCulling( CULLING_DEFAULT )
50 : : {
51 : 2 : }
52 : :
53 [ - + ]: 4 : LaplaceWrapper::~LaplaceWrapper() {}
54 : :
55 : 4 : void LaplaceWrapper::run_wrapper( MeshDomainAssoc* mesh_and_domain, ParallelMesh* pmesh, Settings* settings,
56 : : QualityAssessor* qa, MsqError& err )
57 : : {
58 [ + - ][ - + ]: 4 : if( maxTime <= 0.0 && movementFactor <= 0.0 && iterationLimit <= 0 )
[ # # ]
59 : : {
60 : : MSQ_SETERR( err )
61 : : ( "No termination criterion set. "
62 : : "LaplaceWrapper will run forever.",
63 [ # # ][ # # ]: 0 : MsqError::INVALID_STATE );
64 : 4 : return;
65 : : }
66 : :
67 [ + - ]: 4 : IdealWeightInverseMeanRatio qa_metric;
68 [ + - ]: 4 : qa->add_quality_assessment( &qa_metric );
69 : :
70 [ + - ][ + - ]: 8 : LaplacianSmoother smoother;
71 [ + - ][ + - ]: 8 : TerminationCriterion outer( "<type:laplace_outer>" ), inner( "<type:laplace_inner>" );
[ + - ][ + - ]
[ + - ][ + - ]
72 [ - + ][ # # ]: 4 : if( maxTime > 0.0 ) outer.add_cpu_time( maxTime );
73 [ + - ][ + - ]: 4 : if( iterationLimit > 0 ) outer.add_iteration_limit( iterationLimit );
74 [ + - ][ + - ]: 4 : if( doCulling && movementFactor > 0.0 )
75 : : {
76 [ + - ]: 4 : inner.cull_on_absolute_vertex_movement_edge_length( movementFactor );
77 [ + - ]: 4 : smoother.set_inner_termination_criterion( &inner );
78 : : }
79 [ # # ]: 0 : else if( movementFactor > 0.0 )
80 : : {
81 [ # # ]: 0 : outer.add_absolute_vertex_movement_edge_length( movementFactor );
82 : : }
83 [ + - ]: 4 : smoother.set_outer_termination_criterion( &outer );
84 : :
85 [ + - ][ + - ]: 8 : InstructionQueue q;
86 [ + - ][ + - ]: 4 : q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
[ - + ][ # # ]
[ # # ][ - + ]
87 [ + - ][ + - ]: 4 : q.set_master_quality_improver( &smoother, err );MSQ_ERRRTN( err );
[ - + ][ # # ]
[ # # ][ - + ]
88 [ + - ][ + - ]: 4 : q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
[ - + ][ # # ]
[ # # ][ - + ]
89 [ + - ][ + - ]: 8 : q.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
[ - + ][ # # ]
[ # # ][ - + ]
[ + - ]
90 : : }
91 : :
92 [ + - ][ + - ]: 8 : } // namespace MBMesquite
|