using System.Collections.Generic; using System.Data; using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; using Deltares.DamEngine.Calculators.Properties; using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.Results; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Data.Standard.Logging; using Deltares.DamPiping.Sellmeijer4ForcesCalculator; namespace Deltares.DamEngine.Calculators.KernelWrappers.DamPipingSellmeijer4Forces { class DamPipingSellmeijer4ForcesKernelWrapper : IKernelWrapper { public IKernelDataInput Prepare(DamKernelInput damKernelInput) { // TODO: this is just fake data return new DamPipingSellmeijer4ForcesInput() { HRiver = 1.0, HExit = 0.0, Rc = 0.3, DTotal = 2.0, AquiferHeight = 8.0, SeepageLength = 40.5, D70 = 200.0, WhitesConstant = 0.25, BeddingAngle = 37.0, WaterViscosity = 1.33E-06, PermeabilityKx = 0.0001 }; } public int Validate(IKernelDataInput kernelDataInput, out List messages) { var calculator = PipingCalculatorSellmeijer4Forces(kernelDataInput); List kernelMessages = calculator.Validate(); messages = new List(); foreach (string stringMessage in kernelMessages) { messages.Add(new LogMessage() { Message = stringMessage, MessageType = LogMessageType.Error }); } return messages.Count; } public IKernelDataOutput Execute(IKernelDataInput kernelDataInput, out List messages) { var calculatorBligh = PipingCalculatorSellmeijer4Forces(kernelDataInput); calculatorBligh.Calculate(); var damPipingOutput = new DamPipingSellmeijer4ForcesOutput(); damPipingOutput.FoSp = calculatorBligh.FoSp; damPipingOutput.Hc = calculatorBligh.Hc; messages = new List(); return damPipingOutput; } private static PipingCalculatorSellmeijer4Forces PipingCalculatorSellmeijer4Forces(IKernelDataInput kernelDataInput) { DamPipingSellmeijer4ForcesInput damPipingInput = kernelDataInput as DamPipingSellmeijer4ForcesInput; if (damPipingInput == null) { throw new NoNullAllowedException(Resources.DamPipingSellmeijer4ForcesKernelWrapper_PipingCalculatorSellmeijer4Forces_NoInputObjectDefinedForSellmeijer4Forces); } var calculator = new PipingCalculatorSellmeijer4Forces { HRiver = damPipingInput.HRiver, HExit = damPipingInput.HExit, Rc = damPipingInput.Rc, DTotal = damPipingInput.DTotal, SeepageLength = damPipingInput.SeepageLength, D70 = damPipingInput.D70 }; return calculator; } public void PostProcess(IKernelDataOutput kernelDataOutput, out DesignResult designResult) { DamPipingSellmeijer4ForcesOutput damPipingOutput = kernelDataOutput as DamPipingSellmeijer4ForcesOutput; if (damPipingOutput == null) { throw new NoNullAllowedException(Resources.DamPipingSellmeijer4ForcesKernelWrapper_PostProcess_NoOutputObjectDefinedForSellmeijer4Forces); } string id = "id"; string soilProfile2DName = "soilProfile2DName"; var d = new DamFailureMechanismeCalculationSpecification(); var s = new DesignScenario(); var p = new SoilProfile1D(); designResult = new DesignResult(id, d, s, p, soilProfile2DName, AnalysisType.NoAdaption, 0); var pipingDesignResults = new PipingDesignResults(PipingModelType.Sellmeijer4Forces); pipingDesignResults.BlighFactor = damPipingOutput.FoSp; pipingDesignResults.BlighHcritical = damPipingOutput.Hc; designResult.PipingDesignResults = pipingDesignResults; } } }