00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef SUNDANCE_MESH_H
00032 #define SUNDANCE_MESH_H
00033
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceMeshBase.hpp"
00036 #include "SundanceMaximalCofacetBatch.hpp"
00037 #include "SundanceIncrementallyCreatableMesh.hpp"
00038 #include "SundanceIdentityReorderer.hpp"
00039 #include "SundanceCellReorderer.hpp"
00040 #include "PlayaHandle.hpp"
00041
00042 namespace Sundance
00043 {
00044 using namespace Teuchos;
00045
00046
00047
00048
00049
00050
00051
00052 class Mesh : public Playa::Handle<MeshBase>
00053 {
00054 public:
00055
00056
00057 HANDLE_CTORS(Mesh, MeshBase);
00058
00059
00060 int id() const {return ptr()->id();}
00061
00062
00063 const MeshEntityOrder& meshOrder() const {return ptr()->meshOrder();}
00064
00065
00066
00067
00068 int spatialDim() const {return ptr()->spatialDim();}
00069
00070
00071
00072
00073 int numCells(int dim) const {return ptr()->numCells(dim);}
00074
00075
00076
00077
00078 Point nodePosition(int i) const {return ptr()->nodePosition(i);}
00079
00080
00081
00082
00083 const double* nodePositionView(int i) const {return ptr()->nodePositionView(i);}
00084
00085
00086
00087
00088
00089 Point centroid(int cellDim, int cellLID) const
00090 {return ptr()->centroid(cellDim, cellLID);}
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 void outwardNormals(
00104 const Array<int>& cellLIDs,
00105 Array<Point>& outwardNormals
00106 ) const
00107 {ptr()->outwardNormals(cellLIDs, outwardNormals);}
00108
00109
00110
00111
00112
00113
00114
00115
00116 void tangentsToEdges(
00117 const Array<int>& cellLIDs,
00118 Array<Point>& tangentVectors
00119 ) const
00120 {ptr()->tangentsToEdges(cellLIDs, tangentVectors);}
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 void getJacobians(int cellDim, const Array<int>& cellLID,
00136 CellJacobianBatch& jBatch) const
00137 {ptr()->getJacobians(cellDim, cellLID, jBatch);}
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 virtual void getCellDiameters(int cellDim, const Array<int>& cellLID,
00150 Array<double>& diameters) const
00151 {ptr()->getCellDiameters(cellDim, cellLID, diameters);}
00152
00153
00154
00155
00156
00157
00158 void pushForward(int cellDim, const Array<int>& cellLID,
00159 const Array<Point>& refQuadPts,
00160 Array<Point>& physQuadPts) const
00161 {ptr()->pushForward(cellDim, cellLID, refQuadPts, physQuadPts);}
00162
00163
00164
00165
00166
00167
00168 int ownerProcID(int cellDim, int cellLID) const
00169 {return ptr()->ownerProcID(cellDim, cellLID);}
00170
00171
00172
00173
00174
00175 int numFacets(int cellDim, int cellLID,
00176 int facetDim) const
00177 {return ptr()->numFacets(cellDim, cellLID, facetDim);}
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 int facetLID(int cellDim, int cellLID,
00188 int facetDim, int facetIndex,
00189 int& facetOrientation) const
00190 {return ptr()->facetLID(cellDim, cellLID,
00191 facetDim, facetIndex,
00192 facetOrientation);}
00193
00194
00195
00196
00197
00198
00199 void getFacetArray(int cellDim, int cellLID, int facetDim,
00200 Array<int>& facetLIDs,
00201 Array<int>& facetOrientations) const
00202 {ptr()->getFacetArray(cellDim, cellLID,
00203 facetDim, facetLIDs,
00204 facetOrientations);}
00205
00206
00207
00208
00209 const int* elemZeroFacetView(int cellLID) const
00210 {return ptr()->elemZeroFacetView(cellLID);}
00211
00212
00213
00214
00215
00216
00217 void getFacetLIDs(int cellDim,
00218 const Array<int>& cellLID,
00219 int facetDim,
00220 Array<int>& facetLID,
00221 Array<int>& facetOrientations) const
00222 {ptr()->getFacetLIDs(cellDim, cellLID,
00223 facetDim, facetLID, facetOrientations);}
00224
00225
00226
00227
00228
00229 int numMaxCofacets(int cellDim, int cellLID) const
00230 {return ptr()->numMaxCofacets(cellDim, cellLID);}
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 int maxCofacetLID(int cellDim, int cellLID,
00243 int cofacetIndex,
00244 int& facetIndex) const
00245 {return ptr()->maxCofacetLID(cellDim, cellLID, cofacetIndex, facetIndex);}
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 void getMaxCofacetLIDs(const Array<int>& cellLIDs,
00256 MaximalCofacetBatch& cofacets) const
00257 {ptr()->getMaxCofacetLIDs(cellLIDs, cofacets);}
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 void getCofacets(int cellDim, int cellLID,
00270 int cofacetDim, Array<int>& cofacetLIDs) const
00271 {ptr()->getCofacets(cellDim, cellLID, cofacetDim, cofacetLIDs);}
00272
00273
00274
00275
00276 int mapGIDToLID(int cellDim, int globalIndex) const
00277 {return ptr()->mapGIDToLID(cellDim, globalIndex);}
00278
00279
00280
00281
00282 bool hasGID(int cellDim, int globalIndex) const
00283 {return ptr()->hasGID(cellDim, globalIndex);}
00284
00285
00286
00287
00288
00289
00290 int mapLIDToGID(int cellDim, int localIndex) const
00291 {return ptr()->mapLIDToGID(cellDim, localIndex);}
00292
00293
00294
00295
00296 CellType cellType(int cellDim) const
00297 {return ptr()->cellType(cellDim);}
00298
00299
00300 int label(int cellDim, int cellLID) const
00301 {return ptr()->label(cellDim, cellLID);}
00302
00303
00304 void getLabels(int cellDim, const Array<int>& cellLID, Array<int>& labels) const
00305 {ptr()->getLabels(cellDim, cellLID, labels);}
00306
00307
00308 void setLabel(int cellDim, int cellLID, int label)
00309 {ptr()->setLabel(cellDim, cellLID, label);}
00310
00311
00312 Set<int> getAllLabelsForDimension(int cellDim) const
00313 {return ptr()->getAllLabelsForDimension(cellDim);}
00314
00315
00316
00317
00318 virtual int numLabels(int cellDim) const
00319 {return getAllLabelsForDimension(cellDim).size();}
00320
00321
00322
00323
00324
00325
00326 void getLIDsForLabel(int cellDim, int label, Array<int>& cellLIDs) const
00327 {ptr()->getLIDsForLabel(cellDim, label, cellLIDs);}
00328
00329
00330 const MPIComm& comm() const {return ptr()->comm();}
00331
00332
00333
00334
00335 void estimateNumVertices(int nPts)
00336 {creatableMesh()->estimateNumVertices(nPts);}
00337
00338
00339 void estimateNumElements(int nElems)
00340 {creatableMesh()->estimateNumElements(nElems);}
00341
00342
00343
00344 int addVertex(int globalIndex, const Point& x,
00345 int ownerProcID, int label)
00346 {return creatableMesh()->addVertex(globalIndex, x, ownerProcID, label);}
00347
00348
00349 int addElement(int globalIndex, const Array<int>& vertLID,
00350 int ownerProcID, int label)
00351 {return creatableMesh()->addElement(globalIndex, vertLID,
00352 ownerProcID, label);}
00353
00354
00355
00356
00357
00358 void setReorderer(const CellReorderer& reorderer)
00359 {ptr()->setReorderer(reorderer);}
00360
00361
00362 const CellReordererImplemBase* reorderer() const
00363 {return ptr()->reorderer();}
00364
00365
00366
00367 static CellReorderer& defaultReorderer()
00368 {
00369 static CellReorderer rtn = new IdentityReorderer();
00370 return rtn;
00371 }
00372
00373
00374 void assignIntermediateCellGIDs(int cellDim)
00375 {
00376 if (!hasIntermediateGIDs(cellDim))
00377 ptr()->assignIntermediateCellGIDs(cellDim);
00378 }
00379
00380
00381 bool hasIntermediateGIDs(int cellDim) const
00382 {
00383 return ptr()->hasIntermediateGIDs(cellDim);
00384 }
00385
00386
00387 void dump(const std::string& filename) const ;
00388
00389
00390
00391
00392 bool checkConsistency(const std::string& filename) const ;
00393
00394
00395
00396
00397 bool checkConsistency(std::ostream& os) const ;
00398
00399
00400
00401
00402 bool allowsHangingHodes() const { return ptr()->allowsHangingHodes(); }
00403
00404
00405
00406 bool isElementHangingNode(int cellDim , int cellLID) const
00407 { return ptr()->isElementHangingNode(cellDim , cellLID); }
00408
00409
00410
00411 int indexInParent(int maxCellLID) const
00412 { return ptr()->indexInParent(maxCellLID); }
00413
00414
00415
00416 int maxChildren() const { return ptr()->maxChildren();}
00417
00418
00419 void returnParentFacets( int childCellLID , int dimFacets ,
00420 Array<int> &facetsLIDs , int &parentCellLIDs ) const {
00421 ptr()->returnParentFacets( childCellLID , dimFacets , facetsLIDs , parentCellLIDs );
00422 }
00423
00424
00425
00426
00427
00428
00429
00430 bool IsSpecialWeightValid() const {return ptr()->IsSpecialWeightValid();}
00431
00432
00433
00434 void setSpecialWeightValid(bool val) const { ptr()->setSpecialWeightValid(val);}
00435
00436
00437 void flushSpecialWeights() const { ptr()->flushSpecialWeights(); }
00438
00439
00440 bool hasSpecialWeight(int dim, int cellLID) const {return ptr()->hasSpecialWeight( dim, cellLID); }
00441
00442
00443 void setSpecialWeight(int dim, int cellLID, Array<double>& w) const {ptr()->setSpecialWeight(dim, cellLID, w);}
00444
00445
00446 void getSpecialWeight(int dim, int cellLID, Array<double>& w) const {ptr()->getSpecialWeight(dim, cellLID, w);}
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457 bool IsCurvePointsValid() const {return ptr()->IsCurvePointsValid();}
00458
00459
00460 void setCurvePointsValid(bool val) const {ptr()->setCurvePointsValid(val); }
00461
00462
00463 void flushCurvePoints() const { ptr()->flushCurvePoints(); }
00464
00465
00466 bool hasCurvePoints(int maxCellLID , int curveID) const { return ptr()->hasCurvePoints( maxCellLID , curveID); }
00467
00468
00469 void setCurvePoints(int maxCellLID, int curveID , Array<Point>& points , Array<Point>& derivs , Array<Point>& normals) const
00470 {ptr()->setCurvePoints( maxCellLID, curveID , points , derivs , normals); }
00471
00472
00473 void getCurvePoints(int maxCellLID, int curveID , Array<Point>& points , Array<Point>& derivs , Array<Point>& normals) const
00474 {ptr()->getCurvePoints( maxCellLID, curveID , points , derivs , normals); }
00475
00476
00477
00478 private:
00479
00480 IncrementallyCreatableMesh* creatableMesh();
00481
00482
00483
00484 bool checkVertexConsistency(std::ostream& os) const ;
00485
00486 bool checkCellConsistency(std::ostream& os, int dim) const ;
00487
00488
00489 bool checkRemoteEntity(std::ostream& os, int p, int dim, int gid,
00490 int owner, bool mustExist, int& lid) const ;
00491
00492
00493 bool testIdentity(std::ostream& os, int a, int b, const std::string& msg) const ;
00494
00495
00496 bool testIdentity(std::ostream& os,
00497 const Array<int>& a,
00498 const Array<int>& b, const std::string& msg) const ;
00499 };
00500 }
00501
00502 #endif