コード例 #1
0
        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,
        }
コード例 #2
0
 /// 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);
 }
コード例 #3
0
        public override void IntLoadResidual_CqL(int off_L,
                                                 ref ChVectorDynamic <double> R,
                                                 ChVectorDynamic <double> L,
                                                 double c)
        {
            int cnt = 0;

            for (int i = 0; i < mask.nconstr; i++)
            {
                if (mask.Constr_N(i).IsActive())
                {
                    mask.Constr_N(i).MultiplyTandAdd(R.matrix, L.matrix[off_L + cnt] * c);
                    cnt++;
                }
            }
        }
コード例 #4
0
        //
        // STATE FUNCTIONS
        //

        // (override/implement interfaces for global state vectors, see ChPhysicsItem for comments.)
        public override void IntStateGatherReactions(int off_L, ref ChVectorDynamic <double> L)
        {
            if (!this.IsActive())
            {
                return;
            }

            int nc = 0;

            if (c_x)
            {
                if (mask.Constr_N(nc).IsActive())
                {
                    L.matrix[off_L + nc] = -react_force.x;
                }
                nc++;
            }
            if (c_y)
            {
                if (mask.Constr_N(nc).IsActive())
                {
                    L.matrix[off_L + nc] = -react_force.y;
                }
                nc++;
            }
            if (c_z)
            {
                if (mask.Constr_N(nc).IsActive())
                {
                    L.matrix[off_L + nc] = -react_force.z;
                }
                nc++;
            }
            if (c_rx)
            {
                if (mask.Constr_N(nc).IsActive())
                {
                    L.matrix[off_L + nc] = -2.0 * react_torque.x;
                }
                nc++;
            }
            if (c_ry)
            {
                if (mask.Constr_N(nc).IsActive())
                {
                    L.matrix[off_L + nc] = -2.0 * react_torque.y;
                }
                nc++;
            }
            if (c_rz)
            {
                if (mask.Constr_N(nc).IsActive())
                {
                    L.matrix[off_L + nc] = -2.0 * react_torque.z;
                }
                nc++;
            }
        }