Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "forceCoeffs.H"
00027 #include <OpenFOAM/dictionary.H>
00028 #include <OpenFOAM/Time.H>
00029 #include <OpenFOAM/Pstream.H>
00030
00031
00032
00033 namespace Foam
00034 {
00035 defineTypeNameAndDebug(forceCoeffs, 0);
00036 }
00037
00038
00039
00040
00041 Foam::forceCoeffs::forceCoeffs
00042 (
00043 const word& name,
00044 const objectRegistry& obr,
00045 const dictionary& dict,
00046 const bool loadFromFiles
00047 )
00048 :
00049 forces(name, obr, dict, loadFromFiles),
00050 liftDir_(vector::zero),
00051 dragDir_(vector::zero),
00052 pitchAxis_(vector::zero),
00053 magUInf_(0.0),
00054 lRef_(0.0),
00055 Aref_(0.0)
00056 {
00057 read(dict);
00058 }
00059
00060
00061
00062
00063 Foam::forceCoeffs::~forceCoeffs()
00064 {}
00065
00066
00067
00068
00069 void Foam::forceCoeffs::read(const dictionary& dict)
00070 {
00071 if (active_)
00072 {
00073 forces::read(dict);
00074
00075
00076 dict.lookup("liftDir") >> liftDir_;
00077 dict.lookup("dragDir") >> dragDir_;
00078 dict.lookup("pitchAxis") >> pitchAxis_;
00079
00080
00081 dict.lookup("magUInf") >> magUInf_;
00082
00083
00084 dict.lookup("lRef") >> lRef_;
00085 dict.lookup("Aref") >> Aref_;
00086 }
00087 }
00088
00089
00090 void Foam::forceCoeffs::writeFileHeader()
00091 {
00092 if (forcesFilePtr_.valid())
00093 {
00094 forcesFilePtr_()
00095 << "# Time" << tab << "Cd" << tab << "Cl" << tab << "Cm" << endl;
00096 }
00097 }
00098
00099
00100 void Foam::forceCoeffs::execute()
00101 {
00102
00103 }
00104
00105
00106 void Foam::forceCoeffs::end()
00107 {
00108
00109 }
00110
00111
00112 void Foam::forceCoeffs::write()
00113 {
00114 if (active_)
00115 {
00116
00117 makeFile();
00118
00119 forcesMoments fm = forces::calcForcesMoment();
00120
00121 scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
00122
00123 vector totForce = fm.first().first() + fm.first().second();
00124 vector totMoment = fm.second().first() + fm.second().second();
00125
00126 scalar liftForce = totForce & liftDir_;
00127 scalar dragForce = totForce & dragDir_;
00128 scalar pitchMoment = totMoment & pitchAxis_;
00129
00130 scalar Cl = liftForce/(Aref_*pDyn);
00131 scalar Cd = dragForce/(Aref_*pDyn);
00132 scalar Cm = pitchMoment/(Aref_*lRef_*pDyn);
00133
00134 if (Pstream::master())
00135 {
00136 forcesFilePtr_()
00137 << obr_.time().value() << tab
00138 << Cd << tab << Cl << tab << Cm << endl;
00139
00140 if (log_)
00141 {
00142 Info<< "forceCoeffs output:" << nl
00143 << " Cd = " << Cd << nl
00144 << " Cl = " << Cl << nl
00145 << " Cm = " << Cm << nl
00146 << endl;
00147 }
00148 }
00149 }
00150 }
00151
00152
00153