diff --git a/FunctionSpace/FunctionSpace.cpp b/FunctionSpace/FunctionSpace.cpp index be3e19b2606e914b800c7c82820977ce6cdce8fd..3a7d3fc537943896f6cc5be4c9a39c4d136b6fa7 100644 --- a/FunctionSpace/FunctionSpace.cpp +++ b/FunctionSpace/FunctionSpace.cpp @@ -1,4 +1,3 @@ -#include <limits.h> #include <sstream> #include "ReferenceSpaceManager.h" @@ -9,7 +8,6 @@ using namespace std; -const Dof FunctionSpace::rejectedDof(INT_MAX, INT_MAX); const size_t FunctionSpace::nGeoType = 9; size_t FunctionSpace::nxtOffset = 0; @@ -162,12 +160,15 @@ size_t FunctionSpace::findMaxType(void){ nDof = it->second[e].size(); for(size_t d = 0; d < nDof; d++){ - // This Dof Type - type = it->second[e][d].getType(); - - // If this Dof type is bigger, it becomes the new 'maxType' - if(type > maxType) - maxType = type; + // Check if not a RejectedDof + if(it->second[e][d] != Dof::RejectedDof()){ + // This Dof Type + type = it->second[e][d].getType(); + + // If this Dof type is bigger, it becomes the new 'maxType' + if(type > maxType) + maxType = type; + } } } } @@ -177,7 +178,7 @@ size_t FunctionSpace::findMaxType(void){ } void FunctionSpace::getUnorderedKeys(const MElement& elem, - std::vector<Dof>& dof, bool full) const{ + std::vector<Dof>& dof) const{ // Const_Cast // MElement& element = const_cast<MElement&>(elem); @@ -245,44 +246,21 @@ void FunctionSpace::getUnorderedKeys(const MElement& elem, it++; } - // Reject Keys or mark them rejected // - if(full) - markMyKeys(dof); - else - rejectKeys(dof); + // Mark rejected keys // + markKeys(dof); } -void FunctionSpace::rejectKeys(vector<Dof>& dof) const{ - // Temp list - list<Dof> tmp(dof.begin(), dof.end()); - - // Look in rejection map - list<Dof>::iterator end = tmp.end(); - list<Dof>::iterator it = tmp.begin(); - - while(it != end) - if(rejected.count(*it) == 1) - it = tmp.erase(it); - else - it++; +void FunctionSpace::markKeys(vector<Dof>& dof) const{ + if(rejected.size() != 0){ + const size_t nDof = dof.size(); - // Rebuild dof vector (if needed) - if(tmp.size() != dof.size()){ - dof.clear(); - dof.assign(tmp.begin(), tmp.end()); + for(size_t i = 0; i < nDof; i++) + if(rejected.count(dof[i]) == 1) + dof[i] = Dof::RejectedDof(); } } -void FunctionSpace::markMyKeys(vector<Dof>& dof) const{ - const size_t nDof = dof.size(); - - for(size_t i = 0; i < nDof; i++) - if(rejected.count(dof[i]) == 1) - dof[i] = rejectedDof; -} - -void FunctionSpace::getKeys(const MElement& elem, std::vector<Dof>& dof, - bool full) const{ +void FunctionSpace::getKeys(const MElement& elem, std::vector<Dof>& dof) const{ // Const_Cast // MElement& element = const_cast<MElement&>(elem); @@ -306,7 +284,7 @@ void FunctionSpace::getKeys(const MElement& elem, std::vector<Dof>& dof, MElement* permElement = factory.create(lowOrderTag, vertex, element.getNum()); // Get Dofs from permuted Element // - getUnorderedKeys(*permElement, dof, full); + getUnorderedKeys(*permElement, dof); // Free and Return // delete permElement; @@ -325,7 +303,8 @@ void FunctionSpace::getKeys(const GroupOfElement& goe, nDof = allDofs[i].size(); for(size_t j = 0; j < nDof; j++) - dof.insert(allDofs[i][j]); + if(allDofs[i][j] != Dof::RejectedDof()) + dof.insert(allDofs[i][j]); } } @@ -341,28 +320,3 @@ FunctionSpace::getKeys(const GroupOfElement& goe) const{ // Return vector // return it->second; } - -void FunctionSpace::delKeys(const GroupOfElement& goe, - std::set<Dof>& dof) const{ - // Get Dofs // - const vector<vector<Dof> >& allDofs = getKeys(goe); - - // Remove them from map // - const size_t size = allDofs.size(); - - set<Dof>::iterator end; - set<Dof>::iterator it; - size_t nDof; - - for(size_t i = 0; i < size; i++){ - nDof = allDofs[i].size(); - - for(size_t j = 0; j < nDof; j++){ - end = dof.end(); - it = dof.find(allDofs[i][j]); - - if(it != end) - dof.erase(it); - } - } -} diff --git a/FunctionSpace/FunctionSpace.h b/FunctionSpace/FunctionSpace.h index 4a7159abf576cd725af0ad65935e7edeee192005..269c474f92e821bf3e78914153e709cd3f8acf89 100644 --- a/FunctionSpace/FunctionSpace.h +++ b/FunctionSpace/FunctionSpace.h @@ -31,9 +31,6 @@ class GroupOfElement; class FunctionSpace{ protected: - // A Dof suposed to be rejected - static const Dof rejectedDof; - // Number of possible geomtrical topologies & Dof Type offset // static const size_t nGeoType; static size_t nxtOffset; @@ -78,8 +75,6 @@ class FunctionSpace{ void getKeys(const GroupOfElement& goe, std::set<Dof>& dof) const; const std::vector<std::vector<Dof> >& getKeys(const GroupOfElement& goe)const; - void delKeys(const GroupOfElement& goe, std::set<Dof>& dof) const; - protected: FunctionSpace(void); void build(const std::vector<const GroupOfElement*>& goe, @@ -92,11 +87,8 @@ class FunctionSpace{ size_t findMaxType(void); - void getUnorderedKeys(const MElement& element, std::vector<Dof>& dof, - bool full) const; - void rejectKeys(std::vector<Dof>& dof) const; - void markMyKeys(std::vector<Dof>& dof) const; - void getKeys(const MElement& element, std::vector<Dof>& dof, bool full) const; + void getUnorderedKeys(const MElement& element, std::vector<Dof>& dof) const; + void markKeys(std::vector<Dof>& dof) const; }; @@ -154,14 +146,6 @@ class FunctionSpace{ @param goe A GroupOfElement @return Returns a vector of vector of Dof such that: dof[i][j] is the jth Dof of the ith element of the given GroupOfElement - ** - - @fn void FunctionSpace::delKeys(const GroupOfElement&, std::set<Dof>&) const - @param goe A GroupOfElement - @param dof A set of Dof%s - - Removes from the given set the Dof%s associated to the MElement%s - of the given GroupOfElement */ ////////////////////// @@ -192,9 +176,4 @@ inline const Basis& FunctionSpace::getBasis(size_t eType) const{ return *basis[eType]; } -inline -void FunctionSpace::getKeys(const MElement& elem, std::vector<Dof>& dof) const{ - getKeys(elem, dof, false); -} - #endif diff --git a/FunctionSpace/FunctionSpaceScalar.cpp b/FunctionSpace/FunctionSpaceScalar.cpp index 4d2247a04f8b717ee895ec6bc2434f7a304f5d08..818d3b17fa261ebd1d0a40ff9f57b2bfd19bfe07 100644 --- a/FunctionSpace/FunctionSpaceScalar.cpp +++ b/FunctionSpace/FunctionSpaceScalar.cpp @@ -65,18 +65,16 @@ double FunctionSpaceScalar::interpolateInABC(const MElement& element, basis.getFunctions(fun, element, abc[0], abc[1], abc[2]); - // Get All Dofs (even those that are supposed to be rejected) + // Get All Dofs vector<Dof> myDof; - getKeys(element, myDof, true); + getKeys(element, myDof); // Interpolate (in Reference Place) // double val = 0; - for(size_t i = 0, j = 0; i < nFun; i++){ - if(myDof[i] != rejectedDof){ - val += fun(i, 0) * coef[j]; - j++; - } + for(size_t i = 0; i < nFun; i++){ + if(myDof[i] != Dof::RejectedDof()) + val += fun(i, 0) * coef[i]; } // Return Interpolated Value // @@ -99,9 +97,9 @@ interpolateDerivativeInABC(const MElement& element, basis.getDerivative(fun, element, abc[0], abc[1], abc[2]); - // Get All Dofs (even those that are supposed to be rejected) + // Get All Dofs vector<Dof> myDof; - getKeys(element, myDof, true); + getKeys(element, myDof); // Interpolate (in Reference Place) // fullMatrix<double> val(1, 3); @@ -109,13 +107,11 @@ interpolateDerivativeInABC(const MElement& element, val(0, 1) = 0; val(0, 2) = 0; - for(size_t i = 0, j = 0; i < nFun; i++){ - if(myDof[i] != rejectedDof){ - val(0, 0) += fun(i, 0) * coef[j]; - val(0, 1) += fun(i, 1) * coef[j]; - val(0, 2) += fun(i, 2) * coef[j]; - - j++; + for(size_t i = 0; i < nFun; i++){ + if(myDof[i] != Dof::RejectedDof()){ + val(0, 0) += fun(i, 0) * coef[i]; + val(0, 1) += fun(i, 1) * coef[i]; + val(0, 2) += fun(i, 2) * coef[i]; } } diff --git a/FunctionSpace/FunctionSpaceVector.cpp b/FunctionSpace/FunctionSpaceVector.cpp index 2f5f52667ad286dcdbf7be548d1d41e875152e13..efb0d83f6b61bf388020f27cb178595502372cbc 100644 --- a/FunctionSpace/FunctionSpaceVector.cpp +++ b/FunctionSpace/FunctionSpaceVector.cpp @@ -68,9 +68,9 @@ interpolateInABC(const MElement& element, basis.getFunctions(fun, element, abc[0], abc[1], abc[2]); - // Get All Dofs (even those that are supposed to be rejected) + // Get All Dofs vector<Dof> myDof; - getKeys(element, myDof, true); + getKeys(element, myDof); // Interpolate (in Reference Place) // fullMatrix<double> val(1, 3); @@ -78,13 +78,11 @@ interpolateInABC(const MElement& element, val(0, 1) = 0; val(0, 2) = 0; - for(size_t i = 0, j = 0; i < nFun; i++){ - if(myDof[i] != rejectedDof){ - val(0, 0) += fun(i, 0) * coef[j]; - val(0, 1) += fun(i, 1) * coef[j]; - val(0, 2) += fun(i, 2) * coef[j]; - - j++; + for(size_t i = 0; i < nFun; i++){ + if(myDof[i] != Dof::RejectedDof()){ + val(0, 0) += fun(i, 0) * coef[i]; + val(0, 1) += fun(i, 1) * coef[i]; + val(0, 2) += fun(i, 2) * coef[i]; } } @@ -110,9 +108,9 @@ interpolateDerivativeInABC(const MElement& element, basis.getDerivative(fun, element, abc[0], abc[1], abc[2]); - // Get All Dofs (even those that are supposed to be rejected) + // Get All Dofs vector<Dof> myDof; - getKeys(element, myDof, true); + getKeys(element, myDof); // Interpolate (in Reference Place) // fullMatrix<double> val(1, 3); @@ -120,13 +118,11 @@ interpolateDerivativeInABC(const MElement& element, val(0, 1) = 0; val(0, 2) = 0; - for(size_t i = 0, j = 0; i < nFun; i++){ - if(myDof[i] != rejectedDof){ - val(0, 0) += fun(i, 0) * coef[j]; - val(0, 1) += fun(i, 1) * coef[j]; - val(0, 2) += fun(i, 2) * coef[j]; - - j++; + for(size_t i = 0; i < nFun; i++){ + if(myDof[i] != Dof::RejectedDof()){ + val(0, 0) += fun(i, 0) * coef[i]; + val(0, 1) += fun(i, 1) * coef[i]; + val(0, 2) += fun(i, 2) * coef[i]; } }