Skip to content
Snippets Groups Projects
Commit 9ad2edf9 authored by Nicolas Marsic's avatar Nicolas Marsic
Browse files

Adaptive View for vectorial fields

parent bf73b2b9
No related branches found
No related tags found
No related merge requests found
...@@ -61,3 +61,40 @@ interpolate(const MElement& element, ...@@ -61,3 +61,40 @@ interpolate(const MElement& element,
// Return Interpolated Value // // Return Interpolated Value //
return val; return val;
} }
fullVector<double> FunctionSpaceEdge::
interpolateInRefSpace(const MElement& element,
const std::vector<double>& coef,
const fullVector<double>& uvw) const{
// Const Cast For MElement //
MElement& eelement =
const_cast<MElement&>(element);
// Get Basis Functions //
const vector<const vector<Polynomial>*>& fun = getLocalFunctions(element);
const unsigned int nFun = fun.size();
// Get Jacobian //
fullMatrix<double> invJac(3, 3);
eelement.getJacobian(uvw(0), uvw(1), uvw(2), invJac);
invJac.invertInPlace();
// Interpolate (in Reference Place) //
fullVector<double> val(3);
val(0) = 0;
val(1) = 0;
val(2) = 0;
for(unsigned int i = 0; i < nFun; i++){
fullVector<double> vi =
Mapper::grad(Polynomial::at(*fun[i], uvw(0), uvw(1), uvw(2)),
invJac);
vi.scale(coef[i]);
val.axpy(vi, 1);
}
// Return Interpolated Value //
return val;
}
...@@ -21,6 +21,11 @@ class FunctionSpaceEdge : public FunctionSpaceVector{ ...@@ -21,6 +21,11 @@ class FunctionSpaceEdge : public FunctionSpaceVector{
interpolate(const MElement& element, interpolate(const MElement& element,
const std::vector<double>& coef, const std::vector<double>& coef,
const fullVector<double>& xyz) const; const fullVector<double>& xyz) const;
virtual fullVector<double>
interpolateInRefSpace(const MElement& element,
const std::vector<double>& coef,
const fullVector<double>& uvw) const;
}; };
......
...@@ -48,3 +48,23 @@ interpolate(const MElement& element, ...@@ -48,3 +48,23 @@ interpolate(const MElement& element,
// Return Interpolated Value // // Return Interpolated Value //
return val; return val;
} }
double FunctionSpaceNode::
interpolateInRefSpace(const MElement& element,
const std::vector<double>& coef,
const fullVector<double>& uvw) const{
// Get Basis Functions //
const vector<const Polynomial*> fun = getLocalFunctions(element);
const unsigned int nFun = fun.size();
// Interpolate (in Reference Place) //
double val = 0;
for(unsigned int i = 0; i < nFun; i++)
val +=
fun[i]->at(uvw(0), uvw(1), uvw(2)) * coef[i];
// Return Interpolated Value //
return val;
}
...@@ -21,6 +21,11 @@ class FunctionSpaceNode : public FunctionSpaceScalar{ ...@@ -21,6 +21,11 @@ class FunctionSpaceNode : public FunctionSpaceScalar{
interpolate(const MElement& element, interpolate(const MElement& element,
const std::vector<double>& coef, const std::vector<double>& coef,
const fullVector<double>& xyz) const; const fullVector<double>& xyz) const;
virtual double
interpolateInRefSpace(const MElement& element,
const std::vector<double>& coef,
const fullVector<double>& uvw) const;
}; };
......
...@@ -35,6 +35,11 @@ class FunctionSpaceScalar : public FunctionSpace{ ...@@ -35,6 +35,11 @@ class FunctionSpaceScalar : public FunctionSpace{
interpolate(const MElement& element, interpolate(const MElement& element,
const std::vector<double>& coef, const std::vector<double>& coef,
const fullVector<double>& xyz) const = 0; const fullVector<double>& xyz) const = 0;
virtual double
interpolateInRefSpace(const MElement& element,
const std::vector<double>& coef,
const fullVector<double>& uvw) const = 0;
const std::vector<const Polynomial*> const std::vector<const Polynomial*>
getLocalFunctions(const MElement& element) const; getLocalFunctions(const MElement& element) const;
...@@ -57,7 +62,26 @@ class FunctionSpaceScalar : public FunctionSpace{ ...@@ -57,7 +62,26 @@ class FunctionSpaceScalar : public FunctionSpace{
@param coef The coefficients of the interpolation @param coef The coefficients of the interpolation
@param xyz The coordinate @param xyz The coordinate
(of point @em inside the given @c element) (of point @em inside the given @c element)
of the interpolation of the interpolation in the @em Physical Space
@return Returns the (scalar) interpolated value
@warning
If the given coordinate are not in the given
@c element @em Bad @em Things may happend
@todo
If the given coordinate are not in the given
@c element @em Bad @em Things may happend
---> check
**
@fn FunctionSpaceScalar::interpolateInRefSpace
@param element The MElement to interpolate on
@param coef The coefficients of the interpolation
@param uvw The coordinate
(of point @em inside the given @c element)
of the interpolation in the @em Reference Space
@return Returns the (scalar) interpolated value @return Returns the (scalar) interpolated value
......
...@@ -40,6 +40,11 @@ class FunctionSpaceVector : public FunctionSpace{ ...@@ -40,6 +40,11 @@ class FunctionSpaceVector : public FunctionSpace{
const std::vector<double>& coef, const std::vector<double>& coef,
const fullVector<double>& xyz) const = 0; const fullVector<double>& xyz) const = 0;
virtual fullVector<double>
interpolateInRefSpace(const MElement& element,
const std::vector<double>& coef,
const fullVector<double>& uvw) const = 0;
const std::vector<const std::vector<Polynomial>*> const std::vector<const std::vector<Polynomial>*>
getLocalFunctions(const MElement& element) const; getLocalFunctions(const MElement& element) const;
...@@ -64,7 +69,26 @@ class FunctionSpaceVector : public FunctionSpace{ ...@@ -64,7 +69,26 @@ class FunctionSpaceVector : public FunctionSpace{
@param coef The coefficients of the interpolation @param coef The coefficients of the interpolation
@param xyz The coordinate @param xyz The coordinate
(of point @em inside the given @c element) (of point @em inside the given @c element)
of the interpolation of the interpolation in the @em Physical Space
@return Returns the (vectorial) interpolated value
@warning
If the given coordinate are not in the given
@c element @em Bad @em Things may happend
@todo
If the given coordinate are not in the given
@c element @em Bad @em Things may happend
---> check
**
@fn FunctionSpaceVector::interpolateInRefSpace
@param element The MElement to interpolate on
@param coef The coefficients of the interpolation
@param xyz The coordinate
(of point @em inside the given @c element)
of the interpolation in the @em Reference Space
@return Returns the (vectorial) interpolated value @return Returns the (vectorial) interpolated value
......
...@@ -9,24 +9,50 @@ LagrangeBasis::LagrangeBasis(void){ ...@@ -9,24 +9,50 @@ LagrangeBasis::LagrangeBasis(void){
LagrangeBasis::~LagrangeBasis(void){ LagrangeBasis::~LagrangeBasis(void){
} }
fullVector<double> LagrangeBasis:: vector<double> LagrangeBasis::
project(const fullVector<double>& coef, project(const MElement& element,
const std::vector<const Polynomial*>& basis){ const vector<double>& coef,
const FunctionSpaceScalar& fSpace){
// Init New Coefs // // Init New Coefs //
const unsigned int size = point->size1(); const unsigned int size = point->size1();
fullVector<double> newCoef(size); vector<double> newCoef(size);
// Interpolation at Lagrange Points // // Interpolation at Lagrange Points //
const unsigned int nCoef = coef.size();
for(unsigned int i = 0; i < size; i++){ for(unsigned int i = 0; i < size; i++){
newCoef(i) = 0; fullVector<double> uvw(3);
uvw(0) = (*point)(i, 0);
uvw(1) = (*point)(i, 1);
uvw(2) = (*point)(i, 2);
newCoef[i] = fSpace.interpolateInRefSpace(element,
coef,
uvw);
}
// Return ;
return newCoef;
}
vector<fullVector<double> > LagrangeBasis::
project(const MElement& element,
const vector<double>& coef,
const FunctionSpaceVector& fSpace){
// Init New Coefs //
const unsigned int size = point->size1();
vector<fullVector<double> > newCoef(size);
// Interpolation at Lagrange Points //
for(unsigned int i = 0; i < size; i++){
fullVector<double> uvw(3);
uvw(0) = (*point)(i, 0);
uvw(1) = (*point)(i, 1);
uvw(2) = (*point)(i, 2);
for(unsigned int j = 0; j < nCoef; j++) newCoef[i] = fSpace.interpolateInRefSpace(element,
newCoef(i) += coef(j) * basis[j]->at((*point)(i, 0), coef,
(*point)(i, 1), uvw);
(*point)(i, 2));
} }
// Return ; // Return ;
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
#include "polynomialBasis.h" #include "polynomialBasis.h"
#include "BasisScalar.h" #include "BasisScalar.h"
#include "MElement.h"
#include "FunctionSpaceScalar.h"
#include "FunctionSpaceVector.h"
/** /**
@interface LagrangeBasis @interface LagrangeBasis
@brief Interoface for Lagrange Basis @brief Interoface for Lagrange Basis
...@@ -39,13 +43,28 @@ class LagrangeBasis: public BasisScalar{ ...@@ -39,13 +43,28 @@ class LagrangeBasis: public BasisScalar{
//! @return Returns the Monomial Matrix //! @return Returns the Monomial Matrix
const fullMatrix<double>& getMonomial(void) const; const fullMatrix<double>& getMonomial(void) const;
//! @param coef A vector of Real numbers //! @param element A MElement
//! @param basis A vector of Polynomials //! @param coef A vector of coefficient associated
//! in a @em Reference Space //! to the given Element
//! @param fSpace The (scalar) Function Space
//! of the given Coefficients
//! @return Projects the given Coefficients in this LagrangeBasis@n //! @return Projects the given Coefficients in this LagrangeBasis@n
fullVector<double> project(const fullVector<double>& coef, std::vector<double> project(const MElement& element,
const std::vector<const Polynomial*>& basis); const std::vector<double>& coef,
const FunctionSpaceScalar& fSpace);
//! @param element A MElement
//! @param coef A vector of coefficient associated
//! to the given Element
//! @param fSpace The (vectorial) Function Space
//! of the given Coefficients
//! @return Projects the given Coefficients in this LagrangeBasis@n
//! @note Each Coefficients will be projected into a vector
//! with the same dimesion as the vectorial Polynomials
std::vector<fullVector<double> >
project(const MElement& element,
const std::vector<double>& coef,
const FunctionSpaceVector& fSpace);
protected: protected:
//! Returns a new LagrangeBasis //! Returns a new LagrangeBasis
//! //!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment