mbsimphysics  4.0.0
MBSim Physics Module
buoyancy.h
1 /* Copyright (C) 2004-2018 MBSim Development Team
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * Contact: martin.o.foerg@googlemail.com
17  */
18 
19 #ifndef _BUOYANCY_H
20 #define _BUOYANCY_H
21 
22 #include "mbsim/links/floating_frame_link.h"
23 
24 #include "mbsim/utils/boost_parameters.h"
25 #include "mbsim/utils/openmbv_utils.h"
26 
27 namespace MBSim {
28  class Frame;
29  template <class Sig> class Function;
30 }
31 
32 namespace MBSimPhysics {
33 
35  public:
36  Buoyancy(const std::string &name="");
37  ~Buoyancy() override;
38  void init(InitStage stage, const MBSim::InitConfigSet &config) override;
39  void initializeUsingXML(xercesc::DOMElement *element) override;
40 
41  void plot() override;
42 
43  using FloatingFrameLink::connect;
44 
45  void connect(MBSim::Frame *frame_) { frame[1] = frame_; }
46 
47  void setDisplacedVolume(double V_) { V = V_; }
48  void setDensityFunction(MBSim::Function<double(double)> *func);
49  void setGravityFunction(MBSim::Function<double(double)> *func);
50 
51  void updateGeneralizedPositions() override { updrrel = false; }
52  void updateGeneralizedVelocities() override { updvrel = false; }
53  void updatelaF() override;
54 
55  bool isActive() const override { return true; }
56  bool gActiveChanged() override { return false; }
57  bool isSingleValued() const override { return true; }
58 
59  BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, MBSim::tag, (optional (sideOfInteraction,(MBSim::OpenMBVInteractionArrow::SideOfInteraction),MBSim::OpenMBVInteractionArrow::action)(scaleLength,(double),1)(scaleSize,(double),1)(referencePoint,(MBSim::OpenMBVArrow::ReferencePoint),MBSim::OpenMBVArrow::toPoint)(colorRepresentation,(MBSim::OpenMBVArrow::ColorRepresentation),MBSim::OpenMBVArrow::none)(minimalColorValue,(double),0)(maximalColorValue,(double),1)(diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
60  ombvArrow = std::shared_ptr<MBSim::OpenMBVInteractionArrow>(new MBSim::OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,MBSim::OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
61  }
62 
63  protected:
64  double V{0};
65  MBSim::Function<double(double)> *frho{nullptr};
66  MBSim::Function<double(double)> *fg{nullptr};
67 
68  std::shared_ptr<MBSim::OpenMBVInteractionArrow> ombvArrow;
69  std::vector<std::shared_ptr<OpenMBV::Arrow>> openMBVForce;
70  };
71 
72 }
73 
74 #endif
Definition: buoyancy.h:34
Definition: aerodynamics.h:29
std::string name