Index: dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapper.cs =================================================================== diff -u -r694 -r715 --- dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapper.cs (.../DamMacroStabilityKernelWrapper.cs) (revision 694) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapper.cs (.../DamMacroStabilityKernelWrapper.cs) (revision 715) @@ -34,18 +34,32 @@ /// public PrepareResult Prepare(DamKernelInput damKernelInput, out IKernelDataInput kernelDataInput, out IKernelDataOutput kernelDataOutput) { - // TODO: this is just fake data + // ToDo zant set stiFileName +// string stabilityDirectory = GetStabilityCalculationDirectory(); +// string filenameExtension = GetFilenameExtension(); +// string fileName = calculationName + filenameExtension; +// var stabilityProjectFilename = Path.Combine(stabilityDirectory, fileName); + const string testFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\Files\MacroStability"; // Relative paths in ini file do not work yet in DGeoStability 16.2. This is fixed in 18.1. var absoluteFolder = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), testFolder)); var stiFileName = Path.Combine(absoluteFolder, "test.sti"); - kernelDataInput = new DamMacroStabilityInput() + + + var damPipingInput = new DamMacroStabilityInput() { DGeoStabilityExePath = Path.Combine(DamMacroStabilityFolder, DGeoStabilityExe), DGeoStabilityInputFileName = stiFileName }; + kernelDataInput = damPipingInput; kernelDataOutput = new DamMacroStabilityOutput(); + // Write xml file + XDocument xmlDocument = CreateMstabDamXmlDocument(damKernelInput, damPipingInput); + + // Use xml file to create sti file + CreateStiFile(xmlDocument); + return PrepareResult.Successful; } @@ -82,14 +96,6 @@ DamMacroStabilityOutput damMacroStabilityOutput = (DamMacroStabilityOutput) kernelDataOutput; messages = new List(); - // ToDo zant Question: write sti file in prepare or in execute? - - // Write xml file - XDocument xmlDocument = CreateMstabDamXmlDocument(); - - // Use xml file to create sti file - CreateStiFile(xmlDocument); - // start calculation var calculator = StabilityCalculator(kernelDataInput); calculator.Calculate(); @@ -118,50 +124,34 @@ } } - internal XDocument CreateMstabDamXmlDocument() + internal XDocument CreateMstabDamXmlDocument(DamKernelInput damKernelInput, DamMacroStabilityInput kernelDataInput) { - // ToDo zant Fake data -// var stabilityProjectFilename = "testproject"; -// var scenario = new DesignScenario(); -// var soilProfile = new SoilProfile1D(); -// var soilGeometry2DName = "testgeom2D"; -// var riverLevel = 1.1; -// var mstabDesignEmbankment = new MStabDesignEmbankment(); -// var surfaceLine = new SurfaceLine2(); -// var trafficLoad = 2.2; -// var requiredSafetyFactor = 1.2; -// List errorMessages; -// -// XDocument TestmstabXml = MStabXmlDoc.CreateMStabXmlDoc(stabilityProjectFilename, scenario, soilProfile, soilGeometry2DName, -// riverLevel, mstabDesignEmbankment, surfaceLine, trafficLoad, requiredSafetyFactor, out errorMessages); -// TestmstabXml.Save(stabilityProjectFilename + ".xml"); - - // ToDo zant_xml tmp use predefined xml doc until CreateMstabDamXmlDocument is fully implemented const string testFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\Files\MacroStability"; - var xmlFileName = Path.Combine(testFolder, "test.xml"); - var stiFileName = Path.Combine(testFolder, "test.sti"); + // var stabilityProjectFilename = Path.Combine(testFolder, "test.sti"); + // var soilDbName = var geometryFileName = Path.Combine(testFolder, "DWP_1.sti"); - var soilDbName = Path.Combine(testFolder, "DAM Tutorial Design0.soilmaterials.mdb"); - XDocument mstabXml = XDocument.Load(xmlFileName); - XElement inputElement = (from element in mstabXml.Root.Descendants() - where element.Name.LocalName == DamMStabAssembler.XmlElementNameInput - select element).Single(); - XAttribute mstabFileName = inputElement.Attribute(DamMStabAssembler.XmlAttributeMStabFileName); - Debug.Assert(mstabFileName != null, "mstabFileName != null"); - mstabFileName.Value = stiFileName; - // modify name of Soil DB Name - XAttribute dbName = inputElement.Attribute(DamMStabAssembler.XmlAttributeSoilDBName); - Debug.Assert(dbName != null, "dbName != null"); - dbName.Value = soilDbName; + var stabilityProjectFilename = kernelDataInput.DGeoStabilityInputFileName; + var scenario = damKernelInput.DesignScenario; + var subSoilScenario = damKernelInput.SubSoilScenario; + var riverLevel = scenario.RiverLevel; + var surfaceLine = scenario.Location.SurfaceLine; + var trafficLoad = scenario.Location.StabilityOptions.TrafficLoad; + var requiredSafetyFactor = scenario.RequiredSafetyFactorStabilityInnerSlope; + if (requiredSafetyFactor == null) + { + throw new MacroStabilityException("Required safety factor must be specified"); + } + List errorMessages; + + // ToDo zant + scenario.Location.StabilityOptions.MapForSoilGeometries2D = testFolder; + scenario.Location.SoildatabaseName = Path.Combine(testFolder, "DAM Tutorial Design0.soilmaterials.mdb"); + scenario.Location.DikeEmbankmentMaterial = "dijksmateriaal_klei"; - // modify name of geometry input file - XElement geometryOptionsElement = (from element in inputElement.Descendants() - where element.Name.LocalName == DamMStabAssembler.XmlElementGeometryCreationOptions - select element).Single(); - XAttribute geomFileName = geometryOptionsElement.Attribute(DamMStabAssembler.XmlAttributeSoilGeometry2DFilename); - Debug.Assert(geomFileName != null, "geomFileName != null"); - geomFileName.Value = geometryFileName; + XDocument mstabXml = MStabXmlDoc.CreateMStabXmlDoc(stabilityProjectFilename, scenario, subSoilScenario, + riverLevel, null, surfaceLine, trafficLoad, requiredSafetyFactor.Value, out errorMessages); + mstabXml.Save(stabilityProjectFilename + ".xml"); return mstabXml; }