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
LocalFunctionSpace.cpp
LocalFunctionSpaceScalar.cpp
LocalFunctionSpaceVector.cpp
LocalFunctionSpace0Form.cpp
LocalFunctionSpace1Form.cpp
)
file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
......
......@@ -8,27 +8,3 @@ 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 @@
@class LocalFunctionSpace
@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
A Local Function Space is a Basis on which we can interpolate on.@n
In order to interpolate, a Local Function Space shall colaborate
with a Jacobian.
with an Element.
*/
#include "Jacobian.h"
class LocalFunctionSpace{
protected:
typedef fullVector<double>(Jacobian::*JacMethod)
(const fullVector<double>&) const;
bool scalar;
int size;
int type;
Jacobian* jac;
fullVector<double> (*transform)(const Jacobian&,
double,
double,
double);
public:
//! Deletes this LocalFunctionSpace
......@@ -59,29 +52,6 @@ class LocalFunctionSpace{
//! Instantiate a new LocalFunctionSpace
//! @warning Users can't instantiate a LocalFunctionSpace
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{
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
#include "LocalFunctionSpaceScalar.h"
#include "BasisScalar.h"
#include "Exception.h"
LocalFunctionSpaceScalar::LocalFunctionSpaceScalar(const Basis& basis){
if(!basis.isScalar())
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){
scalar = true;
}
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_
#define _LOCALFUNCTIONSPACESCALAR_H_
#include <vector>
#include "Polynomial.h"
#include "Basis.h"
#include "LocalFunctionSpace.h"
/**
......@@ -13,16 +10,8 @@
A Local Function Space build on a @em Scalar Basis.
*/
class LocalFunctionSpaceScalar: LocalFunctionSpace{
protected:
const std::vector<Polynomial>* basis;
class LocalFunctionSpaceScalar: public LocalFunctionSpace{
public:
//! Instantiate a new LocalFunctionSpaceScalar
//! @param basis The Basis used to build
//! this Function Space
LocalFunctionSpaceScalar(const Basis& basis);
//! Deletes this LocalFunctionSpaceScalar
//!
virtual ~LocalFunctionSpaceScalar(void);
......@@ -32,8 +21,13 @@ class LocalFunctionSpaceScalar: LocalFunctionSpace{
//! Interpolation
//! @param x,y,z The coordinate of the Interpolation
//! @return Returns the value of the Interpolation
double interpolate(const fullVector<double>& coef,
double x, double y, double z) const;
virtual double interpolate(const fullVector<double>& coef,
double x, double y, double z) const = 0;
protected:
//! Instantiate a new LocalFunctionSpaceScalar
//! @warning Users can't instantiate a LocalFunctionSpaceScalar
LocalFunctionSpaceScalar(void);
};
#endif
#include "LocalFunctionSpaceVector.h"
#include "BasisVector.h"
#include "Exception.h"
LocalFunctionSpaceVector::LocalFunctionSpaceVector(const Basis& basis){
if(basis.isScalar())
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){
scalar = false;
}
LocalFunctionSpaceVector::~LocalFunctionSpaceVector(void){
// LocalFunctionSpaceVector is *NOT* responsible
// for deleting 'basis'
// It's the Basis job
}
#ifndef _LOCALFUNCTIONSPACEVECTOR_H_
#define _LOCALFUNCTIONSPACEVECTOR_H_
#include <vector>
#include "Polynomial.h"
#include "Basis.h"
#include "fullMatrix.h"
#include "LocalFunctionSpace.h"
......@@ -14,16 +11,8 @@
A Local Function Space build on a @em Vectorial Basis.
*/
class LocalFunctionSpaceVector: LocalFunctionSpace{
protected:
const std::vector<std::vector<Polynomial> >* basis;
class LocalFunctionSpaceVector: public LocalFunctionSpace{
public:
//! Instantiate a new LocalFunctionSpaceVector
//! @param basis The Basis used to build
//! this Function Space
LocalFunctionSpaceVector(const Basis& basis);
//! Deletes this LocalFunctionSpaceVector
//!
virtual ~LocalFunctionSpaceVector(void);
......@@ -33,8 +22,13 @@ class LocalFunctionSpaceVector: LocalFunctionSpace{
//! Interpolation
//! @param x,y,z The coordinate of the Interpolation
//! @return Returns the value of the Interpolation
fullVector<double> interpolate(const fullVector<double>& coef,
double x, double y, double z) const;
virtual fullVector<double> interpolate(const fullVector<double>& coef,
double x, double y, double z) const = 0;
protected:
//! Instantiate a new LocalFunctionSpacaeVector
//! @warning Users can't instantiate a LocalFunctionSpaceVector
LocalFunctionSpaceVector(void);
};
#endif
......@@ -171,7 +171,7 @@ class Polynomial{
@return Returns the @em evaluation of this
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 x 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