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

Definition at line 400 of file OpenFoamModuleDriverTest.H.

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

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

400  {
401  std::cout << "Running Test__ModuleSurfaceData" << std::endl;
402 
403  //load OpenFoam module
404  COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI, "OFModule");
405 
406  //Call GetInputData to copy input test data to temp directory for running tests.
407  std::string suffix = "/share/Testing/test_data/HronTurekFsi";
408  std::string dirName = SourceDirPath + suffix;
409  std::string testDir = IRAD::Sys::CWD() + "/UnitTestDataSurfaceData";
410  int IntDir = GetInputData(dirName, testDir);
411  std::string fluidDir = testDir + "/fluid";
412  std::string OrgDir = IRAD::Sys::CWD();
413  IntDir = IRAD::Sys::ChDir(fluidDir);
414 
415  // call init to setup the mesh
416  int dummy1=1;
417  char *dummy2[2];
418  dummy2[0] = const_cast<char *>(std::string("DataReg").c_str());
419  dummy2[1] = NULL;
420  int verb=3;
421  int initHandle = COM_get_function_handle("OFModule.InitFoam");
422  COM_call_function(initHandle, &dummy1, &dummy2, &verb);
423 
424  // list of panes in this window
425  int numPanes;
426  int* paneList;
427  COM_get_panes("OFModule", &numPanes, &paneList);
428 
429  // only one pane for serial runs
430  int pane = paneList[0];
431 
432  // check that the pressure is registered
433  int status = COM_get_status("OFModule.pressure", pane);
434  if(status <= 0) {
435  std::cout << "ModuleSurfaceData Error: pressure not a valid DataItem. "
436  << "status = " << status << std::endl;
437  result.UpdateResult("PressureData:Registered", false);
438  return;
439  } else {
440  result.UpdateResult("PressureData:Registered", true);
441  }
442 
443  // get some information about how the item was registered
444  char getDataItemLoc;
445  COM_Type getDataItemType;
446  int getDataItemComponents;
447  std::string getDataItemUnits;
448  COM_get_dataitem("OFModule.pressure", &getDataItemLoc, &getDataItemType,
449  &getDataItemComponents, &getDataItemUnits);
450 
451  double* pressure=NULL;
452  COM_get_array("OFModule.pressure", pane, &pressure);
453 
454  // check the array size against what we expect
455  // pressures are scalars stored at the cell centers
456  // assumes a single connectivity for this pane
457 
458  bool pressureCorrect = false;
459  int numPres = 0;
460  int numPresExpected = 168;
461  int numPresCompExpected = 1;
462  COM_get_size("OFModule.pressure", pane, &numPres);
463 
464  if (numPres != numPresExpected || numPresCompExpected != getDataItemComponents) {
465  std::cout << "Wrong number of pressures registered for this mesh." << std::endl;
466  std::cout << "Got " << numPres << " Items, Expected: " << numPresExpected << std::endl;
467  std::cout << "Got " << getDataItemComponents << " Components, Expected: "
468  << numPresCompExpected << std::endl;
469  } else {
470  pressureCorrect = true;
471  }
472 
473 
474  // traction
475  status = COM_get_status("OFModule.traction", pane);
476  if(status <= 0) {
477  std::cout << "ModuleSurfaceData Error: traction not a valid DataItem."
478  << "status = " << status << std::endl;
479  result.UpdateResult("TractionData:Registered", false);
480  return;
481  } else {
482  result.UpdateResult("TractionData:Registered", true);
483  }
484 
485  COM_get_dataitem("OFModule.traction", &getDataItemLoc, &getDataItemType,
486  &getDataItemComponents, &getDataItemUnits);
487 
488  double* traction=NULL;
489  COM_get_array("OFModule.traction", pane, &traction);
490 
491  // check the array size against what we expect
492  // tractions are 3-dimensional vectors stored at the cell centers
493 
494  bool tractionCorrect = false;
495  int numTrac = 0;
496  int numTracExpected = 168;
497  int numTracCompExpected = 3;
498  COM_get_size("OFModule.traction", pane, &numTrac);
499 
500  if (numTrac != numTracExpected || numTracCompExpected != getDataItemComponents) {
501  std::cout << "Wrong number of tractions registered for this mesh." << std::endl;
502  std::cout << "Got " << numTrac << " Items, Expected: " << numTracExpected << std::endl;
503  std::cout << "Got " << getDataItemComponents << " Components, Expected: "
504  << numTracCompExpected << std::endl;
505  } else {
506  tractionCorrect = true;
507  }
508 
509  // now step the solution and compare the pressure and traction vs what
510  // we expect from the sample problem
511  int stepHandle = COM_get_function_handle("OFModule.StepFluid");
512  COM_call_function(stepHandle);
513 
514  bool works=false;
515  //testTime = 1.e-3;
516  //toler = 1.e-9;
517  if(0)
518  works=true;
519  else {
520  std::cout << "ModuleSurfaceData Error: pressure incorrect "
521  << std::endl;
522  }
523  result.UpdateResult("PressureData:Correct", pressureCorrect);
524  result.UpdateResult("TractionData:Correct", tractionCorrect);
525 
526  // cleanup
527  IntDir = IRAD::Sys::ChDir(OrgDir);
528  //Unload OpenFoam module
529  COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI, "OFModule");
530 
531  return;
532  }
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: