Branch data Line data Source code
1 : : /* *****************************************************************
2 : : MESQUITE -- The Mesh Quality Improvement Toolkit
3 : :
4 : : Copyright 2004 Sandia Corporation and Argonne National
5 : : Laboratory. Under the terms of Contract DE-AC04-94AL85000
6 : : with Sandia Corporation, the U.S. Government retains certain
7 : : rights in 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 : : [email protected], [email protected], [email protected],
24 : : [email protected], [email protected], [email protected]
25 : :
26 : : ***************************************************************** */
27 : : /*!
28 : : \file VertexMover.hpp
29 : : \brief
30 : :
31 : : The VertexMover Class is the base class for all the smoothing and
32 : : optimizing algorythms
33 : :
34 : : \author Thomas Leurent
35 : : \date 2002-01-17
36 : : */
37 : :
38 : : #ifndef Mesquite_VertexMover_hpp
39 : : #define Mesquite_VertexMover_hpp
40 : :
41 : : #include "Mesquite.hpp"
42 : : #include "QualityImprover.hpp"
43 : : #include "OFEvaluator.hpp"
44 : : #include "MeshInterface.hpp"
45 : :
46 : : namespace MBMesquite
47 : : {
48 : : class ObjectiveFunction;
49 : : class PatchData;
50 : : class ParallelMesh;
51 : :
52 : : /*! \class VertexMover
53 : : Base class for all Vertex Movers.
54 : : */
55 : : class MESQUITE_EXPORT VertexMover : public QualityImprover
56 : : {
57 : : protected:
58 : : VertexMover( ObjectiveFunction* OF = NULL );
59 : :
60 : : public:
61 : : // virtual destructor ensures use of polymorphism during destruction
62 : : virtual ~VertexMover();
63 : :
64 : : virtual void initialize_queue( MeshDomainAssoc* mesh_and_domain, const Settings* settings, MsqError& err );
65 : :
66 : : virtual double loop_over_mesh( MeshDomainAssoc* mesh_and_domain, const Settings* settings, MsqError& err );
67 : :
68 : : virtual double loop_over_mesh( ParallelMesh* mesh, MeshDomain* domain, const Settings* settings, MsqError& err );
69 : :
70 : : /**\brief Do Nash-game type optimization
71 : : *
72 : : * Default, opposite of \c do_block_coordinate_descent().
73 : : */
74 : : inline void do_nash_game_optimization()
75 : : {
76 : : objFuncEval.do_nash_game();
77 : : }
78 : :
79 : : /**\brief Check if optmizer will do Nash-game type optimization
80 : : *
81 : : * Default, opposite of \c is_block_coordinate_descent_optimization().
82 : : */
83 : : inline bool is_nash_game_optimization() const
84 : : {
85 : : return objFuncEval.is_nash_game();
86 : : }
87 : :
88 : : /**\brief Do block coordinate descent optimization
89 : : *
90 : : * Opposite of \c do_nash_game().
91 : : */
92 : : inline void do_block_coordinate_descent_optimization()
93 : : {
94 : : objFuncEval.do_block_coordinate_descent();
95 : : }
96 : :
97 : : /**\brief Check if optmizer will do block coordinate descent type optimization
98 : : *
99 : : * Default, opposite of \c is_nash_game_optimization().
100 : : */
101 : : inline bool is_block_coordinate_descent_optimization() const
102 : : {
103 : : return objFuncEval.is_block_coordinate_descent();
104 : : }
105 : :
106 : : /**\brief Use Jacobi iteration for optimization
107 : : *
108 : : * Opposite of \c do_gauss_optimization()
109 : : */
110 : 1 : inline void do_jacobi_optimization()
111 : : {
112 : 1 : jacobiOpt = true;
113 : 1 : }
114 : :
115 : : /**\brief Check if optimization will use Jacobi iteration
116 : : *
117 : : * Opposite of \c is_gauss_optimization()
118 : : */
119 : : inline bool is_jacobi_optimization() const
120 : : {
121 : : return jacobiOpt;
122 : : }
123 : :
124 : : /**\brief Use Gauss-Seidel iteration for optimization
125 : : *
126 : : * Default, opposite of \c do_jacobi_optimization()
127 : : */
128 : 20 : inline void do_gauss_optimization()
129 : : {
130 : 20 : jacobiOpt = false;
131 : 20 : }
132 : :
133 : : /**\brief Check if optimization will use Gauss-Seidel iteration
134 : : *
135 : : * Default, opposite of \c is_jacobi_optimization()
136 : : */
137 : : inline bool is_gauss_optimization() const
138 : : {
139 : : return !jacobiOpt;
140 : : }
141 : :
142 : : protected:
143 : : virtual void initialize( PatchData& pd, MsqError& err ) = 0;
144 : : virtual void cleanup() = 0;
145 : : virtual void optimize_vertex_positions( PatchData& pd,
146 : : MsqError& err ) = 0; // modifies the PatchData object
147 : :
148 : : virtual void initialize_mesh_iteration( PatchData& pd, MsqError& err ) = 0;
149 : : virtual void terminate_mesh_iteration( PatchData&, MsqError& err ) = 0;
150 : :
151 : 80308 : OFEvaluator& get_objective_function_evaluator()
152 : : {
153 : 80308 : return objFuncEval;
154 : : }
155 : :
156 : : static TagHandle get_jacobi_coord_tag( Mesh* mesh, MsqError& err );
157 : : static void commit_jacobi_coords( TagHandle tag, Mesh* mesh, MsqError& err );
158 : :
159 : : private:
160 : : OFEvaluator objFuncEval;
161 : : bool jacobiOpt;
162 : : };
163 : :
164 : : } // namespace MBMesquite
165 : : #endif // Mesquite_VertexMover_hpp
|