BoundaryObject.cc 4.47 KB
Newer Older
1
2
3
4
5
6
7
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
8
 * Authors:
9
10
11
12
13
14
15
16
17
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
18
 *
19
 ******************************************************************************/
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35


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

namespace AMDiS {

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


36
37
38
39
  BoundaryObject::BoundaryObject(Element *e,
				 int eType,
				 GeoIndex sObj,
				 int iObj,
40
41
42
43
44
45
46
47
48
49
50
				 bool rMode)
  : el(e),
    elIndex(e->getIndex()),
    elType(eType),
    subObj(sObj),
    ithObj(iObj),
    reverseMode(rMode),
    excludedSubstructures(0)
  {}


51
  bool BoundaryObject::computeReverseMode(BoundaryObject &obj0,
52
53
54
55
56
57
58
					  BoundaryObject &obj1,
					  const FiniteElemSpace *feSpace,
					  BoundaryType boundary)
  {
    FUNCNAME("BoundaryObject::computeReverseMode()");

    bool reverseMode = false;
59

60
    TEST_EXIT_DBG(obj0.el && obj1.el)("BoundaryObject without element pointer.\n");
61
62
63
64
65
66
67
68

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

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


73
      if (obj0.subObj == EDGE) {
74
75
	int el0_v0 = obj0.el->getVertexOfEdge(obj0.ithObj, 0);
	int el1_v0 = obj0.el->getVertexOfEdge(obj1.ithObj, 0);
76
#ifndef NDEBUG
77
	int el0_v1 = obj0.el->getVertexOfEdge(obj0.ithObj, 1);
78
	int el1_v1 = obj0.el->getVertexOfEdge(obj1.ithObj, 1);
79
#endif
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

	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])
98
	    reverseMode = true;
99
100
101
102
103
104
105
106
107
108
109
110
	} 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);
111

112
113
	if (obj0.ithObj == 2 || obj0.ithObj == 3)
	  reverseMode = (localDofs0[0] != localDofs1[0]);
114

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
	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
  {
130
131
    return (other.elIndex == elIndex &&
	    other.subObj == subObj &&
132
133
134
135
136
137
	    other.ithObj == ithObj);
  }


  bool BoundaryObject::operator!=(const BoundaryObject& other) const
  {
138
139
    return (other.elIndex != elIndex ||
	    other.subObj != subObj ||
140
141
142
143
	    other.ithObj != ithObj);
  }


144
145
146
147
148
149
150
151
  bool BoundaryObject::operator<(const BoundaryObject& other) const
  {
    if (elIndex == other.elIndex) {
      if (subObj == other.subObj)
	return ithObj < other.ithObj;

      return subObj < other.subObj;
    }
152

153
154
155
156
    return (elIndex < other.elIndex);
  }


157
158
  bool AtomicBoundary::operator==(const AtomicBoundary& other) const
  {
159
160
    return (rankObj == other.rankObj &&
	    neighObj == other.neighObj &&
161
162
163
	    type == other.type);
  }

164
165
166
167
168
169
170
  bool AtomicBoundary::operator!=(const AtomicBoundary& other) const
  {
    return (rankObj != other.rankObj ||
	    neighObj != other.neighObj ||
	    type != other.type);
  }

171
}