From e0acca2e3609c3af2b27d9f6d6b5fe288718f313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD=20=D0=98=D0=B2=D0=B0=D1=88=D0=BA?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Wed, 12 Feb 2025 20:44:12 +0500 Subject: [PATCH] Add FunctionMaterialLogic and FunctionMaterialUpdateStrategy, run function material "Show diagram". --- .../Materials/MaterialCommonOptionLogic.cs | 4 +- .../Factories/HeadMaterialFactory.cs | 2 +- .../Models/Materials/FunctionMaterial.cs | 11 ++--- .../Materials/Logics/FunctionMaterialLogic.cs | 41 +++++++++++++++++++ .../Logics/FunctionUpdateStrategy.cs | 23 +++++++++++ .../Logics/IFunctionMaterialLogic.cs | 15 +++++++ 6 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 StructureHelperLogics/Models/Materials/Logics/FunctionMaterialLogic.cs create mode 100644 StructureHelperLogics/Models/Materials/Logics/FunctionUpdateStrategy.cs create mode 100644 StructureHelperLogics/Models/Materials/Logics/IFunctionMaterialLogic.cs diff --git a/StructureHelperCommon/Models/Materials/MaterialCommonOptionLogic.cs b/StructureHelperCommon/Models/Materials/MaterialCommonOptionLogic.cs index f5b1f7d..6ec9070 100644 --- a/StructureHelperCommon/Models/Materials/MaterialCommonOptionLogic.cs +++ b/StructureHelperCommon/Models/Materials/MaterialCommonOptionLogic.cs @@ -19,12 +19,12 @@ namespace StructureHelperCommon.Models.Materials public void SetMaterialOptions(LCMB.IMaterialOptions materialOptions) { - materialOptions.InitModulus = options.MaterialEntity.InitModulus; + /*materialOptions.InitModulus = options.MaterialEntity.InitModulus; materialOptions.Strength = options.MaterialEntity.MainStrength; ProcessCodeType(materialOptions); ProcessLimitState(materialOptions); ProcessCalcTerm(materialOptions); - ProcessExternalFactors(materialOptions); + ProcessExternalFactors(materialOptions);*/ } private void ProcessExternalFactors(IMaterialOptions materialOptions) diff --git a/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs b/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs index 78a289f..0066434 100644 --- a/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs +++ b/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs @@ -108,7 +108,7 @@ namespace StructureHelperLogics.Models.Materials private static IHeadMaterial GetFunction() { var material = new HeadMaterial(); - material.HelperMaterial = new + material.HelperMaterial = new ReinforcementLibMaterial(); return material; } } diff --git a/StructureHelperLogics/Models/Materials/FunctionMaterial.cs b/StructureHelperLogics/Models/Materials/FunctionMaterial.cs index 5270363..1e7f3e7 100644 --- a/StructureHelperLogics/Models/Materials/FunctionMaterial.cs +++ b/StructureHelperLogics/Models/Materials/FunctionMaterial.cs @@ -1,6 +1,7 @@ using LoaderCalculator.Data.Materials; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Models.Materials.Libraries; +using StructureHelperLogics.Models.Materials.Logics; using System; using System.Collections.Generic; using System.Linq; @@ -9,9 +10,9 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.Materials { - public class FunctionMaterial + public class FunctionMaterial : IFunctionMaterial { - private IElasticMaterialLogic elasticMaterialLogic => new ElasticMaterialLogic(); + private IFunctionMaterialLogic functionMaterialLogic => new FunctionMaterialLogic(); public double Modulus { get; set; } public double CompressiveStrength { get; set; } public double TensileStrength { get; set; } @@ -29,14 +30,14 @@ namespace StructureHelperLogics.Models.Materials } public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) { - var material = elasticMaterialLogic.GetLoaderMaterial(this, limitState, calcTerm); + var material = functionMaterialLogic.GetLoaderMaterial(this, limitState, calcTerm); return material; } public object Clone() { - var newItem = new ElasticMaterial(); - var updateStrategy = new ElasticUpdateStrategy(); + var newItem = new FunctionMaterial(); + var updateStrategy = new FunctionUpdateStrategy(); updateStrategy.Update(newItem, this); return newItem; } diff --git a/StructureHelperLogics/Models/Materials/Logics/FunctionMaterialLogic.cs b/StructureHelperLogics/Models/Materials/Logics/FunctionMaterialLogic.cs new file mode 100644 index 0000000..25031bc --- /dev/null +++ b/StructureHelperLogics/Models/Materials/Logics/FunctionMaterialLogic.cs @@ -0,0 +1,41 @@ +using LoaderCalculator.Data.Materials; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Models.Materials.Libraries; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.Materials.Logics +{ + internal class FunctionMaterialLogic : IFunctionMaterialLogic + { + private List parameters; + public IMaterial GetLoaderMaterial(IFunctionMaterial functionMaterial, LimitStates limitState, CalcTerms calcTerm, double factor = 1d) + { + IMaterial material = new Material(); + /*material.InitModulus = functionMaterial.Modulus; + IFactorLogic factorLogic = new FactorLogic(functionMaterial.SafetyFactors); + var factors = factorLogic.GetTotalFactor(limitState, calcTerm); + parameters = new List() + { + functionMaterial.Modulus, + functionMaterial.CompressiveStrength * factors.Compressive * factor, + functionMaterial.TensileStrength * factors.Tensile * factor + }; + material.DiagramParameters = parameters; + material.Diagram = GetStressByStrain;*/ + return material; + } + private double GetStressByStrain(IEnumerable parameters1, double strain) + { + double modulus = parameters.First(); + double stress = modulus * strain; + double compressiveStrength = (-1d) * parameters.ElementAt(1); + double tensileStrength = parameters.ElementAt(2); + if (stress > tensileStrength || stress < compressiveStrength) { return 0d; } + else { return stress; } + } + } +} diff --git a/StructureHelperLogics/Models/Materials/Logics/FunctionUpdateStrategy.cs b/StructureHelperLogics/Models/Materials/Logics/FunctionUpdateStrategy.cs new file mode 100644 index 0000000..4f0ec25 --- /dev/null +++ b/StructureHelperLogics/Models/Materials/Logics/FunctionUpdateStrategy.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 StructureHelperLogics.Models.Materials.Logics +{ + internal class FunctionUpdateStrategy : IUpdateStrategy + { + public void Update(IFunctionMaterial targetObject, IFunctionMaterial sourceObject) + { + CheckObject.CompareTypes(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + + /*targetObject.Modulus = sourceObject.Modulus; + targetObject.CompressiveStrength = sourceObject.CompressiveStrength; + targetObject.TensileStrength = sourceObject.TensileStrength;*/ //from elastic + } + } +} diff --git a/StructureHelperLogics/Models/Materials/Logics/IFunctionMaterialLogic.cs b/StructureHelperLogics/Models/Materials/Logics/IFunctionMaterialLogic.cs new file mode 100644 index 0000000..3d84ad0 --- /dev/null +++ b/StructureHelperLogics/Models/Materials/Logics/IFunctionMaterialLogic.cs @@ -0,0 +1,15 @@ +using LoaderCalculator.Data.Materials; +using StructureHelperCommon.Infrastructures.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.Materials.Logics +{ + internal interface IFunctionMaterialLogic + { + IMaterial GetLoaderMaterial(IFunctionMaterial material, LimitStates limitState, CalcTerms calcTerm, double factor = 1d); + } +}