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