Добавил тест для прямоугольника
This commit is contained in:
@@ -8,8 +8,8 @@ namespace StructureHelperLogics.Data.Shapes
|
||||
public class Center : ICenter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public double CenterX { get; set; }
|
||||
public double X { get; set; }
|
||||
/// <inheritdoc />
|
||||
public double CenterY { get; set; }
|
||||
public double Y { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace StructureHelperLogics.Data.Shapes
|
||||
/// Coordinate of center of rectangle by local axis X, m
|
||||
/// Координата центра вдоль локальной оси X, м
|
||||
/// </summary>
|
||||
double CenterX { get;}
|
||||
double X { get;}
|
||||
/// <summary>
|
||||
/// Coordinate of center of rectangle by local axis Y, m
|
||||
/// Координата центра вдоль локальной оси Y, м
|
||||
/// </summary>
|
||||
double CenterY { get;}
|
||||
double Y { get;}
|
||||
}
|
||||
}
|
||||
|
||||
12
StructureHelperLogics/Data/Shapes/ICenterShape.cs
Normal file
12
StructureHelperLogics/Data/Shapes/ICenterShape.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Data.Shapes
|
||||
{
|
||||
public interface ICenterShape
|
||||
{
|
||||
ICenter Center {get;}
|
||||
IShape Shape { get;}
|
||||
}
|
||||
}
|
||||
11
StructureHelperLogics/Data/Shapes/ICircle.cs
Normal file
11
StructureHelperLogics/Data/Shapes/ICircle.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Data.Shapes
|
||||
{
|
||||
public interface ICircle : IShape
|
||||
{
|
||||
double Diameter { get; set; }
|
||||
}
|
||||
}
|
||||
11
StructureHelperLogics/Data/Shapes/IPoint.cs
Normal file
11
StructureHelperLogics/Data/Shapes/IPoint.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Data.Shapes
|
||||
{
|
||||
public interface IPoint : IShape
|
||||
{
|
||||
double Area { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Data.Shapes
|
||||
{
|
||||
public interface IRectangle
|
||||
public interface IRectangle : IShape
|
||||
{
|
||||
/// <summary>
|
||||
/// Width of rectangle, m
|
||||
|
||||
10
StructureHelperLogics/Data/Shapes/IShape.cs
Normal file
10
StructureHelperLogics/Data/Shapes/IShape.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Data.Shapes
|
||||
{
|
||||
public interface IShape
|
||||
{
|
||||
}
|
||||
}
|
||||
11
StructureHelperLogics/Data/Shapes/Point.cs
Normal file
11
StructureHelperLogics/Data/Shapes/Point.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Data.Shapes
|
||||
{
|
||||
public class Point : IPoint
|
||||
{
|
||||
public double Area { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Infrastructures.CommonEnums
|
||||
{
|
||||
public enum CalcTerms
|
||||
{
|
||||
ShortTerm,
|
||||
LongTerm,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.Infrastructures.CommonEnums
|
||||
{
|
||||
public enum LimitStates
|
||||
{
|
||||
Collapse = 1,
|
||||
ServiceAbility = 2,
|
||||
Special = 3,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Entities
|
||||
{
|
||||
public interface INdmPrimitive
|
||||
{
|
||||
ICenter Center { get; set; }
|
||||
IShape Shape { get; set; }
|
||||
IPrimitiveMaterial PrimitiveMaterial {get;set;}
|
||||
double NdmMaxSize { get; set; }
|
||||
int NdmMinDivision { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Entities
|
||||
{
|
||||
public class NdmPrimitive : INdmPrimitive
|
||||
{
|
||||
public ICenter Center { get; set; }
|
||||
public IShape Shape { get; set; }
|
||||
public IPrimitiveMaterial PrimitiveMaterial { get; set; }
|
||||
public double NdmMaxSize { get; set; }
|
||||
public int NdmMinDivision { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Materials
|
||||
{
|
||||
public interface IPrimitiveMaterial
|
||||
{
|
||||
string Id { get;}
|
||||
MaterialTypes MaterialType { get; }
|
||||
string ClassName { get; }
|
||||
double Strength { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Materials
|
||||
{
|
||||
public enum MaterialTypes
|
||||
{
|
||||
Concrete,
|
||||
Reinforcement,
|
||||
//Steel,
|
||||
//CarbonFiber,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Materials
|
||||
{
|
||||
public class PrimitiveMaterial : IPrimitiveMaterial
|
||||
{
|
||||
public string Id { get; }
|
||||
public MaterialTypes MaterialType { get; set; }
|
||||
public string ClassName { get; set; }
|
||||
public double Strength { get; set; }
|
||||
|
||||
public PrimitiveMaterial()
|
||||
{
|
||||
Id = Convert.ToString(Guid.NewGuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using StructureHelperLogics.Infrastructures.CommonEnums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public interface ITriangulationOptions
|
||||
{
|
||||
LimitStates LimiteState { get; }
|
||||
CalcTerms CalcTerm { get; }
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
LoaderCalculator.Triangulations.RectangleTriangulationLogicOptions logicOptions = new LoaderCalculator.Triangulations.RectangleTriangulationLogicOptions(width, height, ndmMaxSize, ndmMinDivision);
|
||||
var logic = LoaderCalculator.Triangulations.Triangulation.GetLogicInstance(logicOptions);
|
||||
var ndmCollection = logic.GetNdmCollection(new LoaderCalculator.Data.Planes.RectangularPlane { Material = material });
|
||||
double dX = rectangleOptions.Center.CenterX;
|
||||
double dY = rectangleOptions.Center.CenterY;
|
||||
double dX = rectangleOptions.Center.X;
|
||||
double dY = rectangleOptions.Center.Y;
|
||||
NdmTransform.Move(ndmCollection, dX, dY);
|
||||
double angle = rectangleOptions.Rectangle.Angle;
|
||||
NdmTransform.Rotate(ndmCollection, angle);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@@ -24,5 +25,14 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
NdmMaxSize = ndmMaxSize;
|
||||
NdmMinDivision = ndmMinDivision;
|
||||
}
|
||||
|
||||
public RectangleTriangulationOptions(INdmPrimitive primitive)
|
||||
{
|
||||
if (! (primitive.Shape is IRectangle)) { throw new Exception("Shape type is not valid"); }
|
||||
Center = primitive.Center;
|
||||
Rectangle = primitive.Shape as IRectangle;
|
||||
NdmMaxSize = primitive.NdmMaxSize;
|
||||
NdmMinDivision = primitive.NdmMinDivision;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using LoaderCalculator.Data.Materials.MaterialBuilders;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Entities;
|
||||
using StructureHelperLogics.NdmCalculations.Materials;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public static class Triangulation
|
||||
{
|
||||
public static IEnumerable<INdm> GetNdms(IEnumerable<INdmPrimitive> ndmPrimitives, ITriangulationOptions options)
|
||||
{
|
||||
List<INdm> ndms = new List<INdm>();
|
||||
Dictionary<string, IPrimitiveMaterial> primitiveMaterials = GetPrimitiveMaterials(ndmPrimitives);
|
||||
Dictionary<string, IMaterial> materials = GetMaterials(primitiveMaterials, options);
|
||||
foreach (var ndmPrimitive in ndmPrimitives)
|
||||
{
|
||||
IPrimitiveMaterial primitiveMaterial = ndmPrimitive.PrimitiveMaterial;
|
||||
IMaterial material;
|
||||
if (materials.TryGetValue(primitiveMaterial.Id, out material) == false) { throw new Exception("Material dictionary is not valid"); }
|
||||
IEnumerable<INdm> localNdms = GetNdmsByPrimitive(ndmPrimitive, material);
|
||||
ndms.AddRange(localNdms);
|
||||
}
|
||||
return ndms;
|
||||
}
|
||||
|
||||
private static Dictionary<string, IPrimitiveMaterial> GetPrimitiveMaterials(IEnumerable<INdmPrimitive> ndmPrimitives)
|
||||
{
|
||||
Dictionary<string, IPrimitiveMaterial> primitiveMaterials = new Dictionary<string, IPrimitiveMaterial>();
|
||||
foreach (var ndmPrimitive in ndmPrimitives)
|
||||
{
|
||||
IPrimitiveMaterial material = ndmPrimitive.PrimitiveMaterial;
|
||||
if (!primitiveMaterials.ContainsKey(material.Id)) { primitiveMaterials.Add(material.Id, material); }
|
||||
}
|
||||
return primitiveMaterials;
|
||||
}
|
||||
|
||||
private static Dictionary<string, IMaterial> GetMaterials(Dictionary<string, IPrimitiveMaterial> PrimitiveMaterials, ITriangulationOptions options)
|
||||
{
|
||||
Dictionary<string, IMaterial> materials = new Dictionary<string, IMaterial>();
|
||||
IEnumerable<string> keyCollection = PrimitiveMaterials.Keys;
|
||||
IMaterial material;
|
||||
foreach (string id in keyCollection)
|
||||
{
|
||||
IPrimitiveMaterial primitiveMaterial;
|
||||
if (PrimitiveMaterials.TryGetValue(id, out primitiveMaterial) == false) { throw new Exception("Material dictionary is not valid"); }
|
||||
material = GetMaterial(primitiveMaterial, options);
|
||||
materials.Add(id, material);
|
||||
}
|
||||
return materials;
|
||||
}
|
||||
|
||||
private static IEnumerable<INdm> GetNdmsByPrimitive(INdmPrimitive primitive, IMaterial material)
|
||||
{
|
||||
List<INdm> ndms = new List<INdm>();
|
||||
ITriangulationLogicOptions options;
|
||||
ICenter center = primitive.Center;
|
||||
IShape shape = primitive.Shape;
|
||||
if (shape is IRectangle)
|
||||
{
|
||||
IRectangle rectangle = shape as IRectangle;
|
||||
options = new RectangleTriangulationOptions(primitive);
|
||||
IRectangleTriangulationLogic logic = new RectangleTriangulationLogic(options);
|
||||
ndms.AddRange(logic.GetNdmCollection(material));
|
||||
}
|
||||
else { throw new Exception("Primitive type is not valid"); }
|
||||
return ndms;
|
||||
}
|
||||
|
||||
private static IMaterial GetMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
|
||||
{
|
||||
IMaterial material;
|
||||
if (primitiveMaterial.MaterialType == MaterialTypes.Concrete) { material = GetConcreteMaterial(primitiveMaterial, options); }
|
||||
else if (primitiveMaterial.MaterialType == MaterialTypes.Reinforcement) { material = GetReinforcementMaterial(primitiveMaterial, options); }
|
||||
else { throw new Exception("Material type is invalid"); }
|
||||
return material;
|
||||
}
|
||||
|
||||
private static IMaterial GetConcreteMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
|
||||
{
|
||||
IMaterialOptions materialOptions = new ConcreteOptions();
|
||||
SetMaterialOptions(materialOptions, primitiveMaterial, options);
|
||||
IMaterialBuilder builder = new ConcreteBuilder(materialOptions);
|
||||
IBuilderDirector director = new BuilderDirector(builder);
|
||||
return director.BuildMaterial();
|
||||
}
|
||||
|
||||
private static IMaterial GetReinforcementMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
|
||||
{
|
||||
IMaterialOptions materialOptions = new ReinforcementOptions();
|
||||
SetMaterialOptions(materialOptions, primitiveMaterial, options);
|
||||
IMaterialBuilder builder = new ReinforcementBuilder(materialOptions);
|
||||
IBuilderDirector director = new BuilderDirector(builder);
|
||||
return director.BuildMaterial();
|
||||
}
|
||||
|
||||
private static void SetMaterialOptions(IMaterialOptions materialOptions, IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
|
||||
{
|
||||
materialOptions.Strength = primitiveMaterial.Strength;
|
||||
materialOptions.CodesType = CodesType.EC2_1990;
|
||||
if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.Collapse) { materialOptions.LimitState = LimitStates.Collapse; }
|
||||
else if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.ServiceAbility) { materialOptions.LimitState = LimitStates.ServiceAbility; }
|
||||
else if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.Special) { materialOptions.LimitState = LimitStates.Special; }
|
||||
else { throw new Exception("LimitStateType is not valid"); }
|
||||
if (options.CalcTerm == Infrastructures.CommonEnums.CalcTerms.ShortTerm) { materialOptions.IsShortTerm = true; }
|
||||
else if (options.CalcTerm == Infrastructures.CommonEnums.CalcTerms.LongTerm) { materialOptions.IsShortTerm = false; }
|
||||
else { throw new Exception("Calculation term is not valid"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using StructureHelperLogics.Infrastructures.CommonEnums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public class TriangulationOptions : ITriangulationOptions
|
||||
{
|
||||
public LimitStates LimiteState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
|
||||
{
|
||||
class RCSectionTest
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using LoaderCalculator;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.SourceData;
|
||||
using LoaderCalculator.Tests.Infrastructures.Logics;
|
||||
using NUnit.Framework;
|
||||
using StructureHelperLogics.Data.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Entities;
|
||||
using StructureHelperLogics.NdmCalculations.Materials;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace StructureHelperTests.FunctionalTests.Ndms.SteelSections
|
||||
{
|
||||
public class ReinforcementTest
|
||||
{
|
||||
[TestCase(0.3, 0.6, 4e8, 0, 0, 1800000, 0d, 0d, 5e-5d)]
|
||||
[TestCase(0.3, 0.6, 4e8, 0, 0, -1800000, 0d, 0d, -5e-5d)]
|
||||
[TestCase(0.3, 0.6, 4e8, 7000000, 0, 0, 0.0065882684745345067d, 0d, 0d)]
|
||||
[TestCase(0.3, 0.6, 6e8, 10000000, 0, 0, 0.010485801788961743d, 0d, -0.00011114996218404612d)]
|
||||
public void Run_ShouldPass(double width, double height, double strength, double mx, double my, double nz, double expectedKx, double expectedKy, double expectedEpsilonZ)
|
||||
{
|
||||
//Arrange
|
||||
ICenter center = new Center() { X = 0, Y = 0 };
|
||||
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = 0 };
|
||||
IPrimitiveMaterial material = new PrimitiveMaterial() { MaterialType = MaterialTypes.Reinforcement, ClassName = "S400", Strength = strength };
|
||||
ITriangulationOptions options = new TriangulationOptions() { LimiteState = StructureHelperLogics.Infrastructures.CommonEnums.LimitStates.Collapse, CalcTerm = StructureHelperLogics.Infrastructures.CommonEnums.CalcTerms.ShortTerm };
|
||||
INdmPrimitive primitive = new NdmPrimitive() { Center = center, Shape = rectangle, PrimitiveMaterial = material, NdmMaxSize = 1, NdmMinDivision = 100 };
|
||||
List<INdmPrimitive> primitives = new List<INdmPrimitive>();
|
||||
primitives.Add(primitive);
|
||||
var ndmList = Triangulation.GetNdms(primitives, options);
|
||||
var loaderData = new LoaderOptions
|
||||
{
|
||||
Preconditions = new Preconditions
|
||||
{
|
||||
ConditionRate = 0.01,
|
||||
MaxIterationCount = 100,
|
||||
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
|
||||
},
|
||||
NdmCollection = ndmList
|
||||
};
|
||||
var calculator = new Calculator();
|
||||
//Act
|
||||
calculator.Run(loaderData, new CancellationToken());
|
||||
var results = calculator.Result;
|
||||
//Assert
|
||||
Assert.NotNull(results);
|
||||
var strainMatrix = results.StrainMatrix;
|
||||
Assert.NotNull(strainMatrix);
|
||||
Assert.AreEqual(expectedKx, strainMatrix.Kx, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKx));
|
||||
Assert.AreEqual(expectedKy, strainMatrix.Ky, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKy));
|
||||
Assert.AreEqual(expectedEpsilonZ, strainMatrix.EpsZ, ExpectedProcessor.GetAccuracyForExpectedValue(expectedEpsilonZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,8 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FunctionalTests\Ndms\RCSections\RCSectionTest.cs" />
|
||||
<Compile Include="FunctionalTests\Ndms\SteelSections\ReinforcementTest.cs" />
|
||||
<Compile Include="Infrastructures\Logics\ExpectedProcessor.cs" />
|
||||
<Compile Include="LibrariesTests\Ndms\RCSections\RCSectionTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -69,9 +71,7 @@
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="FunctionalTests\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj">
|
||||
<Project>{330bef5b-15be-4d2c-a750-b1ae50fb2be3}</Project>
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
{
|
||||
//Arrange
|
||||
IMaterial material = new Material();
|
||||
ICenter center = new Center() { CenterX = centerX, CenterY = centerY };
|
||||
ICenter center = new Center() { X = centerX, Y = centerY };
|
||||
IRectangle rectangle = new Rectangle() { Width = width, Height = height, Angle = angle };
|
||||
IRectangleTriangulationOptions options = new RectangleTriangulationOptions(center, rectangle, ndmMaxSize, ndmMinDivision);
|
||||
IRectangleTriangulationLogic logic = new StructureHelperLogics.NdmCalculations.Triangulations.RectangleTriangulationLogic(options);
|
||||
|
||||
Reference in New Issue
Block a user