Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapper.cs
===================================================================
diff -u -r1925 -r1927
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapper.cs (.../DamWbiMacroStabilityInwardsKernelWrapper.cs) (revision 1925)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapper.cs (.../DamWbiMacroStabilityInwardsKernelWrapper.cs) (revision 1927)
@@ -4,6 +4,7 @@
using System.Linq;
using Deltares.DamEngine.Calculators.DikesDesign;
using Deltares.DamEngine.Calculators.KernelWrappers.Common;
+using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon;
using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces;
using Deltares.DamEngine.Calculators.Properties;
using Deltares.DamEngine.Data.Design;
@@ -21,6 +22,15 @@
{
private WTIStabilityCalculation wbiMacroStabilityCalculator = null;
private int lastIterationIndex = 0;
+
+ ///
+ /// Gets or sets the failure mechanisme paramaters for mstab.
+ ///
+ ///
+ /// The failure mechanisme paramaters mstab.
+ ///
+ public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; } //ToDo MWDAM-? Use same as for DGeoStability or create new one for WBI?
+
public bool tmpPresumePrepareSucceeds; //ToDo MWDAM-1356
public bool tmpPresumePrepareIsUplift; //ToDo MWDAM-? Determine Uplift for Wbi, same as for DGeoStability?
public bool tmpPresumeInputValid; //ToDo MWDAM-1367
@@ -38,7 +48,6 @@
///
public PrepareResult Prepare(DamKernelInput damKernelInput, int iterationIndex, out IKernelDataInput kernelDataInput, out IKernelDataOutput kernelDataOutput)
{
- ThrowWhenWbiMacroStabilityCalculatorNull(wbiMacroStabilityCalculator);
var macroStabilityInput = new DamWbiMacroStabilityInput();
kernelDataInput = macroStabilityInput;
var macroStabilityOutput = new DamWbiMacroStabilityOutput
@@ -56,18 +65,9 @@
kernelDataOutput = macroStabilityOutput;
if (upliftSituation.IsUplift)
{
- var xmlInput = CreateXmlInput(macroStabilityInput);
- // ToDo MWDAM-1356: Not clear yet what parts are required for input. Temporary test code added.
- //ToDo wbiMacroStabilityCalculator.InitializeForDeterministic(xmlInput);
- //ToDo return PrepareResult.Successful;
- if (tmpPresumePrepareSucceeds)
- {
- return PrepareResult.Successful;
- }
- else
- {
- return PrepareResult.Failed;
- }
+ // ToDo MWDAM-1356: Not clear yet what parts are required for input.
+ var xmlInput = CreateXmlInput(macroStabilityInput, FailureMechanismParametersMStab.EmbankmentDesignParameters);
+ return PrepareKernel(xmlInput);
}
else
{
@@ -81,9 +81,33 @@
return PrepareResult.Failed;
}
}
-
- private string CreateXmlInput(DamWbiMacroStabilityInput macroStabilityInput)
+
+ private PrepareResult PrepareKernel(string xmlInput)
{
+ ThrowWhenWbiMacroStabilityCalculatorNull(wbiMacroStabilityCalculator);
+ try
+ {
+ // ToDo MWDAM-1356: Not clear yet what parts are required for input. Temporary test code added.
+ //wbiMacroStabilityCalculator.InitializeForDeterministic(xmlInput); //ToDo: uncomment when input is set
+ //return PrepareResult.Successful; //ToDo: uncomment when input is set
+ if (tmpPresumePrepareSucceeds) //ToDo: remove the temporary test code when input is set
+ {
+ return PrepareResult.Successful;
+ }
+ else
+ {
+ return PrepareResult.Failed;
+ }
+
+ }
+ catch
+ {
+ return PrepareResult.Failed;
+ }
+ }
+
+ private string CreateXmlInput(DamWbiMacroStabilityInput macroStabilityInput, EmbankmentDesignParameters embankmentDesignParameters)
+ {
string xmlInput = "";
//ToDo in MWDAM-1356
return xmlInput;
@@ -384,11 +408,61 @@
return isDesignReady;
}
+ ///
+ /// Prepares the design.
+ ///
+ /// The kernel data input.
+ /// The kernel data output.
+ /// The dam kernel input.
+ /// Index of the iteration.
+ /// The embankment design parameters.
public void PrepareDesign(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, DamKernelInput damKernelInput,
int iterationIndex, out EmbankmentDesignParameters embankmentDesignParameters)
{
- // ToDo: Not clear yet if this must be done or how
- throw new NotImplementedException();
+ DamWbiMacroStabilityInput macroStabilityInput = kernelDataInput as DamWbiMacroStabilityInput;
+ ThrowWhenWbiMacroStabilityKernelInputNull(macroStabilityInput);
+
+ lastIterationIndex = iterationIndex;
+ MStabModelType model = MStabModelType.UpliftVan;
+ var location = damKernelInput.Location;
+ //ToDo MWDAM-1356: Not clear yet what parts are required for input. subSoilScenario, riverLevel and others might be necessary for CreateXmlInput
+ //var subSoilScenario = damKernelInput.SubSoilScenario;
+ //double riverLevel = damKernelInput.RiverLevelHigh;
+ EmbankmentDesignParameters embankmentDesignParametersForKernelInput;
+ if (iterationIndex < 1)
+ {
+ // This is the first (initial) call to prepareDesign.
+ // The embankment material is set to DikeEmbankmentMaterial, because the next iteration (Index = 1) will be height adaption
+ embankmentDesignParameters = new EmbankmentDesignParameters()
+ {
+ EmbankmentMaterialname = location.DikeEmbankmentMaterial,
+ };
+ //ToDo MWDAM-? Use FailureMechanismParametersMStab or create new one for WBI?
+ FailureMechanismParametersMStab.EmbankmentDesignParameters = embankmentDesignParameters;
+ embankmentDesignParametersForKernelInput = null;
+ }
+ else
+ {
+ // Calculation iterations start with IterationIndex = 1.
+ // When IterationIndex = 1: height adaption.
+ // When Iteration > 1: Slope/Shoulder adaption.
+ // Starting from IterationIndex 2 the following parameters should be used:
+ // - The embankment material is set to ShoulderEmbankmentMaterial.
+ // - The previous geometry is set to the height adapted geometry (name is constructed with iteration index 1).
+ if (iterationIndex == 2)
+ {
+ FailureMechanismParametersMStab.EmbankmentDesignParameters.EmbankmentMaterialname = location.ShoulderEmbankmentMaterial;
+ }
+ // In the following prepareDesign calls just return the stored embankmentDesignParameters
+ embankmentDesignParameters = FailureMechanismParametersMStab.EmbankmentDesignParameters;
+ embankmentDesignParametersForKernelInput = embankmentDesignParameters;
+ }
+ var xmlInput = CreateXmlInput(macroStabilityInput, embankmentDesignParametersForKernelInput);
+ var prepareResult = PrepareKernel(xmlInput);
+ if (prepareResult != PrepareResult.Successful)
+ {
+ throw new MacroStabilityException(Resources.DamWbiMacroStabilityKernelWrapper_PrepareForWbiMacroStabilityDidNotSucceed);
+ }
}
///