public void HasValidStatePoints_SoilProfileWithPOPAndPreconsolidationStressOnOneLayer_ReturnsFalse() { // Setup MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[] { MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 1)) }); IMacroStabilityInwardsSoilLayer firstLayer = stochasticSoilProfile.SoilProfile.Layers.First(); firstLayer.Data.UsePop = true; firstLayer.Data.Pop = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)1, CoefficientOfVariation = (RoundedDouble)2 }; MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile, CreateSurfaceLine()); // Call bool hasValidStatePoints = PersistableStateHelper.HasValidStatePoints(soilProfileUnderSurfaceLine); // Assert Assert.IsFalse(hasValidStatePoints); }
public void HasValidStatePoints_SoilProfileNull_ThrowsArgumentNullException() { // Call void Call() => PersistableStateHelper.HasValidStatePoints(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("soilProfile", exception.ParamName); }
public void GetLayerForPreconsolidationStress_PreconsolidationStressNull_ThrowsArgumentNullException() { // Call void Call() => PersistableStateHelper.GetLayerForPreconsolidationStress(Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("preconsolidationStress", exception.ParamName); }
public void HasValidPop_PopNull_ThrowsArgumentNullException() { // Call void Call() => PersistableStateHelper.HasValidPop(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("pop", exception.ParamName); }
public void HasValidStatePoints_SoilProfileWithPreconsolidationStressOutsideLayers_ReturnsFalse() { // Setup MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[] { MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, -50)) }); MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile, CreateSurfaceLine()); // Call bool hasValidStatePoints = PersistableStateHelper.HasValidStatePoints(soilProfileUnderSurfaceLine); // Assert Assert.IsFalse(hasValidStatePoints); }
public void GetLayerForPreconsolidationStress_PreconsolidationStressNotInLayer_ReturnsNull() { // Setup MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[] { MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, -50)) }); MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile, CreateSurfaceLine()); // Call MacroStabilityInwardsSoilLayer2D layer = PersistableStateHelper.GetLayerForPreconsolidationStress(soilProfileUnderSurfaceLine.Layers, soilProfileUnderSurfaceLine.PreconsolidationStresses.First()); // Assert Assert.IsNull(layer); }
public void GetLayerForPreconsolidationStress_LayersNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var preconsolidationStress = mocks.Stub <IMacroStabilityInwardsPreconsolidationStress>(); mocks.ReplayAll(); // Call void Call() => PersistableStateHelper.GetLayerForPreconsolidationStress(null, preconsolidationStress); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("layers", exception.ParamName); mocks.VerifyAll(); }
public void HasValidPop_DistributionWithValidValues_ReturnsTrue() { // Setup var mocks = new MockRepository(); var pop = mocks.Stub <IVariationCoefficientDistribution>(); mocks.ReplayAll(); pop.Mean = new RoundedDouble(2); pop.CoefficientOfVariation = new RoundedDouble(2); // Call bool hasValidPop = PersistableStateHelper.HasValidPop(pop); // Assert Assert.IsTrue(hasValidPop); mocks.VerifyAll(); }
private void ValidateData() { if (Math.Abs(calculation.InputParameters.MaximumSliceWidth - 1) > 1e-3) { LogWarning(string.Format(Resources.MacroStabilityInwardsCalculationExporter_ValidateData_DGeoSuite_only_supports_MaximumSliceWidth_one_but_calculation_has_MaximumSliceWidth_0, calculation.InputParameters.MaximumSliceWidth.ToString(null, CultureInfo.CurrentCulture))); } MacroStabilityInwardsSoilLayer2D[] layers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(calculation.InputParameters.SoilProfileUnderSurfaceLine.Layers).ToArray(); if (layers.Count(l => l.Data.IsAquifer) > 1) { LogWarning(Resources.MacroStabilityInwardsCalculationExporter_ValidateData_Multiple_aquifer_layers_not_supported_no_aquifer_layer_exported); } if (!PersistableStateHelper.HasValidStatePoints(calculation.InputParameters.SoilProfileUnderSurfaceLine)) { LogWarning(Resources.MacroStabilityInwardsCalculationExporter_ValidateData_Multiple_stress_points_not_supported_no_stress_points_exported); } }
private static PersistableState Create(IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile, MacroStabilityInwardsExportStageType stageType, IdFactory idFactory, MacroStabilityInwardsExportRegistry registry) { MacroStabilityInwardsSoilLayer2D[] layers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers).ToArray(); var statePoints = new List <PersistableStatePoint>(); if (PersistableStateHelper.HasValidStatePoints(soilProfile)) { statePoints.AddRange(layers.Where(l => l.Data.UsePop && PersistableStateHelper.HasValidPop(l.Data.Pop)) .Select(l => CreatePOPStatePoint(l, stageType, idFactory, registry)) .ToArray()); var preconsolidationStressPoints = new List <PersistableStatePoint>(); foreach (IMacroStabilityInwardsPreconsolidationStress preconsolidationStress in soilProfile.PreconsolidationStresses) { MacroStabilityInwardsSoilLayer2D layer = PersistableStateHelper.GetLayerForPreconsolidationStress(layers, preconsolidationStress); if (layer != null) { preconsolidationStressPoints.Add( CreateYieldStressStatePoint(layer, preconsolidationStress, stageType, idFactory, registry)); } } statePoints.AddRange(preconsolidationStressPoints); } var state = new PersistableState { Id = idFactory.Create(), StateLines = Enumerable.Empty <PersistableStateLine>(), StatePoints = statePoints }; registry.AddState(stageType, state.Id); return(state); }