Material logic was changed

This commit is contained in:
Evgeny Redikultsev
2023-11-19 22:43:21 +05:00
parent ba797e7aaa
commit 68b03bdf01
17 changed files with 326 additions and 96 deletions

View File

@@ -0,0 +1,55 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Materials.Libraries;
using System.Windows.Media.Media3D;
using static System.Windows.Forms.Design.AxImporter;
using LMBuilders = LoaderCalculator.Data.Materials.MaterialBuilders;
namespace StructureHelperLogics.Models.Materials
{
public class ConcreteCurveLogic : IMaterialLogic
{
private ConcreteOptions concreteOptions;
private IMaterialOptionLogic optionLogic;
private ConcreteLogicOptions options;
public string Name { get; set; }
public IMaterialLogicOptions Options
{
get => options;
set
{
if (value is not ConcreteLogicOptions)
{
throw new StructureHelperException($"{ErrorStrings.ExpectedWas(typeof(ConcreteLogicOptions), value)}");
}
options = (ConcreteLogicOptions)value;
}
}
public IMaterial GetLoaderMaterial()
{
GetLoaderOptions();
IBuilderDirector director = GetMaterialDirector();
var material = director.BuildMaterial();
return material;
}
private IBuilderDirector GetMaterialDirector()
{
IMaterialBuilder builder = new ConcreteBuilder(concreteOptions);
IBuilderDirector director = new BuilderDirector(builder);
return director;
}
private void GetLoaderOptions()
{
concreteOptions = new ConcreteOptions();
optionLogic = new ConcreteMaterialOptionLogic(options);
optionLogic.SetMaterialOptions(concreteOptions);
}
}
}

View File

@@ -5,6 +5,7 @@ using LMBuilders = LoaderCalculator.Data.Materials.MaterialBuilders;
using LMLogic = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics;
using LM = LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Exceptions;
namespace StructureHelperLogics.Models.Materials
{
@@ -14,21 +15,32 @@ namespace StructureHelperLogics.Models.Materials
private IMaterialOptionLogic optionLogic;
private IFactorLogic factorLogic => new FactorLogic(SafetyFactors);
private LMLogic.ITrueStrengthLogic strengthLogic;
/// <inheritdoc/>
public ILibMaterialEntity MaterialEntity { get; set; }
/// <inheritdoc/>
public List<IMaterialSafetyFactor> SafetyFactors { get; }
/// <inheritdoc/>
public bool TensionForULS { get ; set; }
/// <inheritdoc/>
public bool TensionForSLS { get; set; }
public double Humidity { get; set; }
/// <summary>
/// Humidity of concrete
/// </summary>
public double RelativeHumidity { get; set; }
/// <inheritdoc/>
public IMaterialLogic MaterialLogic { get; set; }
/// <inheritdoc/>
public List<IMaterialLogic> MaterialLogics { get; }
public ConcreteLibMaterial()
{
MaterialLogic = new ConcreteCurveLogic();
SafetyFactors = new List<IMaterialSafetyFactor>();
lmOptions = new LMBuilders.ConcreteOptions();
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultConcreteSafetyFactors(ProgramSetting.CodeType));
TensionForULS = false;
TensionForSLS = true;
Humidity = 0.55d;
RelativeHumidity = 0.55d;
}
public object Clone()
@@ -39,30 +51,7 @@ namespace StructureHelperLogics.Models.Materials
return newItem;
}
public LM.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
GetOptions(limitState, calcTerm, false);
LMBuilders.IBuilderDirector director = GetMaterial(limitState, calcTerm);
return director.BuildMaterial();
}
private LMBuilders.IBuilderDirector GetMaterial(LimitStates limitState, CalcTerms calcTerm)
{
var strength = factorLogic.GetTotalFactor(limitState, calcTerm);
lmOptions.ExternalFactor.Compressive = strength.Compressive;
lmOptions.ExternalFactor.Tensile = strength.Tensile;
LMBuilders.IMaterialBuilder builder = new LMBuilders.ConcreteBuilder(lmOptions);
LMBuilders.IBuilderDirector director = new LMBuilders.BuilderDirector(builder);
return director;
}
private void GetOptions(LimitStates limitState, CalcTerms calcTerm, bool isSectionCracked)
{
optionLogic = new MaterialCommonOptionLogic(MaterialEntity, limitState, calcTerm);
optionLogic.SetMaterialOptions(lmOptions);
optionLogic = new ConcreteMaterialOptionLogic(this, limitState, isSectionCracked);
optionLogic.SetMaterialOptions(lmOptions);
}
public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm)
{
@@ -83,9 +72,56 @@ namespace StructureHelperLogics.Models.Materials
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
GetOptions(limitState, calcTerm, true);
LMBuilders.IBuilderDirector director = GetMaterial(limitState, calcTerm);
return director.BuildMaterial();
ConcreteLogicOptions options = SetOptions(limitState, calcTerm);
options.WorkInTension = false;
MaterialLogic.Options = options;
var material = MaterialLogic.GetLoaderMaterial();
return material;
}
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
ConcreteLogicOptions options = SetOptions(limitState, calcTerm);
MaterialLogic.Options = options;
var material = MaterialLogic.GetLoaderMaterial();
return material;
}
private ConcreteLogicOptions SetOptions(LimitStates limitState, CalcTerms calcTerm)
{
var options = new ConcreteLogicOptions();
options.SafetyFactors = SafetyFactors;
options.MaterialEntity = MaterialEntity;
options.LimitState = limitState;
options.CalcTerm = calcTerm;
if (limitState == LimitStates.ULS)
{
if (TensionForULS == true)
{
options.WorkInTension = true;
}
else
{
options.WorkInTension = false;
}
}
else if (limitState == LimitStates.SLS)
{
if (TensionForSLS == true)
{
options.WorkInTension = true;
}
else
{
options.WorkInTension = false;
}
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(limitState));
}
options.RelativeHumidity = RelativeHumidity;
return options;
}
}
}

View File

@@ -0,0 +1,21 @@
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
{
public class ConcreteLogicOptions : IMaterialLogicOptions
{
public List<IMaterialSafetyFactor> SafetyFactors { get; set; }
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
public ILibMaterialEntity MaterialEntity { get; set; }
public bool WorkInCompression { get; set; }
public bool WorkInTension { get; set; }
public double RelativeHumidity { get; set; }
}
}

View File

@@ -11,6 +11,6 @@ namespace StructureHelperLogics.Models.Materials
{
bool TensionForULS { get; set; }
bool TensionForSLS { get; set; }
double Humidity { get; set; }
double RelativeHumidity { get; set; }
}
}

View File

@@ -11,6 +11,8 @@ namespace StructureHelperLogics.Models.Materials
{
ILibMaterialEntity MaterialEntity { get; set; }
List<IMaterialSafetyFactor> SafetyFactors { get; }
IMaterialLogic MaterialLogic { get; set; }
List<IMaterialLogic> MaterialLogics { get; }
(double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm);
}
}

View File

@@ -0,0 +1,17 @@
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
{
public interface IMaterialLogic
{
string Name { get; set; }
IMaterialLogicOptions Options { get; set; }
IMaterial GetLoaderMaterial();
}
}

View File

@@ -0,0 +1,20 @@
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
{
public interface IMaterialLogicOptions
{
public List<IMaterialSafetyFactor> SafetyFactors { get; set; }
public ILibMaterialEntity MaterialEntity { get; set; }
LimitStates LimitState { get; set; }
CalcTerms CalcTerm { get; set; }
bool WorkInCompression { get; set; }
bool WorkInTension { get; set; }
}
}

View File

@@ -23,6 +23,9 @@ namespace StructureHelperLogics.Models.Materials
public ILibMaterialEntity MaterialEntity { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; }
public IMaterialLogic MaterialLogic { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public List<IMaterialLogic> MaterialLogics => throw new NotImplementedException();
public LibMaterial(MaterialTypes materialType, CodeTypes codeType, string name, double mainStrength)
{

View File

@@ -16,7 +16,8 @@ namespace StructureHelperLogics.Models.Materials
libUpdateStrategy.Update(targetObject, sourceObject);
targetObject.TensionForULS = sourceObject.TensionForULS;
targetObject.TensionForSLS = sourceObject.TensionForSLS;
targetObject.Humidity = sourceObject.Humidity;
targetObject.RelativeHumidity = sourceObject.RelativeHumidity;
targetObject.MaterialLogic = sourceObject.MaterialLogic;
}
}
}

View File

@@ -7,50 +7,37 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.Design.AxImporter;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Models.Materials.Libraries;
namespace StructureHelperLogics.Models.Materials
{
internal class ConcreteMaterialOptionLogic : IMaterialOptionLogic
{
private IConcreteLibMaterial material;
private LimitStates limitState;
bool IsMaterialCracked;
public ConcreteMaterialOptionLogic(IConcreteLibMaterial material, LimitStates limitState, bool IsMaterialCracked)
private ConcreteLogicOptions options;
private MaterialCommonOptionLogic optionLogic;
private FactorLogic factorLogic;
public ConcreteMaterialOptionLogic(ConcreteLogicOptions options)
{
this.material = material;
this.limitState = limitState;
this.IsMaterialCracked = IsMaterialCracked;
}
public void SetMaterialOptions(LCMB.IMaterialOptions materialOptions)
{
Check(materialOptions);
var concreteOptions = materialOptions as LCMB.ConcreteOptions;
concreteOptions.WorkInTension = false;
if (IsMaterialCracked)
{
concreteOptions.WorkInTension = true;
return;
}
if (limitState == LimitStates.ULS & material.TensionForULS == true)
{
concreteOptions.WorkInTension = true;
}
if (limitState == LimitStates.SLS & material.TensionForSLS == true)
{
concreteOptions.WorkInTension = true;
}
this.options = options;
}
private static void Check(LCMB.IMaterialOptions materialOptions)
public void SetMaterialOptions(IMaterialOptions materialOptions)
{
if (materialOptions is null)
if (materialOptions is not ConcreteOptions)
{
throw new StructureHelperException(ErrorStrings.ParameterIsNull + $": expected {typeof(LCMB.ConcreteOptions)}, but was null");
}
if (materialOptions is not LCMB.ConcreteOptions)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": expected {typeof(LCMB.ConcreteOptions)}, but was {materialOptions.GetType()}");
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(ConcreteOptions), materialOptions.GetType()));
}
var concreteOptions = materialOptions as ConcreteOptions;
optionLogic = new MaterialCommonOptionLogic(options);
optionLogic.SetMaterialOptions(concreteOptions);
factorLogic = new FactorLogic(options.SafetyFactors);
var strength = factorLogic.GetTotalFactor(options.LimitState, options.CalcTerm);
concreteOptions.ExternalFactor.Compressive = strength.Compressive;
concreteOptions.ExternalFactor.Tensile = strength.Tensile;
concreteOptions.WorkInTension = options.WorkInTension;
concreteOptions.RelativeHumidity = options.RelativeHumidity;
}
}
}

View File

@@ -1,46 +1,45 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LCMB = LoaderCalculator.Data.Materials.MaterialBuilders;
namespace StructureHelperLogics.Models.Materials
{
public class MaterialCommonOptionLogic : IMaterialOptionLogic
{
private ILibMaterialEntity materialEntity;
private LimitStates limitState;
private CalcTerms calcTerm;
private IMaterialLogicOptions options;
public MaterialCommonOptionLogic(ILibMaterialEntity materialEntity, LimitStates limitState, CalcTerms calcTerm)
public MaterialCommonOptionLogic(IMaterialLogicOptions options)
{
this.materialEntity = materialEntity;
this.limitState = limitState;
this.calcTerm = calcTerm;
this.options = options;
}
public void SetMaterialOptions(LCMB.IMaterialOptions materialOptions)
{
materialOptions.Strength = materialEntity.MainStrength;
if (materialEntity.CodeType == CodeTypes.EuroCode_2_1990)
materialOptions.Strength = options.MaterialEntity.MainStrength;
if (options.MaterialEntity.CodeType == CodeTypes.EuroCode_2_1990)
{
materialOptions.CodesType = LCMB.CodesType.EC2_1990;
}
else if (materialEntity.CodeType == CodeTypes.SP63_2018)
else if (options.MaterialEntity.CodeType == CodeTypes.SP63_2018)
{
materialOptions.CodesType = LCMB.CodesType.SP63_2018;
}
else { throw new StructureHelperException($"{ErrorStrings.ObjectTypeIsUnknown} : {materialOptions.CodesType}"); }
if (limitState == LimitStates.ULS) { materialOptions.LimitState = LCMB.LimitStates.Collapse; }
else if (limitState == LimitStates.SLS) { materialOptions.LimitState = LCMB.LimitStates.ServiceAbility; }
else if (limitState == LimitStates.Special) { materialOptions.LimitState = LCMB.LimitStates.Special; }
if (options.LimitState == LimitStates.ULS)
{
materialOptions.LimitState = LCMB.LimitStates.Collapse;
}
else if (options.LimitState == LimitStates.SLS)
{
materialOptions.LimitState = LCMB.LimitStates.ServiceAbility;
}
else if (options.LimitState == LimitStates.Special)
{
materialOptions.LimitState = LCMB.LimitStates.Special;
}
else { throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid); }
if (calcTerm == CalcTerms.ShortTerm) { materialOptions.IsShortTerm = true; }
else if (calcTerm == CalcTerms.LongTerm) { materialOptions.IsShortTerm = false; }
if (options.CalcTerm == CalcTerms.ShortTerm) { materialOptions.IsShortTerm = true; }
else if (options.CalcTerm == CalcTerms.LongTerm) { materialOptions.IsShortTerm = false; }
else { throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid); }
}
}

View File

@@ -0,0 +1,58 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.Design.AxImporter;
namespace StructureHelperLogics.Models.Materials
{
public class ReinforcementBiLinearLogic : IMaterialLogic
{
private ReinforcementOptions materialOptions;
private IMaterialOptionLogic optionLogic;
private ReinforcementLogicOptions options;
private IMaterialLogicOptions options1;
public string Name { get; set; }
public IMaterialLogicOptions Options
{
get => options;
set
{
if (value is not ReinforcementLogicOptions)
{
throw new StructureHelperException($"{ErrorStrings.ExpectedWas(typeof(ReinforcementLogicOptions), value)}");
}
options = (ReinforcementLogicOptions)value;
}
}
public IMaterial GetLoaderMaterial()
{
GetLoaderOptions();
IBuilderDirector director = GetMaterialDirector();
var material = director.BuildMaterial();
return material;
}
private IBuilderDirector GetMaterialDirector()
{
IMaterialBuilder builder = new ReinforcementBuilder(materialOptions);
IBuilderDirector director = new BuilderDirector(builder);
return director;
}
private void GetLoaderOptions()
{
materialOptions = new ReinforcementOptions();
optionLogic = new MaterialCommonOptionLogic(options);
optionLogic.SetMaterialOptions(materialOptions);
}
}
}

View File

@@ -20,10 +20,13 @@ namespace StructureHelperLogics.Models.Materials
private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic;
public ILibMaterialEntity MaterialEntity { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; }
public IMaterialLogic MaterialLogic { get; set; }
public List<IMaterialLogic> MaterialLogics { get; }
public ReinforcementLibMaterial()
{
MaterialLogic = new ReinforcementBiLinearLogic();
SafetyFactors = new List<IMaterialSafetyFactor>();
lmOptions = new LMBuilders.ReinforcementOptions();
}
@@ -36,17 +39,24 @@ namespace StructureHelperLogics.Models.Materials
return newItem;
}
public Loadermaterials.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
optionLogic = new MaterialCommonOptionLogic(MaterialEntity, limitState, calcTerm);
optionLogic.SetMaterialOptions(lmOptions);
var factors = factorLogic.GetTotalFactor(limitState, calcTerm);
lmOptions.ExternalFactor.Compressive = factors.Compressive;
lmOptions.ExternalFactor.Tensile = factors.Tensile;
LMBuilders.IMaterialBuilder builder = new LMBuilders.ReinforcementBuilder(lmOptions);
LMBuilders.IBuilderDirector director = new LMBuilders.BuilderDirector(builder);
return director.BuildMaterial();
ReinforcementLogicOptions options = SetOptions(limitState, calcTerm);
MaterialLogic.Options = options;
var material = MaterialLogic.GetLoaderMaterial();
return material;
}
private ReinforcementLogicOptions SetOptions(LimitStates limitState, CalcTerms calcTerm)
{
var options = new ReinforcementLogicOptions();
options.SafetyFactors = SafetyFactors;
options.MaterialEntity = MaterialEntity;
options.LimitState = limitState;
options.CalcTerm = calcTerm;
return options;
}
public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm)
{
strengthLogic = new LoaderMaterialLogics.TrueStrengthReinforcementLogic(MaterialEntity.MainStrength);

View File

@@ -0,0 +1,20 @@
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
{
internal class ReinforcementLogicOptions : IMaterialLogicOptions
{
public List<IMaterialSafetyFactor> SafetyFactors { get; set; }
public ILibMaterialEntity MaterialEntity { get; set; }
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
public bool WorkInCompression { get; set; }
public bool WorkInTension { get; set; }
}
}