15 TEUCHOS_ASSERT(blockIndex < (
int)
children_.size());
16 Teuchos::RCP<BlockReorderManager> child = Teuchos::rcp(
new BlockReorderLeaf(reorder));
21 TEUCHOS_ASSERT(blockIndex < (
int)
children_.size());
27 void tokenize(std::string srcInput, std::string whitespace, std::string prefer, std::vector<std::string>& tokens) {
28 std::string input = srcInput;
29 std::vector<std::string> wsTokens;
30 std::size_t endPos = input.length() - 1;
31 while (endPos < input.length()) {
32 std::size_t next = input.find_first_of(whitespace);
36 if (next != std::string::npos) {
37 s = input.substr(0, next);
40 input = input.substr(next + 1, endPos);
46 endPos = input.length() - 1;
49 if (s ==
"")
continue;
50 wsTokens.push_back(s);
53 for (
unsigned int i = 0; i < wsTokens.size(); i++) {
57 endPos = input.length() - 1;
58 while (endPos < input.length()) {
59 std::size_t next = input.find_first_of(prefer);
61 std::string s = input;
62 if (next > 0 && next < input.length()) {
64 s = input.substr(0, next);
66 input = input.substr(next, endPos);
67 }
else if (next == 0) {
69 s = input.substr(0, next + 1);
71 input = input.substr(next + 1, endPos);
76 endPos = input.length() - 1;
87 std::vector<std::string>::const_iterator begin,
88 std::vector<std::string>::const_iterator end,
89 std::vector<std::string>& subBlock) {
90 std::stack<std::string> matched;
91 std::vector<std::string>::const_iterator itr;
92 for (itr = begin; itr != end; ++itr) {
93 subBlock.push_back(*itr);
106 TEUCHOS_ASSERT(matched.empty());
114 if (tokens.size() == 1)
118 TEUCHOS_ASSERT(*(tokens.begin()) ==
"[")
119 TEUCHOS_ASSERT(*(tokens.end() - 1) ==
"]");
121 std::vector<Teuchos::RCP<Xpetra::BlockReorderManager> > vecRMgr;
122 std::vector<std::string>::const_iterator itr = tokens.begin() + 1;
123 while (itr != tokens.end() - 1) {
125 std::vector<std::string> subBlock;
137 rMgr->SetNumBlocks(vecRMgr.size());
138 for (
unsigned int i = 0; i < vecRMgr.size(); i++)
139 rMgr->SetBlock(i, vecRMgr[i]);
157 std::vector<std::string> tokens;
162 tokenize(reorder,
" \t\n",
"[]", tokens);
std::vector< std::string >::const_iterator buildSubBlock(std::vector< std::string >::const_iterator begin, std::vector< std::string >::const_iterator end, std::vector< std::string > &subBlock)
Teuchos::RCP< const Xpetra::BlockReorderManager > blockedReorderFromString(std::string reorder)
Convert a string to a block reorder manager object.
void tokenize(std::string srcInput, std::string whitespace, std::string prefer, std::vector< std::string > &tokens)
virtual void SetBlock(int blockIndex, int reorder)
Sets the subblock to a specific index value.
Teuchos::RCP< Xpetra::BlockReorderManager > blockedReorderFromTokens(const std::vector< std::string > &tokens)
std::vector< Teuchos::RCP< BlockReorderManager > > children_
definitions of the subblocks