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
int TransferPressuresToStructures ( fluidagent fluidAgent,
solidagent solidAgent 
)
inline

Definition at line 221 of file FsiCoupling.H.

References fluidsInterfaceName, simpalInterfaceName, structuresInterfaceName, surfUtilInterfaceName, and transferAgent.

222  {
223  std::stringstream outString;
224  int stride = 0, solidStride = 0, solidLoadStride = 0;
225  int cap = 0, solidCap = 0, solidLoadCap = 0;
226  double *pressures = NULL, *solidPressures = NULL, *solidLoads = NULL;
227 
228  //Get pressure array from fluid solver
229  COM_get_array((fluidsInterfaceName+".pressure").c_str(),101,&pressures,&stride,&cap);
230  int isize = cap*stride;
231  //Add atmospheric pressure
232  for(int i = 0;i < isize;i++){
233  std::cout << "Pressure(" << i << ") = " << pressures[i] << std::endl;
234  }
235  //Transfer the pressures from the fluid to the solid
236  transferAgent->Transfer("pressure","Pressures",true);
237  transferAgent->Transfer("pressure","NodePressures",true);
238 
240  //Get handles for dataitems needed
241  int solidFaceLoadsHandle = COM_get_dataitem_handle(structuresInterfaceName+".FaceLoads");
242  if(solidFaceLoadsHandle < 0){
243  outString << "Error: (TransferPressuresToStructures)" << std::endl
244  << " No handle for FaceLoads with structure solver" << std::endl;
245  StdOut(outString.str(),0,true);
246  outString.clear();
247  outString.str("");
248  return(1);
249  }
250  int solidPressuresHandle = COM_get_dataitem_handle(structuresInterfaceName+".Pressures");
251  if(solidPressuresHandle < 0){
252  outString << "Error: (TransferPressuresToStructures)" << std::endl
253  << " No handle for Pressures with structure solver" << std::endl;
254  StdOut(outString.str(),0,true);
255  outString.clear();
256  outString.str("");
257  return(1);
258  }
259 
260  //Account for atmospheric pressure when transferring to Elmer (we aren't doing this)
261  //Get pressure array from solid solver
262  COM_get_array((structuresInterfaceName+".Pressures").c_str(),11,&solidPressures,
263  &solidStride,&solidCap);
264  int solidIsize = solidCap*solidStride;
265  //Add atmospheric pressure (we aren't doing this - should we?)
266  for(int i = 0;i < solidIsize;i++){
267  //solidPressures[i] += 101325.0;
268  //solidPressures[i] = 1.0;
269  outString << std::setprecision(15) << "solidPressure(" << i << ") = " << solidPressures[i] << std::endl;
270  }
271  StdOut(outString.str(),3,true);
272  outString.clear();
273  outString.str("");
274 
275  //Get handles for functions needed
276  std::string funcName;
277  funcName = surfUtilInterfaceName + ".compute_element_normals";
278  int faceNormalsHandle = COM_get_function_handle(funcName.c_str());
279  if(faceNormalsHandle < 0){
280  outString << "Error: (TransferPressuresToStructures)" << std::endl
281  << " No handle for compute_element_normals function " << std::endl;
282  StdOut(outString.str(),0,true);
283  outString.clear();
284  outString.str("");
285  return(1);
286  }
287  funcName = simpalInterfaceName + ".mul";
288  int mulHandle = COM_get_function_handle(funcName.c_str());
289  if(mulHandle < 0){
290  outString << "Error: (TransferPressuresToStructures)" << std::endl
291  << " No handle for simpal multiply function " << std::endl;
292  StdOut(outString.str(),0,true);
293  outString.clear();
294  outString.str("");
295  return(1);
296  }
297  funcName = simpalInterfaceName + ".neg";
298  int negHandle = COM_get_function_handle(funcName.c_str());
299  if(negHandle < 0){
300  outString << "Error: (TransferPressuresToStructures)" << std::endl
301  << " No handle for simpal negate function " << std::endl;
302  StdOut(outString.str(),0,true);
303  outString.clear();
304  outString.str("");
305  return(1);
306  }
307 
308  //Execute the appropriate function calls
309  //I'm gonna try not normalizing them!!
310  int normalize=1;
311  //Call function to get face normals, store them in solidFaceLoads, do not
312  //normalize them
313  COM_call_function(faceNormalsHandle, &solidFaceLoadsHandle, &normalize);
314  //Call function to get face normals, store them in solidFaceLoads, do not
315  //normalize them
316  COM_call_function(mulHandle, &solidFaceLoadsHandle, &solidPressuresHandle,
317  &solidFaceLoadsHandle);
318  COM_call_function(negHandle, &solidFaceLoadsHandle, &solidFaceLoadsHandle);
320 
322  transferagent *structuresTransferAgent = new transferagent("structuresTransferAgent");
323 
324  // Initialize the transfer module's common refinement
325  structuresTransferAgent->Overlay(structuresInterfaceName,structuresInterfaceName);
326 
327  // Call the transfer now
328  structuresTransferAgent->Transfer("FaceLoads","Loads");
329 
330  //Get loads array from solid solver to check
331  COM_get_array((structuresInterfaceName+".Loads").c_str(),11,&solidLoads,
332  &solidLoadStride,&solidLoadCap);
333  int solidLoadsize = solidLoadCap*solidLoadStride;
334  for(int i = 0;i < solidLoadsize;i++){
335  std::cout << std::setprecision(15) << "solidLoads(" << i << ") = " << solidLoads[i] << std::endl;
336  }
337 
338  //Print out the face normals from the fluid solver as a check
339  int fluidFaceNormalsHandle = COM_get_dataitem_handle(fluidsInterfaceName+".normals");
340  if(fluidFaceNormalsHandle < 0){
341  outString << "Error: (TransferPressuresToStructures)" << std::endl
342  << " No handle for FaceNormals with fluids solver" << std::endl;
343  StdOut(outString.str(),0,true);
344  outString.clear();
345  outString.str("");
346  return(1);
347  }
348  normalize=0;
349  COM_call_function(faceNormalsHandle, &fluidFaceNormalsHandle, &normalize);
350  double *fluidFaceNormals = NULL;
351  COM_get_array((fluidsInterfaceName+".normals").c_str(),101,&fluidFaceNormals,&stride,&cap);
352  isize = stride*cap;
353 
354  outString << "stride = " << stride << std::endl;
355  std::vector<double> sums (stride, 0.0);
356  outString << "Driver: fluid face normals:" << std::endl;
357  for(int i=0; i < cap; i++){
358  for(int j=0; j < stride; j++){
359  outString << fluidFaceNormals[stride*i + j] << " ";
360  sums[j] += fluidFaceNormals[stride*i + j];
361  }
362  outString << std::endl;
363  }
364  outString << "sums: ";
365  for(int i=0; i < sums.size(); i++)
366  outString << sums[i] << " ";
367  outString << std::endl;
368  StdOut(outString.str(),3,true);
369  outString.clear();
370  outString.str("");
371 
372  return(0);
373  };
SolverUtils::TransferObject transferagent
Definition: FsiCoupling.H:19
transferagent * transferAgent
Definition: FsiCoupling.H:31
std::string simpalInterfaceName
Definition: FsiCoupling.H:37
std::string structuresInterfaceName
Definition: FsiCoupling.H:34
std::string surfUtilInterfaceName
Definition: FsiCoupling.H:36
std::string fluidsInterfaceName
Definition: FsiCoupling.H:33