QuadraturePointsGroup.cpp

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 #include "QuadraturePointsGroup.hpp"
00030 
00031 template<unsigned DIM>
00032 QuadraturePointsGroup<DIM>::QuadraturePointsGroup(TetrahedralMesh<DIM,DIM>& rMesh,
00033                           GaussianQuadratureRule<DIM>& rQuadRule)
00034 {
00035     mNumElements = rMesh.GetNumElements();
00036     mNumQuadPointsPerElement = rQuadRule.GetNumQuadPoints();
00037     data.resize(mNumElements*mNumQuadPointsPerElement, zero_vector<double>(DIM));
00038 
00039     // loop over elements
00040     for (unsigned elem_index=0; elem_index<rMesh.GetNumElements(); elem_index++)
00041     {
00042         Element<DIM,DIM>& r_elem = *(rMesh.GetElement(elem_index));
00043 
00044         c_vector<double, DIM+1> linear_phi;
00045         for (unsigned quad_index=0; quad_index<rQuadRule.GetNumQuadPoints(); quad_index++)
00046         {
00047             const ChastePoint<DIM>& quadrature_point = rQuadRule.rGetQuadPoint(quad_index);
00048 
00049             LinearBasisFunction<DIM>::ComputeBasisFunctions(quadrature_point, linear_phi);
00050 
00051             // interpolate to calculate quad point
00052             c_vector<double,DIM> X = zero_vector<double>(DIM);
00053             for (unsigned node_index=0; node_index<DIM+1; node_index++)
00054             {
00055                 X += linear_phi(node_index)*rMesh.GetNode( r_elem.GetNodeGlobalIndex(node_index) )->rGetLocation();
00056             }
00057 
00058             // save the quad point
00059             assert(elem_index<mNumElements);
00060             assert(quad_index<mNumQuadPointsPerElement);
00061             data[ elem_index*mNumQuadPointsPerElement + quad_index ] = X;
00062         }
00063     }
00064 }
00065 
00066 template<unsigned DIM>
00067 c_vector<double,DIM>& QuadraturePointsGroup<DIM>::Get(unsigned elementIndex, unsigned quadIndex)
00068 {
00069     assert(elementIndex<mNumElements);
00070     assert(quadIndex<mNumQuadPointsPerElement);
00071     return data[ elementIndex*mNumQuadPointsPerElement + quadIndex ];
00072 }
00073 
00074 template<unsigned DIM>
00075 c_vector<double,DIM>& QuadraturePointsGroup<DIM>::Get(unsigned i)
00076 {
00077     assert(i < mNumElements*mNumQuadPointsPerElement);
00078     return data[i];
00079 }
00080 
00081 template<unsigned DIM>
00082 unsigned QuadraturePointsGroup<DIM>::GetNumElements() const
00083 {
00084     return mNumElements;
00085 }
00086 
00087 template<unsigned DIM>
00088 unsigned QuadraturePointsGroup<DIM>::GetNumQuadPointsPerElement() const
00089 {
00090     return mNumQuadPointsPerElement;
00091 }
00092 
00093 template<unsigned DIM>
00094 unsigned QuadraturePointsGroup<DIM>::Size() const
00095 {
00096     return mNumElements*mNumQuadPointsPerElement;
00097 }
00098 
00100 // Explicit instantiation
00102 
00103 template class QuadraturePointsGroup<1>;
00104 template class QuadraturePointsGroup<2>;
00105 template class QuadraturePointsGroup<3>;

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