Trace logger calls were adde in limit curve calculator
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Sections;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
@@ -25,6 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public IAccuracy Accuracy { get; set; }
|
||||
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public void Run()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.ResultData;
|
||||
using LoaderCalculator.Data.SourceData;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
@@ -13,6 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public IResult Result { get; private set; }
|
||||
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public ForceTupleCalculator(IForceTupleInputData inputData)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,6 +15,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Fac
|
||||
public IEnumerable<INdm> Ndms { get; set; }
|
||||
public PredicateTypes PredicateType { get; set; }
|
||||
public IConvert2DPointTo3DPointLogic ConvertLogic { get; set; }
|
||||
public string Name { get; set; }
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public Predicate<IPoint2D> GetPredicate()
|
||||
{
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories
|
||||
{
|
||||
public interface IGetPredicateLogic
|
||||
{
|
||||
string Name { get; set; }
|
||||
Predicate<IPoint2D> GetPredicate();
|
||||
ITraceLogger? TraceLogger { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -22,5 +23,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
/// <param name="points"></param>
|
||||
/// <returns></returns>
|
||||
List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points);
|
||||
ITraceLogger? TraceLogger { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -8,10 +9,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
/// <summary>
|
||||
/// Find parameter by point and predicate
|
||||
/// </summary>
|
||||
public interface ILimitCurveParameterLogic : IHasActionByResult, ICloneable
|
||||
{
|
||||
Predicate<Point2D> LimitPredicate { get; set; }
|
||||
IPoint2D CurrentPoint { get; set; }
|
||||
double GetParameter();
|
||||
ITraceLogger? TraceLogger { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -25,6 +26,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public IResult Result => result;
|
||||
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public LimitCurveCalculator(ILimitCurveLogic limitCurveLogic)
|
||||
{
|
||||
@@ -45,20 +47,27 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
|
||||
public void Run()
|
||||
{
|
||||
if (TraceLogger is not null) { limitCurveLogic.TraceLogger = TraceLogger; }
|
||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLoggerStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Start solution in calculator {Name}");
|
||||
result = new LimitCurveResult();
|
||||
result.IsValid = true;
|
||||
result.Name = Name;
|
||||
SurroundProcLogic.SurroundData = SurroundData;
|
||||
SurroundProcLogic.PointCount = PointCount;
|
||||
TraceLogger?.AddMessage($"Point count {PointCount}");
|
||||
surroundList = SurroundProcLogic.GetPoints();
|
||||
TraceLogger?.AddMessage($"There are {surroundList.Count()} point prepared for calculation");
|
||||
try
|
||||
{
|
||||
limitCurveLogic.ActionToOutputResults = GetCurrentStepNumber;
|
||||
factoredList = limitCurveLogic.GetPoints(surroundList);
|
||||
TraceLogger?.AddMessage($"Solution was successfully obtained for {factoredList.Count()} point");
|
||||
result.Points = factoredList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculation result is not valid: {ex.Message}", TraceLoggerStatuses.Error);
|
||||
result.IsValid = false;
|
||||
result.Description += ex.Message;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
|
||||
private object lockObject = new object();
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public LimitCurveLogic(ILimitCurveParameterLogic parameterLogic)
|
||||
{
|
||||
@@ -30,22 +32,25 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
/// <inheritdoc/>
|
||||
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
if (TraceLogger is not null) { ParameterLogic.TraceLogger = TraceLogger; }
|
||||
result = new();
|
||||
resultList = new();
|
||||
TraceLogger?.AddMessage($"Predicate name is {GetPredicateLogic.Name}");
|
||||
Predicate<IPoint2D> limitPredicate = GetPredicateLogic.GetPredicate();
|
||||
//if predicate is true for point (0,0), then check other point is pointless
|
||||
if (limitPredicate(new Point2D()) == true)
|
||||
{
|
||||
var range = points.Select(point => new Point2D { X = point.X * 0d, Y = point.Y * 0d }).ToList();
|
||||
TraceLogger?.AddMessage($"Predicate is true for point (0d, 0d). All point will be skiped", TraceLoggerStatuses.Warning);
|
||||
var range = points.Select(point => new Point2D { X = 0d, Y = 0d }).ToList();
|
||||
resultList.AddRange(range);
|
||||
return resultList;
|
||||
}
|
||||
pointCount = 0;
|
||||
MultyThreadProc(points);
|
||||
//MonoThreadProc(points);
|
||||
MultiThreadProc(points);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private void MultyThreadProc(IEnumerable<IPoint2D> points)
|
||||
private void MultiThreadProc(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
Task<IPoint2D>[] tasks = new Task<IPoint2D>[points.Count()];
|
||||
for (int i = 0; i < points.Count(); i++)
|
||||
@@ -63,53 +68,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
}
|
||||
}
|
||||
|
||||
private void MonoThreadProc(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
foreach (var point in points)
|
||||
{
|
||||
FindParameter(point);
|
||||
}
|
||||
}
|
||||
|
||||
private void FindParameter(IPoint2D point)
|
||||
{
|
||||
IPoint2D resultPoint = FindResultPoint(point);
|
||||
resultList.Add(resultPoint);
|
||||
lock (lockObject)
|
||||
{
|
||||
pointCount++;
|
||||
}
|
||||
result.IterationNumber = pointCount;
|
||||
ActionToOutputResults?.Invoke(result);
|
||||
}
|
||||
|
||||
private Point2D FindResultPoint(IPoint2D point)
|
||||
{
|
||||
double parameter;
|
||||
var locCurrentPoint = point.Clone() as IPoint2D;
|
||||
Predicate<IPoint2D> limitPredicate;
|
||||
lock (lockObject)
|
||||
{
|
||||
limitPredicate = GetPredicateLogic.GetPredicate();
|
||||
}
|
||||
var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic;
|
||||
logic.CurrentPoint = locCurrentPoint;
|
||||
logic.LimitPredicate = limitPredicate;
|
||||
|
||||
if (limitPredicate(locCurrentPoint) == false)
|
||||
{
|
||||
parameter = 1d;
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter = logic.GetParameter();
|
||||
}
|
||||
|
||||
var resultPoint = new Point2D()
|
||||
{
|
||||
X = locCurrentPoint.X * parameter,
|
||||
Y = locCurrentPoint.Y * parameter
|
||||
};
|
||||
var resultPoint = FindResultPointByPredicate(point, limitPredicate);
|
||||
lock (lockObject)
|
||||
{
|
||||
pointCount++;
|
||||
@@ -117,7 +83,39 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
result.IterationNumber = pointCount;
|
||||
ActionToOutputResults?.Invoke(result);
|
||||
return resultPoint;
|
||||
//}
|
||||
}
|
||||
|
||||
private Point2D FindResultPointByPredicate(IPoint2D point, Predicate<IPoint2D> limitPredicate)
|
||||
{
|
||||
var localCurrentPoint = point.Clone() as IPoint2D;
|
||||
var logic = ParameterLogic.Clone() as ILimitCurveParameterLogic;
|
||||
logic.TraceLogger = new TraceLogger();
|
||||
logic.CurrentPoint = localCurrentPoint;
|
||||
logic.LimitPredicate = limitPredicate;
|
||||
double parameter;
|
||||
|
||||
if (limitPredicate(localCurrentPoint) == false)
|
||||
{
|
||||
parameter = 1d;
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter = logic.GetParameter();
|
||||
}
|
||||
|
||||
var resultPoint = new Point2D()
|
||||
{
|
||||
X = localCurrentPoint.X * parameter,
|
||||
Y = localCurrentPoint.Y * parameter
|
||||
};
|
||||
lock (lockObject)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Source point (X = {localCurrentPoint.X}, Y = {localCurrentPoint.Y})");
|
||||
TraceLogger?.TraceLoggerEntries.AddRange(logic.TraceLogger.TraceLoggerEntries);
|
||||
TraceLogger?.AddMessage($"Parameter value {parameter} was obtained");
|
||||
TraceLogger?.AddMessage($"Calculated point (X={localCurrentPoint.X} * {parameter} = {resultPoint.X}, Y={localCurrentPoint.Y} * {parameter} = {resultPoint.Y})");
|
||||
}
|
||||
return resultPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,6 +16,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public Predicate<Point2D> LimitPredicate { get; set; }
|
||||
public IPoint2D CurrentPoint { get; set; }
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public LimitCurveParameterLogic()
|
||||
{
|
||||
@@ -27,6 +29,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
Predicate = GetFactorPredicate,
|
||||
};
|
||||
if (TraceLogger is not null) { parameterCalculator.TraceLogger = TraceLogger; }
|
||||
parameterCalculator.Accuracy.IterationAccuracy = 0.001d;
|
||||
parameterCalculator.Run();
|
||||
if (parameterCalculator.Result.IsValid == false)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationsResults;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve.Factories;
|
||||
@@ -29,6 +30,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public IResult Result => result;
|
||||
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public LimitCurvesCalculator()
|
||||
{
|
||||
Name = "New calculator";
|
||||
@@ -36,6 +39,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
}
|
||||
public void Run()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLoggerStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Start solution in calculator {Name}");
|
||||
GetNewResult();
|
||||
try
|
||||
{
|
||||
@@ -46,7 +51,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
item.Run();
|
||||
var locResult = item.Result as LimitCurveResult;
|
||||
result.LimitCurveResults.Add(locResult);
|
||||
if (locResult.IsValid == false) { result.Description += locResult.Description; }
|
||||
if (locResult.IsValid == false)
|
||||
{
|
||||
result.Description += locResult.Description;
|
||||
}
|
||||
result.IterationNumber = curvesIterationCount * InputData.PointCount + locResult.IterationNumber;
|
||||
ActionToOutputResults?.Invoke(result);
|
||||
curvesIterationCount++;
|
||||
@@ -54,6 +62,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculation result is not valid: {ex.Message}", TraceLoggerStatuses.Error);
|
||||
result.IsValid = false;
|
||||
result.Description += ex;
|
||||
}
|
||||
@@ -81,6 +90,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
string calcName = $"{primitiveSeries.Name}_{predicateEntry.Name}_{limitState}_{calcTerm}";
|
||||
LimitCurveCalculator calculator = GetCalculator(ndms, predicateEntry.PredicateType, calcName);
|
||||
if (TraceLogger is not null) { calculator.TraceLogger = TraceLogger; }
|
||||
calculators.Add(calculator);
|
||||
}
|
||||
}
|
||||
@@ -91,18 +101,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
|
||||
private LimitCurveCalculator GetCalculator(List<INdm> ndms, PredicateTypes predicateType, string calcName)
|
||||
{
|
||||
var factory = new PredicateFactory()
|
||||
{
|
||||
Ndms = ndms,
|
||||
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic
|
||||
};
|
||||
var predicate = factory.GetPredicate(predicateType);
|
||||
var getPredicateLogic = new GetPredicateLogic()
|
||||
{
|
||||
Name = calcName,
|
||||
Ndms = ndms,
|
||||
ConvertLogic = InputData.SurroundData.ConvertLogicEntity.ConvertLogic,
|
||||
PredicateType = predicateType
|
||||
};
|
||||
if (TraceLogger is not null) { getPredicateLogic.TraceLogger = TraceLogger; }
|
||||
var logic = new LimitCurveLogic(getPredicateLogic);
|
||||
var calculator = new LimitCurveCalculator(logic)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -11,6 +12,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
public class StabLimitCurveLogic : ILimitCurveLogic
|
||||
{
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public List<IPoint2D> GetPoints(IEnumerable<IPoint2D> points)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Services.NdmCalculations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -23,6 +24,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
|
||||
|
||||
public int StepCount => interpolateTuplesResult.StepCount + 1;
|
||||
|
||||
public ITraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public void WorkerDoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
InterpolateCalculator = InterpolateService.InterpolateForceCalculator(forceCalculator, interpolateTuplesResult);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -19,6 +20,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Geometry
|
||||
public IResult Result => geometryResult;
|
||||
|
||||
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public ITraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public GeometryCalculator(IEnumerable<INdm> ndms, IStrainMatrix strainMatrix)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user