Crack Calculator was added
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.MaterialBuilders
|
||||
{
|
||||
internal interface IDecoratorOption : IMaterialOption
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.MaterialBuilders.Decorators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.MaterialBuilders
|
||||
{
|
||||
internal class RestrictStrainDecorator : IMaterialBuilder
|
||||
{
|
||||
IMaterialBuilder builder;
|
||||
public IMaterialOption MaterialOption { get; set; }
|
||||
|
||||
public RestrictStrainDecorator(IMaterialBuilder builder)
|
||||
{
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
public IMaterial GetMaterial()
|
||||
{
|
||||
CheckOptions();
|
||||
var option = (RestrictStrainOption)MaterialOption;
|
||||
var material = new Material();
|
||||
material.InitModulus = builder.GetMaterial().InitModulus;
|
||||
material.DiagramParameters = new List<double>()
|
||||
{
|
||||
option.MaxTensileStrain,
|
||||
option.MaxCompessionStrain
|
||||
};
|
||||
material.Diagram = GetStressDiagram;
|
||||
return material;
|
||||
}
|
||||
|
||||
private void CheckOptions()
|
||||
{
|
||||
CheckObject.CompareTypes(typeof(RestrictStrainOption), MaterialOption.GetType());
|
||||
}
|
||||
|
||||
private double GetStressDiagram(IEnumerable<double> parameters, double strain)
|
||||
{
|
||||
var maxTensileStrain = parameters.ToList()[0];
|
||||
var maxCompressionStrain = parameters.ToList()[1];
|
||||
if (strain > maxTensileStrain || strain < maxCompressionStrain)
|
||||
{
|
||||
return 0d;
|
||||
}
|
||||
else
|
||||
{
|
||||
var material = builder.GetMaterial();
|
||||
return material.Diagram.Invoke(parameters, strain);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.MaterialBuilders.Decorators
|
||||
{
|
||||
internal class RestrictStrainOption : IDecoratorOption
|
||||
{
|
||||
private double maxTensileStrain;
|
||||
private double maxCompessionStrain;
|
||||
|
||||
public double MaxTensileStrain
|
||||
{
|
||||
get => maxTensileStrain;
|
||||
set
|
||||
{
|
||||
if (value < 0d)
|
||||
{
|
||||
//to do exception
|
||||
}
|
||||
maxTensileStrain = value;
|
||||
}
|
||||
}
|
||||
public double MaxCompessionStrain { get => maxCompessionStrain; set => maxCompessionStrain = value; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user