Beispiel #1
0
    /// <summary>
    /// Set the integrator required for the chosen algorithm
    /// </summary>
    /// <param name="algorithm"></param>
    public void SetAlgorithmAndForce(GravityEngine.Algorithm algorithm, IForceDelegate forceDelegate)
    {
        this.forceDelegate = forceDelegate;
        // cast may be null if no force selection
        if (forceDelegate is SelectiveForceBase)
        {
            selectiveForce = (SelectiveForceBase)forceDelegate;
        }
        switch (algorithm)
        {
        case GravityEngine.Algorithm.LEAPFROG:
            integrator = new LeapFrogIntegrator(forceDelegate);
            break;

        //case GravityEngine.Algorithm.LEAPFROG_JOB:
        //    integrator = new LeapFrogJob(forceDelegate);
        //    break;
        case GravityEngine.Algorithm.HERMITE8:
            integrator = new HermiteIntegrator(forceDelegate);
            break;

        case GravityEngine.Algorithm.AZTRIPLE:
            integrator = new AZTripleIntegrator();
            break;

        default:
            Debug.LogError("Unknown algortithm");
            break;
        }
    }
Beispiel #2
0
    /// <summary>
    /// Clone constructor
    ///
    /// Creates a deep copy suitable for independent evolution as a trajectory or for maneuver iterations.
    /// Maneuvers will be executed but the callback to motify the owner of the maneuver will be skipped (only
    /// the real evolution will notify).
    /// </summary>
    /// <param name="fromState"></param>
    public GravityState(GravityState fromState)
    {
        m                       = new double[fromState.arraySize];
        r                       = new double[fromState.arraySize, NDIM];
        info                    = new byte[fromState.arraySize];
        size2                   = new double[fromState.arraySize];
        physicalTime            = new double[System.Enum.GetNames(typeof(Evolvers)).Length];
        arraySize               = fromState.arraySize;
        numBodies               = fromState.numBodies;
        fixedBodiesInIntegrator = fromState.fixedBodiesInIntegrator;
        onRails                 = fromState.onRails;


        // omitting hasTrajectories
        integrator = fromState.integrator.DeepClone();

        // don't copy particles, but need to init list
        gravityParticles = new List <GravityParticles>();

        // DO copy the maneuvers
        maneuverMgr = new ManeuverMgr(fromState.maneuverMgr);

        fixedBodies = new List <GravityEngine.FixedBody>(fromState.fixedBodies);

        for (int i = 0; i < physicalTime.Length; i++)
        {
            physicalTime[i] = fromState.physicalTime[i];
        }
        time           = fromState.time;
        forceDelegate  = fromState.forceDelegate;
        selectiveForce = fromState.selectiveForce;

        keplerDepthChanged = new List <GravityEngine.FixedBody>(fromState.keplerDepthChanged);

        if (fromState.masslessEngine != null)
        {
            masslessEngine = fromState.masslessEngine.DeepClone();
            masslessEngine.ResetTrajectories((float)fromState.time);
        }

        for (int i = 0; i < arraySize; i++)
        {
            m[i]     = fromState.m[i];
            info[i]  = fromState.info[i];
            size2[i] = fromState.size2[i];
            r[i, 0]  = fromState.r[i, 0];
            r[i, 1]  = fromState.r[i, 1];
            r[i, 2]  = fromState.r[i, 2];
        }

        // copies do not notify maneuver owners of maneuver completion. They are assumed to be "what if"
        // evolutions
        isCopy = true;

#pragma warning disable 162     // disable unreachable code warning
        if (GravityEngine.DEBUG)
        {
            Debug.Log("Created new (copy) gravityState");
        }
#pragma warning restore 162
    }