Commit 850d8dbe by Thomas Witkowski

### Fixed a problem with virtual function in ProblemInstat, rewritten BasisFct::interpol

parent 27106dcf
 ... ... @@ -181,7 +181,7 @@ namespace AMDiS { virtual DimVec *getCoords(int i) const = 0; /** \brief * Returns a pointer to a const vector with interpolation coefficients of the * Fills a vector with interpolation coefficients of the * function f; if indices is a pointer to NULL, the coefficient for all * basis functions are calculated and the i-th entry in the vector is the * coefficient of the i-th basis function; if indices is non NULL, only the ... ... @@ -197,16 +197,18 @@ namespace AMDiS { * during mesh traversal. * Must be implemented by sub classes. */ virtual const double* interpol(const ElInfo *el_info, int n, const int *indices, virtual void interpol(const ElInfo *el_info, int n, const int *indices, AbstractFunction > *f, double *coeff) = 0; mtl::dense_vector &coeff) const = 0; /// WorldVector valued interpol function. virtual const WorldVector* interpol(const ElInfo *el_info, int no, virtual void interpol(const ElInfo *el_info, int no, const int *b_no, AbstractFunction, WorldVector > *f, WorldVector *vec) = 0; mtl::dense_vector >& coeff) const = 0; /// Returns the i-th local basis function inline BasFctType *getPhi(int i) const ... ...
 ... ... @@ -572,9 +572,6 @@ namespace AMDiS { /// Returns the average value of the DOFVector. T average() const; /// Used by interpol while mesh traversal. void interpolFct(ElInfo* elinfo); /// Prints \ref vec to stdout. void print() const; ... ... @@ -641,12 +638,6 @@ namespace AMDiS { /// Specifies what operation should be performed after coarsening CoarsenOperation coarsenOperation; /// Used by \ref interpol AbstractFunction > *interFct; /// Used for mesh traversal static DOFVector *traverseVector; }; ... ... @@ -795,7 +786,7 @@ namespace AMDiS { // y = a*x + y template void axpy(double a,const DOFVector& x, DOFVector& y); void axpy(double a, const DOFVector& x, DOFVector& y); // matrix vector product template ... ... @@ -856,6 +847,12 @@ namespace AMDiS { return vec->getUsedSize(); } template inline int size(const DOFVector& vec) { return vec.getUsedSize(); } template inline void checkFeSpace(const FiniteElemSpace* feSpace, const std::vector& vec) { ... ...
 ... ... @@ -132,9 +132,6 @@ namespace AMDiS { vec.clear(); } template DOFVector * DOFVector::traverseVector = NULL; template void DOFVectorBase::addElementVector(T factor, const ElementVector &elVec, ... ... @@ -450,8 +447,6 @@ namespace AMDiS { TEST_EXIT_DBG(fct)("No function to interpolate!\n"); interFct = fct; if (!this->getFeSpace()) { MSG("no dof admin in vec %s, skipping interpolation\n", this->getName().c_str()); ... ... @@ -476,33 +471,24 @@ namespace AMDiS { return; } traverseVector = this; const BasisFunction *basFct = this->getFeSpace()->getBasisFcts(); const DOFAdmin* admin = this->getFeSpace()->getAdmin(); int nBasFcts = basFct->getNumber(); std::vector myLocalIndices(nBasFcts); mtl::dense_vector fctInterpolValues(nBasFcts); TraverseStack stack; ElInfo *elInfo = stack.traverseFirst(this->getFeSpace()->getMesh(), -1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS); while (elInfo) { interpolFct(elInfo); elInfo = stack.traverseNext(elInfo); } } template void DOFVector::interpolFct(ElInfo* elinfo) { const BasisFunction *basFct = traverseVector->getFeSpace()->getBasisFcts(); const DOFAdmin* admin = traverseVector->getFeSpace()->getAdmin(); const T *inter_val = const_cast(basFct)->interpol(elinfo, 0, NULL, traverseVector->interFct, NULL); int nBasFcts = basFct->getNumber(); std::vector myLocalIndices(nBasFcts); basFct->getLocalIndices(const_cast(elinfo->getElement()), basFct->interpol(elInfo, 0, NULL, fct, fctInterpolValues); basFct->getLocalIndices(const_cast(elInfo->getElement()), admin, myLocalIndices); for (int i = 0; i < nBasFcts; i++) (*traverseVector)[myLocalIndices[i]] = inter_val[i]; vec[myLocalIndices[i]] = fctInterpolValues[i]; elInfo = stack.traverseNext(elInfo); } } ... ... @@ -1047,7 +1033,6 @@ namespace AMDiS { this->nBasFcts = rhs.nBasFcts; vec = rhs.vec; this->elementVector.change_dim(this->nBasFcts); interFct = rhs.interFct; coarsenOperation = rhs.coarsenOperation; this->operators = rhs.operators; this->operatorFactor = rhs.operatorFactor; ... ...
 ... ... @@ -811,42 +811,20 @@ namespace AMDiS { } const double* Lagrange::interpol(const ElInfo *el_info, int no, const int *b_no, void Lagrange::interpol(const ElInfo *el_info, int no, const int *b_no, AbstractFunction > *f, double *vec) mtl::dense_vector &rvec) const { FUNCNAME("Lagrange::interpol()"); static double* localVec = NULL; static int localVecSize = 0; double *rvec = NULL; if (vec) { rvec = vec; } else { if (localVec && nBasFcts > localVecSize) { delete [] localVec; localVec = new double[nBasFcts]; } if (!localVec) localVec = new double[nBasFcts]; localVecSize = nBasFcts; rvec = localVec; } WorldVector x; el_info->testFlag(Mesh::FILL_COORDS); if (b_no) { if (no <= 0 || no > getNumber()) { ERROR("something is wrong, doing nothing\n"); rvec[0] = 0.0; return(const_cast(rvec)); } TEST_EXIT_DBG(no >= 0 && no < getNumber())("Something is wrong!\n"); for (int i = 0; i < no; i++) { if (b_no[i] < Global::getGeo(VERTEX, dim)) { ... ... @@ -865,23 +843,17 @@ namespace AMDiS { rvec[i] = (*f)(x); } } return(const_cast( rvec)); } const WorldVector* Lagrange::interpol(const ElInfo *el_info, void Lagrange::interpol(const ElInfo *el_info, int no, const int *b_no, AbstractFunction, WorldVector > *f, WorldVector *vec) mtl::dense_vector > &rvec) const { FUNCNAME("*Lagrange::interpol_d()"); FUNCNAME("*Lagrange::interpol()"); static WorldVector *inter; WorldVector *rvec = vec ? vec : (inter ? inter : inter = new WorldVector[getNumber()]); WorldVector x; el_info->testFlag(Mesh::FILL_COORDS); ... ... @@ -889,12 +861,8 @@ namespace AMDiS { int vertices = Global::getGeo(VERTEX, dim); if (b_no) { if (no <= 0 || no > getNumber()) { ERROR("something is wrong, doing nothing\n"); for (int i = 0; i < dow; i++) rvec[0][i] = 0.0; return(const_cast *>( rvec)); } TEST_EXIT_DBG(no >= 0 && no < getNumber())("Something is wrong!\n"); for (int i = 0; i < no; i++) { if (b_no[i] < Global::getGeo(VERTEX, dim)) { rvec[i] = (*f)(el_info->getCoord(b_no[i])); ... ... @@ -911,8 +879,6 @@ namespace AMDiS { rvec[i] = (*f)(x); } } return(const_cast *>( rvec)); } ... ...
 ... ... @@ -64,16 +64,15 @@ namespace AMDiS { static Lagrange* getLagrange(int dim, int degree); /// Implements BasisFunction::interpol const double *interpol(const ElInfo *, int, const int *, void interpol(const ElInfo *, int, const int *, AbstractFunction >*, double *); mtl::dense_vector&) const; /// Implements BasisFunction::interpol const WorldVector *interpol(const ElInfo *, int, void interpol(const ElInfo *, int, const int *b_no, AbstractFunction, WorldVector >*, WorldVector *); AbstractFunction, WorldVector >*, mtl::dense_vector >&) const; /// Returns the barycentric coordinates of the i-th basis function. DimVec *getCoords(int i) const; ... ...