// Copyright (C) Stichting Deltares 2016. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System.Collections.Generic;
using Ringtoets.HydraRing.Calculation.Data;
using Ringtoets.HydraRing.Calculation.Data.Settings;
using Ringtoets.HydraRing.Calculation.IO;
using Ringtoets.HydraRing.Calculation.Properties;
namespace Ringtoets.HydraRing.Calculation.Providers
{
///
/// Provider of .
///
internal class NumericsSettingsProvider
{
private readonly IDictionary>> fileNumericsSettings;
private IDictionary> defaultNumericsSettings;
///
/// Creates a new instance of the class.
///
public NumericsSettingsProvider()
{
InitializeDefaultNumericsSettings();
fileNumericsSettings = new NumericsSettingsCsvReader(Resources.NumericsSettings).ReadSettings();
}
///
/// Returns based on the provided and sub mechanism id.
///
/// The to obtain the for.
/// The sub mechanism id to obtain the for.
/// The ring id to obtain the for.
/// The corresponding to the provided and sub mechanism id.
public NumericsSettings GetNumericsSettings(HydraRingFailureMechanismType failureMechanismType, int subMechanismId, string ringId)
{
var mechanismId = new FailureMechanismDefaultsProvider().GetFailureMechanismDefaults(failureMechanismType).MechanismId;
if (fileNumericsSettings.ContainsKey(mechanismId) &&
fileNumericsSettings[mechanismId].ContainsKey(subMechanismId) &&
ringId != null &&
fileNumericsSettings[mechanismId][subMechanismId].ContainsKey(ringId))
{
return fileNumericsSettings[mechanismId][subMechanismId][ringId];
}
return defaultNumericsSettings[failureMechanismType][subMechanismId];
}
private void InitializeDefaultNumericsSettings()
{
defaultNumericsSettings = new Dictionary>
{
{
HydraRingFailureMechanismType.AssessmentLevel, new Dictionary
{
{
1, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.WaveHeight, new Dictionary
{
{
11, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.WavePeakPeriod, new Dictionary
{
{
14, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.WaveSpectralPeriod, new Dictionary
{
{
16, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.QVariant, new Dictionary
{
{
3, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
4, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
5, new NumericsSettings(4, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.DikesOvertopping, new Dictionary
{
{
102, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
103, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.DikesHeight, new Dictionary
{
{
102, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
103, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.DikesPiping, new Dictionary
{
{
311, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
313, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
314, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.StructuresOvertopping, new Dictionary
{
{
421, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
422, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
423, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.StructuresClosure, new Dictionary
{
{
422, new NumericsSettings(1, 1, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
424, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
425, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
426, new NumericsSettings(1, 1, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
427, new NumericsSettings(1, 1, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
},
{
HydraRingFailureMechanismType.StructuresStructuralFailure, new Dictionary
{
{
422, new NumericsSettings(1, 1, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
424, new NumericsSettings(1, 1, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
425, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
430, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
431, new NumericsSettings(1, 1, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
432, new NumericsSettings(1, 1, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
433, new NumericsSettings(1, 1, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
434, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
},
{
435, new NumericsSettings(1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 10000, 20000, 0.1, -6.0, 6.0, 25)
}
}
}
};
}
}
}