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 
00040 //#define FINECOARSEMESHPAIR_VERBOSE
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     TetrahedralMesh<DIM,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 //    /** 4 values, 
00131 //     *   [0] number of points for which the containing element was found quickly (the element was
00132 //     *       in the same box as the point, 
00133 //     *   [1] number of points for which the containing element was found more slowly (the element 
00134 //     *       was not the same box as the point, but one of the neighbouring boxes), 
00135 //     *   [2] num points found very slowly (the elemment was not in a neighbouring box, but somewhere else)
00136 //     *   [3] num points not in the searched mesh at all 
00137 //     * 
00138 //     *  Note mCounters[3] = mNotInMesh.size() = mNotInMeshNearestElementWeights.size();
00139 //     */
00140 //    std::vector<unsigned> mStatisticsCounters;
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, TetrahedralMesh<DIM,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 /*FINECOARSEMESHPAIR_HPP_*/

Generated on Mon Apr 18 11:35:36 2011 for Chaste by  doxygen 1.5.5