Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
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,
00047                    ParallelComm* pc,
00048                    Range& elems,
00049                    Tag cds_tag    = 0,
00050                    Tag fixed_tag  = 0,
00051                    double abs_tol = -1.0,
00052                    double rel_tol = 1.0e-6 );
00053 
00054     /* \brief Destructor
00055      */
00056     ~LloydSmoother();
00057 
00058     /* \brief perform smoothing operation
00059      */
00060     ErrorCode perform_smooth();
00061 
00062     /* \brief get instance
00063      */
00064     Interface* mb_impl()
00065     {
00066         return mbImpl;
00067     }
00068 
00069     /* \brief get/set ParallelComm
00070      */
00071     ParallelComm* pcomm()
00072     {
00073         return myPcomm;
00074     }
00075 
00076     /* \brief get/set ParallelComm
00077      */
00078     void pcomm( ParallelComm* pc )
00079     {
00080         myPcomm = pc;
00081     }
00082 
00083     /* \brief get/set elements
00084      */
00085     Range& elems()
00086     {
00087         return myElems;
00088     }
00089 
00090     /* \brief get/set elements
00091      */
00092     const Range& elems() const
00093     {
00094         return myElems;
00095     }
00096 
00097     /* \brief get/set fixed tag
00098      */
00099     Tag fixed_tag()
00100     {
00101         return fixedTag;
00102     }
00103 
00104     /* \brief get/set fixed tag
00105      */
00106     void fixed_tag( Tag fixed )
00107     {
00108         fixedTag = fixed;
00109     }
00110 
00111     /* \brief get/set coords tag
00112      */
00113     Tag coords_tag()
00114     {
00115         return coordsTag;
00116     }
00117 
00118     /* \brief get/set coords tag
00119      */
00120     void coords_tag( Tag coords )
00121     {
00122         coordsTag = coords;
00123     }
00124 
00125     /* \brief get/set tolerance
00126      */
00127     double abs_tol()
00128     {
00129         return absTol;
00130     }
00131 
00132     /* \brief get/set tolerance
00133      */
00134     void abs_tol( double tol )
00135     {
00136         absTol = tol;
00137     }
00138 
00139     /* \brief get/set tolerance
00140      */
00141     double rel_tol()
00142     {
00143         return relTol;
00144     }
00145 
00146     /* \brief get/set tolerance
00147      */
00148     void rel_tol( double tol )
00149     {
00150         relTol = tol;
00151     }
00152 
00153     /* \brief get/set numIts
00154      */
00155     int num_its()
00156     {
00157         return numIts;
00158     }
00159     void num_its( int num )
00160     {
00161         numIts = num;
00162     }
00163 
00164     /* \brief get/set reportIts
00165      */
00166     int report_its()
00167     {
00168         return reportIts;
00169     }
00170     void report_its( int num )
00171     {
00172         reportIts = num;
00173     }
00174 
00175   private:
00176     //- initialize some things in certain cases
00177     ErrorCode initialize();
00178 
00179     //- MOAB instance
00180     Interface* mbImpl;
00181 
00182     //- ParallelComm
00183     ParallelComm* myPcomm;
00184 
00185     //- elements to smooth
00186     Range myElems;
00187 
00188     //- tag for coordinates; if zero, true vertex coords are used
00189     Tag coordsTag;
00190 
00191     //- tag marking which vertices are fixed, 0 = not fixed, otherwise fixed
00192     Tag fixedTag;
00193 
00194     //- tolerances
00195     double absTol, relTol;
00196 
00197     //- number of iterations between reporting
00198     int reportIts;
00199 
00200     //- number of iterations taken during smooth
00201     int numIts;
00202 
00203     //- keep track of whether I created the fixed tag
00204     bool iCreatedTag;
00205 };
00206 
00207 }  // namespace moab
00208 
00209 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines