CrackedCalculator and TriangulationLogic were changed
This commit is contained in:
@@ -22,6 +22,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||
internal class CrackDiagramLogic : ILongProcessLogic
|
||||
{
|
||||
static readonly CrackForceCalculator calculator = new();
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
private List<IForcesTupleResult> ValidTupleList { get; set; }
|
||||
ArrayParameter<double> arrayParameter;
|
||||
private IEnumerable<IForcesTupleResult> TupleList { get; set; }
|
||||
@@ -102,7 +104,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||
calculator.EndTuple = validTupleList[i].DesignForceTuple.ForceTuple;
|
||||
var limitState = validTupleList[i].DesignForceTuple.LimitState;
|
||||
var calcTerm = validTupleList[i].DesignForceTuple.CalcTerm;
|
||||
var ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = limitState,
|
||||
CalcTerm = calcTerm,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
calculator.NdmCollection = ndms;
|
||||
calculator.Run();
|
||||
var result = (CrackForceResult)calculator.Result;
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
internal class ShowCrackResultLogic
|
||||
{
|
||||
private CrackForceCalculator calculator;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
|
||||
public LimitStates LimitState { get; set; }
|
||||
@@ -42,7 +43,13 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
calculator.TraceLogger = new ShiftTraceLogger();
|
||||
calculator.StartTuple = startDesignTuple;
|
||||
calculator.EndTuple = finishDesignTuple;
|
||||
calculator.NdmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitState, CalcTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = LimitState,
|
||||
CalcTerm = CalcTerm
|
||||
};
|
||||
calculator.NdmCollection = triangulateLogic.GetNdms();
|
||||
calculator.Run();
|
||||
var result = (CrackForceResult)calculator.Result;
|
||||
if (result.IsValid)
|
||||
|
||||
@@ -19,14 +19,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
|
||||
internal void Show()
|
||||
{
|
||||
var inputData = new CrackWidthCalculatorInputData()
|
||||
var inputData = new TupleCrackInputData()
|
||||
{
|
||||
//LimitState = LimitState,
|
||||
//CalcTerm = CalcTerm,
|
||||
LongTermTuple = ForceTuple,
|
||||
NdmPrimitives = ndmPrimitives
|
||||
};
|
||||
var calculator = new CrackWidthCalculator() { InputData = inputData };
|
||||
var calculator = new TupleCrackCalculator() { InputData = inputData };
|
||||
calculator.Run();
|
||||
var result = calculator.Result;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using LoaderCalculator;
|
||||
using LoaderCalculator.Data.Materials.MaterialBuilders;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using LoaderCalculator.Data.ResultData;
|
||||
@@ -9,6 +10,7 @@ using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Services.Units;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
@@ -26,6 +28,8 @@ namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public class CrossSectionModel
|
||||
{
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
public ICrossSection Section { get; private set; }
|
||||
private IPrimitiveRepository primitiveRepository;
|
||||
public IHeadMaterialRepository HeadMaterialRepository { get; }
|
||||
@@ -52,7 +56,13 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public IEnumerable<INdm> GetNdms(ICalculationProperty calculationProperty)
|
||||
{
|
||||
var ndmPrimitives = Section.SectionRepository.Primitives;
|
||||
return NdmPrimitivesService.GetNdms(ndmPrimitives, calculationProperty.LimitState, calculationProperty.CalcTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = calculationProperty.LimitState,
|
||||
CalcTerm = calculationProperty.CalcTerm
|
||||
};
|
||||
return triangulateLogic.GetNdms();
|
||||
////Настройки триангуляции, пока опции могут быть только такие
|
||||
//ITriangulationOptions options = new TriangulationOptions { LimiteState = calculationProperty.LimitState, CalcTerm = calculationProperty.CalcTerm };
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
<ContentControl ContentTemplate="{DynamicResource DiagramCalculator}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Visibility="Hidden" Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.CrackCalculator}" ToolTip="Add Interaction Diagram Calculator">
|
||||
<Button Style="{DynamicResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.CrackCalculator}" ToolTip="Add Crack Calculator">
|
||||
<Viewbox>
|
||||
<ContentControl ContentTemplate="{DynamicResource CrackCalculator}"/>
|
||||
</Viewbox>
|
||||
@@ -357,7 +357,7 @@
|
||||
</Viewbox>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Visibility="Hidden" Header="Add Crack Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.CrackCalculator}">
|
||||
<MenuItem Header="Add Crack Calculator" Command="{Binding Add}" CommandParameter="{x:Static enums:CalculatorTypes.CrackCalculator}">
|
||||
<MenuItem.Icon>
|
||||
<Viewbox Width="16" Height="16">
|
||||
<ContentControl ContentTemplate="{DynamicResource CrackCalculator}"/>
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
private ICrossSection section;
|
||||
private ICrossSectionRepository repository => section.SectionRepository;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
|
||||
public CrossSectionVisualPropertyVM VisualProperty { get; private set; }
|
||||
|
||||
@@ -172,7 +174,13 @@ namespace StructureHelper.Windows.MainWindow
|
||||
MovePrimitiveToGravityCenterCommand = new RelayCommand(o =>
|
||||
{
|
||||
if (CheckMaterials() == false) { return;}
|
||||
var ndms = NdmPrimitivesService.GetNdms(repository.Primitives, LimitStates.SLS, CalcTerms.ShortTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = repository.Primitives,
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
var center = GeometryOperations.GetGravityCenter(ndms);
|
||||
foreach (var item in PrimitiveLogic.Items)
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Logics;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
@@ -56,7 +57,13 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
private void AddCrackCalculator()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var inputData = new CrackInputData();
|
||||
var calculator = new CrackCalculator(inputData)
|
||||
{
|
||||
Name = "New crack calculator",
|
||||
TraceLogger = new ShiftTraceLogger(),
|
||||
};
|
||||
NewItem = calculator;
|
||||
}
|
||||
|
||||
private void AddLimitCurveCalculator()
|
||||
@@ -102,20 +109,15 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
private void EditCalculator()
|
||||
{
|
||||
if (SelectedItem is ForceCalculator)
|
||||
{
|
||||
var calculator = SelectedItem as ForceCalculator;
|
||||
EditForceCalculator(calculator);
|
||||
}
|
||||
else if (SelectedItem is LimitCurvesCalculator)
|
||||
{
|
||||
var calculator = SelectedItem as LimitCurvesCalculator;
|
||||
EditLimitCurveCalculator(calculator);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
|
||||
}
|
||||
if (SelectedItem is ForceCalculator forceCalculator) { EditForceCalculator(forceCalculator);}
|
||||
else if (SelectedItem is LimitCurvesCalculator limitCurvesCalculator) { EditLimitCurveCalculator(limitCurvesCalculator); }
|
||||
else if (SelectedItem is CrackCalculator crackCalculator) { EditCrackCalculator(crackCalculator);}
|
||||
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));}
|
||||
}
|
||||
|
||||
private void EditCrackCalculator(CrackCalculator crackCalculator)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void EditLimitCurveCalculator(LimitCurvesCalculator calculator)
|
||||
@@ -193,6 +195,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
ProcessResult();
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectedItem.TraceLogger is not null)
|
||||
{
|
||||
var wnd = new TraceDocumentView(SelectedItem.TraceLogger.TraceLoggerEntries);
|
||||
@@ -214,12 +217,15 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
private void ProcessResult()
|
||||
{
|
||||
if (SelectedItem is IForceCalculator)
|
||||
if (SelectedItem is ForceCalculator forceCalculator)
|
||||
{
|
||||
var calculator = SelectedItem as ForceCalculator;
|
||||
var vm = new ForcesResultsViewModel(calculator);
|
||||
var vm = new ForcesResultsViewModel(forceCalculator);
|
||||
var wnd = new ForceResultsView(vm);
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
else if (SelectedItem is CrackCalculator crackCalculator)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -5,6 +5,9 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public interface IHasForceCombinations
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of force actions
|
||||
/// </summary>
|
||||
List<IForceAction> ForceActions { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace StructureHelperCommon.Models.Loggers
|
||||
{
|
||||
public static string DimensionLess => "(dimensionless)";
|
||||
public static string MethodBasedOn => "Method of calculation based on ";
|
||||
public static string CalculationError => "Some errors happened during calculations: ";
|
||||
public static string CalculationHasDone => "Calculation has done succesfully";
|
||||
public static string Summary => "Summary";
|
||||
public static string Maximum => "Maximum";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
|
||||
namespace StructureHelperLogics.Models.Templates.CrossSections
|
||||
{
|
||||
@@ -8,14 +9,19 @@ namespace StructureHelperLogics.Models.Templates.CrossSections
|
||||
{
|
||||
public IEnumerable<ICalculator> GetNdmCalculators()
|
||||
{
|
||||
var calculators = new List<ICalculator>
|
||||
var calculators = new List<ICalculator>();
|
||||
var forceCalculator = new ForceCalculator()
|
||||
{
|
||||
new ForceCalculator()
|
||||
{
|
||||
Name = "New Force Calculator",
|
||||
TraceLogger = new ShiftTraceLogger()
|
||||
}
|
||||
Name = "New Force Calculator",
|
||||
TraceLogger = new ShiftTraceLogger()
|
||||
};
|
||||
calculators.Add(forceCalculator);
|
||||
var crackCalculator = new CrackCalculator(new CrackInputData())
|
||||
{
|
||||
Name = "New Crack Calculator",
|
||||
TraceLogger = new ShiftTraceLogger()
|
||||
};
|
||||
calculators.Add(crackCalculator);
|
||||
return calculators;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -62,6 +63,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
var forceCalculator = calculator as IHasForceCombinations;
|
||||
forceCalculator.ForceActions.AddRange(combinations);
|
||||
}
|
||||
if (calculator is CrackCalculator crackCalculator)
|
||||
{
|
||||
crackCalculator.InputData.ForceActions.AddRange(combinations);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void AddAllPrimitivesToCalculator()
|
||||
@@ -73,6 +78,10 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
|
||||
var primitiveCalculator = calculator as IHasPrimitives;
|
||||
primitiveCalculator.Primitives.AddRange(primitives);
|
||||
}
|
||||
if (calculator is CrackCalculator crackCalculator)
|
||||
{
|
||||
crackCalculator.InputData.Primitives.AddRange(primitives);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
@@ -8,12 +7,10 @@ using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Models.Sections;
|
||||
using StructureHelperCommon.Models.Sections.Logics;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
|
||||
using StructureHelperLogics.NdmCalculations.Buckling;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
@@ -24,6 +21,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
private ForcesResults result;
|
||||
private IProcessorLogic<IForceTuple> eccentricityLogic;
|
||||
private ForceTupleBucklingLogic bucklingLogic;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
|
||||
public string Name { get; set; }
|
||||
public List<LimitStates> LimitStatesList { get; private set; }
|
||||
@@ -99,7 +98,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
IForcesTupleResult tupleResult;
|
||||
LimitStates limitState = tuple.LimitState;
|
||||
CalcTerms calcTerm = tuple.CalcTerm;
|
||||
var ndms = NdmPrimitivesService.GetNdms(Primitives, limitState, calcTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = Primitives,
|
||||
LimitState = limitState,
|
||||
CalcTerm = calcTerm,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
IPoint2D point2D;
|
||||
IProcessorLogic<IForceTuple> forcelogic = new ForceTupleCopier(tuple.ForceTuple);
|
||||
if (combination.SetInGravityCenter == true)
|
||||
@@ -196,7 +202,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
string result = "";
|
||||
try
|
||||
{
|
||||
NdmPrimitivesService.CheckPrimitives(Primitives);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = Primitives
|
||||
};
|
||||
triangulateLogic.CheckPrimitives(Primitives);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
private LimitCurvesResult result;
|
||||
private int curvesIterationCount;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
private LimitCurvesCalculatorUpdateStrategy updateStrategy => new();
|
||||
|
||||
public Guid Id { get; }
|
||||
@@ -78,7 +80,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
foreach (var calcTerm in InputData.CalcTerms)
|
||||
{
|
||||
var ndms = NdmPrimitivesService.GetNdms(primitiveSeries.Collection, limitState, calcTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = primitiveSeries.Collection,
|
||||
LimitState = limitState,
|
||||
CalcTerm = calcTerm,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
TraceLogger?.AddMessage($"Number of elementary parts N={ndms.Count()} were obtainded succesfully");
|
||||
TraceLogger?.AddMessage($"Summary area of elementary parts Asum={ndms.Sum(x=>x.Area * x.StressScale)}", TraceLogStatuses.Debug);
|
||||
foreach (var predicateEntry in InputData.PredicateEntries)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using LoaderCalculator.Logics;
|
||||
using LoaderCalculator.Logics.Geometry;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
@@ -24,6 +25,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
|
||||
private List<INdm> concreteNdms;
|
||||
private List<INdm> otherNdms;
|
||||
IForcesTupleResult forcesResults;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
@@ -52,7 +54,13 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
|
||||
Accuracy = accuracy;
|
||||
|
||||
var allPrimitives = options.Primitives;
|
||||
ndmCollection = NdmPrimitivesService.GetNdms(allPrimitives, options.LimitState, options.CalcTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = allPrimitives,
|
||||
LimitState = options.LimitState,
|
||||
CalcTerm = options.CalcTerm
|
||||
};
|
||||
ndmCollection = triangulateLogic.GetNdms();
|
||||
concreteNdms = ndmCollection.Where(x => x.Material is ICrackMaterial).ToList();
|
||||
otherNdms = ndmCollection.Except(concreteNdms).ToList();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackCalculator : ICalculator
|
||||
{
|
||||
const LimitStates limitState = LimitStates.SLS;
|
||||
const CalcTerms longTerm = CalcTerms.LongTerm;
|
||||
const CalcTerms shortTerm = CalcTerms.ShortTerm;
|
||||
|
||||
private CrackResult result;
|
||||
private IGetTupleInputDatasLogic datasLogic;
|
||||
private CrackCalculatorUpdateStrategy updateStrategy = new();
|
||||
|
||||
public string Name { get; set; }
|
||||
public CrackInputData InputData { get; set; }
|
||||
public IResult Result => result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public CrackCalculator(CrackInputData inputData)
|
||||
{
|
||||
InputData = inputData;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newItem = new CrackCalculator(new CrackInputData());
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
PrepareNewResult();
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
|
||||
try
|
||||
{
|
||||
ProcessCalculations();
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += ex;
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationError + ex, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessCalculations()
|
||||
{
|
||||
datasLogic = new GetTupleInputDatasLogic(InputData.Primitives, InputData.ForceActions)
|
||||
{
|
||||
LimitState = limitState,
|
||||
LongTerm = longTerm,
|
||||
ShortTerm = shortTerm,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
var datas = datasLogic.GetTupleInputDatas();
|
||||
foreach (var data in datas)
|
||||
{
|
||||
var calculator = new TupleCrackCalculator()
|
||||
{
|
||||
InputData = data,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
calculator.Run();
|
||||
var calcResult = calculator.Result as TupleCrackResult;
|
||||
result.TupleResults.Add(calcResult);
|
||||
}
|
||||
}
|
||||
|
||||
private void PrepareNewResult()
|
||||
{
|
||||
result = new CrackResult
|
||||
{
|
||||
IsValid = true,
|
||||
Description = string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackCalculatorUpdateStrategy : IUpdateStrategy<CrackCalculator>
|
||||
{
|
||||
private CrackInputDataUpdateStrategy inputDataUpdateStrategy => new();
|
||||
public void Update(CrackCalculator targetObject, CrackCalculator sourceObject)
|
||||
{
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.InputData ??= new();
|
||||
inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackInputData : IInputData, IHasPrimitives, IHasForceCombinations
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public List<INdmPrimitive> Primitives { get; private set; }
|
||||
/// <inheritdoc/>
|
||||
public List<IForceAction> ForceActions { get; private set; }
|
||||
public CrackInputData()
|
||||
{
|
||||
Primitives = new();
|
||||
ForceActions = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackInputDataUpdateStrategy : IUpdateStrategy<CrackInputData>
|
||||
{
|
||||
public void Update(CrackInputData targetObject, CrackInputData sourceObject)
|
||||
{
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.ForceActions.Clear();
|
||||
targetObject.ForceActions.AddRange(sourceObject.ForceActions);
|
||||
targetObject.Primitives.Clear();
|
||||
targetObject.Primitives.AddRange(sourceObject.Primitives);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackResult : IResult
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public List<TupleCrackResult> TupleResults {get;set;}
|
||||
public CrackResult()
|
||||
{
|
||||
TupleResults = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class GetTupleInputDatasLogic : IGetTupleInputDatasLogic
|
||||
{
|
||||
public List<IForceAction> ForceActions { get; set; }
|
||||
public List<INdmPrimitive> Primitives { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms LongTerm { get; set; }
|
||||
public CalcTerms ShortTerm { get; set; }
|
||||
|
||||
public GetTupleInputDatasLogic(List<INdmPrimitive> primitives, List<IForceAction> forceActions)
|
||||
{
|
||||
Primitives = primitives;
|
||||
ForceActions = forceActions;
|
||||
}
|
||||
|
||||
public List<TupleCrackInputData> GetTupleInputDatas()
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
|
||||
|
||||
List<TupleCrackInputData> resultList = new();
|
||||
CheckInputData();
|
||||
foreach (var action in ForceActions)
|
||||
{
|
||||
var tuple = GetTuplesByActions(action);
|
||||
if (tuple.isValid == false)
|
||||
{
|
||||
resultList.Add(new TupleCrackInputData()
|
||||
{
|
||||
IsValid = false,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
resultList.Add(new TupleCrackInputData()
|
||||
{
|
||||
IsValid = true,
|
||||
LongTermTuple = tuple.LongTuple,
|
||||
ShortTermTuple = tuple.ShortTuple,
|
||||
NdmPrimitives = Primitives
|
||||
});
|
||||
}
|
||||
}
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private void CheckInputData()
|
||||
{
|
||||
if (ForceActions is null)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force action is null", TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": {nameof(ForceActions)} is null");
|
||||
}
|
||||
}
|
||||
|
||||
private (bool isValid, IForceTuple? LongTuple, IForceTuple? ShortTuple) GetTuplesByActions(IForceAction action)
|
||||
{
|
||||
IForceTuple longTuple, shortTuple;
|
||||
var combinations = action.GetCombinations().DesignForces;
|
||||
try
|
||||
{
|
||||
longTuple = GetTupleByCombination(combinations, LimitState, LongTerm);
|
||||
TraceLogger?.AddMessage("Long term force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(longTuple));
|
||||
shortTuple = GetTupleByCombination(combinations, LimitState, ShortTerm);
|
||||
TraceLogger?.AddMessage("Short term force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(longTuple));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force combination is not obtained: \n" + ex, TraceLogStatuses.Error);
|
||||
return (false, null, null);
|
||||
}
|
||||
return (true, longTuple, shortTuple);
|
||||
}
|
||||
|
||||
private static IForceTuple GetTupleByCombination(List<IDesignForceTuple> combinations, LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
return combinations
|
||||
.Where(x => x.LimitState == limitState & x.CalcTerm == calcTerm)
|
||||
.Single()
|
||||
.ForceTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public interface IGetTupleInputDatasLogic : ILogic, IHasPrimitives, IHasForceCombinations
|
||||
{
|
||||
LimitStates LimitState { get; set; }
|
||||
CalcTerms LongTerm { get; set; }
|
||||
CalcTerms ShortTerm { get; set; }
|
||||
List<TupleCrackInputData> GetTupleInputDatas();
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,10 @@ using StructureHelperCommon.Models.Calculators;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthSimpleCalculator : ICalculator
|
||||
public class RebarCrackCalculator : ICalculator
|
||||
{
|
||||
ICrackWidthLogic crackWidthLogic = new CrackWidthLogicSP63();
|
||||
CrackWidthSimpleCalculatorResult result;
|
||||
RebarCrackResult result;
|
||||
public string Name { get; set; }
|
||||
public ICrackWidthSimpleCalculatorInputData InputData { get; set; }
|
||||
public IResult Result => result;
|
||||
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthSimpleCalculatorInputData : ICrackWidthSimpleCalculatorInputData
|
||||
public class RebarCrackInputData : ICrackWidthSimpleCalculatorInputData
|
||||
{
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
public StrainTuple StrainTuple { get; set; }
|
||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthSimpleCalculatorResult : IResult
|
||||
public class RebarCrackResult : IResult
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
public string Description { get; set; }
|
||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
@@ -11,37 +12,54 @@ using StructureHelperLogics.Services.NdmPrimitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthCalculator : ICalculator
|
||||
public class TupleCrackCalculator : ICalculator
|
||||
{
|
||||
private static readonly ILengthBetweenCracksLogic lengthLogic = new LengthBetweenCracksLogicSP63();
|
||||
private CrackWidthCalculatorResult result;
|
||||
private TupleCrackResult result;
|
||||
private IEnumerable<INdmPrimitive> ndmPrimitives;
|
||||
private List<RebarPrimitive>? rebarPrimitives;
|
||||
private IEnumerable<INdm> ndmCollection;
|
||||
private IEnumerable<INdm> defaultNdm;
|
||||
private IEnumerable<INdm> fulyCrackedNdm;
|
||||
private CrackForceResult crackForceResult;
|
||||
private StrainTuple strainTuple;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
public string Name { get; set; }
|
||||
public CrackWidthCalculatorInputData InputData { get; set; }
|
||||
public TupleCrackInputData InputData { get; set; }
|
||||
public IResult Result => result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public void Run()
|
||||
{
|
||||
result = new() { IsValid = true, Description = ""};
|
||||
PrepareNewResult();
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
|
||||
|
||||
try
|
||||
{
|
||||
ProcessCalculations();
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += ex;
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationError + ex, TraceLogStatuses.Error);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PrepareNewResult()
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
IsValid = true,
|
||||
Description = string.Empty
|
||||
};
|
||||
}
|
||||
|
||||
private void ProcessCalculations()
|
||||
{
|
||||
CheckInputData();
|
||||
@@ -49,12 +67,16 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
CalcStrainMatrix();
|
||||
CalcCrackForce();
|
||||
var crackInputData = GetCrackInputData();
|
||||
var calculator = new CrackWidthSimpleCalculator { InputData = crackInputData };
|
||||
var calculator = new RebarCrackCalculator
|
||||
{
|
||||
InputData = crackInputData,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
foreach (var item in rebarPrimitives)
|
||||
{
|
||||
crackInputData.RebarPrimitive = item;
|
||||
calculator.Run();
|
||||
var rebarResult = calculator.Result as CrackWidthSimpleCalculatorResult;
|
||||
var rebarResult = calculator.Result as RebarCrackResult;
|
||||
//if (crackForceResult.IsSectionCracked == false)
|
||||
//{
|
||||
// rebarResult.CrackWidth = 0d;
|
||||
@@ -65,19 +87,19 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
|
||||
private void CalcStrainMatrix()
|
||||
{
|
||||
IForceTupleInputData inputData = new ForceTupleInputData() { NdmCollection = ndmCollection, Tuple = InputData.LongTermTuple};
|
||||
IForceTupleInputData inputData = new ForceTupleInputData() { NdmCollection = defaultNdm, Tuple = InputData.LongTermTuple};
|
||||
IForceTupleCalculator calculator = new ForceTupleCalculator() { InputData = inputData };
|
||||
calculator.Run();
|
||||
var forceResult = calculator.Result as IForcesTupleResult;
|
||||
strainTuple = TupleConverter.ConvertToStrainTuple(forceResult.LoaderResults.StrainMatrix);
|
||||
}
|
||||
|
||||
private CrackWidthSimpleCalculatorInputData GetCrackInputData()
|
||||
private RebarCrackInputData GetCrackInputData()
|
||||
{
|
||||
lengthLogic.NdmCollection = ndmCollection;
|
||||
lengthLogic.NdmCollection = defaultNdm;
|
||||
lengthLogic.StrainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(strainTuple);
|
||||
var length = lengthLogic.GetLength();
|
||||
var crackInputData = new CrackWidthSimpleCalculatorInputData
|
||||
var crackInputData = new RebarCrackInputData
|
||||
{
|
||||
PsiSFactor = crackForceResult.PsiS,
|
||||
Length = length,
|
||||
@@ -97,14 +119,21 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
rebarPrimitives.Add(item as RebarPrimitive);
|
||||
}
|
||||
}
|
||||
ndmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitStates.SLS, CalcTerms.ShortTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = CalcTerms.ShortTerm,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
defaultNdm = triangulateLogic.GetNdms();
|
||||
}
|
||||
|
||||
private void CalcCrackForce()
|
||||
{
|
||||
var calculator = new CrackForceCalculator();
|
||||
calculator.EndTuple = InputData.LongTermTuple;
|
||||
calculator.NdmCollection = ndmCollection;
|
||||
calculator.NdmCollection = defaultNdm;
|
||||
calculator.Run();
|
||||
crackForceResult = calculator.Result as CrackForceResult;
|
||||
}
|
||||
@@ -10,10 +10,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthCalculatorInputData : IInputData
|
||||
public class TupleCrackInputData : IInputData
|
||||
{
|
||||
public IForceTuple LongTermTuple { get; set; }
|
||||
public IForceTuple ShortTermTuple { get; set; }
|
||||
public List<INdmPrimitive> NdmPrimitives {get;set;}
|
||||
public bool IsValid { get; set; }
|
||||
public IForceTuple? LongTermTuple { get; set; }
|
||||
public IForceTuple? ShortTermTuple { get; set; }
|
||||
public List<INdmPrimitive>? NdmPrimitives {get;set;}
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthCalculatorResult : IResult
|
||||
public class TupleCrackResult : IResult
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
public string Description { get; set; }
|
||||
public IForceTuple LongTermTuple { get; set; }
|
||||
public IForceTuple ShortTermTuple { get; set; }
|
||||
public bool IsCracked { get; set; }
|
||||
public List<CrackWidthSimpleCalculatorResult> RebarResults { get; set; }
|
||||
public List<RebarCrackResult> RebarResults { get; set; }
|
||||
public double MaxLongTermCrackWidth => IsCracked? RebarResults.Select(x => x.LongTermResult.CrackWidth).Max() : 0d;
|
||||
public double MaxShortTermCrackWidth => IsCracked? RebarResults.Select(x => x.ShortTermResult.CrackWidth).Max() : 0d;
|
||||
|
||||
public CrackWidthCalculatorResult()
|
||||
public TupleCrackResult()
|
||||
{
|
||||
RebarResults = new List<CrackWidthSimpleCalculatorResult>();
|
||||
RebarResults = new ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
public interface IHasPrimitives
|
||||
{
|
||||
/// <summary>
|
||||
/// Collection of NdmPrimitives
|
||||
/// </summary>
|
||||
List<INdmPrimitive> Primitives { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,18 @@ namespace StructureHelperLogics.Services.NdmCalculations
|
||||
public class CalculationService
|
||||
{
|
||||
private ICalculationProperty calculationProperty;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
public IStrainMatrix GetPrimitiveStrainMatrix(INdmPrimitive[] ndmPrimitives, double mx, double my, double nz)
|
||||
{
|
||||
var ndmCollection = new List<INdm>();
|
||||
ndmCollection.AddRange(NdmPrimitivesService.GetNdms(ndmPrimitives, calculationProperty.LimitState, calculationProperty.CalcTerm));
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = calculationProperty.LimitState,
|
||||
CalcTerm = calculationProperty.CalcTerm
|
||||
};
|
||||
ndmCollection.AddRange(triangulateLogic.GetNdms());
|
||||
var loaderData = new LoaderOptions
|
||||
{
|
||||
Preconditions = new Preconditions
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
{
|
||||
public interface ITriangulatePrimitiveLogic : ILogic
|
||||
{
|
||||
IEnumerable<INdmPrimitive> Primitives { get; set; }
|
||||
LimitStates LimitState { get; set; }
|
||||
CalcTerms CalcTerm { get; set; }
|
||||
List<INdm> GetNdms();
|
||||
bool CheckPrimitives(IEnumerable<INdmPrimitive> primitives);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
|
||||
namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
{
|
||||
public static class NdmPrimitivesService
|
||||
{
|
||||
public static List<INdm> GetNdms(IEnumerable<INdmPrimitive> primitives, LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
var orderedNdmPrimitives = primitives.OrderBy(x => x.VisualProperty.ZIndex);
|
||||
var ndms = new List<INdm>();
|
||||
var triangulationOptions = new TriangulationOptions() { LimiteState = limitState, CalcTerm = calcTerm };
|
||||
foreach (var item in orderedNdmPrimitives)
|
||||
{
|
||||
if (item is IHasDivisionSize)
|
||||
{
|
||||
var hasDivision = item as IHasDivisionSize;
|
||||
if (hasDivision.ClearUnderlying == true)
|
||||
{
|
||||
ndms.RemoveAll(x => hasDivision.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true);
|
||||
}
|
||||
}
|
||||
if (item.Triangulate == true)
|
||||
{
|
||||
ndms.AddRange(item.GetNdms(triangulationOptions));
|
||||
}
|
||||
}
|
||||
return ndms;
|
||||
}
|
||||
|
||||
public static bool CheckPrimitives(IEnumerable<INdmPrimitive> primitives)
|
||||
{
|
||||
if (!primitives.Any())
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero");
|
||||
}
|
||||
if (!primitives.Any(x => x.Triangulate == true))
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate");
|
||||
}
|
||||
foreach (var item in primitives)
|
||||
{
|
||||
if (item.Triangulate == true &
|
||||
item.HeadMaterial is null)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
|
||||
namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
{
|
||||
public class TriangulatePrimitiveLogic : ITriangulatePrimitiveLogic
|
||||
{
|
||||
private List<INdm> ndmCollection;
|
||||
|
||||
public IEnumerable<INdmPrimitive> Primitives { get; set; }
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
public bool ConsiderCracking { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public TriangulatePrimitiveLogic()
|
||||
{
|
||||
ConsiderCracking = false;
|
||||
}
|
||||
public List<INdm> GetNdms()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Total count of primitives n = {Primitives.Count()}", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Limit state is {LimitState}", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Calc term is {CalcTerm}", TraceLogStatuses.Service);
|
||||
var orderedNdmPrimitives = Primitives.OrderBy(x => x.VisualProperty.ZIndex);
|
||||
ndmCollection = new List<INdm>();
|
||||
foreach (var item in orderedNdmPrimitives)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Triangulation of primitive {item.Name} has started", TraceLogStatuses.Service);
|
||||
ProcessHasDivision(item);
|
||||
TriangulatePrimitive(item);
|
||||
}
|
||||
if (TraceLogger is not null)
|
||||
{
|
||||
TraceService.TraceNdmCollection(TraceLogger, ndmCollection);
|
||||
}
|
||||
return ndmCollection;
|
||||
}
|
||||
|
||||
private void TriangulatePrimitive(INdmPrimitive item)
|
||||
{
|
||||
if (item.Triangulate == true)
|
||||
{
|
||||
var triangulationOptions = new TriangulationOptions()
|
||||
{
|
||||
LimiteState = LimitState,
|
||||
CalcTerm = CalcTerm
|
||||
};
|
||||
var itemNdms = item.GetNdms(triangulationOptions);
|
||||
ndmCollection.AddRange(itemNdms);
|
||||
TraceLogger?.AddMessage($"Triangulation of primitive {item.Name} was finished, {itemNdms.Count()} part(s) were obtained", TraceLogStatuses.Service);
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceLogger?.AddMessage($"Triangulation of primitive was skiped cause its settings", TraceLogStatuses.Service);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessHasDivision(INdmPrimitive? item)
|
||||
{
|
||||
if (item is IHasDivisionSize hasDivision)
|
||||
{
|
||||
if (hasDivision.ClearUnderlying == true)
|
||||
{
|
||||
TraceLogger?.AddMessage("Removing of background part has started", TraceLogStatuses.Service);
|
||||
ndmCollection
|
||||
.RemoveAll(x =>
|
||||
hasDivision
|
||||
.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckPrimitives(IEnumerable<INdmPrimitive> primitives)
|
||||
{
|
||||
if (!primitives.Any())
|
||||
{
|
||||
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
if (!primitives.Any(x => x.Triangulate == true))
|
||||
{
|
||||
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
foreach (var item in primitives)
|
||||
{
|
||||
if (item.Triangulate == true &
|
||||
item.HeadMaterial is null)
|
||||
{
|
||||
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.CrackCalculatorT
|
||||
{
|
||||
internal class CrackCalculatorTest
|
||||
{
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
[TestCase(0.4d, 0.6d, 0.012d, 0.025d, 2, 2, 0.81d)]
|
||||
public void Run_ShouldPass(double width, double height, double topDiametr, double bottomDiametr, int widthCount, int heightCount, double expectedFactor)
|
||||
{
|
||||
@@ -25,7 +27,13 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.CrackCalculatorT
|
||||
var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount };
|
||||
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
|
||||
var ndmPrimitives = newSection.SectionRepository.Primitives;
|
||||
var ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitStates.SLS, CalcTerms.ShortTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
var calculator = new CrackForceCalculator();
|
||||
calculator.EndTuple = new ForceTuple() { Mx = -50e3d, My = -50e3d, Nz = 0d };
|
||||
calculator.NdmCollection = ndms;
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
public class RectangleTriangulationTest
|
||||
{
|
||||
private Mock<IHeadMaterial> materialMock;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
@@ -75,7 +77,13 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
opening.VisualProperty.ZIndex = 1;
|
||||
var primitives = new List<INdmPrimitive>() { mainBlock, opening };
|
||||
//Act
|
||||
var ndms = NdmPrimitivesService.GetNdms(primitives, LimitStates.ULS, CalcTerms.ShortTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = primitives,
|
||||
LimitState = LimitStates.ULS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
//Assert
|
||||
var area = ndms.Sum(x => x.Area);
|
||||
var moments = GeometryOperations.GetReducedMomentsOfInertia(ndms);
|
||||
@@ -106,7 +114,13 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
opening.VisualProperty.ZIndex = 1;
|
||||
var primitives = new List<INdmPrimitive>() { mainBlock, opening };
|
||||
//Act
|
||||
var ndms = NdmPrimitivesService.GetNdms(primitives, LimitStates.ULS, CalcTerms.ShortTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = primitives,
|
||||
LimitState = LimitStates.ULS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
//Assert
|
||||
var area = ndms.Sum(x => x.Area);
|
||||
var moments = GeometryOperations.GetReducedMomentsOfInertia(ndms);
|
||||
@@ -138,7 +152,13 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
|
||||
opening.VisualProperty.ZIndex = 1;
|
||||
var primitives = new List<INdmPrimitive>() { mainBlock, opening };
|
||||
//Act
|
||||
var ndms = NdmPrimitivesService.GetNdms(primitives, LimitStates.ULS, CalcTerms.ShortTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = primitives,
|
||||
LimitState = LimitStates.ULS,
|
||||
CalcTerm = CalcTerms.ShortTerm
|
||||
};
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
//Assert
|
||||
var area = ndms.Sum(x => x.Area);
|
||||
var moments = GeometryOperations.GetReducedMomentsOfInertia(ndms);
|
||||
|
||||
Reference in New Issue
Block a user