Line data Source code
1 : /*
2 : * Copyright (c) 2011-2022: G-CSC, Goethe University Frankfurt
3 : * Author: Andreas Vogel, Lukas Larisch
4 : *
5 : * This file is part of UG4.
6 : *
7 : * UG4 is free software: you can redistribute it and/or modify it under the
8 : * terms of the GNU Lesser General Public License version 3 (as published by the
9 : * Free Software Foundation) with the following additional attribution
10 : * requirements (according to LGPL/GPL v3 §7):
11 : *
12 : * (1) The following notice must be displayed in the Appropriate Legal Notices
13 : * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 : *
15 : * (2) The following notice must be displayed at a prominent place in the
16 : * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 : *
18 : * (3) The following bibliography is recommended for citation and must be
19 : * preserved in all covered files:
20 : * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 : * parallel geometric multigrid solver on hierarchically distributed grids.
22 : * Computing and visualization in science 16, 4 (2013), 151-164"
23 : * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 : * flexible software system for simulating pde based models on high performance
25 : * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 : *
27 : * This program is distributed in the hope that it will be useful,
28 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : * GNU Lesser General Public License for more details.
31 : */
32 :
33 :
34 : namespace ug{
35 :
36 :
37 : // Order for 1D
38 : template<int dim, size_t orderDim>
39 0 : bool ComparePosDim(const std::pair<MathVector<dim>, size_t> &p1,
40 : const std::pair<MathVector<dim>, size_t> &p2)
41 0 : {return false;}
42 :
43 : template<>
44 0 : bool ComparePosDim<1, 0>(const std::pair<MathVector<1>, size_t> &p1,
45 : const std::pair<MathVector<1>, size_t> &p2)
46 : {
47 0 : return (p1.first[0]<p2.first[0]);
48 : };
49 :
50 : // Order for 2D
51 : template<>
52 0 : bool ComparePosDim<2,0>(const std::pair<MathVector<2>, size_t> &p1,
53 : const std::pair<MathVector<2>, size_t> &p2)
54 : {
55 0 : if (p1.first[0]==p2.first[0]) {
56 0 : return (p1.first[1] < p2.first[1]);
57 : }
58 : else {
59 0 : return (p1.first[0] < p2.first[0]);
60 : }
61 : };
62 : template<>
63 0 : bool ComparePosDim<2,1>(const std::pair<MathVector<2>, size_t> &p1,
64 : const std::pair<MathVector<2>, size_t> &p2)
65 : {
66 0 : if (p1.first[1]==p2.first[1]) {
67 0 : return (p1.first[0] < p2.first[0]);
68 : }
69 : else {
70 0 : return (p1.first[1] < p2.first[1]);
71 : }
72 : };
73 :
74 : // Order for 3D
75 : template<>
76 0 : bool ComparePosDim<3,0>(const std::pair<MathVector<3>, size_t> &p1,
77 : const std::pair<MathVector<3>, size_t> &p2)
78 : {
79 0 : if (p1.first[2]==p2.first[2]){
80 0 : if (p1.first[1]==p2.first[1]) {
81 0 : return p1.first[0] < p2.first[0];
82 : }
83 : else {
84 0 : return (p1.first[1] < p2.first[1]);
85 : }
86 : }
87 : else{
88 0 : return (p1.first[2] < p2.first[2]);
89 : }
90 : };
91 : template<>
92 0 : bool ComparePosDim<3,1>(const std::pair<MathVector<3>, size_t> &p1,
93 : const std::pair<MathVector<3>, size_t> &p2)
94 : {
95 0 : if (p1.first[0]==p2.first[0]){
96 0 : if (p1.first[2]==p2.first[2]) {
97 0 : return p1.first[1] < p2.first[1];
98 : }
99 : else {
100 0 : return (p1.first[2] < p2.first[2]);
101 : }
102 : }
103 : else{
104 0 : return (p1.first[0] < p2.first[0]);
105 : }
106 : };
107 : template<>
108 0 : bool ComparePosDim<3,2>(const std::pair<MathVector<3>, size_t> &p1,
109 : const std::pair<MathVector<3>, size_t> &p2)
110 : {
111 0 : if (p1.first[1]==p2.first[1]){
112 0 : if (p1.first[0]==p2.first[0]) {
113 0 : return p1.first[2] < p2.first[2];
114 : }
115 : else {
116 0 : return (p1.first[0] < p2.first[0]);
117 : }
118 : }
119 : else{
120 0 : return (p1.first[1] < p2.first[1]);
121 : }
122 : };
123 :
124 :
125 : //Decreasing
126 :
127 : // Order for 1D
128 : template<int dim, size_t orderDim>
129 0 : bool ComparePosDimDec(const std::pair<MathVector<dim>, size_t> &p1,
130 : const std::pair<MathVector<dim>, size_t> &p2)
131 0 : {return false;}
132 :
133 : template<>
134 0 : bool ComparePosDimDec<1, 0>(const std::pair<MathVector<1>, size_t> &p1,
135 : const std::pair<MathVector<1>, size_t> &p2)
136 : {
137 0 : return (p1.first[0]>p2.first[0]);
138 : };
139 :
140 : // Order for 2D
141 : template<>
142 0 : bool ComparePosDimDec<2,0>(const std::pair<MathVector<2>, size_t> &p1,
143 : const std::pair<MathVector<2>, size_t> &p2)
144 : {
145 0 : if (p1.first[0]==p2.first[0]) {
146 0 : return (p1.first[1] > p2.first[1]);
147 : }
148 : else {
149 0 : return (p1.first[0] > p2.first[0]);
150 : }
151 : };
152 : template<>
153 0 : bool ComparePosDimDec<2,1>(const std::pair<MathVector<2>, size_t> &p1,
154 : const std::pair<MathVector<2>, size_t> &p2)
155 : {
156 0 : if (p1.first[1]==p2.first[1]) {
157 0 : return (p1.first[0] > p2.first[0]);
158 : }
159 : else {
160 0 : return (p1.first[1] > p2.first[1]);
161 : }
162 : };
163 :
164 : // Order for 3D
165 : template<>
166 0 : bool ComparePosDimDec<3,0>(const std::pair<MathVector<3>, size_t> &p1,
167 : const std::pair<MathVector<3>, size_t> &p2)
168 : {
169 0 : if (p1.first[2]==p2.first[2]){
170 0 : if (p1.first[1]==p2.first[1]) {
171 0 : return p1.first[0] > p2.first[0];
172 : }
173 : else {
174 0 : return (p1.first[1] > p2.first[1]);
175 : }
176 : }
177 : else{
178 0 : return (p1.first[2] > p2.first[2]);
179 : }
180 : };
181 : template<>
182 0 : bool ComparePosDimDec<3,1>(const std::pair<MathVector<3>, size_t> &p1,
183 : const std::pair<MathVector<3>, size_t> &p2)
184 : {
185 0 : if (p1.first[0]==p2.first[0]){
186 0 : if (p1.first[2]==p2.first[2]) {
187 0 : return p1.first[1] > p2.first[1];
188 : }
189 : else {
190 0 : return (p1.first[2] > p2.first[2]);
191 : }
192 : }
193 : else{
194 0 : return (p1.first[0] > p2.first[0]);
195 : }
196 : };
197 : template<>
198 0 : bool ComparePosDimDec<3,2>(const std::pair<MathVector<3>, size_t> &p1,
199 : const std::pair<MathVector<3>, size_t> &p2)
200 : {
201 0 : if (p1.first[1]==p2.first[1]){
202 0 : if (p1.first[0]==p2.first[0]) {
203 0 : return p1.first[2] > p2.first[2];
204 : }
205 : else {
206 0 : return (p1.first[0] > p2.first[0]);
207 : }
208 : }
209 : else{
210 0 : return (p1.first[1] > p2.first[1]);
211 : }
212 : };
213 :
214 :
215 : }
|