BoundaryObject.cc 3.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


#include "BoundaryObject.h"
#include "Mesh.h"
#include "FiniteElemSpace.h"
#include "BasisFunction.h"

namespace AMDiS {

  BoundaryObject::BoundaryObject()
    : elType(0),
      reverseMode(false),
      excludedSubstructures(0)
  {}


  BoundaryObject::BoundaryObject(Element *e, 
				 int eType, 
				 GeoIndex sObj, 
				 int iObj, 
				 bool rMode)
  : el(e),
    elIndex(e->getIndex()),
    elType(eType),
    subObj(sObj),
    ithObj(iObj),
    reverseMode(rMode),
    excludedSubstructures(0)
  {}


  bool BoundaryObject::computeReverseMode(BoundaryObject &obj0, 
					  BoundaryObject &obj1,
					  const FiniteElemSpace *feSpace,
					  BoundaryType boundary)
  {
    FUNCNAME("BoundaryObject::computeReverseMode()");

    bool reverseMode = false;

    switch (feSpace->getMesh()->getDim()) {
    case 2:
      reverseMode = true;
      break;

    case 3:
      TEST_EXIT_DBG(obj1.elType == 0)
	("Only 3D macro elements with level 0 are supported. This element has level %d!\n", 
	 obj1.elType);


      if (obj0.subObj == EDGE) {	
	int el0_v0 = obj0.el->getVertexOfEdge(obj0.ithObj, 0);
	int el1_v0 = obj0.el->getVertexOfEdge(obj1.ithObj, 0);
65
66
#if DEBUG != 0
	int el0_v1 = obj0.el->getVertexOfEdge(obj0.ithObj, 1);
67
	int el1_v1 = obj0.el->getVertexOfEdge(obj1.ithObj, 1);
68
#endif
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

	const BasisFunction *basFcts = feSpace->getBasisFcts();
	int nBasFcts = basFcts->getNumber();
	std::vector<DegreeOfFreedom> localDofs0(nBasFcts), localDofs1(nBasFcts);
	basFcts->getLocalIndices(obj0.el, feSpace->getAdmin(), localDofs0);
	basFcts->getLocalIndices(obj1.el, feSpace->getAdmin(), localDofs1);

	Mesh *mesh = feSpace->getMesh();

	if (mesh->isPeriodicAssociation(boundary) == false) {
	  TEST_EXIT_DBG(localDofs0[el0_v0] == localDofs1[el1_v0] ||
			localDofs0[el0_v0] == localDofs1[el1_v1])
	    ("This should not happen!\n");
	  TEST_EXIT_DBG(localDofs0[el0_v1] == localDofs1[el1_v0] ||
			localDofs0[el0_v1] == localDofs1[el1_v1])
	    ("This should not happen!\n");

	  if (localDofs0[el0_v0] != localDofs1[el1_v0])
	    reverseMode = true; 	
	} else {
	  if (mesh->associated(localDofs0[el0_v0], localDofs1[el1_v0]) == false)
	    reverseMode = true;
	}
      }

      if (obj0.subObj == FACE && obj0.ithObj != 1) {
	const BasisFunction *basFcts = feSpace->getBasisFcts();
	int nBasFcts = basFcts->getNumber();
	std::vector<DegreeOfFreedom> localDofs0(nBasFcts), localDofs1(nBasFcts);
	basFcts->getLocalIndices(obj0.el, feSpace->getAdmin(), localDofs0);
	basFcts->getLocalIndices(obj1.el, feSpace->getAdmin(), localDofs1);
	
	if (obj0.ithObj == 2 || obj0.ithObj == 3)
	  reverseMode = (localDofs0[0] != localDofs1[0]);
	  
	if (obj0.ithObj == 0)
	  reverseMode = (localDofs0[1] != localDofs1[1]);
      }
      break;

    default:
      ERROR_EXIT("This should not happen!\n");
    }

    return reverseMode;
  }


  bool BoundaryObject::operator==(const BoundaryObject& other) const
  {
    return (other.elIndex == elIndex && 
	    other.subObj == subObj && 
	    other.ithObj == ithObj);
  }


  bool BoundaryObject::operator!=(const BoundaryObject& other) const
  {
    return (other.elIndex != elIndex || 
	    other.subObj != subObj || 
	    other.ithObj != ithObj);
  }


133
134
135
136
137
138
139
140
141
142
143
144
145
  bool BoundaryObject::operator<(const BoundaryObject& other) const
  {
    if (elIndex == other.elIndex) {
      if (subObj == other.subObj)
	return ithObj < other.ithObj;

      return subObj < other.subObj;
    }
     
    return (elIndex < other.elIndex);
  }


146
147
148
149
150
151
152
  bool AtomicBoundary::operator==(const AtomicBoundary& other) const
  {
    return (rankObj == other.rankObj && 
	    neighObj == other.neighObj && 
	    type == other.type);
  }

153
154
155
156
157
158
159
  bool AtomicBoundary::operator!=(const AtomicBoundary& other) const
  {
    return (rankObj != other.rankObj ||
	    neighObj != other.neighObj ||
	    type != other.type);
  }

160
}