Add series to graph

This commit is contained in:
Evgeny Redikultsev
2023-12-23 22:40:42 +05:00
parent a19333f7df
commit 0a6d29bcfc
38 changed files with 762 additions and 233 deletions

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class PredicateEntry
{
public string Name { get; set; }
public PredicateTypes PredicateType { get; set; }
}
}

View File

@@ -1,19 +1,21 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public enum PredicateTypes
{
Strength,
Cracking
}
public class PredicateFactory
{
private ForceTupleCalculator calculator;
private ForceTuple tuple;
private ForceTupleInputData inputData;
@@ -24,7 +26,23 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
inputData = new();
calculator = new() { InputData = inputData };
}
public bool IsSectionFailure(IPoint2D point2D)
public Predicate<IPoint2D> GetPredicate(PredicateTypes predicateType)
{
if (predicateType == PredicateTypes.Strength)
{
return point2D => IsSectionFailure(point2D);
}
else if (predicateType == PredicateTypes.Cracking)
{
return point2D => IsSectionCracked(point2D);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(predicateType));
}
}
private bool IsSectionFailure(IPoint2D point2D)
{
var point3D = ConvertLogic.GetPoint3D(point2D);
tuple = new()
@@ -40,7 +58,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
return !result.IsValid;
}
public bool IsSectionCracked(IPoint2D point2D)
private bool IsSectionCracked(IPoint2D point2D)
{
var logic = new HoleSectionCrackedLogic();
var point3D = ConvertLogic.GetPoint3D(point2D);
@@ -48,7 +66,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
Nz = point3D.Z,
Mx = point3D.X,
My = point2D.Y
My = point3D.Y
};
logic.Tuple = tuple;
logic.NdmCollection = Ndms;

View File

@@ -0,0 +1,12 @@
using StructureHelperCommon.Models.Calculators;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public interface ILimitCurveCalculator : ICalculator, IHasActionByResult
{
Action<IResult> ActionToOutputResults { get; set; }
SurroundData SurroundData { get; set; }
int PointCount { get; set; }
ISurroundProc SurroundProcLogic { get; set; }
}
}

View File

@@ -10,6 +10,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public interface ISurroundProc
{
SurroundData SurroundData { get; set; }
int PointCount { get; set; }
List<IPoint2D> GetPoints();
}
}

View File

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class LimitCurveCalculator : ICalculator, IHasActionByResult
public class LimitCurveCalculator : ILimitCurveCalculator
{
private LimitCurveResult result;
private List<IPoint2D> surroundList;
@@ -19,6 +19,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public string Name { get; set; }
public SurroundData SurroundData { get; set; }
public int PointCount { get; set; }
public ISurroundProc SurroundProcLogic { get; set; }
public IResult Result => result;
@@ -46,7 +47,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
result = new LimitCurveResult();
result.IsValid = true;
result.Name = Name;
SurroundProcLogic.SurroundData = SurroundData;
SurroundProcLogic.PointCount = PointCount;
surroundList = SurroundProcLogic.GetPoints();
try
{
@@ -60,7 +63,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
result.Description += ex.Message;
}
}
private void GetCurrentStepNumber(IResult calcResult)
{
if (calcResult is not FindParameterResult)

View File

@@ -0,0 +1,35 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
{
public class LimitCurveInputData : IInputData
{
public List<LimitStates> LimitStates { get; }
public List<CalcTerms> CalcTerms { get; }
public List<INdmPrimitive> Primitives { get; set; }
public List<PredicateEntry> PredicateEntries { get; }
public SurroundData SurroundData { get; set; }
public int PointCount { get; set; }
public LimitCurveInputData()
{
LimitStates = new();
CalcTerms = new();
Primitives = new();
PredicateEntries = new();
SurroundData = new();
PointCount = 80;
}
}
}

View File

@@ -33,16 +33,49 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
var range = points.Select(point => new Point2D { X = point.X * 0d, Y = point.Y * 0d }).ToList();
resultList.AddRange(range);
return resultList;
//throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": predicate for zero value is not valid");
}
//MultyProcessPoints(points);
MonoProcessPoints(points);
return resultList;
}
private void MultyProcessPoints(IEnumerable<IPoint2D> points)
{
Task<IPoint2D>[] tasks = new Task<IPoint2D>[points.Count()];
for (int i = 0; i < points.Count(); i++)
{
var point = points.ToList()[i];
tasks[i] = new Task<IPoint2D>(() => FindResultPoint(point));
tasks[i].Start();
}
Task.WaitAll(tasks);
for (int j = 0; j < points.Count(); j++)
{
var taskResult = tasks[j].Result;
resultList.Add(taskResult);
result.IterationNumber = resultList.Count;
ActionToOutputResults?.Invoke(result);
}
}
private void MonoProcessPoints(IEnumerable<IPoint2D> points)
{
foreach (var point in points)
{
FindParameter(point);
}
return resultList;
}
private void FindParameter(IPoint2D point)
{
IPoint2D resultPoint = FindResultPoint(point);
resultList.Add(resultPoint);
result.IterationNumber = resultList.Count;
ActionToOutputResults?.Invoke(result);
}
private Point2D FindResultPoint(IPoint2D point)
{
double parameter;
currentPoint = point.Clone() as IPoint2D;
@@ -53,16 +86,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
}
else
{
parameter = parameterLogic.GetParameter();
parameter = parameterLogic.GetParameter();
}
var resultPoint = new Point2D()
{
X = currentPoint.X * parameter,
Y = currentPoint.Y * parameter
};
resultList.Add(resultPoint);
result.IterationNumber = resultList.Count;
ActionToOutputResults?.Invoke(result);
return resultPoint;
}
}
}

View File

@@ -6,14 +6,19 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class LimitCurveResult : IResult, IiterationResult
{
public bool IsValid { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public List<IPoint2D> Points { get; set; }
public int IterationNumber { get; set; }
public int MaxIterationCount { get; set; }
public LimitCurveResult()
{

View File

@@ -0,0 +1,117 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Calculations.CalculationsResults;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
{
public class LimitCurvesCalculator : ISaveable, ICalculator, IHasActionByResult
{
private LimitCurvesResult result;
private int curvesIterationCount;
public Guid Id { get; }
public string Name { get; set; }
public LimitCurveInputData InputData { get; set; }
public IResult Result => result;
public Action<IResult> ActionToOutputResults { get; set; }
public void Run()
{
GetNewResult();
try
{
var calculators = GetCalulators();
curvesIterationCount = 0;
foreach (var item in calculators)
{
item.Run();
var locResult = item.Result as LimitCurveResult;
result.LimitCurveResults.Add(locResult);
if (locResult.IsValid == false) { result.Description += locResult.Description; }
result.IterationNumber = curvesIterationCount * InputData.PointCount + locResult.IterationNumber;
ActionToOutputResults?.Invoke(result);
curvesIterationCount++;
}
}
catch (Exception ex)
{
result.IsValid = false;
result.Description += ex;
}
}
private void GetNewResult()
{
result = new()
{
IsValid = true
};
}
private List<ILimitCurveCalculator> GetCalulators()
{
List<ILimitCurveCalculator> calculators = new();
foreach (var limitState in InputData.LimitStates)
{
foreach (var calcTerm in InputData.CalcTerms)
{
var ndms = NdmPrimitivesService.GetNdms(InputData.Primitives, limitState, calcTerm);
foreach (var predicateEntry in InputData.PredicateEntries)
{
string calcName = $"{predicateEntry.Name}_{limitState}_{calcTerm}";
LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry, calcName);
calculators.Add(calculator);
}
}
}
return calculators;
}
private LimitCurveCalculator GetCalculator(List<INdm> ndms, PredicateEntry predicateEntry, string calcName)
{
var factory = new PredicateFactory()
{
Ndms = ndms,
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic
};
var predicateType = predicateEntry.PredicateType;
var predicate = factory.GetPredicate(predicateType);
//Predicate<IPoint2D> predicate = factory.IsSectionCracked;
var logic = new LimitCurveLogic(predicate);
//var logic = new StabLimitCurveLogic();
var calculator = new LimitCurveCalculator(logic)
{
Name = calcName,
SurroundData = InputData.SurroundData,
PointCount = InputData.PointCount,
ActionToOutputResults = SetCurveCount
};
return calculator;
}
public object Clone()
{
throw new NotImplementedException();
}
private void SetCurveCount(IResult locResult)
{
var curveResult = locResult as IiterationResult;;
result.IterationNumber = curvesIterationCount * InputData.PointCount + curveResult.IterationNumber;
ActionToOutputResults?.Invoke(result);
}
}
}

View File

@@ -0,0 +1,23 @@
using StructureHelperCommon.Models.Calculators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
{
public class LimitCurvesResult : IResult, IiterationResult
{
public bool IsValid { get; set; }
public string? Description { get; set; }
public List<LimitCurveResult> LimitCurveResults {get;set;}
public int MaxIterationCount { get; set; }
public int IterationNumber { get; set; }
public LimitCurvesResult()
{
LimitCurveResults = new();
}
}
}

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,13 +13,20 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private List<IPoint2D> surroundList;
public SurroundData SurroundData { get; set; }
public int PointCount { get; set; }
public RectSurroundProc()
{
}
public List<IPoint2D> GetPoints()
{
CheckParameters();
var xRadius = (SurroundData.XMax - SurroundData.XMin) / 2;
var yRadius = (SurroundData.YMax - SurroundData.YMin) / 2;
surroundList = new();
var pointCount = Convert.ToInt32(Math.Ceiling(SurroundData.PointCount / 8d));
var pointCount = Convert.ToInt32(Math.Ceiling(PointCount / 8d));
double xStep = xRadius / pointCount;
double yStep = yRadius / pointCount;
double x, y;
@@ -49,5 +57,17 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
surroundList.Add(surroundList[0].Clone() as IPoint2D);
return surroundList;
}
private void CheckParameters()
{
//if (surroundList is null || surroundList.Count == 0)
//{
// throw new StructureHelperException(ErrorStrings.ParameterIsNull);
//}
if (PointCount < 12)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Point count must be grater than 12, but was {PointCount}");
}
}
}
}

View File

@@ -12,6 +12,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private List<IPoint2D> surroundList;
public SurroundData SurroundData { get; set; }
public int PointCount { get; set; }
public RoundSurroundProc()
{
SurroundData = new();
@@ -23,7 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
var xCenter = (SurroundData.XMax + SurroundData.XMin) / 2;
var yCenter = (SurroundData.YMax + SurroundData.YMin) / 2;
surroundList = new();
var pointCount = Convert.ToInt32(Math.Ceiling(SurroundData.PointCount / 4d) * 4d);
var pointCount = Convert.ToInt32(Math.Ceiling(PointCount / 4d) * 4d);
double angleStep = 2d * Math.PI / pointCount;
double angle;
for (int i = 0; i < pointCount; i++)

View File

@@ -18,6 +18,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
foreach (var item in points)
{
result.Add(new Point2D() { X = item.X * 0.5d, Y = item.Y * 0.5d });
Thread.Sleep(10);
}
return result;
}

View File

@@ -6,24 +6,37 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
/// <summary>
/// Limits of coordinates for workplane
/// </summary>
public class SurroundData
{
public double XMax { get; set; }
public double XMin { get; set; }
public double YMax { get; set; }
public double YMin { get; set; }
/// <summary>
/// Constant value of coordinate in direction, which is normal to specific workplane
/// </summary>
public double ConstZ { get; set; }
/// <summary>
/// Logic for transformation of 2D worplane to 3D space
/// </summary>
public ConstOneDirectionConverter ConvertLogicEntity { get; set; }
public int PointCount { get; set; }
/// <summary>
/// Returns new instance of class
/// </summary>
public SurroundData()
{
XMax = 1e7d;
XMin = -1e7d;
YMax = 1e7d;
YMin = -1e7d;
PointCount = 80;
ConvertLogicEntity = ConvertLogics.ConverterLogics[0];
}
}