1 #ifndef __ELMERFOAMFSI_TEST_H__
13 #define __ELMERFOAMFSI_TEST_H__
14 #ifdef _ELMERFOAMFSI_PARALLEL_
32 namespace ElmerFoamFSI {
37 namespace TestFixture {
43 double F1(
double x) {
return (2.0*x); };
49 double F2(
double x) {
return (3.0*x*x); };
79 template<
typename ResultsType>
138 for(
int i = 10;i < 10000000;i*=10)
N.push_back(i);
143 args_dupe =
new char * [3];
144 args_dupe[0] =
const_cast<char *
>(
"test");
145 args_dupe[1] =
const_cast<char *
>(
"-com-mpi");
147 COM_init(&nargs_dupe,&args_dupe);
154 double F1(
double x) {
return (2.0*x); };
160 double F2(
double x) {
return (3.0*x*x); };
176 result.UpdateResult(
"ExampleFunction:Works",
178 result.UpdateResult(
"ExampleFunction:Fails",
196 std::ostringstream Ostr;
197 std::vector<double> E;
198 size_t n = 2*
N.size();
200 for(std::vector<int>::iterator i =
N.begin();i !=
N.end();i++){
207 E.push_back(std::fabs(Ii-1.0));
209 bool order2 = (E[0] < 1e-14);
210 for(std::vector<int>::iterator i =
N.begin();i !=
N.end();i++){
217 E.push_back(std::fabs(Ii-1.0));
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);
231 result.UpdateResult(
"TrapezoidQuadrature:Order2",order2);
248 std::ostringstream Ostr;
249 std::vector<double> Ibar;
250 std::vector<double> E;
251 size_t n = 2*
N.size();
254 for(std::vector<int>::iterator i =
N.begin();i !=
N.end();i++){
262 E.push_back(std::fabs(Ii-1.0));
264 order2 = (E[0] < 1e-14);
265 for(std::vector<int>::iterator i =
N.begin();i !=
N.end();i++){
273 E.push_back(std::fabs(Ii-1.0));
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);
287 result.UpdateResult(
"MidPointQuadrature:Order2",order2);
292 std::cout <<
"Running Test__ElmerModuleLoad" << std::endl;
295 std::cout <<
"Loading Elmer Module" << std::endl;
296 COM_LOAD_MODULE_STATIC_DYNAMIC(ElmerCSC,
"ElmerModule");
300 int h=COM_get_window_handle(
"ElmerModule");
302 std::cout <<
" After loading, COM_get_window_handle(\"ElmerModule\") returns "
304 std::cout <<
"ModuleLoadUnload Error: Could not get window handle."
309 std::cout <<
"Elmer Module Loaded" << std::endl;
311 result.UpdateResult(
"LoadElmerModule:Works",works);
314 std::cout <<
"Unloading Elmer Module" << std::endl;
315 COM_UNLOAD_MODULE_STATIC_DYNAMIC(ElmerCSC,
"ElmerModule");
319 h=COM_get_window_handle(
"ElmerModule");
321 std::cout <<
"After unloading, COM_get_window_handle(\"ElmerModule\") returns "
323 std::cout <<
"ModuleLoadUnload Error: Did not properly unload module."
328 std::cout <<
"Elmer Module Unloaded" << std::endl;
331 result.UpdateResult(
"UnloadElmerModule:Works",works);
338 std::cout <<
"Running Test__OFModuleLoad" << std::endl;
341 std::cout <<
"Loading OpenFoam Module" << std::endl;
342 COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI,
"OFModule");
346 int h=COM_get_window_handle(
"OFModule");
348 std::cout <<
" After loading, COM_get_window_handle(\"OFModule\") returns "
350 std::cout <<
"ModuleLoadUnload Error: Could not get window handle."
355 std::cout <<
"OpenFoam Module Loaded" << std::endl;
357 result.UpdateResult(
"LoadOpenFoamModule:Works",works);
360 std::cout <<
"Unloading OpenFoam Module" << std::endl;
361 COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSI,
"OFModule");
365 h=COM_get_window_handle(
"OFModule");
367 std::cout <<
"After unloading, COM_get_window_handle(\"OFModule\") returns "
369 std::cout <<
"ModuleLoadUnload Error: Did not properly unload module."
374 std::cout <<
"OpenFoam Module Unloaded" << std::endl;
377 result.UpdateResult(
"UnloadOpenFoamModule:Works",works);
384 bool works, loadWorks, globWorks, initWorks, runWorks, finWorks, unloadWorks =
false;
386 std::cout <<
"Running Test__ElmerHandlesCheck" << std::endl;
389 std::cout <<
"Loading Elmer Module" << std::endl;
390 COM_LOAD_MODULE_STATIC_DYNAMIC(ElmerCSC,
"ElmerModule");
393 int ElmerHandle = COM_get_window_handle(
"ElmerModule");
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;
401 std::cout <<
"Elmer Module Loaded." << std::endl;
405 int globHandle = COM_get_dataitem_handle(
"ElmerModule.global");
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;
413 std::cout <<
"Global data handle accessed." << std::endl;
417 int initHandle = COM_get_function_handle(
"ElmerModule.Initialize");
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;
425 std::cout <<
"Initialize function handle accessed." << std::endl;
429 int runHandle = COM_get_function_handle(
"ElmerModule.Run");
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;
437 std::cout <<
"Run function handle accessed." << std::endl;
441 int finHandle = COM_get_function_handle(
"ElmerModule.Finalize");
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;
449 std::cout <<
"Finalize function handle accessed." << std::endl;
453 std::cout <<
"Unloading Elmer Module" << std::endl;
454 COM_UNLOAD_MODULE_STATIC_DYNAMIC(ElmerCSC,
"ElmerModule");
457 ElmerHandle = COM_get_window_handle(
"ElmerModule");
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;
465 std::cout <<
"ElmerModule Unloaded." << std::endl;
468 if(loadWorks & globWorks & initWorks & runWorks & finWorks & unloadWorks) works =
true;
469 result.UpdateResult(
"ElmerHandlesCheck:Works",works);
487 OrgDir = IRAD::Sys::CWD();
493 if(!IRAD::Sys::FILEEXISTS(DirName)){
494 std::cout <<
"GetInputData Error: Could not find data directory, "
495 << DirName <<
". Exiting (fail)." << std::endl;
501 std::string InFileName;
502 std::string OutFileName;
507 if(!IRAD::Sys::FILEEXISTS(TestDir)){
508 IntDir = IRAD::Sys::CreateDirectory(TestDir);
510 std::cout <<
"GetInputData Error: Could not make directory, "
511 << TestDir <<
". Exiting (fail)." << std::endl;
517 IRAD::Sys::Directory SourceDir(DirName);
520 IntDir = IRAD::Sys::ChDir(TestDir);
522 std::cout <<
"GetInputData Error: Could not change directories to "
523 << TestDir <<
". Exiting (fail)." << std::endl;
528 for(std::vector<std::string>::iterator it = SourceDir.begin();
529 it != SourceDir.end(); ++it){
530 InFileName = DirName +
"/" + *it;
533 bool isDir = IRAD::Sys::ISDIR(InFileName.c_str());
535 std::string dirSuffix = suffix +
"/" + *it;
536 std::string dirTestDir = TestDir +
"/" + *it;
541 std::cout <<
"GetInput failed at the recursive level"
547 Inf.open(InFileName.c_str());
548 OutFileName = IRAD::Sys::CWD() +
"/" + *it;
549 Ouf.open(OutFileName.c_str());
556 IntDir = IRAD::Sys::ChDir(OrgDir);
558 std::cout <<
"GetInputData Error: Could not change directories to "
559 << OrgDir <<
". Exiting (fail)." << std::endl;
571 std::string OrgDir, TestDir;
574 std::string suffix =
"/testing/share/Testing/test_data/SimpleStatic";
577 TestDir = IRAD::Sys::CWD() +
"/SimpleStatic";
578 std::cout <<
"Getting Input Data!!" << std::endl;
583 std::cout <<
"GetInputData failed!"
588 if(!IRAD::Sys::FILEEXISTS(TestDir)){
589 std::cout <<
"Could not find directory, "
590 << TestDir <<
", for running tests." << std::endl;
602 if(out == 0) works =
true;
604 result.UpdateResult(
"GetInput:Works",works);
618 std::string fluidDir;
619 std::string simStaticDir;
620 fluidDir = IRAD::Sys::CWD() +
"/SimpleStatic/fluid";
621 simStaticDir = IRAD::Sys::CWD() +
"/SimpleStatic";
623 std::cout <<
"GetInputData failed 2!" << std::endl;
625 std::cout <<
"Could not find directory for running tests" << std::endl;
627 if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simStaticDir)))){
628 std::cout <<
"SimpleStatic / fluid Folders do not exists!" << std::endl;
632 IntDir = IRAD::Sys::ChDir(simStaticDir);
634 std::cout <<
"GetInputData Error: Could not change directory to "
635 << fluidDir <<
". Exiting (fail). " << std::endl;
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);
642 std::cout <<
"GetInputData Error: Could not change directory to "
643 << fluidDir <<
". Exiting (fail). " << std::endl;
647 std::string fluidSolverName(
"OpenFoamFSI");
648 std::string solidSolverName(
"ElmerCSC");
649 std::string transferServiceName(
"SurfX");
650 std::string runMode(
"1");
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");
666 std::cout <<
"fsiCouplerAgentsInitialize Successful!" << std::endl;
696 double time_final = 0.05;
697 double timestep = 2.0e-3;
702 std::cout <<
"Initalizing..." << std::endl;
705 std::cout <<
"Initialize Completed!" << std::endl;
709 std::vector<std::string> classInterfaceNames;
718 result.UpdateResult(
"fsiCoupler:Works",works);
729 std::cout <<
"Initalizing Structure..." << std::endl;
732 std::cout <<
"Initialization Completed!" << std::endl;
735 if (initresult != 0){
736 std::cout <<
"structuresAgent->Initialize returns error. " <<
737 "Refer to ElmerAgent.H for more information. " << std::endl;
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;
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};
754 for (
int i = 0; i < 306; i++){
755 if (arr[i] != nodecoordinates.at(i)){
756 std::cout <<
"Node Coordinate Inconsistencies." << std::endl;
761 result.UpdateResult(
"ElmerStructures:Works",works);
773 std::cout <<
"Initializing Fluids..." << std::endl;
776 std::cout <<
"Initialization Completed!" << std::endl;
779 if (initresult != 0){
780 std::cout <<
"fluidsAgent->Initialize returns error. " <<
781 "Refer to OpenFoamAgent.H for more information. " << std::endl;
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;
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};
798 for (
int i = 0; i < 306; i++){
799 if (arr[i] != nodecoordinates.at(i)){
800 std::cout <<
"Node Coordinate Inconsistencies." << std::endl;
805 result.UpdateResult(
"OpenFoamFluids:Works",works);
820 double time_final = 0.05;
821 double timestep = 2.0e-3;
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;
835 result.UpdateResult(
"fsiCoupler:Works",works);
839 IntDir = IRAD::Sys::ChDir(simStaticDir);
841 std::cout <<
"GetInputData Error: Could not change directory to "
842 << fluidDir <<
". Exiting (fail). " << std::endl;
844 result.UpdateResult(
"fsiCoupler:Works",works);
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);
851 std::cout <<
"GetInputData Error: Could not change directory to "
852 << fluidDir <<
". Exiting (fail). " << std::endl;
854 result.UpdateResult(
"fsiCoupler:Works",works);
860 std::string fluidSolverName(
"OpenFoamFSI");
861 std::string solidSolverName(
"ElmerCSC");
862 std::string transferServiceName(
"SurfX");
863 std::string runMode(
"1");
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");
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");
883 fsiCoupler.
Initialize(componentInterfaceNames, time_final, timestep);
887 int maxSubSteps = 1000;
888 int dumpinterval = 1;
891 double *fluidDisp1 = NULL;
892 double *fluidDisp2 = NULL;
893 double *solidDisp1 = NULL;
894 double *solidDisp2 = NULL;
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);
915 COM_get_array(fluidsCoordinateName.c_str(),(fsiCoupler.
getFluidAgent())->PaneID(),&fluidDisp2);
916 COM_get_array(solidsCoordinateName.c_str(),(fsiCoupler.
getStructureAgent())->PaneID(),&solidDisp2);
918 double totalFluidDis, totalSolidDis = 0;
921 totalFluidDis += fluidDisp2[3*i+1];
922 totalSolidDis += solidDisp2[3*i+1];
925 std::cout <<
"total fluid dis = " << totalFluidDis << std::endl;
926 std::cout <<
"total solid dis = " << totalSolidDis << std::endl;
929 double totalError = (totalFluidDis - totalSolidDis) / totalSolidDis;
931 std::cout <<
"total error = " << totalError << std::endl;
932 if(totalError >= .05) works =
false;
934 result.UpdateResult(
"TransferDisplacementsToFluid:Works",works);
940 double time_final = 0.05;
941 double timestep = 2.0e-3;
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;
955 result.UpdateResult(
"fsiCoupler:Works",works);
959 IntDir = IRAD::Sys::ChDir(simStaticDir);
961 std::cout <<
"GetInputData Error: Could not change directory to "
962 << fluidDir <<
". Exiting (fail). " << std::endl;
964 result.UpdateResult(
"fsiCoupler:Works",works);
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);
971 std::cout <<
"GetInputData Error: Could not change directory to "
972 << fluidDir <<
". Exiting (fail). " << std::endl;
974 result.UpdateResult(
"fsiCoupler:Works",works);
979 std::string fluidSolverName(
"OpenFoamFSI");
980 std::string solidSolverName(
"ElmerCSC");
981 std::string transferServiceName(
"SurfX");
982 std::string runMode(
"1");
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");
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");
999 fsiCoupler.
Initialize(componentInterfaceNames, time_final, timestep);
1003 int maxSubSteps = 1000;
1004 int dumpinterval = 1;
1007 double *fluidDisp1 = NULL;
1008 double *fluidDisp2 = NULL;
1009 double *solidDisp1 = NULL;
1010 double *solidDisp2 = NULL;
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);
1024 std::cout <<
"simultime is =" << simultime << std::endl;
1032 double *tractions = NULL;
1033 COM_get_array((fsiCoupler.
getFluidIntName()+
".traction").c_str(),101,&tractions,&stride,&cap);
1034 int isize = cap*stride;
1042 result.UpdateResult(
"FluidAgentRun:Works",works);
1045 double tractionSave[isize];
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;
1200 for(
int i = 0; i < isize; i++){
1209 return (std::abs(a-b) < epsilon);
1214 std::vector<double> Cord(3);
1228 double time_final = 0.05;
1229 double timestep = 2.0e-3;
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;
1243 result.UpdateResult(
"fsiCoupler:Works",works);
1247 IntDir = IRAD::Sys::ChDir(simStaticDir);
1249 std::cout <<
"GetInputData Error: Could not change directory to "
1250 << fluidDir <<
". Exiting (fail). " << std::endl;
1252 result.UpdateResult(
"fsiCoupler:Works",works);
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);
1259 std::cout <<
"GetInputData Error: Could not change directory to "
1260 << fluidDir <<
". Exiting (fail). " << std::endl;
1262 result.UpdateResult(
"fsiCoupler:Works",works);
1267 std::string fluidSolverName(
"OpenFoamFSI");
1268 std::string solidSolverName(
"ElmerCSC");
1269 std::string transferServiceName(
"SurfX");
1270 std::string runMode(
"1");
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");
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");
1286 fsiCoupler.
Initialize(componentInterfaceNames, time_final, timestep);
1290 int maxSubSteps = 1000;
1291 int dumpinterval = 1;
1301 std::cout <<
"simultime is =" << simultime << std::endl;
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;
1317 std::vector<double> cellCoordVec(connCap*3);
1318 std::vector<double> avgCoor(3);
1319 for(
int i =0; i < connCap; i++){
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;
1334 COM_get_array((fsiCoupler.
getFluidIntName()+
".traction").c_str(),101,&tractions,&stride,&cap);
1335 std::cout <<
"stride and cap = " << stride <<
"," << cap << std::endl;
1337 int isize = cap * stride ;
1338 for(
int i = 0; i < isize/3 ; i++){
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;
1346 double * solidLoads1 = NULL;
1347 int solidLoadStride1 = 0;
1348 int solidLoadCap1 =0;
1350 COM_get_array((fsiCoupler.
getSolidIntName()+
".Loads").c_str(),11,&solidLoads1,&solidLoadStride1,&solidLoadCap1);
1351 int solidLoadSize1 = solidLoadCap1*solidLoadStride1;
1356 double * solidLoads = NULL;
1357 int solidLoadStride = 0;
1358 int solidLoadCap =0;
1360 COM_get_array((fsiCoupler.
getSolidIntName()+
".Loads").c_str(),11,&solidLoads,&solidLoadStride,&solidLoadCap);
1361 int solidLoadSize = solidLoadCap*solidLoadStride;
1363 std::cout <<
"solidLoadCap = " << solidLoadCap <<
", solidLoadStride = " << solidLoadStride << std::endl;
1364 for(
int i = 0; i < solidLoadSize/3; i++){
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];
1375 std::cout <<
"total loads = " << totalLoad << std::endl;
1376 std::cout <<
"total tractions = " << totalTraction << std::endl;
1379 double totalError = (totalLoad - totalTraction) / totalTraction;
1381 std::cout <<
"total error = " << totalError << std::endl;
1382 if(totalError >= .05) works =
false;
1384 double maxError = 0;
1386 for(
int i = 0; i < isize/3 ; i++){
1387 for(
int j = 0; j <= 9; j = j + 3){
1390 errr = std::abs( ( solidLoads[7*i+1-i+j] - tractions[3*i+1]) / tractions[3*i+1] );
1391 if(errr >= maxError){
1393 std::cout <<
"maxError = " << maxError << std::endl;
1394 std::cout <<
"Happens at i,j = " << i <<
", " << j << std::endl;
1398 std::cout <<
"Max error = " << maxError << std::endl;
1399 result.UpdateResult(
"TransferLoadsToStructures:Works",works);
1407 double time_final = 0.05;
1408 double timestep = 2.0e-3;
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;
1422 result.UpdateResult(
"fsiCoupler:Works",works);
1426 IntDir = IRAD::Sys::ChDir(simStaticDir);
1428 std::cout <<
"GetInputData Error: Could not change directory to "
1429 << fluidDir <<
". Exiting (fail). " << std::endl;
1431 result.UpdateResult(
"fsiCoupler:Works",works);
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);
1438 std::cout <<
"GetInputData Error: Could not change directory to "
1439 << fluidDir <<
". Exiting (fail). " << std::endl;
1441 result.UpdateResult(
"fsiCoupler:Works",works);
1446 std::string fluidSolverName(
"OpenFoamFSI");
1447 std::string solidSolverName(
"ElmerCSC");
1448 std::string transferServiceName(
"SurfX");
1449 std::string runMode(
"1");
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");
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");
1465 fsiCoupler.
Initialize(componentInterfaceNames, time_final, timestep);
1469 int maxSubSteps = 1000;
1470 int dumpinterval = 1;
1480 std::cout <<
"simultime is =" << simultime << std::endl;
1491 COM_get_array((fsiCoupler.
getFluidIntName()+
".traction").c_str(),101,&tractions,&stride,&cap);
1492 std::cout <<
"stride and cap = " << stride <<
"," << cap << std::endl;
1494 int isize = cap * stride ;
1495 for(
int i = 0; i < isize/3 ; i++){
1499 tractions[3*i+1] = 50000;
1500 std::cout <<
"tractions[" << i <<
"] = " << tractions[3*i] <<
", " << tractions[3*i+1] <<
", " << tractions[3*i+2] << std::endl;
1513 double *solidDisp = NULL;
1516 std::string solidsCoordinateName(fsiCoupler.
getSolidIntName()+
".Displacements");
1517 COM_get_array(solidsCoordinateName.c_str(),(fsiCoupler.
getStructureAgent())->PaneID(),&solidDisp);
1521 result.UpdateResult(
"SolidAgentRun:Works",works);
1525 double solidDisSave[size];
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;
1830 for(
int i = 0; i < size; i++){
1871 virtual void RunTest(
const std::string &name,ResultsType &result)
1874 if(name ==
"ExampleFunction")
1876 else if(name ==
"TrapezoidQuadrature")
1878 else if(name ==
"MidPointQuadrature")
1880 else if(name ==
"ElmerModuleLoad")
1882 else if(name ==
"OpenFoamModuleLoad")
1884 else if(name ==
"ElmerHandlesCheck")
1886 else if(name ==
"FsiCoupler")
1888 else if(name ==
"TransferDisplacementsToFluid")
1890 else if(name ==
"FluidAgentRun")
1892 else if(name ==
"TransferLoadsToStructures")
1894 else if(name ==
"SolidAgentRun")
1896 else if(name ==
"ElmerStructures")
1898 else if(name ==
"OpenFoamFluids")
1909 virtual void ProcessTests(std::list<std::string> &test_names,ResultsType &result){
1911 std::list<std::string>::iterator tni = test_names.begin();
1912 while(tni != test_names.end())
1918 #ifdef _ELMERFOAMFSI_PARALLEL_
1919 template<
typename CommType,
typename ResultsType>
1930 class ParallelTestingObject : TestingObject<ResultsType>
1934 typedef IRAD::Global::ParallelGlobalObj<CommType,StackType,int,ProfilerType> TestPGlobalType;
1948 std::string SourceDirPath;
1950 TestPGlobalType pGlobal;
1957 std::vector<std::string> componentInterfaceNames;
1958 double simulationFinalTime;
1959 double simulationTimeStep;
1960 bool initIsPerformed;
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); };
1976 virtual void Epilogue() {};
1985 virtual void Prologue(){
1986 for(
int i = _communicator.Size();i <= 1000000;i*=2) N.push_back(i);
1992 void SetSourceDirPath(std::string input){
1993 SourceDirPath = input;
1995 std::cout <<
"Source Directory Path = " << SourceDirPath << std::endl;
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();
2021 bool accurate =
true;
2024 std::vector<double> E;
2025 std::vector<double> times;
2026 for(
int i = 1;i <= nproc;i*=nproc){
2028 int color = (rank < i);
2029 _communicator.Split(color,rank,subcomm);
2030 int nproc_color = subcomm.Size();
2031 double time0 = IRAD::Profiler::Time();
2034 for(
int j = 0;j < 200;j++){
2047 subcomm.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2049 error = std::abs(Itot - (200*nproc_color));
2050 accurate = (error < 1e-14);
2054 times.push_back(IRAD::Profiler::Time() - time0);
2059 double dt = *times.rbegin() - *times.begin();
2060 double percent_change = dt/(*times.begin());
2061 scales = (percent_change < (nproc*.005));
2063 result.UpdateResult(
"ParallelTrapezoidQuadrature:Runs",runs);
2064 result.UpdateResult(
"ParallelTrapezoidQuadrature:Accurate",accurate);
2066 result.UpdateResult(
"ParallelTrapezoidQuadrature:WeakScaling",scales);
2069 for(
int i = 1;i <= nproc;i*=nproc){
2071 int color = (rank < i);
2072 _communicator.Split(color,rank,subcomm);
2073 int nproc_color = subcomm.Size();
2074 double time0 = IRAD::Profiler::Time();
2076 int npart = *N.rbegin()/nproc_color;
2078 for(
int j = 0;j < 200;j++){
2091 subcomm.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2093 error = std::abs(Itot - (200*nproc_color));
2094 accurate = (error < 1e-14);
2098 times.push_back(IRAD::Profiler::Time() - time0);
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);
2106 result.UpdateResult(
"ParallelTrapezoidQuadrateure:StrongScaling",scales);
2108 for(
int i = nproc;i <= 1000000;i*=10){
2115 _communicator.SetExit(1);
2117 if(_communicator.Check())
2121 _communicator.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2123 error = std::abs(Itot - nproc);
2128 int esize = E.size();
2129 for(
int i = 0;i < esize-1;i++){
2130 double e = E[i+1]/E[i];
2132 double p = std::log(e)/std::log(n1);
2139 result.UpdateResult(
"ParallelTrapezoidQuadrature:Order2",order2);
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();
2166 bool accurate =
true;
2169 std::vector<double> E;
2170 std::vector<double> times;
2171 for(
int i = 1;i <= nproc;i*=nproc){
2173 int color = (rank < i);
2174 _communicator.Split(color,rank,subcomm);
2175 int nproc_color = subcomm.Size();
2176 double time0 = IRAD::Profiler::Time();
2179 for(
int j = 0;j < 200;j++){
2192 subcomm.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2194 error = std::abs(Itot - (200*nproc_color));
2195 accurate = (error < 1e-14);
2199 times.push_back(IRAD::Profiler::Time() - time0);
2204 double dt = *times.rbegin() - *times.begin();
2205 double percent_change = dt/(*times.begin());
2206 scales = (percent_change < (nproc*.005));
2215 result.UpdateResult(
"ParallelMidPointQuadrature:Runs",runs);
2216 result.UpdateResult(
"ParallelMidPointQuadrature:Accurate",accurate);
2218 result.UpdateResult(
"ParallelMidPointQuadrature:WeakScaling",scales);
2221 for(
int i = 1;i <= nproc;i*=nproc){
2223 int color = (rank < i);
2224 _communicator.Split(color,rank,subcomm);
2225 int nproc_color = subcomm.Size();
2226 double time0 = IRAD::Profiler::Time();
2228 int npart = *N.rbegin()/nproc_color;
2230 for(
int j = 0;j < 200;j++){
2243 subcomm.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2245 error = std::abs(Itot - (200*nproc_color));
2246 accurate = (error < 1e-14);
2250 times.push_back(IRAD::Profiler::Time() - time0);
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);
2258 result.UpdateResult(
"ParallelMidPointQuadrateure:StrongScaling",scales);
2260 for(
int i = nproc;i <= 1000000;i*=10){
2267 _communicator.SetExit(1);
2269 if(_communicator.Check())
2273 _communicator.AllReduce(Ii, Itot,IRAD::Comm::DTDOUBLE, IRAD::Comm::SUMOP);
2275 error = std::abs(Itot - nproc);
2280 int esize = E.size();
2281 for(
int i = 0;i < esize-1;i++){
2282 double e = E[i+1]/E[i];
2284 double p = std::log(e)/std::log(n1);
2291 result.UpdateResult(
"ParallelMidPointQuadrature:Order2",order2);
2299 virtual void Test__ParElmerModuleLoadUnload(ResultsType &result) {
2301 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
2304 std::cout <<
"Loading parallel Elmer Module" << std::endl;
2305 COM_LOAD_MODULE_STATIC_DYNAMIC(ElmerCSCParallel,
"ElmerModule");
2309 int h=COM_get_window_handle(
"ElmerModule");
2311 std::cout <<
" After loading, COM_get_window_handle(\"ElmerModule\") returns "
2313 std::cout <<
"ModuleLoadUnload Error: Could not get window handle."
2318 std::cout <<
"Parallel Elmer Module Loaded" << std::endl;
2320 result.UpdateResult(
"ParElmerModuleLoad:Works",works);
2323 std::cout <<
"Unloading Parallel Elmer Module" << std::endl;
2324 COM_UNLOAD_MODULE_STATIC_DYNAMIC(ElmerCSCParallel,
"ElmerModule");
2328 h=COM_get_window_handle(
"ElmerModule");
2330 std::cout <<
"After unloading, COM_get_window_handle(\"ElmerModule\") returns "
2332 std::cout <<
"ModuleLoadUnload Error: Did not properly unload module."
2337 std::cout <<
"Parallel Elmer Module Unloaded" << std::endl;
2340 result.UpdateResult(
"ParElmerModuleUnload:Works",works);
2341 _communicator.Barrier();
2350 virtual void Test__ParOFModuleLoadUnload(ResultsType &result) {
2352 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
2355 std::cout <<
"Loading parallel OpenFoam Module" << std::endl;
2356 COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSIPar,
"OFModule");
2360 int h=COM_get_window_handle(
"OFModule");
2362 std::cout <<
" After loading, COM_get_window_handle(\"OFModule\") returns "
2364 std::cout <<
"ModuleLoadUnload Error: Could not get window handle."
2369 std::cout <<
"Parallel OpenFoam Module Loaded" << std::endl;
2371 result.UpdateResult(
"ParOFModuleLoad:Works",works);
2374 std::cout <<
"Unloading Parallel OpenFoam Module" << std::endl;
2375 COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSIPar,
"OFModule");
2379 h=COM_get_window_handle(
"OFModule");
2381 std::cout <<
"After unloading, COM_get_window_handle(\"OFModule\") returns "
2383 std::cout <<
"ModuleLoadUnload Error: Did not properly unload module."
2388 std::cout <<
"Parallel OpenFoam Module Unloaded" << std::endl;
2390 result.UpdateResult(
"ParOFModuleUnload:Works",works);
2391 _communicator.Barrier();
2401 virtual void Test__ParElmerHandlesCheck(ResultsType & result){
2403 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
2405 bool works, loadWorks, globWorks, initWorks, runWorks, finWorks, unloadWorks =
false;
2407 std::cout <<
"Running Test__ParElmerHandlesCheck" << std::endl;
2410 std::cout <<
"Loading Parallel Elmer Module" << std::endl;
2411 COM_LOAD_MODULE_STATIC_DYNAMIC(ElmerCSCParallel,
"ElmerModule");
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;
2422 std::cout <<
"Parallel Elmer Module Loaded." << std::endl;
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;
2434 std::cout <<
"Global data handle accessed." << std::endl;
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;
2446 std::cout <<
"Initialize function handle accessed." << std::endl;
2450 int runHandle = COM_get_function_handle(
"ElmerModule.Run");
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;
2458 std::cout <<
"Run function handle accessed." << std::endl;
2462 int finHandle = COM_get_function_handle(
"ElmerModule.Finalize");
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;
2470 std::cout <<
"Finalize function handle accessed." << std::endl;
2474 std::cout <<
"Unloading Elmer Module" << std::endl;
2475 COM_UNLOAD_MODULE_STATIC_DYNAMIC(ElmerCSCParallel,
"ElmerModule");
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;
2486 std::cout <<
"Parallel Elmer Module Unloaded." << std::endl;
2489 if(loadWorks & globWorks & initWorks & runWorks & finWorks & unloadWorks) works =
true;
2490 result.UpdateResult(
"ParElmerHandlesCheck:Works",works);
2491 _communicator.Barrier();
2501 virtual void Test__ParOpenFoamHandlesCheck(ResultsType & result){
2503 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
2505 bool works, loadWorks, globWorks, initWorks, runWorks, finWorks, unloadWorks =
false;
2508 std::cout <<
"Loading Parallel OpenFoam Module" << std::endl;
2509 COM_LOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSIPar,
"OFModule");
2512 int OFHandle = COM_get_window_handle(
"OFModule");
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;
2520 std::cout <<
"Parallel OpenFoam Module Loaded." << std::endl;
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;
2532 std::cout <<
"Global data handle accessed." << std::endl;
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;
2544 std::cout <<
"Initialize function handle accessed." << std::endl;
2548 int runHandle = COM_get_function_handle(
"OFModule.RunFoam");
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;
2556 std::cout <<
"Run function handle accessed." << std::endl;
2560 int finHandle = COM_get_function_handle(
"OFModule.StepFluid");
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;
2568 std::cout <<
"Finalize function handle accessed." << std::endl;
2572 std::cout <<
"Unloading OpenFoam Module" << std::endl;
2573 COM_UNLOAD_MODULE_STATIC_DYNAMIC(OpenFoamFSIPar,
"OFModule");
2576 OFHandle = COM_get_window_handle(
"OFModule");
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;
2584 std::cout <<
"Parallel OpenFoam Module Unloaded." << std::endl;
2587 if(loadWorks & globWorks & initWorks & runWorks & finWorks & unloadWorks) works =
true;
2588 result.UpdateResult(
"ParOpenFoamHandlesCheck:Works",works);
2589 _communicator.Barrier();
2601 virtual int GetInputData(std::string sourceDirName, std::string TestDir){
2602 std::cout <<
"Copying from " << sourceDirName
2603 <<
" to " << TestDir << std::endl;
2606 OrgDir = IRAD::Sys::CWD();
2608 if(!IRAD::Sys::FILEEXISTS(sourceDirName)){
2609 std::cout <<
"GetInputData Error: Could not find data directory, "
2610 << sourceDirName <<
". Exiting (fail)." << std::endl;
2615 std::string InFileName;
2616 std::string OutFileName;
2620 if(!IRAD::Sys::FILEEXISTS(TestDir)){
2621 IntDir = IRAD::Sys::CreateDirectory(TestDir);
2623 std::cout <<
"GetInputData Error: Could not make directory, "
2624 << TestDir <<
". Exiting (fail)." << std::endl;
2629 IRAD::Sys::Directory SourceDir(sourceDirName);
2631 IntDir = IRAD::Sys::ChDir(TestDir);
2633 std::cout <<
"GetInputData Error: Could not change directories to "
2634 << TestDir <<
". Exiting (fail)." << std::endl;
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;
2646 if(IRAD::Sys::ISLINK(InFileName))
2648 int IntDir = IRAD::Sys::SymLink(InFileName, OutFileName);
2649 else if(IRAD::Sys::ISDIR(InFileName)) {
2651 int IntDir = GetInputData(InFileName, OutFileName);
2654 Inf.open(InFileName.c_str());
2655 Ouf.open(OutFileName.c_str());
2663 IntDir = IRAD::Sys::ChDir(OrgDir);
2665 std::cout <<
"GetInputData Error: Could not change directories to "
2666 << OrgDir <<
"\n Exiting (fail)." << std::endl;
2676 virtual int __helper(){
2679 std::string OrgDir, TestDir;
2682 std::string sourceDir = SourceDirPath +
"/share/Testing/test_data/HronTurekFSI3_4";
2685 TestDir = IRAD::Sys::CWD() +
"/HronTurekFSI3_4_UnitTest";
2686 std::cout <<
"Getting Input Data!!" << std::endl;
2687 IntDir = GetInputData(sourceDir, TestDir);
2691 std::cout <<
"GetInputData failed!"
2696 if(!IRAD::Sys::FILEEXISTS(TestDir)){
2697 std::cout <<
"Could not find directory, "
2698 << TestDir <<
", for running tests." << std::endl;
2708 virtual void Test__ParFsiCouplerAgentsInitialize(){
2710 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
2715 int work=__helper();
2717 std::cout <<
"GetInputData failed 2!" << std::endl;
2720 else if (work == 2) {
2721 std::cout <<
"Could not find directory for running tests" << std::endl;
2726 _communicator.Barrier();
2733 std::string fluidDir;
2735 fluidDir = IRAD::Sys::CWD() +
"/HronTurekFSI3_4_UnitTest/fluid";
2736 simDir = IRAD::Sys::CWD() +
"/HronTurekFSI3_4_UnitTest";
2738 if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simDir)))){
2739 std::cout <<
"Test folder does not exist!" << std::endl;
2743 IntDir = IRAD::Sys::ChDir(simDir);
2745 std::cout <<
"GetInputData Error: Could not change directory to "
2746 << fluidDir <<
". Exiting (fail). " << std::endl;
2749 std::system(
"chmod 755 Allclean AllrunParDrvSetup makeLinks makeSerialLinks removeSerialLinks");
2751 std::system(
"./Allclean");
2752 std::system(
"./AllrunParDrvSetup");
2754 _communicator.Barrier();
2756 IntDir = IRAD::Sys::ChDir(fluidDir);
2758 std::cout <<
"GetInputData Error: Could not change directory to "
2759 << fluidDir <<
". Exiting (fail). " << std::endl;
2764 std::string fluidSolverName(
"OpenFoamFSIPar");
2765 std::string solidSolverName(
"ElmerCSCParallel");
2766 std::string transferServiceName(
"SurfX");
2767 std::string runMode(
"1");
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");
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");
2784 fsiCouplerPar.SetRunMode(runMode);
2785 fsiCouplerPar.SetVerbLevel(verblevel);
2786 std::cout <<
"fsiCouplerAgentsInitialize Successful!" << std::endl;
2789 initIsPerformed =
true;
2790 _communicator.Barrier();
2797 virtual int initializeSampleProblem()
2799 simulationFinalTime = 5.0e-3;
2800 simulationTimeStep = 5.0e-4;
2801 if (!initIsPerformed) {
2804 std::cout <<
"Initalizing..." << std::endl;
2805 Test__ParFsiCouplerAgentsInitialize();
2806 fsiCouplerPar.Initialize(componentInterfaceNames, simulationFinalTime, simulationTimeStep);
2807 std::cout <<
"Initialize Completed!" << std::endl;
2811 if (!initIsPerformed) {
2812 std::cout <<
"Problem initialization failed!" << std::endl;
2824 virtual void Test__ParFsiCoupler(ResultsType &result){
2826 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
2831 if (initializeSampleProblem()){
2833 result.UpdateResult(
"ParFsiCoupler:Works",
false);
2836 _communicator.Barrier();
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;
2851 bool timeHackCheck= (fsiCouplerPar.getSimulationTime()==0) &&
2852 (fsiCouplerPar.getSimulationTimeStep()==simulationTimeStep) &&
2853 (fsiCouplerPar.getSimulationFinalTime()==simulationFinalTime);
2855 works = interfaceNameCheck && timeHackCheck;
2856 result.UpdateResult(
"ParFsiCoupler:Works",works);
2857 _communicator.Barrier();
2868 virtual void Test__ParTransferDisplacementsToFluid(ResultsType &result){
2870 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
2875 if (initializeSampleProblem()){
2877 result.UpdateResult(
"ParTransferDisplacementsToFluid:Works",works);
2880 _communicator.Barrier();
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;
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;
2902 fsiCouplerPar.TransferDisplacementsToFluid(fsiCouplerPar.getStructureAgent(),fsiCouplerPar.getFluidAgent());
2903 _communicator.Barrier();
2906 if (testRankFluid) {
2907 COM_get_array(fluidsDispName.c_str(),(fsiCouplerPar.getFluidAgent())->PaneID(),&fluidDisp);
2909 for(
int i=0; i < fsiCouplerPar.getFluidAgent()->Coordinates().size()/3; i++){
2910 totalFluidDisp += fluidDisp[3*i+1];
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
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);
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
2935 _communicator.Barrier();
2937 double ttSolidDispFrac = ttSolidDisp/(ttNNdeSolid/3.0);
2938 double ttFluidDispFrac = ttFluidDisp/(ttNNdeFluid/3.0);
2939 double totalDispErr = (ttFluidDispFrac - ttSolidDispFrac) / ttSolidDispFrac;
2942 std::cout <<
" Total Diplacement Interpolation Error (%) = "
2943 << totalDispErr*100 << std::endl;
2945 if (totalDispErr <= .05)
2948 result.UpdateResult(
"ParTransferDisplacementsToFluid:Works",works);
2949 _communicator.Barrier();
2960 virtual void Test__ParFluidAgentRun(ResultsType &result){
2962 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
2968 if (initializeSampleProblem()){
2969 result.UpdateResult(
"ParFluidAgentRun:Works",
false);
2972 _communicator.Barrier();
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");
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++){
2991 double simulTime = fsiCouplerPar.getSimulationTime();
2992 fsiCouplerPar.getFluidAgent()->InitializeTimeStep(simulTime);
2993 fsiCouplerPar.getFluidAgent()->Run(simulTime);
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];
3014 std::cout <<
"Rank " << _communicator.Rank()
3015 <<
" totTrac[0] = " << totTrac[0]
3016 <<
" totTrac[1] = " << totTrac[1]
3017 <<
" totTrac[2] = " << totTrac[2]
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();
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);
3036 std::cout <<
"Total Traction Error = "
3039 if (ttTracErr < 1.0e-10)
3041 _communicator.Barrier();
3043 result.UpdateResult(
"ParFluidAgentRun:Works",works);
3054 virtual void Test__ParTransferLoadsToStructure(ResultsType &result){
3056 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
3061 if (initializeSampleProblem()){
3063 result.UpdateResult(
"ParTransferLoadsToStructure:Works",works);
3066 _communicator.Barrier();
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;
3078 int stride, cap = 0;
3079 std::vector<double> nElm;
3081 if (testRankFluid) {
3082 COM_get_array(fluidsTracName.c_str(),(fsiCouplerPar.getFluidAgent())->PaneID(),&fluidTrac, &stride, &cap);
3084 std::cout <<
" nElm = " << nElm[0]
3085 <<
" stride x cap = " << stride*nElm[0]
3086 <<
" size = " << fsiCouplerPar.getFluidAgent()->Coordinates().size()
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;
3099 fsiCouplerPar.TransferLoadsToStructures(fsiCouplerPar.getFluidAgent(),fsiCouplerPar.getStructureAgent());
3100 _communicator.Barrier();
3103 if (testRankSolid) {
3104 COM_get_array(solidsTracName.c_str(),(fsiCouplerPar.getStructureAgent())->PaneID(),&solidTrac);
3106 for(
int i=0; i < fsiCouplerPar.getStructureAgent()->Coordinates().size()/3; i++){
3107 totalSolidTrac += solidTrac[3*i+1];
3114 double ttFluidTrac = 0 ;
3115 double ttSolidTrac = 0 ;
3116 std::cout <<
"Rank " << _communicator.Rank()
3117 <<
" totalFluidTrac = " << totalFluidTrac
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
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);
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
3137 _communicator.Barrier();
3139 double ttSolidTracFrac = ttSolidTrac/(ttNNdeSolid/3.0);
3140 double ttFluidTracFrac = ttFluidTrac/ttNElmFluid;
3141 double totalTracErr = (ttSolidTracFrac - ttFluidTracFrac) / ttFluidTracFrac;
3144 std::cout <<
" Total Traction Least-square Interpolation Error (%) = "
3145 << totalTracErr*100 << std::endl;
3147 if (totalTracErr <= .05)
3150 result.UpdateResult(
"ParTransferLoadsToStructure:Works",works);
3151 _communicator.Barrier();
3163 virtual void Test__ParStructureAgentRun(ResultsType &result){
3165 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
3171 if (initializeSampleProblem()){
3172 result.UpdateResult(
"ParStructureAgentRun:Works",
false);
3175 _communicator.Barrier();
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");
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;
3196 double simulTime = fsiCouplerPar.getSimulationTime();
3197 double simulTimeStep = fsiCouplerPar.getSimulationTimeStep();
3198 fsiCouplerPar.getStructureAgent()->InitializeTimeStep(simulTime);
3199 fsiCouplerPar.getStructureAgent()->Run(simulTime + simulTimeStep);
3200 _communicator.Barrier();
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];
3221 _communicator.Barrier();
3222 std::cout <<
"Rank " << _communicator.Rank()
3223 <<
" totDisp[0] = " << totDisp[0]
3224 <<
" totDisp[1] = " << totDisp[1]
3225 <<
" totDisp[2] = " << totDisp[2]
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();
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);
3244 std::cout <<
"Total Displacement Error = "
3247 if (ttDispErr < 1.0e-10)
3249 _communicator.Barrier();
3251 result.UpdateResult(
"ParStructureAgentRun:Works",works);
3262 virtual void Test__ParElmerStructure(ResultsType &result){
3264 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
3270 if (initializeSampleProblem()){
3271 result.UpdateResult(
"ParElmerStructure:Works",
false);
3274 _communicator.Barrier();
3277 bool testRankFluid = (fsiCouplerPar.getFluidAgent()->Coordinates().size()!=0);
3278 bool testRankSolid = (fsiCouplerPar.getStructureAgent()->Coordinates().size()!=0);
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];
3296 _communicator.Barrier();
3297 std::cout <<
"Rank " << _communicator.Rank()
3298 <<
" totCrds[0] = " << totCrds[0]
3299 <<
" totCrds[1] = " << totCrds[1]
3300 <<
" totCrds[2] = " << totCrds[2]
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();
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);
3326 std::cout <<
"Total Nodal Coordinate Error = "
3329 if (ttCrdsErr < 1.0e-10)
3331 _communicator.Barrier();
3333 result.UpdateResult(
"ParElmerStructure:Works",works);
3344 virtual void Test__ParOpenFoamFluid(ResultsType &result){
3346 std::cout <<
"\n Running " << __func__ <<
"\n" <<std::endl;
3352 if (initializeSampleProblem()){
3353 result.UpdateResult(
"ParOpenFoamFluid:Works",
false);
3356 _communicator.Barrier();
3359 bool testRankFluid = (fsiCouplerPar.getFluidAgent()->Coordinates().size()!=0);
3360 bool testRankSolid = (fsiCouplerPar.getStructureAgent()->Coordinates().size()!=0);
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];
3378 _communicator.Barrier();
3379 std::cout <<
"Rank " << _communicator.Rank()
3380 <<
" totCrds[0] = " << totCrds[0]
3381 <<
" totCrds[1] = " << totCrds[1]
3382 <<
" totCrds[2] = " << totCrds[2]
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();
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);
3408 std::cout <<
"Total Coordinate Error = "
3411 if (ttCrdsErr < 1.0e-10)
3413 _communicator.Barrier();
3415 result.UpdateResult(
"ParOpenFoamFluid:Works",works);
3424 virtual void Process(ResultsType &result){
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);
3448 virtual void RunTest(
const std::string &name,ResultsType &result)
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);
3484 virtual void ProcessTests(std::list<std::string> &test_names,ResultsType &result){
3486 std::list<std::string>::iterator tni = test_names.begin();
3487 while(tni != test_names.end())
3488 RunTest(*tni++,result);
std::string getSolidIntName()
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()
virtual std::vector< double > returnNodeCoords()
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()
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)
bool DisplacementCheck(double *disp, int size)
int TransferDisplacementsToFluid(solidagent *solidAgent, fluidagent *fluidAgent)
std::string ExampleTestFixture
A sample string test fixture.
int verblevel
track verbosity level for tests
virtual void Test__FluidAgentRun(ResultsType &result)
Test for fluidAgent->Run() function.
Example program interface.
fsicoupling fsiCoupler
Instantiation of class for use with the fsiCoupler & 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()
virtual int Initialize(const std::string &interfaceName, int verblevel=1)
std::string SourceDirPath
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.
double F1(double x)
Simple test function fixture returns .
virtual void Test__ElmerHandlesCheck(ResultsType &result)
virtual void Test__SolidAgentRun(ResultsType &result)
Test for solidAgent->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)
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)
elmeragentpar solidagentpar
fluidagent * getFluidAgent()
COM_EXTERN_MODULE(OpenFoamFSI)
virtual int InitializeTimeStep(double time)
std::vector< std::string > getVariable()
Helper function that allows access to protected data members.
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
IRAD::Profiler::ProfilerObj ProfilerType
Encapsulate example program-specific code constructs.
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.
int TransferLoadsToStructures(fluidagent *fluidAgent, solidagent *solidAgent)
virtual int Run(double time)
bool tractionCheck(double *tractions, int isize)
const std::vector< double > & Coordinates() const
void SetVerbLevel(int verb)
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.
double getSimulationFinalTime()
std::string getFluidIntName()
virtual int Initialize(std::vector< std::string > &componentInterfaceNames, double finalTime, double timeStep)
virtual int Initialize(const std::string interfaceName, int verblevel=1)
fluidagent * TestfluidsAgent