MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_BlackBoxPFactory_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 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_BLACKBOXPFACTORY_DECL_HPP
47 #define MUELU_BLACKBOXPFACTORY_DECL_HPP
48 
50 
51 #include <Xpetra_MultiVector.hpp>
52 #include <Xpetra_Matrix_fwd.hpp>
53 
54 #include "MueLu_ConfigDefs.hpp"
55 #include "MueLu_PFactory.hpp"
57 
58 #include "MueLu_Level_fwd.hpp"
59 
60 namespace MueLuTests {
61  // Forward declaration of friend tester class used to UnitTest BlackBoxPFactory
62  template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
64 }
65 
66 namespace MueLu {
67 
116  template <class Scalar = double, class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = KokkosClassic::DefaultNode::DefaultNodeType>
117  class BlackBoxPFactory : public PFactory {
118 #undef MUELU_BLACKBOXPFACTORY_SHORT
119 #include "MueLu_UseShortNames.hpp"
120 
121  public:
122 
123  friend class MueLuTests::BlackBoxPFactoryTester<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
124 
126 
127 
130 
132  virtual ~BlackBoxPFactory() { }
134 
136 
138 
139 
140  void DeclareInput(Level& fineLevel, Level& coarseLevel) const;
141 
143 
145 
146 
147  void Build (Level& fineLevel, Level& coarseLevel) const;
148  void BuildP(Level& fineLevel, Level& coarseLevel) const;
149 
151 
152  private:
153 
154  struct NodesIDs {
155  // This small struct just carries basic data associated with coarse nodes that is needed
156  // to compute colMapP and to fillComplete P,
157 
161  std::vector<GO> colInds;
162  };
163 
164  struct NodeID {
165  // This small struct is similar to the one above but only for one node.
166  // It is used to create a vector of NodeID that can easily be sorted
167 
169  int PID;
171  };
172 
174  const Array<LO> coarseRate, const Array<GO> gFineNodesPerDir,
175  const Array<LO> lFineNodesPerDir, const LO BlkSize, Array<GO>& gIndices,
176  Array<LO>& myOffset, Array<bool>& ghostInterface, Array<LO>& endRate,
177  Array<GO>& gCoarseNodesPerDir, Array<LO>& lCoarseNodesPerDir,
178  Array<LO>& glCoarseNodesPerDir, Array<GO>& ghostGIDs,
179  Array<GO>& coarseNodesGIDs, Array<GO>& colGIDs, GO& gNumCoarseNodes,
180  LO& lNumCoarseNodes, ArrayRCP<Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> > coarseNodes,
181  Array<int>& boundaryFlags, RCP<NodesIDs> ghostedCoarseNodes) const;
182 
183  void ComputeLocalEntries(const RCP<const Matrix>& Aghost, const Array<LO> coarseRate,
184  const Array<LO> endRate, const LO BlkSize, const Array<LO> elemInds,
185  const Array<LO> lCoarseElementsPerDir,
186  const LO numDimensions, const Array<LO> lFineNodesPerDir,
187  const Array<GO> gFineNodesPerDir, const Array<GO> gIndices,
188  const Array<LO> lCoarseNodesPerDir, const Array<bool> ghostInterface,
189  const Array<int> elementFlags, const std::string stencilType,
190  const std::string blockStrategy, const Array<LO> elementNodesPerDir,
191  const LO numNodesInElement, const Array<GO> colGIDs,
195  Array<LO>& dofType, Array<LO>& lDofInd) const;
196 
197  void CollapseStencil(const int type, const int orientation, const int collapseFlags[3],
198  Array<SC>& stencil) const ;
199 
200  void FormatStencil(const LO BlkSize, const Array<bool> ghostInterface, const LO ie,
201  const LO je, const LO ke, const ArrayView<const SC> rowValues,
202  const Array<LO> elementNodesPerDir, const int collapseFlags[3],
203  const std::string stencilType, Array<SC>& stencil) const;
204 
205  void GetNodeInfo(const LO ie, const LO je, const LO ke, const Array<LO> elementNodesPerDir,
206  int* type, LO& ind, int* orientation) const;
207 
208  void sh_sort_permute(
209  const typename Teuchos::Array<LocalOrdinal>::iterator& first1,
210  const typename Teuchos::Array<LocalOrdinal>::iterator& last1,
211  const typename Teuchos::Array<LocalOrdinal>::iterator& first2,
212  const typename Teuchos::Array<LocalOrdinal>::iterator& last2) const;
213 
214  }; //class BlackBoxPFactory
215 
216 } //namespace MueLu
217 
218 #define MUELU_BLACKBOXPFACTORY_SHORT
219 #endif // MUELU_BLACKBOXPFACTORY_DECL_HPP
void GetGeometricData(RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LO, GO, NO > > &coordinates, const Array< LO > coarseRate, const Array< GO > gFineNodesPerDir, const Array< LO > lFineNodesPerDir, const LO BlkSize, Array< GO > &gIndices, Array< LO > &myOffset, Array< bool > &ghostInterface, Array< LO > &endRate, Array< GO > &gCoarseNodesPerDir, Array< LO > &lCoarseNodesPerDir, Array< LO > &glCoarseNodesPerDir, Array< GO > &ghostGIDs, Array< GO > &coarseNodesGIDs, Array< GO > &colGIDs, GO &gNumCoarseNodes, LO &lNumCoarseNodes, ArrayRCP< Array< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > > coarseNodes, Array< int > &boundaryFlags, RCP< NodesIDs > ghostedCoarseNodes) const
GlobalOrdinal GO
void GetNodeInfo(const LO ie, const LO je, const LO ke, const Array< LO > elementNodesPerDir, int *type, LO &ind, int *orientation) const
void ComputeLocalEntries(const RCP< const Matrix > &Aghost, const Array< LO > coarseRate, const Array< LO > endRate, const LO BlkSize, const Array< LO > elemInds, const Array< LO > lCoarseElementsPerDir, const LO numDimensions, const Array< LO > lFineNodesPerDir, const Array< GO > gFineNodesPerDir, const Array< GO > gIndices, const Array< LO > lCoarseNodesPerDir, const Array< bool > ghostInterface, const Array< int > elementFlags, const std::string stencilType, const std::string blockStrategy, const Array< LO > elementNodesPerDir, const LO numNodesInElement, const Array< GO > colGIDs, Teuchos::SerialDenseMatrix< LO, SC > &Pi, Teuchos::SerialDenseMatrix< LO, SC > &Pf, Teuchos::SerialDenseMatrix< LO, SC > &Pe, Array< LO > &dofType, Array< LO > &lDofInd) const
LocalOrdinal LO
Prolongator factory performing geometric coarsening.
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
void FormatStencil(const LO BlkSize, const Array< bool > ghostInterface, const LO ie, const LO je, const LO ke, const ArrayView< const SC > rowValues, const Array< LO > elementNodesPerDir, const int collapseFlags[3], const std::string stencilType, Array< SC > &stencil) const
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
void CollapseStencil(const int type, const int orientation, const int collapseFlags[3], Array< SC > &stencil) const
void BuildP(Level &fineLevel, Level &coarseLevel) const
Abstract Build method.
Node NO
Factory that provides an interface for a concrete implementation of a prolongation operator...
std::vector< T >::iterator iterator
void sh_sort_permute(const typename Teuchos::Array< LocalOrdinal >::iterator &first1, const typename Teuchos::Array< LocalOrdinal >::iterator &last1, const typename Teuchos::Array< LocalOrdinal >::iterator &first2, const typename Teuchos::Array< LocalOrdinal >::iterator &last2) const