Branch data Line data Source code
1 : : /* *****************************************************************
2 : : MESQUITE -- The Mesh Quality Improvement Toolkit
3 : :
4 : : Copyright 2009 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 : : (2009) [email protected]
24 : :
25 : : ***************************************************************** */
26 : :
27 : : /** \file PaverMinEdgeLengthWrapper.cpp
28 : : * \brief
29 : : * \author Jason Kraftcheck
30 : : */
31 : :
32 : : #include "Mesquite.hpp"
33 : : #include "PaverMinEdgeLengthWrapper.hpp"
34 : :
35 : : #include "TerminationCriterion.hpp"
36 : : #include "InstructionQueue.hpp"
37 : : #include "QualityAssessor.hpp"
38 : : #include "MeshImpl.hpp"
39 : : #include "PlanarDomain.hpp"
40 : :
41 : : #include "ElementPMeanP.hpp"
42 : : #include "PMeanPTemplate.hpp"
43 : : #include "TrustRegion.hpp"
44 : : #include "TQualityMetric.hpp"
45 : : #include "IdealShapeTarget.hpp"
46 : : #include "TShapeSizeB1.hpp"
47 : : #include "RefMeshTargetCalculator.hpp"
48 : : #include "ReferenceMesh.hpp"
49 : :
50 : : #include "EdgeLengthMetric.hpp"
51 : : #include "LambdaConstant.hpp"
52 : :
53 : : #include "MsqFPE.hpp"
54 : : #include "MeshUtil.hpp"
55 : : #include "SimpleStats.hpp"
56 : :
57 : : namespace MBMesquite
58 : : {
59 : :
60 : 3 : void PaverMinEdgeLengthWrapper::run_wrapper( MeshDomainAssoc* mesh_and_domain, ParallelMesh* pmesh, Settings* settings,
61 : : QualityAssessor* qa, MsqError& err )
62 : : {
63 [ + - ]: 3 : InstructionQueue q;
64 [ + - ]: 3 : Mesh* mesh = mesh_and_domain->get_mesh();
65 : :
66 : : // calculate average lambda for mesh
67 [ + - ][ + - ]: 6 : ReferenceMesh ref_mesh( mesh );
68 [ + - ][ + - ]: 6 : RefMeshTargetCalculator W_0( &ref_mesh );
69 [ + - ]: 3 : SimpleStats lambda_stats;
70 [ + - ][ + - ]: 6 : MeshUtil tool( mesh, settings );
71 [ + - ][ + - ]: 3 : tool.lambda_distribution( lambda_stats, err );MSQ_ERRRTN( err );
[ - + ][ # # ]
[ # # ][ - + ]
72 [ + - ]: 3 : double lambda = lambda_stats.average();
73 : :
74 : : // create objective function
75 [ + - ]: 3 : IdealShapeTarget W_i;
76 [ + - ][ + - ]: 6 : LambdaConstant W( lambda, &W_i );
77 [ + - ]: 3 : TShapeSizeB1 tm;
78 [ + - ][ + - ]: 6 : TQualityMetric mu_0( &W, &tm );
79 [ + - ][ + - ]: 6 : ElementPMeanP mu( 1.0, &mu_0 );
80 [ + - ][ + - ]: 6 : PMeanPTemplate of( 1.0, &mu );
81 : :
82 : : // create quality assessor
83 [ + - ][ + - ]: 6 : EdgeLengthMetric len( 0.0 );
84 [ + - ]: 3 : qa->add_quality_assessment( &mu );
85 [ + - ]: 3 : qa->add_quality_assessment( &len );
86 [ + - ]: 3 : q.add_quality_assessor( qa, err );
87 : :
88 : : // create solver
89 [ + - ][ + - ]: 6 : TrustRegion solver( &of );
90 [ + - ][ + - ]: 6 : TerminationCriterion tc, ptc;
[ + - ][ + - ]
[ + - ][ + - ]
91 [ + - ]: 3 : tc.add_absolute_vertex_movement( maxVtxMovement );
92 [ + - ]: 3 : tc.add_iteration_limit( iterationLimit );
93 [ - + ][ + - ]: 3 : ptc.add_iteration_limit( pmesh ? parallelIterations : 1 );
94 [ + - ]: 3 : solver.set_inner_termination_criterion( &tc );
95 [ + - ]: 3 : solver.set_outer_termination_criterion( &ptc );
96 [ + - ][ + - ]: 3 : q.set_master_quality_improver( &solver, err );MSQ_ERRRTN( err );
[ - + ][ # # ]
[ # # ][ - + ]
97 [ + - ]: 3 : q.add_quality_assessor( qa, err );
98 : :
99 : : // Optimize mesh
100 [ + - ][ + - ]: 6 : q.run_common( mesh_and_domain, pmesh, settings, err );MSQ_CHKERR( err );
[ - + ][ # # ]
[ # # ][ + - ]
101 : : }
102 : :
103 [ + - ][ + - ]: 4 : } // namespace MBMesquite
|