46 #ifndef MUELU_AMALGAMATIONFACTORY_DEF_HPP
47 #define MUELU_AMALGAMATIONFACTORY_DEF_HPP
54 #include "MueLu_AmalgamationInfo.hpp"
59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
63 return validParamList;
66 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 Input(currentLevel,
"A");
71 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
75 RCP<Matrix> A = Get<RCP<Matrix> >(currentLevel,
"A");
97 LO nStridedOffset = 0;
98 LO stridedblocksize = fullblocksize;
99 LO storageblocksize = A->GetStorageBlockSize();
104 if (A->IsView(
"stridedMaps") && Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
108 fullblocksize = stridedRowMap->getFixedBlockSize();
109 offset = stridedRowMap->getOffset();
110 blockid = stridedRowMap->getStridedBlockId();
113 std::vector<size_t> stridingInfo = stridedRowMap->getStridingData();
114 for (
size_t j = 0; j < Teuchos::as<size_t>(blockid); j++)
115 nStridedOffset += stridingInfo[j];
116 stridedblocksize = Teuchos::as<LocalOrdinal>(stridingInfo[blockid]);
119 stridedblocksize = fullblocksize;
123 TEUCHOS_TEST_FOR_EXCEPTION(fullblocksize % storageblocksize != 0,
Exceptions::RuntimeError,
"AmalgamationFactory: fullblocksize needs to be a multiple of A->GetStorageBlockSize()");
124 fullblocksize /= storageblocksize;
125 stridedblocksize /= storageblocksize;
127 oldView = A->SwitchToView(oldView);
128 GetOStream(
Runtime1) <<
"AmalagamationFactory::Build():"
129 <<
" found fullblocksize=" << fullblocksize <<
" and stridedblocksize=" << stridedblocksize <<
" from strided maps. offset=" << offset << std::endl;
132 GetOStream(
Warnings0) <<
"AmalagamationFactory::Build(): no striding information available. Use blockdim=1 with offset=0" << std::endl;
144 if (fullblocksize > 1) {
152 AmalgamateMap(*(A->getRowMap()), *A, uniqueMap, *theRowTranslation);
153 AmalgamateMap(*(A->getColMap()), *A, nonUniqueMap, *theColTranslation);
179 Set(currentLevel,
"UnAmalgamationInfo", amalgamationData);
182 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
185 typedef std::unordered_map<GO, size_type> container;
187 GO indexBase = sourceMap.getIndexBase();
189 size_type numElements = elementAList.
size();
193 LO blkSize = A.GetFixedBlockSize() / A.GetStorageBlockSize();
194 if (A.IsView(
"stridedMaps") ==
true) {
198 offset = strMap->getOffset();
199 blkSize = Teuchos::as<const LO>(strMap->getFixedBlockSize());
203 translation.
resize(numElements);
205 size_type numRows = 0;
206 for (size_type
id = 0;
id < numElements;
id++) {
207 GO dofID = elementAList[id];
210 typename container::iterator it = filter.find(nodeID);
211 if (it == filter.end()) {
212 filter[nodeID] = numRows;
214 translation[id] = numRows;
215 elementList[numRows] = nodeID;
220 translation[id] = it->second;
223 elementList.
resize(numRows);
228 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
232 return globalblockid;
Important warning messages (one line)
void DeclareInput(Level ¤tLevel) const override
Input.
Exception indicating invalid cast attempted.
MueLu::DefaultLocalOrdinal LocalOrdinal
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Timer to be used in factories. Similar to Monitor but with additional timers.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static const GlobalOrdinal DOFGid2NodeId(GlobalOrdinal gid, LocalOrdinal blockSize, const GlobalOrdinal offset, const GlobalOrdinal indexBase)
Translate global (row/column) id to global amalgamation block id.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
static void AmalgamateMap(const Map &sourceMap, const Matrix &A, RCP< const Map > &amalgamatedMap, Array< LO > &translation)
Method to create merged map for systems of PDEs.
void resize(size_type new_size, const value_type &x=value_type())
void Build(Level ¤tLevel) const override
Build an object with this factory.
RCP< const ParameterList > GetValidParameterList() const override
Return a const parameter list of valid parameters that setParameterList() will accept.
Exception throws to report errors in the internal logical of the program.
Description of what is happening (more verbose)
minimal container class for storing amalgamation information