diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IEffectiveDepth.cs b/StructureHelperCommon/Infrastructures/Interfaces/IEffectiveDepth.cs index 7179500..7823cfd 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/IEffectiveDepth.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/IEffectiveDepth.cs @@ -6,8 +6,18 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Infrastructures.Interfaces { + /// + /// Implement effective depth for reinforced concrete section + /// public interface IEffectiveDepth { + /// + /// Full depth of cross-section + /// + double FullDepth { get; set; } + /// + /// Effective depth of cross-section + /// double EffectiveDepth { get; set; } } } diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IGetResultByInputDataLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/IGetResultByInputDataLogic.cs new file mode 100644 index 0000000..20c797f --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/IGetResultByInputDataLogic.cs @@ -0,0 +1,16 @@ +using StructureHelperCommon.Models.Calculators; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + public interface IGetResultByInputDataLogic : ILogic + where T : IInputData + where V : IResult + { + V GetResultByInputData(T inputData); + } +} diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IHasBeamShearActions.cs b/StructureHelperCommon/Infrastructures/Interfaces/IHasBeamShearActions.cs index fee6be5..7079896 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/IHasBeamShearActions.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/IHasBeamShearActions.cs @@ -7,6 +7,9 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Infrastructures.Interfaces { + /// + /// Implement collection of shear beams load + /// public interface IHasBeamShearActions { List BeamShearActions { get; } diff --git a/StructureHelperCommon/Models/Forces/BeamShearActions/ConcentratedForce.cs b/StructureHelperCommon/Models/Forces/BeamShearActions/ConcentratedForce.cs new file mode 100644 index 0000000..a861227 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/BeamShearActions/ConcentratedForce.cs @@ -0,0 +1,42 @@ +using NLog; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Forces +{ + /// + public class ConcentratedForce : IConcenratedForce + { + private double relativeLoadLevel; + + /// + public Guid Id { get; set; } + /// + public string Name { get; set; } + /// + public double ForceCoordinate { get; set; } + /// + public double ForceValue { get; set; } + /// + public double RelativeLoadLevel + { + get => relativeLoadLevel; + set + { + if (value > 0.5d) { relativeLoadLevel = 0.5d; } + if (value < -0.5d) { relativeLoadLevel = -0.5d; } + relativeLoadLevel = value; + } + } + /// + public double LoadRatio { get; set; } = 1; + + public object Clone() + { + throw new NotImplementedException(); + } + } +} diff --git a/StructureHelperCommon/Models/Forces/IBeamShearAction.cs b/StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearAction.cs similarity index 68% rename from StructureHelperCommon/Models/Forces/IBeamShearAction.cs rename to StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearAction.cs index 3ad1127..d878070 100644 --- a/StructureHelperCommon/Models/Forces/IBeamShearAction.cs +++ b/StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearAction.cs @@ -8,6 +8,7 @@ namespace StructureHelperCommon.Models.Forces { public interface IBeamShearAction : IAction { - + IBeamShearAxisAction XAxisSheaAction { get; } + IBeamShearAxisAction YAxisSheaAction { get; } } } diff --git a/StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearAxisAction.cs b/StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearAxisAction.cs new file mode 100644 index 0000000..cf0f653 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearAxisAction.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Forces +{ + /// + /// Implement properties of shear loads on beam + /// + public interface IBeamShearAxisAction : IAction + { + double SupportShearForce { get; set; } + List ShearLoads {get;} + } +} diff --git a/StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearLoad.cs b/StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearLoad.cs new file mode 100644 index 0000000..459e404 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/BeamShearActions/IBeamShearLoad.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Forces +{ + /// + /// Implement properties for shear beam load + /// + public interface IBeamShearLoad : IAction + { + /// + /// Value of level where action is applyied at, 0.5 is top surface, -0.5 is bottom surface + /// + double RelativeLoadLevel { get; set; } + /// + /// Ratio of substraction load from total shear force + /// + double LoadRatio { get; set; } + } +} diff --git a/StructureHelperCommon/Models/Forces/BeamShearActions/IConcenratedForce.cs b/StructureHelperCommon/Models/Forces/BeamShearActions/IConcenratedForce.cs new file mode 100644 index 0000000..f2dfca6 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/BeamShearActions/IConcenratedForce.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Forces +{ + /// + /// Implement properties for concentrated load in beam + /// + public interface IConcenratedForce : IBeamShearLoad + { + /// + /// Coordinate of location of force along beam, m + /// + double ForceCoordinate { get; set; } + /// + /// Value of force, N + /// + double ForceValue { get; set; } + } +} diff --git a/StructureHelperCommon/Models/Forces/BeamShearActions/IUniformlyDistributedLoad.cs b/StructureHelperCommon/Models/Forces/BeamShearActions/IUniformlyDistributedLoad.cs new file mode 100644 index 0000000..8c1abfb --- /dev/null +++ b/StructureHelperCommon/Models/Forces/BeamShearActions/IUniformlyDistributedLoad.cs @@ -0,0 +1,21 @@ +namespace StructureHelperCommon.Models.Forces +{ + /// + /// Implement properties of + /// + public interface IUniformlyDistributedLoad : IBeamShearLoad + { + /// + /// Value of uniformly distributed load, N/m + /// + double LoadValue { get; set; } + /// + /// Coordinate of start of load, m + /// + double StartCoordinate { get; set; } + /// + /// Coordinate of end of load, m + /// + double EndCoordinate { get; set; } + } +} \ No newline at end of file diff --git a/StructureHelperCommon/Models/Forces/BeamShearActions/UniformlyDistributedLoad.cs b/StructureHelperCommon/Models/Forces/BeamShearActions/UniformlyDistributedLoad.cs new file mode 100644 index 0000000..4a3a130 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/BeamShearActions/UniformlyDistributedLoad.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Forces +{ + public class UniformlyDistributedLoad : IUniformlyDistributedLoad + { + private double relativeLoadLevel; + + public Guid Id { get; } + + public string Name { get; set; } = string.Empty; + public double LoadValue { get; set; } = 0d; + public double RelativeLoadLevel + { + get => relativeLoadLevel; + set + { + if (value > 0.5d) { relativeLoadLevel = 0.5d; } + if (value < -0.5d) { relativeLoadLevel = -0.5d; } + relativeLoadLevel = value; + } + } + + public double StartCoordinate { get; set; } = double.NegativeInfinity; + public double EndCoordinate { get; set; } = double.PositiveInfinity; + /// + public double LoadRatio { get; set; } = 1; + + public UniformlyDistributedLoad(Guid id) + { + Id = id; + } + + public object Clone() + { + throw new NotImplementedException(); + } + } +} diff --git a/StructureHelperCommon/Models/Forces/Logics/UniformlyDisributedLoadUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/UniformlyDisributedLoadUpdateStrategy.cs new file mode 100644 index 0000000..8aeef73 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/Logics/UniformlyDisributedLoadUpdateStrategy.cs @@ -0,0 +1,23 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Forces +{ + public class UniformlyDisributedLoadUpdateStrategy : IUpdateStrategy + { + public void Update(IUniformlyDistributedLoad targetObject, IUniformlyDistributedLoad sourceObject) + { + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.Name = sourceObject.Name; + targetObject.LoadValue = sourceObject.LoadValue; + targetObject.RelativeLoadLevel = sourceObject.RelativeLoadLevel; + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearCalculator.cs b/StructureHelperLogics/Models/BeamShears/BeamShearCalculator.cs new file mode 100644 index 0000000..0c873f9 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/BeamShearCalculator.cs @@ -0,0 +1,86 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Calculators; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + internal class BeamShearCalculator : IBeamShearCalculator + { + private ICheckInputDataLogic checkInputDataLogic; + IGetResultByInputDataLogic calculationLogic; + private IBeamShearCalculatorResult result; + + public Guid Id { get; } + public string Name { get; set; } = string.Empty; + public IBeamShearCalculatorInputData InputData { get; set; } = new BeamShearCalculatorInputData(Guid.NewGuid()); + + public IResult Result => result; + + public IShiftTraceLogger? TraceLogger { get; set; } + + + public object Clone() + { + throw new NotImplementedException(); + } + + public void Run() + { + PrepareNewResult(); + PrepareInputData(); + try + { + InitializeStrategies(); + if (CheckInputData() == false) { return;} + CalculateResult(); + } + catch (Exception ex) + { + result.IsValid = false; + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + } + } + + private void PrepareInputData() + { + throw new NotImplementedException(); + } + + private bool CheckInputData() + { + var checkResult = checkInputDataLogic.Check(); + if (checkResult == false) + { + result.IsValid = false; + result.Description += checkInputDataLogic.CheckResult; + TraceLogger?.AddMessage(checkInputDataLogic.CheckResult, TraceLogStatuses.Error); + } + return checkResult; + } + + private void CalculateResult() + { + result = calculationLogic.GetResultByInputData(InputData); + } + + private void InitializeStrategies() + { + checkInputDataLogic ??= new CheckBeamShearCalculatorInputDataLogic(InputData, TraceLogger); + calculationLogic ??= new BeamShearCalculatorLogic(TraceLogger); + } + + private void PrepareNewResult() + { + result = new BeamShearCalculatorResult() + { + IsValid = true, + Description = string.Empty + }; + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorInputData.cs b/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorInputData.cs new file mode 100644 index 0000000..636a785 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorInputData.cs @@ -0,0 +1,30 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + /// + public class BeamShearCalculatorInputData : IBeamShearCalculatorInputData + { + /// + public Guid Id { get; } + + + /// + public List BeamShearActions { get; } = new(); + /// + public List ShearSections { get; } = new(); + /// + public List Stirrups { get; } = new(); + public BeamShearCalculatorInputData(Guid id) + { + Id = id; + } + + } +} diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorLogic.cs b/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorLogic.cs new file mode 100644 index 0000000..c7d6c4f --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorLogic.cs @@ -0,0 +1,88 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public class BeamShearCalculatorLogic : IGetResultByInputDataLogic + { + private IBeamShearCalculatorResult result; + private IBeamShearSectionCalculator beamShearSectionCalculator; + private List sectionInputDatas; + + public BeamShearCalculatorLogic(IShiftTraceLogger? traceLogger) + { + TraceLogger = traceLogger; + } + + public IShiftTraceLogger? TraceLogger { get; set; } + + public IBeamShearCalculatorResult GetResultByInputData(IBeamShearCalculatorInputData inputData) + { + PrepareNewResult(); + InitializeStrategies(); + try + { + GetSectionInputDatas(inputData); + CalculateResult(); + } + catch (Exception ex) + { + TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error); + result.IsValid = false; + } + + return result; + } + + private void CalculateResult() + { + foreach (var sectionInputData in sectionInputDatas) + { + beamShearSectionCalculator.InputData = sectionInputData; + beamShearSectionCalculator.Run(); + var sectionResult = beamShearSectionCalculator.Result as IBeamShearSectionCalculatorResult; + result.SectionResults.Add(sectionResult); + } + } + + private void InitializeStrategies() + { + beamShearSectionCalculator ??= new BeamShearSectionCalculator(); + } + + private void PrepareNewResult() + { + result = new BeamShearCalculatorResult() + { + IsValid = true, + Description = string.Empty + }; + } + + private void GetSectionInputDatas(IBeamShearCalculatorInputData inputData) + { + sectionInputDatas = new(); + foreach (var beamShearSection in inputData.ShearSections) + { + foreach (var stirrup in inputData.Stirrups) + { + foreach (var beamShearAction in inputData.BeamShearActions) + { + BeamShearSectionCalculatorInputData newInputData = new(Guid.NewGuid()) + { + BeamShearSection = beamShearSection, + Stirrup = stirrup, + BeamShearAction = beamShearAction + }; + sectionInputDatas.Add(newInputData); + } + } + } + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorResult.cs b/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorResult.cs new file mode 100644 index 0000000..c53cf50 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/BeamShearCalculatorResult.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public class BeamShearCalculatorResult : IBeamShearCalculatorResult + { + public bool IsValid { get; set; } = true; + public string? Description { get; set; } = string.Empty; + public List SectionResults { get; set; } = new(); + } +} diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearRepository.cs b/StructureHelperLogics/Models/BeamShears/BeamShearRepository.cs index f697788..1c8a191 100644 --- a/StructureHelperLogics/Models/BeamShears/BeamShearRepository.cs +++ b/StructureHelperLogics/Models/BeamShears/BeamShearRepository.cs @@ -13,15 +13,33 @@ namespace StructureHelperLogics.Models.BeamShears public Guid Id { get; } - public List BeamShearActions { get; } + public List BeamShearActions {get;} + + public List Calculators { get; } = new(); + + public List ShearSections { get; } = new(); + + public List Stirrups { get; } = new(); - public List Calculators { get; } public BeamShearRepository(Guid id) { Id = id; } + public void DeleteBeamShearAction(IBeamShearAction beamShearAction) + { + foreach (var calculator in Calculators) + { + if (calculator is IBeamShearCalculator beamShearCalculator) + { + var inputData = beamShearCalculator.InputData; + inputData.BeamShearActions.Remove(beamShearAction); + } + } + BeamShearActions.Remove(beamShearAction); + } + public object Clone() { throw new NotImplementedException(); diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculator.cs b/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculator.cs new file mode 100644 index 0000000..c883901 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculator.cs @@ -0,0 +1,34 @@ +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Calculators; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public class BeamShearSectionCalculator : IBeamShearSectionCalculator + { + private IBeamShearSectionCalculatorResult result; + + public Guid Id { get; } + public string Name { get; set; } + public IBeamShearSectionCalculatorInputData InputData { get; set; } + + public IResult Result => result; + + public IShiftTraceLogger? TraceLogger { get; set; } + + + public object Clone() + { + throw new NotImplementedException(); + } + + public void Run() + { + throw new NotImplementedException(); + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculatorInputData.cs b/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculatorInputData.cs new file mode 100644 index 0000000..65e8f3d --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculatorInputData.cs @@ -0,0 +1,27 @@ +using StructureHelperCommon.Models.Forces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + /// + public class BeamShearSectionCalculatorInputData : IBeamShearSectionCalculatorInputData + { + /// + public Guid Id { get; } + /// + public IBeamShearSection? BeamShearSection { get; set; } + /// + public IBeamShearAction? BeamShearAction { get; set; } + /// + public IStirrup? Stirrup { get; set; } + public BeamShearSectionCalculatorInputData(Guid id) + { + Id = id; + } + + } +} diff --git a/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculatorResult.cs b/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculatorResult.cs new file mode 100644 index 0000000..15f0c90 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/BeamShearSectionCalculatorResult.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public class BeamShearSectionCalculatorResult : IBeamShearSectionCalculatorResult + { + public bool IsValid { get; set; } + public string? Description { get; set; } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IBeamShearCalculator.cs b/StructureHelperLogics/Models/BeamShears/IBeamShearCalculator.cs new file mode 100644 index 0000000..434b9d6 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/IBeamShearCalculator.cs @@ -0,0 +1,14 @@ +using StructureHelperCommon.Models.Calculators; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IBeamShearCalculator : ICalculator + { + IBeamShearCalculatorInputData InputData { get; set; } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IBeamShearCalculatorInputData.cs b/StructureHelperLogics/Models/BeamShears/IBeamShearCalculatorInputData.cs new file mode 100644 index 0000000..0ba9f58 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/IBeamShearCalculatorInputData.cs @@ -0,0 +1,15 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Calculators; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IBeamShearCalculatorInputData : ISaveable, IInputData, IHasBeamShearActions, IHasBeamShearSections, IHasStirrups + { + + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IBeamShearCalculatorResult.cs b/StructureHelperLogics/Models/BeamShears/IBeamShearCalculatorResult.cs new file mode 100644 index 0000000..96a85b7 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/IBeamShearCalculatorResult.cs @@ -0,0 +1,14 @@ +using StructureHelperCommon.Models.Calculators; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IBeamShearCalculatorResult : IResult + { + List SectionResults { get; set; } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IBeamShearRepository.cs b/StructureHelperLogics/Models/BeamShears/IBeamShearRepository.cs index 793abf6..faa3b8b 100644 --- a/StructureHelperLogics/Models/BeamShears/IBeamShearRepository.cs +++ b/StructureHelperLogics/Models/BeamShears/IBeamShearRepository.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.BeamShears { - public interface IBeamShearRepository : ISaveable, IHasBeamShearActions, IHasCalculators, ICloneable + public interface IBeamShearRepository : ISaveable, IHasBeamShearActions, IHasCalculators, IHasBeamShearSections, IHasStirrups, ICloneable { } diff --git a/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculator.cs b/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculator.cs new file mode 100644 index 0000000..e6dc96a --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculator.cs @@ -0,0 +1,14 @@ +using StructureHelperCommon.Models.Calculators; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IBeamShearSectionCalculator : ICalculator + { + IBeamShearSectionCalculatorInputData InputData { get; set; } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculatorInputData.cs b/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculatorInputData.cs new file mode 100644 index 0000000..b9195b8 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculatorInputData.cs @@ -0,0 +1,18 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Forces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IBeamShearSectionCalculatorInputData : IInputData, ISaveable + { + IBeamShearSection? BeamShearSection { get; set; } + IBeamShearAction? BeamShearAction { get; set; } + IStirrup? Stirrup { get; set; } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculatorResult.cs b/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculatorResult.cs new file mode 100644 index 0000000..96fcca1 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/IBeamShearSectionCalculatorResult.cs @@ -0,0 +1,13 @@ +using StructureHelperCommon.Models.Calculators; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IBeamShearSectionCalculatorResult : IResult + { + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IHasBeamShearSections.cs b/StructureHelperLogics/Models/BeamShears/IHasBeamShearSections.cs new file mode 100644 index 0000000..0410d5b --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/IHasBeamShearSections.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IHasBeamShearSections + { + List ShearSections { get; } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IHasStirrups.cs b/StructureHelperLogics/Models/BeamShears/IHasStirrups.cs new file mode 100644 index 0000000..6faf9c0 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/IHasStirrups.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IHasStirrups + { + List Stirrups { get; } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/IInclinedSection.cs b/StructureHelperLogics/Models/BeamShears/IInclinedSection.cs index d6b4ea1..183f450 100644 --- a/StructureHelperLogics/Models/BeamShears/IInclinedSection.cs +++ b/StructureHelperLogics/Models/BeamShears/IInclinedSection.cs @@ -7,10 +7,23 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.BeamShears { + /// + /// Implement parameers of inclined cross-section for beam shear calculating + /// public interface IInclinedSection : IEffectiveDepth { + /// + /// Width of cross-section + /// double WebWidth { get; set; } + /// + /// Coordinate of start of inclined cross-section + /// double StartCoord { get; set; } + /// + /// Coordinate of end of inclined cross-section + /// double EndCoord { get; set; } + } } diff --git a/StructureHelperLogics/Models/BeamShears/InclinedSection.cs b/StructureHelperLogics/Models/BeamShears/InclinedSection.cs index 4f90628..94a856e 100644 --- a/StructureHelperLogics/Models/BeamShears/InclinedSection.cs +++ b/StructureHelperLogics/Models/BeamShears/InclinedSection.cs @@ -6,11 +6,18 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.BeamShears { + /// public class InclinedSection : IInclinedSection { + /// + public double FullDepth { get; set; } + /// public double EffectiveDepth { get; set; } + /// public double WebWidth { get; set; } + /// public double StartCoord { get; set; } + /// public double EndCoord { get; set; } } } diff --git a/StructureHelperLogics/Models/BeamShears/Logics/CheckBeamShearCalculatorInputDataLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/CheckBeamShearCalculatorInputDataLogic.cs new file mode 100644 index 0000000..19122d2 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/Logics/CheckBeamShearCalculatorInputDataLogic.cs @@ -0,0 +1,58 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperLogics.NdmCalculations.Cracking; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public class CheckBeamShearCalculatorInputDataLogic : ICheckInputDataLogic + { + private bool result; + private string checkResult; + + public string CheckResult => checkResult; + public IBeamShearCalculatorInputData InputData { get; set; } + public IShiftTraceLogger? TraceLogger { get; set; } + public CheckBeamShearCalculatorInputDataLogic(IBeamShearCalculatorInputData inputData, IShiftTraceLogger? traceLogger) + { + InputData = inputData; + TraceLogger = traceLogger; + } + + public bool Check() + { + result = true; + checkResult = string.Empty; + if (InputData is null) + { + result = false; + string errorString = ErrorStrings.ParameterIsNull + ": Input data"; + throw new StructureHelperException(errorString); + } + if (InputData.BeamShearActions is null || ! InputData.BeamShearActions.Any()) + { + result = false; + string errorString = "Collection of actions does not contain any action"; + TraceMessage(errorString); + } + if (InputData.ShearSections is null || ! InputData.ShearSections.Any()) + { + result = false; + string errorString = "Collection of sections does not contain any section"; + TraceMessage(errorString); + } + return result; + } + + private void TraceMessage(string errorString) + { + checkResult += errorString; + TraceLogger?.AddMessage(errorString); + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionListInputData.cs b/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionListInputData.cs new file mode 100644 index 0000000..529a56b --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionListInputData.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public class GetInclinedSectionListInputData : IGetInclinedSectionListInputData + { + public int StepCount { get; set; } = 50; + public double MaxInclinedSectionLegthFactor { get; set; } = 3d; + public IGetInclinedSectionLogic? GetInclinedSectionLogic { get; set; } + public IBeamShearSection BeamShearSection { get; set; } + + public GetInclinedSectionListInputData(IBeamShearSection beamShearSection) + { + BeamShearSection = beamShearSection; + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionListLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionListLogic.cs new file mode 100644 index 0000000..63dbbe5 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionListLogic.cs @@ -0,0 +1,87 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Services; + +namespace StructureHelperLogics.Models.BeamShears +{ + public class GetInclinedSectionListLogic : IGetInclinedSectionListLogic + { + private readonly GetInclinedSectionListInputData inputData; + private IGetInclinedSectionLogic inclinedSectionLogic; + private double depth; + private double effectiveDepth; + private List inclinedSections; + private List coordinates; + public IShiftTraceLogger? TraceLogger { get; set; } + + public GetInclinedSectionListLogic( + GetInclinedSectionListInputData inputData, + IShiftTraceLogger? traceLogger) + { + this.inputData = inputData; + TraceLogger = traceLogger; + } + + + public List GetInclinedSections() + { + Check(); + GetShapeParameters(); + GetCoordinates(); + foreach (var startCoord in coordinates) + { + var endCoordinates = coordinates.Where(x => x >= startCoord); + foreach (var endCoord in endCoordinates) + { + inclinedSectionLogic = InitializeInclinedSectionLogic(startCoord, endCoord); + IInclinedSection inclinedSection = inclinedSectionLogic.GetInclinedSection(); + inclinedSections.Add(inclinedSection); + } + } + return inclinedSections; + } + + private void GetCoordinates() + { + double maxSectionLength = inputData.MaxInclinedSectionLegthFactor * effectiveDepth; + double step = maxSectionLength / inputData.StepCount; + inclinedSections = new(); + coordinates = new(); + for (int i = 0; i < inputData.StepCount + 1; i++) + { + double endCoord = step * i; + coordinates.Add(endCoord); + } + } + private void Check() + { + CheckObject.IsNull(inputData); + CheckObject.IsNull(inputData.BeamShearSection); + } + private IGetInclinedSectionLogic InitializeInclinedSectionLogic(double startCoord, double endCoord) + { + if (inputData.GetInclinedSectionLogic is not null) + { + return inputData.GetInclinedSectionLogic; + } + return new GetInclinedSectionLogic(inputData.BeamShearSection, startCoord, endCoord, TraceLogger); + } + private void GetShapeParameters() + { + if (inputData.BeamShearSection.Shape is IRectangleShape rectangle) + { + depth = rectangle.Height; + } + else if (inputData.BeamShearSection.Shape is ICircleShape circle) + { + depth = circle.Diameter; + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(inputData.BeamShearSection.Shape)); + } + effectiveDepth = depth - inputData.BeamShearSection.CenterCover; + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionLogic.cs index 6b95f7e..c6f6ca9 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/GetInclinedSectionLogic.cs @@ -1,11 +1,6 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Shapes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace StructureHelperLogics.Models.BeamShears { @@ -17,6 +12,8 @@ namespace StructureHelperLogics.Models.BeamShears private double width; private double depth; private double effectiveDepth; + private InclinedSection? inclinedSection; + public IShiftTraceLogger? TraceLogger { get; set; } public GetInclinedSectionLogic( IBeamShearSection beamShearSection, @@ -31,14 +28,26 @@ namespace StructureHelperLogics.Models.BeamShears Check(); } - public GetInclinedSectionLogic(IShiftTraceLogger? traceLogger) + public IInclinedSection GetInclinedSection() { - TraceLogger = traceLogger; + GetShapeParameters(); + GetSection(); + return inclinedSection; } - public IShiftTraceLogger? TraceLogger { get; set; } - - public IInclinedSection GetInclinedSection() + private void GetSection() + { + effectiveDepth = depth - beamShearSection.CenterCover; + inclinedSection = new() + { + FullDepth = depth, + EffectiveDepth = effectiveDepth, + StartCoord = startCoord, + EndCoord = endCoord, + WebWidth = width + }; + } + private void GetShapeParameters() { if (beamShearSection.Shape is IRectangleShape rectangle) { @@ -54,17 +63,7 @@ namespace StructureHelperLogics.Models.BeamShears { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(beamShearSection.Shape)); } - effectiveDepth = depth - beamShearSection.CenterCover; - InclinedSection inclinedSection = new() - { - EffectiveDepth = effectiveDepth, - StartCoord = startCoord, - EndCoord = endCoord, - WebWidth = width - }; - return inclinedSection; } - private void Check() { if (beamShearSection is null) diff --git a/StructureHelperLogics/Models/BeamShears/Logics/GetSumForceByShearActionLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/GetSumForceByShearActionLogic.cs new file mode 100644 index 0000000..74223f2 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/Logics/GetSumForceByShearActionLogic.cs @@ -0,0 +1,106 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Forces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public class GetSumForceByShearActionLogic : IGetSumForceByShearActionLogic + { + public IShiftTraceLogger? TraceLogger { get; set; } + + public GetSumForceByShearActionLogic(IShiftTraceLogger? traceLogger) + { + TraceLogger = traceLogger; + } + + public double GetSumShearForce(IBeamShearLoad beamShearAction, double startCoord, double endCoord) + { + if (beamShearAction is IUniformlyDistributedLoad distributedLoad) + { + return GetDistributedLoadSum(distributedLoad, startCoord, endCoord); + } + else if (beamShearAction is IConcenratedForce concenratedForce) + { + return GetConcentratedForceSum(concenratedForce, startCoord, endCoord); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(beamShearAction)); + } + } + + private double GetConcentratedForceSum(IConcenratedForce concentratedForce, double startCoord, double endCoord) + { + TraceLogger?.AddMessage($"Concentrated force Name = {concentratedForce.Name}, Value = {concentratedForce.ForceValue}(N/m) "); + if (concentratedForce.ForceCoordinate > endCoord) + { + TraceLogger?.AddMessage($"Force coordinate {concentratedForce.ForceCoordinate}(m) is bigger than section end {endCoord}(m), so total load is zero"); + return 0; + } + double totalLoad; + double limitCoordinate = startCoord; + if (concentratedForce.ForceCoordinate >= startCoord) + { + limitCoordinate = GetCoordinateByLevel(startCoord, endCoord, concentratedForce.RelativeLoadLevel); + } + if (concentratedForce.ForceCoordinate < limitCoordinate) + { + totalLoad = concentratedForce.ForceValue * concentratedForce.LoadRatio; + TraceLogger?.AddMessage($"Total load Q,tot = {concentratedForce.ForceValue}(N) * {concentratedForce.LoadRatio} = {totalLoad}(N)"); + } + else + { + TraceLogger?.AddMessage($"Force coordinate {concentratedForce.ForceCoordinate}(m) is bigger than limit coordinate {limitCoordinate}(m), so total load is zero"); + totalLoad = 0d; + } + return totalLoad; + } + + private double GetDistributedLoadSum(IUniformlyDistributedLoad distributedLoad, double startCoord, double endCoord) + { + TraceLogger?.AddMessage($"Uniformly distributed load Name = {distributedLoad.Name}, Value = {distributedLoad.LoadValue}(N/m) "); + double loadStartCoord = Math.Max(distributedLoad.StartCoordinate, 0d); + if (loadStartCoord > endCoord) + { + TraceLogger?.AddMessage($"Load start coordinate {loadStartCoord}(m) is bigger than section end {endCoord}(m), so total load is zero"); + return 0d; + } + double endCoordByLevel = GetCoordinateByLevel(startCoord, endCoord, distributedLoad.RelativeLoadLevel); + double loadEndCoord = Math.Min(distributedLoad.EndCoordinate, endCoordByLevel); + double loadLength = loadEndCoord - loadStartCoord; + TraceLogger?.AddMessage($"Total length L,tot = {loadEndCoord}(m) - {loadStartCoord}(m) = {loadLength}(m)"); + double totalLoad = distributedLoad.LoadValue * distributedLoad.LoadRatio * loadLength; + TraceLogger?.AddMessage($"Total load Q,tot = {distributedLoad.LoadValue}(N/m) * {distributedLoad.LoadRatio} * {loadLength}(m) = {totalLoad}(N)"); + return totalLoad; + } + + private double GetCoordinateByLevel(double startCoord, double endCoord, double relativeLevel) + { + CheckRelativeLevel(relativeLevel); + double delta = endCoord - startCoord; + double coordinate = startCoord + delta * (relativeLevel + 0.5d); + return coordinate; + } + + private void CheckRelativeLevel(double relativeLevel) + { + if (relativeLevel > 0.5d) + { + string errorString = ErrorStrings.IncorrectValue + ": relative level must not be greater than 0.5"; + TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); + throw new StructureHelperException(errorString); + } + if (relativeLevel < -0.5d) + { + string errorString = ErrorStrings.IncorrectValue + ": relative level must not be less than -0.5"; + TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); + throw new StructureHelperException(errorString); + } + } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionBySectionLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionBySectionLogic.cs index c73b4be..b8ab143 100644 --- a/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionBySectionLogic.cs +++ b/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionBySectionLogic.cs @@ -7,8 +7,15 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.BeamShears { + /// + /// Implement logic for obtaining of inclined section + /// public interface IGetInclinedSectionLogic : ILogic { + /// + /// Returns inclined section + /// + /// Inclined section IInclinedSection GetInclinedSection(); } } diff --git a/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionListInputData.cs b/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionListInputData.cs new file mode 100644 index 0000000..17053d8 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionListInputData.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + public interface IGetInclinedSectionListInputData + { + int StepCount { get; set; } + double MaxInclinedSectionLegthFactor { get; set; } + IGetInclinedSectionLogic? GetInclinedSectionLogic { get; set; } + IBeamShearSection BeamShearSection { get; set; } + } +} diff --git a/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionListLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionListLogic.cs new file mode 100644 index 0000000..5d59294 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/Logics/IGetInclinedSectionListLogic.cs @@ -0,0 +1,12 @@ +using StructureHelperCommon.Infrastructures.Interfaces; + +namespace StructureHelperLogics.Models.BeamShears +{ + /// + /// Returns collection of inclined section for beam shear calculating + /// + public interface IGetInclinedSectionListLogic : ILogic + { + List GetInclinedSections(); + } +} diff --git a/StructureHelperLogics/Models/BeamShears/Logics/IGetSumForceByShearActionLogic.cs b/StructureHelperLogics/Models/BeamShears/Logics/IGetSumForceByShearActionLogic.cs new file mode 100644 index 0000000..26ea453 --- /dev/null +++ b/StructureHelperLogics/Models/BeamShears/Logics/IGetSumForceByShearActionLogic.cs @@ -0,0 +1,25 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.BeamShears +{ + /// + /// Implement logic for obtaining of summary force of action from start to end + /// + public interface IGetSumForceByShearActionLogic : ILogic + { + /// + /// Returns summary force of action from start to end + /// + /// Source action + /// Coordinate of start point, m + /// Coordinate of end point, m + /// Summary force, N + double GetSumShearForce(IBeamShearLoad beamShearAction, double startCoord, double endCoord); + } +}