12 #include "yaml-cpp/yaml.h" 31 for (
int i=0; i<2; i++)
32 Body.
X0[i] = node[
"centerRotation"][i].as<
real>(0.0);
34 for (
int i=0; i<2; i++)
36 Body.
Xc0[i] = node[
"initialOffset"][i].as<
real>(0.0);
37 Body.
Xc[i] = Body.
Xc0[i];
40 Body.
Theta0 = node[
"angleOfAttack"].as<
real>(0.0) * M_PI / 180.0;
43 for (
int i=0; i<2; i++)
44 Body.
moving[i] = node[
"moving"][i].as<
bool>(
false);
46 for (
int i=0; i<2; i++)
51 for (
int i=0; i<3; i++)
55 for (
int i=0; i<3; i++)
59 for (
int i=0; i<3; i++)
65 std::string type = node[
"type"].as<std::string>();
68 std::string fileName = node[
"pointsFile"].as<std::string>();
69 std::string folderPath = DB[
"inputs"][
"caseFolder"].get<std::string>();
70 std::ifstream inFile((folderPath +
"/" + fileName).c_str());
75 inFile >> Body.
X[i] >> Body.
Y[i];
78 else if (type ==
"lineSegment")
80 real startX = node[
"segmentOptions"][0].as<
real>();
81 real endX = node[
"segmentOptions"][1].as<
real>();
82 real startY = node[
"segmentOptions"][2].as<
real>();
83 real endY = node[
"segmentOptions"][3].as<
real>();
84 int numPoints = node[
"segmentOptions"][4].as<
int>();
88 else if (type ==
"circle")
90 real cx = node[
"circleOptions"][0].as<
real>();
91 real cy = node[
"circleOptions"][1].as<
real>();
92 real R = node[
"circleOptions"][2].as<
real>();
93 int numPoints = node[
"circleOptions"][3].as<
int>();
96 Body.
X.resize(numPoints);
97 Body.
Y.resize(numPoints);
100 Body.
X[i] = cx + R*cos(i*2*M_PI/Body.
numPoints);
101 Body.
Y[i] = cy + R*sin(i*2*M_PI/Body.
numPoints);
106 printf(
"Error: Unknown body type '%s'!\n", type.c_str());
119 if (!std::ifstream(bodiesFile.c_str()))
121 if (DB[
"simulation"][
"ibmScheme"].get<ibmScheme>() !=
NAVIER_STOKES)
123 printf(
"Error: Missing YAML file bodies.yaml!\n");
128 printf(
"Parsing YAML file with bodies info ...\n");
129 YAML::Node nodes = YAML::LoadFile(bodiesFile);
131 std::vector<body> *B = DB[
"flow"][
"bodies"].get<std::vector<body> *>();
132 for (
int i=0; i<nodes.size(); i++)
real xOscillation[3]
amplitude, angular frequency and phase difference of oscillation in the x-direction ...
Definition of the class body.
double real
Is a float or a double depending on the machine precision.
real pitchOscillation[3]
amplitude, angular frequency and phase difference of pitch oscillation
vecH Y
reference y-coordinate of boundary points
Contains information about an immersed boundary in the flow.
Declaration of the functions of the namespace io.
std::map< std::string, componentParameter > parameterDB
Map from a string to a componentParameter.
Contains functions related to I/O tasks.
vecH X
reference x-coordinate of boundary points
no immersed bodies - Perot (1993)
real X0[2]
reference center of rotation
real Theta0
initial angle of attack
real Xc[2]
actual center of rotation (x- and y-coordinates)
real Theta
actual angle of attack (counterclockwise is positive)
real omega
uniform rotational velocity
real velocity[2]
uniform translational velocity (x- and y-components)
void parseBodiesFile(std::string &bodiesFile, parameterDB &DB)
Parses the bodies.yaml file and stores information about the immersed bodies.
bool moving[2]
flag to indicate if the body is moving (translating or rotating)
int numPoints
number of boundary points
real Xc0[2]
initial position of center of rotation
void parseBodiesNode(const YAML::Node &node, body &Body, parameterDB &DB)
Overloads the operator >>. Stores information about an immersed body.
void reset()
Resets the position and motion of the body.
real yOscillation[3]
amplitude, angular frequency and phase difference of oscillation in the y-direction ...