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