|
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_MEC_H_ 00021 #define _HNODE_MEC_H_ 00022 00023 #include "hnode.h" 00024 #include <fmatvec/function.h> 00025 00026 namespace MBSim { 00027 class Frame; 00028 class GeneralizedForceLaw; 00029 class GeneralizedImpactLaw; 00030 } 00031 00032 namespace MBSimHydraulics { 00033 00034 class HydFluid; 00035 class OilBulkModulus; 00036 00037 struct connectedTransFrameStruct { 00038 MBSim::Frame * frame; 00039 fmatvec::Vec normal; 00040 double area; 00041 bool considerVolumeChange; 00042 }; 00043 00044 struct connectedRotFrameStruct { 00045 MBSim::Frame * frame; 00046 fmatvec::Vec normal; 00047 MBSim::Frame * fref; 00048 double area; 00049 bool considerVolumeChange; 00050 }; 00051 00053 class HNodeMec : public HNode { 00054 public: 00055 HNodeMec(const std::string &name); 00056 ~HNodeMec(); 00057 virtual std::string getType() const { return "HNodeMec"; } 00058 00059 #ifdef HAVE_OPENMBVCPPINTERFACE 00060 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBVArrows, tag, (optional (size,(double),1))) { 00061 openMBVArrowSize=(size>.0)?size:.0; 00062 } 00063 #endif 00064 00065 void setInitialVolume(double V0_) {V0=V0_; } 00066 unsigned int addTransMecArea(MBSim::Frame * f, fmatvec::Vec fN, double area, bool considerVolumeChange=true); 00067 unsigned int addRotMecArea(MBSim::Frame * f, fmatvec::Vec fN, double area, MBSim::Frame * frameOfReference, bool considerVolumeChange=true); 00068 void setTransMecArea(unsigned int i, double area) {connectedTransFrames[i].area=area; } 00069 00070 void calcxSize() {xSize=1; } 00071 00072 void init(InitStage stage); 00073 void initializeUsingXML(xercesc::DOMElement *element); 00074 00075 virtual void updateWRef(const fmatvec::Mat& Wref, int i=0); 00076 virtual void updateVRef(const fmatvec::Mat& Vref, int i=0); 00077 virtual void updatehRef(const fmatvec::Vec& href, int i=0); 00078 virtual void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0); 00079 virtual void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0); 00080 virtual void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0); 00081 virtual void updaterRef(const fmatvec::Vec& ref, int i=0); 00082 00083 void updateh(double t, int j=0); 00084 void updatedhdz(double t); 00085 virtual void updater(double t, int j=0); 00086 void updategd(double t); 00087 void updatexd(double t); 00088 void updatedx(double t, double dt); 00089 00090 void plot(double t, double dt); 00091 00092 protected: 00093 std::vector<connectedTransFrameStruct> connectedTransFrames; 00094 std::vector<connectedRotFrameStruct> connectedRotFrames; 00095 double QMecTrans, QMecRot, QMec; 00096 double V0; 00097 unsigned int nTrans, nRot; 00098 #ifdef HAVE_OPENMBVCPPINTERFACE 00099 std::vector<OpenMBV::Arrow *> openMBVArrows; 00100 double openMBVArrowSize; 00101 #endif 00102 00103 private: 00104 std::vector<std::string> saved_translatorial_frameOfReference, saved_rotatorial_frameOfReference, saved_rotatorial_frameOfRotationCenter; 00105 std::vector<fmatvec::Vec> saved_translatorial_normal, saved_rotatorial_normal; 00106 std::vector<double> saved_translatorial_area, saved_rotatorial_area; 00107 std::vector<bool> saved_translatorial_noVolumeChange, saved_rotatorial_noVolumeChange; 00108 }; 00109 00111 class ConstrainedNodeMec : public HNodeMec { 00112 public: 00113 ConstrainedNodeMec(const std::string &name="") : HNodeMec(name), pFun(NULL) {} 00114 ~ConstrainedNodeMec() { delete pFun; } 00115 virtual std::string getType() const { return "ConstrainedNodeMec"; } 00116 00117 void setpFunction(fmatvec::Function<double(double)> * pFun_) {pFun=pFun_; } 00118 00119 void init(InitStage stage); 00120 void initializeUsingXML(xercesc::DOMElement *element); 00121 00122 void updateg(double t); 00123 00124 virtual bool isSingleValued() const {return true;} 00125 00126 private: 00127 fmatvec::Function<double(double)> * pFun; 00128 }; 00129 00130 00132 class EnvironmentNodeMec : public HNodeMec { 00133 public: 00134 EnvironmentNodeMec(const std::string &name="") : HNodeMec(name) {} 00135 virtual std::string getType() const { return "EnvironmentNodeMec"; } 00136 00137 void init(InitStage stage); 00138 00139 virtual bool isSingleValued() const {return true;} 00140 }; 00141 00142 00144 class ElasticNodeMec : public HNodeMec { 00145 public: 00146 ElasticNodeMec(const std::string &name="") : HNodeMec(name), E(0), fracAir(0), p0(0), bulkModulus(NULL) {} 00147 ~ElasticNodeMec(); 00148 virtual std::string getType() const { return "ElasticNode"; } 00149 00150 void setFracAir(double fracAir_) {fracAir=fracAir_; } 00151 void setp0(double p0_) {p0=p0_; } 00152 00153 void calcxSize() {xSize=2; } 00154 00155 void init(InitStage stage); 00156 void initializeUsingXML(xercesc::DOMElement *element); 00157 00158 void updatexRef(const fmatvec::Vec &xParent); 00159 00160 void updatexd(double t); 00161 void updatedx(double t, double dt); 00162 00163 void plot(double t, double dt); 00164 00165 virtual bool isSingleValued() const {return true;} 00166 00167 00168 private: 00169 double E; 00170 double fracAir; 00171 double p0; 00172 00173 OilBulkModulus * bulkModulus; 00174 }; 00175 00176 00178 class RigidNodeMec : public HNodeMec { 00179 public: 00180 RigidNodeMec(const std::string &name=""); 00181 ~RigidNodeMec(); 00182 virtual std::string getType() const { return "RigidNodeMec"; } 00183 00184 bool isSetValued() const {return true; } 00185 bool isActive() const {return true; } 00186 00187 void calclaSize(int j) {laSize=1; } 00188 //void calclaSizeForActiveg() {laSize=0; } 00189 void calcrFactorSize(int j) {rFactorSize=1; } 00190 00191 void init(InitStage stage); 00192 00193 void updatewbRef(const fmatvec::Vec& wbParent); 00194 00195 void updategd(double t); 00196 void updateW(double t, int j=0); 00197 00198 void updaterFactors(); 00199 void solveImpactsFixpointSingle(double dt); 00200 void solveConstraintsFixpointSingle(); 00201 void solveImpactsGaussSeidel(double dt); 00202 void solveConstraintsGaussSeidel(); 00203 void solveImpactsRootFinding(double dt); 00204 void solveConstraintsRootFinding(); 00205 void jacobianImpacts(); 00206 void jacobianConstraints(); 00207 void checkImpactsForTermination(double dt); 00208 void checkConstraintsForTermination(); 00209 private: 00210 double gdn, gdd; 00211 MBSim::GeneralizedForceLaw * gfl; 00212 MBSim::GeneralizedImpactLaw * gil; 00213 }; 00214 } 00215 00216 #endif /* ----- #ifndef _HYDNODE_MEC_H_ ----- */ 00217
1.8.0