FineCoarseMeshPair.hpp
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
00047 template<unsigned DIM>
00048 struct ElementAndWeights
00049 {
00050 unsigned ElementNum;
00051 c_vector<double,DIM+1> Weights;
00052 };
00053
00096 template <unsigned DIM>
00097 class FineCoarseMeshPair
00098 {
00099 friend class TestFineCoarseMeshPair;
00100
00101 private:
00102
00104 TetrahedralMesh<DIM,DIM>& mrFineMesh;
00105
00107 TetrahedralMesh<DIM,DIM>& mrCoarseMesh;
00108
00112 BoxCollection<DIM>* mpFineMeshBoxCollection;
00113
00118 BoxCollection<DIM>* mpCoarseMeshBoxCollection;
00119
00125 std::vector<ElementAndWeights<DIM> > mFineMeshElementsAndWeights;
00126
00128 std::vector<unsigned> mNotInMesh;
00129
00134 std::vector<c_vector<double,DIM+1> > mNotInMeshNearestElementWeights;
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00157 std::vector<unsigned> mStatisticsCounters;
00158
00164 std::vector<unsigned> mCoarseElementsForFineNodes;
00165
00171 std::vector<unsigned> mCoarseElementsForFineElementCentroids;
00172
00182 void ComputeFineElementAndWeightForGivenPoint(ChastePoint<DIM>& rPoint,
00183 bool safeMode,
00184 unsigned boxForThisPoint,
00185 unsigned index);
00186
00194 unsigned ComputeCoarseElementForGivenPoint(ChastePoint<DIM>& rPoint,
00195 bool safeMode,
00196 unsigned boxForThisPoint);
00197
00208 void SetUpBoxes(TetrahedralMesh<DIM,DIM>& rMesh,
00209 double boxWidth,
00210 BoxCollection<DIM>*& rpBoxCollection);
00211
00222 void CollectElementsInContainingBox(BoxCollection<DIM>*& rpBoxCollection,
00223 unsigned boxIndex,
00224 std::set<unsigned>& rElementIndices);
00235 void CollectElementsInLocalBoxes(BoxCollection<DIM>*& rpBoxCollection,
00236 unsigned boxIndex,
00237 std::set<unsigned>& rElementIndices);
00238
00243 void ResetStatisticsVariables();
00244
00245 public:
00246
00253 FineCoarseMeshPair(TetrahedralMesh<DIM,DIM>& rFineMesh, TetrahedralMesh<DIM,DIM>& rCoarseMesh);
00254
00258 ~FineCoarseMeshPair();
00259
00272 void SetUpBoxesOnFineMesh(double boxWidth = -1);
00273
00286 void SetUpBoxesOnCoarseMesh(double boxWidth = -1);
00287
00305 void ComputeFineElementsAndWeightsForCoarseQuadPoints(GaussianQuadratureRule<DIM>& rQuadRule,
00306 bool safeMode);
00307
00322 void ComputeFineElementsAndWeightsForCoarseNodes(bool safeMode);
00323
00336 void PrintStatistics();
00337
00348 void ComputeCoarseElementsForFineNodes(bool safeMode);
00349
00361 void ComputeCoarseElementsForFineElementCentroids(bool safeMode);
00362
00366 std::vector<ElementAndWeights<DIM> >& rGetElementsAndWeights()
00367 {
00368 return mFineMeshElementsAndWeights;
00369 }
00370
00375 std::vector<unsigned>& rGetCoarseElementsForFineNodes()
00376 {
00377 assert(mCoarseElementsForFineNodes.size() > 0);
00378 return mCoarseElementsForFineNodes;
00379 }
00380
00385 std::vector<unsigned>& rGetCoarseElementsForFineElementCentroids()
00386 {
00387 assert(mCoarseElementsForFineElementCentroids.size() > 0);
00388 return mCoarseElementsForFineElementCentroids;
00389 }
00390
00395 void DeleteFineBoxCollection();
00396
00401 void DeleteCoarseBoxCollection();
00402 };
00403
00404 #endif