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 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Tobias Wiesner (tawiesn@sandia.gov)
42 // Ray Tuminaro (rstumin@sandia.gov)
43 //
44 // ***********************************************************************
45 //
46 // @HEADER
47 #ifndef PACKAGES_MUELU_SRC_GRAPH_MUELU_VARIABLEDOFLAPLACIANFACTORY_DECL_HPP_
48 #define PACKAGES_MUELU_SRC_GRAPH_MUELU_VARIABLEDOFLAPLACIANFACTORY_DECL_HPP_
49 
50 #include "MueLu_ConfigDefs.hpp"
53 #include "MueLu_Level_fwd.hpp"
54 
55 #include "MueLu_Utilities_fwd.hpp"
56 
57 namespace MueLu {
58 
99 template <class Scalar = DefaultScalar,
102  class Node = DefaultNode>
104 #undef MUELU_VARIABLEDOFLAPLACIANFACTORY_SHORT
105 #include "MueLu_UseShortNames.hpp"
106 
107  public:
109 
110 
113 
116 
118 
120 
122 
123 
124  void DeclareInput(Level& currentLevel) const;
125 
127 
128  void Build(Level& currentLevel) const; // Build
129 
130  private:
131  void buildPaddedMap(const Teuchos::ArrayRCP<const LocalOrdinal>& dofPresent, std::vector<LocalOrdinal>& map, size_t nDofs) const;
132  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;
133  void squeezeOutNnzs(Teuchos::ArrayRCP<size_t>& rowPtr, Teuchos::ArrayRCP<LocalOrdinal>& cols, Teuchos::ArrayRCP<Scalar>& vals, const std::vector<bool>& keep) const;
135 
136  template <class listType>
137  void MueLu_az_sort(listType list[], size_t N, size_t list2[], Scalar list3[]) const {
138  /* local variables */
139 
140  listType RR, K;
141  size_t l, r, j, i;
142  int flag;
143  size_t RR2;
144  Scalar RR3;
145 
146  /*********************** execution begins ******************************/
147 
148  if (N <= 1) return;
149 
150  l = N / 2 + 1;
151  r = N - 1;
152  l = l - 1;
153  RR = list[l - 1];
154  K = list[l - 1];
155 
156  if ((list2 != NULL) && (list3 != NULL)) {
157  RR2 = list2[l - 1];
158  RR3 = list3[l - 1];
159  while (r != 0) {
160  j = l;
161  flag = 1;
162 
163  while (flag == 1) {
164  i = j;
165  j = j + j;
166 
167  if (j > r + 1)
168  flag = 0;
169  else {
170  if (j < r + 1)
171  if (list[j] > list[j - 1]) j = j + 1;
172 
173  if (list[j - 1] > K) {
174  list[i - 1] = list[j - 1];
175  list2[i - 1] = list2[j - 1];
176  list3[i - 1] = list3[j - 1];
177  } else {
178  flag = 0;
179  }
180  }
181  }
182 
183  list[i - 1] = RR;
184  list2[i - 1] = RR2;
185  list3[i - 1] = RR3;
186 
187  if (l == 1) {
188  RR = list[r];
189  RR2 = list2[r];
190  RR3 = list3[r];
191 
192  K = list[r];
193  list[r] = list[0];
194  list2[r] = list2[0];
195  list3[r] = list3[0];
196  r = r - 1;
197  } else {
198  l = l - 1;
199  RR = list[l - 1];
200  RR2 = list2[l - 1];
201  RR3 = list3[l - 1];
202  K = list[l - 1];
203  }
204  }
205 
206  list[0] = RR;
207  list2[0] = RR2;
208  list3[0] = RR3;
209  } else if (list2 != NULL) {
210  RR2 = list2[l - 1];
211  while (r != 0) {
212  j = l;
213  flag = 1;
214 
215  while (flag == 1) {
216  i = j;
217  j = j + j;
218 
219  if (j > r + 1)
220  flag = 0;
221  else {
222  if (j < r + 1)
223  if (list[j] > list[j - 1]) j = j + 1;
224 
225  if (list[j - 1] > K) {
226  list[i - 1] = list[j - 1];
227  list2[i - 1] = list2[j - 1];
228  } else {
229  flag = 0;
230  }
231  }
232  }
233 
234  list[i - 1] = RR;
235  list2[i - 1] = RR2;
236 
237  if (l == 1) {
238  RR = list[r];
239  RR2 = list2[r];
240 
241  K = list[r];
242  list[r] = list[0];
243  list2[r] = list2[0];
244  r = r - 1;
245  } else {
246  l = l - 1;
247  RR = list[l - 1];
248  RR2 = list2[l - 1];
249  K = list[l - 1];
250  }
251  }
252 
253  list[0] = RR;
254  list2[0] = RR2;
255  } else if (list3 != NULL) {
256  RR3 = list3[l - 1];
257  while (r != 0) {
258  j = l;
259  flag = 1;
260 
261  while (flag == 1) {
262  i = j;
263  j = j + j;
264 
265  if (j > r + 1)
266  flag = 0;
267  else {
268  if (j < r + 1)
269  if (list[j] > list[j - 1]) j = j + 1;
270 
271  if (list[j - 1] > K) {
272  list[i - 1] = list[j - 1];
273  list3[i - 1] = list3[j - 1];
274  } else {
275  flag = 0;
276  }
277  }
278  }
279 
280  list[i - 1] = RR;
281  list3[i - 1] = RR3;
282 
283  if (l == 1) {
284  RR = list[r];
285  RR3 = list3[r];
286 
287  K = list[r];
288  list[r] = list[0];
289  list3[r] = list3[0];
290  r = r - 1;
291  } else {
292  l = l - 1;
293  RR = list[l - 1];
294  RR3 = list3[l - 1];
295  K = list[l - 1];
296  }
297  }
298 
299  list[0] = RR;
300  list3[0] = RR3;
301 
302  } else {
303  while (r != 0) {
304  j = l;
305  flag = 1;
306 
307  while (flag == 1) {
308  i = j;
309  j = j + j;
310 
311  if (j > r + 1)
312  flag = 0;
313  else {
314  if (j < r + 1)
315  if (list[j] > list[j - 1]) j = j + 1;
316 
317  if (list[j - 1] > K) {
318  list[i - 1] = list[j - 1];
319  } else {
320  flag = 0;
321  }
322  }
323  }
324 
325  list[i - 1] = RR;
326 
327  if (l == 1) {
328  RR = list[r];
329 
330  K = list[r];
331  list[r] = list[0];
332  r = r - 1;
333  } else {
334  l = l - 1;
335  RR = list[l - 1];
336  K = list[l - 1];
337  }
338  }
339 
340  list[0] = RR;
341  }
342  }
343 
344 }; // class CoalesceDropFactory
345 
346 } // namespace MueLu
347 
348 #define MUELU_VARIABLEDOFLAPLACIANFACTORY_SHORT
349 
350 #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:99
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.