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

ReferenceSpace reworking -- seems ok

parent cd1427a6
No related branches found
No related tags found
No related merge requests found
File changed. Contains only whitespace changes. Show whitespace changes.
File changed. Contains only whitespace changes. Show whitespace changes.
File changed. Contains only whitespace changes. Show whitespace changes.
...@@ -19,10 +19,8 @@ LineReferenceSpace::LineReferenceSpace(void){ ...@@ -19,10 +19,8 @@ LineReferenceSpace::LineReferenceSpace(void){
nFace = 0; nFace = 0;
refFace = NULL; refFace = NULL;
// Init All (Use Tri Face -- // // Init All //
// unused -- // init();
// just for interface) //
init(0);
} }
LineReferenceSpace::~LineReferenceSpace(void){ LineReferenceSpace::~LineReferenceSpace(void){
... ...
......
...@@ -19,7 +19,14 @@ QuadReferenceSpace::QuadReferenceSpace(void){ ...@@ -19,7 +19,14 @@ QuadReferenceSpace::QuadReferenceSpace(void){
} }
// Face Definition // // Face Definition //
// Number of face
nFace = 1; nFace = 1;
// Number of node per face
nNodeInFace = new unsigned int[nFace];
nNodeInFace[0] = 4;
// Reference Face
refFace = new unsigned int*[nFace]; refFace = new unsigned int*[nFace];
refFace[0] = new unsigned int[4]; refFace[0] = new unsigned int[4];
...@@ -28,8 +35,8 @@ QuadReferenceSpace::QuadReferenceSpace(void){ ...@@ -28,8 +35,8 @@ QuadReferenceSpace::QuadReferenceSpace(void){
refFace[0][2] = 2; refFace[0][2] = 2;
refFace[0][3] = 3; refFace[0][3] = 3;
// Init All (Quad Face) // // Init All //
init(1); init();
} }
QuadReferenceSpace::~QuadReferenceSpace(void){ QuadReferenceSpace::~QuadReferenceSpace(void){
...@@ -44,6 +51,7 @@ QuadReferenceSpace::~QuadReferenceSpace(void){ ...@@ -44,6 +51,7 @@ QuadReferenceSpace::~QuadReferenceSpace(void){
delete[] refFace[i]; delete[] refFace[i];
delete[] refFace; delete[] refFace;
delete[] nNodeInFace;
} }
string QuadReferenceSpace::toLatex(void) const{ string QuadReferenceSpace::toLatex(void) const{
... ...
......
...@@ -15,11 +15,6 @@ ReferenceSpace::ReferenceSpace(void){ ...@@ -15,11 +15,6 @@ ReferenceSpace::ReferenceSpace(void){
perm = NULL; perm = NULL;
lPerm = NULL; lPerm = NULL;
nUnconnected = 0;
unconnected = NULL;
toBeUnconnected = NULL;
reduceBy = 0;
pTreeRoot.depth = 0; pTreeRoot.depth = 0;
pTreeRoot.last = NULL; pTreeRoot.last = NULL;
pTreeRoot.number = 0; pTreeRoot.number = 0;
...@@ -28,20 +23,17 @@ ReferenceSpace::ReferenceSpace(void){ ...@@ -28,20 +23,17 @@ ReferenceSpace::ReferenceSpace(void){
nEdge = 0; nEdge = 0;
refEdge = NULL; refEdge = NULL;
permutedRefEdge = NULL;
edge = NULL; edge = NULL;
nFace = 0; nFace = 0;
nNodeInFace = NULL;
refFace = NULL; refFace = NULL;
permutedRefFace = NULL;
face = NULL; face = NULL;
// Defining Ref Edge and Face in // // Defining Ref Edge and Face in //
// Dervived Class // // Dervived Class //
// And CALL init(faceType) //
// //
// faceType is: //
// * 0 if triangular faces //
// * 1 if quadragular faces //
// * 3 if NOT IMPLEMENTED //
} }
ReferenceSpace::~ReferenceSpace(void){ ReferenceSpace::~ReferenceSpace(void){
...@@ -51,32 +43,34 @@ ReferenceSpace::~ReferenceSpace(void){ ...@@ -51,32 +43,34 @@ ReferenceSpace::~ReferenceSpace(void){
// Delete Permutated Edge // // Delete Permutated Edge //
for(unsigned int p = 0; p < nPerm; p++){ for(unsigned int p = 0; p < nPerm; p++){
for(unsigned int i = 0; i < nEdge; i++) for(unsigned int i = 0; i < nEdge; i++){
delete[] permutedRefEdge[p][i];
delete (*(*edge)[p])[i]; delete (*(*edge)[p])[i];
}
delete[] permutedRefEdge[p];
delete (*edge)[p]; delete (*edge)[p];
} }
delete[] permutedRefEdge;
delete edge; delete edge;
// Delete Permutated Face // // Delete Permutated Face //
for(unsigned int p = 0; p < nPerm; p++){ for(unsigned int p = 0; p < nPerm; p++){
for(unsigned int i = 0; i < nFace; i++) for(unsigned int i = 0; i < nFace; i++){
delete[] permutedRefFace[p][i];
delete (*(*face)[p])[i]; delete (*(*face)[p])[i];
}
delete[] permutedRefFace[p];
delete (*face)[p]; delete (*face)[p];
} }
delete[] permutedRefFace;
delete face; delete face;
} }
void ReferenceSpace::init(unsigned int faceType){ void ReferenceSpace::init(void){
if(faceType > 3)
throw Exception("ReferenceSpace: unknown face type");
if(faceType == 3)
throw Exception("ReferenceSpace: prism not implemented");
// Init Root // // Init Root //
nPerm = 0; nPerm = 0;
nextLeafId = 0; nextLeafId = 0;
...@@ -94,7 +88,7 @@ void ReferenceSpace::init(unsigned int faceType){ ...@@ -94,7 +88,7 @@ void ReferenceSpace::init(unsigned int faceType){
lPerm = new list<unsigned int*>; lPerm = new list<unsigned int*>;
populate(&pTreeRoot); populate(&pTreeRoot);
// Get Permutations // // Get Permutation //
perm = new unsigned int*[nPerm]; perm = new unsigned int*[nPerm];
for(unsigned int i = 0; i < nPerm; i++){ for(unsigned int i = 0; i < nPerm; i++){
// Take Permutation for queue // Take Permutation for queue
...@@ -107,13 +101,7 @@ void ReferenceSpace::init(unsigned int faceType){ ...@@ -107,13 +101,7 @@ void ReferenceSpace::init(unsigned int faceType){
// Get Edges & Faces // // Get Edges & Faces //
getEdge(); getEdge();
getFace();
switch(faceType){
case 0: getTriFace(); break;
case 1: getQuaFace(); break;
default: throw Exception("ReferenceSpace: impossible error");
}
} }
void ReferenceSpace::populate(node* pTreeRoot){ void ReferenceSpace::populate(node* pTreeRoot){
...@@ -121,10 +109,9 @@ void ReferenceSpace::populate(node* pTreeRoot){ ...@@ -121,10 +109,9 @@ void ReferenceSpace::populate(node* pTreeRoot){
const unsigned int number = pTreeRoot->number; const unsigned int number = pTreeRoot->number;
const unsigned int nextNumber = number - 1; const unsigned int nextNumber = number - 1;
const unsigned int depth = pTreeRoot->depth; const unsigned int depth = pTreeRoot->depth;
const unsigned int nextDepth = pTreeRoot->depth + 1; const unsigned int nextDepth = depth + 1;
// Temp Data // // Temp Data //
unsigned int nextLast;
unsigned int offset; unsigned int offset;
// If Leaf : a new permutation is found // // If Leaf : a new permutation is found //
...@@ -149,13 +136,13 @@ void ReferenceSpace::populate(node* pTreeRoot){ ...@@ -149,13 +136,13 @@ void ReferenceSpace::populate(node* pTreeRoot){
// Init each child node // Init each child node
for(unsigned int i = 0; i < number; i++){ for(unsigned int i = 0; i < number; i++){
nextLast = pTreeRoot->possible[i]; // Reset offset
offset = 0; offset = 0;
// Depth and Last Choices of child nodes // Depth and Last Choices of child nodes
pTreeRoot->next[i].depth = nextDepth; pTreeRoot->next[i].depth = nextDepth;
pTreeRoot->next[i].last = new unsigned int[nextDepth]; pTreeRoot->next[i].last = new unsigned int[nextDepth];
pTreeRoot->next[i].last[depth] = nextLast; pTreeRoot->next[i].last[depth] = pTreeRoot->possible[i];
for(unsigned int j = 0; j < depth; j++) for(unsigned int j = 0; j < depth; j++)
pTreeRoot->next[i].last[j] = pTreeRoot->last[j]; pTreeRoot->next[i].last[j] = pTreeRoot->last[j];
...@@ -165,7 +152,7 @@ void ReferenceSpace::populate(node* pTreeRoot){ ...@@ -165,7 +152,7 @@ void ReferenceSpace::populate(node* pTreeRoot){
pTreeRoot->next[i].possible = new unsigned int[nextNumber]; pTreeRoot->next[i].possible = new unsigned int[nextNumber];
for(unsigned int j = 0; j < nextNumber; j++){ for(unsigned int j = 0; j < nextNumber; j++){
if(pTreeRoot->possible[j] == nextLast) if(pTreeRoot->possible[j] == pTreeRoot->possible[i])
offset = 1; offset = 1;
pTreeRoot->next[i].possible[j] = pTreeRoot->possible[j + offset]; pTreeRoot->next[i].possible[j] = pTreeRoot->possible[j + offset];
...@@ -191,165 +178,247 @@ void ReferenceSpace::destroy(node* node){ ...@@ -191,165 +178,247 @@ void ReferenceSpace::destroy(node* node){
} }
void ReferenceSpace::getEdge(void){ void ReferenceSpace::getEdge(void){
// Alloc
vector<const vector<unsigned int>*>* tmp; vector<const vector<unsigned int>*>* tmp;
edge = new vector<const vector<const vector<unsigned int>*>*>(nPerm); edge = new vector<const vector<const vector<unsigned int>*>*>(nPerm);
// All Edges have two nodes
unsigned int* nNodeInEdge = new unsigned int[nEdge];
for(unsigned int e = 0; e < nEdge; e++)
nNodeInEdge[e] = 2;
// Get Edge nodes depending on the orientation
// (edge 1 = [1 2] for orientation 1)
// ( = [4 1] for orientation 2)
getPermutedRefEntity(&permutedRefEdge,
refEdge,
nNodeInEdge,
nEdge);
delete[] nNodeInEdge;
// Populate Edge
for(unsigned int p = 0; p < nPerm; p++){ for(unsigned int p = 0; p < nPerm; p++){
tmp = new vector<const vector<unsigned int>*>(nEdge); tmp = new vector<const vector<unsigned int>*>(nEdge);
for(unsigned int i = 0; i < nEdge; i++) for(unsigned int e = 0; e < nEdge; e++)
(*tmp)[i] = inOrder(p, (*tmp)[e] = getOrderedEdge(p, e);
refEdge[i][0],
refEdge[i][1]);
(*edge)[p] = tmp; (*edge)[p] = tmp;
} }
} }
void ReferenceSpace::getTriFace(void){ void ReferenceSpace::getFace(void){
// Alloc
vector<const vector<unsigned int>*>* tmp; vector<const vector<unsigned int>*>* tmp;
face = new vector<const vector<const vector<unsigned int>*>*>(nPerm); face = new vector<const vector<const vector<unsigned int>*>*>(nPerm);
// Get Face nodes depending on the orientation
// (face 1 = [1 2 3 4] for orientation 1)
// ( = [4 1 2 3] for orientation 2)
getPermutedRefEntity(&permutedRefFace,
refFace,
nNodeInFace,
nFace);
// Populate Face
for(unsigned int p = 0; p < nPerm; p++){ for(unsigned int p = 0; p < nPerm; p++){
tmp = new vector<const vector<unsigned int>*>(nFace); tmp = new vector<const vector<unsigned int>*>(nFace);
for(unsigned int i = 0; i < nFace; i++) for(unsigned int f = 0; f < nFace; f++){
(*tmp)[i] = inOrder(p, // Dending on the number of node per face
refFace[i][0], // The ordering strategy is different
refFace[i][1],
refFace[i][2]); switch(nNodeInFace[f]){
case 3: (*tmp)[f] = getOrderedTriFace(p, f); break;
case 4: (*tmp)[f] = getOrderedQuadFace(p, f); break;
default:
throw Exception("I can handle face with %d nodes",
nNodeInFace[f]);
}
}
(*face)[p] = tmp; (*face)[p] = tmp;
} }
} }
void ReferenceSpace::getQuaFace(void){ void ReferenceSpace::getPermutedRefEntity(unsigned int**** permutedRefEntity,
vector<const vector<unsigned int>*>* tmp; unsigned int** refEntity,
face = new vector<const vector<const vector<unsigned int>*>*>(nPerm); unsigned int* nNodeInEntity,
unsigned int nEntity){
// Alloc PermutedRefEntity
(*permutedRefEntity) = new unsigned int**[nPerm];
for(unsigned int p = 0; p < nPerm; p++){ for(unsigned int p = 0; p < nPerm; p++){
tmp = new vector<const vector<unsigned int>*>(nFace); (*permutedRefEntity)[p] = new unsigned int*[nEntity];
for(unsigned int i = 0; i < nFace; i++) for(unsigned int e = 0; e < nEntity; e++)
(*tmp)[i] = inOrder(p, (*permutedRefEntity)[p][e] = new unsigned int[nNodeInEntity[e]];
refFace[i][0],
refFace[i][1],
refFace[i][2],
refFace[i][3]);
(*face)[p] = tmp;
}
} }
const vector<unsigned int>* ReferenceSpace:: // Alloc Idx
inOrder(unsigned int permutation, unsigned int** idx = new unsigned int*[nEntity];
unsigned int a,
unsigned int b){
unsigned int v; for(unsigned int e = 0; e < nEntity; e++)
unsigned int k = 0; idx[e] = new unsigned int[nNodeInEntity[e]];
vector<unsigned int>* inorder =
new vector<unsigned int>(2);
for(unsigned int i = 0; i < nVertex; i++){ // Get Reference Index
v = perm[permutation][i]; // Use refEntity and perm[0] as reference element
for(unsigned int e = 0; e < nEntity; e++)
getIndex(nNodeInEntity[e], refEntity[e], nVertex, perm[0], &idx[e]);
if(v == a || v == b){ // Generate Permuted Ref Entity
(*inorder)[k] = v; for(unsigned int p = 0; p < nPerm; p++){
k++; for(unsigned int e = 0; e < nEntity; e++){
for(unsigned int n = 0; n < nNodeInEntity[e]; n++)
(*permutedRefEntity)[p][e][n] = perm[p][idx[e][n]];
} }
} }
return inorder; // Delete Temp
for(unsigned int e = 0; e < nEntity; e++)
delete[] idx[e];
delete[] idx;
} }
const std::vector<unsigned int>* ReferenceSpace:: const vector<unsigned int>* ReferenceSpace::
inOrder(unsigned int permutation, getOrderedEdge(unsigned int permutation,
unsigned int a, unsigned int edge){
unsigned int b,
unsigned int c){
unsigned int v; /*************************************************************************
unsigned int k = 0; * Let say we have we have permutedRefEdge[4][2] = [0 1]. *
vector<unsigned int>* inorder = * I want to get back to same node ID than refEdge[2] = [2 0]. *
new vector<unsigned int>(3); * That is, I want to return [0 2]. *
* *
* I need to sort permutedRefEdge and keep the index swaping. *
* I can use this index swaping to get the right permutation of refEdge. *
*************************************************************************/
for(unsigned int i = 0; i < nVertex; i++){ // Alloc
v = perm[permutation][i]; vector<unsigned int>* ordered = new vector<unsigned int>(2);
if(v == a || v == b || v == c){ // Sort & Swap
(*inorder)[k] = v; sortAndSwap(permutedRefEdge[permutation][edge],
k++; refEdge[edge],
} *ordered);
}
return inorder; // Return ordered
return ordered;
} }
const std::vector<unsigned int>* ReferenceSpace:: const std::vector<unsigned int>* ReferenceSpace::
inOrder(unsigned int permutation, getOrderedTriFace(unsigned int permutation,
unsigned int a, unsigned int face){
unsigned int b,
unsigned int c,
unsigned int d){
unsigned int opposite; /******************************************************
* Same as getOrderedEdge, but I need to use 3 nodes. *
******************************************************/
unsigned int v; // Alloc
unsigned int k = 0; vector<unsigned int>* ordered = new vector<unsigned int>(3);
vector<unsigned int>* inorder =
new vector<unsigned int>(4);
// Take nodes in order // // Sort & Swap
for(unsigned int i = 0; i < nVertex; i++){ sortAndSwap(permutedRefFace[permutation][face],
v = perm[permutation][i]; refFace[face],
*ordered);
if(v == a || v == b || v == c || v == d){ // Return ordered
(*inorder)[k] = v; return ordered;
k++;
} }
}
// We need node at inoder[2] to be //
// opposite to node at inorder[0] //
// --> if not make a permutation such //
// that node opposite at inorder[2] //
// is at inorder[0] //
opposite = ((*inorder)[0] + 2) % 4; const std::vector<unsigned int>* ReferenceSpace::
if((*inorder)[2] != opposite){ getOrderedQuadFace(unsigned int permutation,
unsigned int face){
/*********************************************************************
* Same as getOrderedEdge, but I need to use 4 nodes. *
* *
* Moreover, *
* I need node at ordered[2] to be *opposite* to node at ordered[0]. *
* --> If not make a permutation such *
* that node opposite at ordered[2] *
* is at ordered[0] *
*********************************************************************/
// Alloc
vector<unsigned int>* ordered = new vector<unsigned int>(4);
// Sort & Swap
sortAndSwap(permutedRefFace[permutation][face],
refFace[face],
*ordered);
// Get ordered[2] opposite to ordered[0]
unsigned int opposite = ((*ordered)[0] + 2) % 4;
if((*ordered)[2] != opposite){
// Find opposite node index // Find opposite node index
unsigned int tmp; unsigned int tmp;
unsigned int idx = 1; unsigned int idx = 1;
while((*inorder)[idx] != opposite) while((*ordered)[idx] != opposite)
idx++; idx++;
// Swap inorder[2] and inorder[idx] // Swap ordered[2] and ordered[idx]
tmp = (*inorder)[2]; tmp = (*ordered)[2];
(*inorder)[2] = opposite; (*ordered)[2] = opposite;
(*inorder)[idx] = tmp; (*ordered)[idx] = tmp;
}
// Return
return ordered;
}
void ReferenceSpace::sortAndSwap(unsigned int* srcSort,
unsigned int* srcSwap,
vector<unsigned int>& dest){
// Get Size
const unsigned int size = dest.size();
// Copy srcSort in sorted
vector<pair<unsigned int, unsigned int> > sorted(size);
for(unsigned int i = 0; i < size; i++){
sorted[i].first = i;
sorted[i].second = srcSort[i];
} }
return inorder; // Sort it with repsect to second entry
std::sort(sorted.begin(), sorted.end(), sortPredicate);
// Swap with respect to srcSwap
for(unsigned int i = 0; i < size; i++)
dest[i] = srcSwap[sorted[i].first];
} }
unsigned int ReferenceSpace::getPermutation(const MElement& elem) const{ unsigned int ReferenceSpace::getPermutation(const MElement& elem) const{
// Const_Cast // // Const_Cast //
MElement& element = const_cast<MElement&>(elem); MElement& element = const_cast<MElement&>(elem);
// Get Primary Vertices // // Get Primary Vertices Global ID //
const int nVertex = element.getNumPrimaryVertices(); const int nVertex = element.getNumPrimaryVertices();
vector<pair<unsigned int, MVertex*> > vertex(nVertex); vector<pair<unsigned int, unsigned int> > vertexGlobalId(nVertex);
for(int i = 0; i < nVertex; i++){ for(int i = 0; i < nVertex; i++){
vertex[i].first = i; vertexGlobalId[i].first = i;
vertex[i].second = element.getVertex(i); vertexGlobalId[i].second = element.getVertex(i)->getNum();
} }
// Sort Them with repsect to Vertex Global ID // // Sort Them with repsect to Vertex Global ID //
// (vertex[i].second->getNum) // // (vertex[i].second->getNum) //
std::sort(vertex.begin(), vertex.end(), sortPredicate); std::sort(vertexGlobalId.begin(), vertexGlobalId.end(), sortPredicate);
// Reduce Vertex Global ID //
vector<unsigned int> vertexReducedId(nVertex);
for(int i = 0; i < nVertex; i++)
vertexReducedId[vertexGlobalId[i].first] = i;
// Tree Lookup // // Tree Lookup //
try{ try{
return treeLookup(&pTreeRoot, vertex); return treeLookup(&pTreeRoot, vertexReducedId);
} }
catch(...){ catch(...){
...@@ -359,8 +428,7 @@ unsigned int ReferenceSpace::getPermutation(const MElement& elem) const{ ...@@ -359,8 +428,7 @@ unsigned int ReferenceSpace::getPermutation(const MElement& elem) const{
} }
unsigned int ReferenceSpace::treeLookup(const node* root, unsigned int ReferenceSpace::treeLookup(const node* root,
vector<pair<unsigned int, MVertex*> >& vector<unsigned int>& vertexReducedId){
sortedArray){
// Temp Data // // Temp Data //
unsigned int choice; unsigned int choice;
unsigned int i; unsigned int i;
...@@ -368,7 +436,7 @@ unsigned int ReferenceSpace::treeLookup(const node* root, ...@@ -368,7 +436,7 @@ unsigned int ReferenceSpace::treeLookup(const node* root,
// If Root is *not* a Leaf: Lookup // // If Root is *not* a Leaf: Lookup //
if(root->number){ if(root->number){
// Get This Choice // Get This Choice
choice = sortedArray[root->depth].first; choice = vertexReducedId[root->depth];
// Look for next node corresponding to this Choice // Look for next node corresponding to this Choice
i = 0; i = 0;
...@@ -380,7 +448,7 @@ unsigned int ReferenceSpace::treeLookup(const node* root, ...@@ -380,7 +448,7 @@ unsigned int ReferenceSpace::treeLookup(const node* root,
throw Exception(); throw Exception();
// Go to next Node // Go to next Node
return treeLookup(&root->next[i], sortedArray); return treeLookup(&root->next[i], vertexReducedId);
} }
// Else: Return Leaf ID // // Else: Return Leaf ID //
... ...
......
...@@ -23,8 +23,8 @@ class ReferenceSpace{ ...@@ -23,8 +23,8 @@ class ReferenceSpace{
struct node_s{ struct node_s{
unsigned int depth; // Depth unsigned int depth; // Depth
unsigned int* last; // Last Choises unsigned int* last; // Last Choises
unsigned int number; // Number of Next Choise unsigned int number; // Number of Next Choises
unsigned int* possible; // Possible Next Choise unsigned int* possible; // Possible Next Choises
node_s* next; // Next Choise node_s* next; // Next Choise
unsigned int leafId; // If leaf: this leaf number unsigned int leafId; // If leaf: this leaf number
...@@ -43,21 +43,19 @@ class ReferenceSpace{ ...@@ -43,21 +43,19 @@ class ReferenceSpace{
unsigned int** perm; unsigned int** perm;
std::list<unsigned int*>* lPerm; std::list<unsigned int*>* lPerm;
unsigned int nUnconnected;
std::pair<unsigned int, unsigned int>* unconnected;
std::stack<node*>* toBeUnconnected;
unsigned int reduceBy;
node pTreeRoot; node pTreeRoot;
// Edge Permutation // // Edge Permutation //
unsigned int nEdge; unsigned int nEdge;
unsigned int** refEdge; unsigned int** refEdge;
unsigned int*** permutedRefEdge;
std::vector<const std::vector<const std::vector<unsigned int>*>*>* edge; std::vector<const std::vector<const std::vector<unsigned int>*>*>* edge;
// Face Permutation // // Face Permutation //
unsigned int nFace; unsigned int nFace;
unsigned int* nNodeInFace;
unsigned int** refFace; unsigned int** refFace;
unsigned int*** permutedRefFace;
std::vector<const std::vector<const std::vector<unsigned int>*>*>* face; std::vector<const std::vector<const std::vector<unsigned int>*>*>* face;
public: public:
...@@ -80,39 +78,46 @@ class ReferenceSpace{ ...@@ -80,39 +78,46 @@ class ReferenceSpace{
protected: protected:
ReferenceSpace(void); ReferenceSpace(void);
void init(unsigned int faceType); void init(void);
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 getTriFace(void); void getFace(void);
void getQuaFace(void);
void getPermutedRefEntity(unsigned int**** permutedRefEntity,
unsigned int** refEntity,
unsigned int* nNodeInEntity,
unsigned int nEntity);
const std::vector<unsigned int>* getOrderedEdge(unsigned int permutation,
unsigned int edge);
const std::vector<unsigned int>* inOrder(unsigned int permutation, const std::vector<unsigned int>* getOrderedTriFace(unsigned int permutation,
unsigned int a, unsigned int face);
unsigned int b);
const std::vector<unsigned int>* inOrder(unsigned int permutation, const std::vector<unsigned int>* getOrderedQuadFace(unsigned int permutation,
unsigned int a, unsigned int face);
unsigned int b,
unsigned int c);
const std::vector<unsigned int>* inOrder(unsigned int permutation, static void sortAndSwap(unsigned int* srcSort,
unsigned int a, unsigned int* srcSwap,
unsigned int b, std::vector<unsigned int>& dest);
unsigned int c,
unsigned int d);
static bool sortPredicate(const std::pair<unsigned int, MVertex*>& a, static unsigned int whereIsIncluded(unsigned int elem,
const std::pair<unsigned int, MVertex*>& b); unsigned int* vec,
unsigned int size);
static void getIndex(unsigned int sizeRef,
unsigned int* ref,
unsigned int sizeVec,
unsigned int* vec,
unsigned int** idx);
static bool sortPredicate(const std::pair<unsigned int, unsigned int>& a,
const std::pair<unsigned int, unsigned int>& b);
static unsigned int treeLookup(const node* root, static unsigned int treeLookup(const node* root,
std::vector<std::pair<unsigned int, MVertex*> >& std::vector<unsigned int>& vertexReducedId);
sortedArray);
std::string toString(const node* node) const; std::string toString(const node* node) const;
}; };
...@@ -199,11 +204,34 @@ ReferenceSpace::getAllFace(void) const{ ...@@ -199,11 +204,34 @@ ReferenceSpace::getAllFace(void) const{
return *face; return *face;
} }
inline
void ReferenceSpace::getIndex(unsigned int sizeRef,
unsigned int* ref,
unsigned int sizeVec,
unsigned int* vec,
unsigned int** idx){
for(unsigned int i = 0; i < sizeRef; i++)
(*idx)[i] = whereIsIncluded(ref[i], vec, sizeVec);
}
inline
unsigned int ReferenceSpace::whereIsIncluded(unsigned int elem,
unsigned int* vec,
unsigned int size){
for(unsigned int i = 0; i < size; i++)
if(vec[i] == elem)
return i;
return -1;
}
inline inline
bool bool
ReferenceSpace::sortPredicate(const std::pair<unsigned int, MVertex*>& a, ReferenceSpace::sortPredicate(const std::pair<unsigned int, unsigned int>& a,
const std::pair<unsigned int, MVertex*>& b){ const std::pair<unsigned int, unsigned int>& b){
return a.second->getNum() < b.second->getNum(); return a.second < b.second;
} }
#endif #endif
...@@ -19,7 +19,16 @@ TetReferenceSpace::TetReferenceSpace(void){ ...@@ -19,7 +19,16 @@ TetReferenceSpace::TetReferenceSpace(void){
} }
// Face Definition // // Face Definition //
// Number of face
nFace = 4; nFace = 4;
// Number of node per face
nNodeInFace = new unsigned int[nFace];
for(unsigned int f = 0; f < nFace; f++)
nNodeInFace[f] = 3;
// Reference Face
refFace = new unsigned int*[nFace]; refFace = new unsigned int*[nFace];
for(unsigned int i = 0; i < nFace; i++){ for(unsigned int i = 0; i < nFace; i++){
...@@ -29,8 +38,8 @@ TetReferenceSpace::TetReferenceSpace(void){ ...@@ -29,8 +38,8 @@ TetReferenceSpace::TetReferenceSpace(void){
refFace[i][2] = MTetrahedron::faces_tetra(i, 2); refFace[i][2] = MTetrahedron::faces_tetra(i, 2);
} }
// Init All (Tri Face) // // Init All //
init(0); init();
} }
TetReferenceSpace::~TetReferenceSpace(void){ TetReferenceSpace::~TetReferenceSpace(void){
...@@ -45,6 +54,7 @@ TetReferenceSpace::~TetReferenceSpace(void){ ...@@ -45,6 +54,7 @@ TetReferenceSpace::~TetReferenceSpace(void){
delete[] refFace[i]; delete[] refFace[i];
delete[] refFace; delete[] refFace;
delete[] nNodeInFace;
} }
string TetReferenceSpace::toLatex(void) const{ string TetReferenceSpace::toLatex(void) const{
... ...
......
...@@ -30,14 +30,14 @@ TriLagrangeBasis::TriLagrangeBasis(unsigned int order){ ...@@ -30,14 +30,14 @@ TriLagrangeBasis::TriLagrangeBasis(unsigned int order){
(gmshGeneratePointsTriangle(order, false)); (gmshGeneratePointsTriangle(order, false));
// ReferenceSpace // // ReferenceSpace //
refSpace = new TriLagrangeReferenceSpace(order); // refSpace = new TriLagrangeReferenceSpace(order);
std::cout << refSpace->toString() << std::endl; // std::cout << refSpace->toString() << std::endl;
} }
TriLagrangeBasis::~TriLagrangeBasis(void){ TriLagrangeBasis::~TriLagrangeBasis(void){
delete lBasis; delete lBasis;
delete lPoint; delete lPoint;
delete refSpace; // delete refSpace;
} }
unsigned int TriLagrangeBasis::getTag(unsigned int order){ unsigned int TriLagrangeBasis::getTag(unsigned int order){
... ...
......
...@@ -26,8 +26,8 @@ TriLagrangeReferenceSpace::TriLagrangeReferenceSpace(unsigned int order){ ...@@ -26,8 +26,8 @@ TriLagrangeReferenceSpace::TriLagrangeReferenceSpace(unsigned int order){
refFace[0][1] = 1; refFace[0][1] = 1;
refFace[0][2] = 2; refFace[0][2] = 2;
// Init ReferenceSpace (Tri Face) // // Init ReferenceSpace //
init(0); init();
// Get Lagrange Node // // Get Lagrange Node //
nNodePerEdge = 3 * (order - 1) / nEdge; nNodePerEdge = 3 * (order - 1) / nEdge;
... ...
......
...@@ -19,7 +19,14 @@ TriReferenceSpace::TriReferenceSpace(void){ ...@@ -19,7 +19,14 @@ TriReferenceSpace::TriReferenceSpace(void){
} }
// Face Definition // // Face Definition //
// Number of face
nFace = 1; nFace = 1;
// Number of node per face
nNodeInFace = new unsigned int[nFace];
nNodeInFace[0] = 3;
// Reference Face
refFace = new unsigned int*[nFace]; refFace = new unsigned int*[nFace];
refFace[0] = new unsigned int[3]; refFace[0] = new unsigned int[3];
...@@ -27,8 +34,8 @@ TriReferenceSpace::TriReferenceSpace(void){ ...@@ -27,8 +34,8 @@ TriReferenceSpace::TriReferenceSpace(void){
refFace[0][1] = 1; refFace[0][1] = 1;
refFace[0][2] = 2; refFace[0][2] = 2;
// Init All (Tri Face) // // Init All //
init(0); init();
} }
TriReferenceSpace::~TriReferenceSpace(void){ TriReferenceSpace::~TriReferenceSpace(void){
...@@ -43,6 +50,7 @@ TriReferenceSpace::~TriReferenceSpace(void){ ...@@ -43,6 +50,7 @@ TriReferenceSpace::~TriReferenceSpace(void){
delete[] refFace[i]; delete[] refFace[i];
delete[] refFace; delete[] refFace;
delete[] nNodeInFace;
} }
string TriReferenceSpace::toLatex(void) const{ string TriReferenceSpace::toLatex(void) const{
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment