Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamPipingBligh/DamPipingBlighKernelWrapper.cs =================================================================== diff -u -r1122 -r1129 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamPipingBligh/DamPipingBlighKernelWrapper.cs (.../DamPipingBlighKernelWrapper.cs) (revision 1122) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamPipingBligh/DamPipingBlighKernelWrapper.cs (.../DamPipingBlighKernelWrapper.cs) (revision 1129) @@ -26,7 +26,6 @@ using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; using Deltares.DamEngine.Calculators.Properties; using Deltares.DamEngine.Calculators.Uplift; -using Deltares.DamEngine.Data.Standard; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; using Deltares.DamEngine.Data.General.Results; @@ -70,7 +69,6 @@ var damPipingBlighInput = new DamPipingBlighInput(); var soilProfile1D = damKernelInput.SubSoilScenario.SoilProfile1D; - var surfaceLine = damKernelInput.Location.SurfaceLine; var location = damKernelInput.Location; double waterLevel = damKernelInput.RiverLevelHigh; UpliftSituation upliftSituation; @@ -180,14 +178,8 @@ { DamPipingBlighInput damPipingBlighInput = kernelDataInput as DamPipingBlighInput; DamPipingBlighOutput damPipingBlighOutput = (DamPipingBlighOutput)kernelDataOutput; - if (damPipingBlighInput == null) - { - throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoInputObjectDefinedForBligh); - } - if (damPipingBlighOutput == null) - { - throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoOutputObjectDefinedForBligh); - } + ThrowWhenKernelInputNull(damPipingBlighInput); + ThrowWhenKernelOutputNull(damPipingBlighOutput); PerformSingleCalculationBligh(out messages, damPipingBlighOutput, damPipingBlighInput); } @@ -223,10 +215,7 @@ private static PipingCalculatorBligh CreatePipingCalculatorBligh(IKernelDataInput kernelDataInput) { DamPipingBlighInput damPipingBlighInput = kernelDataInput as DamPipingBlighInput; - if (damPipingBlighInput == null) - { - throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoInputObjectDefinedForBligh); - } + ThrowWhenKernelInputNull(damPipingBlighInput); var calculator = new PipingCalculatorBligh { HRiver = damPipingBlighInput.HRiver, @@ -250,7 +239,7 @@ public void PostProcess(DamKernelInput damKernelInput, IKernelDataOutput kernelDataOutput, string resultMessage, out List designResults) { DamPipingBlighOutput damPipingBlighOutput = kernelDataOutput as DamPipingBlighOutput; - ThrowWhenKernelInputNull(damKernelInput); + ThrowWhenDamKernelInputNull(damKernelInput); ThrowWhenKernelOutputNull(damPipingBlighOutput); designResults = new List(); @@ -273,28 +262,21 @@ designResults.Add(designResult); } - private static void ThrowWhenKernelOutputNull(DamPipingBlighOutput damPipingBlighOutput) - { - if (damPipingBlighOutput == null) - { - throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoOutputObjectDefinedForBligh); - } - } - - private static void ThrowWhenKernelInputNull(DamKernelInput damKernelInput) - { - if (damKernelInput == null) - { - throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoInputObjectDefinedForBligh); - } - } - + /// + /// Calculates the design at point. + /// + /// The dam kernel input. + /// The kernel data input. + /// The kernel data output. + /// The point. + /// The messages. + /// public ShoulderDesign CalculateDesignAtPoint(DamKernelInput damKernelInput, IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, GeometryPoint point, out List messages) { messages = new List(); DamPipingBlighInput damPipingBlighInput = kernelDataInput as DamPipingBlighInput; DamPipingBlighOutput damPipingBlighOutput = (DamPipingBlighOutput)kernelDataOutput; - ThrowWhenKernelInputNull(damKernelInput); + ThrowWhenDamKernelInputNull(damKernelInput); ThrowWhenKernelOutputNull(damPipingBlighOutput); Location location = damKernelInput.Location; SoilProfile1D soilProfile = damKernelInput.SubSoilScenario.SoilProfile1D; @@ -337,5 +319,52 @@ } return null; } + + /// + /// Evaluates the design (current factor greater than desired factor) + /// + /// The dam kernel input. + /// The kernel data input. + /// The kernel data output. + /// The evaluation message. + /// + /// if the design was succesful + /// + /// + public bool EvaluateDesign(DamKernelInput damKernelInput, IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, out string evaluationMessage) + { + DamPipingBlighInput damPipingBlighInput = kernelDataInput as DamPipingBlighInput; + DamPipingBlighOutput damPipingBlighOutput = (DamPipingBlighOutput)kernelDataOutput; + ThrowWhenKernelInputNull(damPipingBlighInput); + ThrowWhenDamKernelInputNull(damKernelInput); + ThrowWhenKernelOutputNull(damPipingBlighOutput); + double fosRequiered = damKernelInput.Location.ModelFactors.RequiredSafetyFactorPiping.Value; + double fosAchieved = damPipingBlighOutput.FoSp; + evaluationMessage = String.Format(Resources.FactorAchievedVsFactorRequired, fosAchieved, fosRequiered); + return (fosAchieved >= fosRequiered); + } + private static void ThrowWhenKernelInputNull(DamPipingBlighInput damPipingBlighInput) + { + if (damPipingBlighInput == null) + { + throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoInputObjectDefinedForBligh); + } + } + private static void ThrowWhenKernelOutputNull(DamPipingBlighOutput damPipingBlighOutput) + { + if (damPipingBlighOutput == null) + { + throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoOutputObjectDefinedForBligh); + } + } + + private static void ThrowWhenDamKernelInputNull(DamKernelInput damKernelInput) + { + if (damKernelInput == null) + { + throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoDamInputObjectDefinedForBligh); + } + } + } }