10 #include "com_devel.hpp"
16 #include "primitive_utilities.H"
22 std::cout <<
"SolverModuleDriver:usage: Usage: " << std::endl
23 << exec <<
" -com-mpi timeNext timeNext ... timeFinal" << std::endl
24 <<
"where at least -com-mpi and timeFinal is required." << std::endl
25 <<
"NOTES:" << std::endl
26 <<
"*currently it is required to use the -com-mpi flag" << std::endl
27 <<
"*steady state problems will always use a timestep" << std::endl
28 <<
" of 1.0, and should only have a timeFinal" << std::endl
29 <<
"*each time must be greater than the previous time" << std::endl
30 <<
" because the simulation begins at the previous time and runs" << std::endl
31 <<
" to the current time" << std::endl;
37 COM_init( &argc, &argv);
39 std::cout <<
"SoverModuleDriver:init: After COM_init" << std::endl;
57 for(
int i=1; i < argc; i++){
61 if(
ss.str() ==
"-com-mpi")
63 if(
ss.str() ==
"-fsi"){
67 if(
ss.str() ==
"-loads"){
71 for(
int j=0; j <
ss.str().size(); j++){
72 if(!isdigit(
ss.str()[j]) &&
ss.str()[j] !=
'e'
73 &&
ss.str()[j] !=
'E' &&
ss.str()[j] !=
'-'
74 &&
ss.str()[j] !=
'.')
84 for(
int i=1; i <
tNext.size(); i++){
89 COM_LOAD_MODULE_STATIC_DYNAMIC( ElmerCSC,
"Window1");
92 int init_handle = COM_get_function_handle(
"Window1.Initialize");
93 bool init_func = (init_handle > 0);
97 COM_call_function(init_handle, &
runs, &verb);
111 std::cout <<
"SoverModuleDriver:run: coord_handle = " <<
coord_handle << std::endl;
113 COM_get_size(
"Window1.nc",11,&
CoordSize);
116 COM_get_array(
"Window1.nc",11,&
Coord);
117 std::cout <<
"SoverModuleDriver:run: Coord: " << std::endl;
119 for(
int j=0; j < 3; j++){
120 std::cout <<
Coord[i*3+j] <<
" ";
122 std::cout << std::endl;
124 Mesh().nc.init(CoordSize,
Coord);
134 COM_get_array(
"Window1.:b2:",11,&
Conn);
137 COM_get_size(
"Window1.:b2:",11,&
ConnSize);
139 std::cout <<
"SoverModuleDriver:run: Conn: " << std::endl;
141 for(
int j=0; j < 2; j++){
142 std::cout <<
Conn[i*2+j] <<
" ";
143 elems.push_back(Conn[i*2+j]);
145 std::cout << std::endl;
147 Mesh().con.AddElements(ConnSize,2,
elems);
151 std::cout <<
"SoverModuleDriver:run: WriteMeshToStream: " << std::endl;
152 WriteMeshToStream(std::cout);
153 std::cout << std::endl;
156 COM_get_array(
"Window1.Displacements",11,&
Disp);
159 COM_get_size(
"Window1.Displacements",11,&
DispSize);
161 std::cout <<
"SoverModuleDriver:run: Checking displacements" << std::endl;
163 for(
int j=0; j < 3; j++){
164 std::cout <<
Disp[i*3+j] <<
" ";
167 std::cout << std::endl;
172 std::cout <<
"Line = " << __LINE__ << std::endl;
180 COM_get_array(
"Window1.Loads",11,&
Loads);
182 std::cout <<
"SoverModuleDriver:run: Loads not NULL" << std::endl;
184 COM_get_size(
"Window1.Loads",11,&
LoadsSize);
187 std::cout <<
"SoverModuleDriver:run: Checking loads" << std::endl;
189 for(
int j=0; j < 3; j++){
190 Loads[i*3 + j] = double(i*3 + j);
191 std::cout <<
Loads[i*3+j] <<
" ";
194 std::cout << std::endl;
198 std::cout <<
"SoverModuleDriver:run: Line = " << __LINE__ << std::endl;
203 Solution().Meta().AddField(
"displacement",
'n',3,8,
"m");
204 std::cout <<
"SoverModuleDriver:run: WriteSolnMetaToStream:" << std::endl;
205 WriteSolnMetaToStream(std::cout);
206 std::cout << std::endl;
209 Solution().Meta().AddField(
"loads",
'n',3,8,
"");
210 std::cout <<
"SoverModuleDriver:run: WriteSolnMetaToStream:" << std::endl;
211 WriteSolnMetaToStream(std::cout);
212 std::cout << std::endl;
214 std::cout <<
"SoverModuleDriver:run: Line = " << __LINE__ << std::endl;
218 std::cout <<
"SoverModuleDriver:run: Line = " << __LINE__ << std::endl;
220 Solution().SetFieldBuffer(
"displacement",
DispPass);
222 Solution().SetFieldBuffer(
"loads",
LoadsPass);
224 std::cout <<
"SoverModuleDriver:run: Line = " << __LINE__ << std::endl;
229 std::string filename;
230 filename =
"fsi0.vtk";
231 Ouf.open(filename.c_str());
233 std::cerr <<
"SoverModuleDriver:run: SolverModuleDriver::DumpSolution:Error: Could not open output file, "
234 << filename <<
"." << std::endl;
237 std::cout <<
"SoverModuleDriver:run: WriteVTKToStream time 0" << std::endl;
238 SolverUtils::WriteVTKToStream(
"Window1",*
this,Ouf);
244 int run_handle = COM_get_function_handle(
"Window1.Run");
245 bool run_func = (run_handle > 0);
249 for(
int i=0; i <
tNext.size(); i++){
252 std::cout <<
"SoverModuleDriver:run: Changing load values" << std::endl;
254 for(
int j=0; j < 3; j++){
256 std::cout <<
Loads[k*3 + j] <<
" ";
259 std::cout << std::endl;
263 std::cout <<
"SoverModuleDriver:run: Calling run function from driver" << std::endl;
264 COM_call_function(run_handle,&
runs,&
tNext[i]);
268 std::cout <<
"SoverModuleDriver:run: Checking displacements" << std::endl;
270 for(
int j=0; j < 3; j++){
271 std::cout <<
Disp[k*3+j] <<
" ";
274 std::cout << std::endl;
284 std::string filename;
285 filename =
"fsi" +
ss.str() +
".vtk";
286 Ouf.open(filename.c_str());
288 std::cerr <<
"SolverModuleDriver::DumpSolution:Error: Could not open output file, "
289 << filename <<
"." << std::endl;
292 SolverUtils::WriteVTKToStream(
"Window1",*
this,Ouf);
303 int final_handle = COM_get_function_handle(
"Window1.Finalize");
304 bool final_func = (final_handle > 0);
307 COM_call_function(final_handle,&
runs);
310 COM_UNLOAD_MODULE_STATIC_DYNAMIC( ElmerCSC,
"Window1");
313 std::cout <<
"SolverModuleDriver:finalize: After COM_finalize" << std::endl;
319 int main(
int argc,
char *argv[]){
323 driverObject.
init(argc, argv);
327 std::ofstream Outfile;
329 Outfile.open(
"out.dat");
331 Outfile <<
"howdy!" << std::endl;
332 Outfile <<
"1.2 4.2 5.6 7.8" << std::endl;
333 Outfile <<
" blargity blarg blarg" << std::endl;
std::vector< double > DispPass
std::vector< unsigned int > elems
int init(int argc, char *argv[])
COM_EXTERN_MODULE(OpenFoamFSI)
std::vector< double > tNext
std::vector< double > LoadsPass