MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_VariableDofLaplacianFactory_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef PACKAGES_MUELU_SRC_GRAPH_MUELU_VARIABLEDOFLAPLACIANFACTORY_DECL_HPP_
11 #define PACKAGES_MUELU_SRC_GRAPH_MUELU_VARIABLEDOFLAPLACIANFACTORY_DECL_HPP_
12 
13 #include "MueLu_ConfigDefs.hpp"
16 #include "MueLu_Level_fwd.hpp"
17 
18 #include "MueLu_Utilities_fwd.hpp"
19 
20 namespace MueLu {
21 
62 template <class Scalar = DefaultScalar,
65  class Node = DefaultNode>
67 #undef MUELU_VARIABLEDOFLAPLACIANFACTORY_SHORT
68 #include "MueLu_UseShortNames.hpp"
69 
70  public:
72 
73 
76 
79 
81 
83 
85 
86 
87  void DeclareInput(Level& currentLevel) const;
88 
90 
91  void Build(Level& currentLevel) const; // Build
92 
93  private:
94  void buildPaddedMap(const Teuchos::ArrayRCP<const LocalOrdinal>& dofPresent, std::vector<LocalOrdinal>& map, size_t nDofs) const;
95  void assignGhostLocalNodeIds(const Teuchos::RCP<const Map>& rowDofMap, const Teuchos::RCP<const Map>& colDofMap, std::vector<LocalOrdinal>& myLocalNodeIds, const std::vector<LocalOrdinal>& dofMap, size_t maxDofPerNode, size_t& nLocalNodes, size_t& nLocalPlusGhostNodes, Teuchos::RCP<const Teuchos::Comm<int> > comm) const;
96  void squeezeOutNnzs(Teuchos::ArrayRCP<size_t>& rowPtr, Teuchos::ArrayRCP<LocalOrdinal>& cols, Teuchos::ArrayRCP<Scalar>& vals, const std::vector<bool>& keep) const;
98 
99  template <class listType>
100  void MueLu_az_sort(listType list[], size_t N, size_t list2[], Scalar list3[]) const {
101  /* local variables */
102 
103  listType RR, K;
104  size_t l, r, j, i;
105  int flag;
106  size_t RR2;
107  Scalar RR3;
108 
109  /*********************** execution begins ******************************/
110 
111  if (N <= 1) return;
112 
113  l = N / 2 + 1;
114  r = N - 1;
115  l = l - 1;
116  RR = list[l - 1];
117  K = list[l - 1];
118 
119  if ((list2 != NULL) && (list3 != NULL)) {
120  RR2 = list2[l - 1];
121  RR3 = list3[l - 1];
122  while (r != 0) {
123  j = l;
124  flag = 1;
125 
126  while (flag == 1) {
127  i = j;
128  j = j + j;
129 
130  if (j > r + 1)
131  flag = 0;
132  else {
133  if (j < r + 1)
134  if (list[j] > list[j - 1]) j = j + 1;
135 
136  if (list[j - 1] > K) {
137  list[i - 1] = list[j - 1];
138  list2[i - 1] = list2[j - 1];
139  list3[i - 1] = list3[j - 1];
140  } else {
141  flag = 0;
142  }
143  }
144  }
145 
146  list[i - 1] = RR;
147  list2[i - 1] = RR2;
148  list3[i - 1] = RR3;
149 
150  if (l == 1) {
151  RR = list[r];
152  RR2 = list2[r];
153  RR3 = list3[r];
154 
155  K = list[r];
156  list[r] = list[0];
157  list2[r] = list2[0];
158  list3[r] = list3[0];
159  r = r - 1;
160  } else {
161  l = l - 1;
162  RR = list[l - 1];
163  RR2 = list2[l - 1];
164  RR3 = list3[l - 1];
165  K = list[l - 1];
166  }
167  }
168 
169  list[0] = RR;
170  list2[0] = RR2;
171  list3[0] = RR3;
172  } else if (list2 != NULL) {
173  RR2 = list2[l - 1];
174  while (r != 0) {
175  j = l;
176  flag = 1;
177 
178  while (flag == 1) {
179  i = j;
180  j = j + j;
181 
182  if (j > r + 1)
183  flag = 0;
184  else {
185  if (j < r + 1)
186  if (list[j] > list[j - 1]) j = j + 1;
187 
188  if (list[j - 1] > K) {
189  list[i - 1] = list[j - 1];
190  list2[i - 1] = list2[j - 1];
191  } else {
192  flag = 0;
193  }
194  }
195  }
196 
197  list[i - 1] = RR;
198  list2[i - 1] = RR2;
199 
200  if (l == 1) {
201  RR = list[r];
202  RR2 = list2[r];
203 
204  K = list[r];
205  list[r] = list[0];
206  list2[r] = list2[0];
207  r = r - 1;
208  } else {
209  l = l - 1;
210  RR = list[l - 1];
211  RR2 = list2[l - 1];
212  K = list[l - 1];
213  }
214  }
215 
216  list[0] = RR;
217  list2[0] = RR2;
218  } else if (list3 != NULL) {
219  RR3 = list3[l - 1];
220  while (r != 0) {
221  j = l;
222  flag = 1;
223 
224  while (flag == 1) {
225  i = j;
226  j = j + j;
227 
228  if (j > r + 1)
229  flag = 0;
230  else {
231  if (j < r + 1)
232  if (list[j] > list[j - 1]) j = j + 1;
233 
234  if (list[j - 1] > K) {
235  list[i - 1] = list[j - 1];
236  list3[i - 1] = list3[j - 1];
237  } else {
238  flag = 0;
239  }
240  }
241  }
242 
243  list[i - 1] = RR;
244  list3[i - 1] = RR3;
245 
246  if (l == 1) {
247  RR = list[r];
248  RR3 = list3[r];
249 
250  K = list[r];
251  list[r] = list[0];
252  list3[r] = list3[0];
253  r = r - 1;
254  } else {
255  l = l - 1;
256  RR = list[l - 1];
257  RR3 = list3[l - 1];
258  K = list[l - 1];
259  }
260  }
261 
262  list[0] = RR;
263  list3[0] = RR3;
264 
265  } else {
266  while (r != 0) {
267  j = l;
268  flag = 1;
269 
270  while (flag == 1) {
271  i = j;
272  j = j + j;
273 
274  if (j > r + 1)
275  flag = 0;
276  else {
277  if (j < r + 1)
278  if (list[j] > list[j - 1]) j = j + 1;
279 
280  if (list[j - 1] > K) {
281  list[i - 1] = list[j - 1];
282  } else {
283  flag = 0;
284  }
285  }
286  }
287 
288  list[i - 1] = RR;
289 
290  if (l == 1) {
291  RR = list[r];
292 
293  K = list[r];
294  list[r] = list[0];
295  r = r - 1;
296  } else {
297  l = l - 1;
298  RR = list[l - 1];
299  K = list[l - 1];
300  }
301  }
302 
303  list[0] = RR;
304  }
305  }
306 
307 }; // class CoalesceDropFactory
308 
309 } // namespace MueLu
310 
311 #define MUELU_VARIABLEDOFLAPLACIANFACTORY_SHORT
312 
313 #endif /* PACKAGES_MUELU_SRC_GRAPH_MUELU_VARIABLEDOFLAPLACIANFACTORY_DECL_HPP_ */
void buildPaddedMap(const Teuchos::ArrayRCP< const LocalOrdinal > &dofPresent, std::vector< LocalOrdinal > &map, size_t nDofs) const
MueLu::DefaultLocalOrdinal LocalOrdinal
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
void buildLaplacian(const Teuchos::ArrayRCP< size_t > &rowPtr, const Teuchos::ArrayRCP< LocalOrdinal > &cols, Teuchos::ArrayRCP< Scalar > &vals, const size_t &numdim, const RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LocalOrdinal, GlobalOrdinal, Node > > &ghostedCoords) const
void DeclareInput(Level &currentLevel) const
Input.
MueLu::DefaultNode Node
void assignGhostLocalNodeIds(const Teuchos::RCP< const Map > &rowDofMap, const Teuchos::RCP< const Map > &colDofMap, std::vector< LocalOrdinal > &myLocalNodeIds, const std::vector< LocalOrdinal > &dofMap, size_t maxDofPerNode, size_t &nLocalNodes, size_t &nLocalPlusGhostNodes, Teuchos::RCP< const Teuchos::Comm< int > > comm) const
void MueLu_az_sort(listType list[], size_t N, size_t list2[], Scalar list3[]) const
MueLu::DefaultScalar Scalar
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
void Build(Level &currentLevel) const
Build an object with this factory.
Factory for building scalar Laplace operator (that is used as fake operator for variable dof size pro...
void squeezeOutNnzs(Teuchos::ArrayRCP< size_t > &rowPtr, Teuchos::ArrayRCP< LocalOrdinal > &cols, Teuchos::ArrayRCP< Scalar > &vals, const std::vector< bool > &keep) const
Base class for factories that use one level (currentLevel).
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.