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
void TestTransfer ( )
inline

Definition at line 396 of file FsiCoupling.H.

References openfoamagent::Coordinates(), elmeragent::Coordinates(), fluidsAgent, fluidsInterfaceName, openfoamagent::PaneID(), elmeragent::PaneID(), structuresAgent, structuresInterfaceName, and transferAgent.

397  {
398  std::stringstream outString;
399  double *fluidCoordinates = NULL;
400  double *solidCoordinates = NULL;
401  std::string fluidsCoordinateName(fluidsInterfaceName+".nc");
402  std::string solidsCoordinateName(structuresInterfaceName+".nc");
403  COM_get_array(fluidsCoordinateName.c_str(),fluidsAgent->PaneID(),&fluidCoordinates);
404  COM_get_array(solidsCoordinateName.c_str(),structuresAgent->PaneID(),&solidCoordinates);
405  int numberFluidNodes = fluidsAgent->Coordinates().size()/3;
406  int numberSolidNodes = structuresAgent->Coordinates().size()/3;
407  if(!fluidCoordinates || !solidCoordinates){
408  outString << "FSICoupling::TestTransfer:Error: Failed to get coordinate arrays. Exiting."
409  << std::endl;
410  StdOut(outString.str(),0,true);
411  outString.clear();
412  outString.str("");
413  exit(1);
414  }
415  double tolerance = 1e-12;
416  double maxdiff = 0;
417  const std::vector<double> &fluidCoordArray(fluidsAgent->Coordinates());
418  const std::vector<double> &structCoordArray(structuresAgent->Coordinates());
419  outString << "BEFORE TRANSFER: " << std::endl;
420  for(int i = 0; i < numberFluidNodes;i++){
421  outString << "F(" << fluidCoordArray[i*3] << "," << fluidCoordArray[i*3+1] << ","
422  << fluidCoordArray[i*3+2] << ")" << std::endl;
423  }
424  for(int i = 0; i < numberSolidNodes;i++){
425  outString << "S(" << structCoordArray[i*3] << "," << structCoordArray[i*3+1] << ","
426  << structCoordArray[i*3+2] << ")" << std::endl;
427  }
428  StdOut(outString.str(),3,true);
429  outString.clear();
430  outString.str("");
431  transferAgent->Interpolate("coords","coords"); // transfer from structures to fluids the node coordinates
432  outString << "FLUIDS AFTER TRANSFER: " << std::endl;
433  for(int i = 0; i < numberFluidNodes;i++){
434  double diff1 = std::abs(fluidCoordinates[i*3] - fluidCoordArray[i*3]);
435  double diff2 = std::abs(fluidCoordinates[i*3+1] - fluidCoordArray[i*3+1]);
436  double diff3 = std::abs(fluidCoordinates[i*3+2] - fluidCoordArray[i*3+2]);
437  double diff = std::sqrt(diff1*diff1 + diff2*diff2 + diff3*diff3);
438  if(diff > maxdiff) maxdiff = diff;
439  if(diff > tolerance){
440  outString << "FSICoupling::TestTransfer: Coordinate transfer tolerance exceeded for node " << i+1
441  << " (" << diff << ")" << std::endl
442  << "(" << fluidCoordinates[i*3] << "," << fluidCoordinates[i*3+1] << "," << fluidCoordinates[i*3+2]
443  << ") : (" << fluidCoordArray[i*3] << "," << fluidCoordArray[i*3+1] << "," << fluidCoordArray[i*3+2]
444  << ")" << std::endl;
445  }
446  }
447  outString << "FSICoupling::TestTransfer: Maximum transferred (s->f) coordinate difference: " << maxdiff << std::endl;
448  StdOut(outString.str(),3,true);
449  outString.clear();
450  outString.str("");
451  };
fluidagent * fluidsAgent
Definition: FsiCoupling.H:29
solidagent * structuresAgent
Definition: FsiCoupling.H:30
transferagent * transferAgent
Definition: FsiCoupling.H:31
std::string structuresInterfaceName
Definition: FsiCoupling.H:34
int PaneID()
Definition: ElmerAgent.H:80
const std::vector< double > & Coordinates() const
Definition: ElmerAgent.H:79
std::string fluidsInterfaceName
Definition: FsiCoupling.H:33
const std::vector< double > & Coordinates() const
Definition: OpenFoamAgent.H:63

Here is the call graph for this function: