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 #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
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
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
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
00102
00103 template class QuadraturePointsGroup<1>;
00104 template class QuadraturePointsGroup<2>;
00105 template class QuadraturePointsGroup<3>;