Triangle.cc 1.93 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "Triangle.h"
#include "DOFAdmin.h"
#include "Mesh.h"
#include "CoarseningManager.h"
#include "FixVec.h"

namespace AMDiS {

  const int Triangle::vertexOfEdge[3][2] = {{1,2}, {2,0}, {0,1}};
  const int Triangle::sideOfChild[2][3] = {{-1,2,0}, {2,-1,1}};
  const int Triangle::vertexOfParent[2][3] = {{2,0,-1}, {1,2,-1}};

  bool Triangle::hasSide(Element* sideElem) const
  {
    FUNCNAME("Triangle::hasSide");
16
    TEST_EXIT_DBG(sideElem->isLine())("called for sideElem-type != Line\n");
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
    ERROR_EXIT("not yet\n");
    return false;
  }

  int Triangle::getVertexOfPosition(GeoIndex position,
				    int      positionIndex,
				    int      vertexIndex) const 
  {
    FUNCNAME("Triangle::getVertexOfPosition");
    switch(position) {
    case VERTEX:
      return positionIndex;
      break;
    case EDGE:
      return vertexOfEdge[positionIndex][vertexIndex];
      break;
    case CENTER:
      return vertexIndex;
      break;
    default:
      ERROR_EXIT("invalid position\n");
      return 0;
    }
  }

  const FixVec<int, WORLD>&
  Triangle::sortFaceIndices(int face, FixVec<int,WORLD> *vec) const
  {
    static MatrixOfFixVecs<FixVec<int,WORLD> > *sorted_2d = NULL;

    int no = 0;
    const int *vof = NULL;
    FixVec<int,WORLD> *val = NULL;
    vof = vertexOfEdge[face];

    if (NULL==sorted_2d) {
      sorted_2d = new MatrixOfFixVecs<FixVec<int,WORLD> >(2,3,2,NO_INIT);

      (*sorted_2d)[1][0][1]=(*sorted_2d)[1][1][0]=
	(*sorted_2d)[2][0][0]=(*sorted_2d)[2][1][1]=0;
      (*sorted_2d)[0][0][0]=(*sorted_2d)[0][1][1]=
	(*sorted_2d)[2][0][1]=(*sorted_2d)[2][1][0]=1;
      (*sorted_2d)[0][0][1]=(*sorted_2d)[0][1][0]=
	(*sorted_2d)[1][0][0]=(*sorted_2d)[1][1][1]=2;
    }

    if (dof[vof[0]][0] < dof[vof[1]][0])
      no = 0;
    else
      no = 1;

    if (vec) {
      val = vec;
      *val = (*sorted_2d)[face][no];
    }
    else
      val = &((*sorted_2d)[face][no]);

    return(*(const_cast<const FixVec<int,WORLD>* >(val)));
  }

}