46#ifndef MUELU_TOGGLECOORDINATESTRANSFER_FACTORY_DEF_HPP
47#define MUELU_TOGGLECOORDINATESTRANSFER_FACTORY_DEF_HPP
57 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
59 RCP<ParameterList> validParamList = rcp(
new ParameterList());
61 validParamList->set< RCP<const FactoryBase> >(
"Chosen P", Teuchos::null,
"Name of TogglePFactory this ToggleCoordinatesTransferFactory is connected to. Parameter provides information which execution path (prolongator) has been chosen.");
63 return validParamList;
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 const ParameterList& pL = GetParameterList();
69 TEUCHOS_TEST_FOR_EXCEPTION(!pL.isParameter(
"Chosen P"),
Exceptions::RuntimeError,
"MueLu::ToggleCoordinatesTransferFactory::DeclareInput: You have to set the 'Chosen P' parameter to a factory name of type TogglePFactory. The ToggleCoordinatesTransferFactory must be used together with a TogglePFactory!");
70 Input(coarseLevel,
"Chosen P");
71 for (std::vector<RCP<const FactoryBase> >::const_iterator it = coordFacts_.begin(); it != coordFacts_.end(); ++it) {
72 coarseLevel.
DeclareInput(
"Coordinates", (*it).get(),
this);
73 (*it)->CallDeclareInput(coarseLevel);
75 hasDeclaredInput_ =
true;
78 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 FactoryMonitor m(*
this,
"Coordinate transfer toggle", coarseLevel);
82 typedef Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,LO,GO,NO> xdMV;
84 TEUCHOS_TEST_FOR_EXCEPTION(coordFacts_.size() != 2,
Exceptions::RuntimeError,
"MueLu::TogglePFactory::Build: ToggleCoordinatesTransferFactory needs two different transfer operator strategies for toggling.");
86 int chosenP = Get< int > (coarseLevel,
"Chosen P");
87 GetOStream(
Runtime1) <<
"Transfer Coordinates" << chosenP <<
" to coarse level" << std::endl;
88 RCP<xdMV> coarseCoords = coarseLevel.
Get< RCP<xdMV> >(
"Coordinates",(coordFacts_[chosenP]).get());
89 Set(coarseLevel,
"Coordinates", coarseCoords);
106 for(
size_t t=0; t<coordFacts_.size(); ++t) {
107 coarseLevel.
Release(*(coordFacts_[t]));
113 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
116 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::rcp_dynamic_cast<const TwoLevelFactoryBase>(factory) == Teuchos::null,
Exceptions::BadCast,
117 "MueLu::ToggleCoordinatesTransferFactory::AddCoordTransferFactory: Transfer factory is not derived from TwoLevelFactoryBase. Make sure you provide the factory which generates the coarse coordinates. Usually this is a coordinate transfer factory."
118 "This is very strange. (Note: you can remove this exception if there's a good reason for)");
119 TEUCHOS_TEST_FOR_EXCEPTION(hasDeclaredInput_,
Exceptions::RuntimeError,
"MueLu::ToggleCoordinatesTransferFactory::AddCoordTransferFactory: Factory is being added after we have already declared input");
120 coordFacts_.push_back(factory);
Exception indicating invalid cast attempted.
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()
void Release(const FactoryBase &factory)
Decrement the storage counter for all the inputs of a factory.
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void AddCoordTransferFactory(const RCP< const FactoryBase > &factory)
Add a coordinate transfer factory in the end of list of coordinate transfer factories.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
void DeclareInput(Level &finelevel, Level &coarseLevel) const
Specifies the data that this class needs, and the factories that generate that data.
Namespace for MueLu classes and methods.
@ Runtime1
Description of what is happening (more verbose)