mbsimphysics  4.0.0
MBSim Physics Module
drag.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 _DRAG_H
20#define _DRAG_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 Drag(const std::string &name="");
37 ~Drag() 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 setDragFunction(MBSim::Function<double(double)> *func);
48
49 void updateGeneralizedPositions() override { updrrel = false; }
50 void updateGeneralizedVelocities() override { updvrel = false; }
51 void updatelaF() override;
52
53 bool isActive() const override { return true; }
54 bool gActiveChanged() override { return false; }
55 bool isSingleValued() const override { return true; }
56
57 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))) {
58 ombvArrow = std::shared_ptr<MBSim::OpenMBVInteractionArrow>(new MBSim::OpenMBVInteractionArrow(sideOfInteraction,scaleLength,scaleSize,MBSim::OpenMBVArrow::toHead,referencePoint,colorRepresentation,minimalColorValue,maximalColorValue,diffuseColor,transparency,pointSize,lineWidth));
59 }
60
61 protected:
62 MBSim::Function<double(double)> *fdrag{nullptr};
63
64 std::shared_ptr<MBSim::OpenMBVInteractionArrow> ombvArrow;
65 std::vector<std::shared_ptr<OpenMBV::Arrow>> openMBVForce;
66 };
67
68}
69
70#endif
Definition: drag.h:34
std::string name