Change value diagram calculator
This commit is contained in:
@@ -7,7 +7,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
public interface IValueDiagramCalculatorResult : IResult
|
||||
{
|
||||
IValueDiagramCalculatorInputData? InputData { get; set; }
|
||||
List<IPoint2D> Points { get; set; }
|
||||
List<IExtendedForceTupleCalculatorResult> ForceTupleResults { get; set; }
|
||||
List<IValueDiagramEntityResult> EntityResults { get; set; }
|
||||
List<IForceTupleCalculatorResult> ForceTupleResults { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public interface IValueDiagramEntityResult : IResult
|
||||
{
|
||||
IValueDiagramEntity ValueDiagramEntity { get; }
|
||||
List<IPoint2D> PointList { get; set;}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public interface IValueDiagramEntityLogic : ILogic
|
||||
{
|
||||
IValueDiagramEntity ValueDiagramEntity { get; set; }
|
||||
IValueDiagramEntityResult Result { get; }
|
||||
void Run();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Sections;
|
||||
using StructureHelperCommon.Models.Sections.Logics;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramCalculatorLogic : IValueDiagramCalculatorLogic
|
||||
{
|
||||
private readonly IValueDiagramEntityLogic entityLogic = new ValueDiagramEntityLogic();
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
private List<INdm> ndms;
|
||||
private IValueDiagramCalculatorResult result;
|
||||
public IValueDiagramCalculatorInputData InputData { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
@@ -23,7 +23,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
public IValueDiagramCalculatorResult GetResult()
|
||||
{
|
||||
PrepareResult();
|
||||
GetPoints();
|
||||
GetEntitiesResults();
|
||||
CalculateTupleResults();
|
||||
return result;
|
||||
}
|
||||
@@ -37,30 +37,67 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
CalcTerm = InputData.StateTermPair.CalcTerm,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
ndms = triangulateLogic.GetNdms();
|
||||
foreach (var forceAction in InputData.ForceActions)
|
||||
{
|
||||
var combination = forceAction.GetCombinations();
|
||||
List<IForceTuple> forceTuples = [];
|
||||
foreach (var action in combination)
|
||||
{
|
||||
var actionCombination = action
|
||||
var forceTuple = action
|
||||
.DesignForces
|
||||
.Where(x => x.LimitState == InputData.StateTermPair.LimitState && x.CalcTerm == InputData.StateTermPair.CalcTerm);
|
||||
}
|
||||
ForceTupleInputData forceTupleInputData = new()
|
||||
{
|
||||
NdmCollection = ndms,
|
||||
Accuracy = new Accuracy(),
|
||||
CheckStrainLimit = true,
|
||||
.Single(x => x.LimitState == InputData.StateTermPair.LimitState && x.CalcTerm == InputData.StateTermPair.CalcTerm)
|
||||
.ForceTuple;
|
||||
|
||||
|
||||
IPoint2D point2D;
|
||||
IProcessorLogic<IForceTuple> forcelogic = new ForceTupleCopier(forceTuple);
|
||||
if (action.SetInGravityCenter == true)
|
||||
{
|
||||
var (Cx, Cy) = LoaderCalculator.Logics.Geometry.GeometryOperations.GetGravityCenter(ndms);
|
||||
point2D = new Point2D() { X = Cx, Y = Cy };
|
||||
forcelogic = new ForceTupleMoveToPointDecorator(forcelogic) { Point2D = point2D };
|
||||
}
|
||||
var newTuple = forcelogic.GetValue();
|
||||
GetForceTupleResult(forceAction, newTuple);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void GetPoints()
|
||||
private void GetForceTupleResult(IForceAction forceAction, IForceTuple forceTuple)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
ForceTupleInputData forceTupleInputData = new()
|
||||
{
|
||||
ForceTuple = forceTuple,
|
||||
NdmCollection = ndms,
|
||||
Accuracy = new Accuracy() { IterationAccuracy = 0.001, MaxIterationCount = 1000},
|
||||
CheckStrainLimit = InputData.CheckStrainLimit,
|
||||
};
|
||||
ForceTupleCalculator calculator = new ForceTupleCalculator()
|
||||
{
|
||||
InputData = forceTupleInputData,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(100)
|
||||
};
|
||||
calculator.Run();
|
||||
var tupleResult = calculator.Result as IForceTupleCalculatorResult;
|
||||
if (tupleResult.IsValid == false)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Result is not valid for action {forceAction.Name}: {tupleResult.Description}", TraceLogStatuses.Error);
|
||||
}
|
||||
result.ForceTupleResults.Add(tupleResult);
|
||||
}
|
||||
|
||||
private void GetEntitiesResults()
|
||||
{
|
||||
var entities = InputData.Digrams
|
||||
.Where(x => x.IsTaken == true);
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
entityLogic.ValueDiagramEntity = entity;
|
||||
entityLogic.Run();
|
||||
result.EntityResults.Add(entityLogic.Result);
|
||||
}
|
||||
}
|
||||
|
||||
private void PrepareResult()
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramEntityLogic : IValueDiagramEntityLogic
|
||||
{
|
||||
public IValueDiagramEntity ValueDiagramEntity { get; set; }
|
||||
|
||||
private IValueDiagramEntityResult result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public IValueDiagramEntityResult Result => result;
|
||||
|
||||
public void Run()
|
||||
{
|
||||
result = new ValueDiagramEntityResult(ValueDiagramEntity);
|
||||
result.PointList = GetPoints();
|
||||
}
|
||||
|
||||
private List<IPoint2D> GetPoints()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Getting point for diagram {ValueDiagramEntity.Name} has been started");
|
||||
var startPoint = ValueDiagramEntity.ValueDigram.Point2DRange.StartPoint;
|
||||
var endPoint = ValueDiagramEntity.ValueDigram.Point2DRange.EndPoint;
|
||||
double dx = (endPoint.X - startPoint.X) / ValueDiagramEntity.ValueDigram.StepNumber;
|
||||
double dy = (endPoint.Y - startPoint.Y) / ValueDiagramEntity.ValueDigram.StepNumber;
|
||||
List<IPoint2D> point2Ds = [];
|
||||
for (int i = 0; i < ValueDiagramEntity.ValueDigram.StepNumber + 1; i++)
|
||||
{
|
||||
double x = startPoint.X + dx * i;
|
||||
double y = startPoint.Y + dy * i;
|
||||
point2Ds.Add(new Point2D(x, y));
|
||||
}
|
||||
TraceLogger?.AddMessage($"Getting point for diagram {ValueDiagramEntity.Name} has been finished, total {point2Ds.Count} points obtained");
|
||||
return point2Ds;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramCalculator : IValueDiagramCalculator
|
||||
{
|
||||
private readonly IValueDiagramCalculatorLogic valueDiagramCalculatorLogic = new ValueDiagramCalculatorLogic();
|
||||
private readonly ICheckInputDataLogic<IValueDiagramCalculatorInputData> checkInputDataLogic;
|
||||
private IValueDiagramCalculatorResult result;
|
||||
|
||||
public Guid Id { get; }
|
||||
@@ -38,7 +35,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
|
||||
public void Run()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
valueDiagramCalculatorLogic.InputData = InputData;
|
||||
result = valueDiagramCalculatorLogic.GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public IValueDiagramCalculatorInputData? InputData { get; set; }
|
||||
|
||||
public List<IPoint2D> Points { get; set; } = [];
|
||||
|
||||
public List<IExtendedForceTupleCalculatorResult> ForceTupleResults { get; set; } = [];
|
||||
public List<IForceTupleCalculatorResult> ForceTupleResults { get; set; } = [];
|
||||
|
||||
public bool IsValid { get; set; } = true;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
public List<IValueDiagramEntityResult> EntityResults { get; set; } = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramEntityResult : IValueDiagramEntityResult
|
||||
{
|
||||
public IValueDiagramEntity ValueDiagramEntity { get; }
|
||||
|
||||
public ValueDiagramEntityResult(IValueDiagramEntity valueDiagramEntity)
|
||||
{
|
||||
ValueDiagramEntity = valueDiagramEntity;
|
||||
}
|
||||
|
||||
public List<IPoint2D> PointList { get; set; } = [];
|
||||
public bool IsValid { get; set; } = true;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user