23 #include "mbsim/link.h"
24 #include "mbsim/utils/function.h"
26 #ifdef HAVE_OPENMBVCPPINTERFACE
34 class GeneralizedForceLaw;
35 class GeneralizedImpactLaw;
38 namespace MBSimControl {
42 namespace MBSimHydraulics {
55 class HNode :
public MBSim::Link {
57 HNode(
const std::string &name);
59 virtual std::string getType()
const {
return "HNode"; }
61 #ifdef HAVE_OPENMBVCPPINTERFACE
62 virtual void enableOpenMBV(
double size=1,
double pMin=0e5,
double pMax=10e5, fmatvec::Vec WrON=fmatvec::Vec(3));
65 void addInFlow(
HLine * in);
66 void addOutFlow(
HLine * out);
68 void calcgdSize(
int j) {gdSize=1; }
70 void init(MBSim::InitStage stage);
72 virtual void updateWRef(
const fmatvec::Mat& WRef,
int i=0);
73 virtual void updateVRef(
const fmatvec::Mat& VRef,
int i=0);
74 virtual void updatehRef(
const fmatvec::Vec& hRef,
int i=0);
75 virtual void updaterRef(
const fmatvec::Vec& rRef,
int i=0);
76 virtual void updatedhdqRef(
const fmatvec::Mat& dhdqRef,
int i=0);
77 virtual void updatedhduRef(
const fmatvec::SqrMat& dhduRef,
int i=0);
78 virtual void updatedhdtRef(
const fmatvec::Vec& dhdtRef,
int i=0);
80 void updateh(
double t,
int j=0);
81 void updatedhdz(
double t);
82 virtual void updater(
double t,
int j);
83 virtual void updateg(
double t) {};
84 virtual void updategd(
double t);
85 virtual bool isActive()
const {
return false; }
86 virtual bool gActiveChanged() {
return false; }
88 void plot(
double t,
double dt);
90 void initializeUsingXML(TiXmlElement *element);
93 std::vector<connectedLinesStruct> connectedLines;
94 std::vector<connectedLinesStruct> connected0DOFLines;
95 std::vector<std::string> refInflowString;
96 std::vector<std::string> refOutflowString;
99 #ifdef HAVE_OPENMBVCPPINTERFACE
100 OpenMBV::Group * openMBVGrp;
101 OpenMBV::Sphere * openMBVSphere;
111 virtual std::string getType()
const {
return "ConstrainedNode"; }
113 void setpFunction(MBSim::Function1<double,double> * pFun_) {pFun=pFun_; }
115 void updateg(
double t);
116 void init(MBSim::InitStage stage);
117 void initializeUsingXML(TiXmlElement *element);
120 MBSim::Function1<double,double> * pFun;
128 virtual std::string getType()
const {
return "EnvironmentNode"; }
130 void init(MBSim::InitStage stage);
137 ElasticNode(
const std::string &name) :
HNode(name), V(0), E(0), fracAir(0), p0(0), bulkModulus(NULL) {}
139 virtual std::string getType()
const {
return "ElasticNode"; }
141 void setVolume(
double V_) {V=V_; }
142 void setFracAir(
double fracAir_) {fracAir=fracAir_; }
143 void setp0(
double p0_) {p0=p0_; }
145 void calcxSize() {xSize=1; }
147 void init(MBSim::InitStage stage);
148 void initializeUsingXML(TiXmlElement *element);
150 void updatexRef(
const fmatvec::Vec &xParent);
152 void updatexd(
double t);
153 void updatedx(
double t,
double dt);
155 void plot(
double t,
double dt);
170 virtual std::string getType()
const {
return "RigidNode"; }
172 bool isSetValued()
const {
return true; }
173 virtual bool isActive()
const {
return true; }
175 void calclaSize(
int j) {laSize=1; }
177 void calcrFactorSize(
int j) {rFactorSize=1; }
179 void updategd(
double t);
180 void updateW(
double t,
int j=0);
182 void updaterFactors();
183 void solveImpactsFixpointSingle(
double dt);
184 void solveConstraintsFixpointSingle();
185 void solveImpactsGaussSeidel(
double dt);
186 void solveConstraintsGaussSeidel();
187 void solveImpactsRootFinding(
double dt);
188 void solveConstraintsRootFinding();
189 void jacobianImpacts();
190 void jacobianConstraints();
191 void checkImpactsForTermination(
double dt);
192 void checkConstraintsForTermination();
195 MBSim::GeneralizedForceLaw * gfl;
196 MBSim::GeneralizedImpactLaw * gil;
205 virtual std::string getType()
const {
return "RigidCavitationNode"; }
207 void setCavitationPressure(
double pCav_) {pCav=pCav_; }
209 bool isSetValued()
const {
return true; }
210 bool hasSmoothPart()
const {
return true; }
211 virtual bool isActive()
const {
return active; }
213 void calcxSize() {xSize=1; }
214 void calcgSize(
int j) {gSize=1; }
216 void calclaSize(
int j) {laSize=1; }
218 void calcrFactorSize(
int j) {rFactorSize=1; }
219 void calcsvSize() {svSize=1; }
221 void init(MBSim::InitStage stage);
222 void initializeUsingXML(TiXmlElement *element);
223 void plot(
double t,
double dt);
225 void checkActive(
int j);
227 bool gActiveChanged();
229 void updateg(
double t);
230 void updateh(
double t,
int j=0);
231 void updateStopVector(
double t);
232 void updateW(
double t,
int j=0);
233 void updatexd(
double t);
234 void updatedx(
double t,
double dt);
237 void updaterFactors();
238 void solveImpactsFixpointSingle(
double dt);
239 void solveConstraintsFixpointSingle();
240 void solveImpactsGaussSeidel(
double dt);
241 void solveConstraintsGaussSeidel();
242 void solveImpactsRootFinding(
double dt);
243 void solveConstraintsRootFinding();
244 void jacobianImpacts();
245 void jacobianConstraints();
246 void checkImpactsForTermination(
double dt);
247 void checkConstraintsForTermination();
251 bool active, active0;
253 MBSim::GeneralizedForceLaw * gfl;
254 MBSim::GeneralizedImpactLaw * gil;
261 PressurePump(
const std::string &name) :
HNode(name), pSignal(NULL), pSignalString(
"") {}
262 virtual std::string getType()
const {
return "PressurePump"; }
264 void setpSignal(MBSimControl::Signal * pSignal_) {pSignal=pSignal_; }
266 void updateg(
double t);
267 void init(MBSim::InitStage stage);
268 void initializeUsingXML(TiXmlElement *element);
271 MBSimControl::Signal * pSignal;
272 std::string pSignalString;