MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_TopRAPFactory_def.hpp
Go to the documentation of this file.
1 /*
2  * MueLu_TopRAPFactory_def.hpp
3  *
4  * Created on: Jan 25, 2016
5  * Author: tawiesn
6  */
7 
8 #ifndef PACKAGES_MUELU_SRC_MUECENTRAL_MUELU_TOPRAPFACTORY_DEF_HPP_
9 #define PACKAGES_MUELU_SRC_MUECENTRAL_MUELU_TOPRAPFACTORY_DEF_HPP_
10 
11 #include "MueLu_ConfigDefs.hpp"
12 
14 //#include "MueLu_HierarchyUtils_fwd.hpp"
16 
17 namespace MueLu {
18 
19 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
21  : PFact_(parentFactoryManager->GetFactory("P"))
22  , RFact_(parentFactoryManager->GetFactory("R"))
23  , AcFact_(parentFactoryManager->GetFactory("A")) {}
24 
25 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
27  : PFact_(parentFactoryManagerCoarse->GetFactory("P"))
28  , RFact_(parentFactoryManagerCoarse->GetFactory("R"))
29  , AcFact_(parentFactoryManagerCoarse->GetFactory("A")) {}
30 
31 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
33 
34 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
36  if (PFact_ != Teuchos::null) coarseLevel.DeclareInput("P", PFact_.get());
37  if (RFact_ != Teuchos::null) coarseLevel.DeclareInput("R", RFact_.get());
38  if ((AcFact_ != Teuchos::null) && (AcFact_ != NoFactory::getRCP())) coarseLevel.DeclareInput("A", AcFact_.get());
39 }
40 
41 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
43  if ((PFact_ != Teuchos::null) && (PFact_ != NoFactory::getRCP())) {
44  RCP<Operator> oP = coarseLevel.Get<RCP<Operator> >("P", PFact_.get());
45  // Don't have a valid operator (e.g., # global aggregates is 0) so we just bail out
46  // This level will ultimately be removed in MueLu_Hierarchy_defs.h via a resize()j
47  if (oP == Teuchos::null) return;
48  RCP<Matrix> P = rcp_dynamic_cast<Matrix>(oP);
49  if (!P.is_null())
50  coarseLevel.Set("P", P, NoFactory::get());
51  else
52  coarseLevel.Set("P", oP, NoFactory::get());
53  coarseLevel.AddKeepFlag("P", NoFactory::get(), MueLu::Final); // FIXME2: Order of Remove/Add matter (data removed otherwise). Should do something about this
54  coarseLevel.RemoveKeepFlag("P", NoFactory::get(), MueLu::UserData); // FIXME: This is a hack, I should change behavior of Level::Set() instead. FIXME3: Should not be removed if flag was there already
55  }
56 
57  if ((RFact_ != Teuchos::null) && (RFact_ != NoFactory::getRCP())) {
58  RCP<Operator> oR = coarseLevel.Get<RCP<Operator> >("R", RFact_.get());
59  RCP<Matrix> R = rcp_dynamic_cast<Matrix>(oR);
60  if (!R.is_null())
61  coarseLevel.Set("R", R, NoFactory::get());
62  else
63  coarseLevel.Set("R", oR, NoFactory::get());
64  coarseLevel.AddKeepFlag("R", NoFactory::get(), MueLu::Final);
65  coarseLevel.RemoveKeepFlag("R", NoFactory::get(), MueLu::UserData); // FIXME: This is a hack
66  }
67 
68  if ((AcFact_ != Teuchos::null) && (AcFact_ != NoFactory::getRCP())) {
69  RCP<Operator> oA = coarseLevel.Get<RCP<Operator> >("A", AcFact_.get());
70  RCP<Matrix> A = rcp_dynamic_cast<Matrix>(oA);
71  if (!A.is_null())
72  coarseLevel.Set("A", A, NoFactory::get());
73  else
74  coarseLevel.Set("A", oA, NoFactory::get());
75  coarseLevel.AddKeepFlag("A", NoFactory::get(), MueLu::Final);
76  coarseLevel.RemoveKeepFlag("A", NoFactory::get(), MueLu::UserData); // FIXME: This is a hack
77  }
78 }
79 } // namespace MueLu
80 
81 #endif /* PACKAGES_MUELU_SRC_MUECENTRAL_MUELU_TOPRAPFACTORY_DEF_HPP_ */
TopRAPFactory(RCP< const FactoryManagerBase > parentFactoryManager)
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level-&gt;Get&lt; RCP&lt;Matrix&gt; &gt;(&quot;A&quot;, factory) if factory == NULL =&gt; use default factory.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
User data are always kept. This flag is set automatically when Level::Set(&quot;data&quot;, data) is used...
static const NoFactory * get()
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
Keep data only for this run. Used to keep data useful for Hierarchy::Iterate(). Data will be deleted ...
void RemoveKeepFlag(const std::string &ename, const FactoryBase *factory, KeepType keep=MueLu::All)
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
static const RCP< const NoFactory > getRCP()
Static Get() functions.
bool is_null() const