41 #include "FGBuoyantForces.h" 42 #include "FGMassBalance.h" 43 #include "input_output/FGPropertyManager.h" 44 #include "input_output/FGXMLElement.h" 50 IDENT(IdSrc,
"$Id: FGBuoyantForces.cpp,v 1.30 2015/03/28 14:49:02 bcoconni Exp $");
51 IDENT(IdHdr,ID_BUOYANTFORCES);
59 Name =
"FGBuoyantForces";
63 vTotalForces.InitMatrix();
64 vTotalMoments.InitMatrix();
75 for (
unsigned int i=0; i<Cells.size(); i++)
delete Cells[i];
83 bool FGBuoyantForces::InitModel(
void)
85 if (!FGModel::InitModel())
return false;
87 vTotalForces.InitMatrix();
88 vTotalMoments.InitMatrix();
98 if (Holding)
return false;
99 if (NoneDefined)
return true;
103 vTotalForces.InitMatrix();
104 vTotalMoments.InitMatrix();
106 for (
unsigned int i=0; i<Cells.size(); i++) {
107 Cells[i]->Calculate(FDMExec->
GetDeltaT());
108 vTotalForces += Cells[i]->GetBodyForces();
109 vTotalMoments += Cells[i]->GetMoments();
129 gas_cell_element = document->
FindElement(
"gas_cell");
130 while (gas_cell_element) {
132 Cells.push_back(
new FGGasCell(FDMExec, gas_cell_element, Cells.size(), in));
136 PostLoad(document, PropertyManager);
151 for (
unsigned int i = 0; i < Cells.size(); i++) {
152 Gw += Cells[i]->GetMass();
162 vXYZgasCell_arm.InitMatrix();
163 for (
unsigned int i = 0; i < Cells.size(); i++) {
164 vXYZgasCell_arm += Cells[i]->GetMassMoment();
166 return vXYZgasCell_arm;
173 size_t size = Cells.size();
175 if (size == 0)
return gasCellJ;
179 for (
unsigned int i=0; i < size; i++) {
180 gasCellJ += Cells[i]->GetInertia();
190 string CoeffStrings =
"";
220 string SDValues =
"";
248 void FGBuoyantForces::bind(
void)
252 PropertyManager->
Tie(
"moments/l-buoyancy-lbsft",
this, eL,
254 PropertyManager->
Tie(
"moments/m-buoyancy-lbsft",
this, eM,
255 (PGF)&FGBuoyantForces::GetMoments, (PSF)0,
false);
256 PropertyManager->
Tie(
"moments/n-buoyancy-lbsft",
this, eN,
257 (PGF)&FGBuoyantForces::GetMoments, (PSF)0,
false);
258 PropertyManager->
Tie(
"forces/fbx-buoyancy-lbs",
this, eX,
260 PropertyManager->
Tie(
"forces/fby-buoyancy-lbs",
this, eY,
261 (PGF)&FGBuoyantForces::GetForces, (PSF)0,
false);
262 PropertyManager->
Tie(
"forces/fbz-buoyancy-lbs",
this, eZ,
263 (PGF)&FGBuoyantForces::GetForces, (PSF)0,
false);
285 void FGBuoyantForces::Debug(
int from)
287 if (debug_lvl <= 0)
return;
291 cout << endl <<
" Buoyant Forces: " << endl;
294 if (debug_lvl & 2 ) {
295 if (from == 0) cout <<
"Instantiated: FGBuoyantForces" << endl;
296 if (from == 1) cout <<
"Destroyed: FGBuoyantForces" << endl;
298 if (debug_lvl & 4 ) {
300 if (debug_lvl & 8 ) {
302 if (debug_lvl & 16) {
304 if (debug_lvl & 64) {
306 cout << IdSrc << endl;
307 cout << IdHdr << endl;
const FGColumnVector3 & GetGasMassMoment(void)
Gets the total moment from the gas mass.
Encapsulates the Buoyant forces calculations.
~FGBuoyantForces()
Destructor.
Element * FindElement(const std::string &el="")
Searches for a specified element.
std::string GetBuoyancyValues(const std::string &delimeter)
Gets the coefficient values.
virtual bool Run(bool Holding)
Runs the model; called by the Executive.
void Tie(const std::string &name, bool *pointer, bool useDefault=true)
Tie a property to an external bool variable.
const FGMatrix33 & GetGasMassInertia(void)
Gets the total moments of inertia for the gas mass in the body frame.
bool Run(bool Holding)
Runs the Buoyant forces model; called by the Executive Can pass in a value indicating if the executiv...
const FGColumnVector3 & GetMoments(void) const
Gets the total Buoyancy moment vector.
double GetGasMass(void) const
Gets the total gas mass.
Base class for all scheduled JSBSim models.
std::string GetBuoyancyStrings(const std::string &delimeter)
Gets the strings for the current set of gas cells.
const FGColumnVector3 & GetForces(void) const
Gets the total Buoyant force vector.
This class implements a 3 element column vector.
bool Load(Element *element)
Loads the Buoyant forces model.
Element * FindNextElement(const std::string &el="")
Searches for the next element as specified.
Handles matrix math operations.
void InitMatrix(void)
Initialize the matrix.
double GetDeltaT(void) const
Returns the simulation delta T.
Encapsulates the JSBSim simulation executive.
virtual bool Load(Element *el)
Loads this model.