// Copyright (C) Stichting Deltares 2023. All rights reserved. // // This file is part of the application DAM - Live. // // DAM - Live is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using Deltares.Dam.Data; using Deltares.DamLive.Io; namespace Deltares.DamLive.Application; public static class FillDomainFromXmlCalculationParameters { public static DamFailureMechanismeCalculationSpecification CreateCalculationParameters(XmlCalculationParameters xmlCalculationParameters) { var calculationParameters = new DamFailureMechanismeCalculationSpecification(); TransferCalculationModules(xmlCalculationParameters.CalculationModules, calculationParameters); TransferStabilityParameters(xmlCalculationParameters.StabilityParameters, calculationParameters); return calculationParameters; } private static void TransferCalculationModules(XmlCalculationParametersCalculationModules calculationModulesXml, DamFailureMechanismeCalculationSpecification calculationParameters) { if (calculationModulesXml != null) { if (calculationModulesXml.PipingWtiSpecified && calculationModulesXml.PipingWti) { // Note: set FailureMechanismSystemType first so that CalculationModel will be set correctly too. calculationParameters.FailureMechanismSystemType = FailureMechanismSystemType.Piping; calculationParameters.PipingModelType = PipingModelType.Wti2017; } if (calculationModulesXml.PipingBlighSpecified && calculationModulesXml.PipingBligh) { // Note: set FailureMechanismSystemType first so that CalculationModel will be set correctly too. calculationParameters.FailureMechanismSystemType = FailureMechanismSystemType.Piping; calculationParameters.PipingModelType = PipingModelType.Bligh; } if (calculationModulesXml.StabilityInsideSpecified && calculationModulesXml.StabilityInside) { calculationParameters.FailureMechanismSystemType = FailureMechanismSystemType.StabilityInside; } if (calculationModulesXml.StabilityOutsideSpecified && calculationModulesXml.StabilityOutside) { calculationParameters.FailureMechanismSystemType = FailureMechanismSystemType.StabilityOutside; } } } private static void TransferStabilityParameters(XmlCalculationParametersStabilityParameters stabilityParametersXml, DamFailureMechanismeCalculationSpecification calculationParameters) { if (stabilityParametersXml.SearchMethodSpecified || stabilityParametersXml.CalculationModelSpecified) { if (stabilityParametersXml.CalculationModelSpecified && (calculationParameters.FailureMechanismSystemType == FailureMechanismSystemType.StabilityInside || calculationParameters.FailureMechanismSystemType == FailureMechanismSystemType.StabilityOutside)) { calculationParameters.CalculationModel = XmlConversionHelper.ConvertToModelType(stabilityParametersXml.CalculationModel); } if (stabilityParametersXml.SearchMethodSpecified) { calculationParameters.SearchMethod = XmlConversionHelper.ConvertToSearchMethod(stabilityParametersXml.SearchMethod); } } } }