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 
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 } // namespace MueLuTests
65 
66 namespace MueLu {
67 
116 template <class Scalar = DefaultScalar,
119  class Node = DefaultNode>
120 class BlackBoxPFactory : public PFactory {
121 #undef MUELU_BLACKBOXPFACTORY_SHORT
122 #include "MueLu_UseShortNames.hpp"
123 
124  public:
126 
128 
129 
132 
134  virtual ~BlackBoxPFactory() {}
136 
138 
140 
141 
142  void DeclareInput(Level& fineLevel, Level& coarseLevel) const;
143 
145 
147 
148 
149  void Build(Level& fineLevel, Level& coarseLevel) const;
150  void BuildP(Level& fineLevel, Level& coarseLevel) const;
151 
153 
154  private:
155  struct NodesIDs {
156  // This small struct just carries basic data associated with coarse nodes that is needed
157  // to compute colMapP and to fillComplete P,
158 
162  std::vector<GO> colInds;
163  };
164 
165  struct NodeID {
166  // This small struct is similar to the one above but only for one node.
167  // It is used to create a vector of NodeID that can easily be sorted
168 
170  int PID;
172  };
173 
175  const Array<LO> coarseRate, const Array<GO> gFineNodesPerDir,
176  const Array<LO> lFineNodesPerDir, const LO BlkSize, Array<GO>& gIndices,
177  Array<LO>& myOffset, Array<bool>& ghostInterface, Array<LO>& endRate,
178  Array<GO>& gCoarseNodesPerDir, Array<LO>& lCoarseNodesPerDir,
179  Array<LO>& glCoarseNodesPerDir, Array<GO>& ghostGIDs,
180  Array<GO>& coarseNodesGIDs, Array<GO>& colGIDs, GO& gNumCoarseNodes,
181  LO& lNumCoarseNodes, ArrayRCP<Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> > coarseNodes,
182  Array<int>& boundaryFlags, RCP<NodesIDs> ghostedCoarseNodes) const;
183 
184  void ComputeLocalEntries(const RCP<const Matrix>& Aghost, const Array<LO> coarseRate,
185  const Array<LO> endRate, const LO BlkSize, const Array<LO> elemInds,
186  const Array<LO> lCoarseElementsPerDir,
187  const LO numDimensions, const Array<LO> lFineNodesPerDir,
188  const Array<GO> gFineNodesPerDir, const Array<GO> gIndices,
189  const Array<LO> lCoarseNodesPerDir, const Array<bool> ghostInterface,
190  const Array<int> elementFlags, const std::string stencilType,
191  const std::string blockStrategy, const Array<LO> elementNodesPerDir,
192  const LO numNodesInElement, const Array<GO> colGIDs,
196  Array<LO>& dofType, Array<LO>& lDofInd) const;
197 
198  void CollapseStencil(const int type, const int orientation, const int collapseFlags[3],
199  Array<SC>& stencil) const;
200 
201  void FormatStencil(const LO BlkSize, const Array<bool> ghostInterface, const LO ie,
202  const LO je, const LO ke, const ArrayView<const SC> rowValues,
203  const Array<LO> elementNodesPerDir, const int collapseFlags[3],
204  const std::string stencilType, Array<SC>& stencil) const;
205 
206  void GetNodeInfo(const LO ie, const LO je, const LO ke, const Array<LO> elementNodesPerDir,
207  int* type, LO& ind, int* orientation) const;
208 
209  void sh_sort_permute(
210  const typename Teuchos::Array<LocalOrdinal>::iterator& first1,
211  const typename Teuchos::Array<LocalOrdinal>::iterator& last1,
212  const typename Teuchos::Array<LocalOrdinal>::iterator& first2,
213  const typename Teuchos::Array<LocalOrdinal>::iterator& last2) const;
214 
215 }; // class BlackBoxPFactory
216 
217 } // namespace MueLu
218 
219 #define MUELU_BLACKBOXPFACTORY_SHORT
220 #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
MueLu::DefaultLocalOrdinal LocalOrdinal
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
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
MueLu::DefaultNode Node
Prolongator factory performing geometric coarsening.
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 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