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.
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Macros
Groups
Pages
src/ExampleSerialProgram.C
Go to the documentation of this file.
1
9
#include "ExampleProgram.H"
10
11
12
namespace
ElmerFoamFSI {
13
14
namespace
ExampleProgram {
15
16
int
SerialProgram::Run
()
17
{
18
// FunctionEntry("NAME"): Updates the user-defined stack and
19
// the program profiles with timing information. The placement
20
// of FunctionEntry and FunctionExit calls is at the developer's
21
// discretion.
22
FunctionEntry(
"Run"
);
23
24
// ---------- The Program -----------------
25
// This program just "copies" the input file
26
// to the output file.
27
//
28
29
// Open the specified input file for reading
30
Inf
.open(
input_name
.c_str());
31
if
(!
Inf
){
32
// If the input file failed to open, notify to
33
// the error stream and return non-zero
34
std::ostringstream Ostr;
35
Ostr <<
"Error: Could not open input file, '"
36
<<
input_name
<<
"'.\n"
;
37
ErrOut(Ostr.str());
38
// don't forget to tell the profiler/stacker the
39
// function is exiting.
40
FunctionExit(
"Run"
);
41
return
(1);
42
}
43
44
// Open the specified output file for writing
45
bool
use_outfile =
false
;
46
if
(!
output_name
.empty()){
47
use_outfile =
true
;
48
Ouf
.open(
output_name
.c_str());
49
if
(!
Ouf
){
50
// If the output file failed to open, notify
51
// to error stream and return non-zero
52
std::ostringstream Ostr;
53
Ostr <<
"Error: Unable to open output file, "
<<
output_name
<<
"."
;
54
ErrOut(Ostr.str());
55
// don't forget to tell the profiler/stacker the
56
// function is exiting.
57
FunctionExit(
"Run"
);
58
return
(1);
59
}
60
}
61
62
// Read lines from the input file and repeat them
63
// to the output file.
64
std::string line;
65
while
(std::getline(
Inf
,line)){
66
if
(use_outfile)
67
Ouf
<< line << std::endl;
68
else
69
StdOut(line+
"\n"
);
70
}
71
// Close both files
72
Ouf
.close();
73
Inf
.close();
74
75
//
76
// ---------- Program End -----------------
77
78
79
// Update the stacker/profiler that we are exiting
80
// this function.
81
FunctionExit(
"Run"
);
82
// return 0 for success
83
return
(0);
84
};
85
};
86
};
ElmerFoamFSI::ExampleProgram::SerialProgram::Ouf
std::ofstream Ouf
Outfile stream for output.
Definition:
include/ExampleProgram.H:168
ElmerFoamFSI::ExampleProgram::SerialProgram::input_name
std::string input_name
Name of input file.
Definition:
include/ExampleProgram.H:164
ElmerFoamFSI::ExampleProgram::SerialProgram::Inf
std::ifstream Inf
Infile stream for input.
Definition:
include/ExampleProgram.H:170
ElmerFoamFSI::ExampleProgram::SerialProgram::Run
virtual int Run()
This function implements the main function executed by the program.
Definition:
src/ExampleSerialProgram.C:16
ElmerFoamFSI::ExampleProgram::SerialProgram::output_name
std::string output_name
Name of file for output.
Definition:
include/ExampleProgram.H:162
src
ExampleSerialProgram.C
Generated on Mon Jul 25 2016 15:50:53 for ElmerFoamFSI by
1.8.5