17 #ifndef MUELU_COARSEMAPFACTORY_DEF_HPP_
18 #define MUELU_COARSEMAPFACTORY_DEF_HPP_
23 #include <Xpetra_StridedMapFactory.hpp>
27 #include "MueLu_Aggregates.hpp"
32 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
35 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
38 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
45 validParamList->
set<std::string>(
"Striding info",
"{}",
"Striding information");
46 validParamList->
set<
LocalOrdinal>(
"Strided block id", -1,
"Strided block id");
56 validParamList->
set<std::string>(
"Domain GID offsets",
"{0}",
"vector with offsets for GIDs for each level. If no offset GID value is given for the level we use 0 as default.");
58 return validParamList;
61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 Input(currentLevel,
"Aggregates");
64 Input(currentLevel,
"Nullspace");
67 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 stridingInfo_ = stridingInfo;
74 std::string strStridingInfo;
75 strStridingInfo.clear();
79 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
83 GlobalOrdinal domainGIDOffset = GetDomainGIDOffset(currentLevel);
84 BuildCoarseMap(currentLevel, domainGIDOffset);
87 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
90 RCP<Aggregates> aggregates = Get<RCP<Aggregates> >(currentLevel,
"Aggregates");
94 RCP<MultiVector> nullspace = Get<RCP<MultiVector> >(currentLevel,
"Nullspace");
96 const size_t NSDim = nullspace->getNumVectors();
105 std::string strStridingInfo = pL.
get<std::string>(
"Striding info");
106 if (strStridingInfo.empty() ==
false) {
108 stridingInfo_ = Teuchos::createVector(arrayVal);
112 CheckForConsistentStridingInformation(stridedBlockId, NSDim);
114 GetOStream(
Statistics2) <<
"domainGIDOffset: " << domainGIDOffset <<
" block size: " << getFixedBlockSize() <<
" stridedBlockId: " << stridedBlockId << std::endl;
120 RCP<const Map> coarseMap = StridedMapFactory::Build(aggMap->lib(),
129 Set(currentLevel,
"CoarseMap", coarseMap);
132 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
134 Level& currentLevel)
const {
137 std::vector<GlobalOrdinal> domainGidOffsets;
138 domainGidOffsets.clear();
141 std::string strDomainGIDs = pL.
get<std::string>(
"Domain GID offsets");
142 if (strDomainGIDs.empty() ==
false) {
144 domainGidOffsets = Teuchos::createVector(arrayVal);
145 if (currentLevel.
GetLevelID() < Teuchos::as<int>(domainGidOffsets.size())) {
146 domainGidOffset = domainGidOffsets[currentLevel.
GetLevelID()];
151 return domainGidOffset;
154 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
156 const LocalOrdinal stridedBlockId,
const size_t nullspaceDimension)
const {
158 if (stridedBlockId == -1) {
161 stridingInfo_.clear();
162 stridingInfo_.push_back(nullspaceDimension);
168 size_t stridedBlockSize = stridingInfo_[stridedBlockId];
MueLu::DefaultLocalOrdinal LocalOrdinal
KOKKOS_INLINE_FUNCTION LO GetNumAggregates() const
T & get(const std::string &name, T def_value)
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
virtual void BuildCoarseMap(Level ¤tLevel, const GlobalOrdinal domainGIDOffset) const
Build the coarse map using the domain GID offset.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
RCP< const ParameterList > GetValidParameterList() const override
Return a const parameter list of valid parameters that setParameterList() will accept.
Print even more statistics.
bool isParameter(const std::string &name) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
virtual GlobalOrdinal GetDomainGIDOffset(Level ¤tLevel) const
Extract domain GID offset from user data.
virtual void CheckForConsistentStridingInformation(LocalOrdinal stridedBlockId, const size_t nullspaceDimension) const
void Build(Level ¤tLevel) const override
Build an object with this factory.
virtual void setStridingData(std::vector< size_t > stridingInfo)
setStridingData set striding vector for the domain DOF map (= coarse map), e.g. (2,1) for 2 velocity dofs and 1 pressure dof
int GetLevelID() const
Return level number.
Exception throws to report errors in the internal logical of the program.
void DeclareInput(Level ¤tLevel) const override
Specifies the data that this class needs, and the factories that generate that data.