// Copyright (C) Stichting Deltares 2019. All rights reserved.
//
// This file is part of the Dam Engine.
//
// The Dam Engine 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 System;
using Deltares.DamEngine.Data.Design;
using Deltares.DamEngine.Data.Geotechnics;
using Deltares.DamEngine.Data.Standard;
using Deltares.DamEngine.Data.Standard.Calculation;
namespace Deltares.DamEngine.Data.General.Results
{
///
/// Contains the results for the design calculations.
///
///
public class DesignResult : ICloneable
{
private double? safetyFactor;
private string baseFileName;
private string calculationSubDir;
private string locationName;
private string scenarioName;
private string profileName;
private CalculationResult calculationResult = CalculationResult.NoRun;
private StabilityDesignResults stabilityDesignResults;
private PipingDesignResults pipingDesignResults;
///
/// Gets or sets the safety factor.
/// Note: this is a placeholder, not to be part of the results as written to xml
///
///
/// The safety factor.
///
public double? SafetyFactor
{
get
{
if (DamFailureMechanismeCalculation != null)
{
switch (DamFailureMechanismeCalculation.FailureMechanismSystemType)
{
case FailureMechanismSystemType.StabilityInside:
case FailureMechanismSystemType.StabilityOutside:
case FailureMechanismSystemType.HorizontalBalance:
return StabilityDesignResults.SafetyFactor;
case FailureMechanismSystemType.Piping:
return PipingDesignResults.SafetyFactor;
}
}
return safetyFactor;
}
set
{
if (DamFailureMechanismeCalculation != null)
{
if (DamFailureMechanismeCalculation.FailureMechanismSystemType == FailureMechanismSystemType.Piping)
{
PipingDesignResults.SafetyFactor = value;
}
else
{
StabilityDesignResults.SafetyFactor = value;
}
}
safetyFactor = value;
}
}
///
/// Gets or sets the dam failure mechanisme calculation.
/// Note: this is a placeholder, not to be part of the results as written to xml
///
///
/// The dam failure mechanisme calculation.
///
public DamFailureMechanismeCalculationSpecification DamFailureMechanismeCalculation { get; set; }
///
/// Gets or sets the scenario.
/// Note: this is a placeholder, not to be part of the results as written to xml
///
///
/// The scenario.
///
public DesignScenario Scenario { get; set; }
///
/// Initializes a new instance of the class.
/// Is only to be used by this.Clone() and in FillDamFromXmlOutput (used in tests), nowhere else
///
internal DesignResult()
{
// only for Clone() method
}
///
/// Initializes a new instance of the class.
/// Needed for testing purposes.
///
/// Name of the location.
/// Name of the scenario.
internal DesignResult(string locationName, string scenarioName)
{
this.locationName = locationName;
this.scenarioName = scenarioName;
}
///
/// Initializes a new instance of the class.
///
/// The dam failure mechanisme calculation specification.
/// The scenario.
/// The soil profile.
/// Name of the soil geometry2 d.
public DesignResult(DamFailureMechanismeCalculationSpecification damFailureMechanismeCalculationSpecification,
DesignScenario scenario, SoilProfile1D soilProfile, string soilGeometry2DName)
{
if (scenario != null)
{
locationName = scenario.Location.Name;
scenarioName = scenario.LocationScenarioID;
}
baseFileName = "";
calculationSubDir = "";
DamFailureMechanismeCalculation = damFailureMechanismeCalculationSpecification;
Scenario = scenario;
if (damFailureMechanismeCalculationSpecification != null)
{
switch (damFailureMechanismeCalculationSpecification.FailureMechanismSystemType)
{
case FailureMechanismSystemType.StabilityInside:
case FailureMechanismSystemType.HorizontalBalance:
case FailureMechanismSystemType.StabilityOutside:
profileName = soilGeometry2DName;
break;
case FailureMechanismSystemType.Piping:
if (soilProfile != null)
{
profileName = soilProfile.Name;
}
else
{
profileName = soilGeometry2DName;
}
break;
}
}
}
//Identifiers, needed to retrace the origin of the result
///
/// Gets the name of the location.
/// For identification purpose
///
///
/// The name of the location.
///
public string LocationName
{
get { return locationName; }
}
///
/// Gets the name of the scenario.
/// For identification purpose
///
///
/// The name of the scenario.
///
public string ScenarioName
{
get { return scenarioName; }
}
///
/// Gets or sets the name of the profile.
/// For identification purpose
///
///
/// The name of the profile.
///
public string ProfileName
{
get
{
return profileName;
}
set
{
profileName = value;
}
}
///
/// Gets or sets the name of the base file.
///
///
/// The name of the base file.
/// Can be used to retrace results files.
///
public string BaseFileName // real result for all.
{
get { return baseFileName; }
set { baseFileName = value; }
}
///
/// Gets or sets the calculation sub dir (as relative path).
///
///
/// The calculation sub dir.
///
public string CalculationSubDir
{
get { return calculationSubDir; }
set { calculationSubDir = value; }
}
///
/// Gets or sets the calculation result.
/// This is a derived result.
///
///
/// The calculation result.
///
public CalculationResult CalculationResult
{
get { return calculationResult; }
set { calculationResult = value; }
}
///
/// Gets or sets the stability design results.
///
///
/// The stability design results.
///
public StabilityDesignResults StabilityDesignResults
{
get
{
return stabilityDesignResults;
}
set
{
stabilityDesignResults = value;
}
}
///
/// Gets or sets the piping design results.
///
///
/// The piping design results.
///
public PipingDesignResults PipingDesignResults
{
get
{
return pipingDesignResults;
}
set
{
pipingDesignResults = value;
}
}
///
/// Copy data
///
///
private void Assign(DesignResult designResult)
{
// copy place holders
DamFailureMechanismeCalculation = designResult.DamFailureMechanismeCalculation;
Scenario = designResult.Scenario;
// copy direct data
baseFileName = designResult.BaseFileName;
calculationSubDir = designResult.CalculationSubDir;
locationName = designResult.LocationName;
scenarioName = designResult.ScenarioName;
profileName = designResult.ProfileName;
calculationResult = designResult.calculationResult;
safetyFactor = designResult.SafetyFactor;
stabilityDesignResults = new StabilityDesignResults();
designResult.StabilityDesignResults.CloneProperties(stabilityDesignResults);
pipingDesignResults = new PipingDesignResults(DamFailureMechanismeCalculation.PipingModelType);
designResult.PipingDesignResults.CloneProperties(pipingDesignResults);
}
///
/// Make a clone of object
///
///
public object Clone()
{
DesignResult designResult = new DesignResult();
designResult.Assign(this);
return designResult;
}
}
}