SundanceMaximalCofacetBatch.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 #ifndef SUNDANCE_MAXIMALCOFACETBATCH_H
00043 #define SUNDANCE_MAXIMALCOFACETBATCH_H
00044 
00045 #include "SundanceDefs.hpp"
00046 #include "Teuchos_Array.hpp"
00047 #include "Teuchos_RefCountPtr.hpp"
00048 
00049 namespace Sundance {
00050 using namespace Teuchos;
00051 
00052 /** 
00053  * MaximalCofacetBatch is used to store the maximal cofacets
00054  * of a batch of cells of codimension one. Interior cells will
00055  * have two cofacets, while boundary cells will have only one. Every 
00056  * cell in the batch required to have the same number of cofacets, which
00057  * can be arranged at the user level by careful distinction between
00058  * external boundaries and internal boundaries. 
00059  */
00060 class MaximalCofacetBatch
00061 {
00062 public:
00063   /** 
00064    * Initialize an empty batch
00065    */
00066   MaximalCofacetBatch();
00067 
00068   /** 
00069    * Change the number of cells in the batch.
00070    */
00071   void reset(int numCells);
00072 
00073   /** 
00074    * Change the number of cells and cofacets in the batch.
00075    */
00076   void reset(int numCells, int numCofacets);
00077 
00078   /** 
00079    * Return the number of cells in the batch
00080    */
00081   int numCells() const {return numCells_;}
00082 
00083   /** 
00084    * 
00085    */
00086   int numCofacets() const {return numCofacets_;}
00087 
00088   /** 
00089    * Return the LID of the n-th cofacet of the c-th cell in the batch. 
00090    * 
00091    * \param c The index (within the batch) of the cell whose cofacets are
00092    * requested.
00093    * \param n The number of the cofacet requested. This can only be 0 or 1,
00094    * and must be less than numCells().
00095    * \param facetIndex The c-th cell in the batch is one of the facets of
00096    * its maximal cofacets. Its facet index within that cell is returned
00097    * via reference as facetIndex.
00098    * \returns The LID of the requested cofacet.
00099    */
00100   int cofacetLID(int c, int n, int& facetIndex) const ; 
00101 
00102 
00103   /** 
00104    * Pick one specified cofacet for each cell in the batch.
00105    *
00106    * \param cofacetNumbers the c-th entry selects cofacet for cell c. Each
00107    * entry in the array should be either 0 or 1.
00108    * \param cofacets array for storage of the results.
00109    * \param facet index array for storage of the results.
00110    */
00111   void getSpecifiedCofacets(const Array<int>& cofacetNumbers,
00112     RCP<Array<int> >& cofacets, RCP<Array<int> >& facetIndices) const ;
00113 
00114 
00115   /** 
00116    * Pick one specified cofacet for each cell in the batch.
00117    *
00118    * \param cofacetNumber which cofacet to select
00119    * \param cofacets array for storage of the results.
00120    * \param facet index array for storage of the results.
00121    */
00122   void getSpecifiedCofacets(int cofacetNumber,
00123     RCP<Array<int> >& cofacets, RCP<Array<int> >& facetIndices) const ;
00124 
00125   /** 
00126    * Add a cell with a single cofacet
00127    */
00128   void addSingleCofacet(int c, int cofacetLID, int facetIndex) ;
00129 
00130   /** 
00131    * Add a cell with two cofacets
00132    */
00133   void addTwoCofacets(int c, 
00134     int cofacet1, int facetIndex1,
00135     int cofacet2, int facetIndex2);
00136 
00137 private:
00138   Array<RCP<Array<int> > > cofacetLIDs_;
00139 
00140   Array<RCP<Array<int> > > facetIndices_;
00141 
00142   int numCells_;
00143 
00144   int numCofacets_;
00145 };
00146 
00147 }
00148 
00149 #endif
00150 
00151 

Site Contact