Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityOutwards/MacroStabilityOutwardsKernelWrapper.cs =================================================================== diff -u -r3800 -r3819 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityOutwards/MacroStabilityOutwardsKernelWrapper.cs (.../MacroStabilityOutwardsKernelWrapper.cs) (revision 3800) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityOutwards/MacroStabilityOutwardsKernelWrapper.cs (.../MacroStabilityOutwardsKernelWrapper.cs) (revision 3819) @@ -36,8 +36,6 @@ using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Data.Standard.Logging; using Deltares.MacroStability.CSharpWrapper; -using Deltares.MacroStability.CSharpWrapper.Input; -using Deltares.MacroStability.CSharpWrapper.Output; using CharacteristicPointType = Deltares.DamEngine.Data.Geotechnics.CharacteristicPointType; using MacroStabilityOutput = Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityInwards.MacroStabilityOutput; @@ -53,20 +51,20 @@ private string fileNameForCalculation; /// - /// Gets or sets the failure mechanisme paramaters for mstab. + /// Gets or sets the failure mechanism parameters for mstab. /// /// - /// The failure mechanisme paramaters mstab. + /// The failure mechanism parameters mstab. /// public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; } /// /// Prepares the specified dam kernel input. /// /// The dam kernel input. - /// + /// The number of the current iteration. /// The kernel data input. - /// The kernel data output + /// The kernel data output. /// /// Result of the prepare /// @@ -116,7 +114,7 @@ macroStabilityInput.Input = fillMacroStabilityWrapperFromEngine.CreateMacroStabilityInput(damKernelInput, FailureMechanismParametersMStab.MStabParameters, waterNet); fileNameForCalculation = MacroStabilityCommonHelper.GetStabilityInputFileName(damKernelInput, iterationIndex, FailureMechanismParametersMStab.MStabParameters.Model); stabilityCalculator = new Calculator(macroStabilityInput.Input); - var firstPrepareResult = PrepareKernel(stabilityCalculator, fileNameForCalculation); + var firstPrepareResult = MacroStabilityCommonHelper.PrepareKernel(stabilityCalculator, fileNameForCalculation); return firstPrepareResult; } @@ -131,28 +129,6 @@ return PrepareResult.NotRelevant; } - private PrepareResult PrepareKernel(Calculator calculator, string fileName) - { - try - { - // For now a simple check to see if any data has been past at all. - var inputAsXml = calculator.KernelInputXml; - - File.WriteAllText(fileName, inputAsXml); - - if (inputAsXml.Length > 10) - { - return PrepareResult.Successful; - } - - return PrepareResult.Failed; - } - catch - { - return PrepareResult.Failed; - } - } - /// /// Validates the specified kernel data input. /// @@ -164,62 +140,7 @@ /// public int Validate(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, out List messages) { - MacroStabilityKernelDataInput macroStabilityKernelDataInput = (MacroStabilityKernelDataInput)kernelDataInput; - messages = new List(); - try - { - var result = new Validator(macroStabilityKernelDataInput.Input).Validate(); - if (result.IsValid) - { - return 0; - } - - if (kernelDataOutput != null) - { - ((MacroStabilityOutput)kernelDataOutput).CalculationResult = CalculationResult.InvalidInputData; - } - - foreach (var resultMessage in result.Messages) - { - var message = new LogMessage - { - Message = resultMessage.Content - }; - switch (resultMessage.MessageType) - { - case MessageType.Error: - { - message.MessageType = LogMessageType.Error; - break; - } - case MessageType.Info: - { - message.MessageType = LogMessageType.Info; - break; - } - case MessageType.Warning: - { - message.MessageType = LogMessageType.Warning; - break; - } - } - - messages.Add(message); - } - - return 1; - } - catch (Exception e) - { - var message = new LogMessage { MessageType = LogMessageType.FatalError, Message = e.Message }; - messages.Add(message); - if (kernelDataOutput != null) - { - ((MacroStabilityOutput)kernelDataOutput).CalculationResult = CalculationResult.InvalidInputData; - } - - return 1; - } + return MacroStabilityCommonHelper.Validate(kernelDataInput, kernelDataOutput, out messages); } /// @@ -235,7 +156,7 @@ MacroStabilityCommonHelper.ThrowWhenMacroStabilityKernelInputNull(macroStabilityKernelDataInput); MacroStabilityCommonHelper.ThrowWhenMacroStabilityKernelOutputNull(macroStabilityOutput); - PerformStabilityCalculation(macroStabilityKernelDataInput.Input, macroStabilityOutput, + MacroStabilityCommonHelper.PerformStabilityCalculation(macroStabilityKernelDataInput.Input, macroStabilityOutput, fileNameForCalculation, stabilityCalculator, out messages); var fileName = Path.GetFileNameWithoutExtension(fileNameForCalculation); foreach (var logMessage in messages) @@ -244,39 +165,12 @@ } } - private void PerformStabilityCalculation(MacroStabilityInput input, MacroStabilityOutput macroStabilityOutput, - string fileName, ICalculator calculator, out List messages) - { - macroStabilityOutput.CalculationResult = CalculationResult.NoRun; - macroStabilityOutput.StabilityOutputItems = new List(); - messages = new List(); - try - { - var macroStabilityOutputKernel = calculator.Calculate(); - FillEngineFromMacroStabilityWrapperOutput.FillEngineDataWithResults(macroStabilityOutputKernel, macroStabilityOutput, - out messages); -#if DEBUG - foreach (var stabilityOutputItem in macroStabilityOutput.StabilityOutputItems) - { - input.StabilityModel.BishopCalculationCircle = stabilityOutputItem.BishopCalculationCircle; - MacroStabilityCommonHelper.WriteStixFileBasedOnInputAndResultsSearchGrid(fileName, input); - } -#endif - MacroStabilityCommonHelper.WriteStixFileBasedOnInputAndResultsSlipPlane(fileName, input, macroStabilityOutput); - } - catch (Exception e) - { - macroStabilityOutput.CalculationResult = CalculationResult.UnexpectedError; - messages.Add(new LogMessage(LogMessageType.Error, null, e.Message)); - } - } - /// /// Fills the design results with the kernel output. /// /// The dam kernel input. /// The kernel data output. - /// + /// The design scenario /// The result message. /// The design results. ///