diff --git a/DataAccess/DTOs/DTOEntities/Forces/ForceCombinationFromFileDTO.cs b/DataAccess/DTOs/DTOEntities/Forces/ForceCombinationFromFileDTO.cs index 093c66a..f6346bd 100644 --- a/DataAccess/DTOs/DTOEntities/Forces/ForceCombinationFromFileDTO.cs +++ b/DataAccess/DTOs/DTOEntities/Forces/ForceCombinationFromFileDTO.cs @@ -18,7 +18,9 @@ namespace DataAccess.DTOs public bool SetInGravityCenter { get; set; } [JsonProperty("ForcePoint")] public IPoint2D ForcePoint { get; set; } = new Point2DDTO(); - + [JsonProperty("SkipWrongRows")] + public bool SkipWrongRows { get; set; } = false; + public ForceCombinationFromFileDTO(Guid id) { Id = id; diff --git a/StructureHelper/Documentation/Verification/Materials.shpj b/StructureHelper/Documentation/Verification/Materials.shpj index 64de14e..b93f81c 100644 --- a/StructureHelper/Documentation/Verification/Materials.shpj +++ b/StructureHelper/Documentation/Verification/Materials.shpj @@ -2,7 +2,7 @@ "$id": "1", "$type": "RootObject", "FileVersion": { - "Id": "0e4e721a-1df3-4693-999d-3670b14f7113", + "Id": "f5247ddd-f79f-4943-9e09-764e2a47d0d3", "VersionNumber": 1, "SubVersionNumber": 4 }, @@ -20,7 +20,7 @@ "$id": "4", "$type": "CrossSectionNdmAnalysis", "Id": "4027079c-d866-4266-b15e-e2a59bb69bfa", - "Name": "New NDM Analysis", + "Name": "Materials", "Tags": "#New group", "VersionProcessor": { "$id": "5", @@ -1579,6 +1579,158 @@ "TensionForSLS": true, "MaterialLogicId": "b97e8168-76a1-4e24-ae98-9aa38edd1e9a" } + }, + { + "$id": "165", + "$type": "HeadMaterial", + "Id": "a975c01f-2028-4aa7-93b1-0ef1cfc73580", + "Name": "A240", + "Color": "#FF6ACF46", + "HelperMaterial": { + "$id": "166", + "$type": "ReinforcementLibMaterial", + "Id": "6ec6f688-21ea-4d7a-83a0-66ec7d2ef268", + "MaterialEntityId": "c47ebbd7-2e0c-4247-81b6-dc3fbd064bab", + "SafetyFactors": { + "$id": "167", + "$type": "ListOfMaterialSafetyFactor", + "$values": [] + }, + "MaterialLogicId": "54c4fe40-8f82-4995-8930-81e65e97edb9" + } + }, + { + "$id": "168", + "$type": "HeadMaterial", + "Id": "257fe163-585d-4f7a-a96a-3634e9b6861e", + "Name": "A400", + "Color": "#FF61881E", + "HelperMaterial": { + "$id": "169", + "$type": "ReinforcementLibMaterial", + "Id": "a0547d68-4b5a-42c6-bf20-cc1f9caa8157", + "MaterialEntityId": "ea422282-3465-433c-9b93-c5bbfba5a904", + "SafetyFactors": { + "$id": "170", + "$type": "ListOfMaterialSafetyFactor", + "$values": [] + }, + "MaterialLogicId": "54c4fe40-8f82-4995-8930-81e65e97edb9" + } + }, + { + "$id": "171", + "$type": "HeadMaterial", + "Id": "d5dd42c1-372f-4217-a85f-e3eaaa753b6c", + "Name": "A500", + "Color": "#FFECAA46", + "HelperMaterial": { + "$id": "172", + "$type": "ReinforcementLibMaterial", + "Id": "ca7ce2f8-7bbc-4379-8166-8fc7a4adefc0", + "MaterialEntityId": "045b54b1-0bbf-41fd-a27d-aeb20f600bb4", + "SafetyFactors": { + "$id": "173", + "$type": "ListOfMaterialSafetyFactor", + "$values": [] + }, + "MaterialLogicId": "54c4fe40-8f82-4995-8930-81e65e97edb9" + } + }, + { + "$id": "174", + "$type": "HeadMaterial", + "Id": "e4245f23-f51a-4ed1-a4e5-5f7133028a27", + "Name": "A600", + "Color": "#FF3B68D7", + "HelperMaterial": { + "$id": "175", + "$type": "ReinforcementLibMaterial", + "Id": "4479ec6e-8cf6-48ec-94b7-8645f6aa7ac5", + "MaterialEntityId": "e3cfc6fb-fbd0-47dd-ab4a-79c030704acf", + "SafetyFactors": { + "$id": "176", + "$type": "ListOfMaterialSafetyFactor", + "$values": [] + }, + "MaterialLogicId": "54c4fe40-8f82-4995-8930-81e65e97edb9" + } + }, + { + "$id": "177", + "$type": "HeadMaterial", + "Id": "14b73c38-249d-4c0f-afcc-a1b2ef7268f3", + "Name": "A800", + "Color": "#FFCA9F48", + "HelperMaterial": { + "$id": "178", + "$type": "ReinforcementLibMaterial", + "Id": "b626d13f-f754-411e-8092-1e92e9a27161", + "MaterialEntityId": "6f0882ef-53bf-464e-acf7-da421a43a825", + "SafetyFactors": { + "$id": "179", + "$type": "ListOfMaterialSafetyFactor", + "$values": [] + }, + "MaterialLogicId": "54c4fe40-8f82-4995-8930-81e65e97edb9" + } + }, + { + "$id": "180", + "$type": "HeadMaterial", + "Id": "bab99d80-6773-492c-ad88-1ad8cb948d58", + "Name": "A1000", + "Color": "#FFF5812A", + "HelperMaterial": { + "$id": "181", + "$type": "ReinforcementLibMaterial", + "Id": "b05e32ce-38ae-44f2-bb2c-428d92876544", + "MaterialEntityId": "509fbaae-a3de-43c2-aae6-33387908dc43", + "SafetyFactors": { + "$id": "182", + "$type": "ListOfMaterialSafetyFactor", + "$values": [] + }, + "MaterialLogicId": "54c4fe40-8f82-4995-8930-81e65e97edb9" + } + }, + { + "$id": "183", + "$type": "HeadMaterial", + "Id": "31b4492a-bfe7-4fcf-8f1d-b2f3df11e837", + "Name": "K1400", + "Color": "#FFF150B3", + "HelperMaterial": { + "$id": "184", + "$type": "ReinforcementLibMaterial", + "Id": "0693f06e-f1c6-4e00-acfc-11047344052a", + "MaterialEntityId": "1b44e9eb-d19d-4fd5-9755-33ae01683dc1", + "SafetyFactors": { + "$id": "185", + "$type": "ListOfMaterialSafetyFactor", + "$values": [] + }, + "MaterialLogicId": "54c4fe40-8f82-4995-8930-81e65e97edb9" + } + }, + { + "$id": "186", + "$type": "HeadMaterial", + "Id": "1c1a7ca3-aae7-4ca8-b5bd-dea1b9753e12", + "Name": "K1500", + "Color": "#FFC98453", + "HelperMaterial": { + "$id": "187", + "$type": "ReinforcementLibMaterial", + "Id": "6a3ac6d5-7c5c-42d5-a49e-66e267e8cbd2", + "MaterialEntityId": "93c48a27-ab37-4bd2-aeb8-2a7247e74a1b", + "SafetyFactors": { + "$id": "188", + "$type": "ListOfMaterialSafetyFactor", + "$values": [] + }, + "MaterialLogicId": "54c4fe40-8f82-4995-8930-81e65e97edb9" + } } ] }, @@ -1596,7 +1748,7 @@ } }, "WorkPlaneProperty": { - "$id": "165", + "$id": "189", "$type": "WorkPlanePropertyDTO", "Id": "31ec91ea-d0bc-4426-9ca4-e22e17889457", "GridSize": 0.05, diff --git a/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs b/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs index 06dfd3b..ad957d9 100644 --- a/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs +++ b/StructureHelper/Infrastructure/UI/DataContexts/CircleViewPrimitive.cs @@ -31,6 +31,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts public CircleViewPrimitive(IEllipseNdmPrimitive primitive) : base(primitive) { + this.primitive = primitive; DivisionViewModel = new HasDivisionViewModel(primitive.DivisionSize); } diff --git a/StructureHelper/Libraries/LoaderCalculator.dll b/StructureHelper/Libraries/LoaderCalculator.dll index 9e66def..383d1f5 100644 Binary files a/StructureHelper/Libraries/LoaderCalculator.dll and b/StructureHelper/Libraries/LoaderCalculator.dll differ diff --git a/StructureHelper/Windows/Forces/ForceCombinationByFactorVM.cs b/StructureHelper/Windows/Forces/ForceCombinationByFactorVM.cs index aba7a37..cd31158 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationByFactorVM.cs +++ b/StructureHelper/Windows/Forces/ForceCombinationByFactorVM.cs @@ -19,7 +19,8 @@ namespace StructureHelper.Windows.Forces public ForceTupleVM ForceTupleVM => forceTupleVM; public FactoredCombinationPropertyVM CombinationProperty { - get => combinationProperty; set + get => combinationProperty; + set { combinationProperty = value; OnPropertyChanged(nameof(CombinationProperty)); diff --git a/StructureHelper/Windows/Forces/ForceCombinationFromFileVM.cs b/StructureHelper/Windows/Forces/ForceCombinationFromFileVM.cs index ef5fc62..bef535c 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationFromFileVM.cs +++ b/StructureHelper/Windows/Forces/ForceCombinationFromFileVM.cs @@ -1,4 +1,6 @@ -using StructureHelper.Windows.ViewModels; +using StructureHelper.Infrastructure; +using StructureHelper.Windows.ViewModels; +using StructureHelper.Windows.ViewModels.Errors; using StructureHelper.Windows.ViewModels.Forces; using StructureHelperCommon.Models.Forces; using System; @@ -6,6 +8,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; namespace StructureHelper.Windows.Forces { @@ -14,16 +17,44 @@ namespace StructureHelper.Windows.Forces private readonly IForceCombinationFromFile model; private ListOfFilesVM files; private FactoredCombinationPropertyVM combinationProperty; + private RelayCommand showCombinationViewerCommand; public FactoredCombinationPropertyVM CombinationProperty { - get => combinationProperty; set + get => combinationProperty; + set { combinationProperty = value; OnPropertyChanged(nameof(CombinationProperty)); } } + public bool SkipWrongRows + { + get + { + return model.SkipWrongRows; + } + + set + { + model.SkipWrongRows = value; + OnPropertyChanged(nameof(SkipWrongRows)); + } + } + + public ICommand ShowCombinationViewerCommand + { + get => showCombinationViewerCommand ??= new RelayCommand( + o =>SafetyProcessor.RunSafeProcess(ShowCombinationViewer, "Combination viewer")); + } + + private void ShowCombinationViewer() + { + var wnd = new ForceCombinationViewerView(model); + wnd.ShowDialog(); + } + public ListOfFilesVM Files { get => files; set diff --git a/StructureHelper/Windows/Forces/ForceCombinationFromFileView.xaml b/StructureHelper/Windows/Forces/ForceCombinationFromFileView.xaml index 70fb2d1..8412d4a 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationFromFileView.xaml +++ b/StructureHelper/Windows/Forces/ForceCombinationFromFileView.xaml @@ -7,7 +7,7 @@ xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance local:ForceCombinationFromFileVM}" mc:Ignorable="d" - Title="Force Combination By Files" Height="330" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> + Title="Force Combination By Files" Height="380" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> @@ -18,6 +18,8 @@ + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/Forces/ForceCombinationViewerView.xaml.cs b/StructureHelper/Windows/Forces/ForceCombinationViewerView.xaml.cs index 8fd138b..0c27a4a 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationViewerView.xaml.cs +++ b/StructureHelper/Windows/Forces/ForceCombinationViewerView.xaml.cs @@ -1,17 +1,5 @@ using StructureHelperCommon.Models.Forces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace StructureHelper.Windows.Forces { diff --git a/StructureHelper/Windows/Graphs/MaterialDiagramViewModel.cs b/StructureHelper/Windows/Graphs/MaterialDiagramViewModel.cs index 23403cb..fcae488 100644 --- a/StructureHelper/Windows/Graphs/MaterialDiagramViewModel.cs +++ b/StructureHelper/Windows/Graphs/MaterialDiagramViewModel.cs @@ -206,7 +206,7 @@ namespace StructureHelper.Windows.Graphs for (double s = minValue; s < maxValue; s += step) { double strain = s * factor; - double diagramValue = loaderMaterial.Diagram.Invoke(loaderMaterial.DiagramParameters, strain) * factor; + double diagramValue = loaderMaterial.Diagram.Invoke(strain) * factor; StressEntity stressEntity = new() { LimitState = limitState, @@ -255,11 +255,12 @@ namespace StructureHelper.Windows.Graphs GraphService.SetVisualProps(lineSeries, VisualProps); } var chartValues = new ChartValues(); - for (double s = minValue; s < maxValue; s += step) + for (double strain = minValue; strain < maxValue; strain += step) { - double diagramValue = Math.Round(loaderMaterial.Diagram.Invoke(loaderMaterial.DiagramParameters, s * factor)) * factor * UnitConstants.Stress; + double factoredStrain = strain * factor; + double diagramValue = Math.Round(loaderMaterial.Diagram.Invoke(factoredStrain)) * factor * UnitConstants.Stress; chartValues.Add(diagramValue); - labels.Add(Convert.ToString(Math.Round(s, 4))); + labels.Add(Convert.ToString(Math.Round(strain, 4))); } lineSeries.Values = chartValues; SeriesCollection.Add(lineSeries); diff --git a/StructureHelperCommon/Models/Forces/ColumnedFileProperty.cs b/StructureHelperCommon/Models/Forces/ColumnedFileProperty.cs index 78e15d2..e64f80f 100644 --- a/StructureHelperCommon/Models/Forces/ColumnedFileProperty.cs +++ b/StructureHelperCommon/Models/Forces/ColumnedFileProperty.cs @@ -24,6 +24,7 @@ namespace StructureHelperCommon.Models.Forces public double GlobalFactor { get; set; } = 1d; /// public List ColumnProperties { get; } = new(); + public bool SkipWrongRows { get; set; } = false; public ColumnedFileProperty(Guid id) { diff --git a/StructureHelperCommon/Models/Forces/ForceCombinationFromFile.cs b/StructureHelperCommon/Models/Forces/ForceCombinationFromFile.cs index 3beac30..da24bf4 100644 --- a/StructureHelperCommon/Models/Forces/ForceCombinationFromFile.cs +++ b/StructureHelperCommon/Models/Forces/ForceCombinationFromFile.cs @@ -35,6 +35,7 @@ namespace StructureHelperCommon.Models.Forces public IPoint2D ForcePoint { get; set; } = new Point2D(); public IFactoredCombinationProperty CombinationProperty { get; set; } = new FactoredCombinationProperty(Guid.NewGuid()); + public bool SkipWrongRows { get; set; } = false; public object Clone() { @@ -46,7 +47,11 @@ namespace StructureHelperCommon.Models.Forces public List GetCombinations() { - getTupleFromFileLogic ??= new GetTuplesFromFileLogic() { TraceLogger = new ShiftTraceLogger()}; + getTupleFromFileLogic = new GetTuplesFromFileLogic() + { + TraceLogger = new ShiftTraceLogger(), + SkipWrongRows = SkipWrongRows, + }; factoredCombination = new ForceFactoredList(); factoredCombination.ForceTuples.Clear(); propertyUpdateStrategy ??= new FactoredCombinationPropertyUpdateStrategy(); diff --git a/StructureHelperCommon/Models/Forces/IForceCombinationFromFile.cs b/StructureHelperCommon/Models/Forces/IForceCombinationFromFile.cs index db61825..9a3a4b6 100644 --- a/StructureHelperCommon/Models/Forces/IForceCombinationFromFile.cs +++ b/StructureHelperCommon/Models/Forces/IForceCombinationFromFile.cs @@ -15,5 +15,6 @@ namespace StructureHelperCommon.Models.Forces /// List of file properties for import combination /// List ForceFiles { get; set; } + bool SkipWrongRows { get; set; } } } diff --git a/StructureHelperCommon/Models/Forces/Logics/ForceCombinationFromFileUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/ForceCombinationFromFileUpdateStrategy.cs index e265699..5707d83 100644 --- a/StructureHelperCommon/Models/Forces/Logics/ForceCombinationFromFileUpdateStrategy.cs +++ b/StructureHelperCommon/Models/Forces/Logics/ForceCombinationFromFileUpdateStrategy.cs @@ -35,6 +35,7 @@ namespace StructureHelperCommon.Models.Forces if (ReferenceEquals(targetObject, sourceObject)) { return; } InitializeLogics(); baseUpdateStrategy.Update(targetObject, sourceObject); + targetObject.SkipWrongRows = sourceObject.SkipWrongRows; CheckObject.IsNull(targetObject.CombinationProperty, "Target object combination property"); CheckObject.IsNull(sourceObject.CombinationProperty, "Source object combination property"); combinationPropertyUpdateStrategy.Update(targetObject.CombinationProperty, sourceObject.CombinationProperty); diff --git a/StructureHelperCommon/Models/Forces/Logics/GetTupleByExcelReaderLogic.cs b/StructureHelperCommon/Models/Forces/Logics/GetTupleByExcelReaderLogic.cs index 2c556b5..86e15a4 100644 --- a/StructureHelperCommon/Models/Forces/Logics/GetTupleByExcelReaderLogic.cs +++ b/StructureHelperCommon/Models/Forces/Logics/GetTupleByExcelReaderLogic.cs @@ -24,6 +24,7 @@ namespace StructureHelperCommon.Models.Forces public IShiftTraceLogger? TraceLogger { get; set; } public IColumnedFileProperty ForceFileProperty { get; set; } + public bool SkipWrongRows { get; internal set; } public IForceTuple GetForceTuple(IExcelDataReader? reader) { @@ -38,10 +39,24 @@ namespace StructureHelperCommon.Models.Forces throw new StructureHelperException(ErrorStrings.NullReference + $": reader value for column {item.Name} in file {ForceFileProperty.FilePath}"); } var readerValue = reader.GetValue(item.Index); + if (readerValue is null) + { + if (SkipWrongRows == true) + { + continue; + } + else + { + throw new StructureHelperException(ErrorStrings.NullReference + $": wrong row in file {ForceFileProperty.FilePath}, total row number n = {reader.RowCount}"); + } + } var strValue = readerValue.ToString(); double factor = ForceFileProperty.GlobalFactor * item.Factor * 1000d; var doubleValue = Convert.ToDouble(strValue) * factor; - fillArrayLogic ??= new FillTupleArrayByColumnNameLogic() { TraceLogger = TraceLogger }; + fillArrayLogic ??= new FillTupleArrayByColumnNameLogic() + { + TraceLogger = TraceLogger + }; fillArrayLogic.ProceeForceTupleArray(nDouble, doubleValue, item.Name, ForceFileProperty.FilePath); } TraceLogger?.AddMessage($"String values: Nz = {nDouble[0]}, Mx = {nDouble[1]}, My = {nDouble[2]} were gained", TraceLogStatuses.Debug); diff --git a/StructureHelperCommon/Models/Forces/Logics/GetTuplesFromFileLogic.cs b/StructureHelperCommon/Models/Forces/Logics/GetTuplesFromFileLogic.cs index e89b8b4..9a65496 100644 --- a/StructureHelperCommon/Models/Forces/Logics/GetTuplesFromFileLogic.cs +++ b/StructureHelperCommon/Models/Forces/Logics/GetTuplesFromFileLogic.cs @@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Interfaces; using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; @@ -35,6 +36,7 @@ namespace StructureHelperCommon.Models.Forces public IColumnedFileProperty ForceFileProperty { get; set; } public IShiftTraceLogger? TraceLogger { get; set; } + public bool SkipWrongRows { get; set; } = false; public List GetTuples() { @@ -56,7 +58,7 @@ namespace StructureHelperCommon.Models.Forces // Create an Excel reader using (var reader = ExcelReaderFactory.CreateReader(stream)) { - // Skip the first two header rows if necessary (adjust based on structure) + // Skip the first header rows if necessary (adjust based on structure) for (int i = 0; i < skipRows; i++) { reader.Read(); // Skip row @@ -65,7 +67,8 @@ namespace StructureHelperCommon.Models.Forces excelReaderLogic ??= new GetTupleByExcelReaderLogic() { ForceFileProperty = ForceFileProperty, - TraceLogger = TraceLogger + TraceLogger = TraceLogger, + SkipWrongRows = SkipWrongRows }; // Loop through the rows @@ -74,11 +77,13 @@ namespace StructureHelperCommon.Models.Forces try { IForceTuple newTuple = excelReaderLogic.GetForceTuple(reader); - result.Add(newTuple); + if (! result.Any(x => x.Mx == newTuple.Mx && x.My == newTuple.My && x.Nz == newTuple.Nz)) + { + result.Add(newTuple); + } } catch (Exception ex) { - //to do implement case when file has a data in the row, but thus date is not correct string errorString = ErrorStrings.DataIsInCorrect + $": incorrect data in file {ForceFileProperty.FilePath}, " + ex.Message; TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); throw new StructureHelperException(errorString); diff --git a/StructureHelperCommon/Models/Forces/Logics/IGetTuplesFromFileLogic.cs b/StructureHelperCommon/Models/Forces/Logics/IGetTuplesFromFileLogic.cs index 3b5d60e..85b3717 100644 --- a/StructureHelperCommon/Models/Forces/Logics/IGetTuplesFromFileLogic.cs +++ b/StructureHelperCommon/Models/Forces/Logics/IGetTuplesFromFileLogic.cs @@ -5,6 +5,7 @@ namespace StructureHelperCommon.Models.Forces { public interface IGetTuplesFromFileLogic : ILogic { + bool SkipWrongRows { get; set; } IColumnedFileProperty ForceFileProperty { get; set; } List GetTuples(); diff --git a/StructureHelperLogics/MaterialBuilders/Decorators/RestrictStrainDecorator.cs b/StructureHelperLogics/MaterialBuilders/Decorators/RestrictStrainDecorator.cs index b225503..0c0ac1f 100644 --- a/StructureHelperLogics/MaterialBuilders/Decorators/RestrictStrainDecorator.cs +++ b/StructureHelperLogics/MaterialBuilders/Decorators/RestrictStrainDecorator.cs @@ -12,6 +12,9 @@ namespace StructureHelperLogics.MaterialBuilders internal class RestrictStrainDecorator : IMaterialBuilder { IMaterialBuilder builder; + private double maxTensileStrain; + private double maxCompressionStrain; + public IMaterialOption MaterialOption { get; set; } public RestrictStrainDecorator(IMaterialBuilder builder) @@ -25,11 +28,8 @@ namespace StructureHelperLogics.MaterialBuilders var option = (RestrictStrainOption)MaterialOption; var material = new Material(); material.InitModulus = builder.GetMaterial().InitModulus; - material.DiagramParameters = new List() - { - option.MaxTensileStrain, - option.MaxCompessionStrain - }; + maxTensileStrain = option.MaxTensileStrain; + maxCompressionStrain = option.MaxCompessionStrain; material.Diagram = GetStressDiagram; return material; } @@ -39,10 +39,9 @@ namespace StructureHelperLogics.MaterialBuilders CheckObject.CompareTypes(typeof(RestrictStrainOption), MaterialOption.GetType()); } - private double GetStressDiagram(IEnumerable parameters, double strain) + private double GetStressDiagram(double strain) { - var maxTensileStrain = parameters.ToList()[0]; - var maxCompressionStrain = parameters.ToList()[1]; + if (strain > maxTensileStrain || strain < maxCompressionStrain) { return 0d; @@ -50,7 +49,7 @@ namespace StructureHelperLogics.MaterialBuilders else { var material = builder.GetMaterial(); - return material.Diagram.Invoke(parameters, strain); + return material.Diagram.Invoke(strain); } } } diff --git a/StructureHelperLogics/Models/Materials/Logics/ElasticMaterialLogic.cs b/StructureHelperLogics/Models/Materials/Logics/ElasticMaterialLogic.cs index 15b8448..b8d3368 100644 --- a/StructureHelperLogics/Models/Materials/Logics/ElasticMaterialLogic.cs +++ b/StructureHelperLogics/Models/Materials/Logics/ElasticMaterialLogic.cs @@ -7,12 +7,15 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace StructureHelperLogics.Models.Materials { internal class ElasticMaterialLogic : IElasticMaterialLogic { - private List parameters; + private double modulusOfElasticity; + private double compressiveStrength; + private double tensileStrength; public IMaterial GetLoaderMaterial(IElasticMaterial elasticMaterial, LimitStates limitState, CalcTerms calcTerm, double factor = 1d) { @@ -20,23 +23,16 @@ namespace StructureHelperLogics.Models.Materials material.InitModulus = elasticMaterial.Modulus; IMaterialFactorLogic factorLogic = new MaterialFactorLogic(elasticMaterial.SafetyFactors); var factors = factorLogic.GetTotalFactor(limitState, calcTerm); - parameters = new List() - { - elasticMaterial.Modulus, - elasticMaterial.CompressiveStrength * factors.Compressive * factor, - elasticMaterial.TensileStrength * factors.Tensile * factor - }; - material.DiagramParameters = parameters; - material.Diagram = GetStressByStrain; - return material; + modulusOfElasticity = elasticMaterial.Modulus; + compressiveStrength = (-1d) * elasticMaterial.CompressiveStrength * factors.Compressive * factor; + tensileStrength = elasticMaterial.TensileStrength * factors.Tensile * factor; + material.Diagram = GetStressByStrain; + return material; } - private double GetStressByStrain(IEnumerable parameters1, double strain) + private double GetStressByStrain(double strain) { - double modulus = parameters.First(); - double stress = modulus * strain; - double compressiveStrength = (-1d) * parameters.ElementAt(1); - double tensileStrength = parameters.ElementAt(2); + double stress = modulusOfElasticity * strain; if (stress > tensileStrength || stress < compressiveStrength) { return 0d; } else { return stress; } } diff --git a/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs b/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs index 77bda68..9d092a6 100644 --- a/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs +++ b/StructureHelperLogics/Services/NdmPrimitives/MeshElasticLogic.cs @@ -37,9 +37,9 @@ namespace StructureHelperLogics.Services.NdmPrimitives { var material = ndm.Material; var materialFunc = material.Diagram; - var newMaterialFunc = (IEnumerable parameters, double strain) => strain * material.InitModulus; + var newMaterialFunc = (double strain) => strain * material.InitModulus; var existingPrestrain = ndm.PrestrainLogic.GetAll().Sum(x => x.PrestrainValue); - var newPrestrain = materialFunc(null, existingPrestrain) / material.InitModulus; + var newPrestrain = materialFunc(existingPrestrain) / material.InitModulus; ndm.Material.Diagram = newMaterialFunc; ndm.PrestrainLogic.DeleteAll(); ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, newPrestrain);