diff --git a/AMDiS/src/DOFIndexed.h b/AMDiS/src/DOFIndexed.h index 46238a1cd0402c02e2dc313f28ef122204d992e0..494cc41fc74b9f2e11fdc5d17c24e05f8abd0567 100644 --- a/AMDiS/src/DOFIndexed.h +++ b/AMDiS/src/DOFIndexed.h @@ -92,21 +92,30 @@ namespace AMDiS { template<typename T> class DOFIndexed : public DOFIndexedBase { - public: + public: // typedefs typedef T value_type; typedef DegreeOfFreedom size_type; typedef value_type& reference; typedef value_type const& const_reference; + + typedef typename std::vector<value_type>::iterator iterator; + typedef typename std::vector<value_type>::const_iterator const_iterator; public: virtual ~DOFIndexed() {} /// Returns iterator to the begin of container - virtual typename std::vector<value_type>::iterator begin() = 0; + virtual iterator begin() = 0; /// Returns iterator to the end of container - virtual typename std::vector<value_type>::iterator end() = 0; + virtual iterator end() = 0; + + /// Returns iterator to the begin of container + virtual const_iterator begin() const = 0; + /// Returns iterator to the end of container + virtual const_iterator end() const = 0; + /// Returns container element at index i virtual reference operator[](size_type i) = 0; diff --git a/AMDiS/src/DOFMatrix.h b/AMDiS/src/DOFMatrix.h index cb07a5a337f9e9cb4d63db027131c8c936e5f613..7a687267ffb386d39ab79b4094a9ac13b0fe4e14 100644 --- a/AMDiS/src/DOFMatrix.h +++ b/AMDiS/src/DOFMatrix.h @@ -114,6 +114,19 @@ namespace AMDiS { ERROR_EXIT("Shouldn't be used, only fake."); vector<bool> v; return v.end(); } + + // Only to get rid of the abstract functions, I hope they are not used + vector<bool>::const_iterator begin() const + { + ERROR_EXIT("Shouldn't be used, only fake."); vector<bool> v; + return v.begin(); + } + + vector<bool>::const_iterator end() const + { + ERROR_EXIT("Shouldn't be used, only fake."); vector<bool> v; + return v.end(); + } bool dummy; // Must be deleted later bool& operator[](int i) diff --git a/AMDiS/src/DOFVector.h b/AMDiS/src/DOFVector.h index 993f92b6fc17b8e821849d264c69cccc20841d76..031835ef52126abb73be239618b8e4b61a2bdf9d 100644 --- a/AMDiS/src/DOFVector.h +++ b/AMDiS/src/DOFVector.h @@ -392,7 +392,19 @@ namespace AMDiS { { return vec.end(); } - + + /// Returns const_iterator to the begin of \ref vec + typename vector<T>::const_iterator begin() const + { + return vec.begin(); + } + + /// Returns const_iterator to the end of \ref vec + typename vector<T>::const_iterator end() const + { + return vec.end(); + } + /// Used by DOFAdmin to compress this DOFVector. Implementation of /// \ref DOFIndexedBase::compress() virtual void compressDOFIndexed(int first, int last, diff --git a/AMDiS/src/SecondOrderTerm.cc b/AMDiS/src/SecondOrderTerm.cc index 80edf2615214e91e49b450790b05477526eb7335..2c3bd0c42a1056b1ecbe32c25d5cee76b44cf169 100644 --- a/AMDiS/src/SecondOrderTerm.cc +++ b/AMDiS/src/SecondOrderTerm.cc @@ -268,7 +268,7 @@ namespace AMDiS { Vec2AtQP_SOT::Vec2AtQP_SOT(DOFVectorBase<double> *dv1, DOFVectorBase<double> *dv2, BinaryAbstractFunction<double, double, double> *af) - : SecondOrderTerm(af->getDegree()), vec1(dv1), vec2(dv2), f(af) + : SecondOrderTerm(af ? af->getDegree() : 2*dv1->getFeSpace()->getBasisFcts()->getDegree()), vec1(dv1), vec2(dv2), f(af) { setSymmetric(true); @@ -293,8 +293,12 @@ namespace AMDiS { const DimVec<WorldVector<double> > &grdLambda = elInfo->getGrdLambda(); const int nPoints = static_cast<int>(LALt.size()); - for (int iq = 0; iq < nPoints; iq++) - l1lt(grdLambda, LALt[iq], (*f)(vecAtQPs1[iq], vecAtQPs2[iq])); + for (int iq = 0; iq < nPoints; iq++) { + if (f) + l1lt(grdLambda, LALt[iq], (*f)(vecAtQPs1[iq], vecAtQPs2[iq])); + else + l1lt(grdLambda, LALt[iq], vecAtQPs1[iq] * vecAtQPs2[iq]); + } } void Vec2AtQP_SOT::eval(int nPoints, @@ -308,7 +312,11 @@ namespace AMDiS { if (num_rows(D2UhAtQP) > 0) { for (int iq = 0; iq < nPoints; iq++) { - double factor = (*f)(vecAtQPs1[iq], vecAtQPs2[iq]); + double factor = 1.0; + if (f) + factor = (*f)(vecAtQPs1[iq], vecAtQPs2[iq]); + else + factor = vecAtQPs1[iq] * vecAtQPs2[iq]; double resultQP = 0.0; for (int i = 0; i < dow; i++) resultQP += D2UhAtQP[iq][i][i]; @@ -322,7 +330,11 @@ namespace AMDiS { { int nPoints = grdUhAtQP.size(); for (int iq = 0; iq < nPoints; iq++) { - double factor = (*f)(vecAtQPs1[iq], vecAtQPs2[iq]); + double factor = 1.0; + if (f) + factor = (*f)(vecAtQPs1[iq], vecAtQPs2[iq]); + else + factor = vecAtQPs1[iq] * vecAtQPs2[iq]; axpy(factor, grdUhAtQP[iq], result[iq]); } }