Commit ded27d03 authored by Praetorius, Simon's avatar Praetorius, Simon

DOFConstIterator

parent eccc8043
......@@ -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;
......
......@@ -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)
......
......@@ -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,
......
......@@ -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]);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment