![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsElasticRodParameters.cpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (08/25/2009) 00009 UPDATE (12/17/2010) 00010 ******************************************************************************/ 00011 #include "TAPsElasticRodParameters.hpp" 00012 // Using Inclusion Model (i.e. definitions are included in declarations) 00013 // (this name.cpp is included in name.hpp) 00014 // Each friend is defined directly inside its declaration. 00015 00016 BEGIN_NAMESPACE_TAPs 00017 //============================================================================= 00018 //----------------------------------------------------------------------------- 00019 00020 // Default constructor 00021 template <typename T> 00022 ElasticRodParameters<T>::ElasticRodParameters () : 00023 NumOfNodes( 9 ), 00024 Radius( 0.125 ), 00025 TotalMass( 1 ), 00026 TotalLength( 1 ), 00027 LinkLength( TotalLength / (NumOfNodes-1) ), 00028 MassOfPoint( TotalMass / NumOfNodes ), 00029 Kstretch_modulus( 5E5 ), 00030 Kbend_modulus( 2.75E4 ), 00031 Kshear_modulus( 2.55E4 ), 00032 MaterialDensity( 5E3 ), 00033 00034 Kgravity( -9.81 ), 00035 #ifdef TAPs_ADD_RESTING_LEVEL_Y 00036 RestingLevel( 0.0 ), 00037 #endif//TAPs_ADD_RESTING_LEVEL_Y 00038 00039 #ifdef TAPs_ADD_KNOT_RECOGNITION 00040 EnableKR( true ), 00041 EnableKR_LockKnots( true ), 00042 #endif//TAPs_ADD_KNOT_RECOGNITION 00043 00044 #ifdef TAPs_USE_CUDA 00045 EnableCUDA( false ), 00046 EnableCUDA_GenDrawData( false ), // Unless cudaGLMapBufferObject preformance is much improved, this one should be set to false. 00047 #endif//TAPs_USE_CUDA 00048 00049 // Collision Detection and Response 00050 EnableSelfCDR( true ), 00051 KselfCDR( 1 ), 00052 KselfCDR_ScaleDistance( 1 ), 00053 KselfStick( 1 ), 00054 K_CDRwBV_Cylinder( 1 ), 00055 K_CDRwBV_Sphere( 1 ), 00056 K_CDRwTriangle( 1 ), 00057 00058 // Collision Detection and Response with implicit objects 00059 K_CDRwImpObj_Sphere( 1 ), 00060 K_CDRwImpObj_Torus( 1 ), 00061 Offset_CD_ImpObj_Sphere( 0 ), 00062 Offset_CD_ImpObj_Torus( 0 ), 00063 00064 // Simulation time step and iterations 00065 TimeStep( 0.001 ), 00066 SimIterationTimes( 1 ), 00067 00068 // Offsets 00069 Offset_CD_Self( 0 ), 00070 Offset_CD_SelfStick( 0 ), 00071 Offset_CD_Triangle( 0 ), 00072 Offset_CD_BV_Sphere( 0 ), 00073 Offset_CD_BV_Cylinder( 0 ) 00074 00075 { 00076 Kt = 40; 00077 Kr[0] = 41.5; Kr[1] = 42.5; Kr[2] = 43.5; 00078 Dt = 50; 00079 Dr[0] = 51.5; Dr[1] = 52.5; Dr[2] = 53.5; 00080 Kconstraint_3rdDirAlignTangent = 55; 00081 Kconstraint_ScaleIntrinsicStrainRate = 1; 00082 Kvdamping = 0.125; 00083 00084 CalDependentParameters(); 00085 } 00086 00087 00088 // Assignment operator 00089 template <typename T> 00090 ElasticRodParameters<T> & ElasticRodParameters<T>::operator= ( ElasticRodParameters<T> const & orig ) 00091 { 00092 Name = orig.Name; 00093 00094 // Physical properties 00095 NumOfNodes = orig.NumOfNodes; 00096 Radius = orig.Radius; 00097 TotalMass = orig.TotalMass; 00098 TotalLength = orig.TotalLength; 00099 LinkLength = orig.LinkLength; 00100 MassOfPoint = orig.MassOfPoint; 00101 00102 // Material and Moduli 00103 Kstretch_modulus = orig.Kstretch_modulus; 00104 Kbend_modulus = orig.Kbend_modulus; 00105 Kshear_modulus = orig.Kshear_modulus; 00106 MaterialDensity = orig.MaterialDensity; 00107 00108 // K constants 00109 Kt = orig.Kt; 00110 Kr[0] = orig.Kr[0]; 00111 Kr[1] = orig.Kr[1]; 00112 Kr[2] = orig.Kr[2]; 00113 Dt = orig.Dt; 00114 Dr[0] = orig.Dr[0]; 00115 Dr[1] = orig.Dr[1]; 00116 Dr[2] = orig.Dr[2]; 00117 Kconstraint_3rdDirAlignTangent = orig.Kconstraint_3rdDirAlignTangent; 00118 Kconstraint_ScaleIntrinsicStrainRate = orig.Kconstraint_ScaleIntrinsicStrainRate; 00119 Kvdamping = orig.Kvdamping; 00120 00121 Kgravity = orig.Kgravity; 00122 #ifdef TAPs_ADD_RESTING_LEVEL_Y 00123 RestingLevel = orig.RestingLevel; 00124 #endif//TAPs_ADD_RESTING_LEVEL_Y 00125 00126 // These two below will be set by the values of moduli 00127 Ps = orig.Ps; 00128 Pb[0] = orig.Pb[0]; 00129 Pb[1] = orig.Pb[1]; 00130 Pb[2] = orig.Pb[2]; 00131 00132 // For collision detection and response 00133 EnableSelfCDR = orig.EnableSelfCDR; 00134 KselfCDR = orig.KselfCDR; 00135 KselfCDR_ScaleDistance = orig.KselfCDR_ScaleDistance; 00136 KselfStick = orig.KselfStick; 00137 00138 // For collision detection and response with objects 00139 K_CDRwBV_Cylinder = orig.K_CDRwBV_Cylinder; 00140 K_CDRwBV_Sphere = orig.K_CDRwBV_Sphere; 00141 K_CDRwTriangle = orig.K_CDRwTriangle; 00142 00143 // For collision detection and response with implicit objects 00144 K_CDRwImpObj_Sphere = orig.K_CDRwImpObj_Sphere; 00145 K_CDRwImpObj_Torus = orig.K_CDRwImpObj_Torus; 00146 Offset_CD_ImpObj_Sphere = orig.Offset_CD_ImpObj_Sphere; 00147 Offset_CD_ImpObj_Torus = orig.Offset_CD_ImpObj_Torus; 00148 00149 // Simulation time step and iterations 00150 TimeStep = orig.TimeStep; 00151 SimIterationTimes = orig.SimIterationTimes; 00152 00153 // Offsets 00154 Offset_CD_Self = orig.Offset_CD_Self; 00155 Offset_CD_SelfStick = orig.Offset_CD_SelfStick; 00156 Offset_CD_Triangle = orig.Offset_CD_Triangle; 00157 Offset_CD_BV_Sphere = orig.Offset_CD_BV_Sphere; 00158 Offset_CD_BV_Cylinder = orig.Offset_CD_BV_Cylinder; 00159 00160 #ifdef TAPs_ADD_KNOT_RECOGNITION 00161 // For knot recognition 00162 EnableKR = orig.EnableKR; 00163 EnableKR_LockKnots = orig.EnableKR_LockKnots; 00164 KstickPair = orig.KstickPair; 00165 #endif//#ifdef TAPs_ADD_KNOT_RECOGNITION 00166 00167 #ifdef TAPs_USE_CUDA 00168 EnableCUDA = orig.EnableCUDA; 00169 EnableCUDA_GenDrawData = orig.EnableCUDA_GenDrawData; 00170 #endif//TAPs_USE_CUDA 00171 00172 return *this; 00173 } 00174 00175 00176 // StrInfo 00177 template <typename T> 00178 std::string ElasticRodParameters<T>::StrInfo () const 00179 { 00180 std::stringstream output; 00181 output << "###############################################################################\n" 00182 << "Name\t" << "\"" << Name << "\"\n" 00183 << "###############################################################################\n" 00184 //<< "NumOfLinks\t" << NumOfNodes-1 << "\n" 00185 << "Radius\t" << Radius << "\n" 00186 << "Mass\t" << TotalMass << "\n" 00187 //<< "Length\t" << TotalLength << "\n" 00188 //<< "Link Length\t" << LinkLength << "\n" 00189 //<< "Mass of Point\t" << MassOfPoint << "\n" 00190 << "\n" 00191 << "# SIMULATION CONSTANTS\n" 00192 << "K_Kinetic_Translational\t" << Kt << "\n" 00193 << "K_Kinetic_Rotational\t" << Kr[0] << " " << Kr[1] << " " << Kr[2] << "\n" 00194 << "K_Dissipation_Translational\t" << Dt << "\n" 00195 << "K_Dissipation_Rotational\t" << Dr[0] << " " << Dr[1] << " " << Dr[2] << "\n" 00196 << "K_Constraint_3rdDirAlignTangent\t" << Kconstraint_3rdDirAlignTangent << "\n" 00197 << "K_Damping_Velocity\t" << Kvdamping << "\n" 00198 << "K_Stretching_Modulus\t" << Kstretch_modulus << "\n" 00199 << "K_Bending_Modulus\t" << Kbend_modulus << "\n" 00200 << "K_Shear_Modulus\t" << Kshear_modulus << "\n" 00201 << "K_Material_Density\t" << MaterialDensity << "\n" 00202 << "K_Self_CDR\t" << KselfCDR << "\n" 00203 //<< "\n" 00204 //<< "#SimTimeStep\t" << << "\n" 00205 //<< "\t" << << "\n" 00206 << "###############################################################################\n" 00207 << "\n"; 00208 return output.str(); 00209 } 00210 00211 // Calculate the dependent parameters 00212 template <typename T> 00213 void ElasticRodParameters<T>::CalDependentParameters () 00214 { 00215 LinkLength = TotalLength / (NumOfNodes-1); 00216 MassOfPoint = TotalMass / NumOfNodes; 00217 00218 T area = Math<T>::PI * Radius * Radius; 00219 Ps = Kstretch_modulus * area; 00220 Pb[0] = Pb[1] = Kbend_modulus * area * 0.25; 00221 Pb[2] = Kshear_modulus * area * 0.5; 00222 } 00223 00225 //template <typename T> 00226 //void ElasticRodParameters<T>::ScaleAllSimConstsByTimeStep () 00227 //{ 00228 // KselfCDR /= TimeStep; 00229 // K_CDRwBV_Cylinder /= TimeStep; 00230 // K_CDRwBV_Sphere /= TimeStep; 00231 // K_CDRwTriangle /= TimeStep; 00232 //} 00233 00234 //============================================================================= 00235 END_NAMESPACE_TAPs 00236 //----------------------------------------------------------------------------- 00237 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00238 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----