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

Interpolation -- Node

parent 10dfc540
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,8 @@ int ain(int argc, char** argv){ ...@@ -25,7 +25,8 @@ int ain(int argc, char** argv){
Mesh msh(argv[1]); Mesh msh(argv[1]);
// Writer for .msh // Writer for .msh
WriterMsh writer(msh.getGroup(2).getAll()); WriterMsh writer;
writer.setDomain(msh.getGroup(2).getAll());
// Plot Basis // // Plot Basis //
HexNodeBasis b(1); HexNodeBasis b(1);
......
...@@ -22,6 +22,7 @@ set(SRC ...@@ -22,6 +22,7 @@ set(SRC
HexEdgeBasis.cpp HexEdgeBasis.cpp
FunctionSpace.cpp FunctionSpace.cpp
FunctionSpaceScalar.cpp
FunctionSpaceNode.cpp FunctionSpaceNode.cpp
) )
......
#include "FunctionSpaceNode.h" #include "FunctionSpaceNode.h"
#include "Polynomial.h" #include "Polynomial.h"
#include "BasisScalar.h" #include "BasisScalar.h"
#include "fullMatrix.h"
#include "Mapper.h"
#include "Exception.h" #include "Exception.h"
using namespace std; using namespace std;
FunctionSpaceNode::FunctionSpaceNode(const GroupOfElement& goe, int order): FunctionSpaceNode::FunctionSpaceNode(const GroupOfElement& goe, int order):
FunctionSpace(goe, 0, order){ FunctionSpaceScalar(goe, 0, order){
// Just Call Super Constructor with basisType = 0 // Just Call Super Constructor with basisType = 0
} }
...@@ -14,9 +16,10 @@ FunctionSpace(goe, 0, order){ ...@@ -14,9 +16,10 @@ FunctionSpace(goe, 0, order){
FunctionSpaceNode::~FunctionSpaceNode(void){ FunctionSpaceNode::~FunctionSpaceNode(void){
} }
vector<double> FunctionSpaceNode:: void FunctionSpaceNode::
interpolateAtNodes(const MElement& elem, interpolateAtNodes(const MElement& elem,
const vector<double>& coef) const{ const vector<double>& coef,
std::vector<double>& nodeValue) const{
// Check // Check
unsigned int wS = coef.size(); unsigned int wS = coef.size();
unsigned int bS = basis->getSize(); unsigned int bS = basis->getSize();
...@@ -42,20 +45,33 @@ interpolateAtNodes(const MElement& elem, ...@@ -42,20 +45,33 @@ interpolateAtNodes(const MElement& elem,
const vector<Polynomial>& fun = const vector<Polynomial>& fun =
static_cast<const BasisScalar*>(basis)->getBasis(); static_cast<const BasisScalar*>(basis)->getBasis();
// Init Vector // Init some stuff
vector<double> value(N); fullMatrix<double> invJac(3, 3);
fullVector<double> xyz(3);
fullVector<double> origin(3);
origin(0) = node[0]->x();
origin(1) = node[0]->y();
origin(2) = node[0]->z();
// Interpolate // Interpolate
for(unsigned int n = 0; n < N; n++){ for(unsigned int n = 0; n < N; n++){
const double x = node[n]->x(); // Map from physical to reference space
const double y = node[n]->y(); xyz(0) = node[n]->x();
const double z = node[n]->z(); xyz(1) = node[n]->y();
xyz(2) = node[n]->z();
value[n] = 0; element.getJacobian(xyz(0), xyz(1), xyz(2), invJac);
invJac.invertInPlace();
const fullVector<double> uvw =
Mapper::invMap(xyz, origin, invJac);
// Interpolate
const int id = node[n]->getNum();
for(unsigned int i = 0; i < bS; i++) for(unsigned int i = 0; i < bS; i++)
value[n] += fun[i].at(x, y, z) * coef[i]; nodeValue[id] += fun[i].at(uvw(0), uvw(1), uvw(2)) * coef[i];
} }
return value;
} }
#ifndef _FUNCTIONSPACENODE_H_ #ifndef _FUNCTIONSPACENODE_H_
#define _FUNCTIONSPACENODE_H_ #define _FUNCTIONSPACENODE_H_
#include "FunctionSpace.h" #include "FunctionSpaceScalar.h"
class FunctionSpaceNode: public FunctionSpace{ class FunctionSpaceNode: public FunctionSpaceScalar{
public:
FunctionSpaceNode(const GroupOfElement& goe, int order); FunctionSpaceNode(const GroupOfElement& goe, int order);
virtual ~FunctionSpaceNode(void); virtual ~FunctionSpaceNode(void);
std::vector<double> interpolateAtNodes(const MElement& element, virtual void interpolateAtNodes(const MElement& element,
const std::vector<double>& coef) const; const std::vector<double>& coef,
std::vector<double>& nodeValue) const;
}; };
#endif #endif
#include "FunctionSpaceScalar.h"
FunctionSpaceScalar::FunctionSpaceScalar(const GroupOfElement& goe,
int basisType, int order):
FunctionSpace(goe, basisType, order){
}
FunctionSpaceScalar::~FunctionSpaceScalar(void){
}
#ifndef _FUNCTIONSPACESCALAR_H_
#define _FUNCTIONSPACESCALAR_H_
#include "FunctionSpace.h"
class FunctionSpaceScalar: public FunctionSpace{
public:
FunctionSpaceScalar(const GroupOfElement& goe,
int basisType, int order);
virtual ~FunctionSpaceScalar(void);
virtual void interpolateAtNodes(const MElement& element,
const std::vector<double>& coef,
std::vector<double>& nodeValue) const = 0;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment