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 void Test__ModuleFunctionStepFluid ( ResultsType &  result)
inlinevirtual

Definition at line 543 of file OpenFoamModuleDriverTest.H.

References TestingObject< ResultsType >::GetInputData(), and TestingObject< ResultsType >::SourceDirPath.

Referenced by TestingObject< ResultsType >::Process(), and TestingObject< ResultsType >::RunTest().

543  {
544  std::cout << "Running Test__ModuleFunctionStepFluid" << std::endl;
545 
546  //load OpenFoam module
547  COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI, "OFModule");
548 
549  bool works = false;
550 
551 
552  //Call GetInputData to copy input test data to temp directory for running tests.
553  std::string suffix = "/share/Testing/test_data/HronTurekFsi";
554  std::string dirName = SourceDirPath + suffix;
555  std::string testDir = IRAD::Sys::CWD() + "/UnitTestDataStepTest";
556  int IntDir = GetInputData(dirName, testDir);
557  std::string fluidDir = testDir + "/fluid";
558  std::string OrgDir = IRAD::Sys::CWD();
559  IntDir = IRAD::Sys::ChDir(fluidDir);
560 
561  // call init to setup the mesh
562  int dummy1=1;
563  char *dummy2[2];
564  dummy2[0] = const_cast<char *>(std::string("StepFluid").c_str());
565  dummy2[1] = NULL;
566  int verb=3;
567  int initHandle = COM_get_function_handle("OFModule.InitFoam");
568  COM_call_function(initHandle, &dummy1, &dummy2, &verb);
569 
570  // list of panes in this window
571  int numPanes;
572  int* paneList;
573  COM_get_panes("OFModule", &numPanes, &paneList);
574 
575  // only one pane for serial runs
576  int pane = paneList[0];
577 
578  // check that the current simulation time and endTime are registered
579  int status = COM_get_status("OFModule.time", pane);
580  bool timeStatus = false;
581  if(status <= 0) {
582  std::cout << "ModuleFunctionStepFluid Error: time not a valid DataItem."
583  << "status = " << status << std::endl;
584  result.UpdateResult("TimeData:Registered", false);
585  return;
586  } else {
587  timeStatus = true;
588  }
589 
590  status = COM_get_status("OFModule.endTime", pane);
591  if(status <= 0) {
592  std::cout << "ModuleFunctionStepFluid Error: endTime not a valid DataItem."
593  << "status = " << status << std::endl;
594  result.UpdateResult("TimeData:Registered", false);
595  return;
596  } else {
597  timeStatus = timeStatus && true;
598  }
599  result.UpdateResult("TimeData:Registered", timeStatus);
600 
601  double* time=NULL;
602  COM_get_array("OFModule.time", pane, &time);
603  double* endTime=NULL;
604  COM_get_array("OFModule.endTime", pane, &endTime);
605 
606  works=false;
607  double testTime = 0.;
608  double testEndTime = 5.e-3;
609  double toler = 1.e-9;
610  if(*time - testTime < toler && *endTime - testEndTime < toler)
611  works=true;
612  else {
613  std::cout << "ModuleFunctionStepFluid Error: time or endTime initialized incorrectly"
614  << std::endl;
615  std::cout << " time = " << *time << " expected " << testTime << std::endl;
616  std::cout << " endTime = " << *endTime << " expected " << testEndTime << std::endl;
617  }
618  result.UpdateResult("TimeData:Correct",works);
619 
620  // Test StepFluid function exists
621  works = false;
622  int stepHandle = COM_get_function_handle("OFModule.StepFluid");
623  if(stepHandle > 0)
624  works=true;
625  else {
626  std::cout << "ModuleFunctionStepFluid Error: Could not get function handle."
627  << std::endl;
628  result.UpdateResult("StepFluidFunction:Exists",false);
629  return;
630  }
631  result.UpdateResult("StepFluidFunction:Exists",works);
632 
633  // Test StepFluid function steps
634  // check that the time got incremented as expected
635  COM_call_function(stepHandle);
636 
637 
638  works=false;
639  testTime = 1.e-3;
640  toler = 1.e-9;
641  if(*time - testTime < toler )
642  works=true;
643  else {
644  std::cout << "ModuleFunctionStepFluid Error: time did not increment"
645  << std::endl;
646  std::cout << " time = " << *time << "expected " << testTime << std::endl;
647  }
648  result.UpdateResult("StepFluidFunction:Steps",works);
649 
650  // cleanup
651  IntDir = IRAD::Sys::ChDir(OrgDir);
652  //Unload OpenFoam module
653  COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI, "OFModule");
654 
655  return;
656  }
virtual int GetInputData(std::string sourceDir, std::string destDir)
Function to copy input data from source testing directory for use in unit tests.
std::string SourceDirPath
The string for the testing source directory.

Here is the call graph for this function:

Here is the caller graph for this function: