/// Sets some active constraints as redundant. public int SetActiveRedundantByArray(int[] mvector, int mcount) { int cnt; ChLinkMask newmask = Clone(); for (int elem = 0; elem < mcount; elem++) { cnt = 0; for (int i = 0; i < nconstr; i++) { if (constraints[i].IsActive()) { if (cnt == mvector[elem]) { newmask.constraints[i].SetRedundant(true); } cnt++; } } } // Replace the mask with updated one. for (int i = 0; i < nconstr; i++) { constraints[i] = null; constraints[i] = (ChConstraintTwoBodies)newmask.constraints[i].Clone(); } return(mcount); }
public ChLinkMasked() { mask = new ChLinkMask(1); // create the mask; mask.Constr_N(0).SetMode(eChConstraintMode.CONSTRAINT_FREE); // default: one constr.eq. but not working BuildLink(); // setup all matrices - if any (i.e. none in this base link)- // setting automatically n. of DOC and DOF, }
/// Copy constructor public ChLinkMask(ChLinkMask other) { nconstr = other.nconstr; constraints.Resize(other.nconstr); for (int i = 0; i < nconstr; i++) { constraints[i] = (ChConstraintTwoBodies)other.constraints[i].Clone(); } }
// [mostly internal], allocates matrices and, in general, initializes all stuff // which is mask-dependant. Sets n. DOF and n .DOC. // Copies the mask from new_mask. protected void BuildLink(ChLinkMask new_mask) { // set mask mask = null; mask = new_mask.Clone(); // setup matrices; BuildLink(); }
/// To compare two masks, return true if equal public bool IsEqual(ChLinkMask mask2) { if (nconstr != mask2.nconstr) { return(false); } for (int j = 0; j < nconstr; j++) { if (!(Constr_N(j) == mask2.Constr_N(j))) { return(false); } } return(true); }
public ChLinkMasked(ChLinkMasked other) : base(other) { mask = other.mask.Clone(); // setup -alloc all needed matrices!! ChangedLinkMask(); force_D = other.force_D.Clone(); force_R = other.force_R.Clone(); force_X = other.force_X.Clone(); force_Y = other.force_Y.Clone(); force_Z = other.force_Z.Clone(); force_Rx = other.force_Rx.Clone(); force_Ry = other.force_Ry.Clone(); force_Rz = other.force_Rz.Clone(); d_restlength = other.d_restlength; }
protected ChMatrixDynamic <double> C; ///< residuals public ChLinkMateGeneric(bool mc_x = true, bool mc_y = true, bool mc_z = true, bool mc_rx = true, bool mc_ry = true, bool mc_rz = true) { c_x = mc_x; c_y = mc_y; c_z = mc_z; c_rx = mc_rx; c_ry = mc_ry; c_rz = mc_rz; // C = null; mask = new ChLinkMask(); SetupLinkMask(); }
/// Must be called after whatever change the mask of the link, /// in order to update auxiliary matrices sizes... public void ChangeLinkMask(ChLinkMask new_mask) { DestroyLink(); BuildLink(new_mask); }