/// <summary> /// Validates the Waternet with daily circumstances based on the values /// of the <see cref="IMacroStabilityInwardsWaternetInput"/>. /// </summary> /// <param name="input">The input to get the values from.</param> /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param> /// <returns>The validation issues found, if any.</returns> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> /// <exception cref="WaternetCalculationException">Thrown when an error occurs /// during the validation.</exception> public static IEnumerable <MacroStabilityInwardsKernelMessage> ValidateDaily(IMacroStabilityInwardsWaternetInput input, IGeneralMacroStabilityInwardsWaternetInput generalInput) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (generalInput == null) { throw new ArgumentNullException(nameof(generalInput)); } IWaternetCalculator calculator = MacroStabilityInwardsCalculatorFactory.Instance .CreateWaternetDailyCalculator( CreateDailyCalculatorInput(input, generalInput), MacroStabilityInwardsKernelWrapperFactory.Instance); try { return(calculator.Validate().ToArray()); } catch (WaternetCalculatorException e) { throw new WaternetCalculationException(e.Message, e); } }
/// <summary> /// Calculates the Waternet with daily circumstances based on the values /// of the <see cref="IMacroStabilityInwardsWaternetInput"/>. /// </summary> /// <param name="input">The input to get the values from.</param> /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param> /// <returns>A calculated <see cref="MacroStabilityInwardsWaternet"/>, /// or an empty <see cref="MacroStabilityInwardsWaternet"/> when the Waternet /// could not be calculated.</returns> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> public static MacroStabilityInwardsWaternet CalculateDaily(IMacroStabilityInwardsWaternetInput input, IGeneralMacroStabilityInwardsWaternetInput generalInput) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (generalInput == null) { throw new ArgumentNullException(nameof(generalInput)); } IWaternetCalculator calculator = MacroStabilityInwardsCalculatorFactory.Instance .CreateWaternetDailyCalculator( CreateDailyCalculatorInput(input, generalInput), MacroStabilityInwardsKernelWrapperFactory.Instance); try { WaternetCalculatorResult result = calculator.Calculate(); return(MacroStabilityInwardsWaternetConverter.Convert(result)); } catch (WaternetCalculatorException) { return(new MacroStabilityInwardsWaternet(new MacroStabilityInwardsPhreaticLine[0], new MacroStabilityInwardsWaternetLine[0])); } }
public void CreateWaternetDailyCalculator_WithWaternetCalculatorInput_ReturnsWaternetDailyCalculator() { // Setup IMacroStabilityInwardsCalculatorFactory factory = MacroStabilityInwardsCalculatorFactory.Instance; using (new MacroStabilityInwardsKernelFactoryConfig()) { // Call IWaternetCalculator waternetCalculator = factory.CreateWaternetDailyCalculator( new WaternetCalculatorInput(new WaternetCalculatorInput.ConstructionProperties { SurfaceLine = new MacroStabilityInwardsSurfaceLine("test"), SoilProfile = new TestSoilProfile(), PhreaticLineOffsets = new PhreaticLineOffsets(), DrainageConstruction = new DrainageConstruction() }), MacroStabilityInwardsKernelWrapperFactory.Instance); // Assert Assert.IsInstanceOf <WaternetDailyCalculator>(waternetCalculator); } }