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
ElmerFoamFSITest.H
Go to the documentation of this file.
1 #ifndef __ELMERFOAMFSI_TEST_H__
13 #define __ELMERFOAMFSI_TEST_H__
14 #ifdef _ELMERFOAMFSI_PARALLEL_
15 #include "COMM.H"
16 #endif
17 #include "Testing.H"
18 #include "ExampleHeader.H"
19 #include "Profiler.H"
20 #include <vector>
21 #include <cmath>
22 #include "Driver.H"
23 #include "FsiCoupling.H"
24 #include "FsiCouplingPar.H"
25 
26 // Loading native modules
27 COM_EXTERN_MODULE(OpenFoamFSI);
28 COM_EXTERN_MODULE(ElmerCSC);
29 COM_EXTERN_MODULE(OpenFoamFSIPar);
30 COM_EXTERN_MODULE(ElmerCSCParallel);
31 
32 namespace ElmerFoamFSI {
33 
37  namespace TestFixture {
43  double F1(double x) { return (2.0*x); };
49  double F2(double x) { return (3.0*x*x); };
50  };
60 
79  template<typename ResultsType>
80  class TestingObject : public IRAD::Util::TestingObject<ResultsType>
81  {
82  typedef std::string StackType;
83  typedef IRAD::Profiler::ProfilerObj ProfilerType;
84  typedef IRAD::Global::GlobalObj<StackType,int,ProfilerType> TestGlobalType;
85  typedef IRAD::Util::TestingObject<ResultsType> TestingObjectBaseType;
86  protected:
87  // Example test fixtures for ElmerFoamFSI testing.
88  //
89  // In a real project, there would be many test fixtures
90  // in the TestingObject.
94  std::string ExampleTestFixture;
98  std::vector<int> N;
99  //WK Start
100  std::string SourceDirPath;
101  //WK End
103  //NS Start
104  std::vector<std::string> componentInterfaceNames;
118  //NS End
119  public:
127  virtual void Epilogue() {
128  COM_finalize();};
136  virtual void Prologue(){
137  ExampleTestFixture.assign("ExampleTestData");
138  for(int i = 10;i < 10000000;i*=10) N.push_back(i);
139  // initializing COM
140  bool runs = false;
141  int nargs_dupe = 2;
142  char **args_dupe;
143  args_dupe = new char * [3];
144  args_dupe[0] = const_cast<char *>("test");
145  args_dupe[1] = const_cast<char *>("-com-mpi");
146  args_dupe[2] = NULL;
147  COM_init(&nargs_dupe,&args_dupe);
148  }
154  double F1(double x) { return (2.0*x); };
160  double F2(double x) { return (3.0*x*x); };
170  virtual void Test__ExampleFunction(ResultsType &result) {
171  // This is an actual test of the function called
172  // ExampleFunction. The name Test__XXXXX will
173  // eventually help automated utilities with
174  // running tests by name.
175  std::string ExampleResult(ExampleFunction(ExampleTestFixture));
176  result.UpdateResult("ExampleFunction:Works",
177  ExampleResult == ExampleTestFixture);
178  result.UpdateResult("ExampleFunction:Fails",
179  ExampleResult != ExampleTestFixture);
180  }
195  virtual void Test__TrapezoidQuadrature(ResultsType &result) {
196  std::ostringstream Ostr;
197  std::vector<double> E;
198  size_t n = 2*N.size();
199  bool runs = true;
200  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
201  double Ii = 0.0;
202  try {
204  } catch (...) {
205  runs = false;
206  }
207  E.push_back(std::fabs(Ii-1.0));
208  }
209  bool order2 = (E[0] < 1e-14);
210  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
211  double Ii = 0.0;
212  try {
214  } catch (...) {
215  runs = false;
216  }
217  E.push_back(std::fabs(Ii-1.0));
218  }
219  result.UpdateResult("TrapezoidQuadrature:Runs",runs);
220  result.UpdateResult("TrapezoidQuadrature:Accurate",E[n-1] < 1e-12);
221  for(int i = N.size();i < n - 1;i++){
222  double e = E[i+1]/E[i];
223  double n1 = static_cast<double>(N[i-N.size()])/static_cast<double>(N[(i-N.size())+1]);
224  double p = std::log(e)/std::log(n1);
225  p -= 2;
226  p = std::abs(p);
227  if(p > 2e-2){
228  order2 = false;
229  }
230  }
231  result.UpdateResult("TrapezoidQuadrature:Order2",order2);
232  }
233 
247  virtual void Test__MidPointQuadrature(ResultsType &result) {
248  std::ostringstream Ostr;
249  std::vector<double> Ibar;
250  std::vector<double> E;
251  size_t n = 2*N.size();
252  bool runs = true;
253  bool order2 = true;
254  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
255  double Ii = 0.0;
256  try {
258  } catch (...) {
259  runs = false;
260  }
261  Ibar.push_back(Ii);
262  E.push_back(std::fabs(Ii-1.0));
263  }
264  order2 = (E[0] < 1e-14);
265  for(std::vector<int>::iterator i = N.begin();i != N.end();i++){
266  double Ii = 0.0;
267  try {
269  } catch (...) {
270  runs = false;
271  }
272  Ibar.push_back(Ii);
273  E.push_back(std::fabs(Ii-1.0));
274  }
275  result.UpdateResult("MidPointQuadrature:Runs",runs);
276  result.UpdateResult("MidPointQuadrature:Accurate",E[n-1] < 1e-12);
277  for(int i = N.size();i < n - 1;i++){
278  double e = E[i+1]/E[i];
279  double n1 = static_cast<double>(N[i-N.size()])/static_cast<double>(N[(i-N.size())+1]);
280  double p = std::log(e)/std::log(n1);
281  p -= 2;
282  p = std::abs(p);
283  if(p > 1e-2){
284  order2 = false;
285  }
286  }
287  result.UpdateResult("MidPointQuadrature:Order2",order2);
288  }
289 
290  // Test elmerModule load/unloads properly
291  virtual void Test__ElmerModuleLoad(ResultsType &result) {
292  std::cout << "Running Test__ElmerModuleLoad" << std::endl;
293 
294  // load Elmer module
295  std::cout << "Loading Elmer Module" << std::endl;
296  COM_LOAD_MODULE_STATIC_DYNAMIC(ElmerCSC, "ElmerModule");
297  bool works = false;
298 
299  // get window handle
300  int h=COM_get_window_handle("ElmerModule");
301  if(h <= 0){
302  std::cout << " After loading, COM_get_window_handle(\"ElmerModule\") returns "
303  << h << std::endl;
304  std::cout << "ModuleLoadUnload Error: Could not get window handle."
305  << std::endl;
306  }
307  else{
308  works=true;
309  std::cout << "Elmer Module Loaded" << std::endl;
310  }
311  result.UpdateResult("LoadElmerModule:Works",works);
312 
313  // unload Elmer Module
314  std::cout << "Unloading Elmer Module" << std::endl;
315  COM_UNLOAD_MODULE_STATIC_DYNAMIC(ElmerCSC, "ElmerModule");
316  works=false;
317 
318  // make sure module unloaded
319  h=COM_get_window_handle("ElmerModule");
320  if(h > 0){
321  std::cout << "After unloading, COM_get_window_handle(\"ElmerModule\") returns "
322  << h << std::endl;
323  std::cout << "ModuleLoadUnload Error: Did not properly unload module."
324  << std::endl;
325  }
326  else{
327  works=true;
328  std::cout << "Elmer Module Unloaded" << std::endl;
329  }
330 
331  result.UpdateResult("UnloadElmerModule:Works",works);
332 
333  return;
334  }
335 
336  // Test OpenFoamModule load/unloads properly
337  virtual void Test__OFModuleLoad(ResultsType &result) {
338  std::cout << "Running Test__OFModuleLoad" << std::endl;
339 
340  // load Elmer module
341  std::cout << "Loading OpenFoam Module" << std::endl;
342  COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI, "OFModule");
343  bool works = false;
344 
345  // get window handle
346  int h=COM_get_window_handle("OFModule");
347  if(h <= 0){
348  std::cout << " After loading, COM_get_window_handle(\"OFModule\") returns "
349  << h << std::endl;
350  std::cout << "ModuleLoadUnload Error: Could not get window handle."
351  << std::endl;
352  }
353  else{
354  works=true;
355  std::cout << "OpenFoam Module Loaded" << std::endl;
356  }
357  result.UpdateResult("LoadOpenFoamModule:Works",works);
358 
359  // unload Elmer Module
360  std::cout << "Unloading OpenFoam Module" << std::endl;
361  COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI, "OFModule");
362  works=false;
363 
364  // make sure module unloaded
365  h=COM_get_window_handle("OFModule");
366  if(h > 0){
367  std::cout << "After unloading, COM_get_window_handle(\"OFModule\") returns "
368  << h << std::endl;
369  std::cout << "ModuleLoadUnload Error: Did not properly unload module."
370  << std::endl;
371  }
372  else{
373  works=true;
374  std::cout << "OpenFoam Module Unloaded" << std::endl;
375  }
376 
377  result.UpdateResult("UnloadOpenFoamModule:Works",works);
378  return;
379  }
380 
381 
382  // Test if Elmer can load properly, and its functions handles can be accessed
383  virtual void Test__ElmerHandlesCheck(ResultsType & result){
384  bool works, loadWorks, globWorks, initWorks, runWorks, finWorks, unloadWorks = false;
385 
386  std::cout << "Running Test__ElmerHandlesCheck" << std::endl;
387 
388  //Loading Elmer Module
389  std::cout << "Loading Elmer Module" << std::endl;
390  COM_LOAD_MODULE_STATIC_DYNAMIC(ElmerCSC,"ElmerModule");
391 
392  //Checking Elmer Module is indeed loaded.
393  int ElmerHandle = COM_get_window_handle("ElmerModule");
394  if(ElmerHandle <=0){
395  std::cout << "After loading, COM_get_window_handle(\"ElmerModule\") returns "
396  << ElmerHandle << std::endl;
397  std::cout << "Error : Could not get window handle." << std::endl;
398  }
399  else{
400  loadWorks = true;
401  std::cout << "Elmer Module Loaded." << std::endl;
402  }
403 
404  //Checking the registration of global data.
405  int globHandle = COM_get_dataitem_handle("ElmerModule.global");
406  if(globHandle <= 0){
407  std::cout << "After loading, COM_get_dataitem_handle(\"ElmerModule.global\") returns "
408  << globHandle << std::endl;
409  std::cout << "Error : Could not get the data item handle." << std::endl;
410  }
411  else{
412  globWorks = true;
413  std::cout << "Global data handle accessed." << std::endl;
414  }
415 
416  //Checking the ElmerModule function Initialize handle
417  int initHandle = COM_get_function_handle("ElmerModule.Initialize");
418  if(initHandle <= 0){
419  std::cout << "After loading, COM_get_function_handle(\"ElmerModule.Initialize\") returns "
420  << initHandle << std::endl;
421  std::cout << "Error : Could not get the Initialize function handle." << std::endl;
422  }
423  else{
424  initWorks = true;
425  std::cout << "Initialize function handle accessed." << std::endl;
426  }
427 
428  //Checking the ElmerModule function Run handle
429  int runHandle = COM_get_function_handle("ElmerModule.Run");
430  if(runHandle <= 0){
431  std::cout << "After loading, COM_get_function_handle(\"ElmerModule.Run\") returns "
432  << runHandle << std::endl;
433  std::cout << "Error : Could not get the Run function handle." << std::endl;
434  }
435  else{
436  runWorks = true;
437  std::cout << "Run function handle accessed." << std::endl;
438  }
439 
440  //Checking the ElmerModule function Finalize handle
441  int finHandle = COM_get_function_handle("ElmerModule.Finalize");
442  if(finHandle <= 0){
443  std::cout << "After loading, COM_get_function_handle(\"ElmerModule.Finalize\") returns "
444  << finHandle << std::endl;
445  std::cout << "Error : Could not get the Finalize function handle." << std::endl;
446  }
447  else{
448  finWorks = true;
449  std::cout << "Finalize function handle accessed." << std::endl;
450  }
451 
452  //Unloading Elmer Module
453  std::cout << "Unloading Elmer Module" << std::endl;
454  COM_UNLOAD_MODULE_STATIC_DYNAMIC(ElmerCSC, "ElmerModule");
455 
456  //Checking Elmer Module is indeed unloaded.
457  ElmerHandle = COM_get_window_handle("ElmerModule");
458  if(ElmerHandle > 0){
459  std::cout << "After unloading, COM_get_window_handle(\"ElmerModule\") returns "
460  << ElmerHandle << std::endl;
461  std::cout << "Error : Module was not properly unloaded." << std::endl;
462  }
463  else{
464  unloadWorks = true;
465  std::cout << "ElmerModule Unloaded." << std::endl;
466  }
467 
468  if(loadWorks & globWorks & initWorks & runWorks & finWorks & unloadWorks) works = true;
469  result.UpdateResult("ElmerHandlesCheck:Works",works);
470  }
471 
474  void SetSourceDirPath(std::string input){
475  SourceDirPath = input;
476  std::cout << "Source Path = " << SourceDirPath << std::endl;
477  }
478 
479 
480  //Copied from ElmerDriver testing script
481  virtual int GetInputData(std::string suffix,std::string TestDir){
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  }
565 
566 
567  // Helper function
568  virtual int __helper(){
569 
570  int IntDir;
571  std::string OrgDir, TestDir;
572 
573  //call GetInputData to copy input test data to temp directory for running tests.
574  std::string suffix = "/testing/share/Testing/test_data/SimpleStatic";
575 
576  //Make path for directory to run the test in
577  TestDir = IRAD::Sys::CWD() + "/SimpleStatic";
578  std::cout << "Getting Input Data!!" << std::endl;
579  IntDir = GetInputData(suffix, TestDir);
580 
581  //check if GetInputData exited correctly.
582  if(IntDir != 0){
583  std::cout << "GetInputData failed!"
584  << std::endl;
585  return 1;
586  }
587  // Check if TestDir directory exists in current Directory
588  if(!IRAD::Sys::FILEEXISTS(TestDir)){
589  std::cout << "Could not find directory, "
590  << TestDir << ", for running tests." << std::endl;
591  return 2;
592  }
593  return 0;
594  }
595 
596 
597  //testing the getinput
598  virtual void Test__GetInput(ResultsType &result){
599  int out = __helper();
600  bool works;
601 
602  if(out == 0) works = true;
603  else works = false;
604  result.UpdateResult("GetInput:Works",works);
605  }
606 
607 
612  int work =__helper();
613  int IntDir;
614  verblevel = 3;
617 
618  std::string fluidDir;
619  std::string simStaticDir;
620  fluidDir = IRAD::Sys::CWD() + "/SimpleStatic/fluid";
621  simStaticDir = IRAD::Sys::CWD() + "/SimpleStatic";
622  if(work == 1)
623  std::cout << "GetInputData failed 2!" << std::endl;
624  else if (work == 2)
625  std::cout << "Could not find directory for running tests" << std::endl;
626 
627  if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simStaticDir)))){
628  std::cout << "SimpleStatic / fluid Folders do not exists!" << std::endl;
629  return;
630  }
631  else{
632  IntDir = IRAD::Sys::ChDir(simStaticDir);
633  if(IntDir == -1){
634  std::cout << "GetInputData Error: Could not change directory to "
635  << fluidDir << ". Exiting (fail). " << std::endl;
636  }
637  std::system("chmod 755 Allclean Allrun AllrunPar makeLinks makeSerialLinks removeSerialLinks");
638  std::system("./Allclean");
639  std::system("./Allrun");
640  IntDir = IRAD::Sys::ChDir(fluidDir);
641  if(IntDir == -1){
642  std::cout << "GetInputData Error: Could not change directory to "
643  << fluidDir << ". Exiting (fail). " << std::endl;
644  }
645  }
646 
647  std::string fluidSolverName("OpenFoamFSI");
648  std::string solidSolverName("ElmerCSC");
649  std::string transferServiceName("SurfX");
650  std::string runMode("1");
651 
652  std::cout << "COM loading all modules" << std::endl;
653  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
654  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
655  COM_load_module("SurfUtil","SurfUtil");
656  COM_load_module("Simpal","Simpal");
657 
658  componentInterfaceNames.push_back("FluidsComponentInterface");
659  componentInterfaceNames.push_back("StructuresComponentInterface");
660  componentInterfaceNames.push_back("TransferInterface");
661  componentInterfaceNames.push_back("SurfUtil");
662  componentInterfaceNames.push_back("Simpal");
663 
664  fsiCoupler.SetRunMode(runMode);
666  std::cout << "fsiCouplerAgentsInitialize Successful!" << std::endl;
667  }
668 
669 
670 /* void Test__ReadInputWorks(ResultsType &result){
671 
672  int argc = 2;
673  char ** argv;
674  argv = new char*[3];
675  argv[0] = const_cast<char *>("elmerfoamfsi_test");
676  argv[1] = const_cast<char *>("test.config");
677  argv[2] = NULL;
678  std::cout << "Do I even get here? " << std::endl;
679  ElmerFoamFSI::SerialDriverProgram MyProgram(argc,argv);
680  std::cout << "Do I even get here? 2" << std::endl;
681 
682  int retval = MyProgram.Initialize();
683  if(retval){
684  MyProgram.ErrOut("Error in Prram initialization. \n");
685  }
686  std::cout << "Before Reading Input ! " << std::endl;
687  MyProgram.ReadInput();
688  std::cout << "After Reading Input ! " << std::endl;
689  int works = 0;
690  //result.UpdateResult("ReadInputWorks", works);
691  }
692 */
695  virtual void Test__FsiCoupler(ResultsType &result){
696  double time_final = 0.05;
697  double timestep = 2.0e-3;
698  bool works = true;
699 
700  //Call the Agents Initialize function above
701  //as well as the Initialize function of fsiCoupler
702  std::cout << "Initalizing..." << std::endl;
704  fsiCoupler.Initialize(componentInterfaceNames, time_final, timestep);
705  std::cout << "Initialize Completed!" << std::endl;
706 
707  //test to make sure that classInterfaceNames are populated
708  //correctly to match componentInterfaceNames
709  std::vector<std::string> classInterfaceNames;
710  classInterfaceNames = fsiCoupler.getVariable();
711 
712  for(int i = 0; i < componentInterfaceNames.size(); i++){
713  if(componentInterfaceNames.at(i) != classInterfaceNames.at(i)){
714  works = false;
715  break;
716  }
717  }
718  result.UpdateResult("fsiCoupler:Works",works);
719  }
720 
721 
726  virtual void Test__ElmerStructures(ResultsType &result){
727  bool works = true;
728 
729  std::cout << "Initalizing Structure..." << std::endl;
732  std::cout << "Initialization Completed!" << std::endl;
733 
734  //Make sure the initializing doesn't return an error
735  if (initresult != 0){
736  std::cout << "structuresAgent->Initialize returns error. " <<
737  "Refer to ElmerAgent.H for more information. " << std::endl;
738  works = false;
739  }
740 
741  //Test to make sure the node coordinates are populated
742  //More of an exercise to make sure the data is loaded correctly
743  //face coordinates are not in use currently
744  std::vector<double> nodecoordinates(TeststructuresAgent->returnNodeCoords());
745  std::cout << "Node size is: " << nodecoordinates.size() << std::endl;
746  if (nodecoordinates.size() < 0){
747  std::cout << "There is a problem with obtaining the nodecoordinate data" <<
748  "Refer to ElmerAgent.H for more information. " << std::endl;
749  works = false;
750  }
751 
752  double arr[306] = {0.1, 0.1, 0, 0, 0.1, 0, 0, 0.1, 0.02, 0.1, 0.1, 0.02, 0, 0.1, 0.04, 0.1, 0.1, 0.04, 0, 0.1, 0.06, 0.1, 0.1, 0.06, 0, 0.1, 0.08, 0.1, 0.1, 0.08, 0, 0.1, 0.1, 0.1, 0.1, 0.1, 0, 0.1, 0.12, 0.1, 0.1, 0.12, 0, 0.1, 0.14, 0.1, 0.1, 0.14, 0, 0.1, 0.16, 0.1, 0.1, 0.16, 0, 0.1, 0.18, 0.1, 0.1, 0.18, 0, 0.1, 0.2, 0.1, 0.1, 0.2, 0, 0.1, 0.22, 0.1, 0.1, 0.22, 0, 0.1, 0.24, 0.1, 0.1, 0.24, 0, 0.1, 0.26, 0.1, 0.1, 0.26, 0, 0.1, 0.28, 0.1, 0.1, 0.28, 0, 0.1, 0.3, 0.1, 0.1, 0.3, 0, 0.1, 0.32, 0.1, 0.1, 0.32, 0, 0.1, 0.34, 0.1, 0.1, 0.34, 0, 0.1, 0.36, 0.1, 0.1, 0.36, 0, 0.1, 0.38, 0.1, 0.1, 0.38, 0, 0.1, 0.4, 0.1, 0.1, 0.4, 0, 0.1, 0.42, 0.1, 0.1, 0.42, 0, 0.1, 0.44, 0.1, 0.1, 0.44, 0, 0.1, 0.46, 0.1, 0.1, 0.46, 0, 0.1, 0.48, 0.1, 0.1, 0.48, 0, 0.1, 0.5, 0.1, 0.1, 0.5, 0, 0.1, 0.52, 0.1, 0.1, 0.52, 0, 0.1, 0.54, 0.1, 0.1, 0.54, 0, 0.1, 0.56, 0.1, 0.1, 0.56, 0, 0.1, 0.58, 0.1, 0.1, 0.58, 0, 0.1, 0.6, 0.1, 0.1, 0.6, 0, 0.1, 0.62, 0.1, 0.1, 0.62, 0, 0.1, 0.64, 0.1, 0.1, 0.64, 0, 0.1, 0.66, 0.1, 0.1, 0.66, 0, 0.1, 0.68, 0.1, 0.1, 0.68, 0, 0.1, 0.7, 0.1, 0.1, 0.7, 0, 0.1, 0.72, 0.1, 0.1, 0.72, 0, 0.1, 0.74, 0.1, 0.1, 0.74, 0, 0.1, 0.76, 0.1, 0.1, 0.76, 0, 0.1, 0.78, 0.1, 0.1, 0.78, 0, 0.1, 0.8, 0.1, 0.1, 0.8, 0, 0.1, 0.82, 0.1, 0.1, 0.82, 0, 0.1, 0.84, 0.1, 0.1, 0.84, 0, 0.1, 0.86, 0.1, 0.1, 0.86, 0, 0.1, 0.88, 0.1, 0.1, 0.88, 0, 0.1, 0.9, 0.1, 0.1, 0.9, 0, 0.1, 0.92, 0.1, 0.1, 0.92, 0, 0.1, 0.94, 0.1, 0.1, 0.94, 0, 0.1, 0.96, 0.1, 0.1, 0.96, 0, 0.1, 0.98, 0.1, 0.1, 0.98, 0, 0.1, 1, 0.1, 0.1, 1};
753 
754  for (int i = 0; i < 306; i++){
755  if (arr[i] != nodecoordinates.at(i)){
756  std::cout << "Node Coordinate Inconsistencies." << std::endl;
757  works = false;
758  break;
759  }
760  }
761  result.UpdateResult("ElmerStructures:Works",works);
762  delete TeststructuresAgent;
763  }
764 
765 
770  virtual void Test__OpenFoamFluids(ResultsType &result){
771  bool works = true;
772 
773  std::cout << "Initializing Fluids..." << std::endl;
776  std::cout << "Initialization Completed!" << std::endl;
777 
778  //Make sure the initializing doesn't return an error
779  if (initresult != 0){
780  std::cout << "fluidsAgent->Initialize returns error. " <<
781  "Refer to OpenFoamAgent.H for more information. " << std::endl;
782  works = false;
783  }
784 
785  //Test to make sure the node coordinates are populated
786  //More of an exercise to make sure the data is loaded correctly
787  //face coordinates are not in use currently
788  std::vector<double> nodecoordinates(TestfluidsAgent->returnNodeCoords());
789  std::cout << "Fluid Node size is: " << nodecoordinates.size() << std::endl;
790  if (nodecoordinates.size() < 0){
791  std::cout << "There is a problem with obtaining the nodecoordinate data" <<
792  "Refer to OpenFoamAgent.H for more information. " << std::endl;
793  works = false;
794  }
795 
796  double arr[306] = {0.1, 0.1, 0, 0.1, 0.1, 0.02, 0, 0.1, 0.02, 0, 0.1, 0, 0.1, 0.1, 0.04, 0, 0.1, 0.04, 0.1, 0.1, 0.06, 0, 0.1, 0.06, 0.1, 0.1, 0.08, 0, 0.1, 0.08, 0.1, 0.1, 0.1, 0, 0.1, 0.1, 0.1, 0.1, 0.12, 0, 0.1, 0.12, 0.1, 0.1, 0.14, 0, 0.1, 0.14, 0.1, 0.1, 0.16, 0, 0.1, 0.16, 0.1, 0.1, 0.18, 0, 0.1, 0.18, 0.1, 0.1, 0.2, 0, 0.1, 0.2, 0.1, 0.1, 0.22, 0, 0.1, 0.22, 0.1, 0.1, 0.24, 0, 0.1, 0.24, 0.1, 0.1, 0.26, 0, 0.1, 0.26, 0.1, 0.1, 0.28, 0, 0.1, 0.28, 0.1, 0.1, 0.3, 0, 0.1, 0.3, 0.1, 0.1, 0.32, 0, 0.1, 0.32, 0.1, 0.1, 0.34, 0, 0.1, 0.34, 0.1, 0.1, 0.36, 0, 0.1, 0.36, 0.1, 0.1, 0.38, 0, 0.1, 0.38, 0.1, 0.1, 0.4, 0, 0.1, 0.4, 0.1, 0.1, 0.42, 0, 0.1, 0.42, 0.1, 0.1, 0.44, 0, 0.1, 0.44, 0.1, 0.1, 0.46, 0, 0.1, 0.46, 0.1, 0.1, 0.48, 0, 0.1, 0.48, 0.1, 0.1, 0.5, 0, 0.1, 0.5, 0.1, 0.1, 0.52, 0, 0.1, 0.52, 0.1, 0.1, 0.54, 0, 0.1, 0.54, 0.1, 0.1, 0.56, 0, 0.1, 0.56, 0.1, 0.1, 0.58, 0, 0.1, 0.58, 0.1, 0.1, 0.6, 0, 0.1, 0.6, 0.1, 0.1, 0.62, 0, 0.1, 0.62, 0.1, 0.1, 0.64, 0, 0.1, 0.64, 0.1, 0.1, 0.66, 0, 0.1, 0.66, 0.1, 0.1, 0.68, 0, 0.1, 0.68, 0.1, 0.1, 0.7, 0, 0.1, 0.7, 0.1, 0.1, 0.72, 0, 0.1, 0.72, 0.1, 0.1, 0.74, 0, 0.1, 0.74, 0.1, 0.1, 0.76, 0, 0.1, 0.76, 0.1, 0.1, 0.78, 0, 0.1, 0.78, 0.1, 0.1, 0.8, 0, 0.1, 0.8, 0.1, 0.1, 0.82, 0, 0.1, 0.82, 0.1, 0.1, 0.84, 0, 0.1, 0.84, 0.1, 0.1, 0.86, 0, 0.1, 0.86, 0.1, 0.1, 0.88, 0, 0.1, 0.88, 0.1, 0.1, 0.9, 0, 0.1, 0.9, 0.1, 0.1, 0.92, 0, 0.1, 0.92, 0.1, 0.1, 0.94, 0, 0.1, 0.94, 0.1, 0.1, 0.96, 0, 0.1, 0.96, 0.1, 0.1, 0.98, 0, 0.1, 0.98, 0.1, 0.1, 1, 0, 0.1, 1};
797 
798  for (int i = 0; i < 306; i++){
799  if (arr[i] != nodecoordinates.at(i)){
800  std::cout << "Node Coordinate Inconsistencies." << std::endl;
801  works = false;
802  break;
803  }
804  }
805  result.UpdateResult("OpenFoamFluids:Works",works);
806  delete TestfluidsAgent;
807  }
808 
809 
818  virtual void Test__TransferDisplacementsToFluid(ResultsType & result){
819 
820  double time_final = 0.05;
821  double timestep = 2.0e-3;
822  int verblevel = 3;
823  bool works = true;
824  int IntDir;
825 
826  // Copying the SimpleStatic data using getinputdata() helper function.
827  bool work =__helper();
828  std::string fluidDir;
829  std::string simStaticDir;
830  fluidDir = IRAD::Sys::CWD() + "/SimpleStatic/fluid";
831  simStaticDir = IRAD::Sys::CWD() + "/SimpleStatic";
832  if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simStaticDir)))){
833  std::cout << "SimpleStatic / fluid Folders do not exists!" << std::endl;
834  works = false;
835  result.UpdateResult("fsiCoupler:Works",works);
836  return;
837  }
838  else{
839  IntDir = IRAD::Sys::ChDir(simStaticDir);
840  if(IntDir == -1){
841  std::cout << "GetInputData Error: Could not change directory to "
842  << fluidDir << ". Exiting (fail). " << std::endl;
843  works = false;
844  result.UpdateResult("fsiCoupler:Works",works);
845  }
846  std::system("chmod 755 Allclean Allrun AllrunPar makeLinks makeSerialLinks removeSerialLinks");
847  std::system("./Allclean");
848  std::system("./Allrun");
849  IntDir = IRAD::Sys::ChDir(fluidDir);
850  if(IntDir == -1){
851  std::cout << "GetInputData Error: Could not change directory to "
852  << fluidDir << ". Exiting (fail). " << std::endl;
853  works = false;
854  result.UpdateResult("fsiCoupler:Works",works);
855  }
856  }
857 
858 
860  std::string fluidSolverName("OpenFoamFSI");
861  std::string solidSolverName("ElmerCSC");
862  std::string transferServiceName("SurfX");
863  std::string runMode("1");
864 
865 
866  std::cout << "COM loading all this junks" << std::endl;
867  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
868  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
869  COM_load_module("SurfUtil","SurfUtil");
870  COM_load_module("Simpal","Simpal");
871 
872 
873  std::vector<std::string> componentInterfaceNames;
874  componentInterfaceNames.push_back("FluidsComponentInterface");
875  componentInterfaceNames.push_back("StructuresComponentInterface");
876  componentInterfaceNames.push_back("TransferInterface");
877  componentInterfaceNames.push_back("SurfUtil");
878  componentInterfaceNames.push_back("Simpal");
879 
880  fsiCoupler.SetRunMode(runMode);
881  fsiCoupler.SetVerbLevel(verblevel);
882 
883  fsiCoupler.Initialize(componentInterfaceNames, time_final, timestep);
884 
885  // Mimicing FsiCoupler::run, intializing variables, etc.
886  int innerCount = 0;
887  int maxSubSteps = 1000;
888  int dumpinterval = 1;
889  int systemStep = 0;
890 
891  double *fluidDisp1 = NULL;
892  double *fluidDisp2 = NULL;
893  double *solidDisp1 = NULL;
894  double *solidDisp2 = NULL;
895 
896 
897  // Get the displacement vector values for both solid and fluid domain.
898  std::string fluidsCoordinateName(fsiCoupler.getFluidIntName()+".solidDisplacement");
899  std::string solidsCoordinateName(fsiCoupler.getSolidIntName()+".Displacements");
900  COM_get_array(fluidsCoordinateName.c_str(),(fsiCoupler.getFluidAgent())->PaneID(),&fluidDisp1);
901  COM_get_array(solidsCoordinateName.c_str(),(fsiCoupler.getStructureAgent())->PaneID(),&solidDisp1);
902 
903 
904  // Setting Y-component of the displacement vector to be the linear function displacement
905  // along z direction throughout nodes
906  for(int i = 0; i <fsiCoupler.getStructureAgent()->Coordinates().size()/3; i++){
907  solidDisp1[3*i+1] = fsiCoupler.getStructureAgent()->Coordinates()[3*i+2];
908  }
909 
910  if(!(fsiCoupler.getRunMode())){
911  fsiCoupler.TransferDisplacementsToFluid(fsiCoupler.getStructureAgent(),fsiCoupler.getFluidAgent());
912  }
913 
914  // After transferDisplacementToFluids, get displacement vectors for both agents to compare
915  COM_get_array(fluidsCoordinateName.c_str(),(fsiCoupler.getFluidAgent())->PaneID(),&fluidDisp2);
916  COM_get_array(solidsCoordinateName.c_str(),(fsiCoupler.getStructureAgent())->PaneID(),&solidDisp2);
917 
918  double totalFluidDis, totalSolidDis = 0;
919  // Calculate the total displacements for solid displacements and fluid displacements after transfer
920  for(int i=0; i < fsiCoupler.getStructureAgent()->Coordinates().size()/3; i++){
921  totalFluidDis += fluidDisp2[3*i+1];
922  totalSolidDis += solidDisp2[3*i+1];
923  }
924 
925  std::cout << "total fluid dis = " << totalFluidDis << std::endl;
926  std::cout << "total solid dis = " << totalSolidDis << std::endl;
927 
928  // Using Error % = (Experimented value - Theoretical value) / Theoretical value
929  double totalError = (totalFluidDis - totalSolidDis) / totalSolidDis;
930  // If the error % is greater than 5%, let's call it a fail.
931  std::cout << "total error = " << totalError << std::endl;
932  if(totalError >= .05) works = false;
933 
934  result.UpdateResult("TransferDisplacementsToFluid:Works",works);
935  }
936 
938  virtual void Test__FluidAgentRun(ResultsType &result){
939 
940  double time_final = 0.05;
941  double timestep = 2.0e-3;
942  int verblevel = 3;
943  bool works = true;
944  int IntDir;
945 
946  // Copying the SimpleStatic data using getinputdata() helper function.
947  bool work =__helper();
948  std::string fluidDir;
949  std::string simStaticDir;
950  fluidDir = IRAD::Sys::CWD() + "/SimpleStatic/fluid";
951  simStaticDir = IRAD::Sys::CWD() + "/SimpleStatic";
952  if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simStaticDir)))){
953  std::cout << "SimpleStatic / fluid Folders do not exists!" << std::endl;
954  works = false;
955  result.UpdateResult("fsiCoupler:Works",works);
956  return;
957  }
958  else{
959  IntDir = IRAD::Sys::ChDir(simStaticDir);
960  if(IntDir == -1){
961  std::cout << "GetInputData Error: Could not change directory to "
962  << fluidDir << ". Exiting (fail). " << std::endl;
963  works = false;
964  result.UpdateResult("fsiCoupler:Works",works);
965  }
966  std::system("chmod 755 Allclean Allrun AllrunPar makeLinks makeSerialLinks removeSerialLinks");
967  std::system("./Allclean");
968  std::system("./Allrun");
969  IntDir = IRAD::Sys::ChDir(fluidDir);
970  if(IntDir == -1){
971  std::cout << "GetInputData Error: Could not change directory to "
972  << fluidDir << ". Exiting (fail). " << std::endl;
973  works = false;
974  result.UpdateResult("fsiCoupler:Works",works);
975  }
976  }
977 
979  std::string fluidSolverName("OpenFoamFSI");
980  std::string solidSolverName("ElmerCSC");
981  std::string transferServiceName("SurfX");
982  std::string runMode("1");
983 
984  std::cout << "COM loading all this junks" << std::endl;
985  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
986  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
987  COM_load_module("SurfUtil","SurfUtil");
988  COM_load_module("Simpal","Simpal");
989 
990  std::vector<std::string> componentInterfaceNames;
991  componentInterfaceNames.push_back("FluidsComponentInterface");
992  componentInterfaceNames.push_back("StructuresComponentInterface");
993  componentInterfaceNames.push_back("TransferInterface");
994  componentInterfaceNames.push_back("SurfUtil");
995  componentInterfaceNames.push_back("Simpal");
996 
997  fsiCoupler.SetRunMode(runMode);
998  fsiCoupler.SetVerbLevel(verblevel);
999  fsiCoupler.Initialize(componentInterfaceNames, time_final, timestep);
1000 
1001  // Mimicing FsiCoupler::run, intializing variables, etc.
1002  int innerCount = 0;
1003  int maxSubSteps = 1000;
1004  int dumpinterval = 1;
1005  int systemStep = 0;
1006 
1007  double *fluidDisp1 = NULL;
1008  double *fluidDisp2 = NULL;
1009  double *solidDisp1 = NULL;
1010  double *solidDisp2 = NULL;
1011 
1012  // Get the displacement vector values for both solid and fluid domain.
1013  std::string fluidsCoordinateName(fsiCoupler.getFluidIntName()+".solidDisplacement");
1014  std::string solidsCoordinateName(fsiCoupler.getSolidIntName()+".Displacements");
1015  COM_get_array(fluidsCoordinateName.c_str(),(fsiCoupler.getFluidAgent())->PaneID(),&fluidDisp1);
1016  COM_get_array(solidsCoordinateName.c_str(),(fsiCoupler.getStructureAgent())->PaneID(),&solidDisp1);
1017 
1018  if(!(fsiCoupler.getRunMode())){
1019  fsiCoupler.TransferDisplacementsToFluid(fsiCoupler.getStructureAgent(),fsiCoupler.getFluidAgent());
1020  }
1021  double simultime = fsiCoupler.getSimulationTime();
1022 
1023 
1024  std::cout << "simultime is =" << simultime << std::endl;
1025  if(fsiCoupler.getRunMode() < 2){
1026  fsiCoupler.getFluidAgent()->InitializeTimeStep(simultime);
1027  fsiCoupler.getFluidAgent()->Run(fsiCoupler.getSimulationTime()+fsiCoupler.getSimulationFinalTime());
1028  }
1029 
1030  int stride = 0;
1031  int cap = 0;
1032  double *tractions = NULL;
1033  COM_get_array((fsiCoupler.getFluidIntName()+".traction").c_str(),101,&tractions,&stride,&cap);
1034  int isize = cap*stride;
1035 
1036  /*for(int i = 0; i < isize/3 ; i++){
1037  std::cout << "tractions[" << i << "] = " << tractions[3*i] << ", " << tractions[3*i+1] << ", " << tractions[3*i+2] << std::endl;
1038  } */
1039 
1040  works = tractionCheck(tractions,isize);
1041 
1042  result.UpdateResult("FluidAgentRun:Works",works);
1043  }
1044  bool tractionCheck(double * tractions, int isize){
1045  double tractionSave[isize];
1046 
1047  // Hard coding the value
1048  tractionSave[0] = 0;
1049  tractionSave[1] = -1;
1050  tractionSave[2] = 2.63292e-18;
1051  tractionSave[3] = 0;
1052  tractionSave[4] = -1;
1053  tractionSave[5] = 1.32171e-18;
1054  tractionSave[6] = 0;
1055  tractionSave[7] = -1;
1056  tractionSave[8] = 3.64051e-21;
1057  tractionSave[9] = 0;
1058  tractionSave[10] = -1;
1059  tractionSave[11] = 6.63492e-19;
1060  tractionSave[12] = 0;
1061  tractionSave[13] = -1;
1062  tractionSave[14] = 1.98684e-18;
1063  tractionSave[15] = 0;
1064  tractionSave[16] = -1;
1065  tractionSave[17] = 1.98606e-18;
1066  tractionSave[18] = 0;
1067  tractionSave[19] = -1;
1068  tractionSave[20] = 1.98645e-18;
1069  tractionSave[21] = 0;
1070  tractionSave[22] = -1;
1071  tractionSave[23] = 1.32296e-18;
1072  tractionSave[24] = 0;
1073  tractionSave[25] = -1;
1074  tractionSave[26] = 6.63492e-19;
1075  tractionSave[27] = 0;
1076  tractionSave[28] = -1;
1077  tractionSave[29] = 1.97793e-18;
1078  tractionSave[30] = 0;
1079  tractionSave[31] = -1;
1080  tractionSave[32] = 1.31444e-18;
1081  tractionSave[33] = 0;
1082  tractionSave[34] = -1;
1083  tractionSave[35] = 1.31606e-18;
1084  tractionSave[36] = 0;
1085  tractionSave[37] = -1;
1086  tractionSave[38] = 1.31808e-18;
1087  tractionSave[39] = 0;
1088  tractionSave[40] = -1;
1089  tractionSave[41] = 6.61478e-19;
1090  tractionSave[42] = 0;
1091  tractionSave[43] = -1;
1092  tractionSave[44] = 2.01408e-21;
1093  tractionSave[45] = 0;
1094  tractionSave[46] = -1;
1095  tractionSave[47] = -6.56599e-19;
1096  tractionSave[48] = 0;
1097  tractionSave[49] = -1;
1098  tractionSave[50] = -6.58225e-19;
1099  tractionSave[51] = 0;
1100  tractionSave[52] = -1;
1101  tractionSave[53] = -6.56211e-19;
1102  tractionSave[54] = 0;
1103  tractionSave[55] = -1;
1104  tractionSave[56] = -6.58225e-19;
1105  tractionSave[57] = 0;
1106  tractionSave[58] = -1;
1107  tractionSave[59] = 6.65506e-19;
1108  tractionSave[60] = 0;
1109  tractionSave[61] = -1;
1110  tractionSave[62] = 1.32172e-18;
1111  tractionSave[63] = 0;
1112  tractionSave[64] = -1;
1113  tractionSave[65] = 6.61478e-19;
1114  tractionSave[66] = 0;
1115  tractionSave[67] = -1;
1116  tractionSave[68] = 2.32349e-79;
1117  tractionSave[69] = 0;
1118  tractionSave[70] = -1;
1119  tractionSave[71] = 2.01408e-21;
1120  tractionSave[72] = 0;
1121  tractionSave[73] = -1;
1122  tractionSave[74] = 1.55135e-84;
1123  tractionSave[75] = 0;
1124  tractionSave[76] = -1;
1125  tractionSave[77] = -2.01408e-21;
1126  tractionSave[78] = 0;
1127  tractionSave[79] = -1;
1128  tractionSave[80] = -6.56599e-19;
1129  tractionSave[81] = 0;
1130  tractionSave[82] = -1;
1131  tractionSave[83] = -6.4893e-19;
1132  tractionSave[84] = 0;
1133  tractionSave[85] = -1;
1134  tractionSave[86] = -6.43663e-19;
1135  tractionSave[87] = 0;
1136  tractionSave[88] = -1;
1137  tractionSave[89] = -1.96577e-18;
1138  tractionSave[90] = 0;
1139  tractionSave[91] = -1;
1140  tractionSave[92] = -6.44051e-19;
1141  tractionSave[93] = 0;
1142  tractionSave[94] = -1;
1143  tractionSave[95] = 1.05339e-20;
1144  tractionSave[96] = 0;
1145  tractionSave[97] = -1;
1146  tractionSave[98] = 6.89339e-21;
1147  tractionSave[99] = 0;
1148  tractionSave[100] = -1;
1149  tractionSave[101] = -6.59852e-19;
1150  tractionSave[102] = 0;
1151  tractionSave[103] = -1;
1152  tractionSave[104] = -6.66745e-19;
1153  tractionSave[105] = 0;
1154  tractionSave[106] = -1;
1155  tractionSave[107] = -6.72787e-19;
1156  tractionSave[108] = 0;
1157  tractionSave[109] = -1;
1158  tractionSave[110] = -6.75652e-19;
1159  tractionSave[111] = 0;
1160  tractionSave[112] = -1;
1161  tractionSave[113] = -1.29356e-20;
1162  tractionSave[114] = 0;
1163  tractionSave[115] = -1;
1164  tractionSave[116] = -1.33349e-18;
1165  tractionSave[117] = 0;
1166  tractionSave[118] = -1;
1167  tractionSave[119] = -2.64994e-18;
1168  tractionSave[120] = 0;
1169  tractionSave[121] = -1;
1170  tractionSave[122] = -3.31142e-18;
1171  tractionSave[123] = 0;
1172  tractionSave[124] = -1;
1173  tractionSave[125] = -1.98645e-18;
1174  tractionSave[126] = 0;
1175  tractionSave[127] = -1;
1176  tractionSave[128] = -1.32296e-18;
1177  tractionSave[129] = 0;
1178  tractionSave[130] = -1;
1179  tractionSave[131] = 8.21297e-134;
1180  tractionSave[132] = 0;
1181  tractionSave[133] = -1;
1182  tractionSave[134] = 2.07766e-136;
1183  tractionSave[135] = 0;
1184  tractionSave[136] = -1;
1185  tractionSave[137] = -5.26695e-21;
1186  tractionSave[138] = 0;
1187  tractionSave[139] = -1;
1188  tractionSave[140] = -6.61478e-19;
1189  tractionSave[141] = 0;
1190  tractionSave[142] = -1;
1191  tractionSave[143] = -6.89339e-21;
1192  tractionSave[144] = 0;
1193  tractionSave[145] = -1;
1194  tractionSave[146] = -8.89947e-21;
1195  tractionSave[147] = 0;
1196  tractionSave[148] = -1;
1197  tractionSave[149] = -6.6386e-19;
1198 
1199  //When comparing double, exact comparison might not do the job. Hence im giving 5% error margin.
1200  for(int i = 0; i < isize; i++){
1201  if( !(double_equals(tractions[i],tractionSave[i]))){
1202  return false;
1203  }
1204  }
1205  return true;
1206  }
1207  // Helper function to compare two doubles with allowed margin of error (.1%)
1208  bool double_equals(double a, double b, double epsilon = .001){
1209  return (std::abs(a-b) < epsilon);
1210  }
1211 
1212  // Helper function that computes the average coordinates of a point, given four coordinates points
1213  std::vector<double> avgCoord(int first, int second, int third, int fourth, fluidagent* fluidAgent ){
1214  std::vector<double> Cord(3);
1215  // X direction
1216  Cord[0] = (fluidAgent->Coordinates()[3*first] + fluidAgent->Coordinates()[3*second] + fluidAgent->Coordinates()[3*third] + fluidAgent->Coordinates()[3*fourth] ) / 4;
1217  // Y direction
1218  Cord[1] = (fluidAgent->Coordinates()[3*first+1] + fluidAgent->Coordinates()[3*second+1] + fluidAgent->Coordinates()[3*third+1] + fluidAgent->Coordinates()[3*fourth+1] ) / 4;
1219  // Z direction
1220  Cord[2] = (fluidAgent->Coordinates()[3*first+2] + fluidAgent->Coordinates()[3*second+2] + fluidAgent->Coordinates()[3*third+2] + fluidAgent->Coordinates()[3*fourth+2] ) / 4;
1221  return Cord;
1222  }
1223 
1224 
1226  virtual void Test__TransferLoadsToStructures(ResultsType &result){
1227 
1228  double time_final = 0.05;
1229  double timestep = 2.0e-3;
1230  int verblevel = 3;
1231  bool works = true;
1232  int IntDir;
1233 
1234  // Copying the SimpleStatic data using getinputdata() helper function.
1235  bool work =__helper();
1236  std::string fluidDir;
1237  std::string simStaticDir;
1238  fluidDir = IRAD::Sys::CWD() + "/SimpleStatic/fluid";
1239  simStaticDir = IRAD::Sys::CWD() + "/SimpleStatic";
1240  if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simStaticDir)))){
1241  std::cout << "SimpleStatic / fluid Folders do not exists!" << std::endl;
1242  works = false;
1243  result.UpdateResult("fsiCoupler:Works",works);
1244  return;
1245  }
1246  else{
1247  IntDir = IRAD::Sys::ChDir(simStaticDir);
1248  if(IntDir == -1){
1249  std::cout << "GetInputData Error: Could not change directory to "
1250  << fluidDir << ". Exiting (fail). " << std::endl;
1251  works = false;
1252  result.UpdateResult("fsiCoupler:Works",works);
1253  }
1254  std::system("chmod 755 Allclean Allrun AllrunPar makeLinks makeSerialLinks removeSerialLinks");
1255  std::system("./Allclean");
1256  std::system("./Allrun");
1257  IntDir = IRAD::Sys::ChDir(fluidDir);
1258  if(IntDir == -1){
1259  std::cout << "GetInputData Error: Could not change directory to "
1260  << fluidDir << ". Exiting (fail). " << std::endl;
1261  works = false;
1262  result.UpdateResult("fsiCoupler:Works",works);
1263  }
1264  }
1265 
1267  std::string fluidSolverName("OpenFoamFSI");
1268  std::string solidSolverName("ElmerCSC");
1269  std::string transferServiceName("SurfX");
1270  std::string runMode("1");
1271 
1272  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
1273  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
1274  COM_load_module("SurfUtil","SurfUtil");
1275  COM_load_module("Simpal","Simpal");
1276 
1277  std::vector<std::string> componentInterfaceNames;
1278  componentInterfaceNames.push_back("FluidsComponentInterface");
1279  componentInterfaceNames.push_back("StructuresComponentInterface");
1280  componentInterfaceNames.push_back("TransferInterface");
1281  componentInterfaceNames.push_back("SurfUtil");
1282  componentInterfaceNames.push_back("Simpal");
1283 
1284  fsiCoupler.SetRunMode(runMode);
1285  fsiCoupler.SetVerbLevel(verblevel);
1286  fsiCoupler.Initialize(componentInterfaceNames, time_final, timestep);
1287 
1288  // Mimicing FsiCoupler::run, intializing variables, etc.
1289  int innerCount = 0;
1290  int maxSubSteps = 1000;
1291  int dumpinterval = 1;
1292  int systemStep = 0;
1293 
1294 
1295  if(!(fsiCoupler.getRunMode())){
1296  fsiCoupler.TransferDisplacementsToFluid(fsiCoupler.getStructureAgent(),fsiCoupler.getFluidAgent());
1297  }
1298  double simultime = fsiCoupler.getSimulationTime();
1299 
1300 
1301  std::cout << "simultime is =" << simultime << std::endl;
1302  if(fsiCoupler.getRunMode() < 2){
1303  fsiCoupler.getFluidAgent()->InitializeTimeStep(simultime);
1304  fsiCoupler.getFluidAgent()->Run(fsiCoupler.getSimulationTime()+fsiCoupler.getSimulationFinalTime());
1305  }
1306 
1307  int * conn= NULL;
1308  int connStride, connCap=0;
1309  COM_get_array( (fsiCoupler.getFluidIntName()+".:q4:").c_str(),101, &conn,&connStride,&connCap);
1310  std::cout << "connStride , connCap = " << connStride << ", " << connCap << std::endl;
1311  for (int i =0; i < connCap; i++){
1312  std::cout << "Conn Coordinates[" << i << "] = " << conn[4*i] << ", " << conn[4*i+1] << ", " << conn[4*i+2] << ", " << conn[4*i+3] << std::endl;
1313  }
1314 
1315 
1316 
1317  std::vector<double> cellCoordVec(connCap*3);
1318  std::vector<double> avgCoor(3);
1319  for(int i =0; i < connCap; i++){
1320 
1321  avgCoor = avgCoord(conn[4*i]-1,conn[4*i+1]-1,conn[4*i+2]-1,conn[4*i+3]-1, fsiCoupler.getFluidAgent());
1322  cellCoordVec[3*i] = avgCoor[0];
1323  cellCoordVec[3*i+1] = avgCoor[1];
1324  cellCoordVec[3*i+2] = avgCoor[2];
1325  std::cout << "CellCoordVec[" << i << "] = " << cellCoordVec[3*i] << ", " << cellCoordVec[3*i+1] << ", " << cellCoordVec[3*i+2] << std::endl;
1326  avgCoor.clear();
1327  }
1328 
1329 
1330  double * tractions;
1331  int stride = 0;
1332  int cap = 0;
1333  // Get the traction vector values for fluid domain.
1334  COM_get_array((fsiCoupler.getFluidIntName()+".traction").c_str(),101,&tractions,&stride,&cap);
1335  std::cout << "stride and cap = " << stride << "," << cap << std::endl;
1336  //traction becomes Ycoord * 3 + 2
1337  int isize = cap * stride ;
1338  for(int i = 0; i < isize/3 ; i++){
1339  //tractions[3*i+1] = 3*fsiCoupler.getFluidAgent()->Coordinates()[3*i+2]+2;
1340  //tractions[3*i+1] = fsiCoupler.getFluidAgent()->Coordinates()[3*i+2];
1341  //tractions[3*i+1] = 1;
1342  tractions[3*i+1] = cellCoordVec[3*i+2];
1343  std::cout << "tractions[" << i << "] = " << tractions[3*i] << ", " << tractions[3*i+1] << ", " << tractions[3*i+2] << ", Coordinates are = " << cellCoordVec[3*i] << ", " << cellCoordVec[3*i+1] << ", " << cellCoordVec[3*i+2] << std::endl;
1344  }
1345 
1346  double * solidLoads1 = NULL;
1347  int solidLoadStride1 = 0;
1348  int solidLoadCap1 =0;
1349  // Get the load vector from solid domain
1350  COM_get_array((fsiCoupler.getSolidIntName()+".Loads").c_str(),11,&solidLoads1,&solidLoadStride1,&solidLoadCap1);
1351  int solidLoadSize1 = solidLoadCap1*solidLoadStride1;
1352 
1353  // Execute Transfer LoadsToStructures
1354  if(!fsiCoupler.getRunMode()) fsiCoupler.TransferLoadsToStructures(fsiCoupler.getFluidAgent(), fsiCoupler.getStructureAgent());
1355 
1356  double * solidLoads = NULL;
1357  int solidLoadStride = 0;
1358  int solidLoadCap =0;
1359  // Get the load vector from solid domain
1360  COM_get_array((fsiCoupler.getSolidIntName()+".Loads").c_str(),11,&solidLoads,&solidLoadStride,&solidLoadCap);
1361  int solidLoadSize = solidLoadCap*solidLoadStride;
1362 
1363  std::cout << "solidLoadCap = " << solidLoadCap << ", solidLoadStride = " << solidLoadStride << std::endl;
1364  for(int i = 0; i < solidLoadSize/3; i++){
1365  std::cout << "solidLoads(" << i <<") = " << solidLoads[3*i] << ", " << solidLoads[3*i+1] << ", " << solidLoads[3*i+2] << " Where coordinate is = " << fsiCoupler.getStructureAgent()->Coordinates()[3*i] << ", " << fsiCoupler.getStructureAgent()->Coordinates()[3*i+1] << ", " << fsiCoupler.getStructureAgent()->Coordinates()[3*i+2] << std::endl;
1366  }
1367 
1368 
1369  double totalTraction, totalLoad = 0;
1370  for(int i = 0; i < solidLoadSize; i++) totalLoad += solidLoads[i];
1371  totalLoad = totalLoad/2;
1372  for(int i = 0; i < isize/3 ; i++) totalTraction +=tractions[3*i+1];
1373 
1374 
1375  std::cout << "total loads = " << totalLoad << std::endl;
1376  std::cout << "total tractions = " << totalTraction << std::endl;
1377 
1378  // Using Error % = (Experimented value - Theoretical value) / Theoretical value
1379  double totalError = (totalLoad - totalTraction) / totalTraction;
1380  // If the error % is greater than 5%, let's call it a fail.
1381  std::cout << "total error = " << totalError << std::endl;
1382  if(totalError >= .05) works = false;
1383 
1384  double maxError = 0;
1385  double errr = 0;
1386  for(int i = 0; i < isize/3 ; i++){
1387  for(int j = 0; j <= 9; j = j + 3){
1388  //std::cout << "tractions = " << tractions[3*i+1] << std::endl;
1389  //std::cout << "solidLoads = " << solidLoads[7*i+1-i+j] << std::endl;
1390  errr = std::abs( ( solidLoads[7*i+1-i+j] - tractions[3*i+1]) / tractions[3*i+1] );
1391  if(errr >= maxError){
1392  maxError = errr;
1393  std::cout << "maxError = " << maxError << std::endl;
1394  std::cout << "Happens at i,j = " << i << ", " << j << std::endl;
1395  }
1396  }
1397  }
1398  std::cout << "Max error = " << maxError << std::endl;
1399  result.UpdateResult("TransferLoadsToStructures:Works",works);
1400  }
1401 
1402 
1404  virtual void Test__SolidAgentRun(ResultsType &result){
1405 
1406 
1407  double time_final = 0.05;
1408  double timestep = 2.0e-3;
1409  int verblevel = 3;
1410  bool works = true;
1411  int IntDir;
1412 
1413  // Copying the SimpleStatic data using getinputdata() helper function.
1414  bool work =__helper();
1415  std::string fluidDir;
1416  std::string simStaticDir;
1417  fluidDir = IRAD::Sys::CWD() + "/SimpleStatic/fluid";
1418  simStaticDir = IRAD::Sys::CWD() + "/SimpleStatic";
1419  if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simStaticDir)))){
1420  std::cout << "SimpleStatic / fluid Folders do not exists!" << std::endl;
1421  works = false;
1422  result.UpdateResult("fsiCoupler:Works",works);
1423  return;
1424  }
1425  else{
1426  IntDir = IRAD::Sys::ChDir(simStaticDir);
1427  if(IntDir == -1){
1428  std::cout << "GetInputData Error: Could not change directory to "
1429  << fluidDir << ". Exiting (fail). " << std::endl;
1430  works = false;
1431  result.UpdateResult("fsiCoupler:Works",works);
1432  }
1433  std::system("chmod 755 Allclean Allrun AllrunPar makeLinks makeSerialLinks removeSerialLinks");
1434  std::system("./Allclean");
1435  std::system("./Allrun");
1436  IntDir = IRAD::Sys::ChDir(fluidDir);
1437  if(IntDir == -1){
1438  std::cout << "GetInputData Error: Could not change directory to "
1439  << fluidDir << ". Exiting (fail). " << std::endl;
1440  works = false;
1441  result.UpdateResult("fsiCoupler:Works",works);
1442  }
1443  }
1444 
1446  std::string fluidSolverName("OpenFoamFSI");
1447  std::string solidSolverName("ElmerCSC");
1448  std::string transferServiceName("SurfX");
1449  std::string runMode("1");
1450 
1451  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
1452  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
1453  COM_load_module("SurfUtil","SurfUtil");
1454  COM_load_module("Simpal","Simpal");
1455 
1456  std::vector<std::string> componentInterfaceNames;
1457  componentInterfaceNames.push_back("FluidsComponentInterface");
1458  componentInterfaceNames.push_back("StructuresComponentInterface");
1459  componentInterfaceNames.push_back("TransferInterface");
1460  componentInterfaceNames.push_back("SurfUtil");
1461  componentInterfaceNames.push_back("Simpal");
1462 
1463  fsiCoupler.SetRunMode(runMode);
1464  fsiCoupler.SetVerbLevel(verblevel);
1465  fsiCoupler.Initialize(componentInterfaceNames, time_final, timestep);
1466 
1467  // Mimicing FsiCoupler::run, intializing variables, etc.
1468  int innerCount = 0;
1469  int maxSubSteps = 1000;
1470  int dumpinterval = 1;
1471  int systemStep = 0;
1472 
1473 
1474  if(!(fsiCoupler.getRunMode())){
1475  fsiCoupler.TransferDisplacementsToFluid(fsiCoupler.getStructureAgent(),fsiCoupler.getFluidAgent());
1476  }
1477  double simultime = fsiCoupler.getSimulationTime();
1478 
1479 
1480  std::cout << "simultime is =" << simultime << std::endl;
1481  if(fsiCoupler.getRunMode() < 2){
1482  fsiCoupler.getFluidAgent()->InitializeTimeStep(simultime);
1483  fsiCoupler.getFluidAgent()->Run(fsiCoupler.getSimulationTime()+fsiCoupler.getSimulationFinalTime());
1484  }
1485 
1486  // setting a traction value so that you have bigger numbers for solid displacement later
1487  double * tractions;
1488  int stride = 0;
1489  int cap = 0;
1490  // Get the traction vector values for fluid domain.
1491  COM_get_array((fsiCoupler.getFluidIntName()+".traction").c_str(),101,&tractions,&stride,&cap);
1492  std::cout << "stride and cap = " << stride << "," << cap << std::endl;
1493  //traction becomes Ycoord * 3 + 2
1494  int isize = cap * stride ;
1495  for(int i = 0; i < isize/3 ; i++){
1496  //tractions[3*i+1] = 3*fsiCoupler.getFluidAgent()->Coordinates()[3*i+2]+2;
1497  //tractions[3*i+1] = fsiCoupler.getFluidAgent()->Coordinates()[3*i+2];
1498  //tractions[3*i+1] = 1;
1499  tractions[3*i+1] = 50000;
1500  std::cout << "tractions[" << i << "] = " << tractions[3*i] << ", " << tractions[3*i+1] << ", " << tractions[3*i+2] << std::endl;
1501  }
1502 
1503 
1504  if(!fsiCoupler.getRunMode()) fsiCoupler.TransferLoadsToStructures(fsiCoupler.getFluidAgent(), fsiCoupler.getStructureAgent());
1505 
1506 
1507  // Solid Agent Run executing
1508  if( fsiCoupler.getRunMode() !=1){
1509  fsiCoupler.getStructureAgent()->InitializeTimeStep(simultime);
1510  fsiCoupler.getStructureAgent()->Run(fsiCoupler.getSimulationTime()+fsiCoupler.getSimulationFinalTime());
1511  }
1512 
1513  double *solidDisp = NULL;
1514 
1515  // Get the displacement vector values for solid.
1516  std::string solidsCoordinateName(fsiCoupler.getSolidIntName()+".Displacements");
1517  COM_get_array(solidsCoordinateName.c_str(),(fsiCoupler.getStructureAgent())->PaneID(),&solidDisp);
1518 
1519 
1520  works = DisplacementCheck(solidDisp, 300);
1521  result.UpdateResult("SolidAgentRun:Works",works);
1522  }
1523 
1524  bool DisplacementCheck(double * disp, int size){
1525  double solidDisSave[size];
1526 
1527  // Hard coding the value
1528  solidDisSave[0] = 6.37522e-28;
1529  solidDisSave[1] = 0.000298136;
1530  solidDisSave[2] = 5.90759e-05;
1531  solidDisSave[3] = 6.37522e-28;
1532  solidDisSave[4] = 0.000298136;
1533  solidDisSave[5] = 5.90759e-05;
1534  solidDisSave[6] = 4.50796e-28;
1535  solidDisSave[7] = 0.000291629;
1536  solidDisSave[8] = 5.25282e-05;
1537  solidDisSave[9] = 4.50796e-28;
1538  solidDisSave[10] = 0.000291629;
1539  solidDisSave[11] = 5.25282e-05;
1540  solidDisSave[12] = 4.50796e-28;
1541  solidDisSave[13] = 0.000286197;
1542  solidDisSave[14] = 4.63341e-05;
1543  solidDisSave[15] = 8.55785e-28;
1544  solidDisSave[16] = 0.000286197;
1545  solidDisSave[17] = 4.63341e-05;
1546  solidDisSave[18] = 4.50796e-28;
1547  solidDisSave[19] = 0.000282032;
1548  solidDisSave[20] = 4.07105e-05;
1549  solidDisSave[21] = 4.50796e-28;
1550  solidDisSave[22] = 0.000282032;
1551  solidDisSave[23] = 4.07105e-05;
1552  solidDisSave[24] = 4.50796e-28;
1553  solidDisSave[25] = 0.000278934;
1554  solidDisSave[26] = 3.56933e-05;
1555  solidDisSave[27] = 4.50796e-28;
1556  solidDisSave[28] = 0.000278934;
1557  solidDisSave[29] = 3.56933e-05;
1558  solidDisSave[30] = 4.50796e-28;
1559  solidDisSave[31] = 0.0002767;
1560  solidDisSave[32] = 3.12723e-05;
1561  solidDisSave[33] = 8.55785e-28;
1562  solidDisSave[34] = 0.0002767;
1563  solidDisSave[35] = 3.12723e-05;
1564  solidDisSave[36] = 4.50796e-28;
1565  solidDisSave[37] = 0.000275146;
1566  solidDisSave[38] = 2.74114e-05;
1567  solidDisSave[39] = 4.50796e-28;
1568  solidDisSave[40] = 0.000275146;
1569  solidDisSave[41] = 2.74114e-05;
1570  solidDisSave[42] = 4.50796e-28;
1571  solidDisSave[43] = 0.000274116;
1572  solidDisSave[44] = 2.40609e-05;
1573  solidDisSave[45] = 4.50796e-28;
1574  solidDisSave[46] = 0.000274116;
1575  solidDisSave[47] = 2.40609e-05;
1576  solidDisSave[48] = 8.55785e-28;
1577  solidDisSave[49] = 0.000273477;
1578  solidDisSave[50] = 2.11655e-05;
1579  solidDisSave[51] = 4.50796e-28;
1580  solidDisSave[52] = 0.000273477;
1581  solidDisSave[53] = 2.11655e-05;
1582  solidDisSave[54] = 8.55785e-28;
1583  solidDisSave[55] = 0.000273123;
1584  solidDisSave[56] = 1.86691e-05;
1585  solidDisSave[57] = 4.50796e-28;
1586  solidDisSave[58] = 0.000273123;
1587  solidDisSave[59] = 1.86691e-05;
1588  solidDisSave[60] = 4.50796e-28;
1589  solidDisSave[61] = 0.00027297;
1590  solidDisSave[62] = 1.65176e-05;
1591  solidDisSave[63] = 4.50796e-28;
1592  solidDisSave[64] = 0.00027297;
1593  solidDisSave[65] = 1.65176e-05;
1594  solidDisSave[66] = 4.50796e-28;
1595  solidDisSave[67] = 0.000272951;
1596  solidDisSave[68] = 1.46611e-05;
1597  solidDisSave[69] = 4.50796e-28;
1598  solidDisSave[70] = 0.000272951;
1599  solidDisSave[71] = 1.46611e-05;
1600  solidDisSave[72] = 4.50796e-28;
1601  solidDisSave[73] = 0.000273019;
1602  solidDisSave[74] = 1.30543e-05;
1603  solidDisSave[75] = 4.50796e-28;
1604  solidDisSave[76] = 0.000273019;
1605  solidDisSave[77] = 1.30543e-05;
1606  solidDisSave[78] = 4.50796e-28;
1607  solidDisSave[79] = 0.000273137;
1608  solidDisSave[80] = 1.16571e-05;
1609  solidDisSave[81] = 4.50796e-28;
1610  solidDisSave[82] = 0.000273137;
1611  solidDisSave[83] = 1.16571e-05;
1612  solidDisSave[84] = 4.50796e-28;
1613  solidDisSave[85] = 0.000273281;
1614  solidDisSave[86] = 1.04348e-05;
1615  solidDisSave[87] = 8.55785e-28;
1616  solidDisSave[88] = 0.000273281;
1617  solidDisSave[89] = 1.04348e-05;
1618  solidDisSave[90] = 8.55785e-28;
1619  solidDisSave[91] = 0.000273436;
1620  solidDisSave[92] = 9.35745e-06;
1621  solidDisSave[93] = 8.55785e-28;
1622  solidDisSave[94] = 0.000273436;
1623  solidDisSave[95] = 9.35745e-06;
1624  solidDisSave[96] = 8.55785e-28;
1625  solidDisSave[97] = 0.000273593;
1626  solidDisSave[98] = 8.39999e-06;
1627  solidDisSave[99] = 4.50796e-28;
1628  solidDisSave[100] = 0.000273593;
1629  solidDisSave[101] = 8.39999e-06;
1630  solidDisSave[102] = 8.55785e-28;
1631  solidDisSave[103] = 0.000273749;
1632  solidDisSave[104] = 7.54154e-06;
1633  solidDisSave[105] = 8.55785e-28;
1634  solidDisSave[106] = 0.000273749;
1635  solidDisSave[107] = 7.54154e-06;
1636  solidDisSave[108] = 8.55785e-28;
1637  solidDisSave[109] = 0.000273907;
1638  solidDisSave[110] = 6.76512e-06;
1639  solidDisSave[111] = 8.55785e-28;
1640  solidDisSave[112] = 0.000273907;
1641  solidDisSave[113] = 6.76512e-06;
1642  solidDisSave[114] = 4.50796e-28;
1643  solidDisSave[115] = 0.000274069;
1644  solidDisSave[116] = 6.05734e-06;
1645  solidDisSave[117] = 4.50796e-28;
1646  solidDisSave[118] = 0.000274069;
1647  solidDisSave[119] = 6.05734e-06;
1648  solidDisSave[120] = 8.55785e-28;
1649  solidDisSave[121] = 0.000274242;
1650  solidDisSave[122] = 5.40816e-06;
1651  solidDisSave[123] = 4.50796e-28;
1652  solidDisSave[124] = 0.000274242;
1653  solidDisSave[125] = 5.40816e-06;
1654  solidDisSave[126] = 8.55785e-28;
1655  solidDisSave[127] = 0.000274433;
1656  solidDisSave[128] = 4.81074e-06;
1657  solidDisSave[129] = 4.50796e-28;
1658  solidDisSave[130] = 0.000274433;
1659  solidDisSave[131] = 4.81074e-06;
1660  solidDisSave[132] = 4.50796e-28;
1661  solidDisSave[133] = 0.000274649;
1662  solidDisSave[134] = 4.26143e-06;
1663  solidDisSave[135] = 8.55785e-28;
1664  solidDisSave[136] = 0.000274649;
1665  solidDisSave[137] = 4.26143e-06;
1666  solidDisSave[138] = 8.55785e-28;
1667  solidDisSave[139] = 0.000274897;
1668  solidDisSave[140] = 3.75988e-06;
1669  solidDisSave[141] = 8.55785e-28;
1670  solidDisSave[142] = 0.000274897;
1671  solidDisSave[143] = 3.75988e-06;
1672  solidDisSave[144] = 4.50796e-28;
1673  solidDisSave[145] = 0.000275182;
1674  solidDisSave[146] = 3.30926e-06;
1675  solidDisSave[147] = 4.50796e-28;
1676  solidDisSave[148] = 0.000275182;
1677  solidDisSave[149] = 3.30926e-06;
1678  solidDisSave[150] = 4.50796e-28;
1679  solidDisSave[151] = 0.000275506;
1680  solidDisSave[152] = 2.91661e-06;
1681  solidDisSave[153] = 4.50796e-28;
1682  solidDisSave[154] = 0.000275506;
1683  solidDisSave[155] = 2.91661e-06;
1684  solidDisSave[156] = 4.50796e-28;
1685  solidDisSave[157] = 0.000275867;
1686  solidDisSave[158] = 2.59325e-06;
1687  solidDisSave[159] = 4.50796e-28;
1688  solidDisSave[160] = 0.000275867;
1689  solidDisSave[161] = 2.59325e-06;
1690  solidDisSave[162] = 4.50796e-28;
1691  solidDisSave[163] = 0.000276258;
1692  solidDisSave[164] = 2.3553e-06;
1693  solidDisSave[165] = 8.55785e-28;
1694  solidDisSave[166] = 0.000276258;
1695  solidDisSave[167] = 2.3553e-06;
1696  solidDisSave[168] = 4.50796e-28;
1697  solidDisSave[169] = 0.000276662;
1698  solidDisSave[170] = 2.22417e-06;
1699  solidDisSave[171] = 4.50796e-28;
1700  solidDisSave[172] = 0.000276662;
1701  solidDisSave[173] = 2.22417e-06;
1702  solidDisSave[174] = 4.50796e-28;
1703  solidDisSave[175] = 0.000277053;
1704  solidDisSave[176] = 2.22707e-06;
1705  solidDisSave[177] = 8.55785e-28;
1706  solidDisSave[178] = 0.000277053;
1707  solidDisSave[179] = 2.22707e-06;
1708  solidDisSave[180] = 8.55785e-28;
1709  solidDisSave[181] = 0.000277391;
1710  solidDisSave[182] = 2.3973e-06;
1711  solidDisSave[183] = 4.50796e-28;
1712  solidDisSave[184] = 0.000277391;
1713  solidDisSave[185] = 2.3973e-06;
1714  solidDisSave[186] = 4.50796e-28;
1715  solidDisSave[187] = 0.000277621;
1716  solidDisSave[188] = 2.77441e-06;
1717  solidDisSave[189] = 4.50796e-28;
1718  solidDisSave[190] = 0.000277621;
1719  solidDisSave[191] = 2.77441e-06;
1720  solidDisSave[192] = 8.55785e-28;
1721  solidDisSave[193] = 0.000277665;
1722  solidDisSave[194] = 3.40386e-06;
1723  solidDisSave[195] = 4.50796e-28;
1724  solidDisSave[196] = 0.000277665;
1725  solidDisSave[197] = 3.40386e-06;
1726  solidDisSave[198] = 4.50796e-28;
1727  solidDisSave[199] = 0.000277422;
1728  solidDisSave[200] = 4.33615e-06;
1729  solidDisSave[201] = 4.50796e-28;
1730  solidDisSave[202] = 0.000277422;
1731  solidDisSave[203] = 4.33615e-06;
1732  solidDisSave[204] = 4.50796e-28;
1733  solidDisSave[205] = 0.000276762;
1734  solidDisSave[206] = 5.62512e-06;
1735  solidDisSave[207] = 4.50796e-28;
1736  solidDisSave[208] = 0.000276762;
1737  solidDisSave[209] = 5.62512e-06;
1738  solidDisSave[210] = 4.50796e-28;
1739  solidDisSave[211] = 0.000275523;
1740  solidDisSave[212] = 7.32512e-06;
1741  solidDisSave[213] = 4.50796e-28;
1742  solidDisSave[214] = 0.000275523;
1743  solidDisSave[215] = 7.32512e-06;
1744  solidDisSave[216] = 4.50796e-28;
1745  solidDisSave[217] = 0.000273506;
1746  solidDisSave[218] = 9.48674e-06;
1747  solidDisSave[219] = 4.50796e-28;
1748  solidDisSave[220] = 0.000273506;
1749  solidDisSave[221] = 9.48674e-06;
1750  solidDisSave[222] = 4.50796e-28;
1751  solidDisSave[223] = 0.000270473;
1752  solidDisSave[224] = 1.21506e-05;
1753  solidDisSave[225] = 4.50796e-28;
1754  solidDisSave[226] = 0.000270473;
1755  solidDisSave[227] = 1.21506e-05;
1756  solidDisSave[228] = 4.50796e-28;
1757  solidDisSave[229] = 0.000266148;
1758  solidDisSave[230] = 1.53391e-05;
1759  solidDisSave[231] = 4.50796e-28;
1760  solidDisSave[232] = 0.000266148;
1761  solidDisSave[233] = 1.53391e-05;
1762  solidDisSave[234] = 4.50796e-28;
1763  solidDisSave[235] = 0.000260217;
1764  solidDisSave[236] = 1.90445e-05;
1765  solidDisSave[237] = 8.55785e-28;
1766  solidDisSave[238] = 0.000260217;
1767  solidDisSave[239] = 1.90445e-05;
1768  solidDisSave[240] = 4.50796e-28;
1769  solidDisSave[241] = 0.000252337;
1770  solidDisSave[242] = 2.32151e-05;
1771  solidDisSave[243] = 8.55785e-28;
1772  solidDisSave[244] = 0.000252337;
1773  solidDisSave[245] = 2.32151e-05;
1774  solidDisSave[246] = 4.50796e-28;
1775  solidDisSave[247] = 0.000242147;
1776  solidDisSave[248] = 2.77362e-05;
1777  solidDisSave[249] = 8.55785e-28;
1778  solidDisSave[250] = 0.000242147;
1779  solidDisSave[251] = 2.77362e-05;
1780  solidDisSave[252] = 4.50796e-28;
1781  solidDisSave[253] = 0.00022929;
1782  solidDisSave[254] = 3.24075e-05;
1783  solidDisSave[255] = 8.55785e-28;
1784  solidDisSave[256] = 0.00022929;
1785  solidDisSave[257] = 3.24075e-05;
1786  solidDisSave[258] = 8.55785e-28;
1787  solidDisSave[259] = 0.000213439;
1788  solidDisSave[260] = 3.69166e-05;
1789  solidDisSave[261] = 4.50796e-28;
1790  solidDisSave[262] = 0.000213439;
1791  solidDisSave[263] = 3.69166e-05;
1792  solidDisSave[264] = 4.50796e-28;
1793  solidDisSave[265] = 0.000194344;
1794  solidDisSave[266] = 4.08076e-05;
1795  solidDisSave[267] = 4.50796e-28;
1796  solidDisSave[268] = 0.000194344;
1797  solidDisSave[269] = 4.08076e-05;
1798  solidDisSave[270] = 4.50796e-28;
1799  solidDisSave[271] = 0.000171881;
1800  solidDisSave[272] = 4.34459e-05;
1801  solidDisSave[273] = 4.50796e-28;
1802  solidDisSave[274] = 0.000171881;
1803  solidDisSave[275] = 4.34459e-05;
1804  solidDisSave[276] = 8.55785e-28;
1805  solidDisSave[277] = 0.000146113;
1806  solidDisSave[278] = 4.39784e-05;
1807  solidDisSave[279] = 4.50796e-28;
1808  solidDisSave[280] = 0.000146113;
1809  solidDisSave[281] = 4.39784e-05;
1810  solidDisSave[282] = 4.50796e-28;
1811  solidDisSave[283] = 0.000117336;
1812  solidDisSave[284] = 4.1277e-05;
1813  solidDisSave[285] = 8.55785e-28;
1814  solidDisSave[286] = 0.000117336;
1815  solidDisSave[287] = 4.1277e-05;
1816  solidDisSave[288] = 4.50796e-28;
1817  solidDisSave[289] = 8.60282e-05;
1818  solidDisSave[290] = 3.38566e-05;
1819  solidDisSave[291] = 4.50796e-28;
1820  solidDisSave[292] = 8.60282e-05;
1821  solidDisSave[293] = 3.38566e-05;
1822  solidDisSave[294] = 4.50796e-28;
1823  solidDisSave[295] = 5.2381e-05;
1824  solidDisSave[296] = 1.96674e-05;
1825  solidDisSave[297] = 4.50796e-28;
1826  solidDisSave[298] = 5.2381e-05;
1827  solidDisSave[299] = 1.96674e-05;
1828 
1829  //When comparing double, exact comparison might not do the job. Hence im giving 5% error margin.
1830  for(int i = 0; i < size; i++){
1831  if( !(double_equals(disp[i],solidDisSave[i]))){
1832  return false;
1833  }
1834  }
1835  return true;
1836  }
1837 
1843  virtual void Process(ResultsType &result){
1844  Prologue();
1845  Test__ExampleFunction(result);
1846  Test__TrapezoidQuadrature(result);
1847  Test__MidPointQuadrature(result);
1848  Test__ElmerModuleLoad(result);
1849  Test__OFModuleLoad(result);
1850  // WK: Start
1851  Test__ElmerHandlesCheck(result);
1852  Test__FsiCoupler(result);
1854  Test__FluidAgentRun(result);
1856  Test__SolidAgentRun(result);
1857  // WK: End
1858  // NS: Start
1859  Test__ElmerStructures(result);
1860  Test__OpenFoamFluids(result);
1861  // NS: End
1862  Epilogue();
1863  }
1864 
1871  virtual void RunTest(const std::string &name,ResultsType &result)
1872  {
1873  Prologue();
1874  if(name == "ExampleFunction")
1875  Test__ExampleFunction(result);
1876  else if(name == "TrapezoidQuadrature")
1877  Test__TrapezoidQuadrature(result);
1878  else if(name == "MidPointQuadrature")
1879  Test__MidPointQuadrature(result);
1880  else if(name == "ElmerModuleLoad")
1881  Test__ElmerModuleLoad(result);
1882  else if(name == "OpenFoamModuleLoad")
1883  Test__OFModuleLoad(result);
1884  else if(name == "ElmerHandlesCheck")
1885  Test__ElmerHandlesCheck(result);
1886  else if(name == "FsiCoupler")
1887  Test__FsiCoupler(result);
1888  else if(name == "TransferDisplacementsToFluid")
1890  else if(name == "FluidAgentRun")
1891  Test__FluidAgentRun(result);
1892  else if(name == "TransferLoadsToStructures")
1894  else if(name == "SolidAgentRun")
1895  Test__SolidAgentRun(result);
1896  else if(name == "ElmerStructures")
1897  Test__ElmerStructures(result);
1898  else if(name == "OpenFoamFluids")
1899  Test__OpenFoamFluids(result);
1900  Epilogue();
1901  }
1902 
1909  virtual void ProcessTests(std::list<std::string> &test_names,ResultsType &result){
1910  Prologue();
1911  std::list<std::string>::iterator tni = test_names.begin();
1912  while(tni != test_names.end())
1913  RunTest(*tni++,result);
1914  Epilogue();
1915  }
1916  };
1917 
1918 #ifdef _ELMERFOAMFSI_PARALLEL_
1919  template<typename CommType,typename ResultsType>
1930  class ParallelTestingObject : TestingObject<ResultsType>
1931  {
1932  typedef IRAD::Profiler::ProfilerObj ProfilerType;
1933  typedef std::string StackType;
1934  typedef IRAD::Global::ParallelGlobalObj<CommType,StackType,int,ProfilerType> TestPGlobalType;
1935  protected:
1941  CommType _communicator;
1942  bool isRank0;
1946  std::vector<int> N;
1948  std::string SourceDirPath;
1950  TestPGlobalType pGlobal;
1951  fsicouplingpar fsiCouplerPar;
1953  solidagentpar* testStructuresAgent;
1954  fluidagentpar* testFluidsAgent;
1956  int verblevel;
1957  std::vector<std::string> componentInterfaceNames;
1958  double simulationFinalTime;
1959  double simulationTimeStep;
1960  bool initIsPerformed;
1961 
1962  public:
1966  ParallelTestingObject(CommType &incomm) :
1967  TestingObject<ResultsType>(), _communicator(incomm), isRank0(false),
1968  fsiCouplerPar(pGlobal), testStructuresAgent(NULL), testFluidsAgent(NULL),
1969  initIsPerformed(false)
1970  {isRank0 = (_communicator.Rank()==0);};
1971  CommType &GetCommunicator() { return(_communicator); };
1972 
1976  virtual void Epilogue() {};
1977 
1985  virtual void Prologue(){
1986  for(int i = _communicator.Size();i <= 1000000;i*=2) N.push_back(i);
1987  };
1988 
1992  void SetSourceDirPath(std::string input){
1993  SourceDirPath = input;
1994  if (isRank0)
1995  std::cout << "Source Directory Path = " << SourceDirPath << std::endl;
1996  }
1997 
2014  virtual void Test__ParallelTrapezoidQuadrature(ResultsType &result) {
2015  std::ostringstream Ostr;
2016  int fixed_n = 1000000;
2017  int rank = _communicator.Rank();
2018  int nproc = _communicator.Size();
2019  double Ii = 0.0;
2020  bool runs = true;
2021  bool accurate = true;
2022  bool order2 = true;
2023  bool scales = true;
2024  std::vector<double> E;
2025  std::vector<double> times;
2026  for(int i = 1;i <= nproc;i*=nproc){
2027  CommType subcomm;
2028  int color = (rank < i);
2029  _communicator.Split(color,rank,subcomm);
2030  int nproc_color = subcomm.Size();
2031  double time0 = IRAD::Profiler::Time();
2032  if(color){
2033  Ii = 0.0;
2034  for(int j = 0;j < 200;j++){
2035  if(runs){
2036  try {
2038  } catch (...) {
2039  subcomm.SetExit(1);
2040  }
2041  if(subcomm.Check())
2042  runs = false;
2043  }
2044  }
2045  if(runs){
2046  double Itot = 0.0;
2047  subcomm.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2048  double error = 0.0;
2049  error = std::abs(Itot - (200*nproc_color));
2050  accurate = (error < 1e-14);
2051  order2 = accurate;
2052  }
2053  }
2054  times.push_back(IRAD::Profiler::Time() - time0);
2055  if(nproc == 1)
2056  break;
2057  }
2058  if(!rank){
2059  double dt = *times.rbegin() - *times.begin();
2060  double percent_change = dt/(*times.begin());
2061  scales = (percent_change < (nproc*.005));
2062  }
2063  result.UpdateResult("ParallelTrapezoidQuadrature:Runs",runs);
2064  result.UpdateResult("ParallelTrapezoidQuadrature:Accurate",accurate);
2065  if(nproc > 1) // only report scaling results when procs are more than 1.
2066  result.UpdateResult("ParallelTrapezoidQuadrature:WeakScaling",scales);
2067  times.resize(0);
2068  if(nproc > 1){ // If running on more than one proc, then do strong scaling test.
2069  for(int i = 1;i <= nproc;i*=nproc){
2070  CommType subcomm;
2071  int color = (rank < i);
2072  _communicator.Split(color,rank,subcomm);
2073  int nproc_color = subcomm.Size();
2074  double time0 = IRAD::Profiler::Time();
2075  if(color){
2076  int npart = *N.rbegin()/nproc_color;
2077  Ii = 0.0;
2078  for(int j = 0;j < 200;j++){
2079  if(runs){
2080  try {
2082  } catch (...) {
2083  subcomm.SetExit(1);
2084  }
2085  if(subcomm.Check())
2086  runs = false;
2087  }
2088  }
2089  if(runs){
2090  double Itot = 0.0;
2091  subcomm.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2092  double error = 0.0;
2093  error = std::abs(Itot - (200*nproc_color));
2094  accurate = (error < 1e-14);
2095  order2 = accurate;
2096  }
2097  }
2098  times.push_back(IRAD::Profiler::Time() - time0);
2099  }
2100  if(!rank){
2101  double n_t = (*times.begin())/(*times.rbegin());
2102  double n_p = n_t - nproc;
2103  n_p = std::abs(n_p)/nproc;
2104  scales = (n_p < 2e-1);
2105  }
2106  result.UpdateResult("ParallelTrapezoidQuadrateure:StrongScaling",scales);
2107  }
2108  for(int i = nproc;i <= 1000000;i*=10){
2109  if(runs){
2110  Ii = 0.0;
2111  int n = i/nproc;
2112  try {
2114  } catch (...) {
2115  _communicator.SetExit(1);
2116  }
2117  if(_communicator.Check())
2118  runs = false;
2119  if(runs){
2120  double Itot = 0.0;
2121  _communicator.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2122  double error = 0.0;
2123  error = std::abs(Itot - nproc);
2124  E.push_back(error);
2125  }
2126  }
2127  }
2128  int esize = E.size();
2129  for(int i = 0;i < esize-1;i++){
2130  double e = E[i+1]/E[i];
2131  double n1 = .1;
2132  double p = std::log(e)/std::log(n1);
2133  p -= 2;
2134  p = std::abs(p);
2135  if(p > 1e-1){
2136  order2 = false;
2137  }
2138  }
2139  result.UpdateResult("ParallelTrapezoidQuadrature:Order2",order2);
2140  }
2141 
2142 
2159  virtual void Test__ParallelMidPointQuadrature(ResultsType &result) {
2160  std::ostringstream Ostr;
2161  int fixed_n = 1000000;
2162  int rank = _communicator.Rank();
2163  int nproc = _communicator.Size();
2164  double Ii = 0.0;
2165  bool runs = true;
2166  bool accurate = true;
2167  bool order2 = true;
2168  bool scales = true;
2169  std::vector<double> E;
2170  std::vector<double> times;
2171  for(int i = 1;i <= nproc;i*=nproc){
2172  CommType subcomm;
2173  int color = (rank < i);
2174  _communicator.Split(color,rank,subcomm);
2175  int nproc_color = subcomm.Size();
2176  double time0 = IRAD::Profiler::Time();
2177  if(color){
2178  Ii = 0.0;
2179  for(int j = 0;j < 200;j++){
2180  if(runs){
2181  try {
2183  } catch (...) {
2184  subcomm.SetExit(1);
2185  }
2186  if(subcomm.Check())
2187  runs = false;
2188  }
2189  }
2190  if(runs){
2191  double Itot = 0.0;
2192  subcomm.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2193  double error = 0.0;
2194  error = std::abs(Itot - (200*nproc_color));
2195  accurate = (error < 1e-14);
2196  order2 = accurate;
2197  }
2198  }
2199  times.push_back(IRAD::Profiler::Time() - time0);
2200  if(nproc == 1)
2201  break;
2202  }
2203  if(!rank){
2204  double dt = *times.rbegin() - *times.begin();
2205  double percent_change = dt/(*times.begin());
2206  scales = (percent_change < (nproc*.005));
2207  // std::cout << "Weak scaling timings:" << std::endl;
2208  // std::vector<double>::iterator ti = weak_times.begin();
2209  // while(ti != weak_times.end()){
2210  // std::cout << ti-weak_times.begin()+1 << " "
2211  // << *ti << std::endl;
2212  // ti++;
2213  // }
2214  }
2215  result.UpdateResult("ParallelMidPointQuadrature:Runs",runs);
2216  result.UpdateResult("ParallelMidPointQuadrature:Accurate",accurate);
2217  if(nproc > 1) // only report scaling results for nproc > 1
2218  result.UpdateResult("ParallelMidPointQuadrature:WeakScaling",scales);
2219  times.resize(0);
2220  if(nproc > 1){ // only do scaling test if nproc > 1
2221  for(int i = 1;i <= nproc;i*=nproc){
2222  CommType subcomm;
2223  int color = (rank < i);
2224  _communicator.Split(color,rank,subcomm);
2225  int nproc_color = subcomm.Size();
2226  double time0 = IRAD::Profiler::Time();
2227  if(color){
2228  int npart = *N.rbegin()/nproc_color;
2229  Ii = 0.0;
2230  for(int j = 0;j < 200;j++){
2231  if(runs){
2232  try {
2234  } catch (...) {
2235  subcomm.SetExit(1);
2236  }
2237  if(subcomm.Check())
2238  runs = false;
2239  }
2240  }
2241  if(runs){
2242  double Itot = 0.0;
2243  subcomm.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2244  double error = 0.0;
2245  error = std::abs(Itot - (200*nproc_color));
2246  accurate = (error < 1e-14);
2247  order2 = accurate;
2248  }
2249  }
2250  times.push_back(IRAD::Profiler::Time() - time0);
2251  }
2252  if(!rank){
2253  double n_t = (*times.begin())/(*times.rbegin());
2254  double n_p = n_t - nproc;
2255  n_p = std::abs(n_p)/nproc;
2256  scales = (n_p < 2e-1);
2257  }
2258  result.UpdateResult("ParallelMidPointQuadrateure:StrongScaling",scales);
2259  }
2260  for(int i = nproc;i <= 1000000;i*=10){
2261  if(runs){
2262  Ii = 0.0;
2263  int n = i/nproc;
2264  try {
2266  } catch (...) {
2267  _communicator.SetExit(1);
2268  }
2269  if(_communicator.Check())
2270  runs = false;
2271  if(runs){
2272  double Itot = 0.0;
2273  _communicator.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2274  double error = 0.0;
2275  error = std::abs(Itot - nproc);
2276  E.push_back(error);
2277  }
2278  }
2279  }
2280  int esize = E.size();
2281  for(int i = 0;i < esize-1;i++){
2282  double e = E[i+1]/E[i];
2283  double n1 = .1;
2284  double p = std::log(e)/std::log(n1);
2285  p -= 2;
2286  p = std::abs(p);
2287  if(p > 1e-1){
2288  order2 = false;
2289  }
2290  }
2291  result.UpdateResult("ParallelMidPointQuadrature:Order2",order2);
2292  }
2293 
2299  virtual void Test__ParElmerModuleLoadUnload(ResultsType &result) {
2300  if (isRank0)
2301  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
2302 
2303  // load Elmer module
2304  std::cout << "Loading parallel Elmer Module" << std::endl;
2305  COM_LOAD_MODULE_STATIC_DYNAMIC(ElmerCSCParallel, "ElmerModule");
2306  bool works = false;
2307 
2308  // get window handle
2309  int h=COM_get_window_handle("ElmerModule");
2310  if(h <= 0){
2311  std::cout << " After loading, COM_get_window_handle(\"ElmerModule\") returns "
2312  << h << std::endl;
2313  std::cout << "ModuleLoadUnload Error: Could not get window handle."
2314  << std::endl;
2315  }
2316  else{
2317  works=true;
2318  std::cout << "Parallel Elmer Module Loaded" << std::endl;
2319  }
2320  result.UpdateResult("ParElmerModuleLoad:Works",works);
2321 
2322  // unload Elmer Module
2323  std::cout << "Unloading Parallel Elmer Module" << std::endl;
2324  COM_UNLOAD_MODULE_STATIC_DYNAMIC(ElmerCSCParallel, "ElmerModule");
2325  works=false;
2326 
2327  // make sure module unloaded
2328  h=COM_get_window_handle("ElmerModule");
2329  if(h > 0){
2330  std::cout << "After unloading, COM_get_window_handle(\"ElmerModule\") returns "
2331  << h << std::endl;
2332  std::cout << "ModuleLoadUnload Error: Did not properly unload module."
2333  << std::endl;
2334  }
2335  else{
2336  works=true;
2337  std::cout << "Parallel Elmer Module Unloaded" << std::endl;
2338  }
2339 
2340  result.UpdateResult("ParElmerModuleUnload:Works",works);
2341  _communicator.Barrier();
2342  return;
2343  }
2344 
2350  virtual void Test__ParOFModuleLoadUnload(ResultsType &result) {
2351  if (isRank0)
2352  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
2353 
2354  // load Elmer module
2355  std::cout << "Loading parallel OpenFoam Module" << std::endl;
2356  COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSIPar, "OFModule");
2357  bool works = false;
2358 
2359  // get window handle
2360  int h=COM_get_window_handle("OFModule");
2361  if(h <= 0){
2362  std::cout << " After loading, COM_get_window_handle(\"OFModule\") returns "
2363  << h << std::endl;
2364  std::cout << "ModuleLoadUnload Error: Could not get window handle."
2365  << std::endl;
2366  }
2367  else{
2368  works=true;
2369  std::cout << "Parallel OpenFoam Module Loaded" << std::endl;
2370  }
2371  result.UpdateResult("ParOFModuleLoad:Works",works);
2372 
2373  // unload Elmer Module
2374  std::cout << "Unloading Parallel OpenFoam Module" << std::endl;
2375  COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSIPar, "OFModule");
2376  works=false;
2377 
2378  // make sure module unloaded
2379  h=COM_get_window_handle("OFModule");
2380  if(h > 0){
2381  std::cout << "After unloading, COM_get_window_handle(\"OFModule\") returns "
2382  << h << std::endl;
2383  std::cout << "ModuleLoadUnload Error: Did not properly unload module."
2384  << std::endl;
2385  }
2386  else{
2387  works=true;
2388  std::cout << "Parallel OpenFoam Module Unloaded" << std::endl;
2389  }
2390  result.UpdateResult("ParOFModuleUnload:Works",works);
2391  _communicator.Barrier();
2392  return;
2393  }
2394 
2395 
2401  virtual void Test__ParElmerHandlesCheck(ResultsType & result){
2402  if (isRank0)
2403  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
2404 
2405  bool works, loadWorks, globWorks, initWorks, runWorks, finWorks, unloadWorks = false;
2406 
2407  std::cout << "Running Test__ParElmerHandlesCheck" << std::endl;
2408 
2409  //Loading Elmer Module
2410  std::cout << "Loading Parallel Elmer Module" << std::endl;
2411  COM_LOAD_MODULE_STATIC_DYNAMIC(ElmerCSCParallel,"ElmerModule");
2412 
2413  //Checking Elmer Module is indeed loaded.
2414  int ElmerHandle = COM_get_window_handle("ElmerModule");
2415  if(ElmerHandle <=0){
2416  std::cout << "After loading, COM_get_window_handle(\"ElmerModule\") returns "
2417  << ElmerHandle << std::endl;
2418  std::cout << "Error : Could not get window handle." << std::endl;
2419  }
2420  else{
2421  loadWorks = true;
2422  std::cout << "Parallel Elmer Module Loaded." << std::endl;
2423  }
2424 
2425  //Checking the registration of global data.
2426  int globHandle = COM_get_dataitem_handle("ElmerModule.global");
2427  if(globHandle <= 0){
2428  std::cout << "After loading, COM_get_dataitem_handle(\"ElmerModule.global\") returns "
2429  << globHandle << std::endl;
2430  std::cout << "Error : Could not get the data item handle." << std::endl;
2431  }
2432  else{
2433  globWorks = true;
2434  std::cout << "Global data handle accessed." << std::endl;
2435  }
2436 
2437  //Checking the ElmerModule function Initialize handle
2438  int initHandle = COM_get_function_handle("ElmerModule.Initialize");
2439  if(initHandle <= 0){
2440  std::cout << "After loading, COM_get_function_handle(\"ElmerModule.Initialize\") returns "
2441  << initHandle << std::endl;
2442  std::cout << "Error : Could not get the Initialize function handle." << std::endl;
2443  }
2444  else{
2445  initWorks = true;
2446  std::cout << "Initialize function handle accessed." << std::endl;
2447  }
2448 
2449  //Checking the ElmerModule function Run handle
2450  int runHandle = COM_get_function_handle("ElmerModule.Run");
2451  if(runHandle <= 0){
2452  std::cout << "After loading, COM_get_function_handle(\"ElmerModule.Run\") returns "
2453  << runHandle << std::endl;
2454  std::cout << "Error : Could not get the Run function handle." << std::endl;
2455  }
2456  else{
2457  runWorks = true;
2458  std::cout << "Run function handle accessed." << std::endl;
2459  }
2460 
2461  //Checking the ElmerModule function Finalize handle
2462  int finHandle = COM_get_function_handle("ElmerModule.Finalize");
2463  if(finHandle <= 0){
2464  std::cout << "After loading, COM_get_function_handle(\"ElmerModule.Finalize\") returns "
2465  << finHandle << std::endl;
2466  std::cout << "Error : Could not get the Finalize function handle." << std::endl;
2467  }
2468  else{
2469  finWorks = true;
2470  std::cout << "Finalize function handle accessed." << std::endl;
2471  }
2472 
2473  //Unloading Elmer Module
2474  std::cout << "Unloading Elmer Module" << std::endl;
2475  COM_UNLOAD_MODULE_STATIC_DYNAMIC(ElmerCSCParallel, "ElmerModule");
2476 
2477  //Checking Elmer Module is indeed unloaded.
2478  ElmerHandle = COM_get_window_handle("ElmerModule");
2479  if(ElmerHandle > 0){
2480  std::cout << "After unloading, COM_get_window_handle(\"ElmerModule\") returns "
2481  << ElmerHandle << std::endl;
2482  std::cout << "Error : Module was not properly unloaded." << std::endl;
2483  }
2484  else{
2485  unloadWorks = true;
2486  std::cout << "Parallel Elmer Module Unloaded." << std::endl;
2487  }
2488 
2489  if(loadWorks & globWorks & initWorks & runWorks & finWorks & unloadWorks) works = true;
2490  result.UpdateResult("ParElmerHandlesCheck:Works",works);
2491  _communicator.Barrier();
2492  return;
2493  }
2494 
2495 
2501  virtual void Test__ParOpenFoamHandlesCheck(ResultsType & result){
2502  if (isRank0)
2503  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
2504 
2505  bool works, loadWorks, globWorks, initWorks, runWorks, finWorks, unloadWorks = false;
2506 
2507  //Loading parallel OpenFoam Module
2508  std::cout << "Loading Parallel OpenFoam Module" << std::endl;
2509  COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSIPar,"OFModule");
2510 
2511  //Checking OF Module is indeed loaded.
2512  int OFHandle = COM_get_window_handle("OFModule");
2513  if(OFHandle <=0){
2514  std::cout << "After loading, COM_get_window_handle(\"OFModule\") returns "
2515  << OFHandle << std::endl;
2516  std::cout << "Error : Could not get window handle." << std::endl;
2517  }
2518  else{
2519  loadWorks = true;
2520  std::cout << "Parallel OpenFoam Module Loaded." << std::endl;
2521  }
2522 
2523  //Checking the registration of global data.
2524  int globHandle = COM_get_dataitem_handle("OFModule.global");
2525  if(globHandle <= 0){
2526  std::cout << "After loading, COM_get_dataitem_handle(\"OFModule.global\") returns "
2527  << globHandle << std::endl;
2528  std::cout << "Error : Could not get the data item handle." << std::endl;
2529  }
2530  else{
2531  globWorks = true;
2532  std::cout << "Global data handle accessed." << std::endl;
2533  }
2534 
2535  //Checking the function Initialize handle
2536  int initHandle = COM_get_function_handle("OFModule.InitFoam");
2537  if(initHandle <= 0){
2538  std::cout << "After loading, COM_get_function_handle(\"OFModule.InitFoam\") returns "
2539  << initHandle << std::endl;
2540  std::cout << "Error : Could not get the Initialize function handle." << std::endl;
2541  }
2542  else{
2543  initWorks = true;
2544  std::cout << "Initialize function handle accessed." << std::endl;
2545  }
2546 
2547  //Checking the function Run handle
2548  int runHandle = COM_get_function_handle("OFModule.RunFoam");
2549  if(runHandle <= 0){
2550  std::cout << "After loading, COM_get_function_handle(\"OFModule.RunFoam\") returns "
2551  << runHandle << std::endl;
2552  std::cout << "Error : Could not get the Run function handle." << std::endl;
2553  }
2554  else{
2555  runWorks = true;
2556  std::cout << "Run function handle accessed." << std::endl;
2557  }
2558 
2559  //Checking the function Finalize handle
2560  int finHandle = COM_get_function_handle("OFModule.StepFluid");
2561  if(finHandle <= 0){
2562  std::cout << "After loading, COM_get_function_handle(\"OFModule.StepFluid\") returns "
2563  << finHandle << std::endl;
2564  std::cout << "Error : Could not get the Finalize function handle." << std::endl;
2565  }
2566  else{
2567  finWorks = true;
2568  std::cout << "Finalize function handle accessed." << std::endl;
2569  }
2570 
2571  //Unloading Module
2572  std::cout << "Unloading OpenFoam Module" << std::endl;
2573  COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSIPar, "OFModule");
2574 
2575  //Checking Module is indeed unloaded.
2576  OFHandle = COM_get_window_handle("OFModule");
2577  if(OFHandle > 0){
2578  std::cout << "After unloading, COM_get_window_handle(\"OFModule\") returns "
2579  << OFHandle << std::endl;
2580  std::cout << "Error : Module was not properly unloaded." << std::endl;
2581  }
2582  else{
2583  unloadWorks = true;
2584  std::cout << "Parallel OpenFoam Module Unloaded." << std::endl;
2585  }
2586 
2587  if(loadWorks & globWorks & initWorks & runWorks & finWorks & unloadWorks) works = true;
2588  result.UpdateResult("ParOpenFoamHandlesCheck:Works",works);
2589  _communicator.Barrier();
2590  return;
2591  }
2592 
2593 
2601  virtual int GetInputData(std::string sourceDirName, std::string TestDir){
2602  std::cout << "Copying from " << sourceDirName
2603  << " to " << TestDir << std::endl;
2604  std::string OrgDir;
2605  //Save original working directory for later
2606  OrgDir = IRAD::Sys::CWD();
2607  //Check if data directory exists
2608  if(!IRAD::Sys::FILEEXISTS(sourceDirName)){
2609  std::cout << "GetInputData Error: Could not find data directory, "
2610  << sourceDirName << ". Exiting (fail)." << std::endl;
2611  return -1;
2612  }
2613  std::ifstream Inf;
2614  std::ofstream Ouf;
2615  std::string InFileName;
2616  std::string OutFileName;
2617  int IntDir;
2618  //Create TestDir directory in current directory (if it doesn't
2619  //already exist) to run our tests in.
2620  if(!IRAD::Sys::FILEEXISTS(TestDir)){
2621  IntDir = IRAD::Sys::CreateDirectory(TestDir);
2622  if(IntDir == -1){
2623  std::cout << "GetInputData Error: Could not make directory, "
2624  << TestDir << ". Exiting (fail)." << std::endl;
2625  return -1;
2626  }
2627  }
2628  //Open the input test data directory
2629  IRAD::Sys::Directory SourceDir(sourceDirName);
2630  //Change directories to TestDir directory for running
2631  IntDir = IRAD::Sys::ChDir(TestDir);
2632  if(IntDir == -1){
2633  std::cout << "GetInputData Error: Could not change directories to "
2634  << TestDir << ". Exiting (fail)." << std::endl;
2635  return -1;
2636  }
2637  //Copy input data to TestDir directory for running
2638  for(std::vector<std::string>::iterator it = SourceDir.begin();
2639  it != SourceDir.end(); ++it){
2640  InFileName = sourceDirName + "/" + *it;
2641  OutFileName = IRAD::Sys::CWD() + "/" + *it;
2642  //std::cout << "InFileName = " << InFileName
2643  // << ", OutFileName = " << OutFileName
2644  // << std::endl;
2645  // copy source to distnation recursively
2646  if(IRAD::Sys::ISLINK(InFileName))
2647  // preserve links, don't traverse
2648  int IntDir = IRAD::Sys::SymLink(InFileName, OutFileName);
2649  else if(IRAD::Sys::ISDIR(InFileName)) {
2650  // recursively copy directories
2651  int IntDir = GetInputData(InFileName, OutFileName);
2652  } else {
2653  // copy files, travserse into directories recursively
2654  Inf.open(InFileName.c_str());
2655  Ouf.open(OutFileName.c_str());
2656  Ouf << Inf.rdbuf();
2657  Ouf.close();
2658  Inf.close();
2659  }
2660 
2661  }
2662  //Change directories to back to original directory
2663  IntDir = IRAD::Sys::ChDir(OrgDir);
2664  if(IntDir == -1){
2665  std::cout << "GetInputData Error: Could not change directories to "
2666  << OrgDir << "\n Exiting (fail)." << std::endl;
2667  return -1;
2668  } else {
2669  //std::cout << "\n**BACK**\n";
2670  }
2671  return 0;
2672  }
2673 
2674 
2675  // Helper function
2676  virtual int __helper(){
2677 
2678  int IntDir;
2679  std::string OrgDir, TestDir;
2680 
2681  //call GetInputData to copy input test data to temp directory for running tests.
2682  std::string sourceDir = SourceDirPath + "/share/Testing/test_data/HronTurekFSI3_4";
2683 
2684  //Make path for directory to run the test in
2685  TestDir = IRAD::Sys::CWD() + "/HronTurekFSI3_4_UnitTest";
2686  std::cout << "Getting Input Data!!" << std::endl;
2687  IntDir = GetInputData(sourceDir, TestDir);
2688 
2689  //check if GetInputData exited correctly.
2690  if(IntDir != 0){
2691  std::cout << "GetInputData failed!"
2692  << std::endl;
2693  return 1;
2694  }
2695  // Check if TestDir directory exists in current Directory
2696  if(!IRAD::Sys::FILEEXISTS(TestDir)){
2697  std::cout << "Could not find directory, "
2698  << TestDir << ", for running tests." << std::endl;
2699  return 2;
2700  }
2701  return 0;
2702  }
2703 
2704 
2708  virtual void Test__ParFsiCouplerAgentsInitialize(){
2709  if (isRank0)
2710  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
2711 
2712  // prepare testing folder
2713  if (isRank0)
2714  {
2715  int work=__helper();
2716  if(work == 1){
2717  std::cout << "GetInputData failed 2!" << std::endl;
2718  return;
2719  }
2720  else if (work == 2) {
2721  std::cout << "Could not find directory for running tests" << std::endl;
2722  return;
2723  }
2724  }
2725  // waiting for copy to finish
2726  _communicator.Barrier();
2727 
2728  int IntDir;
2729  verblevel = 3;
2730  testStructuresAgent = new solidagentpar;
2731  testFluidsAgent = new fluidagentpar;
2732 
2733  std::string fluidDir;
2734  std::string simDir;
2735  fluidDir = IRAD::Sys::CWD() + "/HronTurekFSI3_4_UnitTest/fluid";
2736  simDir = IRAD::Sys::CWD() + "/HronTurekFSI3_4_UnitTest";
2737 
2738  if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simDir)))){
2739  std::cout << "Test folder does not exist!" << std::endl;
2740  return;
2741  }
2742  else{
2743  IntDir = IRAD::Sys::ChDir(simDir);
2744  if(IntDir == -1){
2745  std::cout << "GetInputData Error: Could not change directory to "
2746  << fluidDir << ". Exiting (fail). " << std::endl;
2747  return;
2748  }
2749  std::system("chmod 755 Allclean AllrunParDrvSetup makeLinks makeSerialLinks removeSerialLinks");
2750  if (isRank0) {
2751  std::system("./Allclean");
2752  std::system("./AllrunParDrvSetup");
2753  }
2754  _communicator.Barrier();
2755 
2756  IntDir = IRAD::Sys::ChDir(fluidDir);
2757  if(IntDir == -1){
2758  std::cout << "GetInputData Error: Could not change directory to "
2759  << fluidDir << ". Exiting (fail). " << std::endl;
2760  return;
2761  }
2762  }
2763 
2764  std::string fluidSolverName("OpenFoamFSIPar");
2765  std::string solidSolverName("ElmerCSCParallel");
2766  std::string transferServiceName("SurfX");
2767  std::string runMode("1");
2768 
2769  std::cout << "COM loading all modules" << std::endl;
2770  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
2771  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
2772  COM_load_module("SurfUtil","SurfUtil");
2773  COM_load_module("Simpal","Simpal");
2774  COM_load_module("SimOUT","Simout");
2775 
2776 
2777  componentInterfaceNames.push_back("FluidsComponentInterface");
2778  componentInterfaceNames.push_back("StructuresComponentInterface");
2779  componentInterfaceNames.push_back("TransferInterface");
2780  componentInterfaceNames.push_back("SurfUtil");
2781  componentInterfaceNames.push_back("Simpal");
2782  componentInterfaceNames.push_back("Simout");
2783 
2784  fsiCouplerPar.SetRunMode(runMode);
2785  fsiCouplerPar.SetVerbLevel(verblevel);
2786  std::cout << "fsiCouplerAgentsInitialize Successful!" << std::endl;
2787 
2788  // at this point initialization should be performed successfully
2789  initIsPerformed = true;
2790  _communicator.Barrier();
2791  return;
2792  }
2793 
2797  virtual int initializeSampleProblem()
2798  {
2799  simulationFinalTime = 5.0e-3;
2800  simulationTimeStep = 5.0e-4;
2801  if (!initIsPerformed) {
2802  // call the Agents Initialize function above
2803  // as well as the Initialize function of fsiCoupler
2804  std::cout << "Initalizing..." << std::endl;
2805  Test__ParFsiCouplerAgentsInitialize();
2806  fsiCouplerPar.Initialize(componentInterfaceNames, simulationFinalTime, simulationTimeStep);
2807  std::cout << "Initialize Completed!" << std::endl;
2808  }
2809 
2810  // making sure initialization is finished properly
2811  if (!initIsPerformed) {
2812  std::cout << "Problem initialization failed!" << std::endl;
2813  return(1);
2814  }
2815  return(0);
2816  }
2817 
2818 
2824  virtual void Test__ParFsiCoupler(ResultsType &result){
2825  if (isRank0)
2826  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
2827 
2828  bool works = false;
2829 
2830  // Initializing the sample FSI problem
2831  if (initializeSampleProblem()){
2832  // if initialization test failed this will fail as well
2833  result.UpdateResult("ParFsiCoupler:Works",false);
2834  return;
2835  }
2836  _communicator.Barrier();
2837 
2838  // test to make sure that classInterfaceNames are populated
2839  // correctly to match componentInterfaceNames
2840  bool interfaceNameCheck = true;
2841  std::vector<std::string> classInterfaceNames;
2842  classInterfaceNames = fsiCouplerPar.getVariable();
2843  for(int i = 0; i < componentInterfaceNames.size(); i++){
2844  if(componentInterfaceNames.at(i) != classInterfaceNames.at(i)){
2845  interfaceNameCheck = false;
2846  break;
2847  }
2848  }
2849 
2850  // test to make sure solver time-related parameters are correctly populated
2851  bool timeHackCheck= (fsiCouplerPar.getSimulationTime()==0) &&
2852  (fsiCouplerPar.getSimulationTimeStep()==simulationTimeStep) &&
2853  (fsiCouplerPar.getSimulationFinalTime()==simulationFinalTime);
2854 
2855  works = interfaceNameCheck && timeHackCheck;
2856  result.UpdateResult("ParFsiCoupler:Works",works);
2857  _communicator.Barrier();
2858  return;
2859  }
2860 
2868  virtual void Test__ParTransferDisplacementsToFluid(ResultsType &result){
2869  if (isRank0)
2870  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
2871 
2872  bool works = false;
2873 
2874  // Initializing the sample FSI problem
2875  if (initializeSampleProblem()){
2876  // if initialization test failed this will fail as well
2877  result.UpdateResult("ParTransferDisplacementsToFluid:Works",works);
2878  return;
2879  }
2880  _communicator.Barrier();
2881 
2882  double *fluidDisp = NULL;
2883  double *solidDisp = NULL;
2884  bool testRankFluid = (fsiCouplerPar.getFluidAgent()->Coordinates().size()!=0);
2885  bool testRankSolid = (fsiCouplerPar.getStructureAgent()->Coordinates().size()!=0);
2886  std::string fluidsDispName(fsiCouplerPar.getFluidIntName()+".solidDisplacement");
2887  std::string solidsDispName(fsiCouplerPar.getSolidIntName()+".Displacements");
2888  double totalFluidDisp, totalSolidDisp = 0;
2889 
2890  // setting solid displacements
2891  if (testRankSolid) {
2892  COM_get_array(solidsDispName.c_str(),(fsiCouplerPar.getStructureAgent())->PaneID(),&solidDisp);
2893  for(int i = 0; i<fsiCouplerPar.getStructureAgent()->Coordinates().size()/3; i++){
2894  solidDisp[3*i+1] = 1.0;
2895  totalSolidDisp += 1.0;
2896  //std::cout<< "Rank " << _communicator.Rank()
2897  // << " solidDisp["<< 3*i+1<< "] = " << solidDisp[3*i+1] << std::endl;
2898  }
2899  }
2900 
2901  // performing parallel interpolation
2902  fsiCouplerPar.TransferDisplacementsToFluid(fsiCouplerPar.getStructureAgent(),fsiCouplerPar.getFluidAgent());
2903  _communicator.Barrier();
2904 
2905  // suming fluids displacements
2906  if (testRankFluid) {
2907  COM_get_array(fluidsDispName.c_str(),(fsiCouplerPar.getFluidAgent())->PaneID(),&fluidDisp);
2908  // Calculate the total displacements for fluid
2909  for(int i=0; i < fsiCouplerPar.getFluidAgent()->Coordinates().size()/3; i++){
2910  totalFluidDisp += fluidDisp[3*i+1];
2911  }
2912  }
2913 
2914  // error calculations
2915  double ttFluidDisp, ttSolidDisp;
2916  _communicator.AllReduce(totalFluidDisp, ttFluidDisp, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2917  _communicator.AllReduce(totalSolidDisp, ttSolidDisp, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2918  double ttNNdeSolid, ttNNdeFluid;
2919  double totNNdeSolid = fsiCouplerPar.getStructureAgent()->Coordinates().size();
2920  double totNNdeFluid = fsiCouplerPar.getFluidAgent()->Coordinates().size();
2921  std::cout << "Rank " << _communicator.Rank()
2922  << " totNNdeFluid = " << totNNdeFluid
2923  << " totNNdeSolid = " << totNNdeSolid
2924  << std::endl;
2925  _communicator.Barrier();
2926  _communicator.AllReduce(totNNdeSolid, ttNNdeSolid, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2927  _communicator.AllReduce(totNNdeFluid, ttNNdeFluid, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2928  if (isRank0)
2929  std::cout << " (tot) is per process \n (tt) is grand total \n"
2930  << " ttFluidDisp = " << ttFluidDisp
2931  << " ttNNdeFluid = " << ttNNdeFluid
2932  << " ttSolidDisp = " << ttSolidDisp
2933  << " ttNNdeSolid = " << ttNNdeSolid
2934  << std::endl;
2935  _communicator.Barrier();
2936 
2937  double ttSolidDispFrac = ttSolidDisp/(ttNNdeSolid/3.0);
2938  double ttFluidDispFrac = ttFluidDisp/(ttNNdeFluid/3.0);
2939  double totalDispErr = (ttFluidDispFrac - ttSolidDispFrac) / ttSolidDispFrac;
2940 
2941  if (isRank0)
2942  std::cout << " Total Diplacement Interpolation Error (%) = "
2943  << totalDispErr*100 << std::endl;
2944  // If the error % is greater than 5%, let's call it a fail.
2945  if (totalDispErr <= .05)
2946  works = true;
2947 
2948  result.UpdateResult("ParTransferDisplacementsToFluid:Works",works);
2949  _communicator.Barrier();
2950  }
2951 
2952 
2960  virtual void Test__ParFluidAgentRun(ResultsType &result){
2961  if (isRank0)
2962  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
2963 
2964  bool works = false;
2965 
2966  // Initializing the sample FSI problem
2967  // if initialization test failed this will fail as well
2968  if (initializeSampleProblem()){
2969  result.UpdateResult("ParFluidAgentRun:Works",false);
2970  return;
2971  }
2972  _communicator.Barrier();
2973 
2974 
2975  bool testRankFluid = (fsiCouplerPar.getFluidAgent()->Coordinates().size()!=0);
2976  bool testRankSolid = (fsiCouplerPar.getStructureAgent()->Coordinates().size()!=0);
2977  std::string fluidsDispName(fsiCouplerPar.getFluidIntName()+".solidDisplacement");
2978  std::string solidsDispName(fsiCouplerPar.getSolidIntName()+".Displacements");
2979 
2980  // setting some dummy solid displacements
2981  double* fluidDisp = NULL;
2982  if (testRankFluid) {
2983  COM_get_array(fluidsDispName.c_str(),(fsiCouplerPar.getFluidAgent())->PaneID(),&fluidDisp);
2984  for(int i = 0; i<fsiCouplerPar.getFluidAgent()->Coordinates().size(); i++){
2985  fluidDisp[i] = 0.0;
2986  }
2987  }
2988 
2989  // Passing a dummy time step to the Run method as it
2990  // only uses the value set by the openFoam input file
2991  double simulTime = fsiCouplerPar.getSimulationTime();
2992  fsiCouplerPar.getFluidAgent()->InitializeTimeStep(simulTime);
2993  fsiCouplerPar.getFluidAgent()->Run(simulTime);
2994 
2995  int stride = 0;
2996  int cap = 0;
2997  double *tractions = NULL;
2998  std::vector<double> totTrac;
2999  totTrac.resize(3, 0.0);
3000  if (testRankFluid) {
3001  COM_get_array((fsiCouplerPar.getFluidIntName()+".traction").c_str(),
3002  (fsiCouplerPar.getFluidAgent())->PaneID(), &tractions, &stride, &cap);
3003  int isize = cap*stride;
3004  for(int i = 0; i < isize/3 ; i++){
3005  totTrac[0] += tractions[3*i];
3006  totTrac[1] += tractions[3*i+1];
3007  totTrac[2] += tractions[3*i+2];
3008  //std::cout << "tractions[" << i << "] = "
3009  // << tractions[3*i] << ", "
3010  // << tractions[3*i+1]
3011  // << ", " << tractions[3*i+2] << std::endl;
3012  }
3013  }
3014  std::cout << "Rank " << _communicator.Rank()
3015  << " totTrac[0] = " << totTrac[0]
3016  << " totTrac[1] = " << totTrac[1]
3017  << " totTrac[2] = " << totTrac[2]
3018  << std::endl;
3019 
3020  // reduce total traction to all ranks
3021  std::vector<double> ttTracTest;
3022  ttTracTest.resize(3, 0.0);
3023  _communicator.AllReduce(totTrac, ttTracTest, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
3024  _communicator.Barrier();
3025 
3026  // compare to reference
3027  std::vector<double> ttTracRef;
3028  ttTracRef.push_back(-1236.35211319659);
3029  ttTracRef.push_back(-7.86484455024674);
3030  ttTracRef.push_back(0.0);
3031  double ttTracErr = pow(ttTracTest[0] - ttTracRef[0], 2) +
3032  pow(ttTracTest[1] - ttTracRef[1], 2) +
3033  pow(ttTracTest[2] - ttTracRef[2], 2);
3034  ttTracErr = pow(ttTracErr, 0.5);
3035  if (isRank0)
3036  std::cout << "Total Traction Error = "
3037  << ttTracErr
3038  << std::endl;
3039  if (ttTracErr < 1.0e-10)
3040  works = true;
3041  _communicator.Barrier();
3042 
3043  result.UpdateResult("ParFluidAgentRun:Works",works);
3044  }
3045 
3046 
3054  virtual void Test__ParTransferLoadsToStructure(ResultsType &result){
3055  if (isRank0)
3056  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
3057 
3058  bool works = false;
3059 
3060  // Initializing the sample FSI problem
3061  if (initializeSampleProblem()){
3062  // if initialization test failed this will fail as well
3063  result.UpdateResult("ParTransferLoadsToStructure:Works",works);
3064  return;
3065  }
3066  _communicator.Barrier();
3067 
3068  double *fluidTrac = NULL;
3069  double *solidTrac = NULL;
3070  bool testRankFluid = (fsiCouplerPar.getFluidAgent()->Coordinates().size()!=0);
3071  bool testRankSolid = (fsiCouplerPar.getStructureAgent()->Coordinates().size()!=0);
3072  std::string fluidsTracName(fsiCouplerPar.getFluidIntName()+".traction");
3073  std::string solidsTracName(fsiCouplerPar.getSolidIntName()+".Loads");
3074  double totalFluidTrac = 0;
3075  double totalSolidTrac = 0;
3076 
3077  // setting tractions
3078  int stride, cap = 0;
3079  std::vector<double> nElm;
3080  nElm.resize(1);
3081  if (testRankFluid) {
3082  COM_get_array(fluidsTracName.c_str(),(fsiCouplerPar.getFluidAgent())->PaneID(),&fluidTrac, &stride, &cap);
3083  nElm[0] = cap;
3084  std::cout << " nElm = " << nElm[0]
3085  << " stride x cap = " << stride*nElm[0]
3086  << " size = " << fsiCouplerPar.getFluidAgent()->Coordinates().size()
3087  << std::endl;
3088  for(int i = 0; i<nElm[0]; i++){
3089  fluidTrac[3*i] = 0.0;
3090  fluidTrac[3*i+1] = 1.0;
3091  fluidTrac[3*i+2] = 0.0;
3092  totalFluidTrac += 1.0;
3093  //std::cout<< "Rank " << _communicator.Rank()
3094  // << " fluidTrac["<< 3*i+1<< "] = " << fluidTrac[3*i+1] << std::endl;
3095  }
3096  }
3097 
3098  // performing parallel least-square interpolation (transfer)
3099  fsiCouplerPar.TransferLoadsToStructures(fsiCouplerPar.getFluidAgent(),fsiCouplerPar.getStructureAgent());
3100  _communicator.Barrier();
3101 
3102  // summing up solid tractions
3103  if (testRankSolid) {
3104  COM_get_array(solidsTracName.c_str(),(fsiCouplerPar.getStructureAgent())->PaneID(),&solidTrac);
3105  // Calculate the total displacements for fluid
3106  for(int i=0; i < fsiCouplerPar.getStructureAgent()->Coordinates().size()/3; i++){
3107  totalSolidTrac += solidTrac[3*i+1];
3108  //std::cout<< "Rank " << _communicator.Rank()
3109  // << " solidTrac["<< 3*i+1<< "] = " << solidTrac[3*i+1] << std::endl;
3110  }
3111  }
3112 
3113  // error calculations
3114  double ttFluidTrac = 0 ;
3115  double ttSolidTrac = 0 ;
3116  std::cout << "Rank " << _communicator.Rank()
3117  << " totalFluidTrac = " << totalFluidTrac
3118  << std::endl;
3119  _communicator.AllReduce(totalFluidTrac, ttFluidTrac, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
3120  _communicator.AllReduce(totalSolidTrac, ttSolidTrac, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
3121  double ttNNdeSolid, ttNElmFluid;
3122  double totNNdeSolid = fsiCouplerPar.getStructureAgent()->Coordinates().size();
3123  std::cout << "Rank " << _communicator.Rank()
3124  << " totNElmFluid = " << nElm[0]
3125  << " totNNdeSolid = " << totNNdeSolid
3126  << std::endl;
3127  _communicator.Barrier();
3128  _communicator.AllReduce(totNNdeSolid, ttNNdeSolid, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
3129  _communicator.AllReduce(nElm[0], ttNElmFluid, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
3130  if (isRank0)
3131  std::cout << " (tot) is per process \n (tt) is grand total \n"
3132  << " ttFluidTrac = " << ttFluidTrac
3133  << " ttNElmFluid = " << ttNElmFluid
3134  << " ttSolidTrac = " << ttSolidTrac
3135  << " ttNNdeSolid = " << ttNNdeSolid
3136  << std::endl;
3137  _communicator.Barrier();
3138 
3139  double ttSolidTracFrac = ttSolidTrac/(ttNNdeSolid/3.0);
3140  double ttFluidTracFrac = ttFluidTrac/ttNElmFluid;
3141  double totalTracErr = (ttSolidTracFrac - ttFluidTracFrac) / ttFluidTracFrac;
3142 
3143  if (isRank0)
3144  std::cout << " Total Traction Least-square Interpolation Error (%) = "
3145  << totalTracErr*100 << std::endl;
3146  // If the error % is greater than 5%, let's call it a fail.
3147  if (totalTracErr <= .05)
3148  works = true;
3149 
3150  result.UpdateResult("ParTransferLoadsToStructure:Works",works);
3151  _communicator.Barrier();
3152  return;
3153  }
3154 
3155 
3163  virtual void Test__ParStructureAgentRun(ResultsType &result){
3164  if (isRank0)
3165  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
3166 
3167  bool works = false;
3168 
3169  // Initializing the sample FSI problem
3170  // if initialization test failed this will fail as well
3171  if (initializeSampleProblem()){
3172  result.UpdateResult("ParStructureAgentRun:Works",false);
3173  return;
3174  }
3175  _communicator.Barrier();
3176 
3177 
3178  bool testRankFluid = (fsiCouplerPar.getFluidAgent()->Coordinates().size()!=0);
3179  bool testRankSolid = (fsiCouplerPar.getStructureAgent()->Coordinates().size()!=0);
3180  std::string fluidsTracName(fsiCouplerPar.getFluidIntName()+".traction");
3181  std::string solidsTracName(fsiCouplerPar.getSolidIntName()+".Loads");
3182 
3183  // setting some dummy structure traction
3184  double* solidTrac = NULL;
3185  if (testRankSolid) {
3186  COM_get_array(solidsTracName.c_str(),(fsiCouplerPar.getStructureAgent())->PaneID(),&solidTrac);
3187  for(int i = 0; i<fsiCouplerPar.getStructureAgent()->Coordinates().size()/3; i++){
3188  solidTrac[3*i] = 0.0;
3189  solidTrac[3*i+1] = 1.0;
3190  solidTrac[3*i+2] = 0.0;
3191  }
3192  }
3193 
3194  // Passing a dummy time step to the Run method as it
3195  // only uses the value set by run method currently
3196  double simulTime = fsiCouplerPar.getSimulationTime();
3197  double simulTimeStep = fsiCouplerPar.getSimulationTimeStep();
3198  fsiCouplerPar.getStructureAgent()->InitializeTimeStep(simulTime);
3199  fsiCouplerPar.getStructureAgent()->Run(simulTime + simulTimeStep);
3200  _communicator.Barrier();
3201 
3202  int stride = 0;
3203  int cap = 0;
3204  double *disps = NULL;
3205  std::vector<double> totDisp;
3206  totDisp.resize(3, 0.0);
3207  if (testRankSolid) {
3208  COM_get_array((fsiCouplerPar.getSolidIntName()+".Displacements").c_str(),
3209  (fsiCouplerPar.getStructureAgent())->PaneID(), &disps, &stride, &cap);
3210  int isize = cap*stride;
3211  for(int i = 0; i < isize/3 ; i++){
3212  totDisp[0] += disps[3*i];
3213  totDisp[1] += disps[3*i+1];
3214  totDisp[2] += disps[3*i+2];
3215  //std::cout << "disps[" << i << "] = "
3216  // << disps[3*i] << ", "
3217  // << disps[3*i+1] << ", "
3218  // << disps[3*i+2] << std::endl;
3219  }
3220  }
3221  _communicator.Barrier();
3222  std::cout << "Rank " << _communicator.Rank()
3223  << " totDisp[0] = " << totDisp[0]
3224  << " totDisp[1] = " << totDisp[1]
3225  << " totDisp[2] = " << totDisp[2]
3226  << std::endl;
3227 
3228  // reduce total displacements to all ranks
3229  std::vector<double> ttDispTest;
3230  ttDispTest.resize(3, 0.0);
3231  _communicator.AllReduce(totDisp, ttDispTest, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
3232  _communicator.Barrier();
3233 
3234  // compare to reference
3235  std::vector<double> ttDispRef;
3236  ttDispRef.push_back(0.0);
3237  ttDispRef.push_back(4.49226422312958e-06);
3238  ttDispRef.push_back(0.0);
3239  double ttDispErr = pow(ttDispTest[0] - ttDispRef[0], 2) +
3240  pow(ttDispTest[1] - ttDispRef[1], 2) +
3241  pow(ttDispTest[2] - ttDispRef[2], 2);
3242  ttDispErr = pow(ttDispErr, 0.5);
3243  if (isRank0)
3244  std::cout << "Total Displacement Error = "
3245  << ttDispErr
3246  << std::endl;
3247  if (ttDispErr < 1.0e-10)
3248  works = true;
3249  _communicator.Barrier();
3250 
3251  result.UpdateResult("ParStructureAgentRun:Works",works);
3252  }
3253 
3254 
3262  virtual void Test__ParElmerStructure(ResultsType &result){
3263  if (isRank0)
3264  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
3265 
3266  bool works = false;
3267 
3268  // Initializing the sample FSI problem
3269  // if initialization test failed this will fail as well
3270  if (initializeSampleProblem()){
3271  result.UpdateResult("ParElmerStructure:Works",false);
3272  return;
3273  }
3274  _communicator.Barrier();
3275 
3276 
3277  bool testRankFluid = (fsiCouplerPar.getFluidAgent()->Coordinates().size()!=0);
3278  bool testRankSolid = (fsiCouplerPar.getStructureAgent()->Coordinates().size()!=0);
3279 
3280  std::vector<double> ndeCrds;
3281  std::vector<double> totCrds;
3282  totCrds.resize(3, 0.0);
3283  if (testRankSolid) {
3284  ndeCrds = (fsiCouplerPar.getStructureAgent())->Coordinates();
3285  int isize = ndeCrds.size();
3286  for(int i = 0; i < isize/3 ; i++){
3287  totCrds[0] += ndeCrds[3*i];
3288  totCrds[1] += ndeCrds[3*i+1];
3289  totCrds[2] += ndeCrds[3*i+2];
3290  //std::cout << "ndrCrds[" << i << "] = "
3291  // << ndeCrds[3*i] << ", "
3292  // << ndeCrds[3*i+1] << ", "
3293  // << ndeCrds[3*i+2] << std::endl;
3294  }
3295  }
3296  _communicator.Barrier();
3297  std::cout << "Rank " << _communicator.Rank()
3298  << " totCrds[0] = " << totCrds[0]
3299  << " totCrds[1] = " << totCrds[1]
3300  << " totCrds[2] = " << totCrds[2]
3301  << std::endl;
3302 
3303  // reduce total displacements to all ranks
3304  std::vector<double> ttCrdsTest;
3305  ttCrdsTest.resize(3, 0.0);
3306  _communicator.AllReduce(totCrds, ttCrdsTest, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
3307  _communicator.Barrier();
3308 
3309  //std::cout << "Rank " << _communicator.Rank()
3310  // << std::setprecision(15)
3311  // << " ttCrdsTest[0] = " << ttCrdsTest[0]
3312  // << " ttCrdsTest[1] = " << ttCrdsTest[1]
3313  // << " ttCrdsTest[2] = " << ttCrdsTest[2]
3314  // << std::endl;
3315 
3316  // compare to reference
3317  std::vector<double> ttCrdsRef;
3318  ttCrdsRef.push_back(272.088);
3319  ttCrdsRef.push_back(127.2);
3320  ttCrdsRef.push_back(0.0);
3321  double ttCrdsErr = pow(ttCrdsTest[0] - ttCrdsRef[0], 2) +
3322  pow(ttCrdsTest[1] - ttCrdsRef[1], 2) +
3323  pow(ttCrdsTest[2] - ttCrdsRef[2], 2);
3324  ttCrdsErr = pow(ttCrdsErr, 0.5);
3325  if (isRank0)
3326  std::cout << "Total Nodal Coordinate Error = "
3327  << ttCrdsErr
3328  << std::endl;
3329  if (ttCrdsErr < 1.0e-10)
3330  works = true;
3331  _communicator.Barrier();
3332 
3333  result.UpdateResult("ParElmerStructure:Works",works);
3334  }
3335 
3336 
3344  virtual void Test__ParOpenFoamFluid(ResultsType &result){
3345  if (isRank0)
3346  std::cout << "\n Running " << __func__ << "\n" <<std::endl;
3347 
3348  bool works = false;
3349 
3350  // Initializing the sample FSI problem
3351  // if initialization test failed this will fail as well
3352  if (initializeSampleProblem()){
3353  result.UpdateResult("ParOpenFoamFluid:Works",false);
3354  return;
3355  }
3356  _communicator.Barrier();
3357 
3358 
3359  bool testRankFluid = (fsiCouplerPar.getFluidAgent()->Coordinates().size()!=0);
3360  bool testRankSolid = (fsiCouplerPar.getStructureAgent()->Coordinates().size()!=0);
3361 
3362  std::vector<double> ndeCrds;
3363  std::vector<double> totCrds;
3364  totCrds.resize(3, 0.0);
3365  if (testRankFluid) {
3366  ndeCrds = (fsiCouplerPar.getFluidAgent())->Coordinates();
3367  int isize = ndeCrds.size();
3368  for(int i = 0; i < isize/3 ; i++){
3369  totCrds[0] += ndeCrds[3*i];
3370  totCrds[1] += ndeCrds[3*i+1];
3371  totCrds[2] += ndeCrds[3*i+2];
3372  //std::cout << "ndrCrds[" << i << "] = "
3373  // << ndeCrds[3*i] << ", "
3374  // << ndeCrds[3*i+1] << ", "
3375  // << ndeCrds[3*i+2] << std::endl;
3376  }
3377  }
3378  _communicator.Barrier();
3379  std::cout << "Rank " << _communicator.Rank()
3380  << " totCrds[0] = " << totCrds[0]
3381  << " totCrds[1] = " << totCrds[1]
3382  << " totCrds[2] = " << totCrds[2]
3383  << std::endl;
3384 
3385  // reduce total displacements to all ranks
3386  std::vector<double> ttCrdsTest;
3387  ttCrdsTest.resize(3, 0.0);
3388  _communicator.AllReduce(totCrds, ttCrdsTest, IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
3389  _communicator.Barrier();
3390 
3391  //std::cout << "Rank " << _communicator.Rank()
3392  // << std::setprecision(15)
3393  // << " ttCrdsTest[0] = " << ttCrdsTest[0]
3394  // << " ttCrdsTest[1] = " << ttCrdsTest[1]
3395  // << " ttCrdsTest[2] = " << ttCrdsTest[2]
3396  // << std::endl;
3397 
3398  // compare to reference
3399  std::vector<double> ttCrdsRef;
3400  ttCrdsRef.push_back(140.1298353186);
3401  ttCrdsRef.push_back(69.1999999999998);
3402  ttCrdsRef.push_back(0.0);
3403  double ttCrdsErr = pow(ttCrdsTest[0] - ttCrdsRef[0], 2) +
3404  pow(ttCrdsTest[1] - ttCrdsRef[1], 2) +
3405  pow(ttCrdsTest[2] - ttCrdsRef[2], 2);
3406  ttCrdsErr = pow(ttCrdsErr, 0.5);
3407  if (isRank0)
3408  std::cout << "Total Coordinate Error = "
3409  << ttCrdsErr
3410  << std::endl;
3411  if (ttCrdsErr < 1.0e-10)
3412  works = true;
3413  _communicator.Barrier();
3414 
3415  result.UpdateResult("ParOpenFoamFluid:Works",works);
3416  }
3417 
3418 
3424  virtual void Process(ResultsType &result){
3425  Prologue();
3426  Test__ParallelTrapezoidQuadrature(result);
3427  Test__ParallelMidPointQuadrature(result);
3428  Test__ParElmerModuleLoadUnload(result);
3429  Test__ParOFModuleLoadUnload(result);
3430  Test__ParElmerHandlesCheck(result);
3431  Test__ParOpenFoamHandlesCheck(result);
3432  Test__ParFsiCoupler(result);
3433  Test__ParElmerStructure(result);
3434  Test__ParOpenFoamFluid(result);
3435  Test__ParTransferDisplacementsToFluid(result);
3436  Test__ParFluidAgentRun(result);
3437  Test__ParTransferLoadsToStructure(result);
3438  Test__ParStructureAgentRun(result);
3439  Epilogue();
3440  }
3441 
3448  virtual void RunTest(const std::string &name,ResultsType &result)
3449  {
3450  if(name == "ParTrapezoidQuadrature")
3451  Test__ParallelTrapezoidQuadrature(result);
3452  if(name == "ParMidPointQuadrature")
3453  Test__ParallelMidPointQuadrature(result);
3454  if(name == "ParElmerModuleLodaUnload")
3455  Test__ParElmerModuleLoadUnload(result);
3456  if(name == "ParOFModuleLoadUnload")
3457  Test__ParOFModuleLoadUnload(result);
3458  if(name == "ParElmerHandlesCheck")
3459  Test__ParElmerHandlesCheck(result);
3460  if(name == "ParOpenFoamHandlesCheck")
3461  Test__ParOpenFoamHandlesCheck(result);
3462  if(name == "ParFsiCoupler")
3463  Test__ParFsiCoupler(result);
3464  if(name == "ParElmerStructure")
3465  Test__ParElmerStructure(result);
3466  if(name == "ParOpenFoamFluid")
3467  Test__ParOpenFoamFluid(result);
3468  if(name == "ParTransferDisplacementsToFluid")
3469  Test__ParTransferDisplacementsToFluid(result);
3470  if(name == "ParFluidAgentRun")
3471  Test__ParFluidAgentRun(result);
3472  if(name == "ParTransferLoadsToStructure")
3473  Test__ParTransferLoadsToStructure(result);
3474  if(name == "ParStructureAgentRun")
3475  Test__ParStructureAgentRun(result);
3476  }
3477 
3484  virtual void ProcessTests(std::list<std::string> &test_names,ResultsType &result){
3485  Prologue();
3486  std::list<std::string>::iterator tni = test_names.begin();
3487  while(tni != test_names.end())
3488  RunTest(*tni++,result);
3489  Epilogue();
3490  }
3491 
3492  };
3493 #endif
3494 };
3495 #endif
std::string getSolidIntName()
Definition: FsiCoupling.H:712
IRAD::Global::GlobalObj< StackType, int, ProfilerType > TestGlobalType
std::vector< double > avgCoord(int first, int second, int third, int fourth, fluidagent *fluidAgent)
virtual void Epilogue()
Tears down the testing fixtures if needed.
virtual void Test__TransferLoadsToStructures(ResultsType &result)
Test for TransferLoadsToStructures() function.
solidagent * getStructureAgent()
Definition: FsiCoupling.H:709
virtual std::vector< double > returnNodeCoords()
Definition: OpenFoamAgent.H:70
Example serial program.
double F1(double x)
Simple test function fixture returns .
std::string ExampleFunction(const std::string &instring)
Example function for ElmerFoamFSI (this is a brief description).
virtual void Test__MidPointQuadrature(ResultsType &result)
Test for ElmerFoamFSI::MidPointQuadrature.
virtual void Process(ResultsType &result)
Runs all tests implemented by the ElmerFoamFSI::TestingObject.
IRAD::Util::TestingObject< ResultsType > TestingObjectBaseType
double getSimulationTime()
Definition: FsiCoupling.H:704
std::vector< int > N
A set of values for testing quadrature methods.
double MidPointQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite midpoint rule.
virtual int Run(double endTime)
Definition: OpenFoamAgent.H:65
bool DisplacementCheck(double *disp, int size)
int TransferDisplacementsToFluid(solidagent *solidAgent, fluidagent *fluidAgent)
Definition: FsiCoupling.H:59
std::string ExampleTestFixture
A sample string test fixture.
Example serial program.
int verblevel
track verbosity level for tests
virtual void Test__FluidAgentRun(ResultsType &result)
Test for fluidAgent-&gt;Run() function.
Example program interface.
fsicoupling fsiCoupler
Instantiation of class for use with the fsiCoupler &amp; Agent tests.
virtual int GetInputData(std::string suffix, std::string TestDir)
virtual void RunTest(const std::string &name, ResultsType &result)
Runs a test specified by name.
double F2(double x)
Simple test function fixture returns .
virtual void Prologue()
Sets up the data fixtures for the tests.
virtual void Test__FsiCoupler(ResultsType &result)
Test the functionality of the fsiCoupler.
virtual std::vector< double > returnNodeCoords()
Definition: ElmerAgent.H:92
virtual int Initialize(const std::string &interfaceName, int verblevel=1)
Definition: ElmerAgent.H:10
bool double_equals(double a, double b, double epsilon=.001)
double F2(double x)
Simple test function fixture returns .
std::string StackType
Convenience type definition for program stack.
Definition: Driver.H:46
double F1(double x)
Simple test function fixture returns .
virtual void Test__ElmerHandlesCheck(ResultsType &result)
virtual void Test__SolidAgentRun(ResultsType &result)
Test for solidAgent-&gt;Run() function.
virtual void Test__ExampleFunction(ResultsType &result)
Test for ElmerFoamFSI::ExampleFunction.
openfoamagentpar fluidagentpar
IRAD::Profiler::ProfilerObj ProfilerType
virtual void Test__fsiCouplerAgentsInitialize()
Initalize function for the fsiCoupler and agents.
virtual void Test__OFModuleLoad(ResultsType &result)
virtual void Test__GetInput(ResultsType &result)
Example C++ header file for ElmerFoamFSI.
double TrapezoidQuadrature(double(*f)(double), double x0, double xn, int n)
Integrates f with composite trapezoid rule.
virtual void ProcessTests(std::list< std::string > &test_names, ResultsType &result)
Runs a list of tests specified by name.
void SetRunMode(const std::string &inMode)
Definition: FsiCoupling.H:376
elmeragentpar solidagentpar
fluidagent * getFluidAgent()
Definition: FsiCoupling.H:708
COM_EXTERN_MODULE(OpenFoamFSI)
virtual int InitializeTimeStep(double time)
Definition: Orchestrator.H:24
std::vector< std::string > getVariable()
Helper function that allows access to protected data members.
Definition: FsiCoupling.H:694
void SetSourceDirPath(std::string input)
Sets the string value of the testing source directory.
virtual void Test__OpenFoamFluids(ResultsType &result)
Run an initialization check to make sure the OpenFoamFluids are running as they should.
std::vector< std::string > componentInterfaceNames
virtual void Test__ElmerStructures(ResultsType &result)
Run an initialization check to make sure that the ElmerStructures are running as they should...
const std::vector< double > & Coordinates() const
Definition: ElmerAgent.H:79
IRAD::Profiler::ProfilerObj ProfilerType
Encapsulate example program-specific code constructs.
Definition: Driver.H:42
IRAD::Comm::CommunicatorObject CommType
Convenience typedef for CommunicatorObject.
virtual void Test__TrapezoidQuadrature(ResultsType &result)
Test for ElmerFoamFSI::TrapezoidQuadrature.
solidagent * TeststructuresAgent
For use with the ElmerStructure and OpenFoamFluids tests.
TestingObject()
Default constructor.
openfoamagent fluidagent
Definition: FsiCoupling.H:20
int TransferLoadsToStructures(fluidagent *fluidAgent, solidagent *solidAgent)
Definition: FsiCoupling.H:176
virtual int Run(double time)
Definition: ElmerAgent.H:71
bool tractionCheck(double *tractions, int isize)
const std::vector< double > & Coordinates() const
Definition: OpenFoamAgent.H:63
void SetVerbLevel(int verb)
Definition: FsiCoupling.H:56
virtual void Test__ElmerModuleLoad(ResultsType &result)
virtual void Test__TransferDisplacementsToFluid(ResultsType &result)
Test for fsiCoupling::TrasferDisplacementsToFluid function.
Project-specific testing object.
IRAD::Util::TestResults TestResults
Project-specific test results type.
int getRunMode()
Definition: FsiCoupling.H:706
double getSimulationFinalTime()
Definition: FsiCoupling.H:705
elmeragent solidagent
Definition: FsiCoupling.H:21
std::string getFluidIntName()
Definition: FsiCoupling.H:711
virtual int Initialize(std::vector< std::string > &componentInterfaceNames, double finalTime, double timeStep)
Definition: FsiCoupling.H:498
virtual int Initialize(const std::string interfaceName, int verblevel=1)
Definition: OpenFoamAgent.H:9