FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
index_representative.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/shape.hpp>
10
11// includes, system
12#include <algorithm>
13
14namespace FEAT
15{
16 namespace Geometry
17 {
19 namespace Intern
20 {
26 template<typename Shape_>
27#ifndef DOXYGEN
28 struct IndexRepresentative;
29#else
30 struct IndexRepresentative
31 {
32 public:
42 template<
43 typename IndexVectorIn,
44 typename IndexVectorOut>
45 static void compute(IndexVectorOut& ivo, const IndexVectorIn& ivi);
46 };
47#endif // DOXYGEN
48
49 // specialization for Hypercube<1>
50 template<>
51 struct IndexRepresentative< Shape::Hypercube<1> >
52 {
53 template<
54 typename IndexVectorIn,
55 typename IndexVectorOut>
56 static void compute(IndexVectorOut& ivo, const IndexVectorIn& ivi)
57 {
58 ivo[0] = std::min(ivi[0], ivi[1]);
59 ivo[1] = std::max(ivi[0], ivi[1]);
60 }
61 }; // IndexRepresentative< Shape::Hypercube<1> >
62
63 // specialization for Hypercube<2>
64 template<>
65 struct IndexRepresentative< Shape::Hypercube<2> >
66 {
67 template<
68 typename IndexVectorIn,
69 typename IndexVectorOut>
70 static void compute(IndexVectorOut& ivo, const IndexVectorIn& ivi)
71 {
72 ivo[0] = std::min(std::min(ivi[0], ivi[1]), std::min(ivi[2], ivi[3]));
73
74 int i = 0;
75
76 while(ivi[i] != ivo[0])
77 {
78 ++i;
79 }
80
81 if((i == 0) || (i == 3))
82 {
83 ivo[1] = std::min(ivi[1], ivi[2]);
84 ivo[2] = std::max(ivi[1], ivi[2]);
85 }
86 else
87 {
88 ivo[1] = std::min(ivi[0], ivi[3]);
89 ivo[2] = std::max(ivi[0], ivi[3]);
90 }
91
92 ivo[3] = ivi[0] + ivi[1] + ivi[2] + ivi[3] - ivo[0] - ivo[1] - ivo[2];
93 }
94 }; // IndexRepresentative< Shape::Hypercube<2> >
95
96 // specialization for Simplex<1>
97 template<>
98 struct IndexRepresentative< Shape::Simplex<1> >
99 {
100 template<
101 typename IndexVectorIn,
102 typename IndexVectorOut>
103 static void compute(IndexVectorOut& ivo, const IndexVectorIn& ivi)
104 {
105 ivo[0] = std::min(ivi[0], ivi[1]);
106 ivo[1] = std::max(ivi[0], ivi[1]);
107 }
108 }; // IndexRepresentative< Shape::Simplex<1> >
109
110 // specialization for Simplex<2>
111 template<>
112 struct IndexRepresentative< Shape::Simplex<2> >
113 {
114 template<
115 typename IndexVectorIn,
116 typename IndexVectorOut>
117 static void compute(IndexVectorOut& ivo, const IndexVectorIn& ivi)
118 {
119 ivo[0] = std::min(std::min(ivi[0], ivi[1]), ivi[2]);
120 ivo[2] = std::max(std::max(ivi[0], ivi[1]), ivi[2]);
121 ivo[1] = ivi[0] + ivi[1] + ivi[2] - ivo[0] - ivo[2];
122 }
123 }; // IndexRepresentative< Shape::Simplex<2> >
124 } // namespace Intern
126 } // namespace Geometry
127} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12