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
ElmerFoamDriver.C
Go to the documentation of this file.
1 
9 #include "Driver.H"
10 #include "Parameters.H"
11 //#include "InterfaceLayer.H"
12 //#include "Orchestrator.H"
13 //#include "OpenFoamAgent.H"
14 //#include "ElmerAgent.H"
15 //#include "Global.H"
16 #include "FsiCoupling.H"
17 
18 //typedef SolverUtils::TransferObject transferagent;
19 //typedef openfoamagent fluidagent;
20 //typedef elmeragent solidagent;
21 //typedef IRAD::Profiler::ProfilerObj ProfilerType;
22 //typedef std::string StackType;
23 //typedef IRAD::Global::GlobalObj<StackType,int,ProfilerType> GlobalType;
24 
25 COM_EXTERN_MODULE(ElmerCSC);
26 COM_EXTERN_MODULE(OpenFoamFSI);
27 
28 namespace ElmerFoamFSI {
29 
31  {
32  // FunctionEntry("NAME"): Updates the user-defined stack and
33  // the program profiles with timing information. The placement
34  // of FunctionEntry and FunctionExit calls is at the developer's
35  // discretion.
36  FunctionEntry("Run");
37  std::ostringstream outString;
38  IRAD::Util::Parameters userParameters;
39  std::ifstream paramFileIn;
40  paramFileIn.open(input_name.c_str());
41  paramFileIn >> userParameters;
42  outString << "User Parameters: " << std::endl
43  << userParameters << std::endl;
44  StdOut(outString.str(), 1, true);
45  outString.clear();
46  outString.str("");
47 
48 
49  std::string fluidSolverName(userParameters.GetValue("FluidSolver"));
50  std::string solidSolverName(userParameters.GetValue("SolidSolver"));
51  std::string transferServiceName(userParameters.GetValue("TransferService"));
52  std::string runMode(userParameters.GetValue("RunMode"));
53 
54 
55  double time_final = 0;
56  time_final = userParameters.GetValue<double>("FinalTime");
57  if(time_final <= 0){
58  // warn = default
59  time_final = 1e+24;
60  }
61 
62  double timestep = 0;
63  timestep = userParameters.GetValue<double>("TimeStep");
64  if(timestep <= 1e-5){
65  // warn = default
66  timestep = 1e-5;
67  }
68 
69  if(fluidSolverName.empty()){
70  outString << "Failed to specify FluidSolver parameter.\n";
71  ErrOut(outString.str());
72  FunctionExit("Run");
73  return(1);
74  }
75  if(solidSolverName.empty()){
76  outString << "Failed to specify SolidSolver parameter.\n";
77  ErrOut(outString.str());
78  FunctionExit("Run");
79  return(1);
80  }
81 
82  FunctionEntry("LoadModules");
83  COM_load_module(fluidSolverName.c_str(),"FluidsComponentInterface");
84  COM_load_module(solidSolverName.c_str(),"StructuresComponentInterface");
85  COM_load_module("SurfUtil","SurfUtil");
86  COM_load_module("Simpal","Simpal");
87  FunctionExit("LoadModules");
88 
89  std::cout << "line " << __LINE__ << std::endl;
90  fsicoupling fsiCoupler(*this);
91  std::cout << "line " << __LINE__ << std::endl;
92  fsiCoupler.SetRunMode(runMode);
93  fsiCoupler.SetVerbLevel(verblevel);
94 
95  std::vector<std::string> componentInterfaceNames;
96  componentInterfaceNames.push_back("FluidsComponentInterface");
97  componentInterfaceNames.push_back("StructuresComponentInterface");
98  componentInterfaceNames.push_back("TransferInterface");
99  componentInterfaceNames.push_back("SurfUtil");
100  componentInterfaceNames.push_back("Simpal");
101 
102  FunctionEntry("coupler.Init");
103  fsiCoupler.Initialize(componentInterfaceNames, time_final, timestep);
104  FunctionExit("coupler.Init");
105 
106  FunctionEntry("coupler.Run");
107  fsiCoupler.Run();
108  FunctionExit("coupler.Run");
109 
110  FunctionEntry("coupler.Finalize");
111  fsiCoupler.Finalize();
112  FunctionExit("coupler.Finalize");
113 
114  //COM_unload_module(fluidSolverName.c_str(),"FluidsComponentInterface");
115  COM_unload_module(solidSolverName.c_str(),"StructuresComponentInterface");
116 
117  outString << "Before Running FunctionExit" << std::endl;
118  StdOut(outString.str(),2,true);
119  outString.clear();
120  outString.str("");
121 
122  FunctionExit("Run");
123  outString << "After Running FunctionExit" << std::endl;
124  StdOut(outString.str(),2,true);
125  outString.clear();
126  outString.str("");
127 
128  // return 0 for success
129  return(0);
130  };
131 };
Example serial program.
Example program interface.
int DriverRun()
This function implements the main function executed by the program.
std::string input_name
Name of input file.
Definition: Driver.H:169
void SetRunMode(const std::string &inMode)
Definition: FsiCoupling.H:376
virtual int Run()
Definition: FsiCoupling.H:556
COM_EXTERN_MODULE(OpenFoamFSI)
int verblevel
Verbosity level.
Definition: Driver.H:171
void SetVerbLevel(int verb)
Definition: FsiCoupling.H:56
virtual int Initialize(std::vector< std::string > &componentInterfaceNames, double finalTime, double timeStep)
Definition: FsiCoupling.H:498
virtual int Finalize()
Definition: FsiCoupling.H:680