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

Minor Fix to ReferenceSpace::toLatex -- Preparing QuadReferenceSpace

parent f33f9be3
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ set(SRC ...@@ -10,6 +10,7 @@ set(SRC
ReferenceSpace.cpp ReferenceSpace.cpp
LineReferenceSpace.cpp LineReferenceSpace.cpp
TriReferenceSpace.cpp TriReferenceSpace.cpp
QuadReferenceSpace.cpp
TetReferenceSpace.cpp TetReferenceSpace.cpp
Basis.cpp Basis.cpp
......
#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();
}
#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
...@@ -7,6 +7,33 @@ ...@@ -7,6 +7,33 @@
using namespace std; using namespace std;
ReferenceSpace::ReferenceSpace(void){ 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 // // Defining Ref Edge and Face in //
// Dervived Class // // Dervived Class //
// And CALL INIT() // // And CALL INIT() //
...@@ -239,6 +266,24 @@ unsigned int ReferenceSpace::getPermutation(const MElement& elem) const{ ...@@ -239,6 +266,24 @@ unsigned int ReferenceSpace::getPermutation(const MElement& elem) const{
// (vertex[i].second->getNum) // // (vertex[i].second->getNum) //
std::sort(vertex.begin(), vertex.end(), sortPredicate); 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 // // Tree Lookup //
try{ try{
return treeLookup(&pTreeRoot, vertex); return treeLookup(&pTreeRoot, vertex);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include <stack>
#include <string> #include <string>
#include "MElement.h" #include "MElement.h"
...@@ -35,13 +36,19 @@ class ReferenceSpace{ ...@@ -35,13 +36,19 @@ class ReferenceSpace{
protected: protected:
// Permutation (Tree + Leaf) // // Permutation (Tree + Leaf) //
unsigned int nextLeafId; unsigned int nVertex;
unsigned int nVertex; unsigned int nextLeafId;
unsigned int nPerm;
unsigned int** perm; unsigned int nPerm;
node pTreeRoot; 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 // // Edge Permutation //
unsigned int nEdge; unsigned int nEdge;
...@@ -77,6 +84,10 @@ class ReferenceSpace{ ...@@ -77,6 +84,10 @@ class ReferenceSpace{
void populate(node* pTreeRoot); void populate(node* pTreeRoot);
void destroy(node* node); 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 getEdge(void);
void getFace(void); void getFace(void);
......
...@@ -65,10 +65,11 @@ string TetReferenceSpace::toLatex(void) const{ ...@@ -65,10 +65,11 @@ string TetReferenceSpace::toLatex(void) const{
for(unsigned int p = 0; p < nPerm; p++){ for(unsigned int p = 0; p < nPerm; p++){
stream << "\\begin{tikzpicture}" << endl stream << "\\begin{tikzpicture}" << endl
<< "\\node[vertex] (n0) at(0, 0) {$0$};" << endl << "\\node[vertex] (n0) at(0, 0) {$" << perm[p][0] << "$};" << endl
<< "\\node[vertex] (n1) at(3, 0) {$1$};" << endl << "\\node[vertex] (n1) at(3, 0) {$" << perm[p][1] << "$};" << endl
<< "\\node[vertex] (n2) at(0, 3) {$2$};" << endl << "\\node[vertex] (n2) at(0, 3) {$" << perm[p][2] << "$};" << endl
<< "\\node[vertex] (n3) at(1, 1) {$3$};" << endl << endl; << "\\node[vertex] (n3) at(1, 1) {$" << perm[p][3] << "$};" << endl
<< endl;
for(unsigned int i = 0; i < 6; i++) for(unsigned int i = 0; i < 6; i++)
stream << "\\path[line]" stream << "\\path[line]"
......
...@@ -19,7 +19,7 @@ TriReferenceSpace::TriReferenceSpace(void){ ...@@ -19,7 +19,7 @@ TriReferenceSpace::TriReferenceSpace(void){
} }
// Face Definition // // Face Definition //
nFace = 1; nFace = 1;
refFace = new unsigned int*[nFace]; refFace = new unsigned int*[nFace];
refFace[0] = new unsigned int[3]; refFace[0] = new unsigned int[3];
...@@ -63,9 +63,10 @@ string TriReferenceSpace::toLatex(void) const{ ...@@ -63,9 +63,10 @@ string TriReferenceSpace::toLatex(void) const{
for(unsigned int p = 0; p < nPerm; p++){ for(unsigned int p = 0; p < nPerm; p++){
stream << "\\begin{tikzpicture}" << endl stream << "\\begin{tikzpicture}" << endl
<< "\\node[vertex] (n0) at(0, 0) {$0$};" << endl << "\\node[vertex] (n0) at(0, 0) {$" << perm[p][0] << "$};" << endl
<< "\\node[vertex] (n1) at(3, 0) {$1$};" << endl << "\\node[vertex] (n1) at(3, 0) {$" << perm[p][1] << "$};" << endl
<< "\\node[vertex] (n2) at(0, 3) {$2$};" << endl << endl; << "\\node[vertex] (n2) at(0, 3) {$" << perm[p][2] << "$};" << endl
<< endl;
for(unsigned int i = 0; i < 3; i++) for(unsigned int i = 0; i < 3; i++)
stream << "\\path[line]" stream << "\\path[line]"
......
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