MueLu Version of the Day
Loading...
Searching...
No Matches
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
12#include "MueLu_ConfigDefs.hpp"
13
16//#include "MueLu_HierarchyUtils_fwd.hpp"
17#include "MueLu_TopRAPFactory.hpp"
18#include "MueLu_Level_fwd.hpp"
26
27
28namespace MueLu {
29
30 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
31 TopRAPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::TopRAPFactory(RCP<const FactoryManagerBase> parentFactoryManager) :
32 PFact_ (parentFactoryManager->GetFactory("P")),
33 RFact_ (parentFactoryManager->GetFactory("R")),
34 AcFact_(parentFactoryManager->GetFactory("A"))
35 { }
36
37 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
38 TopRAPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::TopRAPFactory(RCP<const FactoryManagerBase> /* parentFactoryManagerFine */, RCP<const FactoryManagerBase> parentFactoryManagerCoarse) :
39 PFact_ (parentFactoryManagerCoarse->GetFactory("P")),
40 RFact_ (parentFactoryManagerCoarse->GetFactory("R")),
41 AcFact_(parentFactoryManagerCoarse->GetFactory("A"))
42 { }
43
44 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
46
47 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
49 if (PFact_ != Teuchos::null) coarseLevel.DeclareInput("P", PFact_.get());
50 if (RFact_ != Teuchos::null) coarseLevel.DeclareInput("R", RFact_.get());
51 if ((AcFact_ != Teuchos::null) && (AcFact_ != NoFactory::getRCP())) coarseLevel.DeclareInput("A", AcFact_.get());
52 }
53
54 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
56 if ((PFact_ != Teuchos::null) && (PFact_ != NoFactory::getRCP())) {
57 RCP<Operator> oP = coarseLevel.Get<RCP<Operator> >("P", PFact_.get());
58 // Don't have a valid operator (e.g., # global aggregates is 0) so we just bail out
59 // This level will ultimately be removed in MueLu_Hierarchy_defs.h via a resize()j
60 if (oP == Teuchos::null) return;
61 RCP<Matrix> P = rcp_dynamic_cast<Matrix>(oP);
62 if (!P.is_null()) coarseLevel.Set("P", P, NoFactory::get());
63 else coarseLevel.Set("P", oP, NoFactory::get());
64 coarseLevel.AddKeepFlag ("P", NoFactory::get(), MueLu::Final); // FIXME2: Order of Remove/Add matter (data removed otherwise). Should do something about this
65 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
66
67 }
68
69 if ((RFact_ != Teuchos::null) && (RFact_ != NoFactory::getRCP()) ) {
70 RCP<Operator> oR = coarseLevel.Get<RCP<Operator> >("R", RFact_.get());
71 RCP<Matrix> R = rcp_dynamic_cast<Matrix>(oR);
72 if (!R.is_null()) coarseLevel.Set("R", R, NoFactory::get());
73 else coarseLevel.Set("R", oR, NoFactory::get());
74 coarseLevel.AddKeepFlag ("R", NoFactory::get(), MueLu::Final);
75 coarseLevel.RemoveKeepFlag("R", NoFactory::get(), MueLu::UserData); // FIXME: This is a hack
76 }
77
78 if ((AcFact_ != Teuchos::null) && (AcFact_ != NoFactory::getRCP())) {
79 RCP<Operator> oA = coarseLevel.Get<RCP<Operator> >("A", AcFact_.get());
80 RCP<Matrix> A = rcp_dynamic_cast<Matrix>(oA);
81 if (!A.is_null()) coarseLevel.Set("A", A, NoFactory::get());
82 else coarseLevel.Set("A", oA, NoFactory::get());
83 coarseLevel.AddKeepFlag ("A", NoFactory::get(), MueLu::Final);
84 coarseLevel.RemoveKeepFlag("A", NoFactory::get(), MueLu::UserData); // FIXME: This is a hack
85 }
86 }
87}
88
89
90#endif /* PACKAGES_MUELU_SRC_MUECENTRAL_MUELU_TOPRAPFACTORY_DEF_HPP_ */
Class that holds all level-specific information.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
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)
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
static const RCP< const NoFactory > getRCP()
Static Get() functions.
static const NoFactory * get()
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
TopRAPFactory(RCP< const FactoryManagerBase > parentFactoryManager)
Namespace for MueLu classes and methods.
@ Final
Keep data only for this run. Used to keep data useful for Hierarchy::Iterate(). Data will be deleted ...
@ UserData
User data are always kept. This flag is set automatically when Level::Set("data", data) is used....