416 std::cout <<
"Running Test__ElmerUnitTests" << std::endl;
419 std::string OrgDir, TestDir;
420 bool ItAllWorks =
true;
423 double CoordCheck[15][3] =
424 { {2.2999999999999998, 0.19296300000000000, 0.0000000000000000},
425 {2.2999999999999998, 0.00000000000000000, 0.0000000000000000},
426 {2.2999999999999998, 0.39523399999999997, 0.0000000000000000},
427 {2.2999999999999998, 0.60476600000000003, 0.0000000000000000},
428 {2.2999999999999998, 0.80703700000000000, 0.0000000000000000},
429 {2.2999999999999998, 1.00000000000000000, 0.0000000000000000},
430 {2.3585799999999999, 1.14142000000000010, 0.0000000000000000},
431 {2.5000000000000000, 1.20000000000000000, 0.0000000000000000},
432 {2.6414200000000001, 1.14142000000000010, 0.0000000000000000},
433 {2.7000000000000002, 1.00000000000000000, 0.0000000000000000},
434 {2.7000000000000002, 0.80703700000000000, 0.0000000000000000},
435 {2.7000000000000002, 0.60476600000000003, 0.0000000000000000},
436 {2.7000000000000002, 0.39523399999999997, 0.0000000000000000},
437 {2.7000000000000002, 0.19296300000000000, 0.0000000000000000},
438 {2.7000000000000002, 0.00000000000000000, 0.0000000000000000} };
439 int ConnCheck[14][2] =
440 { {1,2}, {3,1}, {4,3}, {5,4}, {6,5}, {7,6}, {8,7}, {9,8}, {10,9},
441 {11,10}, {12,11}, {13,12}, {14,13}, {15,14} };
447 std::string suffix =
"/share/Testing/test_data/FSIobstacle";
450 TestDir = IRAD::Sys::CWD() +
"/UnitTestData";
455 std::cout <<
"ElmerUnitTests Error: GetInputData call failed."
457 result.UpdateResult(
"ElmerUnitTests:Run",
false);
462 if(!IRAD::Sys::FILEEXISTS(TestDir)){
463 std::cout <<
"ElmerUnitTests Error: Could not find directory, "
464 << TestDir <<
", for running tests." << std::endl;
465 result.UpdateResult(
"ElmerUnitTests:Run",
false);
470 OrgDir = IRAD::Sys::CWD();
473 IntDir = IRAD::Sys::ChDir(TestDir);
475 std::cout <<
"ElmerUnitTests Error: Could not change directories to "
476 << TestDir <<
"." << std::endl;
477 result.UpdateResult(
"ElmerUnitTests:Run",
false);
483 COM_LOAD_MODULE_STATIC_DYNAMIC( ElmerCSC,
"Window1");
485 bool load_unload =
true;
488 int h=COM_get_window_handle(
"Window1");
490 std::cout <<
" After loading, COM_get_window_handle(\"Window1\") returns "
493 std::cout <<
"ElmerUnitTests Error: Could not get window handle."
495 result.UpdateResult(
"LoadSolverModule:Works",
false);
496 result.UpdateResult(
"ElmerUnitTests:Run",
false);
500 result.UpdateResult(
"LoadSolverModule:Works",
true);
505 int init_handle = COM_get_function_handle(
"Window1.Initialize");
506 bool init_func = (init_handle > 0);
509 std::cout <<
"init = " << init_handle << std::endl;
512 COM_call_function(init_handle, &init_runs, &verb);
515 std::cout <<
"InitializeRuns Error: Could not get function handle."
517 result.UpdateResult(
"Initialize:Runs",
false);
523 result.UpdateResult(
"Initialize:Runs",
true);
526 result.UpdateResult(
"Initialize:Runs",
false);
533 int coord_handle = COM_get_dataitem_handle(
"Window1.nc");
535 bool coordData = (coord_handle > 0);
536 bool coordCorrect =
true;
537 std::cout <<
"coord_handle = " << coord_handle << std::endl;
539 COM_get_size(
"Window1.nc",11,&CoordSize);
541 std::cout <<
"ElmerUnitTests Error:"
542 <<
" Coord array is incorrect size!" << std::endl;
544 coordCorrect =
false;
550 COM_get_array(
"Window1.nc",11,&Coord);
551 std::cout <<
"Coord:" << std::endl;
552 for(
int i=0; i < CoordSize; i++){
553 for(
int j=0; j < 3; j++){
554 std::cout << Coord[i*3+j] <<
" ";
555 if(fabs(CoordCheck[i][j] - Coord[i*3+j]) > 1.0e-12){
557 coordCorrect =
false;
560 std::cout << std::endl;
563 result.UpdateResult(
"CoordinateData:Correct", coordCorrect);
564 result.UpdateResult(
"CoordinateData:Registered",
true);
567 result.UpdateResult(
"CoordinateData:Registered",
false);
568 result.UpdateResult(
"CoordinateData:Correct",
false);
575 bool connCorrect =
true;
580 COM_get_array(
"Window1.:b2:",11,&Conn);
583 COM_get_size(
"Window1.:b2:",11,&ConnSize);
585 std::cout <<
"ElmerUnitTests Error:"
586 <<
" Conn array is incorrect size!" << std::endl;
592 std::cout <<
"Conn:" << std::endl;
593 for(
int i=0; i < ConnSize; i++){
594 for(
int j=0; j < 2; j++){
595 std::cout << Conn[i*2+j] <<
" ";
596 if( (ConnCheck[i][j] - Conn[i*2+j]) != 0){
601 std::cout << std::endl;
604 result.UpdateResult(
"ConnectivityData:Correct", connCorrect);
605 result.UpdateResult(
"ConnectivityData:Registered",
true);
608 result.UpdateResult(
"ConnectivityData:Registered",
false);
609 result.UpdateResult(
"ConnectivityData:Correct",
false);
616 double* Loads = NULL;
618 bool loadsRegistered =
true, loadsInitialized =
true;
620 COM_get_array(
"Window1.Loads",11,&Loads);
622 std::cout <<
"Loads not NULL" << std::endl;
624 COM_get_size(
"Window1.Loads",11,&LoadsSize);
626 std::cout <<
"ElmerUnitTests Error:"
627 <<
" Loads array is incorrect size!" << std::endl;
629 loadsInitialized =
false;
633 for(
int i=0; i < LoadsSize; i++){
634 for(
int j=0; j < 3; j++){
635 if(fabs(Loads[i*3 + j]) > 1.0e-12){
636 loadsInitialized =
false;
644 std::cout <<
"Loads are NULL" << std::endl;
645 loadsRegistered =
false;
646 loadsInitialized =
false;
649 result.UpdateResult(
"LoadData:Registered", loadsRegistered);
650 result.UpdateResult(
"LoadData:Initialized", loadsInitialized);
657 double DispTime1[15][3] =
658 {{ 7.1605980866005031E-002, 3.5788052113870331E-002, 0.0000000000000000},
659 { -6.8871825230548747E-026, -6.7515261027908644E-026, 0.0000000000000000},
660 { 0.16559117138148402 , 6.1512134471618775E-002, 0.0000000000000000},
661 { 0.27105716643234351 , 7.0647177803958988E-002, 0.0000000000000000},
662 { 0.37408733220172607 , 6.6788253467455649E-002, 0.0000000000000000},
663 { 0.46975382688278072 , 5.5232228766620040E-002, 0.0000000000000000},
664 { 0.53059533135003267 , 1.7568173579321143E-002, 0.0000000000000000},
665 { 0.54088718131665003 , -5.0723278288525193E-002, 0.0000000000000000},
666 { 0.49733519851449115 , -0.10431856777439819 , 0.0000000000000000},
667 { 0.42342243323024942 , -0.11544236710979815 , 0.0000000000000000},
668 { 0.32858350010626158 , -9.6940873722311166E-002, 0.0000000000000000},
669 { 0.22913389910789400 , -7.6890455177259009E-002, 0.0000000000000000},
670 { 0.13256597264490513 , -5.4789959945688596E-002, 0.0000000000000000},
671 { 5.4547795662606154E-002, -2.9570884780950012E-002, 0.0000000000000000},
672 { -6.8871825230548747E-026, -6.7515261027908632E-026, 0.0000000000000000}};
673 double DispTime2[15][3] =
674 {{ 7.8382763777475994E-002, 3.7159701956680058E-002, 0.0000000000000000},
675 { -1.3908554346559520E-053, -1.3634598387444821E-053, 0.0000000000000000},
676 { 0.17746729339780631 , 6.3782065644847119E-002, 0.0000000000000000},
677 { 0.28589059231716707 , 7.3724507560836025E-002, 0.0000000000000000},
678 { 0.39007099539893136 , 7.0647599706400666E-002, 0.0000000000000000},
679 { 0.48577572075292708 , 5.9851545424915178E-002, 0.0000000000000000},
680 { 0.54619785916039254 , 2.2562624600359866E-002, 0.0000000000000000},
681 { 0.55515630051911513 , -4.5683794688744256E-002, 0.0000000000000000},
682 { 0.51164185034902454 , -9.8434990773815095E-002, 0.0000000000000000},
683 { 0.43876588136755668 , -0.10966508014917155 , 0.0000000000000000},
684 { 0.34337311330396592 , -9.2057033659364212E-002, 0.0000000000000000},
685 { 0.24185886373003795 , -7.3235312951635573E-002, 0.0000000000000000},
686 { 0.14168683127415216 , -5.2598213602584751E-002, 0.0000000000000000},
687 { 5.9082767678702033E-002, -2.8938645702423191E-002, 0.0000000000000000},
688 { -1.3908554346559520E-053, -1.3634598387444801E-053, 0.0000000000000000}};
690 int runs_handle = COM_get_function_handle(
"Window1.Run");
691 bool runs_func = (runs_handle > 0);
692 bool DispCorrect =
true;
695 double time2 = 100.0;
698 COM_get_array(
"Window1.Displacements",11,&Disp);
699 std::cout <<
"runs = " << runs_handle << std::endl;
703 std::cout <<
"Changing load values" << std::endl;
704 for(
int i=0; i < LoadsSize; i++){
705 for(
int j=0; j < 3; j++){
706 Loads[i*3 + j] = double(i*3 + j);
707 std::cout << Loads[i*3 + j] <<
" ";
709 std::cout << std::endl;
712 COM_call_function(runs_handle, &runs_runs, &time1);
715 std::cout <<
"TimeStepperRuns Error: Could not get function handle."
717 result.UpdateResult(
"TimeStepper:Runs",
false);
723 result.UpdateResult(
"TimeStepper:Runs",
true);
726 result.UpdateResult(
"TimeStepper:Runs",
false);
732 result.UpdateResult(
"DisplacementData:Registered",
true);
734 COM_get_size(
"Window1.Displacements",11,&DispSize);
736 std::cout <<
"ElmerUnitTests Error:"
737 <<
" Disp array is incorrect size!" << std::endl;
743 result.UpdateResult(
"DisplacementData:Registered",
false);
749 if (Disp && runs_handle && DispCorrect){
750 std::cout <<
"Checking Displacements Time 1 (" << time1 <<
")" << std::endl;
751 for(
int i=0; i < DispSize; i++){
752 for(
int j=0; j < 3; j++){
753 std::cout << Disp[i*3+j] <<
" ";
754 if(fabs(DispTime1[i][j] - Disp[i*3+j]) > 1.0e-12){
759 std::cout << std::endl;
763 std::cout <<
"Changing load values" << std::endl;
764 for(
int i=0; i < LoadsSize; i++){
765 for(
int j=0; j < 3; j++){
766 Loads[i*3 + j] = double(i*3 + j) + 1.0;
767 std::cout << Loads[i*3 + j] <<
" ";
769 std::cout << std::endl;
774 COM_call_function(runs_handle, &runs_runs2, &time2);
776 std::cout <<
"Checking Displacements Time 2 (" << time2 <<
")" << std::endl;
777 for(
int i=0; i < DispSize; i++){
778 for(
int j=0; j < 3; j++){
779 std::cout << Disp[i*3+j] <<
" ";
780 if(fabs(DispTime2[i][j] - Disp[i*3+j]) > 1.0e-12){
785 std::cout << std::endl;
788 if(runs_runs > 1 && runs_runs2 > 1){
789 result.UpdateResult(
"TimeLoads:Runs",
true);
792 std::cout <<
"runs_runs = " << runs_runs << std::endl;
793 std::cout <<
"runs_runs2 = " << runs_runs2 << std::endl;
794 result.UpdateResult(
"TimeLoads:Runs",
false);
798 result.UpdateResult(
"DisplacementData:Correct", DispCorrect);
804 int final_handle = COM_get_function_handle(
"Window1.Finalize");
805 bool final_func = (final_handle > 0);
807 std::cout <<
"final = " << final_handle << std::endl;
810 COM_call_function(final_handle, &final_runs);
813 std::cout <<
"FinalizeRuns Error: Could not get function handle."
815 result.UpdateResult(
"Finalize:Runs",
false);
821 result.UpdateResult(
"Finalize:Runs",
true);
824 result.UpdateResult(
"Finalize:Runs",
false);
831 COM_UNLOAD_MODULE_STATIC_DYNAMIC( ElmerCSC,
"Window1");
834 h=COM_get_window_handle(
"Window1");
836 std::cout <<
"After unloading, COM_get_window_handle(\"Window1\") returns "
839 std::cout <<
"ElmerUnitTests Error: Did not properly unload module."
841 result.UpdateResult(
"ElmerUnitTests:Run",
false);
842 result.UpdateResult(
"UnloadSolverModule:Works",
false);
846 result.UpdateResult(
"UnloadSolverModule:Works",
true);
849 IntDir = IRAD::Sys::ChDir(OrgDir);
851 std::cout <<
"ElmerUnitTests Error: Could not change directories to "
852 << OrgDir <<
"." << std::endl;
853 result.UpdateResult(
"ElmerUnitTests:Run",
false);
857 result.UpdateResult(
"ElmerUnitTests:Run", ItAllWorks);
virtual int GetInputData(std::string suffix, std::string TestDir)
Function to copy input data from source testing directory for use in unit tests.