|
mbsimhydraulics
4.0.0
|
00001 /* Copyright (C) 2004-2009 MBSim Development Team 00002 * 00003 * This library is free software; you can redistribute it and/or 00004 * modify it under the terms of the GNU Lesser General Public 00005 * License as published by the Free Software Foundation; either 00006 * version 2.1 of the License, or (at your option) any later version. 00007 * 00008 * This library is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public 00014 * License along with this library; if not, write to the Free Software 00015 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00016 * 00017 * Contact: markus.ms.schneider@gmail.com 00018 */ 00019 00020 #ifndef _HNODE_H_ 00021 #define _HNODE_H_ 00022 00023 #include "mbsim/link.h" 00024 #include <fmatvec/function.h> 00025 00026 #ifdef HAVE_OPENMBVCPPINTERFACE 00027 #include <mbsim/utils/boost_parameters.h> 00028 #include <mbsim/utils/openmbv_utils.h> 00029 namespace OpenMBV { 00030 class Group; 00031 class Sphere; 00032 } 00033 #endif 00034 00035 namespace MBSim { 00036 class GeneralizedForceLaw; 00037 class GeneralizedImpactLaw; 00038 } 00039 00040 namespace MBSimControl { 00041 class Signal; 00042 } 00043 00044 namespace MBSimHydraulics { 00045 00046 BOOST_PARAMETER_NAME(size) 00047 BOOST_PARAMETER_NAME(minimalPressure) 00048 BOOST_PARAMETER_NAME(maximalPressure) 00049 BOOST_PARAMETER_NAME(position) 00050 00051 class HLine; 00052 class HydFluid; 00053 class OilBulkModulus; 00054 00055 struct connectedLinesStruct { 00056 HLine * line; 00057 fmatvec::Vec sign; 00058 bool inflow; 00059 }; 00060 00062 class HNode : public MBSim::Link { 00063 public: 00064 HNode(const std::string &name); 00065 ~HNode() {}; 00066 virtual std::string getType() const { return "HNode"; } 00067 00068 #ifdef HAVE_OPENMBVCPPINTERFACE 00069 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVSphere, tag, (optional (size,(double),1)(minimalPressure,(double),0e5)(maximalPressure,(double),10e5)(position,(const fmatvec::Vec3&),fmatvec::Vec3()))) { 00070 enableOpenMBV(size,minimalPressure,maximalPressure,position); 00071 } 00072 virtual void enableOpenMBV(double size, double pMin, double pMax, const fmatvec::Vec3 &WrON); 00073 #endif 00074 00075 void addInFlow(HLine * in); 00076 void addOutFlow(HLine * out); 00077 00078 void calcgdSize(int j) {gdSize=1; } 00079 00080 void init(InitStage stage); 00081 00082 virtual void updateWRef(const fmatvec::Mat& WRef, int i=0); 00083 virtual void updateVRef(const fmatvec::Mat& VRef, int i=0); 00084 virtual void updatehRef(const fmatvec::Vec& hRef, int i=0); 00085 virtual void updaterRef(const fmatvec::Vec& rRef, int i=0); 00086 virtual void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0); 00087 virtual void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0); 00088 virtual void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0); 00089 00090 void updateh(double t, int j=0); 00091 void updatedhdz(double t); 00092 virtual void updater(double t, int j); 00093 virtual void updateg(double t) {}; 00094 virtual void updategd(double t); 00095 virtual bool isActive() const {return false; } 00096 virtual bool gActiveChanged() {return false; } 00097 00098 00099 void plot(double t, double dt); 00100 00101 void initializeUsingXML(xercesc::DOMElement *element); 00102 00103 protected: 00104 std::vector<connectedLinesStruct> connectedLines; 00105 std::vector<connectedLinesStruct> connected0DOFLines; 00106 std::vector<std::string> refInflowString; 00107 std::vector<std::string> refOutflowString; 00108 double QHyd; 00109 unsigned int nLines; 00110 #ifdef HAVE_OPENMBVCPPINTERFACE 00111 OpenMBV::Group * openMBVGrp; 00112 OpenMBV::Sphere * openMBVSphere; 00113 fmatvec::Vec3 WrON; 00114 #endif 00115 }; 00116 00117 00119 class ConstrainedNode : public HNode { 00120 public: 00121 ConstrainedNode(const std::string &name="") : HNode(name), pFun(NULL) {} 00122 ~ConstrainedNode() { delete pFun; } 00123 virtual std::string getType() const { return "ConstrainedNode"; } 00124 00125 void setpFunction(fmatvec::Function<double(double)> * pFun_) {pFun=pFun_; } 00126 00127 void updateg(double t); 00128 void init(InitStage stage); 00129 void initializeUsingXML(xercesc::DOMElement *element); 00130 virtual bool isSingleValued() const {return true;} 00131 00132 private: 00133 fmatvec::Function<double(double)> * pFun; 00134 }; 00135 00136 00138 class EnvironmentNode : public HNode { 00139 public: 00140 EnvironmentNode(const std::string &name="") : HNode(name) {} 00141 virtual std::string getType() const { return "EnvironmentNode"; } 00142 00143 void init(InitStage stage); 00144 00145 virtual bool isSingleValued() const {return true;} 00146 }; 00147 00148 00150 class ElasticNode : public HNode { 00151 public: 00152 ElasticNode(const std::string &name="") : HNode(name), V(0), E(0), fracAir(0), p0(0), bulkModulus(NULL) {} 00153 ~ElasticNode(); 00154 virtual std::string getType() const { return "ElasticNode"; } 00155 00156 void setVolume(double V_) {V=V_; } 00157 void setFracAir(double fracAir_) {fracAir=fracAir_; } 00158 void setp0(double p0_) {p0=p0_; } 00159 00160 void calcxSize() {xSize=1; } 00161 00162 void init(InitStage stage); 00163 void initializeUsingXML(xercesc::DOMElement *element); 00164 00165 void updatexRef(const fmatvec::Vec &xParent); 00166 00167 void updatexd(double t); 00168 void updatedx(double t, double dt); 00169 00170 void plot(double t, double dt); 00171 00172 virtual bool isSingleValued() const {return true;} 00173 00174 private: 00175 double V, E; 00176 double fracAir; 00177 double p0; 00178 OilBulkModulus * bulkModulus; 00179 }; 00180 00181 00183 class RigidNode : public HNode { 00184 public: 00185 RigidNode(const std::string &name=""); 00186 ~RigidNode(); 00187 virtual std::string getType() const { return "RigidNode"; } 00188 00189 bool isSetValued() const {return true; } 00190 virtual bool isActive() const {return true; } 00191 00192 void calclaSize(int j) {laSize=1; } 00193 //void calclaSizeForActiveg() {laSize=0; } 00194 void calcrFactorSize(int j) {rFactorSize=1; } 00195 00196 void updategd(double t); 00197 void updateW(double t, int j=0); 00198 00199 void updaterFactors(); 00200 void solveImpactsFixpointSingle(double dt); 00201 void solveConstraintsFixpointSingle(); 00202 void solveImpactsGaussSeidel(double dt); 00203 void solveConstraintsGaussSeidel(); 00204 void solveImpactsRootFinding(double dt); 00205 void solveConstraintsRootFinding(); 00206 void jacobianImpacts(); 00207 void jacobianConstraints(); 00208 void checkImpactsForTermination(double dt); 00209 void checkConstraintsForTermination(); 00210 private: 00211 double gdn, gdd; 00212 MBSim::GeneralizedForceLaw * gfl; 00213 MBSim::GeneralizedImpactLaw * gil; 00214 }; 00215 00216 00218 class RigidCavitationNode : public HNode { 00219 public: 00220 RigidCavitationNode(const std::string &name=""); 00221 ~RigidCavitationNode(); 00222 virtual std::string getType() const { return "RigidCavitationNode"; } 00223 00224 void setCavitationPressure(double pCav_) {pCav=pCav_; } 00225 00226 bool isSetValued() const {return true; } 00227 bool hasSmoothPart() const {return true; } 00228 virtual bool isActive() const {return active; } 00229 00230 void calcxSize() {xSize=1; } 00231 void calcgSize(int j) {gSize=1; } 00232 //void calcgSizeActive() {gSize=0; } 00233 void calclaSize(int j) {laSize=1; } 00234 //void calclaSizeForActiveg() {laSize=0; } 00235 void calcrFactorSize(int j) {rFactorSize=1; } 00236 void calcsvSize() {svSize=1; } 00237 00238 void init(InitStage stage); 00239 void initializeUsingXML(xercesc::DOMElement *element); 00240 void plot(double t, double dt); 00241 00242 void checkActive(int j); 00243 //void checkActivegdn(); 00244 bool gActiveChanged(); 00245 00246 void updateg(double t); 00247 void updateh(double t, int j=0); 00248 void updateStopVector(double t); 00249 void updateW(double t, int j=0); 00250 void updatexd(double t); 00251 void updatedx(double t, double dt); 00252 void checkRoot(); 00253 00254 void updaterFactors(); 00255 void solveImpactsFixpointSingle(double dt); 00256 void solveConstraintsFixpointSingle(); 00257 void solveImpactsGaussSeidel(double dt); 00258 void solveConstraintsGaussSeidel(); 00259 void solveImpactsRootFinding(double dt); 00260 void solveConstraintsRootFinding(); 00261 void jacobianImpacts(); 00262 void jacobianConstraints(); 00263 void checkImpactsForTermination(double dt); 00264 void checkConstraintsForTermination(); 00265 protected: 00266 double pCav; 00267 private: 00268 bool active, active0; 00269 double gdn, gdd; 00270 MBSim::GeneralizedForceLaw * gfl; 00271 MBSim::GeneralizedImpactLaw * gil; 00272 }; 00273 00274 00276 class PressurePump : public HNode { 00277 public: 00278 PressurePump(const std::string &name="") : HNode(name), pSignal(NULL), pSignalString("") {} 00279 virtual std::string getType() const { return "PressurePump"; } 00280 00281 void setpSignal(MBSimControl::Signal * pSignal_) {pSignal=pSignal_; } 00282 00283 void updateg(double t); 00284 void init(InitStage stage); 00285 void initializeUsingXML(xercesc::DOMElement *element); 00286 00287 private: 00288 MBSimControl::Signal * pSignal; 00289 std::string pSignalString; 00290 }; 00291 00292 } 00293 00294 #endif /* ----- #ifndef _HYDNODE_H_ ----- */ 00295
1.8.0