10 #ifndef MUELU_BLOCKEDCOORDINATESTRANSFER_FACTORY_DEF_HPP
11 #define MUELU_BLOCKEDCOORDINATESTRANSFER_FACTORY_DEF_HPP
14 #include "Xpetra_MultiVectorFactory.hpp"
15 #include "Xpetra_MapFactory.hpp"
25 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
31 return validParamList;
34 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
36 Input(coarseLevel,
"CoarseMap");
39 const size_t numSubFactories = NumFactories();
40 for (
size_t i = 0; i < numSubFactories; i++) {
46 for (std::vector<
RCP<const FactoryBase> >::const_iterator it = subFactories_.begin(); it != subFactories_.end(); ++it)
47 (*it)->CallDeclareInput(coarseLevel);
50 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
57 GetOStream(
Runtime0) <<
"Transferring (blocked) coordinates" << std::endl;
59 const size_t numSubFactories = NumFactories();
60 std::vector<RCP<const Map> > subBlockMaps(numSubFactories);
61 std::vector<RCP<dMV> > subBlockCoords(numSubFactories);
64 GetOStream(
Runtime0) <<
"Reusing coordinates" << std::endl;
69 for (
size_t i = 0; i < numSubFactories; i++) {
70 GetOStream(
Runtime1) <<
"Generating Coordinates for block " << i <<
"/" << numSubFactories << std::endl;
73 subBlockCoords[i] = coarseLevel.
Get<
RCP<dMV> >(
"Coordinates", myFactory.
get());
74 subBlockMaps[i] = subBlockCoords[i]->getMap();
85 bool thyraMode = coarseMap->getThyraMode();
90 if (rcp_dynamic_cast<const StridedMap>(coarseMap->getMap(0, thyraMode)) != Teuchos::null)
91 blkSize = rcp_dynamic_cast<
const StridedMap>(coarseMap->getMap(0, thyraMode))->getFixedBlockSize();
93 for (
size_t i = 1; i < numSubFactories; i++) {
95 if (rcp_dynamic_cast<const StridedMap>(coarseMap->getMap(i, thyraMode)) != Teuchos::null)
96 otherBlkSize = rcp_dynamic_cast<
const StridedMap>(coarseMap->getMap(i, thyraMode))->getFixedBlockSize();
100 GO indexBase = coarseMap->getFullMap()->getIndexBase();
101 size_t numElements = elementAList.
size() / blkSize;
105 for (LO i = 0; i < Teuchos::as<LO>(numElements); i++)
106 elementList[i] = (elementAList[i * blkSize] - indexBase) / blkSize + indexBase;
108 RCP<const Map> coarseCoordMap = MapFactory::Build(coarseMap->getFullMap()->lib(),
111 coarseCoordMapBlocked =
rcp(
new BlockedMap(coarseCoordMap, subBlockMaps, thyraMode));
115 RCP<dBV> bcoarseCoords =
rcp(
new dBV(coarseCoordMapBlocked, subBlockCoords));
118 RCP<dMV> coarseCoords = bcoarseCoords->Merge();
119 Set<RCP<dMV> >(coarseLevel,
"Coordinates", coarseCoords);
122 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
124 subFactories_.push_back(factory);
129 #endif // MUELU_BLOCKEDCOORDINATESTRANSFER_FACTORY_DEF_HPP
void DeclareInput(Level &finelevel, Level &coarseLevel) const
Specifies the data that this class needs, and the factories that generate that data.
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->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
virtual void CallBuild(Level &requestedLevel) const =0
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
One-liner description of what is happening.
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
void AddFactory(const RCP< const FactoryBase > &factory)
Add (sub) coords factory in the end of list of factories in BlockedCoordinatesTransferFactory.
Exception throws to report errors in the internal logical of the program.
Description of what is happening (more verbose)
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.