bool CVXS_Bond::DefineBond(BondType BondTypeIn, int Vox1SIndIn, int Vox2SIndIn, bool PermIn) //usually only called whenn creating bond... { ThisBondType = BondTypeIn; Perm = PermIn; if (!SetVoxels(Vox1SIndIn, Vox2SIndIn)) return false; if (!UpdateConstants()) return false; ResetBond(); //?? return true; }
bool CVXS_Bond::DefineBond(BondType BondTypeIn, int Vox1SIndIn, int Vox2SIndIn, bool PermIn) //usually only called whenn creating bond... { // std::cout << "DEBUG MALLOC: GOT HERE -- BOND." << std::endl; ThisBondType = BondTypeIn; Perm = PermIn; if (!SetVoxels(Vox1SIndIn, Vox2SIndIn)) return false; if (!UpdateConstants()) return false; ResetBond(); //?? // std::cout << "DONE BOND." << std::endl; return true; }
bool CVXS_Bond::SetVoxels(const int V1SIndIn, const int V2SIndIn) { Vox1SInd=V1SIndIn; Vox2SInd=V2SIndIn; if (Vox1SInd == Vox2SInd) return true; //Equale voxel indices is a flag to disable a bond if (!UpdateVox1Ptr()){Vox1SInd=-1; return false;} if (!UpdateVox2Ptr()){Vox2SInd=-1; return false;} OrigDist = pVox2->GetOrigPos() - pVox1->GetOrigPos(); //original distance (world coords) HomogenousBond = (pVox1->GetMaterial() == pVox2->GetMaterial()); if (OrigDist.x == 0 && OrigDist.y == 0) ThisBondDir = BD_Z; else if (OrigDist.x == 0 && OrigDist.z == 0) ThisBondDir = BD_Y; else if (OrigDist.y == 0 && OrigDist.z == 0) ThisBondDir = BD_X; else ThisBondDir = BD_ARB; vfloat E1 = pVox1->GetEMod(), E2 = pVox2->GetEMod(); vfloat u1 = pVox1->GetPoisson(), u2 = pVox2->GetPoisson(); vfloat CTE1 = pVox1->GetCTE(), CTE2 = pVox2->GetCTE(); if (E1 == 0 || E2 == 0) {return false;} if (u1 < 0 || u1 > 0.5 || u2 < 0 || u2 > 0.5 ) {return false;} //bad poissons ratio; E = (E1*E2/(E1+E2))*2; //x2 derived from case of equal stiffness: E1*E1/(E1+E1) = 0.5*E1 if (u1==0 && u2==0) u=0; else u = (u1*u2/(u1+u2))*2; //Poissons ratio CTE = (CTE1/2+CTE2/2); //thermal expansion //for now we are only using the nominal size of the voxel, although we could change this later if needed //rotate the box dimensions into the correct refference frame of x being direction of bond switch (ThisBondType){ case B_LINEAR: L = (pVox1->GetOrigSize() + pVox2->GetOrigSize())*0.5; ToXDirBond(&L); //in X direction, so L.X is beam length, L.y, L.z are transverse dimensions L = L.Abs(); //distances strictly positive! break; case B_LINEAR_CONTACT: //X direction of L is in line with the contact... default: L.x = p_Sim->LocalVXC.GetLatticeDim(); L.y = L.x; L.z = L.x; break; } if (!UpdateConstants()) return false; ResetBond(); return true; }
CVXS_Bond::CVXS_Bond(CVX_Sim* p_SimIn) { p_Sim = p_SimIn; ThisBondType = B_LINEAR; Perm = false; ResetBond(); //Zeroes out all state variables //Set independent variables Vox1SInd = -1; Vox2SInd = -1; pVox1 = NULL; pVox2 = NULL; OrigDist = Vec3D<>(0,0,0); HomogenousBond = false; ThisBondDir = BD_X; E=0; u=0; CTE=0; L = Vec3D<>(0, 0, 0); UpdateConstants(); //updates all the dependent variables based on zeros above. }
CVXS_BondInternal::CVXS_BondInternal(CVX_Sim* p_SimIn) : CVXS_Bond(p_SimIn) { ResetBond(); //Zeroes out all state variables }