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