ElmerFoamFSI  2.0
ElmerFoamFSI is fluid-solid interaction simulation application built up from OpenFOAM CFD and Elmer CSM coupled through the IMPACT multiphysics software integration infrastructure.
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Groups Pages
virtual int GetInputData ( std::string  suffix,
std::string  TestDir 
)
inlinevirtual

Definition at line 481 of file ElmerFoamFSITest.H.

References TestingObject< ResultsType >::SourceDirPath.

Referenced by TestingObject< ResultsType >::__helper().

481  {
482 
483  std::string DirName;
484  std::string OrgDir;
485 
486  //Save original working directory for later
487  OrgDir = IRAD::Sys::CWD();
488 
489  //Create full path for test input data directory
490  DirName = SourceDirPath + suffix;
491 
492  //Check if data directory exists
493  if(!IRAD::Sys::FILEEXISTS(DirName)){
494  std::cout << "GetInputData Error: Could not find data directory, "
495  << DirName << ". Exiting (fail)." << std::endl;
496  return -1;
497  }
498 
499  std::ifstream Inf;
500  std::ofstream Ouf;
501  std::string InFileName;
502  std::string OutFileName;
503  int IntDir;
504 
505  //Create TestDir directory in current directory (if it doesn't
506  //already exist) to run our tests in.
507  if(!IRAD::Sys::FILEEXISTS(TestDir)){
508  IntDir = IRAD::Sys::CreateDirectory(TestDir);
509  if(IntDir == -1){
510  std::cout << "GetInputData Error: Could not make directory, "
511  << TestDir << ". Exiting (fail)." << std::endl;
512  return -1;
513  }
514  }
515 
516  //Open the input test data directory
517  IRAD::Sys::Directory SourceDir(DirName);
518 
519  //Change directories to TestDir directory for running
520  IntDir = IRAD::Sys::ChDir(TestDir);
521  if(IntDir == -1){
522  std::cout << "GetInputData Error: Could not change directories to "
523  << TestDir << ". Exiting (fail)." << std::endl;
524  return -1;
525  }
526 
527  //Copy input data to TestDir directory for running
528  for(std::vector<std::string>::iterator it = SourceDir.begin();
529  it != SourceDir.end(); ++it){
530  InFileName = DirName + "/" + *it;
531 
532  // WK recursively copying the directory as well
533  bool isDir = IRAD::Sys::ISDIR(InFileName.c_str());
534  if( isDir ){
535  std::string dirSuffix = suffix + "/" + *it;
536  std::string dirTestDir = TestDir + "/" + *it;
537  IntDir = GetInputData(dirSuffix, dirTestDir);
538 
539  //checking If recursive GetInputData exited correctly
540  if(IntDir != 0){
541  std::cout << "GetInput failed at the recursive level"
542  << std::endl;
543  return -1;
544  }
545  }
546 
547  Inf.open(InFileName.c_str());
548  OutFileName = IRAD::Sys::CWD() + "/" + *it;
549  Ouf.open(OutFileName.c_str());
550  Ouf << Inf.rdbuf();
551  Ouf.close();
552  Inf.close();
553  }
554 
555  //Change directories to back to original directory
556  IntDir = IRAD::Sys::ChDir(OrgDir);
557  if(IntDir == -1){
558  std::cout << "GetInputData Error: Could not change directories to "
559  << OrgDir << ". Exiting (fail)." << std::endl;
560  return -1;
561  }
562 
563  return 0;
564  }
virtual int GetInputData(std::string suffix, std::string TestDir)

Here is the caller graph for this function: