FineCoarseMeshPair.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
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 //#define FINECOARSEMESHPAIR_VERBOSE
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 //    /** 4 values,
00137 //     *   [0] number of points for which the containing element was found quickly (the element was
00138 //     *       in the same box as the point,
00139 //     *   [1] number of points for which the containing element was found more slowly (the element
00140 //     *       was not the same box as the point, but one of the neighbouring boxes),
00141 //     *   [2] num points found very slowly (the elemment was not in a neighbouring box, but somewhere else)
00142 //     *   [3] num points not in the searched mesh at all
00143 //     *
00144 //     *  Note mCounters[3] = mNotInMesh.size() = mNotInMeshNearestElementWeights.size();
00145 //     */
00146 //    std::vector<unsigned> mStatisticsCounters;
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 /*FINECOARSEMESHPAIR_HPP_*/
Generated on Thu Dec 22 13:00:17 2011 for Chaste by  doxygen 1.6.3