Add trace crack result

This commit is contained in:
Evgeny Redikultsev
2024-12-30 15:42:57 +05:00
parent ba70e0d214
commit 65253a907b
42 changed files with 685 additions and 125 deletions

View File

@@ -1,15 +1,8 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Sections;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{

View File

@@ -53,24 +53,16 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private void TraceInputData()
{
TracePrimitiveFactory tracePrimitiveFactory = new()
ITraceEntityLogic tracelogic = new TracePrimitiveFactory()
{
Collection = InputData.Primitives
};
List<ITraceLoggerEntry> traceEntries = tracePrimitiveFactory.GetTraceEntries();
foreach (var item in traceEntries)
{
TraceLogger?.AddEntry(item);
}
TraceMaterialsFactory traceMaterialFactory = new()
tracelogic.AddEntriesToTraceLogger(TraceLogger);
tracelogic = new TraceMaterialsFactory()
{
Collection = InputData.Primitives.Select(x => x.NdmElement.HeadMaterial).Distinct()
};
traceEntries = traceMaterialFactory.GetTraceEntries();
foreach (var item in traceEntries)
{
TraceLogger?.AddEntry(item);
}
tracelogic.AddEntriesToTraceLogger(TraceLogger);
}
private void CalculateResult()

View File

@@ -32,7 +32,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
public void Update(IForceCalculator targetObject, IForceCalculator sourceObject)
{
var project = ProgramSetting.CurrentProject;
CheckObject.IsNull(cloningStrategy);
CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject);

View File

@@ -2,16 +2,11 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.ResultData;
using LoaderCalculator.Logics;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Infrastructures.Exceptions;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{

View File

@@ -46,7 +46,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public void Update(IHasCalculators targetObject, IHasCalculators sourceObject)
{
var project = ProgramSetting.CurrentProject;
CheckObject.IsNull(cloningStrategy);
CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject);

View File

@@ -0,0 +1,182 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Tables;
using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class TraceCrackResultLogic : ITraceCollectionLogic<ITupleCrackResult>
{
private List<ITraceLoggerEntry> traceLoggerEntries;
private const int rowSize = 4;
public IEnumerable<ITupleCrackResult>? Collection { get; set; }
public int Priority { get; set; } = LoggerService.GetPriorityByStatus(TraceLogStatuses.Info);
public void AddEntriesToTraceLogger(IShiftTraceLogger traceLogger)
{
var entries = GetTraceEntries();
entries.ForEach(x => traceLogger?.AddEntry(x));
}
public List<ITraceLoggerEntry> GetTraceEntries()
{
Check();
traceLoggerEntries = new();
traceLoggerEntries.Add(new StringLogEntry()
{
Message = $"There are totally {Collection.Count()} result(s), {Collection.Count(x => x.IsValid == true)} valid result(s), {Collection.Count(x => x.IsValid == false)} invalid result(s)",
Priority = Priority
}
);
ProcessCollection();
return traceLoggerEntries;
}
private void ProcessCollection()
{
foreach (var item in Collection)
{
int priority = Priority;
if (item.IsValid == false)
{
priority = LoggerService.GetPriorityByStatus(TraceLogStatuses.Error);
}
var message = new StringLogEntry()
{
Message = "Force combination: " + item.InputData.TupleName,
Priority = priority
};
traceLoggerEntries.Add(message);
if (item.IsValid == false)
{
var errorMessage = new StringLogEntry()
{
Message = "Calculation is not valid: " + item.Description,
Priority = priority
};
traceLoggerEntries.Add(errorMessage);
continue;
}
var table = new TableLogEntry(rowSize)
{
Priority = Priority
};
table.ColumnWidth[0] = 100;
table.ColumnWidth[1] = 250;
table.ColumnWidth[2] = 250;
table.ColumnWidth[3] = 100;
table.Table.AddRow(GetHeader(item));
List<IShTableRow<ITraceLoggerEntry>> rows = ProcessTupleCrackResult(item);
rows.ForEach(x => table.Table.AddRow(x));
traceLoggerEntries.Add(table);
if (item.IsValid == true)
{
ProcessRebars(item);
}
}
}
private void ProcessRebars(ITupleCrackResult item)
{
ITraceEntityLogic traceEntityLogic = new TraceRebarCrackResultLogic() { Collection = item.RebarResults };
traceLoggerEntries.AddRange(traceEntityLogic.GetTraceEntries());
}
private List<IShTableRow<ITraceLoggerEntry>> ProcessTupleCrackResult(ITupleCrackResult item)
{
List<IShTableRow<ITraceLoggerEntry>> rows = new();
int priority = Priority;
if (item.IsValid == false)
{
priority = LoggerService.GetPriorityByStatus(TraceLogStatuses.Error);
if (item.LongTermResult is null || item.ShortTermResult is null)
{
return rows;
}
}
ShTableRow<ITraceLoggerEntry> row;
string? description = item.Description;
string termName = "Long term";
IForceTuple? tuple = item.InputData.LongTermTuple;
row = GetTupleRow(priority, termName, tuple, item.LongTermResult);
rows.Add(row);
termName = "Short term";
tuple = item.InputData.ShortTermTuple;
row = GetTupleRow(priority, termName, tuple, item.ShortTermResult);
rows.Add(row);
return rows;
}
private ShTableRow<ITraceLoggerEntry> GetTupleRow(int priority, string longTermName, IForceTuple? tuple, CrackWidthRebarTupleResult rebarResult)
{
ShTableRow<ITraceLoggerEntry> ndmRow;
ndmRow = new(rowSize);
string description = string.Empty;
if (rebarResult.IsCrackLessThanUltimate == false)
{
description = "Actual crack width is greater than ultimate one";
priority = LoggerService.GetPriorityByStatus(TraceLogStatuses.Error);
}
ndmRow.Elements[0].Value = new StringLogEntry()
{
Message = longTermName,
Priority = priority
};
ndmRow.Elements[1].Value = new StringLogEntry()
{
Message = TraceStringService.GetForces(tuple),
Priority = priority
};
ndmRow.Elements[2].Value = new StringLogEntry()
{
Message = $" Acrc = {rebarResult.CrackWidth}(m),\nAcrc,ult=({rebarResult.UltimateCrackWidth}(m))",
Priority = priority
};
ndmRow.Elements[3].Value = new StringLogEntry()
{
Message = description,
Priority = priority
};
return ndmRow;
}
private IShTableRow<ITraceLoggerEntry> GetHeader(ITupleCrackResult tupleCrackResult)
{
const CellRole cellRole = CellRole.Header;
string[] ColumnList = new string[]
{
"Calc term",
"Forces",
"Crack width",
"Description"
};
var ndmRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
ndmRow.Elements.ForEach(x => x.Role = cellRole);
for (int i = 0; i < rowSize; i++)
{
ndmRow.Elements[i].Value = new StringLogEntry()
{
Message = ColumnList[i],
Priority = Priority
};
}
return ndmRow;
}
private void Check()
{
if (Collection is null)
{
throw new StructureHelperException(ErrorStrings.ParameterIsNull + ": Collection of primitives");
}
}
}
}

View File

@@ -0,0 +1,26 @@
using StructureHelperCommon.Models;
using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
internal class TraceCrackWidthTupleResultLogic : ITraceCollectionLogic<ITupleCrackResult>
{
public IEnumerable<ITupleCrackResult>? Collection { get; set; }
public int Priority { get; set; } = LoggerService.GetPriorityByStatus(TraceLogStatuses.Info);
public void AddEntriesToTraceLogger(IShiftTraceLogger traceLogger)
{
throw new NotImplementedException();
}
public List<ITraceLoggerEntry> GetTraceEntries()
{
throw new NotImplementedException();
}
}
}

View File

@@ -11,7 +11,10 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class TraceForcesResultLogic : ITraceEntityFactory<IForcesTupleResult>
/// <summary>
/// Provides trace logger inforvation for collection of force tuple results
/// </summary>
public class TraceForcesResultLogic : ITraceCollectionLogic<IForcesTupleResult>
{
const int rowSize = 4;
private List<ITraceLoggerEntry> traceLoggerEntries;
@@ -60,19 +63,19 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
ndmRow = new(rowSize);
ndmRow.Elements[0].Value = new StringLogEntry()
{
Message = "Limit state: " + item.DesignForceTuple.LimitState.ToString() + ", Calculation term: " + item.DesignForceTuple.CalcTerm,
Message = TraceStringService.GetLimitStateAndCalctTerm(item.DesignForceTuple),
Priority = priority
};
ndmRow.Elements[1].Value = new StringLogEntry()
{
Message = "Mx = " + item.DesignForceTuple.ForceTuple.Mx.ToString() + "N*m, My = " + item.DesignForceTuple.ForceTuple.My.ToString() + "N*m, Nz =" + item.DesignForceTuple.ForceTuple.Nz.ToString() + "N, ",
Message = TraceStringService.GetForces(item.DesignForceTuple.ForceTuple),
Priority = priority
};
if (item.LoaderResults is not null)
{
ndmRow.Elements[2].Value = new StringLogEntry()
{
Message = "Kx = " + item.LoaderResults.StrainMatrix.Kx + "(1/m), Ky = " + item.LoaderResults.StrainMatrix.Ky + "(1/m), EpsZ = " + item.LoaderResults.StrainMatrix.EpsZ + "(dimensionless)",
Message = TraceStringService.GetCuvatures(item.LoaderResults.ForceStrainPair.StrainMatrix),
Priority = priority
};
}
@@ -96,10 +99,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
"Description"
};
var ndmRow = new ShTableRow<ITraceLoggerEntry>(rowSize);
foreach (var item in ndmRow.Elements)
{
item.Role = cellRole;
}
ndmRow.Elements.ForEach(x => x.Role = cellRole);
for (int i = 0; i < rowSize; i++)
{
@@ -119,5 +119,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
throw new StructureHelperException(ErrorStrings.ParameterIsNull + ": Collection of primitives");
}
}
public void AddEntriesToTraceLogger(IShiftTraceLogger traceLogger)
{
var entries = GetTraceEntries();
entries.ForEach(x => traceLogger?.AddEntry(x));
}
}
}

View File

@@ -0,0 +1,35 @@
using LoaderCalculator.Data.Matrix;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public static class TraceStringService
{
public static string GetLimitStateAndCalctTerm(IDesignForceTuple designForceTuple)
{
string s = "Limit state: " + designForceTuple.LimitState.ToString();
s += ", Calculation term: " + designForceTuple.CalcTerm;
return s;
}
public static string GetForces(IForceTuple forceTuple)
{
string s = "Mx = " + forceTuple.Mx.ToString();
s += "(N*m), My = " + forceTuple.My.ToString();
s += "(N*m), Nz =" + forceTuple.Nz.ToString() + "(N), ";
return s;
}
public static string GetCuvatures(IStrainMatrix strainMatrix)
{
string s = "Kx = " + strainMatrix.Kx;
s += "(1/m), Ky = " + strainMatrix.Ky;
s += "(1/m), EpsZ = " + strainMatrix.EpsZ + "(dimensionless)";
return s;
}
}
}