SundanceAToCPointLocator.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_ATOCPOINTLOCATOR_H
00032 #define SUNDANCE_ATOCPOINTLOCATOR_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceMesh.hpp"
00036 #include "SundanceExpr.hpp"
00037 #include "SundanceCellFilter.hpp"
00038 
00039 namespace Sundance
00040 {
00041   using namespace Sundance;
00042   using namespace Sundance;
00043   using namespace Sundance;
00044   using namespace Sundance;
00045   using namespace Sundance;
00046   using namespace Teuchos;
00047 
00048   /**
00049    * AToCPointLocator finds the cell index for a point within an unstructured
00050    * mesh.
00051    *
00052    * Note: not tested in parallel.
00053    */
00054   class AToCPointLocator
00055   {
00056   public:
00057     /** */
00058     AToCPointLocator(const Mesh& mesh, 
00059                      const CellFilter& subdomain,
00060                      const std::vector<int>& nx);
00061 
00062 
00063 
00064     /** Find the index of a point in an overlaid structured grid. */
00065     int getGridIndex(const double* x) const ;
00066 
00067     /** Use an overlaid structured grid to estimate the location of the point. */
00068     int guessCell(const double* x) const 
00069     {return (*table_)[getGridIndex(x)];}
00070 
00071     /** Find the cell that contains the specified point */
00072     int findEnclosingCell(int initialGuessLID, const double* x) const ;
00073 
00074     /** Find the cell that contains the specified point, also
00075      * computing local coordinates within that cell. */
00076     int findEnclosingCell(int initialGuessLID, const double* x,
00077                           double* localCoords) const ;
00078 
00079     /** */
00080     void fillMaximalNeighbors(int cellLID, const int* facetLID) const ;
00081 
00082     /** Test whether a point is within a specified cell */
00083     bool cellContainsPoint(int cellLID, 
00084                            const double* x, 
00085                            const int* facetLID) const ;
00086 
00087     /** Test whether a point is within a specified cell, and if so,
00088      * compute local coordinates within that cell. */
00089     bool cellContainsPoint(int cellLID, 
00090                            const double* x, 
00091                            const int* facetLID,
00092                            double* localCoords) const ;
00093 
00094     /** */
00095     const Mesh& mesh() const {return mesh_;}
00096 
00097     /** */
00098     const CellFilter& subdomain() const {return subdomain_;}
00099 
00100 
00101 
00102     /** */
00103     static Point makePoint(int dim, const double* x) ;
00104   private:
00105 
00106     /** Find the range of structured grid cells within the bounding box of 
00107      * a cell. */
00108     void getGridRange(const Mesh& mesh, int cellDim, int cellLID,
00109                  Array<int>& lowIndex, Array<int>& highIndex) const;
00110 
00111 
00112 
00113 
00114     int dim_;
00115     Mesh mesh_;
00116     int nFacets_;
00117     std::vector<int> nx_;
00118     Array<double> low_;
00119     Array<double> high_;
00120     Array<double> dx_;
00121     RCP<Array<int> > table_;
00122     CellFilter subdomain_;
00123     mutable Array<RCP<Set<int> > > neighborSet_;
00124   };
00125 }
00126 
00127 
00128 #endif

Site Contact