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 #ifndef FINECOARSEMESHPAIR_HPP_
00030 #define FINECOARSEMESHPAIR_HPP_
00031
00032 #include "TetrahedralMesh.hpp"
00033 #include "QuadraticMesh.hpp"
00034 #include "BoxCollection.hpp"
00035 #include "QuadraturePointsGroup.hpp"
00036 #include "GaussianQuadratureRule.hpp"
00037 #include "Warnings.hpp"
00038
00039
00040
00041
00042
00049 template<unsigned DIM>
00050 struct ElementAndWeights
00051 {
00052 unsigned ElementNum;
00053 c_vector<double,DIM+1> Weights;
00054 };
00055
00056
00100 template <unsigned DIM>
00101 class FineCoarseMeshPair
00102 {
00103 friend class TestFineCoarseMeshPair;
00104
00105 private:
00107 TetrahedralMesh<DIM,DIM>& mrFineMesh;
00108
00110 QuadraticMesh<DIM>& mrCoarseMesh;
00111
00113 BoxCollection<DIM>* mpFineMeshBoxCollection;
00114
00116 BoxCollection<DIM>* mpCoarseMeshBoxCollection;
00117
00121 std::vector<ElementAndWeights<DIM> > mFineMeshElementsAndWeights;
00122
00124 std::vector<unsigned> mNotInMesh;
00125
00128 std::vector<c_vector<double,DIM+1> > mNotInMeshNearestElementWeights;
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00150 std::vector<unsigned> mStatisticsCounters;
00151
00152
00157 std::vector<unsigned> mCoarseElementsForFineNodes;
00158
00163 std::vector<unsigned> mCoarseElementsForFineElementCentroids;
00164
00172 void ComputeFineElementAndWeightForGivenPoint(ChastePoint<DIM>& rPoint,
00173 bool safeMode,
00174 unsigned boxForThisPoint,
00175 unsigned index);
00176
00177
00184 unsigned ComputeCoarseElementForGivenPoint(ChastePoint<DIM>& rPoint,
00185 bool safeMode,
00186 unsigned boxForThisPoint);
00187
00198 void SetUpBoxes(TetrahedralMesh<DIM,DIM>& rMesh,
00199 double boxWidth,
00200 BoxCollection<DIM>*& rpBoxCollection);
00201
00202
00212 void CollectElementsInContainingBox(BoxCollection<DIM>*& rpBoxCollection,
00213 unsigned boxIndex,
00214 std::set<unsigned>& rElementIndices);
00224 void CollectElementsInLocalBoxes(BoxCollection<DIM>*& rpBoxCollection,
00225 unsigned boxIndex,
00226 std::set<unsigned>& rElementIndices);
00227
00228
00233 void ResetStatisticsVariables();
00234
00235
00236 public:
00241 FineCoarseMeshPair(TetrahedralMesh<DIM,DIM>& rFineMesh, QuadraticMesh<DIM>& rCoarseMesh);
00242
00246 ~FineCoarseMeshPair();
00247
00260 void SetUpBoxesOnFineMesh(double boxWidth = -1);
00261
00274 void SetUpBoxesOnCoarseMesh(double boxWidth = -1);
00275
00276
00294 void ComputeFineElementsAndWeightsForCoarseQuadPoints(GaussianQuadratureRule<DIM>& rQuadRule,
00295 bool safeMode);
00296
00311 void ComputeFineElementsAndWeightsForCoarseNodes(bool safeMode);
00312
00313
00324 void PrintStatistics();
00325
00326
00337 void ComputeCoarseElementsForFineNodes(bool safeMode);
00338
00350 void ComputeCoarseElementsForFineElementCentroids(bool safeMode);
00351
00355 std::vector<ElementAndWeights<DIM> >& rGetElementsAndWeights()
00356 {
00357 return mFineMeshElementsAndWeights;
00358 }
00359
00360
00365 std::vector<unsigned>& rGetCoarseElementsForFineNodes()
00366 {
00367 assert(mCoarseElementsForFineNodes.size()>0);
00368 return mCoarseElementsForFineNodes;
00369 }
00370
00375 std::vector<unsigned>& rGetCoarseElementsForFineElementCentroids()
00376 {
00377 assert(mCoarseElementsForFineElementCentroids.size()>0);
00378 return mCoarseElementsForFineElementCentroids;
00379 }
00380
00385 void DeleteFineBoxCollection();
00386
00391 void DeleteCoarseBoxCollection();
00392 };
00393
00394 #endif