10 #include "Parameters.H"
23 namespace ElmerFoamFSI {
25 int ParallelDriverProgram::DriverRun()
35 int myid = _communicator.Rank();
36 int nproc = _communicator.Size();
37 bool use_file = !output_name.empty();
45 std::ostringstream RepStr;
47 RepStr <<
"Running on " << nproc <<
" processors." << std::endl;
49 _communicator.Barrier();
51 StdOut(
"All procesors ready.\n");
54 std::ostringstream outString;
55 IRAD::Util::Parameters userParameters;
56 std::ifstream paramFileIn;
57 paramFileIn.open(input_name.c_str());
58 paramFileIn >> userParameters;
61 outString <<
"User Parameters: " << std::endl
62 << userParameters << std::endl;
63 StdOut(outString.str(), 1,
true);
64 _communicator.Barrier();
66 std::string fluidSolverName(userParameters.GetValue(
"FluidSolver"));
67 std::string solidSolverName(userParameters.GetValue(
"SolidSolver"));
68 std::string transferServiceName(userParameters.GetValue(
"TransferService"));
69 std::string runMode(userParameters.GetValue(
"RunMode"));
77 int probProcId(-1), probNdeId(0);
78 std::string probSolverName(
"");
79 if (userParameters.IsSet(
"ProbSolverName")) {
80 probSolverName = userParameters.GetValue(
"ProbSolverName");
81 probProcId = userParameters.GetValue<
int>(
"ProbProcId");
82 probNdeId = userParameters.GetValue<
int>(
"ProbNdeId");
83 if (probProcId>=nproc || probProcId<0) {
84 outString <<
"The requested process ID for probing is not valid.\n";
85 ErrOut(outString.str());
86 _communicator.SetExit(1);
90 outString <<
"Probing "
92 <<
" solution at rank "
94 <<
" registered node "
97 StdOut(outString.str(), 1,
true);
103 if(_communicator.Check()){
111 if(use_file && !myid){
112 Ouf.open(output_name.c_str(),std::ios::app);
116 std::ostringstream Ostr;
117 Ostr <<
"Error: Unable to open output file, " << output_name <<
".";
124 _communicator.SetExit(1);
130 if(_communicator.Check()){
137 double time_final = 0;
138 time_final = userParameters.GetValue<
double>(
"FinalTime");
145 timestep = userParameters.GetValue<
double>(
"TimeStep");
146 if(timestep <= 1e-5){
151 if(fluidSolverName.empty()){
152 outString <<
"Failed to specify FluidSolver parameter.\n";
153 ErrOut(outString.str());
154 _communicator.SetExit(1);
156 if(solidSolverName.empty()){
157 outString <<
"Failed to specify SolidSolver parameter.\n";
158 ErrOut(outString.str());
159 _communicator.SetExit(1);
165 if(_communicator.Check()){
172 FunctionEntry(
"LoadModules");
173 COM_load_module(fluidSolverName.c_str(),
"FluidsComponentInterface");
174 COM_load_module(solidSolverName.c_str(),
"StructuresComponentInterface");
175 COM_load_module(
"SurfUtil",
"SurfUtil");
176 COM_load_module(
"Simpal",
"Simpal");
177 COM_load_module(
"SimOUT",
"Simout");
178 FunctionExit(
"LoadModules");
181 fsiCouplerPar.SetRunMode(runMode);
182 fsiCouplerPar.SetVerbLevel(verblevel);
183 fsiCouplerPar.SetProbe(probProcId, probNdeId, probSolverName);
186 std::vector<std::string> componentInterfaceNames;
187 componentInterfaceNames.push_back(
"FluidsComponentInterface");
188 componentInterfaceNames.push_back(
"StructuresComponentInterface");
189 componentInterfaceNames.push_back(
"TransferInterface");
190 componentInterfaceNames.push_back(
"SurfUtil");
191 componentInterfaceNames.push_back(
"Simpal");
192 componentInterfaceNames.push_back(
"Simout");
195 FunctionEntry(
"fsiCouplerPar.Initialize");
196 fsiCouplerPar.Initialize(componentInterfaceNames, time_final, timestep);
197 FunctionExit(
"fsiCouplerPar.Initialize");
198 _communicator.Barrier();
200 FunctionEntry(
"fsiCouplerPar.Run");
202 FunctionExit(
"fsiCouplerPar.Run");
203 _communicator.Barrier();
205 FunctionEntry(
"fsiCouplerPar.Finalize");
206 fsiCouplerPar.Finalize();
207 FunctionExit(
"fsiCouplerPar.Finalize");
208 _communicator.Barrier();
210 COM_unload_module(fluidSolverName.c_str(),
"FluidsComponentInterface");
211 COM_unload_module(solidSolverName.c_str(),
"StructuresComponentInterface");
212 _communicator.Barrier();
214 outString <<
"Before Running FunctionExit" << std::endl;
215 StdOut(outString.str(),2,
true);
220 outString <<
"After Running FunctionExit" << std::endl;
221 StdOut(outString.str(),2,
true);
Example program interface.
COM_EXTERN_MODULE(OpenFoamFSI)