405 std::cout <<
"ElmerModuleDriver:Main: Setting up parallel communicator..." << std::endl;
407 MPI_Comm masterComm = communicator.GetCommunicator();
408 int rank = communicator.Rank();
409 int nproc = communicator.Size();
411 std::cout <<
"ElmerModuleDriver:Main:Rank #"
418 COM_init( &argc, &argv);
422 driverObject.setRank(rank);
423 driverObject.myPaneId=100+rank;
426 if (driverObject.isStreamer())
427 std::cout <<
"Hi, I am a streamer ..." << std::endl;
430 std::string outfile_name;
431 std::stringstream ss;
432 std::string str_rank;
435 outfile_name =
"out" + str_rank +
".dat";
436 driverObject.outfile.open(outfile_name.c_str());
439 driverObject.setColor(color);
440 driverObject.outfile <<
"color = " << color << std::endl;
441 driverObject.outfile <<
"rank = " << rank << std::endl;
443 communicator.Split(color, rank, newCommunicator);
444 driverObject.outfile <<
"communicator.Size() = " << communicator.Size() << std::endl;
445 driverObject.outfile <<
"newCommunicator.Size() = " << newCommunicator.Size() << std::endl;
446 driverObject.setComm(newCommunicator.GetCommunicator());
448 newComm = newCommunicator.GetCommunicator();
449 COM_set_default_communicator(newComm);
453 driverObject.
init(argc, argv);
458 COM_get_dataitems(
"ELMModule", &numDataItems, output);
459 std::istringstream Istr(output);
460 std::vector<std::string> dataItemNames;
461 for (
int i=0; i<numDataItems; ++i) {
464 dataItemNames.push_back(name);
465 std::cout <<
"Rank #" << rank
466 <<
", ElmerModuleDriver:main: DataItem # " << i <<
": " << name << std::endl;
472 COM_get_panes(
"ELMModule", &numPanes, &paneList);
473 std::cout <<
"Rank #" << rank
474 <<
", ELMModuleDriver:main: Number of Panes " << numPanes << std::endl;
475 for (
int i=0; i<numPanes; ++i)
476 std::cout <<
"Rank #" << rank
477 <<
", ELMModuleDriver:main: Pane ID # " << i+1 <<
"=" << paneList[i] << std::endl;
480 driverObject.updateSolution();
488 if(driverObject.isFSISim() && driverObject.isChangeLoad()){
489 std::vector<int> nLoadsVec;
490 std::vector<int> nLoadsTotVec;
491 std::vector<int> nRecvAllVec;
492 nLoadsVec.push_back(driverObject.nNodes*driverObject.nLoads);
493 std::cout <<
"Rank #"<<rank
494 <<
", nLoadsVec["<<rank<<
"] = "<<nLoadsVec[rank]<<std::endl;
495 parErr = newCommunicator.Gatherv(nLoadsVec, nLoadsTotVec, nRecvAllVec);
497 std::cout <<
"Error in gathering information from processes." << std::endl;
499 for (
int iProc=0; iProc<nLoadsTotVec.size(); iProc++)
500 std::cout <<
"Rank #"<<rank
501 <<
", nLoadsTotVec["<<iProc<<
"] = "<<nLoadsTotVec[iProc]<<std::endl;
504 std::vector<double> loadsVec;
505 std::vector<double> loadsTotVec;
508 for (
int iProc=0; iProc < nLoadsTotVec.size(); iProc++){
509 nLoadsTot += nLoadsTotVec[iProc];
511 loadsTotVec.resize(nLoadsTot,0.0);
512 for (
int iLoad=1; iLoad < nLoadsTot; iLoad+=3)
513 loadsTotVec[iLoad] = 1.0;
514 std::cout <<
"Size of loadsTotVec = " << loadsTotVec.size() << std::endl;
517 parErr = newCommunicator.Scatterv(loadsTotVec, nLoadsTotVec, loadsVec);
519 std::cout <<
"Error in scattering information to processes." << std::endl;
520 std::cout <<
"Rank #" << rank
521 <<
", number of load components I received = " << loadsVec.size()
524 for (
int iLoad=0; iLoad<(driverObject.nLoads*driverObject.nNodes); ++iLoad){
525 driverObject.
Loads[iLoad] = loadsVec[iLoad];
526 std::cout <<
"Rank #" << rank
527 <<
", driverObject.Loads ["<<iLoad<<
"] = "
528 << driverObject.
Loads[iLoad] << std::endl;
531 std::cout <<
"Rank #"<<rank<<
"...Reaching to barrier"<<std::endl;
532 newCommunicator.Barrier();
537 newCommunicator.Barrier();
541 if(driverObject.isFSISim() && driverObject.isChangeLoad()){
542 std::vector<double> dispVec;
543 std::vector<double> dispTotVec;
544 std::vector<int> nSendAllVec;
545 for (
int iDisp=0; iDisp<(driverObject.nDisp*driverObject.nNodes); ++iDisp){
546 dispVec.push_back(driverObject.
Disp[iDisp]);
547 std::cout <<
"Rank #" << rank
548 <<
", dispVec ["<<iDisp<<
"] = " << dispVec[iDisp] << std::endl;
550 std::cout <<
"Rank #" << rank
551 <<
", dispVec size = " << dispVec.size() << std::endl;
553 parErr = newCommunicator.Gatherv(dispVec, dispTotVec, nSendAllVec);
555 std::cout <<
"Error in gathering information from processes." << std::endl;
556 std::cout <<
"Rank #" << rank
557 <<
", size of dispTotVec = " << dispTotVec.size()
560 std::cout <<
"Rank #"<<rank<<
"...Reaching to barrier"<<std::endl;
561 newCommunicator.Barrier();
564 double maxDisp = 0.0;
565 double minDisp = 0.0;
566 for (
int iDisp=0; iDisp<dispTotVec.size(); iDisp++){
567 maxDisp = std::max(dispTotVec[iDisp], maxDisp);
568 minDisp = std::min(dispTotVec[iDisp], minDisp);
569 std::cout <<
"Rank #0, dispTotVec [" << iDisp <<
"] = "
570 << dispTotVec[iDisp] << std::endl;
572 outfile_name =
"maxMinDisp.dat";
573 std::ofstream testFile;
574 testFile.open(outfile_name.c_str());
575 testFile << maxDisp << std::endl << minDisp << std::endl;
579 int OUT_set = COM_get_function_handle(
"OUT.set_option");
580 int OUT_write = COM_get_function_handle(
"OUT.write_dataitem");
581 const char *win_out=
"ELMModule";
582 std::string win_out_pre(win_out);
583 win_out_pre.append(
".");
584 int OUT_all = COM_get_dataitem_handle((win_out_pre+
"all").c_str());
590 fileOut =
"ELMModule_window" + ss.str();
591 COM_call_function( OUT_set,
"format",
"HDF4");
592 COM_call_function( OUT_write, (fileOut +
".hdf").c_str(), &OUT_all, win_out,
600 driverObject.outfile.close();
606 communicator.Finalize();
int init(int argc, char *argv[])
IRAD::Comm::CommunicatorObject CommType
Convenience typedef for CommunicatorObject.