Ejemplo n.º 1
0
    /*
     *  Advect vortons using velocity field
     *
     *  timeStep - amount of time by which to advance simulation
     *
     */
    void AdvectVortons(float timeStep)
    {
        int numVortons = mVortons.Count;

        for (int offset = 0; offset < numVortons; ++offset)
        {   // For each vorton...
            Vorton rVorton = mVortons[offset];

            Vector3 velocity = ((Vector)mVelGrid.Interpolate(rVorton.position)).v;
            mVortons[offset].position += velocity * timeStep;
            mVortons[offset].velocity  = velocity;  // Cache this for use in collisions with rigid bodies.
        }
    }
Ejemplo n.º 2
0
    /*
     *  Stretch and tilt vortons using velocity field
     *  timeStep - amount of time by which to advance simulation
     *  uFrame - frame counter
     *
     *  see J. T. Beale, A convergent three-dimensional vortex method with
     *          grid-free stretching, Math. Comp. 46 (1986), 401-24, April.
     *
     *  This routine assumes CreateInfluenceTree has already executed.
     *
     */
    void StretchAndTiltVortons(float timeStep)
    {
        if ((0.0f == mVelGrid.GetExtent().x) ||
            (0.0f == mVelGrid.GetExtent().y) ||
            (0.0f == mVelGrid.GetExtent().z))
        {   // Domain is 2D, so stretching & tilting does not occur.
            return;
        }

        // Compute all gradients of all components of velocity.
        UniformGrid <Matrix3x3> velocityJacobianGrid = new UniformGrid <Matrix3x3>(mVelGrid);

        velocityJacobianGrid.Init();

        UniformGridMath.ComputeJacobian(ref velocityJacobianGrid, mVelGrid);

        int numVortons = mVortons.Count;

        for (int offset = 0; offset < numVortons; ++offset)
        {                                                                // For each vorton...
            Matrix3x3 velJac      = (Matrix3x3)velocityJacobianGrid.Interpolate(mVortons[offset].position);
            Vector3   stretchTilt = mVortons[offset].vorticity * velJac; // Usual way to compute stretching & tilting
            mVortons[offset].vorticity += /* fudge factor for stability */ 0.5f * stretchTilt * timeStep;
        }
    }