From 8b6bab7543e74d05f4ad331b3e497e8c56952e43 Mon Sep 17 00:00:00 2001 From: Nicolas Marsic <nicolas.marsic@gmail.com> Date: Mon, 6 Aug 2012 18:10:03 +0000 Subject: [PATCH] Solution & interpolation -- BAD (but works) --- FunctionSpace/CMakeLists.txt | 2 - FunctionSpace/FunctionSpace.cpp | 67 +++++++++++++++++++++++ FunctionSpace/FunctionSpace.h | 6 +++ FunctionSpace/FunctionSpaceNode.cpp | 77 --------------------------- FunctionSpace/FunctionSpaceNode.h | 17 ------ FunctionSpace/FunctionSpaceScalar.cpp | 9 ---- FunctionSpace/FunctionSpaceScalar.h | 18 ------- 7 files changed, 73 insertions(+), 123 deletions(-) delete mode 100644 FunctionSpace/FunctionSpaceNode.cpp delete mode 100644 FunctionSpace/FunctionSpaceNode.h delete mode 100644 FunctionSpace/FunctionSpaceScalar.cpp delete mode 100644 FunctionSpace/FunctionSpaceScalar.h diff --git a/FunctionSpace/CMakeLists.txt b/FunctionSpace/CMakeLists.txt index 8a0101e828..fbda89a27f 100644 --- a/FunctionSpace/CMakeLists.txt +++ b/FunctionSpace/CMakeLists.txt @@ -22,8 +22,6 @@ set(SRC HexEdgeBasis.cpp FunctionSpace.cpp - FunctionSpaceScalar.cpp - FunctionSpaceNode.cpp ) file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h) diff --git a/FunctionSpace/FunctionSpace.cpp b/FunctionSpace/FunctionSpace.cpp index c0079b2678..62340ec405 100644 --- a/FunctionSpace/FunctionSpace.cpp +++ b/FunctionSpace/FunctionSpace.cpp @@ -129,3 +129,70 @@ FunctionSpace::~FunctionSpace(void){ delete basis; } +/* +#include "Polynomial.h" +#include "BasisScalar.h" +#include "fullMatrix.h" +#include "Mapper.h" +#include "Exception.h" +void FunctionSpace:: +interpolateAtNodes(const MElement& elem, + const vector<double>& coef, + std::vector<double>& nodeValue) const{ + // Check + unsigned int wS = coef.size(); + unsigned int bS = basis->getSize(); + + if(wS < bS) + throw Exception + ("Not enough coefs for interpolation:\nBasis: %d -- coefs: %d", + bS, wS); + + if(wS > bS) + throw Exception + ("Too much coefs for interpolation:\nBasis: %d -- coefs: %d", + bS, wS); + + // Get Nodes + MElement& element = const_cast<MElement&>(elem); + + vector<MVertex*> node; + element.getVertices(node); + unsigned int N = node.size(); + + // Get Functions + const vector<Polynomial>& fun = + static_cast<const BasisScalar*>(basis)->getBasis(); + + // Init some stuff + 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 + for(unsigned int n = 0; n < N; n++){ + // Map from physical to reference space + xyz(0) = node[n]->x(); + xyz(1) = node[n]->y(); + xyz(2) = node[n]->z(); + + element.getJacobian(xyz(0), xyz(1), xyz(2), invJac); + invJac.invertInPlace(); + + const fullVector<double> uvw = + Mapper::invMap(xyz, origin, invJac); + + printf("(%lf\t%lf\t%lf)\n", uvw(0), uvw(1), uvw(2)); + + // Interpolate + const int id = node[n]->getNum() - 1; + + for(unsigned int i = 0; i < bS; i++) + nodeValue[id] += fun[i].at(uvw(0), uvw(1), uvw(2)) * coef[i]; + } +} +*/ diff --git a/FunctionSpace/FunctionSpace.h b/FunctionSpace/FunctionSpace.h index 73bc9c3483..27ff74a4e4 100644 --- a/FunctionSpace/FunctionSpace.h +++ b/FunctionSpace/FunctionSpace.h @@ -52,6 +52,12 @@ class FunctionSpace{ int getNFunctionPerEdge(const MElement& element) const; int getNFunctionPerFace(const MElement& element) const; int getNFunctionPerCell(const MElement& element) const; + + /* + void interpolateAtNodes(const MElement& element, + const std::vector<double>& coef, + std::vector<double>& nodeValue) const; + */ }; ////////////////////// diff --git a/FunctionSpace/FunctionSpaceNode.cpp b/FunctionSpace/FunctionSpaceNode.cpp deleted file mode 100644 index 2fa2be3b4f..0000000000 --- a/FunctionSpace/FunctionSpaceNode.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "FunctionSpaceNode.h" -#include "Polynomial.h" -#include "BasisScalar.h" -#include "fullMatrix.h" -#include "Mapper.h" -#include "Exception.h" - -using namespace std; - -FunctionSpaceNode::FunctionSpaceNode(const GroupOfElement& goe, int order): -FunctionSpaceScalar(goe, 0, order){ - // Just Call Super Constructor with basisType = 0 -} - - -FunctionSpaceNode::~FunctionSpaceNode(void){ -} - -void FunctionSpaceNode:: -interpolateAtNodes(const MElement& elem, - const vector<double>& coef, - std::vector<double>& nodeValue) const{ - // Check - unsigned int wS = coef.size(); - unsigned int bS = basis->getSize(); - - if(wS < bS) - throw Exception - ("Not enough coefs for interpolation:\nBasis: %d -- coefs: %d", - bS, wS); - - if(wS > bS) - throw Exception - ("Too much coefs for interpolation:\nBasis: %d -- coefs: %d", - bS, wS); - - // Get Nodes - MElement& element = const_cast<MElement&>(elem); - - vector<MVertex*> node; - element.getVertices(node); - unsigned int N = node.size(); - - // Get Functions - const vector<Polynomial>& fun = - static_cast<const BasisScalar*>(basis)->getBasis(); - - // Init some stuff - 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 - for(unsigned int n = 0; n < N; n++){ - // Map from physical to reference space - xyz(0) = node[n]->x(); - xyz(1) = node[n]->y(); - xyz(2) = node[n]->z(); - - 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++) - nodeValue[id] += fun[i].at(uvw(0), uvw(1), uvw(2)) * coef[i]; - } -} diff --git a/FunctionSpace/FunctionSpaceNode.h b/FunctionSpace/FunctionSpaceNode.h deleted file mode 100644 index 0af13f213e..0000000000 --- a/FunctionSpace/FunctionSpaceNode.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _FUNCTIONSPACENODE_H_ -#define _FUNCTIONSPACENODE_H_ - -#include "FunctionSpaceScalar.h" - -class FunctionSpaceNode: public FunctionSpaceScalar{ - public: - FunctionSpaceNode(const GroupOfElement& goe, int order); - - virtual ~FunctionSpaceNode(void); - - virtual void interpolateAtNodes(const MElement& element, - const std::vector<double>& coef, - std::vector<double>& nodeValue) const; -}; - -#endif diff --git a/FunctionSpace/FunctionSpaceScalar.cpp b/FunctionSpace/FunctionSpaceScalar.cpp deleted file mode 100644 index 43d737cde5..0000000000 --- a/FunctionSpace/FunctionSpaceScalar.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "FunctionSpaceScalar.h" - -FunctionSpaceScalar::FunctionSpaceScalar(const GroupOfElement& goe, - int basisType, int order): -FunctionSpace(goe, basisType, order){ -} - -FunctionSpaceScalar::~FunctionSpaceScalar(void){ -} diff --git a/FunctionSpace/FunctionSpaceScalar.h b/FunctionSpace/FunctionSpaceScalar.h deleted file mode 100644 index e8c09f65ff..0000000000 --- a/FunctionSpace/FunctionSpaceScalar.h +++ /dev/null @@ -1,18 +0,0 @@ -#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 -- GitLab