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

New LocalFunctionSpace hierarchy

parent 7348d021
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,8 @@ set(SRC ...@@ -19,6 +19,8 @@ set(SRC
LocalFunctionSpace.cpp LocalFunctionSpace.cpp
LocalFunctionSpaceScalar.cpp LocalFunctionSpaceScalar.cpp
LocalFunctionSpaceVector.cpp LocalFunctionSpaceVector.cpp
LocalFunctionSpace0Form.cpp
LocalFunctionSpace1Form.cpp
) )
file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h) file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
......
...@@ -8,27 +8,3 @@ LocalFunctionSpace::LocalFunctionSpace(void){ ...@@ -8,27 +8,3 @@ LocalFunctionSpace::LocalFunctionSpace(void){
LocalFunctionSpace::~LocalFunctionSpace(void){ LocalFunctionSpace::~LocalFunctionSpace(void){
} }
void LocalFunctionSpace::selectTransform(int form){
switch(form){
case 0:
transform = LocalFunctionSpace::form0;
break;
case 1:
transform = LocalFunctionSpace::form1;
break;
case 2:
throw Exception("Mapping of 2-form not implemented");
break;
case 3:
throw Exception("Mapping of 3-form not implemented");
break;
default:
throw Exception ("Unknown '%d-form'", form);
break;
}
}
...@@ -5,30 +5,23 @@ ...@@ -5,30 +5,23 @@
@class LocalFunctionSpace @class LocalFunctionSpace
@brief Mother class for Local Function Spaces @brief Mother class for Local Function Spaces
This class is the @em mother (by @em inheritence) of all@n This class is the @em mother (by @em inheritence) of all
Local Function Spaces.@n Local Function Spaces.@n
A Local Function Space is a Basis on which we can interpolate on.@n A Local Function Space is a Basis on which we can interpolate on.@n
In order to interpolate, a Local Function Space shall colaborate In order to interpolate, a Local Function Space shall colaborate
with a Jacobian. with an Element.
*/ */
#include "Jacobian.h" #include "Jacobian.h"
class LocalFunctionSpace{ class LocalFunctionSpace{
protected: protected:
typedef fullVector<double>(Jacobian::*JacMethod)
(const fullVector<double>&) const;
bool scalar; bool scalar;
int size; int size;
int type; int type;
Jacobian* jac; Jacobian* jac;
fullVector<double> (*transform)(const Jacobian&,
double,
double,
double);
public: public:
//! Deletes this LocalFunctionSpace //! Deletes this LocalFunctionSpace
...@@ -59,29 +52,6 @@ class LocalFunctionSpace{ ...@@ -59,29 +52,6 @@ class LocalFunctionSpace{
//! Instantiate a new LocalFunctionSpace //! Instantiate a new LocalFunctionSpace
//! @warning Users can't instantiate a LocalFunctionSpace //! @warning Users can't instantiate a LocalFunctionSpace
LocalFunctionSpace(void); LocalFunctionSpace(void);
//! Selects the right transorm method for the Jacobian
//! @param form The @em type of the Basis used
void selectTransform(int form);
//! Mapping of 0-form
//! @param jac The Jacobian to use
//! @param u,v,w The @em reference coordinate to map
//! @return Returns The mapped coordinate in the @em physical space
static fullVector<double> form0(const Jacobian& jac,
double u,
double v,
double w);
//! Mapping of 1-form
//! @param jac The Jacobian to use
//! @param u,v,w The @em reference coordinate to map
//! @return Returns The mapped coordinate in the @em physical space
static fullVector<double> form1(const Jacobian& jac,
double u,
double v,
double w);
}; };
////////////////////// //////////////////////
...@@ -100,19 +70,4 @@ inline int LocalFunctionSpace::getType(void) const{ ...@@ -100,19 +70,4 @@ inline int LocalFunctionSpace::getType(void) const{
return type; return type;
} }
inline fullVector<double> LocalFunctionSpace::form0(const Jacobian& jac,
double u,
double v,
double w){
return jac.map(u, v);
}
inline fullVector<double> LocalFunctionSpace::form1(const Jacobian& jac,
double u,
double v,
double w){
return jac.grad(u, v);
//! @todo Missing Orientation !!
}
#endif #endif
#include "LocalFunctionSpaceScalar.h" #include "LocalFunctionSpaceScalar.h"
#include "BasisScalar.h"
#include "Exception.h"
LocalFunctionSpaceScalar::LocalFunctionSpaceScalar(const Basis& basis){ LocalFunctionSpaceScalar::LocalFunctionSpaceScalar(void){
if(!basis.isScalar()) scalar = true;
throw Exception("Can't Create a Scalar Function Space with a Vectorial Basis");
const BasisScalar& b = static_cast<const BasisScalar&>(basis);
this->scalar = true;
this->size = b.getSize();
this->type = b.getType();
this->basis = &(b.getBasis());
selectTransform(type);
} }
LocalFunctionSpaceScalar::~LocalFunctionSpaceScalar(void){ LocalFunctionSpaceScalar::~LocalFunctionSpaceScalar(void){
// LocalFunctionSpaceScalar is *NOT* responsible
// for deleting 'basis'
// It's the Basis job
}
double LocalFunctionSpaceScalar::interpolate
(const fullVector<double>& coef,
double x, double y, double z) const{
if(coef.size() > size)
throw Exception("To many coeficients for interpolation");
if(coef.size() < size)
throw Exception("Not enough coeficients for interpolation");
fullVector<double> uvw = jac->invMap(x, y);
double res = 0;
for(int i = 0; i < size; ++i){
//transform(*jac, uvw(0), uvw(1), 0);
//! @todo Interpolation rule ...
}
return res;
} }
#ifndef _LOCALFUNCTIONSPACESCALAR_H_ #ifndef _LOCALFUNCTIONSPACESCALAR_H_
#define _LOCALFUNCTIONSPACESCALAR_H_ #define _LOCALFUNCTIONSPACESCALAR_H_
#include <vector>
#include "Polynomial.h"
#include "Basis.h"
#include "LocalFunctionSpace.h" #include "LocalFunctionSpace.h"
/** /**
...@@ -13,16 +10,8 @@ ...@@ -13,16 +10,8 @@
A Local Function Space build on a @em Scalar Basis. A Local Function Space build on a @em Scalar Basis.
*/ */
class LocalFunctionSpaceScalar: LocalFunctionSpace{ class LocalFunctionSpaceScalar: public LocalFunctionSpace{
protected: public:
const std::vector<Polynomial>* basis;
public:
//! Instantiate a new LocalFunctionSpaceScalar
//! @param basis The Basis used to build
//! this Function Space
LocalFunctionSpaceScalar(const Basis& basis);
//! Deletes this LocalFunctionSpaceScalar //! Deletes this LocalFunctionSpaceScalar
//! //!
virtual ~LocalFunctionSpaceScalar(void); virtual ~LocalFunctionSpaceScalar(void);
...@@ -32,8 +21,13 @@ class LocalFunctionSpaceScalar: LocalFunctionSpace{ ...@@ -32,8 +21,13 @@ class LocalFunctionSpaceScalar: LocalFunctionSpace{
//! Interpolation //! Interpolation
//! @param x,y,z The coordinate of the Interpolation //! @param x,y,z The coordinate of the Interpolation
//! @return Returns the value of the Interpolation //! @return Returns the value of the Interpolation
double interpolate(const fullVector<double>& coef, virtual double interpolate(const fullVector<double>& coef,
double x, double y, double z) const; double x, double y, double z) const = 0;
protected:
//! Instantiate a new LocalFunctionSpaceScalar
//! @warning Users can't instantiate a LocalFunctionSpaceScalar
LocalFunctionSpaceScalar(void);
}; };
#endif #endif
#include "LocalFunctionSpaceVector.h" #include "LocalFunctionSpaceVector.h"
#include "BasisVector.h"
#include "Exception.h"
LocalFunctionSpaceVector::LocalFunctionSpaceVector(const Basis& basis){ LocalFunctionSpaceVector::LocalFunctionSpaceVector(void){
if(basis.isScalar()) scalar = false;
throw Exception("Can't Create a Vector Function Space with a Scalar Basis");
const BasisVector& b = static_cast<const BasisVector&>(basis);
this->scalar = false;
this->size = b.getSize();
this->basis = &(b.getBasis());
} }
LocalFunctionSpaceVector::~LocalFunctionSpaceVector(void){ LocalFunctionSpaceVector::~LocalFunctionSpaceVector(void){
// LocalFunctionSpaceVector is *NOT* responsible
// for deleting 'basis'
// It's the Basis job
} }
#ifndef _LOCALFUNCTIONSPACEVECTOR_H_ #ifndef _LOCALFUNCTIONSPACEVECTOR_H_
#define _LOCALFUNCTIONSPACEVECTOR_H_ #define _LOCALFUNCTIONSPACEVECTOR_H_
#include <vector>
#include "Polynomial.h"
#include "Basis.h"
#include "fullMatrix.h" #include "fullMatrix.h"
#include "LocalFunctionSpace.h" #include "LocalFunctionSpace.h"
...@@ -14,16 +11,8 @@ ...@@ -14,16 +11,8 @@
A Local Function Space build on a @em Vectorial Basis. A Local Function Space build on a @em Vectorial Basis.
*/ */
class LocalFunctionSpaceVector: LocalFunctionSpace{ class LocalFunctionSpaceVector: public LocalFunctionSpace{
protected:
const std::vector<std::vector<Polynomial> >* basis;
public: public:
//! Instantiate a new LocalFunctionSpaceVector
//! @param basis The Basis used to build
//! this Function Space
LocalFunctionSpaceVector(const Basis& basis);
//! Deletes this LocalFunctionSpaceVector //! Deletes this LocalFunctionSpaceVector
//! //!
virtual ~LocalFunctionSpaceVector(void); virtual ~LocalFunctionSpaceVector(void);
...@@ -33,8 +22,13 @@ class LocalFunctionSpaceVector: LocalFunctionSpace{ ...@@ -33,8 +22,13 @@ class LocalFunctionSpaceVector: LocalFunctionSpace{
//! Interpolation //! Interpolation
//! @param x,y,z The coordinate of the Interpolation //! @param x,y,z The coordinate of the Interpolation
//! @return Returns the value of the Interpolation //! @return Returns the value of the Interpolation
fullVector<double> interpolate(const fullVector<double>& coef, virtual fullVector<double> interpolate(const fullVector<double>& coef,
double x, double y, double z) const; double x, double y, double z) const = 0;
protected:
//! Instantiate a new LocalFunctionSpacaeVector
//! @warning Users can't instantiate a LocalFunctionSpaceVector
LocalFunctionSpaceVector(void);
}; };
#endif #endif
...@@ -171,7 +171,7 @@ class Polynomial{ ...@@ -171,7 +171,7 @@ class Polynomial{
@return Returns the @em evaluation of this @return Returns the @em evaluation of this
Polynomial at (@c x, @c y, @c z) Polynomial at (@c x, @c y, @c z)
@fn fullVector<double> Polynomial::at(const std::vector<Polynomial>&, const double, const double y, const double z) @fn fullVector<double> Polynomial::at(const std::vector<Polynomial>&, const double, const double, const double)
@param P A vector of Polynomial%s @param P A vector of Polynomial%s
@param x A value @param x A value
@param y A value @param y A value
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment