diff --git a/StructureHelper/Documentation/Manuals/UserManual.docx b/StructureHelper/Documentation/Manuals/UserManual.docx index 13c1427..07cc0a8 100644 Binary files a/StructureHelper/Documentation/Manuals/UserManual.docx and b/StructureHelper/Documentation/Manuals/UserManual.docx differ diff --git a/StructureHelper/Documentation/Manuals/Руководство пользователя.docx b/StructureHelper/Documentation/Manuals/Руководство пользователя.docx new file mode 100644 index 0000000..d66c967 Binary files /dev/null and b/StructureHelper/Documentation/Manuals/Руководство пользователя.docx differ diff --git a/StructureHelper/Documentation/Manuals/Руководство пользователя.pdf b/StructureHelper/Documentation/Manuals/Руководство пользователя.pdf new file mode 100644 index 0000000..1a6af0c Binary files /dev/null and b/StructureHelper/Documentation/Manuals/Руководство пользователя.pdf differ diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceCalculatorView.xaml b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceCalculatorView.xaml index 32c082d..0bcf058 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceCalculatorView.xaml +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForceCalculatorView.xaml @@ -12,86 +12,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs index 1191a0a..57e52e9 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/ForcesResultsViewModel.cs @@ -408,7 +408,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu { this.forceCalculator = forceCalculator; forcesResults = forceCalculator.Result as IForcesResults; - ndmPrimitives = forceCalculator.Primitives; + ndmPrimitives = forceCalculator.InputData.Primitives; } private void ShowIsoField() diff --git a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorInputDataVM.cs b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorInputDataVM.cs new file mode 100644 index 0000000..6160d31 --- /dev/null +++ b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorInputDataVM.cs @@ -0,0 +1,82 @@ +using StructureHelper.Infrastructure; +using StructureHelper.Infrastructure.UI.DataContexts; +using StructureHelper.Windows.ViewModels.NdmCrossSections; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models.Forces; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.ViewModels.Calculations.Calculators +{ + public class ForceCalculatorInputDataVM : ViewModelBase + { + private ForceInputData inputData; + SecondOrderViewModel secondOrderViewModel; + + public double IterationAccuracy + { + get { return inputData.Accuracy.IterationAccuracy; } + set { inputData.Accuracy.IterationAccuracy = value; } + } + + public int MaxIterationCount + { + get { return inputData.Accuracy.MaxIterationCount; } + set { inputData.Accuracy.MaxIterationCount = value; } + } + + public SecondOrderViewModel SecondOrder => secondOrderViewModel; + + public bool ULS { get; set; } + public bool SLS { get; set; } + public bool ShortTerm { get; set; } + public bool LongTerm { get; set; } + + public SourceTargetVM CombinationViewModel { get; } + public SourceTargetVM PrimitivesViewModel { get; private set; } + + + public ForceCalculatorInputDataVM(ForceInputData inputData, IEnumerable allowedPrimitives, IEnumerable allowedCombinations) + { + this.inputData = inputData; + secondOrderViewModel = new SecondOrderViewModel(this.inputData.CompressedMember); + CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(allowedCombinations, this.inputData.ForceActions); + PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(allowedPrimitives, this.inputData.Primitives); + InputRefresh(); + } + + public void InputRefresh() + { + ULS = inputData.LimitStatesList.Contains(LimitStates.ULS); + SLS = inputData.LimitStatesList.Contains(LimitStates.SLS); + ShortTerm = inputData.CalcTermsList.Contains(CalcTerms.ShortTerm); + LongTerm = inputData.CalcTermsList.Contains(CalcTerms.LongTerm); + } + + public void Refresh() + { + var combinations = CombinationViewModel.GetTargetItems(); + inputData.ForceActions.Clear(); + foreach (var item in combinations) + { + inputData.ForceActions.Add(item); + } + inputData.Primitives.Clear(); + foreach (var item in PrimitivesViewModel.GetTargetItems()) + { + inputData.Primitives.Add(item.GetNdmPrimitive()); + } + inputData.LimitStatesList.Clear(); + if (ULS == true) { inputData.LimitStatesList.Add(LimitStates.ULS); } + if (SLS == true) { inputData.LimitStatesList.Add(LimitStates.SLS); } + inputData.CalcTermsList.Clear(); + if (ShortTerm == true) { inputData.CalcTermsList.Add(CalcTerms.ShortTerm); } + if (LongTerm == true) { inputData.CalcTermsList.Add(CalcTerms.LongTerm); } + } + } +} diff --git a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorViewModel.cs b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorViewModel.cs index 0845292..0a4ba85 100644 --- a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorViewModel.cs +++ b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForceCalculatorViewModel.cs @@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Models.Forces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Primitives; +using System; using System.Collections.Generic; @@ -16,7 +17,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators public class ForceCalculatorViewModel : OkCancelViewModelBase { ForceCalculator forcesCalculator; - SecondOrderViewModel secondOrderViewModel; public string Name { @@ -24,64 +24,17 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators set { forcesCalculator.Name = value; } } - public double IterationAccuracy - { - get { return forcesCalculator.Accuracy.IterationAccuracy; } - set { forcesCalculator.Accuracy.IterationAccuracy = value;} - } - - public int MaxIterationCount - { - get { return forcesCalculator.Accuracy.MaxIterationCount; } - set { forcesCalculator.Accuracy.MaxIterationCount = value; } - } - - public SecondOrderViewModel SecondOrder => secondOrderViewModel; - - public bool ULS { get; set; } - public bool SLS { get; set; } - public bool ShortTerm { get; set; } - public bool LongTerm { get; set; } - - public SourceTargetVM CombinationViewModel { get; } - public SourceTargetVM PrimitivesViewModel { get; private set; } + public ForceCalculatorInputDataVM InputData { get; } public ForceCalculatorViewModel(IEnumerable allowedPrimitives, IEnumerable allowedCombinations, ForceCalculator forcesCalculator) { this.forcesCalculator = forcesCalculator; - secondOrderViewModel = new SecondOrderViewModel(this.forcesCalculator.CompressedMember); - CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(allowedCombinations, this.forcesCalculator.ForceActions); - PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(allowedPrimitives, this.forcesCalculator.Primitives); - InputRefresh(); + InputData = new ForceCalculatorInputDataVM(this.forcesCalculator.InputData, allowedPrimitives, allowedCombinations); } - public void InputRefresh() + internal void Refresh() { - ULS = forcesCalculator.LimitStatesList.Contains(LimitStates.ULS); - SLS = forcesCalculator.LimitStatesList.Contains(LimitStates.SLS); - ShortTerm = forcesCalculator.CalcTermsList.Contains(CalcTerms.ShortTerm); - LongTerm = forcesCalculator.CalcTermsList.Contains(CalcTerms.LongTerm); - } - - public void Refresh() - { - var combinations = CombinationViewModel.GetTargetItems(); - forcesCalculator.ForceActions.Clear(); - foreach (var item in combinations) - { - forcesCalculator.ForceActions.Add(item); - } - forcesCalculator.Primitives.Clear(); - foreach (var item in PrimitivesViewModel.GetTargetItems()) - { - forcesCalculator.Primitives.Add(item.GetNdmPrimitive()); - } - forcesCalculator.LimitStatesList.Clear(); - if (ULS == true) { forcesCalculator.LimitStatesList.Add(LimitStates.ULS); } - if (SLS == true) { forcesCalculator.LimitStatesList.Add(LimitStates.SLS); } - forcesCalculator.CalcTermsList.Clear(); - if (ShortTerm == true) { forcesCalculator.CalcTermsList.Add(CalcTerms.ShortTerm); } - if (LongTerm == true) { forcesCalculator.CalcTermsList.Add(CalcTerms.LongTerm); } + InputData.Refresh(); } } } diff --git a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs index 7fccf0d..3b295bd 100644 --- a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs +++ b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs @@ -95,9 +95,9 @@ namespace StructureHelper.Windows.ViewModels.Forces var calcRepository = repository.CalculatorsList; foreach (var calc in calcRepository) { - if (calc is IForceCalculator) + if (calc is ForceCalculator forceCalculator) { - var forceCombinations = calc as IHasForceCombinations; + var forceCombinations = forceCalculator.InputData as IHasForceCombinations; result = DeleteActionFromHost(result, calc, forceCombinations); } else if (calc is CrackCalculator calculator) diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs index 41e100a..b4c206f 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/AnalysisViewModelLogic.cs @@ -60,7 +60,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections private void AddCrackCalculator() { var inputData = new CrackInputData(); - var calculator = new CrackCalculator(inputData, new CheckCrackCalculatorInputDataLogic(inputData)) + var calculator = new CrackCalculator(inputData) { Name = "New crack calculator", TraceLogger = new ShiftTraceLogger(), diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs index f438ee2..9c1b625 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs @@ -136,9 +136,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections repository.Primitives.Remove(ndmPrimitive); foreach (var calc in repository.CalculatorsList) { - if (calc is IForceCalculator) + if (calc is ForceCalculator forceCalculator) { - var forceCalc = calc as IHasPrimitives; + var forceCalc = forceCalculator.InputData as IHasPrimitives; forceCalc.Primitives.Remove(ndmPrimitive); } else if (calc is LimitCurvesCalculator calculator) diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ICheckInputDataLogic.cs b/StructureHelperCommon/Infrastructures/Interfaces/ICheckInputDataLogic.cs index 5cf6ab5..4a5cda9 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/ICheckInputDataLogic.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/ICheckInputDataLogic.cs @@ -7,8 +7,8 @@ using System.Threading.Tasks; namespace StructureHelperCommon.Infrastructures.Interfaces { - public interface ICheckInputDataLogic : ICheckLogic + public interface ICheckInputDataLogic : ICheckLogic where TInputData : IInputData { - IInputData InputData { get; set; } + TInputData InputData { get; set; } } } diff --git a/StructureHelperCommon/Infrastructures/Interfaces/IDecorator.cs b/StructureHelperCommon/Infrastructures/Interfaces/IDecorator.cs new file mode 100644 index 0000000..d96c470 --- /dev/null +++ b/StructureHelperCommon/Infrastructures/Interfaces/IDecorator.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Infrastructures.Interfaces +{ + public interface IDecorator where T : class + { + T SourceValue { get; } + T GetModifiedValue(); + } +} diff --git a/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs b/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs index 7ce2603..8df2207 100644 --- a/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs +++ b/StructureHelperLogics/Models/Templates/CrossSections/RCs/SectionTemplate.cs @@ -4,6 +4,7 @@ using StructureHelperCommon.Models.Forces; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Templates.RCs; using StructureHelperLogics.NdmCalculations.Analyses; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Primitives; using System; @@ -58,10 +59,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs { foreach (var calculator in calculators) { - if (calculator is IHasForceCombinations) + if (calculator is ForceCalculator forceCalculator) { - var forceCalculator = calculator as IHasForceCombinations; - forceCalculator.ForceActions.AddRange(combinations); + forceCalculator.InputData.ForceActions.AddRange(combinations); } if (calculator is CrackCalculator crackCalculator) { @@ -73,10 +73,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs { foreach (var calculator in calculators) { - if (calculator is IHasPrimitives) + if (calculator is ForceCalculator forceCalculator) { - var primitiveCalculator = calculator as IHasPrimitives; - primitiveCalculator.Primitives.AddRange(primitives); + forceCalculator.InputData.Primitives.AddRange(primitives); } if (calculator is CrackCalculator crackCalculator) { diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/CheckForceCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/CheckForceCalculatorInputData.cs new file mode 100644 index 0000000..6efa2d3 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/CheckForceCalculatorInputData.cs @@ -0,0 +1,55 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Infrastructures.Settings; +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.NdmCalculations.Analyses.ByForces +{ + internal class CheckForceCalculatorInputData : ICheckInputDataLogic + { + + public ForceInputData InputData { get; set; } + + public string CheckResult { get; private set; } + + public IShiftTraceLogger? TraceLogger { get; set; } + + public CheckForceCalculatorInputData(ForceInputData inputData) + { + InputData = inputData; + CheckResult = string.Empty; + } + + public bool Check() + { + bool result = true; + CheckResult = string.Empty; + if (!InputData.Primitives.Any()) + { + CheckResult += "Calculator does not contain any primitives \n"; + result = false; + } + if (!InputData.ForceActions.Any()) + { + CheckResult += "Calculator does not contain any forces \n"; + result = false; + } + if (!InputData.LimitStatesList.Any()) + { + CheckResult += "Calculator does not contain any limit states \n"; + result = false; + } + if (!InputData.CalcTermsList.Any()) + { + CheckResult += "Calculator does not contain any calc term \n"; + result = false; + } + return result; + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs index 1101562..0f32865 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculator.cs @@ -1,297 +1,76 @@ -using LoaderCalculator.Data.Ndms; -using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Loggers; -using StructureHelperCommon.Models.Sections; -using StructureHelperCommon.Models.Sections.Logics; -using StructureHelperCommon.Models.Shapes; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; -using StructureHelperLogics.NdmCalculations.Buckling; -using StructureHelperLogics.NdmCalculations.Primitives; -using StructureHelperLogics.Services.NdmPrimitives; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { - public class ForceCalculator : IForceCalculator, IHasActionByResult + public class ForceCalculator : ICalculator, IHasActionByResult { - static readonly ForceCalculatorUpdateStrategy updateStrategy = new(); - private readonly IForceTupleCalculator forceTupleCalculator; - private ForcesResults result; - private IProcessorLogic eccentricityLogic; - private ForceTupleBucklingLogic bucklingLogic; - private ITriangulatePrimitiveLogic triangulateLogic; + private IUpdateStrategy updateStrategy = new ForceCalculatorUpdateStrategy(); + private ICheckInputDataLogic checkInputDataLogic; + private IForceCalculatorLogic forceCalculatorLogic; public string Name { get; set; } - public List LimitStatesList { get; private set; } - public List CalcTermsList { get; private set; } - public List ForceActions { get; private set; } - public List Primitives { get; private set; } - public IResult Result { get; private set; } - public ICompressedMember CompressedMember { get; private set; } - public IAccuracy Accuracy { get; set; } - public List ForceCombinationLists { get; private set; } + public ForceInputData InputData {get;set;} public Action ActionToOutputResults { get; set; } public IShiftTraceLogger? TraceLogger { get; set; } + public IResult Result { get; private set; } public void Run() { TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); - var checkResult = CheckInputData(); - if (checkResult != string.Empty) + checkInputDataLogic = new CheckForceCalculatorInputData(InputData); + checkInputDataLogic.TraceLogger?.GetSimilarTraceLogger(50); + if (checkInputDataLogic.Check() != true) { Result = new ForcesResults() { IsValid = false, - Description = checkResult + Description = checkInputDataLogic.CheckResult }; return; } - GetCombinations(); - CalculateResult(); + if (ActionToOutputResults is not null) + { + forceCalculatorLogic.ActionToOutputResults = ActionToOutputResults; + } + forceCalculatorLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50); + Result = forceCalculatorLogic.GetForcesResults(); } - private void CalculateResult() + private void GetResult() { - result = new ForcesResults() - { - IsValid = true - }; - foreach (var combination in ForceCombinationLists) - { - foreach (var tuple in combination.DesignForces) - { - var limitState = tuple.LimitState; - var calcTerm = tuple.CalcTerm; - if (LimitStatesList.Contains(limitState) & CalcTermsList.Contains(calcTerm)) - { - - IForcesTupleResult tupleResult; - try - { - tupleResult = ProcessNdmResult(combination, tuple); - } - catch(Exception ex) - { - tupleResult = new ForcesTupleResult() - { - IsValid = false, - Description = string.Empty + ex, - DesignForceTuple = tuple - }; - } - result.ForcesResultList.Add(tupleResult); - ActionToOutputResults?.Invoke(result); - } - } - } - Result = result; + throw new NotImplementedException(); } - private IForcesTupleResult ProcessNdmResult(IForceCombinationList combination, IDesignForceTuple tuple) + public ForceCalculator(ForceInputData inputData, + ICheckInputDataLogic checkInputDataLogic, + IForceCalculatorLogic forceCalculatorLogic, + IUpdateStrategy updateStrategy + ) { - IForcesTupleResult tupleResult; - LimitStates limitState = tuple.LimitState; - CalcTerms calcTerm = tuple.CalcTerm; - triangulateLogic = new TriangulatePrimitiveLogic() - { - Primitives = Primitives, - LimitState = limitState, - CalcTerm = calcTerm, - TraceLogger = TraceLogger - }; - var ndms = triangulateLogic.GetNdms(); - IPoint2D point2D; - IProcessorLogic forcelogic = new ForceTupleCopier(tuple.ForceTuple); - if (combination.SetInGravityCenter == true) - { - var (Cx, Cy) = LoaderCalculator.Logics.Geometry.GeometryOperations.GetGravityCenter(ndms); - point2D = new Point2D() { X = Cx, Y = Cy }; - forcelogic = new ForceTupleMoveToPointDecorator(forcelogic) { Point2D = point2D}; - } - var newTuple = forcelogic.GetValue(); - TraceLogger?.AddMessage("Input force combination"); - TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple)); - if (CompressedMember.Buckling == true) - { - if (newTuple.Nz >= 0d) - { - TraceLogger?.AddMessage(string.Format("Second order effect is not considered as Nz={0} >= 0", newTuple.Nz)); - tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple); - } - else - { - tupleResult = ProcessCompressedMember(combination, tuple, ndms, newTuple); - } - } - else - { - if (newTuple.Nz < 0d) - { - string message = string.Format("Second order effect is not considered, despite force Nz={0}", newTuple.Nz); - TraceLogger?.AddMessage(message, TraceLogStatuses.Warning); - } - tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple); - } - return tupleResult; + this.InputData = inputData; + this.checkInputDataLogic = checkInputDataLogic; + this.forceCalculatorLogic = forceCalculatorLogic; + this.updateStrategy = updateStrategy; } - private IForcesTupleResult ProcessCompressedMember(IForceCombinationList combination, IDesignForceTuple tuple, List ndms, IForceTuple newTuple) - { - IForcesTupleResult tupleResult; - LimitStates limitState = tuple.LimitState; - CalcTerms calcTerm = tuple.CalcTerm; - - TraceLogger?.AddMessage("Get eccentricity for full load"); - eccentricityLogic = new ProcessEccentricity(CompressedMember, ndms, newTuple) - { - TraceLogger = TraceLogger ?? null - }; - newTuple = eccentricityLogic.GetValue(); - var buclingInputData = new BucklingInputData() - { - Combination = combination, - LimitState = limitState, - CalcTerm = calcTerm, - Ndms = ndms, - ForceTuple = newTuple - }; - bucklingLogic = new ForceTupleBucklingLogic(buclingInputData) - { - CompressedMember = CompressedMember, - Accuracy = Accuracy, - Primitives = Primitives, - TraceLogger = TraceLogger?.GetSimilarTraceLogger(50) - }; - var buckResult = bucklingLogic.GetForceTupleByBuckling(); - if (buckResult.IsValid == true) - { - newTuple = buckResult.Value; - } - else - { - return new ForcesTupleResult() - { - IsValid = false, - DesignForceTuple = tuple, - Description = buckResult.Description, - }; - } - TraceLogger?.AddMessage(string.Intern("Result of second order was obtained succesfully, new force combination was obtained")); - tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple); - return tupleResult; - } - - private IForcesTupleResult GetForceResult(LimitStates limitState, CalcTerms calcTerm, List ndms, IForceTuple newTuple) - { - TraceLogger?.AddMessage("Calculation of cross-section is started"); - var tupleResult = GetPrimitiveStrainMatrix(ndms, newTuple, Accuracy); - tupleResult.DesignForceTuple.LimitState = limitState; - tupleResult.DesignForceTuple.CalcTerm = calcTerm; - tupleResult.DesignForceTuple.ForceTuple = newTuple; - return tupleResult; - } - - private string CheckInputData() - { - string result = string.Empty; - if (! Primitives.Any()) - { - result += "Calculator does not contain any primitives \n"; - } - if (ForceActions.Count == 0) - { - result += "Calculator does not contain any forces \n"; - } - if (LimitStatesList.Count == 0) - { - result += "Calculator does not contain any limit states \n"; - } - if (CalcTermsList.Count == 0) - { - result += "Calculator does not contain any calc term \n"; - } - //try - //{ - // triangulateLogic = new TriangulatePrimitiveLogic() - // { - // Primitives = Primitives - // }; - // triangulateLogic.CheckPrimitives(Primitives); - //} - //catch (Exception ex) - //{ - // result += ex; - //} - return result; - } - - public ForceCalculator(IForceTupleCalculator forceTupleCalculator) - { - this.forceTupleCalculator = forceTupleCalculator; - SetDefaultProperties(); - } - - public ForceCalculator() : this(new ForceTupleCalculator()) + public ForceCalculator(ForceInputData inputData) : + this(inputData, + new CheckForceCalculatorInputData(inputData), + new ForceCalculatorLogic(inputData), + new ForceCalculatorUpdateStrategy()) { } - private void SetDefaultProperties() - { - ForceActions = new List(); - Primitives = new List(); - CompressedMember = new CompressedMember() - { - Buckling = false - }; - Accuracy = new Accuracy() - { - IterationAccuracy = 0.001d, - MaxIterationCount = 1000 - }; - LimitStatesList = new List() - { - LimitStates.ULS, - LimitStates.SLS - }; - CalcTermsList = new List() - { - CalcTerms.ShortTerm, - CalcTerms.LongTerm - }; - } - private void GetCombinations() - { - ForceCombinationLists = new List(); - foreach (var item in ForceActions) - { - ForceCombinationLists.Add(item.GetCombinations()); - } - } - - private IForcesTupleResult GetPrimitiveStrainMatrix(IEnumerable ndmCollection, IForceTuple tuple, IAccuracy accuracy) - { - var inputData = new ForceTupleInputData() - { - NdmCollection = ndmCollection, - Tuple = tuple, - Accuracy = accuracy - }; - var calculator = forceTupleCalculator.Clone() as IForceTupleCalculator; - calculator.InputData = inputData; - if (TraceLogger is not null) - { - calculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(); - } - calculator.Run(); - return calculator.Result as IForcesTupleResult; - } + public ForceCalculator() : this(new ForceInputData()) { } public object Clone() { - var newCalculator = new ForceCalculator(); + var newCalculator = new ForceCalculator(new ForceInputData()); updateStrategy.Update(newCalculator, this); return newCalculator; } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorInputDataUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorInputDataUpdateStrategy.cs new file mode 100644 index 0000000..ffbbd35 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorInputDataUpdateStrategy.cs @@ -0,0 +1,42 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Sections; +using StructureHelperCommon.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces +{ + public class ForceCalculatorInputDataUpdateStrategy : IUpdateStrategy + { + private IUpdateStrategy accuracyUpdateStrategy; + private IUpdateStrategy compressedMemberUpdateStrategy; + public ForceCalculatorInputDataUpdateStrategy(IUpdateStrategy accuracyUpdateStrategy, IUpdateStrategy compressedMemberUpdateStrategy) + { + this.accuracyUpdateStrategy = accuracyUpdateStrategy; + this.compressedMemberUpdateStrategy = compressedMemberUpdateStrategy; + } + + public ForceCalculatorInputDataUpdateStrategy() : this(new AccuracyUpdateStrategy(), new CompressedMemberUpdateStrategy()) { } + public void Update(ForceInputData targetObject, ForceInputData sourceObject) + { + if (ReferenceEquals(targetObject, sourceObject)) { return; } + CheckObject.CompareTypes(targetObject, sourceObject); + targetObject.Accuracy ??= new Accuracy(); + accuracyUpdateStrategy.Update(targetObject.Accuracy, sourceObject.Accuracy); + targetObject.CompressedMember ??= new CompressedMember(); + compressedMemberUpdateStrategy.Update(targetObject.CompressedMember, sourceObject.CompressedMember); + targetObject.LimitStatesList.Clear(); + targetObject.LimitStatesList.AddRange(sourceObject.LimitStatesList); + targetObject.CalcTermsList.Clear(); + targetObject.CalcTermsList.AddRange(sourceObject.CalcTermsList); + targetObject.Primitives.Clear(); + targetObject.Primitives.AddRange(sourceObject.Primitives); + targetObject.ForceActions.Clear(); + targetObject.ForceActions.AddRange(sourceObject.ForceActions); + } + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorLogic.cs new file mode 100644 index 0000000..5fdd779 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorLogic.cs @@ -0,0 +1,209 @@ +using LoaderCalculator.Data.Ndms; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models.Sections; +using StructureHelperCommon.Models.Sections.Logics; +using StructureHelperCommon.Models.Shapes; +using StructureHelperLogics.NdmCalculations.Buckling; +using StructureHelperLogics.Services.NdmPrimitives; + +namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces +{ + public class ForceCalculatorLogic : IForceCalculatorLogic + { + private ForcesResults result; + private IProcessorLogic eccentricityLogic; + private ForceTupleBucklingLogic bucklingLogic; + private ITriangulatePrimitiveLogic triangulateLogic; + public ForceInputData InputData { get; set; } + public IShiftTraceLogger? TraceLogger { get; set; } + public Action ActionToOutputResults { get; set; } + + public ForceCalculatorLogic(ForceInputData inputData) + { + InputData = inputData; + } + public ForcesResults GetForcesResults() + { + TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); + GetCombinations(); + CalculateResult(); + return result; + } + + private void CalculateResult() + { + result = new ForcesResults() + { + IsValid = true + }; + foreach (var combination in InputData.ForceCombinationLists) + { + foreach (var tuple in combination.DesignForces) + { + var limitState = tuple.LimitState; + var calcTerm = tuple.CalcTerm; + if (InputData.LimitStatesList.Contains(limitState) & InputData.CalcTermsList.Contains(calcTerm)) + { + + IForcesTupleResult tupleResult; + try + { + tupleResult = ProcessNdmResult(combination, tuple); + } + catch (Exception ex) + { + tupleResult = new ForcesTupleResult() + { + IsValid = false, + Description = string.Empty + ex, + DesignForceTuple = tuple + }; + } + result.ForcesResultList.Add(tupleResult); + ActionToOutputResults?.Invoke(result); + } + } + } + } + + private IForcesTupleResult ProcessNdmResult(IForceCombinationList combination, IDesignForceTuple tuple) + { + IForcesTupleResult tupleResult; + LimitStates limitState = tuple.LimitState; + CalcTerms calcTerm = tuple.CalcTerm; + triangulateLogic = new TriangulatePrimitiveLogic() + { + Primitives = InputData.Primitives, + LimitState = limitState, + CalcTerm = calcTerm, + TraceLogger = TraceLogger + }; + var ndms = triangulateLogic.GetNdms(); + IPoint2D point2D; + IProcessorLogic forcelogic = new ForceTupleCopier(tuple.ForceTuple); + if (combination.SetInGravityCenter == true) + { + var (Cx, Cy) = LoaderCalculator.Logics.Geometry.GeometryOperations.GetGravityCenter(ndms); + point2D = new Point2D() { X = Cx, Y = Cy }; + forcelogic = new ForceTupleMoveToPointDecorator(forcelogic) { Point2D = point2D }; + } + var newTuple = forcelogic.GetValue(); + TraceLogger?.AddMessage("Input force combination"); + TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple)); + if (InputData.CompressedMember.Buckling == true) + { + if (newTuple.Nz >= 0d) + { + TraceLogger?.AddMessage(string.Format("Second order effect is not considered as Nz={0} >= 0", newTuple.Nz)); + tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple); + } + else + { + tupleResult = ProcessCompressedMember(combination, tuple, ndms, newTuple); + } + } + else + { + if (newTuple.Nz < 0d) + { + string message = string.Format("Second order effect is not considered, despite force Nz={0}", newTuple.Nz); + TraceLogger?.AddMessage(message, TraceLogStatuses.Warning); + } + tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple); + } + return tupleResult; + } + + private IForcesTupleResult ProcessCompressedMember(IForceCombinationList combination, IDesignForceTuple tuple, List ndms, IForceTuple newTuple) + { + IForcesTupleResult tupleResult; + LimitStates limitState = tuple.LimitState; + CalcTerms calcTerm = tuple.CalcTerm; + + TraceLogger?.AddMessage("Get eccentricity for full load"); + eccentricityLogic = new ProcessEccentricity(InputData.CompressedMember, ndms, newTuple) + { + TraceLogger = TraceLogger ?? null + }; + newTuple = eccentricityLogic.GetValue(); + var buclingInputData = new BucklingInputData() + { + Combination = combination, + LimitState = limitState, + CalcTerm = calcTerm, + Ndms = ndms, + ForceTuple = newTuple + }; + bucklingLogic = new ForceTupleBucklingLogic(buclingInputData) + { + CompressedMember = InputData.CompressedMember, + Accuracy = InputData.Accuracy, + Primitives = InputData.Primitives, + TraceLogger = TraceLogger?.GetSimilarTraceLogger(50) + }; + var buckResult = bucklingLogic.GetForceTupleByBuckling(); + if (buckResult.IsValid == true) + { + newTuple = buckResult.Value; + } + else + { + return new ForcesTupleResult() + { + IsValid = false, + DesignForceTuple = tuple, + Description = buckResult.Description, + }; + } + + string message = string.Intern("Result of second order was obtained succesfully, new force combination was obtained"); + TraceLogger?.AddMessage(message); + tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple); + return tupleResult; + } + + private IForcesTupleResult GetForceResult(LimitStates limitState, CalcTerms calcTerm, List ndms, IForceTuple newTuple) + { + TraceLogger?.AddMessage("Calculation of cross-section is started"); + var tupleResult = GetPrimitiveStrainMatrix(ndms, newTuple, InputData.Accuracy); + tupleResult.DesignForceTuple.LimitState = limitState; + tupleResult.DesignForceTuple.CalcTerm = calcTerm; + tupleResult.DesignForceTuple.ForceTuple = newTuple; + return tupleResult; + } + + + private void GetCombinations() + { + InputData.ForceCombinationLists = new List(); + foreach (var item in InputData.ForceActions) + { + InputData.ForceCombinationLists.Add(item.GetCombinations()); + } + } + + private IForcesTupleResult GetPrimitiveStrainMatrix(IEnumerable ndmCollection, IForceTuple tuple, IAccuracy accuracy) + { + var inputData = new ForceTupleInputData() + { + NdmCollection = ndmCollection, + Tuple = tuple, + Accuracy = accuracy + }; + var calculator = new ForceTupleCalculator(); + calculator.InputData = inputData; + if (TraceLogger is not null) + { + calculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(); + } + calculator.Run(); + return calculator.Result as IForcesTupleResult; + } + + + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceInputData.cs index aa5a4d2..136a291 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceInputData.cs @@ -1,6 +1,10 @@ using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Models.Sections; using StructureHelperLogics.Models.Calculations.CalculationProperties; +using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Collections.Generic; using System.Linq; @@ -9,11 +13,40 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { - public class ForceInputData : IForceInputData + public class ForceInputData : IInputData, IHasPrimitives, IHasForceCombinations { - public IEnumerable ForceCombinationLists { get; set; } - public IEnumerable LimitStates { get; set; } - public IEnumerable CalcTerms { get; set; } - public IIterationProperty IterationProperty { get; } + public List LimitStatesList { get; private set; } + public List CalcTermsList { get; private set; } + public List ForceActions { get; private set; } + public List Primitives { get; private set; } + public ICompressedMember CompressedMember { get; set; } + public IAccuracy Accuracy { get; set; } + public List ForceCombinationLists { get; set; } + + public ForceInputData() + { + ForceActions = new List(); + ForceCombinationLists = new List(); + Primitives = new List(); + CompressedMember = new CompressedMember() + { + Buckling = false + }; + Accuracy = new Accuracy() + { + IterationAccuracy = 0.001d, + MaxIterationCount = 1000 + }; + LimitStatesList = new List() + { + LimitStates.ULS, + LimitStates.SLS + }; + CalcTermsList = new List() + { + CalcTerms.ShortTerm, + CalcTerms.LongTerm + }; + } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculator.cs deleted file mode 100644 index 7061f24..0000000 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculator.cs +++ /dev/null @@ -1,18 +0,0 @@ -using StructureHelperCommon.Infrastructures.Enums; -using StructureHelperCommon.Infrastructures.Interfaces; -using StructureHelperCommon.Models.Calculators; -using StructureHelperCommon.Models.Forces; -using StructureHelperCommon.Models.Sections; -using StructureHelperLogics.NdmCalculations.Primitives; - -namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces -{ - public interface IForceCalculator : ICalculator, IHasPrimitives, IHasForceCombinations - { - List CalcTermsList { get; } - List LimitStatesList { get; } - ICompressedMember CompressedMember { get; } - IAccuracy Accuracy { get; set; } - List ForceCombinationLists { get;} - } -} \ No newline at end of file diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculatorLogic.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculatorLogic.cs new file mode 100644 index 0000000..52e31a5 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceCalculatorLogic.cs @@ -0,0 +1,16 @@ +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.NdmCalculations.Analyses.ByForces +{ + public interface IForceCalculatorLogic : ILogic, IHasActionByResult + { + ForceInputData InputData { get; set; } + ForcesResults GetForcesResults(); + } +} diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceInputData.cs deleted file mode 100644 index d2a6d7e..0000000 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/IForceInputData.cs +++ /dev/null @@ -1,15 +0,0 @@ -using StructureHelperCommon.Infrastructures.Enums; -using StructureHelperCommon.Models.Forces; -using StructureHelperLogics.Models.Calculations.CalculationProperties; -using System.Collections.Generic; - -namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces -{ - public interface IForceInputData - { - IEnumerable CalcTerms { get; set; } - IEnumerable ForceCombinationLists { get; set; } - IIterationProperty IterationProperty { get; } - IEnumerable LimitStates { get; set; } - } -} \ No newline at end of file diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceCalculatorUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceCalculatorUpdateStrategy.cs index f8f77a8..3176ad0 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceCalculatorUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceCalculatorUpdateStrategy.cs @@ -4,24 +4,20 @@ using StructureHelperCommon.Models.Sections; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics { - public class ForceCalculatorUpdateStrategy : IUpdateStrategy + public class ForceCalculatorUpdateStrategy : IUpdateStrategy { - static readonly AccuracyUpdateStrategy accuracyUpdateStrategy = new(); - static readonly CompressedMemberUpdateStrategy compressedMemberUpdateStrategy = new(); - public void Update(IForceCalculator targetObject, IForceCalculator sourceObject) + private readonly IUpdateStrategy inputDataUpdateStrategy; + public ForceCalculatorUpdateStrategy(IUpdateStrategy inputDataUpdateStrategy) + { + this.inputDataUpdateStrategy = inputDataUpdateStrategy; + } + public ForceCalculatorUpdateStrategy() : this(new ForceCalculatorInputDataUpdateStrategy()) { } + public void Update(ForceCalculator targetObject, ForceCalculator sourceObject) { if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.Name = sourceObject.Name; - targetObject.LimitStatesList.Clear(); - targetObject.LimitStatesList.AddRange(sourceObject.LimitStatesList); - targetObject.CalcTermsList.Clear(); - targetObject.CalcTermsList.AddRange(sourceObject.CalcTermsList); - accuracyUpdateStrategy.Update(targetObject.Accuracy, sourceObject.Accuracy); - compressedMemberUpdateStrategy.Update(targetObject.CompressedMember, sourceObject.CompressedMember); - targetObject.Primitives.Clear(); - targetObject.Primitives.AddRange(sourceObject.Primitives); - targetObject.ForceActions.Clear(); - targetObject.ForceActions.AddRange(sourceObject.ForceActions); + targetObject.InputData ??= new ForceInputData(); + inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData); } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs index cc6eada..c8850df 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/Logics/CalculatorUpdateStrategy.cs @@ -21,9 +21,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Logics { if (ReferenceEquals(targetObject, sourceObject)) { return; } CheckObject.CompareTypes(targetObject, sourceObject); - if (targetObject is IForceCalculator target) + if (targetObject is ForceCalculator target) { - new ForceCalculatorUpdateStrategy().Update(target, (IForceCalculator)sourceObject); + new ForceCalculatorUpdateStrategy().Update(target, (ForceCalculator)sourceObject); } else if (targetObject is LimitCurvesCalculator limitCurves) { diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CheckTupleCalculatorInputData.cs b/StructureHelperLogics/NdmCalculations/Cracking/CheckTupleCalculatorInputData.cs index a22968b..8559d52 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CheckTupleCalculatorInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CheckTupleCalculatorInputData.cs @@ -10,31 +10,23 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Cracking { - public class CheckTupleCalculatorInputData : ICheckInputDataLogic + public class CheckTupleCalculatorInputData : ICheckInputDataLogic { private string checkResult; - private TupleCrackInputData inputData; private bool result; - public IInputData InputData - { - get => inputData; set - { - if (value is TupleCrackInputData data) - { - inputData = data; - } - else - { - throw new StructureHelperException(ErrorStrings.DataIsInCorrect); - } - } - } + public TupleCrackInputData InputData { get; set; } + public string CheckResult => checkResult; public IShiftTraceLogger? TraceLogger { get; set; } + public CheckTupleCalculatorInputData(TupleCrackInputData inputData) + { + InputData = inputData; + } + public bool Check() { result = true; diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs index 3ff8f64..f89d503 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculator.cs @@ -23,19 +23,22 @@ namespace StructureHelperLogics.NdmCalculations.Cracking private CrackResult result; private IGetTupleInputDatasLogic datasLogic; private CrackCalculatorUpdateStrategy updateStrategy = new(); - private ICheckInputDataLogic checkInputDataLogic; + private ICheckInputDataLogic checkInputDataLogic; public string Name { get; set; } public CrackInputData InputData { get; set; } public IResult Result => result; public IShiftTraceLogger? TraceLogger { get; set; } - public CrackCalculator(CrackInputData inputData, ICheckInputDataLogic checkInputDataLogic) + public CrackCalculator(CrackInputData inputData, ICheckInputDataLogic checkInputDataLogic) { InputData = inputData; this.checkInputDataLogic = checkInputDataLogic; + Name = string.Empty; } + public CrackCalculator(CrackInputData inputData) : this(inputData, new CheckCrackCalculatorInputDataLogic(inputData)) { } + public object Clone() { CrackInputData crackInputData = new CrackInputData(); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculatorUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculatorUpdateStrategy.cs index 72afe64..2ceb464 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculatorUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackCalculatorUpdateStrategy.cs @@ -10,7 +10,13 @@ namespace StructureHelperLogics.NdmCalculations.Cracking { public class CrackCalculatorUpdateStrategy : IUpdateStrategy { - private CrackInputDataUpdateStrategy crackInputDataUpdateStrategy => new(); + private IUpdateStrategy inputDataUpdateStrategy; + + public CrackCalculatorUpdateStrategy(IUpdateStrategy inputDataUpdateStrategy) + { + this.inputDataUpdateStrategy = inputDataUpdateStrategy; + } + public CrackCalculatorUpdateStrategy() : this(new CrackInputDataUpdateStrategy()) { } public void Update(CrackCalculator targetObject, CrackCalculator sourceObject) { if (ReferenceEquals(targetObject, sourceObject)) { return; } @@ -18,7 +24,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking targetObject.Name = sourceObject.Name; targetObject.InputData ??= new(); - crackInputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData); + inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData); } } } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackInputData.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackInputData.cs index 4105123..2109c3e 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackInputData.cs @@ -16,7 +16,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking public List Primitives { get; private set; } /// public List ForceActions { get; private set; } - public UserCrackInputData UserCrackInputData { get; private set; } + public UserCrackInputData UserCrackInputData { get; set; } public CrackInputData() { Primitives = new(); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackInputDataUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackInputDataUpdateStrategy.cs index d018e8f..c0605be 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackInputDataUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackInputDataUpdateStrategy.cs @@ -10,7 +10,16 @@ namespace StructureHelperLogics.NdmCalculations.Cracking { public class CrackInputDataUpdateStrategy : IUpdateStrategy { - private UserCrackInputDataUpdateStrategy userCrackInputDataUpdateStrategy => new(); + private IUpdateStrategy userCrackInputDataUpdateStrategy; + public CrackInputDataUpdateStrategy(IUpdateStrategy userCrackInputDataUpdateStrategy) + { + this.userCrackInputDataUpdateStrategy = userCrackInputDataUpdateStrategy; + } + + public CrackInputDataUpdateStrategy() : this(new UserCrackInputDataUpdateStrategy()) + { + + } public void Update(CrackInputData targetObject, CrackInputData sourceObject) { if (ReferenceEquals(targetObject, sourceObject)) { return; } @@ -19,7 +28,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking targetObject.ForceActions.AddRange(sourceObject.ForceActions); targetObject.Primitives.Clear(); targetObject.Primitives.AddRange(sourceObject.Primitives); - + targetObject.UserCrackInputData ??= new UserCrackInputData(); userCrackInputDataUpdateStrategy.Update(targetObject.UserCrackInputData, sourceObject.UserCrackInputData); } } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs index 6f0c4f6..90a266c 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/CrackedSectionTriangulationLogic.cs @@ -13,6 +13,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.NdmCalculations.Cracking { + /// public class CrackedSectionTriangulationLogic : ICrackedSectionTriangulationLogic { const LimitStates limitState = LimitStates.SLS; @@ -35,6 +36,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking TraceLogger = TraceLogger?.GetSimilarTraceLogger(50) }; } + /// public List GetNdmCollection() { TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); @@ -48,6 +50,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking }; return triangulateLogic.GetNdms(); } + /// public List GetCrackedNdmCollection() { TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); @@ -62,6 +65,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking return triangulateLogic.GetNdms(); } + /// public List GetRebarPrimitives() { TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); @@ -79,6 +83,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking return rebarPrimitives; } + /// public List GetElasticNdmCollection() { TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/RebarCrackCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/RebarCrackCalculator.cs index 8affe0d..2bc5ee5 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/RebarCrackCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/RebarCrackCalculator.cs @@ -79,6 +79,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking } catch (Exception ex) { + TraceLogger?.AddMessage($"Error of crack width calculation {ex}", TraceLogStatuses.Error); result.IsValid = false; result.Description += "\n" + ex; } diff --git a/StructureHelperLogics/NdmCalculations/Cracking/TupleCrackCalculator.cs b/StructureHelperLogics/NdmCalculations/Cracking/TupleCrackCalculator.cs index c388607..afa4607 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/TupleCrackCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/TupleCrackCalculator.cs @@ -9,6 +9,7 @@ using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Services.Forces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Primitives; +using StructureHelperLogics.NdmCalculations.Triangulations; using StructureHelperLogics.Services.NdmPrimitives; //Copyright (c) 2024 Redikultsev Evgeny, Ekaterinburg, Russia @@ -18,6 +19,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking { public class TupleCrackCalculator : ICalculator { + private const CalcTerms crackingTerm = CalcTerms.ShortTerm; + private const LimitStates crackingLimitState = LimitStates.SLS; private static readonly ILengthBetweenCracksLogic lengthLogic = new LengthBetweenCracksLogicSP63(); private TupleCrackResult result; private ICrackedSectionTriangulationLogic triangulationLogic; @@ -143,6 +146,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking { IEnumerable crackableNdmsLoc = null; IEnumerable crackedNdmsLoc = null; + INdm concreteNdmUnderRebar; RebarPrimitive rebarCopy = null; lock (locker) { @@ -151,6 +155,11 @@ namespace StructureHelperLogics.NdmCalculations.Cracking var triangulationLogicLoc = new CrackedSectionTriangulationLogic(InputData.Primitives); crackableNdmsLoc = triangulationLogicLoc.GetNdmCollection(); crackedNdmsLoc = triangulationLogicLoc.GetCrackedNdmCollection(); + //concreteNdmUnderRebar = rebarCopy.GetConcreteNdm(new TriangulationOptions() + //{ CalcTerm = crackingTerm, + // LimiteState = crackingLimitState }); + //concreteNdmUnderRebar.StressScale = 1d; + //crackableNdmsLoc = new List() { concreteNdmUnderRebar}; } var longRebarData = new RebarCrackInputData() @@ -162,7 +171,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking }; var shortRebarData = new RebarCrackInputData() { - CrackableNdmCollection = crackableNdms, + CrackableNdmCollection = crackableNdmsLoc, CrackedNdmCollection = crackedNdms, ForceTuple = InputData.ShortTermTuple.Clone() as ForceTuple, Length = shortLength diff --git a/StructureHelperLogics/Services/NdmCalculations/InterpolateService.cs b/StructureHelperLogics/Services/NdmCalculations/InterpolateService.cs index 921dbc4..f49bb6c 100644 --- a/StructureHelperLogics/Services/NdmCalculations/InterpolateService.cs +++ b/StructureHelperLogics/Services/NdmCalculations/InterpolateService.cs @@ -8,17 +8,17 @@ namespace StructureHelperLogics.Services.NdmCalculations public static class InterpolateService { static readonly CompressedMemberUpdateStrategy compressedMemberUpdateStrategy = new(); - public static ForceCalculator InterpolateForceCalculator(IForceCalculator source, InterpolateTuplesResult interpolateTuplesResult) + public static ForceCalculator InterpolateForceCalculator(ForceCalculator source, InterpolateTuplesResult interpolateTuplesResult) { ForceCalculator calculator = new ForceCalculator(); - calculator.LimitStatesList.Clear(); - calculator.LimitStatesList.Add(interpolateTuplesResult.StartTuple.LimitState); - calculator.CalcTermsList.Clear(); - calculator.CalcTermsList.Add(interpolateTuplesResult.FinishTuple.CalcTerm); - compressedMemberUpdateStrategy.Update(calculator.CompressedMember, source.CompressedMember); - calculator.Accuracy = source.Accuracy; - calculator.Primitives.AddRange(source.Primitives); - calculator.ForceActions.Clear(); + calculator.InputData.LimitStatesList.Clear(); + calculator.InputData.LimitStatesList.Add(interpolateTuplesResult.StartTuple.LimitState); + calculator.InputData.CalcTermsList.Clear(); + calculator.InputData.CalcTermsList.Add(interpolateTuplesResult.FinishTuple.CalcTerm); + compressedMemberUpdateStrategy.Update(calculator.InputData.CompressedMember, source.InputData.CompressedMember); + calculator.InputData.Accuracy = source.InputData.Accuracy; + calculator.InputData.Primitives.AddRange(source.InputData.Primitives); + calculator.InputData.ForceActions.Clear(); var forceTuples = ForceTupleService.InterpolateDesignTuple(interpolateTuplesResult.FinishTuple, interpolateTuplesResult.StartTuple, interpolateTuplesResult.StepCount); foreach (var forceTuple in forceTuples) { @@ -31,12 +31,12 @@ namespace StructureHelperLogics.Services.NdmCalculations combination.DesignForces.Add(forceTuple); combination.ForcePoint.X = 0; combination.ForcePoint.Y = 0; - calculator.ForceActions.Add(combination); + calculator.InputData.ForceActions.Add(combination); } return calculator; } - public static IForceCalculator InterpolateForceCalculator(IForceCalculator forceCalculator, IDesignForceTuple finishDesignTuple, object startDesignTuple, object stepCount) + public static ForceCalculator InterpolateForceCalculator(ForceCalculator forceCalculator, IDesignForceTuple finishDesignTuple, object startDesignTuple, object stepCount) { throw new NotImplementedException(); } diff --git a/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs b/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs index 98eb362..f78021c 100644 --- a/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs +++ b/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs @@ -23,8 +23,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT HeightCount = heightCount }; var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); - var calculator = newSection.SectionRepository.CalculatorsList[0] as IForceCalculator; - calculator.CompressedMember.Buckling = isBuckling; + var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; + calculator.InputData.CompressedMember.Buckling = isBuckling; //Act calculator.Run(); var result = calculator.Result as IForcesResults; @@ -48,8 +48,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT //Arrange var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); - var calculator = newSection.SectionRepository.CalculatorsList[0] as IForceCalculator; - calculator.CompressedMember.Buckling = isBuckling; + var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; + calculator.InputData.CompressedMember.Buckling = isBuckling; //Act calculator.Run(); var result = calculator.Result as IForcesResults; @@ -65,8 +65,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT //Arrange var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); - var calculator = newSection.SectionRepository.CalculatorsList[0] as IForceCalculator; - calculator.CompressedMember.Buckling = false; + var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator; + calculator.InputData.CompressedMember.Buckling = false; calculator.Run(); var ndmPrimitives = newSection.SectionRepository.Primitives; var result = calculator.Result as IForcesResults;