MOAB: Mesh Oriented datABase  (version 5.3.1)
LloydSmoother.hpp
Go to the documentation of this file.
00001 /** @class LloydSmoother.cpp \n
00002  * \brief Perform Lloyd relaxation on a mesh and its dual \n
00003  *
00004  * Briefly, Lloyd relaxation is a technique to smooth out a mesh.  The centroid of each cell is
00005  * computed from its vertex positions, then vertices are placed at the average of their connected
00006  * cells' centroids, and the process iterates until convergence.
00007  *
00008  * In the parallel algorithm, an extra ghost layer of cells is exchanged.  This allows us to compute
00009  * the centroids for boundary cells on each processor where they appear; this eliminates the need
00010  * for one round of data exchange (for those centroids) between processors.  New vertex positions
00011  * must be sent from owning processors to processors sharing those vertices.  Convergence is
00012  * measured as the maximum distance moved by any vertex.
00013  *
00014  */
00015 
00016 #ifndef LLOYDSMOOTHER_HPP
00017 #define LLOYDSMOOTHER_HPP
00018 
00019 #include "moab/Interface.hpp"
00020 
00021 namespace moab
00022 {
00023 
00024 class ParallelComm;
00025 
00026 class LloydSmoother
00027 {
00028   public:
00029     /* \brief Constructor
00030      * Bare constructor, data input to this class through methods.
00031      * \param impl The MOAB instance for this smoother
00032      */
00033     LloydSmoother( Interface* impl );
00034 
00035     /* \brief Constructor
00036      * Convenience constructor, data input directly
00037      * \param impl The MOAB instance for this smoother
00038      * \param pc The ParallelComm instance by which this mesh is parallel
00039      * \param elems The mesh to be smoothed
00040      * \param cds_tag If specified, this tag is used to get/set coordinates, rather than
00041      *     true vertex coordinates
00042      * \param fixed_tag The tag marking which vertices are fixed
00043      * \param abs_tol Absolute tolerance measuring convergence
00044      * \param rel_tol Relative tolerance measuring convergence
00045      */
00046     LloydSmoother( Interface* impl, ParallelComm* pc, Range& elems, Tag cds_tag = 0, Tag fixed_tag = 0,
00047                    double abs_tol = -1.0, double rel_tol = 1.0e-6 );
00048 
00049     /* \brief Destructor
00050      */
00051     ~LloydSmoother();
00052 
00053     /* \brief perform smoothing operation
00054      */
00055     ErrorCode perform_smooth();
00056 
00057     /* \brief get instance
00058      */
00059     Interface* mb_impl()
00060     {
00061         return mbImpl;
00062     }
00063 
00064     /* \brief get/set ParallelComm
00065      */
00066     ParallelComm* pcomm()
00067     {
00068         return myPcomm;
00069     }
00070 
00071     /* \brief get/set ParallelComm
00072      */
00073     void pcomm( ParallelComm* pc )
00074     {
00075         myPcomm = pc;
00076     }
00077 
00078     /* \brief get/set elements
00079      */
00080     Range& elems()
00081     {
00082         return myElems;
00083     }
00084 
00085     /* \brief get/set elements
00086      */
00087     const Range& elems() const
00088     {
00089         return myElems;
00090     }
00091 
00092     /* \brief get/set fixed tag
00093      */
00094     Tag fixed_tag()
00095     {
00096         return fixedTag;
00097     }
00098 
00099     /* \brief get/set fixed tag
00100      */
00101     void fixed_tag( Tag fixed )
00102     {
00103         fixedTag = fixed;
00104     }
00105 
00106     /* \brief get/set coords tag
00107      */
00108     Tag coords_tag()
00109     {
00110         return coordsTag;
00111     }
00112 
00113     /* \brief get/set coords tag
00114      */
00115     void coords_tag( Tag coords )
00116     {
00117         coordsTag = coords;
00118     }
00119 
00120     /* \brief get/set tolerance
00121      */
00122     double abs_tol()
00123     {
00124         return absTol;
00125     }
00126 
00127     /* \brief get/set tolerance
00128      */
00129     void abs_tol( double tol )
00130     {
00131         absTol = tol;
00132     }
00133 
00134     /* \brief get/set tolerance
00135      */
00136     double rel_tol()
00137     {
00138         return relTol;
00139     }
00140 
00141     /* \brief get/set tolerance
00142      */
00143     void rel_tol( double tol )
00144     {
00145         relTol = tol;
00146     }
00147 
00148     /* \brief get/set numIts
00149      */
00150     int num_its()
00151     {
00152         return numIts;
00153     }
00154     void num_its( int num )
00155     {
00156         numIts = num;
00157     }
00158 
00159     /* \brief get/set reportIts
00160      */
00161     int report_its()
00162     {
00163         return reportIts;
00164     }
00165     void report_its( int num )
00166     {
00167         reportIts = num;
00168     }
00169 
00170   private:
00171     //- initialize some things in certain cases
00172     ErrorCode initialize();
00173 
00174     //- MOAB instance
00175     Interface* mbImpl;
00176 
00177     //- ParallelComm
00178     ParallelComm* myPcomm;
00179 
00180     //- elements to smooth
00181     Range myElems;
00182 
00183     //- tag for coordinates; if zero, true vertex coords are used
00184     Tag coordsTag;
00185 
00186     //- tag marking which vertices are fixed, 0 = not fixed, otherwise fixed
00187     Tag fixedTag;
00188 
00189     //- tolerances
00190     double absTol, relTol;
00191 
00192     //- number of iterations between reporting
00193     int reportIts;
00194 
00195     //- number of iterations taken during smooth
00196     int numIts;
00197 
00198     //- keep track of whether I created the fixed tag
00199     bool iCreatedTag;
00200 };
00201 
00202 }  // namespace moab
00203 
00204 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines