mbsimphysics  4.0.0
MBSim Physics Module
aerodynamics.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 _AERODYNAMICS_H
20#define _AERODYNAMICS_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
27namespace MBSim {
28 class Frame;
29 template <class Sig> class Function;
30}
31
32namespace MBSimPhysics {
33
35 public:
36 Aerodynamics(const std::string &name="");
37 ~Aerodynamics() 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 setDensityFunction(MBSim::Function<double(double)> *func);
48 void setCoefficientFunction(MBSim::Function<fmatvec::Vec3(fmatvec::Vec2)> *func);
49 void setReferenceSurface(double A_) { A = A_; }
50 void setWindSpeed(const fmatvec::Vec3 &vW_) { vW <<= vW_; }
51
52 void updateGeneralizedPositions() override { updrrel = false; }
53 void updateGeneralizedVelocities() override { updvrel = false; }
54 void updatelaF() override;
55
56 bool isActive() const override { return true; }
57 bool gActiveChanged() override { return false; }
58 bool isSingleValued() const override { return true; }
59
60 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))) {
61 ombvArrow = std::shared_ptr<MBSim::OpenMBVInteractionArrow>(new MBSim::OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,MBSim::OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
62 }
63
64 protected:
65 MBSim::Function<double(double)> * frho{nullptr};
66 MBSim::Function<fmatvec::Vec3(fmatvec::Vec2)> * fc{nullptr};
67 double A{1};
68 fmatvec::Vec3 vW;
69
70 std::shared_ptr<MBSim::OpenMBVInteractionArrow> ombvArrow;
71 std::vector<std::shared_ptr<OpenMBV::Arrow>> openMBVForce;
72 };
73
74}
75
76#endif
Definition: aerodynamics.h:34
std::string name