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 * SundancePeanoMesh2D.h 00043 * 00044 * Created on: Sep 8, 2009 00045 * Author: benk 00046 */ 00047 00048 #ifndef SUNDANCEPEANOMESH2D_H_ 00049 #define SUNDANCEPEANOMESH2D_H_ 00050 00051 #include "SundanceDefs.hpp" 00052 #include "SundanceMeshBase.hpp" 00053 #include "SundanceSet.hpp" 00054 #include "SundancePoint.hpp" 00055 #include "SundanceCellType.hpp" 00056 00057 #ifdef HAVE_SUNDANCE_PEANO 00058 00059 #include "SundancePeanoInterface2D.h" 00060 00061 namespace Sundance 00062 { 00063 class PeanoMesh2D : public MeshBase{ 00064 public: 00065 00066 /** 00067 * The constuctor for the Peano grid*/ 00068 PeanoMesh2D(int dim, 00069 const MPIComm& comm, 00070 const MeshEntityOrder& order); 00071 00072 /** 00073 * The constuctor for the Peano grid in 2D*/ 00074 void createMesh( 00075 double position_x, 00076 double position_y, 00077 double offset_x, 00078 double offset_y, 00079 double resolution); 00080 00081 /** Dtor */ 00082 virtual ~PeanoMesh2D(); 00083 00084 /** 00085 * Get the number of cells having dimension dim 00086 */ 00087 virtual int numCells(int dim) const; 00088 00089 /** 00090 * Return the position of the i-th node 00091 */ 00092 virtual Point nodePosition(int i) const; 00093 00094 /** 00095 * Return a view of the i-th node's position 00096 */ 00097 const double* nodePositionView(int i) const; 00098 00099 00100 00101 /** 00102 * Compute the jacobians of a batch of cells, returning the 00103 * result via reference argument 00104 * 00105 * @param cellDim dimension of the cells whose Jacobians are to 00106 * be computed 00107 * @param cellLID local indices of the cells for which Jacobians 00108 * are to be computed 00109 * @param jBatch reference to the resulting Jacobian batch 00110 */ 00111 virtual void getJacobians(int cellDim, const Array<int>& cellLID, 00112 CellJacobianBatch& jBatch) const; 00113 00114 /** 00115 * Compute the diameters of a batch of cells, 00116 * result via reference argument 00117 * 00118 * @param cellDim dimension of the cells whose diameters are to 00119 * be computed 00120 * @param cellLID local indices of the cells for which diameters 00121 * are to be computed 00122 * @param diameters reference to the array of cell diameters 00123 */ 00124 virtual void getCellDiameters(int cellDim, const Array<int>& cellLID, 00125 Array<double>& cellDiameters) const; 00126 00127 00128 /** 00129 * Map reference quadrature points to physical points on the 00130 * given cells. 00131 */ 00132 virtual void pushForward(int cellDim, const Array<int>& cellLID, 00133 const Array<Point>& refQuadPts, 00134 Array<Point>& physQuadPts) const; 00135 00136 /** 00137 * Return the rank of the processor that owns the given cell 00138 */ 00139 virtual int ownerProcID(int cellDim, int cellLID) const; 00140 00141 /** 00142 * Return the number of facets of the given cell 00143 */ 00144 virtual int numFacets(int cellDim, int cellLID, 00145 int facetDim) const; 00146 00147 /** 00148 * Return the local ID of a facet cell 00149 * @param cellDim dimension of the cell whose facets are being obtained 00150 * @param cellLID local index of the cell whose 00151 * facets are being obtained 00152 * @param facetDim dimension of the desired facet 00153 * @param facetIndex index into the list of the cell's facets 00154 * @param facetOrientation orientation of the facet as seen from 00155 * the given cell (returned via reference) 00156 */ 00157 virtual int facetLID(int cellDim, int cellLID, 00158 int facetDim, int facetIndex, 00159 int& facetOrientation) const; 00160 00161 /** 00162 * Return by reference argument an array containing&(elemVerts_.value(cellLID, 0)) 00163 * the LIDs of the facetDim-dimensional facets of the 00164 * given batch of cells 00165 */ 00166 virtual void getFacetLIDs(int cellDim, 00167 const Array<int>& cellLID, 00168 int facetDim, 00169 Array<int>& facetLID, 00170 Array<int>& facetSign) const; 00171 00172 /** 00173 * Return a view of an element's zero-dimensional facets, 00174 * @return an array of integers with the indexes of the points which for it 00175 */ 00176 const int* elemZeroFacetView(int cellLID) const; 00177 00178 /** 00179 * Return the number of maximal cofacets of the given cell 00180 */ 00181 virtual int numMaxCofacets(int cellDim, int cellLID) const; 00182 00183 /** 00184 * Return the local ID of a maximal cofacet cell 00185 * @param cellDim dimension of the cell whose cofacets are being obtained 00186 * @param cellLID local index of the cell whose 00187 * cofacets are being obtained 00188 * @param cofacetIndex which maximal cofacet to get 00189 * @param facetIndex index of the cell cellLID into the list of the 00190 * maximal cell's facets 00191 */ 00192 virtual int maxCofacetLID(int cellDim, int cellLID, 00193 int cofacetIndex, 00194 int& facetIndex) const; 00195 /** 00196 * Get the LIDs of the maximal cofacets for a batch of codimension-one 00197 * cells. 00198 * 00199 * \param cellLIDs [in] array of LIDs of the cells whose cofacets are 00200 * being obtained 00201 * \param cofacets [out] the batch of cofacets 00202 */ 00203 virtual void getMaxCofacetLIDs(const Array<int>& cellLIDs, 00204 MaximalCofacetBatch& cofacets) const; 00205 00206 00207 /** 00208 * Find the cofacets of the given cell 00209 * @param cellDim dimension of the cell whose cofacets are being obtained 00210 * @param cellLID local index of the cell whose 00211 * cofacets are being obtained 00212 * @param cofacetDim dimension of the cofacets to get 00213 * @param cofacetLIDs LIDs of the cofacet 00214 */ 00215 void getCofacets(int cellDim, int cellLID, 00216 int cofacetDim, Array<int>& cofacetLIDs) const; 00217 00218 /** 00219 * Find the local ID of a cell given its global index 00220 */ 00221 virtual int mapGIDToLID(int cellDim, int globalIndex) const; 00222 00223 /** 00224 * Determine whether a given cell GID exists on this processor 00225 */ 00226 virtual bool hasGID(int cellDim, int globalIndex) const; 00227 00228 00229 /** 00230 * Find the global ID of a cell given its local index 00231 */ 00232 virtual int mapLIDToGID(int cellDim, int localIndex) const; 00233 00234 /** 00235 * Get the type of the given cell 00236 */ 00237 virtual CellType cellType(int cellDim) const; 00238 00239 00240 /** Get the label of the given cell */ 00241 virtual int label(int cellDim, int cellLID) const; 00242 00243 /** Get the labels for a batch of cells */ 00244 virtual void getLabels(int cellDim, const Array<int>& cellLID, 00245 Array<int>& labels) const; 00246 00247 00248 00249 /** Get the list of all labels defined for cells of the given dimension */ 00250 virtual Set<int> getAllLabelsForDimension(int cellDim) const; 00251 00252 /** 00253 * Get the cells associated with a specified label. The array 00254 * cellLID will be filled with those cells of dimension cellDim 00255 * having the given label. 00256 */ 00257 virtual void getLIDsForLabel(int cellDim, int label, Array<int>& cellLIDs) const; 00258 00259 00260 /** Set the label of the given cell */ 00261 virtual void setLabel(int cellDim, int cellLID, int label); 00262 00263 /** Coordinate intermediate cell definitions across processors */ 00264 virtual void assignIntermediateCellGIDs(int cellDim); 00265 00266 /** */ 00267 virtual bool hasIntermediateGIDs(int dim) const; 00268 00269 00270 private: 00271 00272 /** The dimension of the grid*/ 00273 int _dimension; 00274 00275 /** The communicator */ 00276 const MPIComm& _comm; 00277 00278 /** This pointer is the pointer to the 2 dimensional Peano mesh*/ 00279 SundancePeanoInterface2D *_peanoMesh; 00280 00281 /** The unique resolution in each dimension */ 00282 double _uniqueResolution; 00283 00284 /** The Point which is used as a returned argument */ 00285 static Point returnPoint; 00286 00287 }; 00288 } 00289 00290 #endif /* HAVE_SUNDANCE_PEANO */ 00291 #endif /* SUNDANCEPEANOMESH2D_H_ */