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);
39 endPos = input.length()-1;
43 wsTokens.push_back(s);
46 for(
unsigned int i=0;i<wsTokens.size();i++) {
50 endPos = input.length()-1;
51 while(endPos<input.length()) {
52 std::size_t next = input.find_first_of(prefer);
54 std::string s = input;
55 if(next>0 && next<input.length()) {
58 s = input.substr(0,next);
60 input = input.substr(next,endPos);
64 s = input.substr(0,next+1);
66 input = input.substr(next+1,endPos);
71 endPos = input.length()-1;
82 std::vector<std::string>::const_iterator begin,
83 std::vector<std::string>::const_iterator end,
84 std::vector<std::string> & subBlock) {
85 std::stack<std::string> matched;
86 std::vector<std::string>::const_iterator itr;
87 for(itr=begin;itr!=end;++itr) {
89 subBlock.push_back(*itr);
92 if(*itr==
"[") matched.push(
"[");
93 else if(*itr==
"]") matched.pop();
100 TEUCHOS_ASSERT(matched.empty());
113 TEUCHOS_ASSERT(*(tokens.begin())==
"[")
114 TEUCHOS_ASSERT(*(tokens.end()-1)==
"]");
116 std::vector<Teuchos::RCP<Xpetra::BlockReorderManager> > vecRMgr;
117 std::vector<std::string>::const_iterator itr = tokens.begin()+1;
118 while(itr!=tokens.end()-1) {
120 std::vector<std::string> subBlock;
132 rMgr->SetNumBlocks(vecRMgr.size());
133 for(
unsigned int i=0;i<vecRMgr.size();i++)
134 rMgr->SetBlock(i,vecRMgr[i]);
153 std::vector<std::string> tokens;
158 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