diff --git a/FunctionSpace/FunctionSpaceScalar.cpp b/FunctionSpace/FunctionSpaceScalar.cpp index 8936e00335e42aca34caf1e841fddf1ce5e55648..84759eff62ad8f89c80a7aef5807a331761b2789 100644 --- a/FunctionSpace/FunctionSpaceScalar.cpp +++ b/FunctionSpace/FunctionSpaceScalar.cpp @@ -8,6 +8,8 @@ FunctionSpaceScalar::FunctionSpaceScalar(void){ locPreEvaluated = false; gradPreEvaluated = false; + evalLoc = NULL; + evalGrad = NULL; } FunctionSpaceScalar::~FunctionSpaceScalar(void){ diff --git a/FunctionSpace/FunctionSpaceScalar.h b/FunctionSpace/FunctionSpaceScalar.h index f20368aa46125ba65c9477ff0f0352992c00c178..795ddbb152120af7bc6a13ca278df06c6e7be06b 100644 --- a/FunctionSpace/FunctionSpaceScalar.h +++ b/FunctionSpace/FunctionSpaceScalar.h @@ -157,7 +157,7 @@ class FunctionSpaceScalar : public FunctionSpace{ to the given element (with correct @em closure) @note - The returned values must be computed by + The returned values @em must be computed by FunctionSpaceScalar::preEvaluateLocalFunctions(), if not an Exception will be thrown ** @@ -169,7 +169,7 @@ class FunctionSpaceScalar : public FunctionSpace{ to the given element (with correct @em closure) @note - The returned values must be computed by + The returned values @em must be computed by FunctionSpaceScalar::preEvaluateGradLocalFunctions(), if not an Exception will be thrown */ diff --git a/FunctionSpace/FunctionSpaceVector.cpp b/FunctionSpace/FunctionSpaceVector.cpp index fc9b5337be9b7d7519263c7ec7676d549a22be25..c58f421b4f534cf34749f6259724c94ab66e801e 100644 --- a/FunctionSpace/FunctionSpaceVector.cpp +++ b/FunctionSpace/FunctionSpaceVector.cpp @@ -8,6 +8,13 @@ FunctionSpaceVector::FunctionSpaceVector(void){ hasDiv = false; divBasis = NULL; + + locPreEvaluated = false; + curlPreEvaluated = false; + divPreEvaluated = false; + evalLoc = NULL; + evalCurl = NULL; + evalDiv = NULL; } FunctionSpaceVector::~FunctionSpaceVector(void){ @@ -16,4 +23,68 @@ FunctionSpaceVector::~FunctionSpaceVector(void){ if(hasDiv) delete divBasis; + + if(locPreEvaluated) + delete evalLoc; + + if(curlPreEvaluated) + delete evalCurl; + + if(divPreEvaluated) + delete evalDiv; +} + +void FunctionSpaceVector:: +preEvaluateLocalFunctions(fullMatrix<double>& points){ + // Delete Old Struct (if any) // + if(locPreEvaluated) + delete evalLoc; + + // New Struct // + evalLoc = new EvaluatedBasisVector(*basisVector, points); + + // PreEvaluated // + locPreEvaluated = true; +} + +void FunctionSpaceVector:: +preEvaluateCurlLocalFunctions(fullMatrix<double>& points){ + // Got Curl Basis ? // + // --> mutable data + // --> Just a 'cache memory' + if(!hasCurl){ + curlBasis = new CurlBasis(*basisVector); + hasCurl = true; + } + + // Delete Old Struct (if any) // + if(curlPreEvaluated) + delete evalCurl; + + // New Struct // + evalCurl = new EvaluatedBasisVector(*curlBasis, points); + + // PreEvaluated // + curlPreEvaluated = true; +} + +void FunctionSpaceVector:: +preEvaluateDivLocalFunctions(fullMatrix<double>& points){ + // Got Div Basis ? // + // --> mutable data + // --> Just a 'cache memory' + if(!hasDiv){ + divBasis = new DivBasis(*basisVector); + hasDiv = true; + } + + // Delete Old Struct (if any) // + if(divPreEvaluated) + delete evalDiv; + + // New Struct // + evalDiv = new EvaluatedBasisScalar(*divBasis, points); + + // PreEvaluated // + divPreEvaluated = true; } diff --git a/FunctionSpace/FunctionSpaceVector.h b/FunctionSpace/FunctionSpaceVector.h index b84cfa0957e939e299fa7774a55ba2e8969e8d42..80250611d942522b7e12203c709a23534a0f25eb 100644 --- a/FunctionSpace/FunctionSpaceVector.h +++ b/FunctionSpace/FunctionSpaceVector.h @@ -2,9 +2,12 @@ #define _FUNCTIONSPACEVECTOR_H_ #include "fullMatrix.h" +#include "Exception.h" #include "BasisVector.h" #include "CurlBasis.h" #include "DivBasis.h" +#include "EvaluatedBasisScalar.h" +#include "EvaluatedBasisVector.h" #include "FunctionSpace.h" /** @@ -34,6 +37,14 @@ class FunctionSpaceVector : public FunctionSpace{ mutable bool hasDiv; mutable DivBasis* divBasis; + bool locPreEvaluated; + bool curlPreEvaluated; + bool divPreEvaluated; + + EvaluatedBasisVector* evalLoc; + EvaluatedBasisVector* evalCurl; + EvaluatedBasisScalar* evalDiv; + public: virtual ~FunctionSpaceVector(void); @@ -56,6 +67,19 @@ class FunctionSpaceVector : public FunctionSpace{ const std::vector<const Polynomial*> getDivLocalFunctions(const MElement& element) const; + void preEvaluateLocalFunctions(fullMatrix<double>& points); + void preEvaluateCurlLocalFunctions(fullMatrix<double>& points); + void preEvaluateDivLocalFunctions(fullMatrix<double>& points); + + const std::vector<const std::vector<fullVector<double> >*> + getEvaluatedLocalFunctions(const MElement& element) const; + + const std::vector<const std::vector<fullVector<double> >*> + getEvaluatedCurlLocalFunctions(const MElement& element) const; + + const std::vector<const std::vector<double>*> + getEvaluatedDivLocalFunctions(const MElement& element) const; + protected: FunctionSpaceVector(void); }; @@ -122,6 +146,75 @@ class FunctionSpaceVector : public FunctionSpace{ @return Returns the @em divergence of the basis functions associated to the given element (with correct @em closure) + ** + + @fn FunctionSpaceVector::preEvaluateLocalFunctions + @param points A set of @c 3D Points + + Precomputes the Local Functions of this FunctionSpace + at the given Points. + + @note Each row of @c point is a new Point, + and each column is a coordinate (for a total of + 3 columns) + ** + + @fn FunctionSpaceVector::preEvaluateCurlLocalFunctions + @param points A set of @c 3D Points + + Precomputes the @em Curl of the Local Functions + of this FunctionSpace at the given Points. + + @note Each row of @c point is a new Point, + and each column is a coordinate (for a total of + 3 columns) + ** + + @fn FunctionSpaceVector::preEvaluateDivLocalFunctions + @param points A set of @c 3D Points + + Precomputes the @em Divergence of the Local Functions + of this FunctionSpace at the given Points. + + @note Each row of @c point is a new Point, + and each column is a coordinate (for a total of + 3 columns) + ** + + @fn FunctionSpaceVector::getEvaluatedLocalFunctions + @param element A MElement + @return Returns the @em values of the @em precomputed + Basis Functions associated + to the given element (with correct @em closure) + + @note + The returned values @em must be computed by + FunctionSpaceVector::preEvaluateLocalFunctions(), + if not an Exception will be thrown + ** + + @fn FunctionSpaceVector::getEvaluatedCurlLocalFunctions + @param element A MElement + @return Returns the @em values of the @em precomputed + @em Curls of the Basis Functions associated + to the given element (with correct @em closure) + + @note + The returned values @em must be computed by + FunctionSpaceVector::preEvaluateCurlLocalFunctions(), + if not an Exception will be thrown + ** + + @fn FunctionSpaceVector::getEvaluatedDivLocalFunctions + @param element A MElement + @return Returns the @em values of the @em precomputed + @em Divergences of the Basis Functions associated + to the given element (with correct @em closure) + + @note + The returned values @em must be computed by + FunctionSpaceVector::preEvaluateDivLocalFunctions(), + if not an Exception will be thrown */ ////////////////////// @@ -161,4 +254,28 @@ FunctionSpaceVector::getDivLocalFunctions(const MElement& element) const{ return locBasis(element, *divBasis); } +inline const std::vector<const std::vector<fullVector<double> >*> +FunctionSpaceVector::getEvaluatedLocalFunctions(const MElement& element) const{ + if(!locPreEvaluated) + throw Exception("Local Basis Functions not PreEvaluated"); + + return locEvalBasis(element, *evalLoc); +} + +inline const std::vector<const std::vector<fullVector<double> >*> +FunctionSpaceVector::getEvaluatedCurlLocalFunctions(const MElement& element) const{ + if(!curlPreEvaluated) + throw Exception("Curls of Local Basis Functions not PreEvaluated"); + + return locEvalBasis(element, *evalCurl); +} + +inline const std::vector<const std::vector<double>*> +FunctionSpaceVector::getEvaluatedDivLocalFunctions(const MElement& element) const{ + if(!divPreEvaluated) + throw Exception("Divergences of Local Basis Functions not PreEvaluated"); + + return locEvalBasis(element, *evalDiv); +} + #endif