MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_GenericRFactory_def.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_GENERICRFACTORY_DEF_HPP
11#define MUELU_GENERICRFACTORY_DEF_HPP
12
13#include <Xpetra_Matrix.hpp>
14
16
17#include "MueLu_FactoryBase.hpp"
18#include "MueLu_PFactory.hpp"
21#include "MueLu_Monitor.hpp"
22
23namespace MueLu {
24
25template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
27 RCP<ParameterList> validParamList = rcp(new ParameterList());
28 validParamList->set<RCP<const FactoryBase> >("P", Teuchos::null, "Generating factory of the matrix P");
29 return validParamList;
30}
31
32template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
34 RCP<const FactoryBase> PFact1 = GetFactory("P");
35 if (PFact1 == Teuchos::null) {
36 PFact1 = coarseLevel.GetFactoryManager()->GetFactory("P");
37 }
38 RCP<PFactory> PFact = Teuchos::rcp_const_cast<PFactory>(rcp_dynamic_cast<const PFactory>(PFact1));
39 ;
40
41 bool rmode = PFact->isRestrictionModeSet();
42 PFact->setRestrictionMode(true); // set restriction mode
43
44 // Force request call for PFact
45 // In general, Request is only called once for each factory, since we
46 // can reuse data generated by the factory. However, here we have to
47 // run the code in PFact.Build again, so we have to request the
48 // dependencies of PFact first! Thedependencies are (automatically)
49 // cleaned up after the second run of PFact.Build in
50 // coarseLevel.Get<RCP<Matrix> >("R",PFact.get())!
51 coarseLevel.DeclareDependencies(PFact.get());
52
53 coarseLevel.DeclareInput("R", PFact.get(), this); // we expect the prolongation operator factory to produce "R" as output
54 // call declareInput is called within DeclareInput call
55 PFact->setRestrictionMode(rmode); // reset restriciton mode flag
56}
57
58template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
60 FactoryMonitor m(*this, "Call prolongator factory for calculating restrictor", coarseLevel);
61
62 RCP<const FactoryBase> PFact1 = GetFactory("P");
63 if (PFact1 == Teuchos::null) {
64 PFact1 = coarseLevel.GetFactoryManager()->GetFactory("P");
65 }
66 RCP<PFactory> PFact = Teuchos::rcp_const_cast<PFactory>(rcp_dynamic_cast<const PFactory>(PFact1));
67 ;
69
70 // BuildR
71 bool rmode = PFact->isRestrictionModeSet();
72 PFact->setRestrictionMode(true); // switch prolongator factory to restriction mode
73
74 // PFact->Build(fineLevel, coarseLevel); // call PFactory::Build explicitely
75 RCP<Matrix> R = coarseLevel.Get<RCP<Matrix> >("R", PFact.get());
76
77 PFact->setRestrictionMode(rmode); // reset restriction mode flag
78
79 Set(coarseLevel, "R", R);
80
81} // BuildR
82
83} // namespace MueLu
84
85#define MUELU_GENERICRFACTORY_SHORT
86#endif // MUELU_GENERICRFACTORY_DEF_HPP
An exception safe way to call the method TwoLevelFactoryBase::DisableMultipleCallCheck.
Timer to be used in factories. Similar to Monitor but with additional timers.
RCP< const ParameterList > GetValidParameterList() const
Input.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
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()
const RCP< const FactoryManagerBase > GetFactoryManager()
returns the current factory manager
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
void DeclareDependencies(const FactoryBase *factory, bool bRequestOnly=false, bool bReleaseOnly=false)
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput() to declare factory depe...
Namespace for MueLu classes and methods.