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 101 of file FsiCouplingPar.H.

References openfoamagentpar::Coordinates(), elmeragentpar::Coordinates(), fluidsAgent, fluidsInterfaceName, openfoamagentpar::PaneID(), elmeragentpar::PaneID(), structuresAgent, structuresInterfaceName, and transferAgent.

102  {
103  std::stringstream outString;
104  double *fluidCoordinates = NULL;
105  double *solidCoordinates = NULL;
106  std::string fluidsCoordinateName(fluidsInterfaceName+".nc");
107  std::string solidsCoordinateName(structuresInterfaceName+".nc");
108  COM_get_array(fluidsCoordinateName.c_str(),fluidsAgent->PaneID(),&fluidCoordinates);
109  COM_get_array(solidsCoordinateName.c_str(),structuresAgent->PaneID(),&solidCoordinates);
110  int numberFluidNodes = fluidsAgent->Coordinates().size()/3;
111  int numberSolidNodes = structuresAgent->Coordinates().size()/3;
112  if(!fluidCoordinates || !solidCoordinates){
113  outString << "FSICoupling::TestTransfer:Error: Failed to get coordinate arrays. Exiting."
114  << std::endl;
115  StdOut(outString.str(),0,true);
116  outString.clear();
117  outString.str("");
118  exit(1);
119  }
120  double tolerance = 1e-12;
121  double maxdiff = 0;
122  const std::vector<double> &fluidCoordArray(fluidsAgent->Coordinates());
123  const std::vector<double> &structCoordArray(structuresAgent->Coordinates());
124  outString << "BEFORE TRANSFER: " << std::endl;
125  for(int i = 0; i < numberFluidNodes;i++){
126  outString << "F(" << fluidCoordArray[i*3] << "," << fluidCoordArray[i*3+1] << ","
127  << fluidCoordArray[i*3+2] << ")" << std::endl;
128  }
129  for(int i = 0; i < numberSolidNodes;i++){
130  outString << "S(" << structCoordArray[i*3] << "," << structCoordArray[i*3+1] << ","
131  << structCoordArray[i*3+2] << ")" << std::endl;
132  }
133  StdOut(outString.str(),3,true);
134  outString.clear();
135  outString.str("");
136  transferAgent->Interpolate("coords","coords"); // transfer from structures to fluids the node coordinates
137  //transferAgent->Transfer("coords","coords"); // transfer from structures to fluids the node coordinates
138  outString << "FLUIDS AFTER TRANSFER: " << std::endl;
139  for(int i = 0; i < numberFluidNodes;i++){
140  double diff1 = std::abs(fluidCoordinates[i*3] - fluidCoordArray[i*3]);
141  double diff2 = std::abs(fluidCoordinates[i*3+1] - fluidCoordArray[i*3+1]);
142  double diff3 = std::abs(fluidCoordinates[i*3+2] - fluidCoordArray[i*3+2]);
143  double diff = std::sqrt(diff1*diff1 + diff2*diff2 + diff3*diff3);
144  if(diff > maxdiff) maxdiff = diff;
145  if(diff > tolerance){
146  outString << "FSICoupling::TestTransfer: Coordinate transfer tolerance exceeded for node " << i+1
147  << " (" << diff << ")" << std::endl
148  << "(" << fluidCoordinates[i*3] << "," << fluidCoordinates[i*3+1] << "," << fluidCoordinates[i*3+2]
149  << ") : (" << fluidCoordArray[i*3] << "," << fluidCoordArray[i*3+1] << "," << fluidCoordArray[i*3+2]
150  << ")" << std::endl;
151  }
152  }
153  outString << "FSICoupling::TestTransfer: Maximum transferred (s->f) coordinate difference: " << maxdiff << std::endl;
154  StdOut(outString.str(),3,true);
155  outString.clear();
156  outString.str("");
157  };
const std::vector< double > & Coordinates() const
Definition: ElmerParAgent.H:87
transferagentpar * transferAgent
solidagentpar * structuresAgent
std::string fluidsInterfaceName
std::string structuresInterfaceName
const std::vector< double > & Coordinates() const
fluidagentpar * fluidsAgent

Here is the call graph for this function: