diff --git a/FunctionSpace/CMakeLists.txt b/FunctionSpace/CMakeLists.txt index d4c99a11864fbb9bc1d96cafa0bd4340140317ca..193a31464872d066ca3b93298dc98c66daedbc28 100644 --- a/FunctionSpace/CMakeLists.txt +++ b/FunctionSpace/CMakeLists.txt @@ -10,6 +10,7 @@ set(SRC ReferenceSpace.cpp LineReferenceSpace.cpp TriReferenceSpace.cpp + QuadReferenceSpace.cpp TetReferenceSpace.cpp Basis.cpp diff --git a/FunctionSpace/QuadReferenceSpace.cpp b/FunctionSpace/QuadReferenceSpace.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ecec74d447e1ac75f98ac3de124904ba9a717edf --- /dev/null +++ b/FunctionSpace/QuadReferenceSpace.cpp @@ -0,0 +1,91 @@ +#include <sstream> +#include "QuadReferenceSpace.h" +#include "MQuadrangle.h" + +using namespace std; + +QuadReferenceSpace::QuadReferenceSpace(void){ + // Vertex Definition // + nVertex = 4; + + // Edge Definition // + nEdge = 4; + refEdge = new unsigned int*[nEdge]; + + for(unsigned int i = 0; i < nEdge; i++){ + refEdge[i] = new unsigned int[2]; + refEdge[i][0] = MQuadrangle::edges_quad(i, 0); + refEdge[i][1] = MQuadrangle::edges_quad(i, 1); + } + + // Face Definition // + nFace = 1; + refFace = new unsigned int*[nFace]; + refFace[0] = new unsigned int[4]; + + refFace[0][0] = 0; + refFace[0][1] = 1; + refFace[0][2] = 2; + refFace[0][3] = 3; + + // Init All // + init(); +} + +QuadReferenceSpace::~QuadReferenceSpace(void){ + // Delete Ref Edge // + for(unsigned int i = 0; i < nEdge; i++) + delete[] refEdge[i]; + + delete[] refEdge; + + // Delete Ref Face // + for(unsigned int i = 0; i < nFace; i++) + delete[] refFace[i]; + + delete[] refFace; +} + +string QuadReferenceSpace::toLatex(void) const{ + stringstream stream; + + stream << "\\documentclass{article}" << endl << endl + + << "\\usepackage{longtable}" << endl + << "\\usepackage{tikz}" << endl + << "\\usetikzlibrary{arrows}" << endl << endl + + << "\\begin{document}" << endl + << "\\tikzstyle{vertex} = [circle, fill = black!25]" << endl + << "\\tikzstyle{line} = [draw, thick, black, -latex']" << endl << endl + + << "\\begin{longtable}{ccc}" << endl << endl; + + for(unsigned int p = 0; p < nPerm; p++){ + stream << "\\begin{tikzpicture}" << endl + + << "\\node[vertex] (n0) at(0, 0) {$" << perm[p][0] << "$};" << endl + << "\\node[vertex] (n1) at(3, 0) {$" << perm[p][1] << "$};" << endl + << "\\node[vertex] (n2) at(3, 3) {$" << perm[p][2] << "$};" << endl + << "\\node[vertex] (n3) at(0, 3) {$" << perm[p][3] << "$};" << endl + << endl; + + for(unsigned int i = 0; i < 4; i++) + stream << "\\path[line]" + << " (n" << (*(*(*edge)[p])[i])[0] << ")" + << " -- " + << " (n" << (*(*(*edge)[p])[i])[1] << ");" + << endl; + + if((p + 1) % 3) + stream << "\\end{tikzpicture} & " << endl << endl; + + else + stream << "\\end{tikzpicture} \\\\ \\\\" << endl << endl; + } + + stream << "\\end{longtable}" << endl + << "\\end{document}" << endl; + + return stream.str(); +} diff --git a/FunctionSpace/QuadReferenceSpace.h b/FunctionSpace/QuadReferenceSpace.h new file mode 100644 index 0000000000000000000000000000000000000000..dadc5a7f48e358403e81f84e736983fae85d7999 --- /dev/null +++ b/FunctionSpace/QuadReferenceSpace.h @@ -0,0 +1,31 @@ +#ifndef _QUADREFERENCESPACE_H_ +#define _QUADREFERENCESPACE_H_ + +#include <string> +#include "ReferenceSpace.h" + +/** + @class QuadReferenceSpace + @brief ReferenceSpace for a Quadrangle + + This class implements a ReferenceSpace for a Quadrangle. + */ + +class QuadReferenceSpace: public ReferenceSpace{ + public: + QuadReferenceSpace(void); + virtual ~QuadReferenceSpace(void); + + virtual std::string toLatex(void) const; +}; + +/** + @fn QuadReferenceSpace::QuadReferenceSpace + Instatiate a new ReferenceSpace for a Quadrangle + ** + + @fn QuadReferenceSpace::~QuadReferenceSpace + Deletes this QuadReferenceSpace +*/ + +#endif diff --git a/FunctionSpace/ReferenceSpace.cpp b/FunctionSpace/ReferenceSpace.cpp index fca8c8cfac571f54361c7b4e38e144aba22a0af8..7b9ef5967bf5da468f81f49c707374eff0d1a4e0 100644 --- a/FunctionSpace/ReferenceSpace.cpp +++ b/FunctionSpace/ReferenceSpace.cpp @@ -7,6 +7,33 @@ using namespace std; ReferenceSpace::ReferenceSpace(void){ + // Init to NULL // + nVertex = 0; + nextLeafId = 0; + + nPerm = 0; + perm = NULL; + lPerm = NULL; + + nUnconnected = 0; + unconnected = NULL; + toBeUnconnected = NULL; + reduceBy = 0; + + pTreeRoot.depth = 0; + pTreeRoot.last = NULL; + pTreeRoot.number = 0; + pTreeRoot.possible = NULL; + pTreeRoot.next = NULL; + + nEdge = 0; + refEdge = NULL; + edge = NULL; + + nFace = 0; + refFace = NULL; + face = NULL; + // Defining Ref Edge and Face in // // Dervived Class // // And CALL INIT() // @@ -239,6 +266,24 @@ unsigned int ReferenceSpace::getPermutation(const MElement& elem) const{ // (vertex[i].second->getNum) // std::sort(vertex.begin(), vertex.end(), sortPredicate); + + /***************************************************************** + * What does that do ? * + * Tree lookup needs vertices in the range [0 .. nVertex[. * + * * + * So we need to convert the node ID from 'element.getVertex()' * + * to a number between [0 .. nVertex[. * + * * + * The convertion is such that the smallest node ID * + * gets the converted ID '0'. * + * Then the second smallest the ID '1'. * + * And so on... * + * * + * The sorting of the vector 'vertex' with respect * + * to the element.getVertex() IDs does that job * + *****************************************************************/ + + // Tree Lookup // try{ return treeLookup(&pTreeRoot, vertex); diff --git a/FunctionSpace/ReferenceSpace.h b/FunctionSpace/ReferenceSpace.h index 88e86a097839f6ce35fc3ec08bb0aac00bc19cfa..5fd8258b4489f5c0475bc126adba7102841b8056 100644 --- a/FunctionSpace/ReferenceSpace.h +++ b/FunctionSpace/ReferenceSpace.h @@ -3,6 +3,7 @@ #include <vector> #include <list> +#include <stack> #include <string> #include "MElement.h" @@ -35,13 +36,19 @@ class ReferenceSpace{ protected: // Permutation (Tree + Leaf) // - unsigned int nextLeafId; - unsigned int nVertex; - unsigned int nPerm; - unsigned int** perm; - node pTreeRoot; + unsigned int nVertex; + unsigned int nextLeafId; + + unsigned int nPerm; + unsigned int** perm; + std::list<unsigned int*>* lPerm; - mutable std::list<unsigned int*>* lPerm; + unsigned int nUnconnected; + std::pair<unsigned int, unsigned int>* unconnected; + std::stack<node*>* toBeUnconnected; + unsigned int reduceBy; + + node pTreeRoot; // Edge Permutation // unsigned int nEdge; @@ -77,6 +84,10 @@ class ReferenceSpace{ void populate(node* pTreeRoot); void destroy(node* node); + void unconnectWalk(node* pTreeRoot); // Find wrong permutations + void markAsUnconnect(node* pTreeRoot); // Mark leafs, with pTreeRoot as root, to be 'unconnected' + void unconnect(void); // Unconnects leafs marked before + void getEdge(void); void getFace(void); diff --git a/FunctionSpace/TetReferenceSpace.cpp b/FunctionSpace/TetReferenceSpace.cpp index 585744aa12d98b90f125ec7b5a98b748c46d2b65..b591b39023fc7f66908eec8a024e9b88e646cb97 100644 --- a/FunctionSpace/TetReferenceSpace.cpp +++ b/FunctionSpace/TetReferenceSpace.cpp @@ -65,10 +65,11 @@ string TetReferenceSpace::toLatex(void) const{ for(unsigned int p = 0; p < nPerm; p++){ stream << "\\begin{tikzpicture}" << endl - << "\\node[vertex] (n0) at(0, 0) {$0$};" << endl - << "\\node[vertex] (n1) at(3, 0) {$1$};" << endl - << "\\node[vertex] (n2) at(0, 3) {$2$};" << endl - << "\\node[vertex] (n3) at(1, 1) {$3$};" << endl << endl; + << "\\node[vertex] (n0) at(0, 0) {$" << perm[p][0] << "$};" << endl + << "\\node[vertex] (n1) at(3, 0) {$" << perm[p][1] << "$};" << endl + << "\\node[vertex] (n2) at(0, 3) {$" << perm[p][2] << "$};" << endl + << "\\node[vertex] (n3) at(1, 1) {$" << perm[p][3] << "$};" << endl + << endl; for(unsigned int i = 0; i < 6; i++) stream << "\\path[line]" diff --git a/FunctionSpace/TriReferenceSpace.cpp b/FunctionSpace/TriReferenceSpace.cpp index 92720d547cb1c07357c8a383e49f93ea7eff8af5..a0c9b9f46df300a9083d2959f629d3d77ebf82d5 100644 --- a/FunctionSpace/TriReferenceSpace.cpp +++ b/FunctionSpace/TriReferenceSpace.cpp @@ -19,7 +19,7 @@ TriReferenceSpace::TriReferenceSpace(void){ } // Face Definition // - nFace = 1; + nFace = 1; refFace = new unsigned int*[nFace]; refFace[0] = new unsigned int[3]; @@ -63,9 +63,10 @@ string TriReferenceSpace::toLatex(void) const{ for(unsigned int p = 0; p < nPerm; p++){ stream << "\\begin{tikzpicture}" << endl - << "\\node[vertex] (n0) at(0, 0) {$0$};" << endl - << "\\node[vertex] (n1) at(3, 0) {$1$};" << endl - << "\\node[vertex] (n2) at(0, 3) {$2$};" << endl << endl; + << "\\node[vertex] (n0) at(0, 0) {$" << perm[p][0] << "$};" << endl + << "\\node[vertex] (n1) at(3, 0) {$" << perm[p][1] << "$};" << endl + << "\\node[vertex] (n2) at(0, 3) {$" << perm[p][2] << "$};" << endl + << endl; for(unsigned int i = 0; i < 3; i++) stream << "\\path[line]"