23 #include "mbsim/objects/object.h" 24 #include <mbsim/functions/function.h> 30 namespace MBSimHydraulics {
34 class HydraulicEnvironment;
36 class HydlinePressureloss;
42 HLine(
const std::string &
name) :
MBSim::Object(
name), nFrom(
nullptr), nTo(
nullptr), nFromRelative(
false), nToRelative(
false), direction(
fmatvec::Vec(3, fmatvec::INIT, 0)), Mlocal(), QIn(1), QOut(1), Jacobian(), frameOfReference(
nullptr), updQ(
true), saved_frameOfReference(
"") { }
43 void calcSize()
override;
46 void updateh(
int j=0)
override { }
47 void updateJacobians(
int j=0) { }
48 void updateInverseKineticsJacobians() { }
49 std::shared_ptr<OpenMBV::Group> getOpenMBVGrp()
override {
return std::shared_ptr<OpenMBV::Group>(); }
53 void setFromNode(
HNode * nFrom_) {nFrom=nFrom_; }
54 void setToNode(
HNode * nTo_) {nTo=nTo_; }
55 void setDirection(
const fmatvec::Vec& dir) {direction=((nrm2(dir)>0)?dir/nrm2(dir):
fmatvec::Vec(3, fmatvec::INIT, 0)); }
56 HNode * getFromNode() {
return nFrom; }
57 HNode * getToNode() {
return nTo; }
58 void setOutflowRelative(
bool rel=
true) { nToRelative=rel; }
59 void setInflowRelative(
bool rel=
true) { nFromRelative=rel; }
60 virtual fmatvec::VecV getInflowFactor() {
return fmatvec::VecV(1, fmatvec::INIT, -1.); }
61 virtual fmatvec::VecV getOutflowFactor() {
return fmatvec::VecV(1, fmatvec::INIT, 1.); }
63 const fmatvec::VecV& evalQIn() {
if(updQ) updateQ();
return QIn; }
64 const fmatvec::VecV& evalQOut() {
if(updQ) updateQ();
return QOut; }
65 const fmatvec::VecV& getQIn(
bool check=
true)
const { assert((not check) or (not updQ));
return QIn; }
66 const fmatvec::VecV& getQOut(
bool check=
true)
const { assert((not check) or (not updQ));
return QOut; }
67 const fmatvec::MatV& getJacobian()
const {
return Jacobian; }
69 virtual void updateQ() { }
70 void updateM()
override {
M=Mlocal; }
72 void init(
InitStage stage,
const MBSim::InitConfigSet &config)
override;
73 void initializeUsingXML(xercesc::DOMElement *element)
override;
75 virtual Element* getDependency()
const {
return nullptr; }
77 void resetUpToDate()
override { MBSim::Object::resetUpToDate(); updQ =
true; }
85 bool nFromRelative, nToRelative;
86 fmatvec::VecV direction;
87 fmatvec::SymMatV Mlocal;
88 fmatvec::VecV QIn, QOut;
89 fmatvec::MatV Jacobian;
93 std::string saved_frameOfReference;
101 void setLength(
double length_) {length=length_; }
102 double getLength()
const {
return length; }
103 void addInflowDependencyOnOutflow(
RigidHLine* line);
104 void addInflowDependencyOnInflow(
RigidHLine* line);
106 void calcqSize()
override {
qSize=0; }
107 void calcuSize(
int j=0)
override {
uSize[j]=getGeneralizedVelocitySize(); }
108 fmatvec::Mat calculateJacobian(std::vector<RigidHLine*> dep_check);
110 void updatePressureLossGravity();
111 double evalPressureLossGravity() {
if(updPLG) updatePressureLossGravity();
return pressureLossGravity; }
113 void updateQ()
override;
114 void updateh(
int j=0)
override;
115 void updateM()
override;
117 void initializeUsingXML(xercesc::DOMElement *element)
override;
118 void init(
InitStage stage,
const MBSim::InitConfigSet &config)
override;
119 void plot()
override;
121 void resetUpToDate()
override { HLine::resetUpToDate(); updPLG =
true; }
124 double pressureLossGravity;
126 std::vector<RigidHLine*> dependencyOnOutflow, dependencyOnInflow;
127 std::vector<std::string> refDependencyOnOutflowString, refDependencyOnInflowString;
137 QFunction=QFunction_;
138 QFunction->setParent(
this);
142 void calcqSize()
override {
qSize=0; }
143 void calcuSize(
int j)
override {
uSize[j]=0; }
145 void updateQ()
override;
147 void initializeUsingXML(xercesc::DOMElement *element)
override;
148 void init(
InitStage stage,
const MBSim::InitConfigSet &config)
override;
159 void setQFunction(
MBSim::Function<
double(
double)> * QFunction_) { QFunction=QFunction_; }
161 void calcqSize()
override {
qSize=0; }
162 void calcuSize(
int j)
override {
uSize[j]=0; }
164 void updateQ()
override;
166 void initializeUsingXML(xercesc::DOMElement *element)
override;
167 void init(
InitStage stage,
const MBSim::InitConfigSet &config)
override;
178 void setInflowFunction(
MBSim::Function<
double(
double)> *inflowFunction_) { inflowFunction=inflowFunction_; }
179 void setOutflowFunction(
MBSim::Function<
double(
double)> *outflowFunction_) { outflowFunction=outflowFunction_; }
180 void setOpeningFunction(
MBSim::Function<
double(
double)> *openingFunction_) { openingFunction=openingFunction_; }
181 void setDiameter(
double diameter_) { diameter=diameter_; }
182 void setAlpha(
double alpha_) { alpha=alpha_; }
183 void setCalcAreaModus(
int calcAreaModus_) { calcAreaModus=calcAreaModus_; }
185 void calcqSize()
override {
qSize=0; }
186 void calcuSize(
int j)
override {
uSize[j]=0; }
188 void updateQ()
override;
190 void initializeUsingXML(xercesc::DOMElement *element)
override;
191 void init(
InitStage stage,
const MBSim::InitConfigSet &config)
override;
192 void plot()
override;
195 MBSim::Function<double(
double)> *inflowFunction{
nullptr}, *outflowFunction{
nullptr}, *openingFunction{
nullptr};
196 double diameter{0}, alpha{0.};
197 int calcAreaModus{0};
199 double pIn, pOut, dp, sign, opening, area, sqrt_dp;
Vector< Ref, double > Vec
void setName(const std::string &str)
Definition: environment.h:31
Element(const std::string &name)