Loading...
Searching...
No Matches
lift_and_drag.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ██╗████████╗██╗ ██╗ █████╗ ██████╗ █████╗ ███████╗██╗ ██╗
3 ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗ ██╔════╝██║ ██║
4 ██║ ██║ ███████║███████║██║ ███████║█████╗█████╗ ██║ ██║
5 ██║ ██║ ██╔══██║██╔══██║██║ ██╔══██║╚════╝██╔══╝ ╚██╗ ██╔╝
6 ██║ ██║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ╚████╔╝
7 ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═══╝
8
9 * In real Time Highly Advanced Computational Applications for Finite Volumes
10 * Copyright (C) 2017 by the ITHACA-FV authors
11-------------------------------------------------------------------------------
12
13License
14 This file is part of OpenFOAM.
15
16 OpenFOAM is free software: you can redistribute it and/or modify it
17 under the terms of the GNU General Public License as published by
18 the Free Software Foundation, either version 3 of the License, or
19 (at your option) any later version.
20
21 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28
29Application
30 lift_and_drag
31
32Author
33 Giovanni Stabile, SISSA MathLab (International School for Advanced Studies) gstabile@sissa.it
34
35Description
36 Application to recover the lift and the drag after the simulation is performed
37
38\*---------------------------------------------------------------------------*/
39
44
47
48#include "fvCFD.H"
49#include "IOmanip.H"
50#include "IFstream.H"
51#include "primitiveFields.H"
52#include "FieldFields.H"
53#include "scalarMatrices.H"
54#include "SortableList.H"
55#include "volFieldsFwd.H"
56#include "forces.H"
57#include "forceCoeffs.H"
58#include "volFields.H"
59#include <iostream>
60#include <fstream>
61#include <sstream>
62#include <vector>
63#include <string>
64#include <stdio.h>
65// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66
67
68int main(int argc, char *argv[])
69{
70
71#include "setRootCase.H"
72#include "createTime.H"
73#include "createMesh.H"
74
75 Info << argv[0] << endl;
76
77 instantList Times = runTime.times();
78
79 runTime.setTime(Times[2], 2);
80
81 //Read FORCESdict
82 IOdictionary FORCESdict
83 (
84 IOobject
85 (
86 "FORCESdict",
87 runTime.system(),
88 mesh,
89 IOobject::MUST_READ,
90 IOobject::NO_WRITE
91 )
92 );
93
94 IOdictionary transportProperties
95 (
96 IOobject
97 (
98 "transportProperties",
99 runTime.constant(),
100 mesh,
101 IOobject::MUST_READ,
102 IOobject::NO_WRITE
103 )
104 );
105
106 word pName(FORCESdict.lookup("pName"));
107 word UName(FORCESdict.lookup("UName"));
108
109 dictionary forcesDict;
110 forcesDict.add("type", functionObjects::forces::typeName);
111 forcesDict.add("patches", FORCESdict.lookup("patches"));
112 forcesDict.add("origin", FORCESdict.lookup("pitchAxis"));
113 forcesDict.add("pitchAxis", FORCESdict.lookup("pitchAxis"));
114 forcesDict.add("CofR", FORCESdict.lookup("CofR"));
115 forcesDict.add("liftDir", FORCESdict.lookup("liftDir"));
116 forcesDict.add("dragDir", FORCESdict.lookup("dragDir"));
117 forcesDict.add("magUInf", FORCESdict.lookup("magUInf"));
118 forcesDict.add("lRef", FORCESdict.lookup("lRef"));
119 forcesDict.add("Aref", FORCESdict.lookup("Aref"));
120 forcesDict.add("rhoInf", FORCESdict.lookup("rhoInf"));
121 forcesDict.add("rho", FORCESdict.lookup("rho"));
122
123 functionObjects::forceCoeffs fc("FC", runTime, forcesDict);
124 functionObjects::forces f("Forces", mesh, forcesDict);
125
126 for (label i = 2; i < Times.size(); i++)
127 {
128 runTime.setTime(Times[i], i);
129 mesh.readUpdate();
130
131 volVectorField U
132 (
133 IOobject
134 (
135 UName,
136 runTime.timeName(),
137 mesh,
138 IOobject::MUST_READ
139 ),
140 mesh
141 );
142
143 U.rename("U");
144
145 volScalarField P
146 (
147 IOobject
148 (
149 pName,
150 runTime.timeName(),
151 mesh,
152 IOobject::MUST_READ
153 ),
154 mesh
155 );
156
157 P.rename("p");
158
159 fc.execute();
160 fc.write();
161 f.write();
162 }
163 Info << endl;
164 Info << "End\n" << endl;
165 return 0;
166}
167
Foam::fvMesh & mesh
Definition createMesh.H:47
Foam::Time & runTime
Definition createTime.H:33
int main(int argc, char *argv[])
volVectorField & U
IOdictionary transportProperties(IOobject("transportProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE))
label i
Definition pEqn.H:46