public PhillipsSpectrumCondition(int size, float windSpeed, float windDir, float waveAge, int numGrids)
            : base(size, numGrids)
        {
            if (numGrids < 1 || numGrids > 4)
            {
                throw new ArgumentException("PhillipsSpectrumCondition must have 1 to 4 grids not " + numGrids);
            }

            Key = new PhillipsSpectrumConditionKey(windSpeed, size, windDir, SPECTRUM_TYPE.PHILLIPS, numGrids);

            if (numGrids == 1)
            {
                GridSizes  = new Vector4(217, 1, 1, 1);
                Choppyness = new Vector4(1.5f, 1.0f, 1.0f, 1.0f);
                WaveAmps   = new Vector4(0.5f, 1.0f, 1.0f, 1.0f);
            }
            else if (numGrids == 2)
            {
                GridSizes  = new Vector4(217, 97, 1, 1);
                Choppyness = new Vector4(1.5f, 1.2f, 1.0f, 1.0f);
                WaveAmps   = new Vector4(0.5f, 1.0f, 1.0f, 1.0f);
            }
            else if (numGrids == 3)
            {
                GridSizes  = new Vector4(217, 97, 31, 1);
                Choppyness = new Vector4(1.5f, 1.2f, 1.0f, 1.0f);
                WaveAmps   = new Vector4(0.5f, 1.0f, 1.0f, 1.0f);
            }
            else if (numGrids == 4)
            {
                GridSizes  = new Vector4(1372, 217, 97, 31);
                Choppyness = new Vector4(1.5f, 1.2f, 1.0f, 1.0f);
                WaveAmps   = new Vector4(0.25f, 0.5f, 1.0f, 1.0f);
            }
        }
        public PhillipsSpectrumCondition(int size, float windSpeed, float windDir, float waveAge, int numGrids)
            : base(size, numGrids)
        {
            if (numGrids < 1 || numGrids > 4)
                throw new ArgumentException("PhillipsSpectrumCondition must have 1 to 4 grids not " + numGrids);

            Key = new PhillipsSpectrumConditionKey(windSpeed, size, windDir, SPECTRUM_TYPE.PHILLIPS, numGrids);

            if (numGrids == 1)
            {
                GridSizes = new Vector4(217, 1, 1, 1);
                Choppyness = new Vector4(1.5f, 1.0f, 1.0f, 1.0f);
                WaveAmps = new Vector4(0.5f, 1.0f, 1.0f, 1.0f);
            }
            else if(numGrids == 2)
            {
                GridSizes = new Vector4(217, 97, 1, 1);
                Choppyness = new Vector4(1.5f, 1.2f, 1.0f, 1.0f);
                WaveAmps = new Vector4(0.5f, 1.0f, 1.0f, 1.0f);
            }
            else if (numGrids == 3)
            {
                GridSizes = new Vector4(217, 97, 31, 1);
                Choppyness = new Vector4(1.5f, 1.2f, 1.0f, 1.0f);
                WaveAmps = new Vector4(0.5f, 1.0f, 1.0f, 1.0f);
            }
            else if (numGrids == 4)
            {
                GridSizes = new Vector4(1372, 217, 97, 31);
                Choppyness = new Vector4(1.5f, 1.2f, 1.0f, 1.0f);
                WaveAmps = new Vector4(0.25f, 0.5f, 1.0f, 1.0f);
            }
        }
        public override SpectrumTask GetCreateSpectrumConditionTask()
        {
            PhillipsSpectrumConditionKey key = Key as PhillipsSpectrumConditionKey;

            PhillipsSpectrum pspectrum = new PhillipsSpectrum(key.WindSpeed, key.WindDir);

            return(new SpectrumTask(this, true, new ISpectrum[] { pspectrum, pspectrum, pspectrum, pspectrum }));
        }
        protected override bool Matches(WaveSpectrumConditionKey k)
        {
            PhillipsSpectrumConditionKey key = k as PhillipsSpectrumConditionKey;

            if (key == null)
            {
                return(false);
            }
            if (WindSpeed != key.WindSpeed)
            {
                return(false);
            }

            return(true);
        }
Example #5
0
        private WaveSpectrumConditionKey NewSpectrumConditionKey(int fourierSize, float windSpeed, float windDir, float waveAge)
        {
            WaveSpectrumConditionKey result;

            switch (this.spectrumType)
            {
            case SPECTRUM_TYPE.UNIFIED:
                result = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, this.spectrumType, this.numberOfGrids);
                break;

            case SPECTRUM_TYPE.PHILLIPS:
                result = new PhillipsSpectrumConditionKey(windSpeed, fourierSize, windDir, this.spectrumType, this.numberOfGrids);
                break;

            case SPECTRUM_TYPE.UNIFIED_PHILLIPS:
                result = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, this.spectrumType, this.numberOfGrids);
                break;

            case SPECTRUM_TYPE.CUSTOM:
                if (base.CustomWaveSpectrum == null)
                {
                    Ocean.LogWarning("Custom spectrum type selected but no custom spectrum interface has been added to the wave spectrum. Defaulting to Unified Spectrum");
                    this.spectrumType = SPECTRUM_TYPE.UNIFIED;
                    result            = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, this.spectrumType, this.numberOfGrids);
                }
                else
                {
                    result = base.CustomWaveSpectrum.CreateKey(fourierSize, windDir, this.spectrumType, this.numberOfGrids);
                }
                break;

            default:
                throw new InvalidOperationException("Invalid spectrum type = " + this.spectrumType);
            }
            return(result);
        }
Example #6
0
        /// <summary>
        /// Create a new wave condition key depending on the spectrum type used.
        /// </summary>
        WaveSpectrumConditionKey NewSpectrumConditionKey(int fourierSize, float windSpeed, float windDir, float waveAge)
        {

            WaveSpectrumConditionKey key = null;

            switch (spectrumType)
            {
                case SPECTRUM_TYPE.UNIFIED:
                    key = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, spectrumType, numberOfGrids);
                    break;

                case SPECTRUM_TYPE.UNIFIED_PHILLIPS:
                    key = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, spectrumType, numberOfGrids);
                    break;

                case SPECTRUM_TYPE.PHILLIPS:;
                    key = new PhillipsSpectrumConditionKey(windSpeed, fourierSize, windDir, spectrumType, numberOfGrids);
                    break;

                case SPECTRUM_TYPE.CUSTOM:
                    {
                        if (CustomWaveSpectrum == null)
                        {
                            Ocean.LogWarning("Custom spectrum type selected but no custom spectrum interface has been added to the wave spectrum. Defaulting to Unified Spectrum");
                            spectrumType = SPECTRUM_TYPE.UNIFIED;
                            key = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, spectrumType, numberOfGrids);
                        }
                        else
                        {
                            key = CustomWaveSpectrum.CreateKey(fourierSize, windDir, spectrumType, numberOfGrids);
                        }
                    }
                    break;

                default:
                    throw new InvalidOperationException("Invalid spectrum type = " + spectrumType);
            }

            return key;

        }
        protected override bool Matches(WaveSpectrumConditionKey k)
        {
            PhillipsSpectrumConditionKey phillipsSpectrumConditionKey = k as PhillipsSpectrumConditionKey;

            return(!(phillipsSpectrumConditionKey == null) && this.WindSpeed == phillipsSpectrumConditionKey.WindSpeed);
        }
Example #8
0
 private WaveSpectrumConditionKey NewSpectrumConditionKey(int fourierSize, float windSpeed, float windDir, float waveAge)
 {
     WaveSpectrumConditionKey result;
     switch (this.spectrumType)
     {
     case SPECTRUM_TYPE.UNIFIED:
         result = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, this.spectrumType, this.numberOfGrids);
         break;
     case SPECTRUM_TYPE.PHILLIPS:
         result = new PhillipsSpectrumConditionKey(windSpeed, fourierSize, windDir, this.spectrumType, this.numberOfGrids);
         break;
     case SPECTRUM_TYPE.UNIFIED_PHILLIPS:
         result = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, this.spectrumType, this.numberOfGrids);
         break;
     case SPECTRUM_TYPE.CUSTOM:
         if (base.CustomWaveSpectrum == null)
         {
             Ocean.LogWarning("Custom spectrum type selected but no custom spectrum interface has been added to the wave spectrum. Defaulting to Unified Spectrum");
             this.spectrumType = SPECTRUM_TYPE.UNIFIED;
             result = new UnifiedSpectrumConditionKey(windSpeed, waveAge, fourierSize, windDir, this.spectrumType, this.numberOfGrids);
         }
         else
         {
             result = base.CustomWaveSpectrum.CreateKey(fourierSize, windDir, this.spectrumType, this.numberOfGrids);
         }
         break;
     default:
         throw new InvalidOperationException("Invalid spectrum type = " + this.spectrumType);
     }
     return result;
 }