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 int Initialize ( const std::string  interfaceName,
int  verblevel = 1 
)
inlinevirtual

Definition at line 9 of file OpenFoamAgent.H.

References agentbase::componentFunctionHandles, agentbase::componentInterfaceNames, agentbase::INIT, nodeCoordinates, paneID, agentbase::RUN, agentbase::WriteErr(), and agentbase::WriteOut().

Referenced by fsicoupling::Initialize(), and TestingObject< ResultsType >::Test__OpenFoamFluids().

9  {
10  componentInterfaceNames.push_back(interfaceName);
11  componentFunctionHandles[INIT] = COM_get_function_handle(std::string(interfaceName+".InitFoam").c_str());
12  int fluidsInitHandle = componentFunctionHandles[INIT];
13  if(fluidsInitHandle < 0){
14  WriteErr("Failed to get fluids initialization handle.\n");
15  return(1);
16  }
17 
18  int fluidsStepHandle = COM_get_function_handle(std::string(interfaceName+".StepFluid").c_str());
19  if(fluidsStepHandle < 0){
20  WriteErr("Failed to get fluids step handle.\n");
21  return(1);
22  }
23  componentFunctionHandles[RUN] = fluidsStepHandle;
24 
25 
26  WriteOut("Calling OpenFOAM Initialization.\n");
27 
28  int argc_dupe = 1;
29  char *argv[2];
30  argv[0] = const_cast<char *>("test");
31  argv[1] = NULL;
32  int verbIn = verblevel;
33  COM_call_function(componentFunctionHandles[INIT],&argc_dupe,argv,&verbIn);
34 
35  std::vector<int> paneIDs;
36  COM_get_panes(interfaceName.c_str(),paneIDs);
37  if(!paneIDs.empty())
38  paneID = paneIDs[0];
39 
40  double *nodalCoordinates;
41  int stride = 0;
42  int cap = 0;
43  std::string coordinateName(interfaceName+".nc");
44  COM_get_array(coordinateName.c_str(),paneID,&nodalCoordinates,&stride,&cap);
45  int arraySize = (stride*cap);
46  nodeCoordinates.resize(arraySize);
47  for(int i = 0;i < arraySize;i++)
48  nodeCoordinates[i] = nodalCoordinates[i];
49 
50 
51  std::string newDataItem(interfaceName+".coords");
52  COM_new_dataitem(newDataItem.c_str(),'n',COM_DOUBLE,3,"m");
53  COM_set_array(newDataItem.c_str(),paneID,&nodeCoordinates[0]);
54 
55  COM_window_init_done(interfaceName);
56 
57  if(SolverUtils::PopulateSolverAgentFromWindow(interfaceName,*this))
58  return(1);
59 
60  WriteOut("OpenFOAM Initialization done!\n");
61  return(0);
62  };
std::vector< double > nodeCoordinates
Definition: OpenFoamAgent.H:80
std::vector< int > componentFunctionHandles
Definition: Orchestrator.H:13
std::vector< std::string > componentInterfaceNames
Definition: Orchestrator.H:11
virtual void WriteErr(const std::string &output)
Definition: Orchestrator.H:32
virtual void WriteOut(const std::string &output)
Definition: Orchestrator.H:28

Here is the call graph for this function:

Here is the caller graph for this function: