47#ifndef PACKAGES_MUELU_SRC_MISC_MUELU_FINELEVELINPUTDATAFACTORY_DEF_HPP_
48#define PACKAGES_MUELU_SRC_MISC_MUELU_FINELEVELINPUTDATAFACTORY_DEF_HPP_
50#include "Xpetra_Matrix.hpp"
59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 RCP<ParameterList> validParamList = rcp(
new ParameterList());
64 validParamList->set< std::string >(
"Variable", std::string(
"A"),
"Variable name on all coarse levels (except the finest level).");
67 validParamList->set< RCP<const FactoryBase> >(
"Fine level factory", Teuchos::null,
"Generating factory of the fine level variable");
68 validParamList->set< RCP<const FactoryBase> >(
"Coarse level factory", Teuchos::null,
"Generating factory for data on all coarse levels (except the finest)");
71 validParamList->set<std::string> (
"Variable type", std::string(
"Matrix"),
"Type of variable");
73 return validParamList;
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 const ParameterList & pL = GetParameterList();
81 std::string variableName =
"";
82 if(pL.isParameter(
"Variable"))
83 variableName = pL.get<std::string>(
"Variable");
85 std::string factoryName =
"NoFactory";
87 factoryName =
"Fine level factory";
89 factoryName =
"Coarse level factory";
92 TEUCHOS_TEST_FOR_EXCEPTION(variableName ==
"",
MueLu::Exceptions::RuntimeError,
"FineLevelInputDataFactory: no variable name provided. Please set \'Variable\' parameter in your input deck.");
95 RCP<const FactoryBase> fact = GetFactory(factoryName);
96 currentLevel.
DeclareInput(variableName, fact.get(),
this);
99 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 const ParameterList& pL = GetParameterList();
105 std::string variableName =
"";
106 if (pL.isParameter(
"Variable"))
107 variableName = pL.get<std::string>(
"Variable");
109 std::string variableType =
"";
110 if(pL.isParameter(
"Variable type"))
111 variableType = pL.get<std::string>(
"Variable type");
113 std::string factoryName =
"NoFactory";
115 factoryName =
"Fine level factory";
117 factoryName =
"Coarse level factory";
119 RCP<const FactoryBase> fact = GetFactory(factoryName);
121 GetOStream(
Debug) <<
"Use " << variableName <<
" of type " << variableType <<
" from " << factoryName <<
"(" << fact.get() <<
")" << std::endl;
125 if (variableType ==
"int") {
126 int data = currentLevel.
Get<
int>(variableName, fact.get());
127 Set(currentLevel, variableName, data);
128 }
else if (variableType ==
"double") {
129 double data = currentLevel.
Get<
double>(variableName, fact.get());
130 Set(currentLevel, variableName, data);
131 }
else if (variableType ==
"string") {
132 std::string data = currentLevel.
Get<std::string>(variableName, fact.get());
133 Set(currentLevel, variableName, data);
135 size_t npos = std::string::npos;
137 if (variableType.find(
"Aggregates") != npos) {
138 RCP<Aggregates> data = currentLevel.
Get<RCP<Aggregates> >(variableName, fact.get());
139 Set(currentLevel, variableName, data);
141 else if (variableType.find(
"Graph") != npos) {
142 RCP<Graph> data = currentLevel.
Get<RCP<Graph> >(variableName, fact.get());
143 Set(currentLevel, variableName, data);
145 else if (variableType.find(
"SmootherBase") != npos) {
146 RCP<SmootherBase> data = currentLevel.
Get<RCP<SmootherBase> >(variableName, fact.get());
147 Set(currentLevel, variableName, data);
149 else if (variableType.find(
"SmootherPrototype") != npos) {
150 RCP<SmootherPrototype> data = currentLevel.
Get<RCP<SmootherPrototype> >(variableName, fact.get());
151 Set(currentLevel, variableName, data);
153 else if (variableType.find(
"Export") != npos) {
154 RCP<Export> data = currentLevel.
Get<RCP<Export> >(variableName, fact.get());
155 Set(currentLevel, variableName, data);
157 else if (variableType.find(
"Import") != npos) {
158 RCP<Import> data = currentLevel.
Get<RCP<Import> >(variableName, fact.get());
159 Set(currentLevel, variableName, data);
161 else if (variableType.find(
"Map") != npos) {
162 RCP<Map> data = currentLevel.
Get<RCP<Map> >(variableName, fact.get());
163 Set(currentLevel, variableName, data);
165 else if (variableType.find(
"Matrix") != npos) {
166 RCP<Matrix> data = currentLevel.
Get<RCP<Matrix> >(variableName, fact.get());
167 Set(currentLevel, variableName, data);
169 else if (variableType.find(
"MultiVector") != npos) {
170 RCP<MultiVector> data = currentLevel.
Get<RCP<MultiVector> >(variableName, fact.get());
171 Set(currentLevel, variableName, data);
173 else if (variableType.find(
"Operator") != npos) {
174 RCP<Operator> data = currentLevel.
Get<RCP<Operator> >(variableName, fact.get());
175 Set(currentLevel, variableName, data);
179 TEUCHOS_TEST_FOR_EXCEPTION(
true,
MueLu::Exceptions::RuntimeError,
"FineLevelInputDataFactory: cannot detect type of variable " << variableName <<
" generated by " << fact.get() <<
". User provided type " << variableType );
Exception throws to report errors in the internal logical of the program.
Timer to be used in factories. Similar to Monitor but with additional timers.
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()
int GetLevelID() const
Return level number.
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
Namespace for MueLu classes and methods.
@ Debug
Print additional debugging information.