MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_BrickAggregationFactory_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 MUELU_BRICKAGGREGATIONFACTORY_DECL_HPP_
11#define MUELU_BRICKAGGREGATIONFACTORY_DECL_HPP_
12
13#include "MueLu_ConfigDefs.hpp"
14
15#include <Xpetra_Import_fwd.hpp>
16#include <Xpetra_ImportFactory_fwd.hpp>
17#include <Xpetra_Map_fwd.hpp>
18#include <Xpetra_MapFactory_fwd.hpp>
19#include <Xpetra_Matrix_fwd.hpp>
20#include <Xpetra_MultiVector_fwd.hpp>
21#include <Xpetra_MultiVectorFactory_fwd.hpp>
22
25
26#include "MueLu_LWGraph_fwd.hpp"
27
28#include "MueLu_Level_fwd.hpp"
30#include "MueLu_Exceptions.hpp"
32
41namespace MueLu {
42
43template <class Scalar = DefaultScalar,
46 class Node = DefaultNode>
48#undef MUELU_BRICKAGGREGATIONFACTORY_SHORT
50 private:
51 typedef Teuchos::ScalarTraits<Scalar> STS;
52
53 // Comparator for doubles
54 // Generally, the coordinates for coarser levels would come out of averaging of fine level coordinates
55 // It is possible that the result of the averaging differs slightly between clusters, as we might have
56 // 3x2 and 2x2 cluster which would result in averaging 6 and 4 y-coordinates respectively, leading to
57 // slightly different results.
58 // Therefore, we hardcode a constant so that close points are considered the same.
59 class compare {
60 public:
61 bool operator()(const Scalar& x, const Scalar& y) const {
62 if (STS::magnitude(x - y) < 1e-14)
63 return false;
64 return STS::real(x) < STS::real(y);
65 }
66 };
67 typedef std::map<Scalar, GlobalOrdinal, compare> container;
68
69 public:
71
72
75 : nDim_(-1)
76 , nx_(-1)
77 , ny_(-1)
78 , nz_(-1)
79 , bx_(-1)
80 , by_(-1)
81 , bz_(-1){};
82
85
86 RCP<const ParameterList> GetValidParameterList() const;
87
89
90 // Options shared by all aggregation algorithms
91
93
94
95 void DeclareInput(Level& currentLevel) const;
96
98
100
101
103 void Build(Level& currentLevel) const;
104
106
107 private:
108 void Setup(const RCP<const Teuchos::Comm<int> >& comm, const RCP<Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType, LO, GO, NO> >& coords, const RCP<const Map>& map) const;
109 RCP<container> Construct1DMap(const RCP<const Teuchos::Comm<int> >& comm, const ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& x) const;
110
111 void BuildGraph(Level& currentLevel, const RCP<Matrix>& A) const;
112
113 bool isDirichlet(LocalOrdinal LID) const;
114 bool isRoot(LocalOrdinal LID) const;
117
118 void getIJK(LocalOrdinal LID, int& i, int& j, int& k) const;
119 void getAggIJK(LocalOrdinal LID, int& i, int& j, int& k) const;
120
121 mutable int nDim_;
122 mutable RCP<container> xMap_, yMap_, zMap_;
123 mutable ArrayRCP<const typename Teuchos::ScalarTraits<Scalar>::magnitudeType> x_, y_, z_;
124 mutable int nx_, ny_, nz_;
125 mutable int bx_, by_, bz_;
127 mutable int naggx_, naggy_, naggz_;
128
129 mutable std::map<GlobalOrdinal, GlobalOrdinal> revMap_;
130}; // class BrickAggregationFactory
131
132} // namespace MueLu
133
134#define MUELU_BRICKAGGREGATIONFACTORY_SHORT
135#endif /* MUELU_BRICKAGGREGATIONFACTORY_DECL_HPP_ */
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
bool operator()(const Scalar &x, const Scalar &y) const
void Setup(const RCP< const Teuchos::Comm< int > > &comm, const RCP< Xpetra::MultiVector< typename Teuchos::ScalarTraits< Scalar >::magnitudeType, LO, GO, NO > > &coords, const RCP< const Map > &map) const
ArrayRCP< const typename Teuchos::ScalarTraits< Scalar >::magnitudeType > x_
std::map< Scalar, GlobalOrdinal, compare > container
GlobalOrdinal getRoot(LocalOrdinal LID) const
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
ArrayRCP< const typename Teuchos::ScalarTraits< Scalar >::magnitudeType > y_
ArrayRCP< const typename Teuchos::ScalarTraits< Scalar >::magnitudeType > z_
GlobalOrdinal getAggGID(LocalOrdinal LID) const
void DeclareInput(Level &currentLevel) const
Input.
void Build(Level &currentLevel) const
Build aggregates.
void BuildGraph(Level &currentLevel, const RCP< Matrix > &A) const
std::map< GlobalOrdinal, GlobalOrdinal > revMap_
void getAggIJK(LocalOrdinal LID, int &i, int &j, int &k) const
RCP< container > Construct1DMap(const RCP< const Teuchos::Comm< int > > &comm, const ArrayRCP< const typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &x) const
void getIJK(LocalOrdinal LID, int &i, int &j, int &k) const
Class that holds all level-specific information.
Base class for factories that use one level (currentLevel).
Namespace for MueLu classes and methods.
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar