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

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

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

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 
57  std::string newDataItem(interfaceName+".coords");
58  COM_new_dataitem(newDataItem.c_str(),'n',COM_DOUBLE,3,"m");
59  COM_set_array(newDataItem.c_str(),paneID,&nodeCoordinates[0]);
60 
61  COM_window_init_done(interfaceName);
62 
63  if(SolverUtils::PopulateSolverAgentFromWindow(interfaceName,*this))
64  return(1);
65 
66 
67 
68  WriteOut("Elmer Initialization done!\n");
69  return(0);
70  };
std::vector< int > componentFunctionHandles
Definition: Orchestrator.H:13
int paneID
Definition: ElmerAgent.H:98
std::vector< double > nodeCoordinates
Definition: ElmerAgent.H:102
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: