ElmerFoamFSI  2.0
ElmerFoamFSI is fluid-solid interaction simulation application built up from OpenFOAM CFD and Elmer CSM coupled through the IMPACT multiphysics software integration infrastructure.
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Groups Pages
virtual void Test__TransferDisplacementsToFluid ( ResultsType &  result)
inlinevirtual

Test for fsiCoupling::TrasferDisplacementsToFluid function.

Parameters
resultElmerFoamFSI::TestResults object to store test results.

This function uses simple static problem data to test the transferagent->interpolate function. Displacement vector for solid agent is set to be the value of linear function along the z direction. After interpolation, displacement vector for fluid agent should have received these values (approximately).

Definition at line 818 of file ElmerFoamFSITest.H.

References TestingObject< ResultsType >::__helper(), TestingObject< ResultsType >::componentInterfaceNames, elmeragent::Coordinates(), TestingObject< ResultsType >::fsiCoupler, fsicoupling::getFluidAgent(), fsicoupling::getFluidIntName(), fsicoupling::getRunMode(), fsicoupling::getSolidIntName(), fsicoupling::getStructureAgent(), TestingObject< ResultsType >::global, fsicoupling::Initialize(), fsicoupling::SetRunMode(), fsicoupling::SetVerbLevel(), fsicoupling::TransferDisplacementsToFluid(), and TestingObject< ResultsType >::verblevel.

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

818  {
819 
820  double time_final = 0.05;
821  double timestep = 2.0e-3;
822  int verblevel = 3;
823  bool works = true;
824  int IntDir;
825 
826  // Copying the SimpleStatic data using getinputdata() helper function.
827  bool work =__helper();
828  std::string fluidDir;
829  std::string simStaticDir;
830  fluidDir = IRAD::Sys::CWD() + "/SimpleStatic/fluid";
831  simStaticDir = IRAD::Sys::CWD() + "/SimpleStatic";
832  if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simStaticDir)))){
833  std::cout << "SimpleStatic / fluid Folders do not exists!" << std::endl;
834  works = false;
835  result.UpdateResult("fsiCoupler:Works",works);
836  return;
837  }
838  else{
839  IntDir = IRAD::Sys::ChDir(simStaticDir);
840  if(IntDir == -1){
841  std::cout << "GetInputData Error: Could not change directory to "
842  << fluidDir << ". Exiting (fail). " << std::endl;
843  works = false;
844  result.UpdateResult("fsiCoupler:Works",works);
845  }
846  std::system("chmod 755 Allclean Allrun AllrunPar makeLinks makeSerialLinks removeSerialLinks");
847  std::system("./Allclean");
848  std::system("./Allrun");
849  IntDir = IRAD::Sys::ChDir(fluidDir);
850  if(IntDir == -1){
851  std::cout << "GetInputData Error: Could not change directory to "
852  << fluidDir << ". Exiting (fail). " << std::endl;
853  works = false;
854  result.UpdateResult("fsiCoupler:Works",works);
855  }
856  }
857 
858 
860  std::string fluidSolverName("OpenFoamFSI");
861  std::string solidSolverName("ElmerCSC");
862  std::string transferServiceName("SurfX");
863  std::string runMode("1");
864 
865 
866  std::cout << "COM loading all this junks" << std::endl;
867  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
868  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
869  COM_load_module("SurfUtil","SurfUtil");
870  COM_load_module("Simpal","Simpal");
871 
872 
873  std::vector<std::string> componentInterfaceNames;
874  componentInterfaceNames.push_back("FluidsComponentInterface");
875  componentInterfaceNames.push_back("StructuresComponentInterface");
876  componentInterfaceNames.push_back("TransferInterface");
877  componentInterfaceNames.push_back("SurfUtil");
878  componentInterfaceNames.push_back("Simpal");
879 
880  fsiCoupler.SetRunMode(runMode);
881  fsiCoupler.SetVerbLevel(verblevel);
882 
883  fsiCoupler.Initialize(componentInterfaceNames, time_final, timestep);
884 
885  // Mimicing FsiCoupler::run, intializing variables, etc.
886  int innerCount = 0;
887  int maxSubSteps = 1000;
888  int dumpinterval = 1;
889  int systemStep = 0;
890 
891  double *fluidDisp1 = NULL;
892  double *fluidDisp2 = NULL;
893  double *solidDisp1 = NULL;
894  double *solidDisp2 = NULL;
895 
896 
897  // Get the displacement vector values for both solid and fluid domain.
898  std::string fluidsCoordinateName(fsiCoupler.getFluidIntName()+".solidDisplacement");
899  std::string solidsCoordinateName(fsiCoupler.getSolidIntName()+".Displacements");
900  COM_get_array(fluidsCoordinateName.c_str(),(fsiCoupler.getFluidAgent())->PaneID(),&fluidDisp1);
901  COM_get_array(solidsCoordinateName.c_str(),(fsiCoupler.getStructureAgent())->PaneID(),&solidDisp1);
902 
903 
904  // Setting Y-component of the displacement vector to be the linear function displacement
905  // along z direction throughout nodes
906  for(int i = 0; i <fsiCoupler.getStructureAgent()->Coordinates().size()/3; i++){
907  solidDisp1[3*i+1] = fsiCoupler.getStructureAgent()->Coordinates()[3*i+2];
908  }
909 
910  if(!(fsiCoupler.getRunMode())){
912  }
913 
914  // After transferDisplacementToFluids, get displacement vectors for both agents to compare
915  COM_get_array(fluidsCoordinateName.c_str(),(fsiCoupler.getFluidAgent())->PaneID(),&fluidDisp2);
916  COM_get_array(solidsCoordinateName.c_str(),(fsiCoupler.getStructureAgent())->PaneID(),&solidDisp2);
917 
918  double totalFluidDis, totalSolidDis = 0;
919  // Calculate the total displacements for solid displacements and fluid displacements after transfer
920  for(int i=0; i < fsiCoupler.getStructureAgent()->Coordinates().size()/3; i++){
921  totalFluidDis += fluidDisp2[3*i+1];
922  totalSolidDis += solidDisp2[3*i+1];
923  }
924 
925  std::cout << "total fluid dis = " << totalFluidDis << std::endl;
926  std::cout << "total solid dis = " << totalSolidDis << std::endl;
927 
928  // Using Error % = (Experimented value - Theoretical value) / Theoretical value
929  double totalError = (totalFluidDis - totalSolidDis) / totalSolidDis;
930  // If the error % is greater than 5%, let's call it a fail.
931  std::cout << "total error = " << totalError << std::endl;
932  if(totalError >= .05) works = false;
933 
934  result.UpdateResult("TransferDisplacementsToFluid:Works",works);
935  }
std::string getSolidIntName()
Definition: FsiCoupling.H:712
solidagent * getStructureAgent()
Definition: FsiCoupling.H:709
int TransferDisplacementsToFluid(solidagent *solidAgent, fluidagent *fluidAgent)
Definition: FsiCoupling.H:59
int verblevel
track verbosity level for tests
fsicoupling fsiCoupler
Instantiation of class for use with the fsiCoupler &amp; Agent tests.
void SetRunMode(const std::string &inMode)
Definition: FsiCoupling.H:376
fluidagent * getFluidAgent()
Definition: FsiCoupling.H:708
std::vector< std::string > componentInterfaceNames
const std::vector< double > & Coordinates() const
Definition: ElmerAgent.H:79
void SetVerbLevel(int verb)
Definition: FsiCoupling.H:56
int getRunMode()
Definition: FsiCoupling.H:706
std::string getFluidIntName()
Definition: FsiCoupling.H:711
virtual int Initialize(std::vector< std::string > &componentInterfaceNames, double finalTime, double timeStep)
Definition: FsiCoupling.H:498

Here is the call graph for this function:

Here is the caller graph for this function: