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_MAXIMALCOFACETBATCH_H 00032 #define SUNDANCE_MAXIMALCOFACETBATCH_H 00033 00034 #include "SundanceDefs.hpp" 00035 #include "Teuchos_Array.hpp" 00036 #include "Teuchos_RefCountPtr.hpp" 00037 00038 namespace Sundance { 00039 using namespace Teuchos; 00040 00041 /** 00042 * MaximalCofacetBatch is used to store the maximal cofacets 00043 * of a batch of cells of codimension one. Interior cells will 00044 * have two cofacets, while boundary cells will have only one. Every 00045 * cell in the batch required to have the same number of cofacets, which 00046 * can be arranged at the user level by careful distinction between 00047 * external boundaries and internal boundaries. 00048 */ 00049 class MaximalCofacetBatch 00050 { 00051 public: 00052 /** 00053 * Initialize an empty batch 00054 */ 00055 MaximalCofacetBatch(); 00056 00057 /** 00058 * Change the number of cells in the batch. 00059 */ 00060 void reset(int numCells); 00061 00062 /** 00063 * Change the number of cells and cofacets in the batch. 00064 */ 00065 void reset(int numCells, int numCofacets); 00066 00067 /** 00068 * Return the number of cells in the batch 00069 */ 00070 int numCells() const {return numCells_;} 00071 00072 /** 00073 * 00074 */ 00075 int numCofacets() const {return numCofacets_;} 00076 00077 /** 00078 * Return the LID of the n-th cofacet of the c-th cell in the batch. 00079 * 00080 * \param c The index (within the batch) of the cell whose cofacets are 00081 * requested. 00082 * \param n The number of the cofacet requested. This can only be 0 or 1, 00083 * and must be less than numCells(). 00084 * \param facetIndex The c-th cell in the batch is one of the facets of 00085 * its maximal cofacets. Its facet index within that cell is returned 00086 * via reference as facetIndex. 00087 * \returns The LID of the requested cofacet. 00088 */ 00089 int cofacetLID(int c, int n, int& facetIndex) const ; 00090 00091 00092 /** 00093 * Pick one specified cofacet for each cell in the batch. 00094 * 00095 * \param cofacetNumbers the c-th entry selects cofacet for cell c. Each 00096 * entry in the array should be either 0 or 1. 00097 * \param cofacets array for storage of the results. 00098 * \param facet index array for storage of the results. 00099 */ 00100 void getSpecifiedCofacets(const Array<int>& cofacetNumbers, 00101 RCP<Array<int> >& cofacets, RCP<Array<int> >& facetIndices) const ; 00102 00103 00104 /** 00105 * Pick one specified cofacet for each cell in the batch. 00106 * 00107 * \param cofacetNumber which cofacet to select 00108 * \param cofacets array for storage of the results. 00109 * \param facet index array for storage of the results. 00110 */ 00111 void getSpecifiedCofacets(int cofacetNumber, 00112 RCP<Array<int> >& cofacets, RCP<Array<int> >& facetIndices) const ; 00113 00114 /** 00115 * Add a cell with a single cofacet 00116 */ 00117 void addSingleCofacet(int c, int cofacetLID, int facetIndex) ; 00118 00119 /** 00120 * Add a cell with two cofacets 00121 */ 00122 void addTwoCofacets(int c, 00123 int cofacet1, int facetIndex1, 00124 int cofacet2, int facetIndex2); 00125 00126 private: 00127 Array<RCP<Array<int> > > cofacetLIDs_; 00128 00129 Array<RCP<Array<int> > > facetIndices_; 00130 00131 int numCells_; 00132 00133 int numCofacets_; 00134 }; 00135 00136 } 00137 00138 #endif 00139 00140