51 #ifdef HAVE_MUELU_EPETRAEXT
58 #include <arpa/inet.h>
72 const std::string& levelName = it->first;
75 if (inList.
isSublist(levelName) && ((levelName.find(
"level ") == 0 && levelName.size() > 6) || levelName.find(
"user data") == 0)) {
76 int levelID = strtol(levelName.substr(6).c_str(), 0, 0);
78 if(levelName.find(
"user data") == std::string::npos) {
80 levelID = strtol(levelName.substr(6).c_str(), 0, 0);
81 if (maxLevel < levelID)
88 const std::string& name = it2->first;
89 if (name ==
"A" || name ==
"P" || name ==
"R" || name==
"M" || name ==
"Mdiag" || name ==
"K" || name ==
"Nullspace" || name ==
"Coordinates"
90 || name ==
"Node Comm" || name ==
"DualNodeID2PrimalNodeID"
91 #ifdef HAVE_MUELU_INTREPID2
92 || name ==
"pcoarsen: element to node map"
94 || name ==
"output stream"
99 #ifdef HAVE_MUELU_MATLAB
113 serialList.
setEntry(it->first, it->second);
124 char* buf = (
char*) malloc(stream.size() + 1);
125 strcpy(buf, stream.c_str());
126 char* token = strtok(buf, delimChars);
136 char* tokStart = token;
137 char* tokEnd = token + strlen(token) - 1;
138 while(*tokStart ==
' ' && tokStart < tokEnd)
140 while(*tokEnd ==
' ' && tokStart < tokEnd)
143 if(tokStart < tokEnd)
145 std::string finishedToken(tokStart, tokEnd - tokStart);
146 tokenList.push_back(finishedToken);
148 token = strtok(NULL, delimChars);
156 char* str = (
char*) malloc(name.length() + 1);
157 strcpy(str, name.c_str());
159 char* firstWord = strtok(str,
" ");
164 char* secondWord = strtok(NULL,
" ");
169 char* thirdWord = strtok(NULL,
" ");
175 char* tolowerIt = firstWord;
178 *tolowerIt = (char)
tolower(*tolowerIt);
182 if(strstr(firstWord,
"matrix") ||
183 strstr(firstWord,
"multivector") ||
184 strstr(firstWord,
"map") ||
185 strstr(firstWord,
"ordinalvector") ||
186 strstr(firstWord,
"int") ||
187 strstr(firstWord,
"scalar") ||
188 strstr(firstWord,
"double") ||
189 strstr(firstWord,
"complex") ||
190 strstr(firstWord,
"string"))
206 char* str = (
char*) malloc(name.length() + 1);
207 strcpy(str, name.c_str());
209 char* firstWord = strtok(str,
" ");
214 char* secondWord = strtok(NULL,
" ");
219 char* thirdWord = strtok(NULL,
" ");
225 char* tolowerIt = firstWord;
228 *tolowerIt = (char)
tolower(*tolowerIt);
232 if(strstr(firstWord,
"matrix") ||
233 strstr(firstWord,
"multivector") ||
234 strstr(firstWord,
"map") ||
235 strstr(firstWord,
"ordinalvector") ||
236 strstr(firstWord,
"int") ||
237 strstr(firstWord,
"scalar") ||
238 strstr(firstWord,
"double") ||
239 strstr(firstWord,
"complex") ||
240 strstr(firstWord,
"string") ||
241 strstr(firstWord,
"array<go>") ||
242 strstr(firstWord,
"array<lo>") ||
243 strstr(firstWord,
"arrayrcp<lo>") ||
244 strstr(firstWord,
"arrayrcp<go>"))
261 int numRanks = baseComm->getSize();
262 if(numRanks == 1) {NodeId = baseComm->getRank();
return baseComm;}
265 char hostname[MPI_MAX_PROCESSOR_NAME];
267 MPI_Get_processor_name(hostname,&len);
268 struct hostent * host = gethostbyname(hostname);
269 int myaddr = (int) htonl(inet_network(inet_ntoa(*(
struct in_addr *)host->h_addr)));
272 std::vector<int> addressList(numRanks);
273 Teuchos::gatherAll(*baseComm,1,&myaddr,numRanks,&addressList[0]);
276 std::sort(addressList.begin(),addressList.end());
280 for(
int i=0, prev=addressList[0]; i<numRanks && prev != myaddr; i++) {
281 if(prev != addressList[i]) {
282 prev = addressList[i];
292 if(reductionFactor != 1) {
295 int coresPerNode = 0;
296 for(
int i=0, prev=addressList[0]; i<numRanks; i++) {
297 if(prev != addressList[i]) {
298 prev = addressList[i];
299 coresPerNode = std::max(i - lastI, coresPerNode);
303 coresPerNode = std::max(numRanks - lastI, coresPerNode);
306 if(coresPerNode % reductionFactor != 0)
307 throw std::runtime_error(
"Reduction factor does not evently divide # cores per node");
308 int reducedCPN = coresPerNode / reductionFactor;
309 int nodeDivision = newComm->getRank() / reducedCPN;
311 NodeId = numNodes * reductionFactor + nodeDivision;
312 newComm = baseComm->split(NodeId,baseComm->getRank());
317 NodeId = baseComm->getRank();
ConstIterator end() const
Teuchos::RCP< const Teuchos::Comm< int > > GenerateNodeComm(RCP< const Teuchos::Comm< int > > &baseComm, int &NodeId, const int reductionFactor)
std::string tolower(const std::string &str)
bool IsParamMuemexVariable(const std::string &name)
ParameterList & setEntry(const std::string &name, const ParameterEntry &entry)
bool isSublist(const std::string &name) const
params_t::ConstIterator ConstIterator
ConstIterator begin() const
bool IsParamValidVariable(const std::string &name)
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
void TokenizeStringAndStripWhiteSpace(const std::string &stream, std::vector< std::string > &tokenList, const char *delimChars)
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)
Extract non-serializable data from level-specific sublists and move it to a separate parameter list...