7 TEUCHOS_ASSERT(blockIndex < (
int)
children_.size());
8 Teuchos::RCP<BlockReorderManager> child = Teuchos::rcp(
new BlockReorderLeaf(reorder));
13 TEUCHOS_ASSERT(blockIndex < (
int)
children_.size());
19 void tokenize(std::string srcInput, std::string whitespace, std::string prefer, std::vector<std::string>& tokens) {
20 std::string input = srcInput;
21 std::vector<std::string> wsTokens;
22 std::size_t endPos = input.length() - 1;
23 while (endPos < input.length()) {
24 std::size_t next = input.find_first_of(whitespace);
28 if (next != std::string::npos) {
29 s = input.substr(0, next);
32 input = input.substr(next + 1, endPos);
38 endPos = input.length() - 1;
41 if (s ==
"")
continue;
42 wsTokens.push_back(s);
45 for (
unsigned int i = 0; i < wsTokens.size(); i++) {
49 endPos = input.length() - 1;
50 while (endPos < input.length()) {
51 std::size_t next = input.find_first_of(prefer);
53 std::string s = input;
54 if (next > 0 && next < input.length()) {
56 s = input.substr(0, next);
58 input = input.substr(next, endPos);
59 }
else if (next == 0) {
61 s = input.substr(0, next + 1);
63 input = input.substr(next + 1, endPos);
68 endPos = input.length() - 1;
79 std::vector<std::string>::const_iterator begin,
80 std::vector<std::string>::const_iterator end,
81 std::vector<std::string>& subBlock) {
82 std::stack<std::string> matched;
83 std::vector<std::string>::const_iterator itr;
84 for (itr = begin; itr != end; ++itr) {
85 subBlock.push_back(*itr);
98 TEUCHOS_ASSERT(matched.empty());
106 if (tokens.size() == 1)
110 TEUCHOS_ASSERT(*(tokens.begin()) ==
"[")
111 TEUCHOS_ASSERT(*(tokens.end() - 1) ==
"]");
113 std::vector<Teuchos::RCP<Xpetra::BlockReorderManager> > vecRMgr;
114 std::vector<std::string>::const_iterator itr = tokens.begin() + 1;
115 while (itr != tokens.end() - 1) {
117 std::vector<std::string> subBlock;
129 rMgr->SetNumBlocks(vecRMgr.size());
130 for (
unsigned int i = 0; i < vecRMgr.size(); i++)
131 rMgr->SetBlock(i, vecRMgr[i]);
149 std::vector<std::string> tokens;
154 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