Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
var _2xSqMxExS = (2.0*Math.sqrt(node.mass*E*node.nomSize));
var zetaCollision=0.01;
return zetaCollision*_2xSqMxExS;
} //!< Returns the global material damping coefficient (translation)
function collisionDampingRotateC(node) {
var zetaCollision=1.0;
var _momentInertia = (node.mass*node.nomSize*node.nomSize / 6.0); //simple 1D approx
var _2xSqIxExSxSxS = (2.0*Math.sqrt(_momentInertia*E*node.nomSize*node.nomSize*node.nomSize));
return zetaCollision*_2xSqIxExSxSxS;
} //!< Returns the global material damping coefficient (rotation)
function moment(node) {
//moments from internal bonds
var totalMoment=new THREE.Vector3(0,0,0);
// for (int i=0; i<6; i++){
// if (links[i]) totalMoment += links[i]->moment(isNegative((linkDirection)i)); //total force in LCS
// }
totalMoment.add(node.intMoment);
totalMoment = RotateVec3D(node.orient,totalMoment);
totalMoment.add(new THREE.Vector3(node.moment.x,node.moment.y,node.moment.z));
//other moments
// if (externalExists()) totalMoment += external()->moment(); //external moments
// totalMoment -= angularVelocity()*mat->globalDampingRotateC(); //global damping
node.intMoment=new THREE.Vector3(0,0,0);
return totalMoment;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//void haltMotion(){linMom = angMom = Vec3D<>(0,0,0);} //!< Halts all momentum of this block. Unless fixed the voxel will continue to move in subsequent timesteps.
function recommendedTimeStep() {
// //find the largest natural frequency (Math.sqrt(k/m)) that anything in the simulation will experience, then multiply by 2*pi and invert to get the optimally largest timestep that should retain stability
// float MaxFreq2 = 0.0f; //maximum frequency in the simulation in rad/sec
// for (std::vector<CVX_Link*>::const_iterator it=linksList.begin(); it != linksList.end(); it++){ //for each link
// CVX_Link* pL = (*it);
// //axial
// float m1 = pL->pVNeg->mat->mass(), m2 = pL->pVPos->mat->mass();
// float thisMaxFreq2 = pL->axialStiffness()/(m1<m2?m1:m2);
// if (thisMaxFreq2 > MaxFreq2) MaxFreq2 = thisMaxFreq2;
// //rotational will always be less than or equal
// }
// if (MaxFreq2 <= 0.0f){ //didn't find anything (i.e no links) check for individual voxelss
// for (std::vector<CVX_Voxel*>::const_iterator it=voxelsList.begin(); it != voxelsList.end(); it++){ //for each link
// float thisMaxFreq2 = (*it)->mat->youngsModulus()*(*it)->mat->nomSize/(*it)->mat->mass();
// if (thisMaxFreq2 > MaxFreq2) MaxFreq2 = thisMaxFreq2;
// }
// }
// if (MaxFreq2 <= 0.0f) return 0.0f;
// else return 1.0f/(6.283185f*sqrt(MaxFreq2)); //the optimal timestep is to advance one radian of the highest natural frequency
}
function isXyzIndependent() {return nu==0.0;} //!< Returns true if poisson's ratio is zero - i.e. deformations in each dimension are independent of those in other dimensions.
function isFailed(edge) {
// return mat->isFailed(maxStrain);
}
// function isLocalVelocityValid() {return boolStates & LOCAL_VELOCITY_VALID ? true : false;} //
// function dampingMultiplier() {return 2*mat->_sqrtMass*mat->zetaInternal/previousDt;} //!< Returns the damping multiplier for this voxel. This would normally be called only internally for the internal damping calculations.
// function setBoolState(linkFlags flag, bool set=true) {set ? boolStates |= (int)flag : boolStates &= ~(int)flag;}
// function setFixedAll(bool fixed=true) {fixed?setDisplacementAll():clearDisplacementAll();} //!< Sets all 6 degrees of freedom to either fixed or free depending on the value of fixed. Either way, sets all displacements to zero. @param[in] fixed Whether all degrees of freedom should be fixed (true) or free (false).
// function setDisplacement(dofComponent dof, double displacement=0.0); //!< Fixes the specified degree of freedom and applies the prescribed displacement if specified. @param[in] dof the degree of freedom in question. @param[in] displacement The displacement in meters (translational dofs) or radians (rotational dofs) to apply. Large fixed displacements may cause instability.
// function setDisplacementAll(const Vec3D<double>& translation = Vec3D<double>(0,0,0), const Vec3D<double>& rotation = Vec3D<double>(0,0,0)); //!< Fixes the all degrees of freedom and applies the specified translation and rotation. @param[in] translation The translation in meters from this voxel's nominal position to fix it at. @param[in] rotation The rotation (in the form of a rotation vector) from this voxel's nominal orientation to fix it at.
function transverseStrainSum(axis){
// if (mat->poissonsRatio() == 0) return 0;
// Vec3D<float> psVec = poissonsStrain();
// switch (axis){
// case CVX_Link::X_AXIS: return psVec.y+psVec.z;
// case CVX_Link::Y_AXIS: return psVec.x+psVec.z;
// case CVX_Link::Z_AXIS: return psVec.x+psVec.y;
// default: return 0.0f;
// }
}
function transverseStrainSum(axis){
// if (mat->poissonsRatio() == 0) return 0;
// Vec3D<float> psVec = poissonsStrain();
// switch (axis){
// case CVX_Link::X_AXIS: return psVec.y+psVec.z;
// case CVX_Link::Y_AXIS: return psVec.x+psVec.z;
// case CVX_Link::Z_AXIS: return psVec.x+psVec.y;
// default: return 0.0f;
// }
}
function poissonsStrain(node){
// if (poissonsStrainInvalid){
// pStrain = strain(true);
// poissonsStrainInvalid = false;
// }
// return pStrain;
}
function strain( poissonsStrain) {
//if no connections in the positive and negative directions of a particular axis, strain is zero
//if one connection in positive or negative direction of a particular axis, strain is that strain - ?? and force or constraint?
//if connections in both the positive and negative directions of a particular axis, strain is the average.
// Vec3D<float> intStrRet(0,0,0); //intermediate strain return value. axes according to linkAxis enum
// int numBondAxis[3] = {0}; //number of bonds in this axis (0,1,2). axes according to linkAxis enum
// bool tension[3] = {false};
// for (int i=0; i<6; i++){ //cycle through link directions
// if (links[i]){
// int axis = toAxis((linkDirection)i);
// intStrRet[axis] += links[i]->axialStrain(isNegative((linkDirection)i));
// numBondAxis[axis]++;
// }
// }
// for (int i=0; i<3; i++){ //cycle through axes
// if (numBondAxis[i]==2) intStrRet[i] *= 0.5f; //average
// if (poissonsStrain){
// tension[i] = ((numBondAxis[i]==2) || (ext && (numBondAxis[i]==1 && (ext->isFixed((dofComponent)(1<<i)) || ext->force()[i] != 0)))); //if both sides pulling, or just one side and a fixed or forced voxel...
// }
// }
// if (poissonsStrain){
// if (!(tension[0] && tension[1] && tension[2])){ //if at least one isn't in tension
// float add = 0;
// for (int i=0; i<3; i++) if (tension[i]) add+=intStrRet[i];
// float value = pow( 1.0f + add, -mat->poissonsRatio()) - 1.0f;
// for (int i=0; i<3; i++) if (!tension[i]) intStrRet[i]=value;
// }
// }
// return intStrRet;
}