Add FunctionMaterialLogic and FunctionMaterialUpdateStrategy, run function material "Show diagram".

This commit is contained in:
Иван Ивашкин
2025-02-12 20:44:12 +05:00
parent 4ec3ef25fb
commit e0acca2e36
6 changed files with 88 additions and 8 deletions

View File

@@ -19,12 +19,12 @@ namespace StructureHelperCommon.Models.Materials
public void SetMaterialOptions(LCMB.IMaterialOptions materialOptions) public void SetMaterialOptions(LCMB.IMaterialOptions materialOptions)
{ {
materialOptions.InitModulus = options.MaterialEntity.InitModulus; /*materialOptions.InitModulus = options.MaterialEntity.InitModulus;
materialOptions.Strength = options.MaterialEntity.MainStrength; materialOptions.Strength = options.MaterialEntity.MainStrength;
ProcessCodeType(materialOptions); ProcessCodeType(materialOptions);
ProcessLimitState(materialOptions); ProcessLimitState(materialOptions);
ProcessCalcTerm(materialOptions); ProcessCalcTerm(materialOptions);
ProcessExternalFactors(materialOptions); ProcessExternalFactors(materialOptions);*/
} }
private void ProcessExternalFactors(IMaterialOptions materialOptions) private void ProcessExternalFactors(IMaterialOptions materialOptions)

View File

@@ -108,7 +108,7 @@ namespace StructureHelperLogics.Models.Materials
private static IHeadMaterial GetFunction() private static IHeadMaterial GetFunction()
{ {
var material = new HeadMaterial(); var material = new HeadMaterial();
material.HelperMaterial = new material.HelperMaterial = new ReinforcementLibMaterial();
return material; return material;
} }
} }

View File

@@ -1,6 +1,7 @@
using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials.Logics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -9,9 +10,9 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Materials 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 Modulus { get; set; }
public double CompressiveStrength { get; set; } public double CompressiveStrength { get; set; }
public double TensileStrength { get; set; } public double TensileStrength { get; set; }
@@ -29,14 +30,14 @@ namespace StructureHelperLogics.Models.Materials
} }
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{ {
var material = elasticMaterialLogic.GetLoaderMaterial(this, limitState, calcTerm); var material = functionMaterialLogic.GetLoaderMaterial(this, limitState, calcTerm);
return material; return material;
} }
public object Clone() public object Clone()
{ {
var newItem = new ElasticMaterial(); var newItem = new FunctionMaterial();
var updateStrategy = new ElasticUpdateStrategy(); var updateStrategy = new FunctionUpdateStrategy();
updateStrategy.Update(newItem, this); updateStrategy.Update(newItem, this);
return newItem; return newItem;
} }

View File

@@ -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<double> 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<double>()
{
functionMaterial.Modulus,
functionMaterial.CompressiveStrength * factors.Compressive * factor,
functionMaterial.TensileStrength * factors.Tensile * factor
};
material.DiagramParameters = parameters;
material.Diagram = GetStressByStrain;*/
return material;
}
private double GetStressByStrain(IEnumerable<double> 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; }
}
}
}

View File

@@ -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<IFunctionMaterial>
{
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
}
}
}

View File

@@ -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);
}
}