示例#1
0
        /// Initialize again this constraint.
        public override void Reset(Ta mobjA,
                                   Tb mobjB,
                                   collision.ChCollisionInfo cinfo)
        {
            // Base method call:
            base.Reset(mobjA, mobjB, cinfo);

            ChBody oA = (this.objA as ChBody);
            ChBody oB = (this.objB as ChBody);

            Rx.Get_tuple_a().SetVariables(ref this.objA);
            Rx.Get_tuple_b().SetVariables(ref this.objB);
            Ru.Get_tuple_a().SetVariables(ref this.objA);
            Ru.Get_tuple_b().SetVariables(ref this.objB);
            Rv.Get_tuple_a().SetVariables(ref this.objA);
            Rv.Get_tuple_b().SetVariables(ref this.objB);

            // Calculate composite material properties
            ChMaterialCompositeNSC mat = new ChMaterialCompositeNSC(
                this.container.GetSystem().composition_strategy,
                (ChMaterialSurfaceNSC)oA.GetMaterialSurfaceBase(),
                (ChMaterialSurfaceNSC)oB.GetMaterialSurfaceBase());

            Rx.SetRollingFrictionCoefficient(mat.rolling_friction);
            Rx.SetSpinningFrictionCoefficient(mat.spinning_friction);

            this.complianceRoll = mat.complianceRoll;
            this.complianceSpin = mat.complianceSpin;

            // COMPUTE JACOBIANS

            // delegate objA to compute its half of jacobian
            oA.ComputeJacobianForRollingContactPart(this.p1, ref this.contact_plane, ref Rx.Get_tuple_a(),
                                                    ref Ru.Get_tuple_a(), ref Rv.Get_tuple_a(), false);

            // delegate objB to compute its half of jacobian
            oB.ComputeJacobianForRollingContactPart(this.p2, ref this.contact_plane, ref Rx.Get_tuple_b(),
                                                    ref Ru.Get_tuple_b(), ref Rv.Get_tuple_b(), true);

            this.react_torque = ChVector.VNULL;
        }
示例#2
0
        /// Initialize again this constraint.
        public override void Reset(Ta mobjA,                       //< collidable object A
                                   Tb mobjB,                       //< collidable object B
                                   collision.ChCollisionInfo cinfo //< data for the contact pair
                                   )                               //where T1: IntInterface.IBase
        {
            // inherit base class:
            base.Reset(mobjA, mobjB, cinfo);

            ChBody oA = (this.objA as ChBody);
            ChBody oB = (this.objB as ChBody);

            Nx.Get_tuple_a().SetVariables(ref this.objA);
            Nx.Get_tuple_b().SetVariables(ref this.objB);
            Tu.Get_tuple_a().SetVariables(ref this.objA);
            Tu.Get_tuple_b().SetVariables(ref this.objB);
            Tv.Get_tuple_a().SetVariables(ref this.objA);
            Tv.Get_tuple_b().SetVariables(ref this.objB);

            // Calculate composite material properties
            ChMaterialCompositeNSC mat = new ChMaterialCompositeNSC(
                this.container.GetSystem().composition_strategy,
                (ChMaterialSurfaceNSC)(oA.GetMaterialSurfaceBase()),
                (ChMaterialSurfaceNSC)(oB.GetMaterialSurfaceBase()));

            // Check for a user-provided callback to modify the material
            if (this.container.GetAddContactCallback() != null)
            {
                this.container.GetAddContactCallback().OnAddContact(cinfo, mat);
            }

            Nx.Constraint2TuplesNall.SetFrictionCoefficient(mat.static_friction);
            Nx.Constraint2TuplesNall.SetCohesion(mat.cohesion);

            this.restitution = mat.restitution;
            this.dampingf    = mat.dampingf;
            this.compliance  = mat.compliance;
            this.complianceT = mat.complianceT;

            this.reactions_cache = cinfo.reaction_cache;

            // COMPUTE JACOBIANS


            // delegate objA to compute its half of jacobian
            oA.ComputeJacobianForContactPart(this.p1, ref this.contact_plane, ref Nx.Get_tuple_a(), ref Tu.Get_tuple_a(),
                                             ref Tv.Get_tuple_a(), false);

            // delegate objB to compute its half of jacobian
            oB.ComputeJacobianForContactPart(this.p2, ref this.contact_plane, ref Nx.Get_tuple_b(), ref Tu.Get_tuple_b(),
                                             ref Tv.Get_tuple_b(), true);

            if (reactions_cache != null)
            {
                react_force.x = reactions_cache[0];
                react_force.y = reactions_cache[1];
                react_force.z = reactions_cache[2];
                //GetLog() << "Reset Fn=" << (double)reactions_cache[0] << "  at cache address:" << (int)this->reactions_cache << "\n";
            }
            else
            {
                react_force = new ChVector(0, 0, 0);
            }
        }