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 10 of file ElmerParAgent.H.

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

Referenced by fsicouplingpar::Initialize().

10  {
11  int structuresInitHandle = COM_get_function_handle(std::string(interfaceName+".Initialize").c_str());
12  if(structuresInitHandle < 0){
13  WriteErr("Failed to get Elmer initialization handle.\n");
14  return(1);
15  }
16  componentFunctionHandles[INIT] = structuresInitHandle;
17 
18  int structuresRunHandle = COM_get_function_handle(std::string(interfaceName+".Run").c_str());
19  if(structuresRunHandle < 0){
20  WriteErr("Failed to get Elmer run handle.\n");
21  return(1);
22  }
23  componentFunctionHandles[RUN] = structuresRunHandle;
24 
25  int structuresFinalizeHandle = COM_get_function_handle(std::string(interfaceName+".Finalize").c_str());
26  if(structuresFinalizeHandle < 0){
27  WriteErr("Failed to get structures finalize handle.\n");
28  return(1);
29  }
30  componentFunctionHandles[FINALIZE] = structuresFinalizeHandle;
31 
32  int runs = 0;
33  int verbIn = verblevel;
34  COM_call_function(componentFunctionHandles[INIT],&runs, &verbIn);
35  if(!runs){
36  WriteErr("Elmer failed to initialize!\n");
37  return(1);
38  }
39 
40  std::vector<int> paneIDs;
41  COM_get_panes(interfaceName.c_str(),paneIDs);
42  if(!paneIDs.empty())
43  paneID = paneIDs[0];
44 
45  double *nodalCoordinates;
46  int stride = 0;
47  int cap = 0;
48  std::string coordinateName(interfaceName+".nc");
49  COM_get_array(coordinateName.c_str(),paneID,&nodalCoordinates,&stride,&cap);
50  int arraySize = (stride*cap);
51  std::cout << "Stride = " << stride << " Cap = " << cap << std::endl;
52  nodeCoordinates.resize(arraySize);
53  for(int i = 0;i < arraySize;i++)
54  nodeCoordinates[i] = nodalCoordinates[i];
55 
56  // extra variables to register
57  std::string newDataItemName(interfaceName+".coords");
58  COM_new_dataitem(newDataItemName.c_str(),'n',COM_DOUBLE,3,"m");
59  COM_set_array(newDataItemName.c_str(),paneID,&nodeCoordinates[0]);
60 
61  // setting up probe
62  newDataItemName = interfaceName+".setsProb";
63  COM_new_dataitem(newDataItemName.c_str(),'w',COM_INT,1,"");
64  newDataItemName = interfaceName+".probProcId";
65  COM_new_dataitem(newDataItemName.c_str(),'w',COM_INT,1,"");
66  newDataItemName = interfaceName+".probNdeId";
67  COM_new_dataitem(newDataItemName.c_str(),'w',COM_INT,1,"");
68 
69  COM_window_init_done(interfaceName);
70 
71 
72  if(SolverUtils::PopulateSolverAgentFromWindow(interfaceName,*this))
73  return(1);
74 
75 
76  WriteOut("Elmer Initialization done!\n");
77  return(0);
78  };
std::vector< int > componentFunctionHandles
Definition: Orchestrator.H:13
std::vector< double > nodeCoordinates
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: