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 OpenFoamParAgent.H.

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

Referenced by fsicouplingpar::Initialize().

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 myArgc = 2;
29  char *myArgv[2];
30  myArgv[0] = const_cast<char *>("dummy");
31  myArgv[1] = const_cast<char *>("-parallel");
32  int verbIn = verblevel;
33  COM_call_function(componentFunctionHandles[INIT], &myArgc, &myArgv, &verbIn);
34 
35 
36  std::vector<int> paneIDs;
37  COM_get_panes(interfaceName.c_str(),paneIDs);
38  if(!paneIDs.empty())
39  paneID = paneIDs[0];
40 
41  double *nodalCoordinates;
42  int stride = 0;
43  int cap = 0;
44  std::string coordinateName(interfaceName+".nc");
45  std::string newDataItemName;
46  if (!paneIDs.empty()) {
47  COM_get_array(coordinateName.c_str(),paneID,&nodalCoordinates,&stride,&cap);
48  int arraySize = (stride*cap);
49  nodeCoordinates.resize(arraySize);
50  for(int i = 0;i < arraySize;i++)
51  nodeCoordinates[i] = nodalCoordinates[i];
52  newDataItemName = interfaceName+".coords";
53  COM_new_dataitem(newDataItemName.c_str(),'n',COM_DOUBLE,3,"m");
54  COM_set_array(newDataItemName.c_str(),paneID,&nodeCoordinates[0]);
55  }
56 
57  // setting up probe
58  newDataItemName = interfaceName+".setsProb";
59  COM_new_dataitem(newDataItemName.c_str(),'w',COM_INT,1,"");
60  newDataItemName = interfaceName+".probProcId";
61  COM_new_dataitem(newDataItemName.c_str(),'w',COM_INT,1,"");
62  newDataItemName = interfaceName+".probNdeId";
63  COM_new_dataitem(newDataItemName.c_str(),'w',COM_INT,1,"");
64 
65  COM_window_init_done(interfaceName);
66 
67  if (!paneIDs.empty()) {
68  if(SolverUtils::PopulateSolverAgentFromWindow(interfaceName,*this))
69  return(1);
70  }
71  WriteOut("OpenFOAM Initialization done!\n");
72  return(0);
73  };
std::vector< int > componentFunctionHandles
Definition: Orchestrator.H:13
std::vector< double > nodeCoordinates
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: