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

Definition at line 325 of file OpenFoamModuleDriverTest.H.

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

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

325  {
326  std::cout << "Running Test__ModuleFunctionInitialize" << std::endl;
327 
328  //load OpenFoam module
329  std::cout << "Before loading OFModule" << std::endl;
330  COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI, "OFModule");
331  std::cout << "After loading OFModule" << std::endl;
332  bool works = false;
333 
334  // Test Initalize function exists
335  int initHandle = COM_get_function_handle("OFModule.InitFoam");
336  if(initHandle > 0)
337  works=true;
338  else {
339  std::cout << "ModuleFunctionInitialize Error: Could not get function handle."
340  << std::endl;
341  }
342  result.UpdateResult("InitFunction:Exists",works);
343  if (!works)
344  return;
345 
346  //Call GetInputData to copy input test data to temp directory for running tests.
347  std::string suffix = "/share/Testing/test_data/HronTurekFsi";
348  std::string dirName = SourceDirPath + suffix;
349  std::string testDir = IRAD::Sys::CWD() + "/UnitTestDataHTFsi";
350  int IntDir = GetInputData(dirName, testDir);
351  std::string fluidDir = testDir + "/fluid";
352  std::string OrgDir = IRAD::Sys::CWD();
353  IntDir = IRAD::Sys::ChDir(fluidDir);
354 
355  // Test proper operation of init
356  // For now, just test that the function returned 0 after running
357  // We test the "correctness" of the registered data in subsequent tests
358  int dummy1=1;
359  char *dummy2[2];
360  int verb=3;
361  dummy2[0] = const_cast<char *>(std::string("functionInit").c_str());
362  dummy2[1] = NULL;
363  COM_call_function(initHandle, &dummy1, &dummy2, &verb);
364 
365  // check the status variable to determine success of initialize
366  int* initStatus=NULL;
367  int status = COM_get_status("OFModule.initStatus",101);
368  if(status <= 0) {
369  std::cout << "ModuleFunctionInitialize Error: initStatus not a valid DataItem."
370  << "status = " << status << std::endl;
371  return;
372  }
373 
374  COM_get_array("OFModule.initStatus", 101, &initStatus);
375 
376  works=false;
377  if(*initStatus == 0)
378  works=true;
379  else {
380  std::cout << "ModuleFunctionInitialize Error: initStatus not set to zero by InitFoam."
381  << std::endl;
382  }
383  result.UpdateResult("InitFunction:Runs",works);
384 
385  // cleanup
386  IntDir = IRAD::Sys::ChDir(OrgDir);
387  COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI, "OFModule");
388 
389  return;
390  }
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: