Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lexorder_comparators.cpp
Go to the documentation of this file.
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
34namespace ug{
35
36
37// Order for 1D
38template<int dim, size_t orderDim>
39bool ComparePosDim(const std::pair<MathVector<dim>, size_t> &p1,
40 const std::pair<MathVector<dim>, size_t> &p2)
41{return false;}
42
43template<>
44bool ComparePosDim<1, 0>(const std::pair<MathVector<1>, size_t> &p1,
45 const std::pair<MathVector<1>, size_t> &p2)
46{
47 return (p1.first[0]<p2.first[0]);
48};
49
50// Order for 2D
51template<>
52bool ComparePosDim<2,0>(const std::pair<MathVector<2>, size_t> &p1,
53 const std::pair<MathVector<2>, size_t> &p2)
54{
55 if (p1.first[0]==p2.first[0]) {
56 return (p1.first[1] < p2.first[1]);
57 }
58 else {
59 return (p1.first[0] < p2.first[0]);
60 }
61};
62template<>
63bool ComparePosDim<2,1>(const std::pair<MathVector<2>, size_t> &p1,
64 const std::pair<MathVector<2>, size_t> &p2)
65{
66 if (p1.first[1]==p2.first[1]) {
67 return (p1.first[0] < p2.first[0]);
68 }
69 else {
70 return (p1.first[1] < p2.first[1]);
71 }
72};
73
74// Order for 3D
75template<>
76bool ComparePosDim<3,0>(const std::pair<MathVector<3>, size_t> &p1,
77 const std::pair<MathVector<3>, size_t> &p2)
78{
79 if (p1.first[2]==p2.first[2]){
80 if (p1.first[1]==p2.first[1]) {
81 return p1.first[0] < p2.first[0];
82 }
83 else {
84 return (p1.first[1] < p2.first[1]);
85 }
86 }
87 else{
88 return (p1.first[2] < p2.first[2]);
89 }
90};
91template<>
92bool ComparePosDim<3,1>(const std::pair<MathVector<3>, size_t> &p1,
93 const std::pair<MathVector<3>, size_t> &p2)
94{
95 if (p1.first[0]==p2.first[0]){
96 if (p1.first[2]==p2.first[2]) {
97 return p1.first[1] < p2.first[1];
98 }
99 else {
100 return (p1.first[2] < p2.first[2]);
101 }
102 }
103 else{
104 return (p1.first[0] < p2.first[0]);
105 }
106};
107template<>
108bool ComparePosDim<3,2>(const std::pair<MathVector<3>, size_t> &p1,
109 const std::pair<MathVector<3>, size_t> &p2)
110{
111 if (p1.first[1]==p2.first[1]){
112 if (p1.first[0]==p2.first[0]) {
113 return p1.first[2] < p2.first[2];
114 }
115 else {
116 return (p1.first[0] < p2.first[0]);
117 }
118 }
119 else{
120 return (p1.first[1] < p2.first[1]);
121 }
122};
123
124
125//Decreasing
126
127// Order for 1D
128template<int dim, size_t orderDim>
129bool ComparePosDimDec(const std::pair<MathVector<dim>, size_t> &p1,
130 const std::pair<MathVector<dim>, size_t> &p2)
131{return false;}
132
133template<>
134bool ComparePosDimDec<1, 0>(const std::pair<MathVector<1>, size_t> &p1,
135 const std::pair<MathVector<1>, size_t> &p2)
136{
137 return (p1.first[0]>p2.first[0]);
138};
139
140// Order for 2D
141template<>
142bool ComparePosDimDec<2,0>(const std::pair<MathVector<2>, size_t> &p1,
143 const std::pair<MathVector<2>, size_t> &p2)
144{
145 if (p1.first[0]==p2.first[0]) {
146 return (p1.first[1] > p2.first[1]);
147 }
148 else {
149 return (p1.first[0] > p2.first[0]);
150 }
151};
152template<>
153bool ComparePosDimDec<2,1>(const std::pair<MathVector<2>, size_t> &p1,
154 const std::pair<MathVector<2>, size_t> &p2)
155{
156 if (p1.first[1]==p2.first[1]) {
157 return (p1.first[0] > p2.first[0]);
158 }
159 else {
160 return (p1.first[1] > p2.first[1]);
161 }
162};
163
164// Order for 3D
165template<>
166bool ComparePosDimDec<3,0>(const std::pair<MathVector<3>, size_t> &p1,
167 const std::pair<MathVector<3>, size_t> &p2)
168{
169 if (p1.first[2]==p2.first[2]){
170 if (p1.first[1]==p2.first[1]) {
171 return p1.first[0] > p2.first[0];
172 }
173 else {
174 return (p1.first[1] > p2.first[1]);
175 }
176 }
177 else{
178 return (p1.first[2] > p2.first[2]);
179 }
180};
181template<>
182bool ComparePosDimDec<3,1>(const std::pair<MathVector<3>, size_t> &p1,
183 const std::pair<MathVector<3>, size_t> &p2)
184{
185 if (p1.first[0]==p2.first[0]){
186 if (p1.first[2]==p2.first[2]) {
187 return p1.first[1] > p2.first[1];
188 }
189 else {
190 return (p1.first[2] > p2.first[2]);
191 }
192 }
193 else{
194 return (p1.first[0] > p2.first[0]);
195 }
196};
197template<>
198bool ComparePosDimDec<3,2>(const std::pair<MathVector<3>, size_t> &p1,
199 const std::pair<MathVector<3>, size_t> &p2)
200{
201 if (p1.first[1]==p2.first[1]){
202 if (p1.first[0]==p2.first[0]) {
203 return p1.first[2] > p2.first[2];
204 }
205 else {
206 return (p1.first[0] > p2.first[0]);
207 }
208 }
209 else{
210 return (p1.first[1] > p2.first[1]);
211 }
212};
213
214
215}
a mathematical Vector with N entries.
Definition math_vector.h:97
the ug namespace
bool ComparePosDim< 3, 1 >(const std::pair< MathVector< 3 >, size_t > &p1, const std::pair< MathVector< 3 >, size_t > &p2)
Definition lexorder_comparators.cpp:92
bool ComparePosDim(const std::pair< MathVector< dim >, size_t > &p1, const std::pair< MathVector< dim >, size_t > &p2)
Definition lexorder_comparators.cpp:39
bool ComparePosDim< 3, 2 >(const std::pair< MathVector< 3 >, size_t > &p1, const std::pair< MathVector< 3 >, size_t > &p2)
Definition lexorder_comparators.cpp:108
bool ComparePosDim< 1, 0 >(const std::pair< MathVector< 1 >, size_t > &p1, const std::pair< MathVector< 1 >, size_t > &p2)
Definition lexorder_comparators.cpp:44
bool ComparePosDimDec< 2, 1 >(const std::pair< MathVector< 2 >, size_t > &p1, const std::pair< MathVector< 2 >, size_t > &p2)
Definition lexorder_comparators.cpp:153
bool ComparePosDimDec< 3, 1 >(const std::pair< MathVector< 3 >, size_t > &p1, const std::pair< MathVector< 3 >, size_t > &p2)
Definition lexorder_comparators.cpp:182
bool ComparePosDimDec< 1, 0 >(const std::pair< MathVector< 1 >, size_t > &p1, const std::pair< MathVector< 1 >, size_t > &p2)
Definition lexorder_comparators.cpp:134
bool ComparePosDimDec< 3, 2 >(const std::pair< MathVector< 3 >, size_t > &p1, const std::pair< MathVector< 3 >, size_t > &p2)
Definition lexorder_comparators.cpp:198
bool ComparePosDim< 2, 0 >(const std::pair< MathVector< 2 >, size_t > &p1, const std::pair< MathVector< 2 >, size_t > &p2)
Definition lexorder_comparators.cpp:52
bool ComparePosDim< 3, 0 >(const std::pair< MathVector< 3 >, size_t > &p1, const std::pair< MathVector< 3 >, size_t > &p2)
Definition lexorder_comparators.cpp:76
bool ComparePosDimDec(const std::pair< MathVector< dim >, size_t > &p1, const std::pair< MathVector< dim >, size_t > &p2)
Definition lexorder_comparators.cpp:129
bool ComparePosDimDec< 3, 0 >(const std::pair< MathVector< 3 >, size_t > &p1, const std::pair< MathVector< 3 >, size_t > &p2)
Definition lexorder_comparators.cpp:166
bool ComparePosDim< 2, 1 >(const std::pair< MathVector< 2 >, size_t > &p1, const std::pair< MathVector< 2 >, size_t > &p2)
Definition lexorder_comparators.cpp:63
bool ComparePosDimDec< 2, 0 >(const std::pair< MathVector< 2 >, size_t > &p1, const std::pair< MathVector< 2 >, size_t > &p2)
Definition lexorder_comparators.cpp:142