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 ConjugateGradient.hpp
29 : : \brief
30 : :
31 : : Conjugate Gradient minimization method ...
32 : :
33 : : \author Michael Brewer
34 : : \date 2002-06/19
35 : : */
36 : :
37 : : #ifndef Mesquite_ConjugateGradient_hpp
38 : : #define Mesquite_ConjugateGradient_hpp
39 : : #include "Mesquite.hpp"
40 : : #include "VertexMover.hpp"
41 : : #include "PatchData.hpp"
42 : : #include "PatchSetUser.hpp"
43 : :
44 : : namespace MBMesquite
45 : : {
46 : : class ObjectiveFunction;
47 : :
48 : : /*! \class ConjugateGradient
49 : : \brief Optimizes the objective function using the Polack-Ribiere scheme.
50 : : */
51 : : class ConjugateGradient : public VertexMover, public PatchSetUser
52 : : {
53 : : public:
54 : : MESQUITE_EXPORT ConjugateGradient( ObjectiveFunction* objective );
55 : : MESQUITE_EXPORT ConjugateGradient( ObjectiveFunction* objective, MsqError& err );
56 : :
57 : : MESQUITE_EXPORT virtual ~ConjugateGradient();
58 : :
59 : : MESQUITE_EXPORT virtual std::string get_name() const;
60 : :
61 : : virtual PatchSet* get_patch_set();
62 : :
63 : : //! Just for debugging purposes or for obtaining more data
64 : : //! during the optimization process.
65 : 4 : MESQUITE_EXPORT void set_debugging_level( int new_lev )
66 : : {
67 : 4 : conjGradDebug = new_lev;
68 : 4 : }
69 : :
70 : : protected:
71 : : //! Initialize data for smoothing process
72 : : virtual void initialize( PatchData& pd, MsqError& err );
73 : :
74 : : virtual void optimize_vertex_positions( PatchData& pd, MsqError& err );
75 : :
76 : : virtual void initialize_mesh_iteration( PatchData& pd, MsqError& err );
77 : :
78 : : virtual void terminate_mesh_iteration( PatchData& pd, MsqError& err );
79 : :
80 : : //! Delete arrays initially created in initialize().
81 : : virtual void cleanup();
82 : :
83 : : //! Returns the step distance to take in the search direction.
84 : : double get_step( PatchData& pd, double f0, int& j, MsqError& err );
85 : :
86 : : //! Culls the vertex list free_vertex_list.
87 : : // void cull_list(PatchData &pd, double beta, MsqError &err);
88 : :
89 : : private:
90 : : std::vector< Vector3D > fGrad, pGrad, fNewGrad;
91 : : PatchDataVerticesMemento* pMemento;
92 : : // just for debugging
93 : : int conjGradDebug;
94 : : };
95 : :
96 : : } // namespace MBMesquite
97 : :
98 : : #endif
|