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

Test for TransferLoadsToStructures() function.

Definition at line 1226 of file ElmerFoamFSITest.H.

References TestingObject< ResultsType >::__helper(), TestingObject< ResultsType >::avgCoord(), TestingObject< ResultsType >::componentInterfaceNames, elmeragent::Coordinates(), TestingObject< ResultsType >::fsiCoupler, fsicoupling::getFluidAgent(), fsicoupling::getFluidIntName(), fsicoupling::getRunMode(), fsicoupling::getSimulationFinalTime(), fsicoupling::getSimulationTime(), fsicoupling::getSolidIntName(), fsicoupling::getStructureAgent(), TestingObject< ResultsType >::global, fsicoupling::Initialize(), agentbase::InitializeTimeStep(), openfoamagent::Run(), fsicoupling::SetRunMode(), fsicoupling::SetVerbLevel(), fsicoupling::TransferDisplacementsToFluid(), fsicoupling::TransferLoadsToStructures(), and TestingObject< ResultsType >::verblevel.

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

1226  {
1227 
1228  double time_final = 0.05;
1229  double timestep = 2.0e-3;
1230  int verblevel = 3;
1231  bool works = true;
1232  int IntDir;
1233 
1234  // Copying the SimpleStatic data using getinputdata() helper function.
1235  bool work =__helper();
1236  std::string fluidDir;
1237  std::string simStaticDir;
1238  fluidDir = IRAD::Sys::CWD() + "/SimpleStatic/fluid";
1239  simStaticDir = IRAD::Sys::CWD() + "/SimpleStatic";
1240  if(!(IRAD::Sys::FILEEXISTS(fluidDir)||(IRAD::Sys::FILEEXISTS(simStaticDir)))){
1241  std::cout << "SimpleStatic / fluid Folders do not exists!" << std::endl;
1242  works = false;
1243  result.UpdateResult("fsiCoupler:Works",works);
1244  return;
1245  }
1246  else{
1247  IntDir = IRAD::Sys::ChDir(simStaticDir);
1248  if(IntDir == -1){
1249  std::cout << "GetInputData Error: Could not change directory to "
1250  << fluidDir << ". Exiting (fail). " << std::endl;
1251  works = false;
1252  result.UpdateResult("fsiCoupler:Works",works);
1253  }
1254  std::system("chmod 755 Allclean Allrun AllrunPar makeLinks makeSerialLinks removeSerialLinks");
1255  std::system("./Allclean");
1256  std::system("./Allrun");
1257  IntDir = IRAD::Sys::ChDir(fluidDir);
1258  if(IntDir == -1){
1259  std::cout << "GetInputData Error: Could not change directory to "
1260  << fluidDir << ". Exiting (fail). " << std::endl;
1261  works = false;
1262  result.UpdateResult("fsiCoupler:Works",works);
1263  }
1264  }
1265 
1267  std::string fluidSolverName("OpenFoamFSI");
1268  std::string solidSolverName("ElmerCSC");
1269  std::string transferServiceName("SurfX");
1270  std::string runMode("1");
1271 
1272  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
1273  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
1274  COM_load_module("SurfUtil","SurfUtil");
1275  COM_load_module("Simpal","Simpal");
1276 
1277  std::vector<std::string> componentInterfaceNames;
1278  componentInterfaceNames.push_back("FluidsComponentInterface");
1279  componentInterfaceNames.push_back("StructuresComponentInterface");
1280  componentInterfaceNames.push_back("TransferInterface");
1281  componentInterfaceNames.push_back("SurfUtil");
1282  componentInterfaceNames.push_back("Simpal");
1283 
1284  fsiCoupler.SetRunMode(runMode);
1285  fsiCoupler.SetVerbLevel(verblevel);
1286  fsiCoupler.Initialize(componentInterfaceNames, time_final, timestep);
1287 
1288  // Mimicing FsiCoupler::run, intializing variables, etc.
1289  int innerCount = 0;
1290  int maxSubSteps = 1000;
1291  int dumpinterval = 1;
1292  int systemStep = 0;
1293 
1294 
1295  if(!(fsiCoupler.getRunMode())){
1297  }
1298  double simultime = fsiCoupler.getSimulationTime();
1299 
1300 
1301  std::cout << "simultime is =" << simultime << std::endl;
1302  if(fsiCoupler.getRunMode() < 2){
1305  }
1306 
1307  int * conn= NULL;
1308  int connStride, connCap=0;
1309  COM_get_array( (fsiCoupler.getFluidIntName()+".:q4:").c_str(),101, &conn,&connStride,&connCap);
1310  std::cout << "connStride , connCap = " << connStride << ", " << connCap << std::endl;
1311  for (int i =0; i < connCap; i++){
1312  std::cout << "Conn Coordinates[" << i << "] = " << conn[4*i] << ", " << conn[4*i+1] << ", " << conn[4*i+2] << ", " << conn[4*i+3] << std::endl;
1313  }
1314 
1315 
1316 
1317  std::vector<double> cellCoordVec(connCap*3);
1318  std::vector<double> avgCoor(3);
1319  for(int i =0; i < connCap; i++){
1320 
1321  avgCoor = avgCoord(conn[4*i]-1,conn[4*i+1]-1,conn[4*i+2]-1,conn[4*i+3]-1, fsiCoupler.getFluidAgent());
1322  cellCoordVec[3*i] = avgCoor[0];
1323  cellCoordVec[3*i+1] = avgCoor[1];
1324  cellCoordVec[3*i+2] = avgCoor[2];
1325  std::cout << "CellCoordVec[" << i << "] = " << cellCoordVec[3*i] << ", " << cellCoordVec[3*i+1] << ", " << cellCoordVec[3*i+2] << std::endl;
1326  avgCoor.clear();
1327  }
1328 
1329 
1330  double * tractions;
1331  int stride = 0;
1332  int cap = 0;
1333  // Get the traction vector values for fluid domain.
1334  COM_get_array((fsiCoupler.getFluidIntName()+".traction").c_str(),101,&tractions,&stride,&cap);
1335  std::cout << "stride and cap = " << stride << "," << cap << std::endl;
1336  //traction becomes Ycoord * 3 + 2
1337  int isize = cap * stride ;
1338  for(int i = 0; i < isize/3 ; i++){
1339  //tractions[3*i+1] = 3*fsiCoupler.getFluidAgent()->Coordinates()[3*i+2]+2;
1340  //tractions[3*i+1] = fsiCoupler.getFluidAgent()->Coordinates()[3*i+2];
1341  //tractions[3*i+1] = 1;
1342  tractions[3*i+1] = cellCoordVec[3*i+2];
1343  std::cout << "tractions[" << i << "] = " << tractions[3*i] << ", " << tractions[3*i+1] << ", " << tractions[3*i+2] << ", Coordinates are = " << cellCoordVec[3*i] << ", " << cellCoordVec[3*i+1] << ", " << cellCoordVec[3*i+2] << std::endl;
1344  }
1345 
1346  double * solidLoads1 = NULL;
1347  int solidLoadStride1 = 0;
1348  int solidLoadCap1 =0;
1349  // Get the load vector from solid domain
1350  COM_get_array((fsiCoupler.getSolidIntName()+".Loads").c_str(),11,&solidLoads1,&solidLoadStride1,&solidLoadCap1);
1351  int solidLoadSize1 = solidLoadCap1*solidLoadStride1;
1352 
1353  // Execute Transfer LoadsToStructures
1355 
1356  double * solidLoads = NULL;
1357  int solidLoadStride = 0;
1358  int solidLoadCap =0;
1359  // Get the load vector from solid domain
1360  COM_get_array((fsiCoupler.getSolidIntName()+".Loads").c_str(),11,&solidLoads,&solidLoadStride,&solidLoadCap);
1361  int solidLoadSize = solidLoadCap*solidLoadStride;
1362 
1363  std::cout << "solidLoadCap = " << solidLoadCap << ", solidLoadStride = " << solidLoadStride << std::endl;
1364  for(int i = 0; i < solidLoadSize/3; i++){
1365  std::cout << "solidLoads(" << i <<") = " << solidLoads[3*i] << ", " << solidLoads[3*i+1] << ", " << solidLoads[3*i+2] << " Where coordinate is = " << fsiCoupler.getStructureAgent()->Coordinates()[3*i] << ", " << fsiCoupler.getStructureAgent()->Coordinates()[3*i+1] << ", " << fsiCoupler.getStructureAgent()->Coordinates()[3*i+2] << std::endl;
1366  }
1367 
1368 
1369  double totalTraction, totalLoad = 0;
1370  for(int i = 0; i < solidLoadSize; i++) totalLoad += solidLoads[i];
1371  totalLoad = totalLoad/2;
1372  for(int i = 0; i < isize/3 ; i++) totalTraction +=tractions[3*i+1];
1373 
1374 
1375  std::cout << "total loads = " << totalLoad << std::endl;
1376  std::cout << "total tractions = " << totalTraction << std::endl;
1377 
1378  // Using Error % = (Experimented value - Theoretical value) / Theoretical value
1379  double totalError = (totalLoad - totalTraction) / totalTraction;
1380  // If the error % is greater than 5%, let's call it a fail.
1381  std::cout << "total error = " << totalError << std::endl;
1382  if(totalError >= .05) works = false;
1383 
1384  double maxError = 0;
1385  double errr = 0;
1386  for(int i = 0; i < isize/3 ; i++){
1387  for(int j = 0; j <= 9; j = j + 3){
1388  //std::cout << "tractions = " << tractions[3*i+1] << std::endl;
1389  //std::cout << "solidLoads = " << solidLoads[7*i+1-i+j] << std::endl;
1390  errr = std::abs( ( solidLoads[7*i+1-i+j] - tractions[3*i+1]) / tractions[3*i+1] );
1391  if(errr >= maxError){
1392  maxError = errr;
1393  std::cout << "maxError = " << maxError << std::endl;
1394  std::cout << "Happens at i,j = " << i << ", " << j << std::endl;
1395  }
1396  }
1397  }
1398  std::cout << "Max error = " << maxError << std::endl;
1399  result.UpdateResult("TransferLoadsToStructures:Works",works);
1400  }
std::string getSolidIntName()
Definition: FsiCoupling.H:712
std::vector< double > avgCoord(int first, int second, int third, int fourth, fluidagent *fluidAgent)
solidagent * getStructureAgent()
Definition: FsiCoupling.H:709
double getSimulationTime()
Definition: FsiCoupling.H:704
virtual int Run(double endTime)
Definition: OpenFoamAgent.H:65
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
virtual int InitializeTimeStep(double time)
Definition: Orchestrator.H:24
std::vector< std::string > componentInterfaceNames
const std::vector< double > & Coordinates() const
Definition: ElmerAgent.H:79
int TransferLoadsToStructures(fluidagent *fluidAgent, solidagent *solidAgent)
Definition: FsiCoupling.H:176
void SetVerbLevel(int verb)
Definition: FsiCoupling.H:56
int getRunMode()
Definition: FsiCoupling.H:706
double getSimulationFinalTime()
Definition: FsiCoupling.H:705
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: