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

@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-12-27T08:24:44.0055462Z||;True|2024-11-13T09:16:22.8894163+05:00||;True|2024-08-13T14:00:35.8311260+05:00||;True|2024-08-12T12:59:16.1785759+05:00||;True|2024-03-11T20:33:14.1457807+05:00||;True|2024-03-10T19:11:27.6834663+05:00||;True|2024-02-02T12:22:50.1454015+05:00||;True|2023-02-25T13:37:39.2738786+05:00||;False|2023-02-25T13:37:24.0284261+05:00||;True|2023-02-25T13:34:01.6858860+05:00||;True|2023-02-25T13:31:18.8295711+05:00||;False|2023-02-25T13:25:21.5807199+05:00||;False|2023-02-25T13:24:41.7164398+05:00||;</History>
<History>True|2024-12-29T15:48:11.7280613Z;True|2024-12-27T13:24:44.0055462+05:00;True|2024-11-13T09:16:22.8894163+05:00;True|2024-08-13T14:00:35.8311260+05:00;True|2024-08-12T12:59:16.1785759+05:00;True|2024-03-11T20:33:14.1457807+05:00;True|2024-03-10T19:11:27.6834663+05:00;True|2024-02-02T12:22:50.1454015+05:00;True|2023-02-25T13:37:39.2738786+05:00;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@@ -7,11 +7,11 @@ using System.Threading.Tasks;
namespace StructureHelper.Services.ResultViewers
{
public class CrackResultFunc : IResultFunc<Func<RebarCrackResult, double>>
public class CrackResultFunc : IResultFunc<Func<IRebarCrackResult, double>>
{
public string Name { get; set; }
public Func<RebarCrackResult, double> ResultFunction { get; set; }
public Func<IRebarCrackResult, double> ResultFunction { get; set; }
public string UnitName { get; set; }

View File

@@ -25,70 +25,70 @@ namespace StructureHelper.Services.ResultViewers
new()
{
Name = "Long crack width",
ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.CrackWidth,
ResultFunction = (IRebarCrackResult rebar) => rebar.LongTermResult.CrackWidth,
UnitFactor = unitLength.Multiplyer,
UnitName = unitLength.Name
},
new()
{
Name = "Short crack width",
ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.CrackWidth,
ResultFunction = (IRebarCrackResult rebar) => rebar.ShortTermResult.CrackWidth,
UnitFactor = unitLength.Multiplyer,
UnitName = unitLength.Name
},
new()
{
Name = "Long softening factor",
ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.SofteningFactor,
ResultFunction = (IRebarCrackResult rebar) => rebar.LongTermResult.SofteningFactor,
UnitFactor = 1,
UnitName = "Dimensionless"
},
new()
{
Name = "Short softening factor",
ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.SofteningFactor,
ResultFunction = (IRebarCrackResult rebar) => rebar.ShortTermResult.SofteningFactor,
UnitFactor = 1,
UnitName = "Dimensionless"
},
new()
{
Name = "Long rebar stress",
ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.RebarStress,
ResultFunction = (IRebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.RebarStress,
UnitFactor = unitStress.Multiplyer,
UnitName = unitStress.Name
},
new()
{
Name = "Short rebar stress",
ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.RebarStress,
ResultFunction = (IRebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.RebarStress,
UnitFactor = unitStress.Multiplyer,
UnitName = unitStress.Name
},
new()
{
Name = "Long rebar strain",
ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.RebarStrain,
ResultFunction = (IRebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.RebarStrain,
UnitFactor = 1d,
UnitName = string.Empty
},
new()
{
Name = "Short rebar strain",
ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.RebarStrain,
ResultFunction = (IRebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.RebarStrain,
UnitFactor = 1d,
UnitName = string.Empty
},
new()
{
Name = "Long concrete strain",
ResultFunction = (RebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.ConcreteStrain,
ResultFunction = (IRebarCrackResult rebar) => rebar.LongTermResult.RebarStressResult.ConcreteStrain,
UnitFactor = 1d,
UnitName = string.Empty
},
new()
{
Name = "Short concrete strain",
ResultFunction = (RebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.ConcreteStrain,
ResultFunction = (IRebarCrackResult rebar) => rebar.ShortTermResult.RebarStressResult.ConcreteStrain,
UnitFactor = 1d,
UnitName = string.Empty
}

View File

@@ -42,7 +42,7 @@ namespace StructureHelper.Services.ResultViewers
return primitiveSets;
}
public static List<IPrimitiveSet> GetPrimitiveSets(IEnumerable<RebarCrackResult> rebarResults, IEnumerable<CrackResultFunc> resultFuncs)
public static List<IPrimitiveSet> GetPrimitiveSets(IEnumerable<IRebarCrackResult> rebarResults, IEnumerable<CrackResultFunc> resultFuncs)
{
List<IPrimitiveSet> primitiveSets = new List<IPrimitiveSet>();
foreach (var valDelegate in resultFuncs)
@@ -59,7 +59,7 @@ namespace StructureHelper.Services.ResultViewers
return primitiveSets;
}
private static IValuePrimitive ProcessNdm(CrackResultFunc valDelegate, RebarCrackResult rebarResult)
private static IValuePrimitive ProcessNdm(CrackResultFunc valDelegate, IRebarCrackResult rebarResult)
{
double delegateResult = valDelegate.ResultFunction.Invoke(rebarResult);
var val = delegateResult * valDelegate.UnitFactor;

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>D:\Repos\StructureHelper\StructureHelper\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
<_LastSelectedProfileId>C:\Source\Repos\StructureHelper\StructureHelper\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Update="App.xaml">

View File

@@ -17,7 +17,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
private RelayCommand? showRebarsCommand;
public TupleCrackResult SelectedResult { get; set; }
public List<TupleCrackResult> TupleResults => CrackResult.TupleResults;
public List<ITupleCrackResult> TupleResults => CrackResult.TupleResults;
public ICommand ShowRebarsCommand
{
get

View File

@@ -5,6 +5,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
public interface IShowCrackIsoFieldsLogic
{
void ShowIsoField(IEnumerable<RebarCrackResult> rebarResults);
void ShowIsoField(IEnumerable<IRebarCrackResult> rebarResults);
}
}

View File

@@ -15,7 +15,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{
private IsoFieldReport isoFieldReport;
public void ShowIsoField(IEnumerable<RebarCrackResult> rebarResults)
public void ShowIsoField(IEnumerable<IRebarCrackResult> rebarResults)
{
try
{

View File

@@ -25,7 +25,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
private IsoFieldReport isoFieldReport;
public TupleCrackResult CrackResult => crackResult;
public List<RebarCrackResult> RebarResults => crackResult.RebarResults;
public List<IRebarCrackResult> RebarResults => crackResult.RebarResults;
public RebarCrackResult SelectedResult { get; set; }
public string WindowTitle => "Result of calculation of cracks for action " + crackResult.InputData.TupleName;
public ICommand ShowIsoFieldCommand

View File

@@ -101,7 +101,12 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
private Block GetBlockByEntry(ITraceLoggerEntry traceEntry)
{
Block block;
if (traceEntry is StringLogEntry stringEntry)
if (traceEntry is null)
{
block = new Paragraph(new Run("---"));
return block;
}
else if (traceEntry is StringLogEntry stringEntry)
{
block = GetBlockByStringEntry(stringEntry);
}

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow.Analyses"
d:DataContext="{d:DesignInstance local:AnalysisViewModel}"
mc:Ignorable="d"
Title="Analysis" Height="250" Width="300" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
Title="Analysis properties" Height="350" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
@@ -15,20 +15,20 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="75"/>
<RowDefinition Height="75"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Name"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding Name}"/>
<GroupBox Grid.Row="1" Grid.ColumnSpan="2" Header="Tags">
<TextBox Margin="1" Text="{Binding Tags}"/>
<TextBox Grid.Row="1" Margin="1" Text="{Binding Name}" TextWrapping="Wrap"/>
<GroupBox Grid.Row="2" Header="Tags">
<TextBox Margin="1" Text="{Binding Tags}" TextWrapping="Wrap"/>
</GroupBox>
<GroupBox Grid.Row="2" Grid.ColumnSpan="2" Header="Comment">
<TextBox Margin="1" Text="{Binding Comment}"/>
<GroupBox Grid.Row="3" Header="Comment">
<TextBox Margin="1" Text="{Binding Comment}" TextWrapping="Wrap"/>
</GroupBox>
</Grid>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>

View File

@@ -1,8 +1,15 @@
using System.Collections.Generic;
using StructureHelperCommon.Models.Forces;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Interface for entities which has collection of force actions
/// </summary>
public interface IHasForceActions
{
/// <summary>

View File

@@ -2,12 +2,14 @@
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Interface for entities which able to save (has unique identifier)
/// </summary>
public interface ISaveable
{
/// <summary>
/// Unique identifier
/// </summary>
Guid Id { get;}
//void Save();
}
}

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperCommon.Models
{
public interface ITraceCollectionLogic<T> : ITraceEntityLogic
{
IEnumerable<T>? Collection { get; set; }
int Priority { get; set; }
}
}

View File

@@ -1,13 +0,0 @@
using StructureHelperCommon.Models;
using System.Collections.Generic;
namespace StructureHelperCommon.Models
{
public interface ITraceEntityFactory<T> where T : class
{
IEnumerable<T>? Collection { get; set; }
int Priority { get; set; }
List<ITraceLoggerEntry> GetTraceEntries();
}
}

View File

@@ -0,0 +1,28 @@
using System.Collections.Generic;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperCommon.Models
{
/// <summary>
/// Creates collection of entries for trace logger of some entity
/// </summary>
public interface ITraceEntityLogic
{
/// <summary>
/// Default priority for created trace logger entries
/// </summary>
int Priority { get; set; }
/// <summary>
/// Returns list of entries
/// </summary>
/// <returns>List of entries</returns>
List<ITraceLoggerEntry> GetTraceEntries();
/// <summary>
/// Creates new collection of entries and adds it into trace logger
/// </summary>
/// <param name="traceLogger"></param>
void AddEntriesToTraceLogger(IShiftTraceLogger traceLogger);
}
}

View File

@@ -37,7 +37,6 @@ namespace StructureHelperLogic.Models.Analyses
public object Clone()
{
CrossSectionNdmAnalysis newAnalysis = new();
var project = ProgramSetting.CurrentProject;
updateStrategy.Update(newAnalysis, this);
var currentVersion = VersionProcessor.GetCurrentVersion().AnalysisVersion as ICloneable;
ISaveable newCrossSection = currentVersion.Clone() as ISaveable;

View File

@@ -9,8 +9,6 @@ namespace StructureHelperLogics.Models.CrossSections
{
public class CrossSection : ICrossSection
{
private ICloneStrategy<ICrossSection> cloneStrategy;
private IUpdateStrategy<ICrossSection> updateStrategy = new CrossSectionUpdateStrategy();
public ICrossSectionRepository SectionRepository { get; set; } = new CrossSectionRepository();
public Guid Id { get; private set; }
@@ -27,7 +25,7 @@ namespace StructureHelperLogics.Models.CrossSections
public object Clone()
{
cloneStrategy = new CrossSectionCloneStrategy();
ICloneStrategy<ICrossSection> cloneStrategy = new CrossSectionCloneStrategy();
return cloneStrategy.GetClone(this);
}
}

View File

@@ -25,7 +25,6 @@ namespace StructureHelperLogics.Models.CrossSections
public ICrossSection GetClone(ICrossSection sourceObject)
{
var project = ProgramSetting.CurrentProject;
ICrossSectionRepository newRepository = repositoryCloneStrategy.GetClone(sourceObject.SectionRepository);
targetObject = new()
{

View File

@@ -44,7 +44,6 @@ namespace StructureHelperLogics.Models.CrossSections
public ICrossSectionRepository GetClone(ICrossSectionRepository sourceObject)
{
var project = ProgramSetting.CurrentProject;
targetRepository = new();
forcesUpdateStrategy.Update(targetRepository, sourceObject);
materialsUpdateStrategy.Update(targetRepository, sourceObject);

View File

@@ -15,7 +15,7 @@ using System.Windows.Shapes;
namespace StructureHelperLogics.Models.Materials
{
public class TraceMaterialsFactory : ITraceEntityFactory<IHeadMaterial>
public class TraceMaterialsFactory : ITraceCollectionLogic<IHeadMaterial>
{
const int rowSize = 2;
private List<ITraceLoggerEntry> traceLoggerEntries;
@@ -267,5 +267,11 @@ namespace StructureHelperLogics.Models.Materials
rows.Add(ndmRow);
return rows;
}
public void AddEntriesToTraceLogger(IShiftTraceLogger traceLogger)
{
var entries = GetTraceEntries();
entries.ForEach(x => traceLogger?.AddEntry(x));
}
}
}

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;
}
}
}

View File

@@ -0,0 +1,192 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Tables;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses
{
internal class TraceRebarCrackResultLogic : ITraceCollectionLogic<IRebarCrackResult>
{
private List<ITraceLoggerEntry> traceLoggerEntries;
private TableLogEntry table;
private const int resultRowSize = 4;
private const int rebarRowSize = 2;
private const int calctTermColumnWidth = 80;
private const int elongationColumnWidth = 200;
private const int psiSColumnWidth = 200;
private const int crackWidthColumnWidth = 250;
public IEnumerable<IRebarCrackResult>? 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();
ProcessCollection();
return traceLoggerEntries;
}
private void ProcessCollection()
{
var message = new StringLogEntry()
{
Message = "Results by rebars",
Priority = Priority
};
traceLoggerEntries.Add(message);
table = new TableLogEntry(rebarRowSize)
{
Priority = Priority
};
table.ColumnWidth[0] = 100;
table.ColumnWidth[1] = calctTermColumnWidth + elongationColumnWidth + psiSColumnWidth + crackWidthColumnWidth;
table.Table.AddRow(GetHeader());
foreach (var item in Collection)
{
List<IShTableRow<ITraceLoggerEntry>> rows = ProcessRebar(item);
rows.ForEach(x => table.Table.AddRow(x));
}
traceLoggerEntries.Add(table);
}
private List<IShTableRow<ITraceLoggerEntry>> ProcessRebar(IRebarCrackResult item)
{
List<IShTableRow<ITraceLoggerEntry>> rows = new();
IShTableRow<ITraceLoggerEntry> rebarRow = new ShTableRow<ITraceLoggerEntry>(rebarRowSize);
rebarRow.Elements[0].Value = new StringLogEntry()
{
Message = item.RebarPrimitive.Name,
Priority = Priority
};
rebarRow.Elements[1].Value = GetResultTable(item);
rows.Add(rebarRow);
return rows;
}
private TableLogEntry GetResultTable(IRebarCrackResult item)
{
TableLogEntry resultTable = new(4) { Priority = Priority};
resultTable.ColumnWidth[0] = calctTermColumnWidth;
resultTable.ColumnWidth[1] = elongationColumnWidth;
resultTable.ColumnWidth[2] = psiSColumnWidth;
resultTable.ColumnWidth[3] = crackWidthColumnWidth;
ShTableRow<ITraceLoggerEntry> resultRow;
string termName = "Long term";
CrackWidthRebarTupleResult rebarResult = item.LongTermResult;
resultRow = GetResultCalcRow(termName, rebarResult);
resultTable.Table.AddRow(resultRow);
termName = "Short term";
rebarResult = item.ShortTermResult;
resultRow = GetResultCalcRow(termName, rebarResult);
resultTable.Table.AddRow(resultRow);
return resultTable;
}
private ShTableRow<ITraceLoggerEntry> GetResultCalcRow(string longTermName, CrackWidthRebarTupleResult rebarResult)
{
ShTableRow<ITraceLoggerEntry> row;
row = new(resultRowSize);
int priority = Priority;
//if (item.IsValid == false)
//{
// priority = LoggerService.GetPriorityByStatus(TraceLogStatuses.Error);
//}
row.Elements[0].Value = new StringLogEntry()
{
Message = longTermName,
Priority = priority
};
double elongation = rebarResult.RebarStressResult.RebarStrain + rebarResult.RebarStressResult.ConcreteStrain;
row.Elements[1].Value = new StringLogEntry()
{
Message = $"{rebarResult.RebarStressResult.RebarStrain} + ({rebarResult.RebarStressResult.ConcreteStrain}) = {elongation}",
Priority = priority
};
row.Elements[2].Value = new StringLogEntry()
{
Message = $"{rebarResult.SofteningFactor}",
Priority = priority
};
row.Elements[3].Value = new StringLogEntry()
{
Message = $" Acrc = {rebarResult.CrackWidth}(m),\nAcrc,ult=({rebarResult.UltimateCrackWidth}(m))",
Priority = priority
};
return row;
}
private IShTableRow<ITraceLoggerEntry> GetHeader()
{
const CellRole cellRole = CellRole.Header;
string[] ColumnList = new string[]
{
"Rebar",
"Results"
};
var headerRow = new ShTableRow<ITraceLoggerEntry>(rebarRowSize);
headerRow.Elements.ForEach(x => x.Role = cellRole);
for (int i = 0; i < ColumnList.Length; i++)
{
headerRow.Elements[i].Value = new StringLogEntry()
{
Message = ColumnList[i],
Priority = Priority
};
}
TableLogEntry resultTable = new(resultRowSize);
resultTable.ColumnWidth[0] = calctTermColumnWidth;
resultTable.ColumnWidth[1] = elongationColumnWidth;
resultTable.ColumnWidth[2] = psiSColumnWidth;
resultTable.ColumnWidth[3] = crackWidthColumnWidth;
resultTable.Table.AddRow(GetResultHeader());
headerRow.Elements[1].Value = resultTable;
return headerRow;
}
private IShTableRow<ITraceLoggerEntry> GetResultHeader()
{
const CellRole cellRole = CellRole.Header;
string[] ColumnList = new string[]
{
"Calc term",
"Elongation",
"Softening factor",
"Crack width"
};
var ndmRow = new ShTableRow<ITraceLoggerEntry>(resultRowSize);
ndmRow.Elements.ForEach(x => x.Role = cellRole);
for (int i = 0; i < resultRowSize; 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

@@ -5,6 +5,8 @@ using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
@@ -14,6 +16,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <inheritdoc/>
public class CrackCalculator : ICrackCalculator
{
const LimitStates limitState = LimitStates.SLS;
@@ -73,11 +76,11 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{
PrepareNewResult();
CheckInputData();
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceInputData();
try
{
ProcessCalculations();
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
TraceResult();
}
catch (Exception ex)
{
@@ -87,6 +90,31 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
}
}
private void TraceResult()
{
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
ITraceEntityLogic traceLogic = new TraceCrackResultLogic()
{
Collection = result.TupleResults
};
traceLogic.AddEntriesToTraceLogger(TraceLogger);
}
private void TraceInputData()
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
ITraceEntityLogic traceLogic = new TracePrimitiveFactory()
{
Collection = InputData.Primitives
};
traceLogic.AddEntriesToTraceLogger(TraceLogger);
traceLogic = new TraceMaterialsFactory()
{
Collection = InputData.Primitives.Select(x => x.NdmElement.HeadMaterial).Distinct()
};
traceLogic.AddEntriesToTraceLogger(TraceLogger);
}
private void CheckInputData()
{
checkInputDataLogic.InputData = InputData;

View File

@@ -14,7 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{
public bool IsValid { get; set; }
public string? Description { get; set; }
public List<TupleCrackResult> TupleResults {get;set;}
public List<ITupleCrackResult> TupleResults {get;set;}
public CrackResult()
{
TupleResults = new();

View File

@@ -2,8 +2,14 @@
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// Calculates width of cracks for cross-section by collection of combination of forces
/// </summary>
public interface ICrackCalculator : ICalculator
{
/// <summary>
/// Input data for crack calculations
/// </summary>
ICrackCalculatorInputData InputData { get; set; }
}
}

View File

@@ -3,12 +3,19 @@ using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Primitives;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// Input data for crack calculator
/// </summary>
public interface ICrackCalculatorInputData : IInputData, IHasPrimitives, IHasForceActions, ISaveable
{
List<IForceAction> ForceActions { get; }
List<INdmPrimitive> Primitives { get; }
/// <summary>
/// Used difined data for crack width calculation
/// </summary>
IUserCrackInputData UserCrackInputData { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// Result of calculation of crack for specific result
/// </summary>
public interface IRebarCrackResult : IResult
{
/// <summary>
/// Specific rebar primitive
/// </summary>
IRebarNdmPrimitive? RebarPrimitive { get; set; }
/// <summary>
/// Result of calculation of crack for long term
/// </summary>
CrackWidthRebarTupleResult? LongTermResult { get; set; }
/// <summary>
/// Result of calculation of crack for short term
/// </summary>
CrackWidthRebarTupleResult? ShortTermResult { get; set; }
}
}

View File

@@ -0,0 +1,31 @@
using StructureHelperCommon.Models.Calculators;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// Result of crack calculation for specific force tuple
/// </summary>
public interface ITupleCrackResult : IResult
{
/// <summary>
/// Reference to input data for calculation
/// </summary>
TupleCrackInputData? InputData { get; set; }
/// <summary>
/// True if cross-section has been cracked under specific force combination
/// </summary>
bool IsCracked { get; set; }
/// <summary>
/// Result of calculation of crack width for long term force combination
/// </summary>
CrackWidthRebarTupleResult? LongTermResult { get; set; }
/// <summary>
/// Collection of resuls for specific rebars
/// </summary>
List<IRebarCrackResult>? RebarResults { get; }
/// <summary>
/// Result of calculation of crack width for short term force combination
/// </summary>
CrackWidthRebarTupleResult? ShortTermResult { get; set; }
}
}

View File

@@ -8,26 +8,18 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// Result of calculation of crack for specific result
/// </summary>
public class RebarCrackResult : IResult
/// <inheritdoc/>
public class RebarCrackResult : IRebarCrackResult
{
/// <inheritdoc/>
public bool IsValid { get; set; }
/// <inheritdoc/>
public string Description { get; set; }
/// <summary>
/// Specific rebar primitive
/// </summary>
public IRebarNdmPrimitive RebarPrimitive { get; set; }
/// <summary>
/// Result of calculation of crack for long term
/// </summary>
public CrackWidthRebarTupleResult LongTermResult { get; set; }
/// <summary>
/// Result of calculation of crack for short term
/// </summary>
public CrackWidthRebarTupleResult ShortTermResult { get; set; }
public string? Description { get; set; }
/// <inheritdoc/>
public IRebarNdmPrimitive? RebarPrimitive { get; set; }
/// <inheritdoc/>
public CrackWidthRebarTupleResult? LongTermResult { get; set; }
/// <inheritdoc/>
public CrackWidthRebarTupleResult? ShortTermResult { get; set; }
}
}

View File

@@ -6,29 +6,27 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2024 Redikultsev Evgeny, Ekaterinburg, Russia
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// Result of crack calculation for specific force tuple
/// </summary>
public class TupleCrackResult : IResult
/// <inheritdoc/>
public class TupleCrackResult : ITupleCrackResult
{
/// <inheritdoc/>
public bool IsValid { get; set; }
/// <inheritdoc/>
public string Description { get; set; }
public TupleCrackInputData InputData { get; set; }
public string? Description { get; set; }
/// <inheritdoc/>
public TupleCrackInputData? InputData { get; set; }
/// <inheritdoc/>
public bool IsCracked { get; set; }
public List<RebarCrackResult> RebarResults { get; private set; }
public CrackWidthRebarTupleResult LongTermResult { get; set; }
public CrackWidthRebarTupleResult ShortTermResult { get; set; }
public TupleCrackResult()
{
RebarResults = new ();
}
/// <inheritdoc/>
public List<IRebarCrackResult>? RebarResults { get; private set; } = new();
/// <inheritdoc/>
public CrackWidthRebarTupleResult? LongTermResult { get; set; }
/// <inheritdoc/>
public CrackWidthRebarTupleResult? ShortTermResult { get; set; }
}
}

View File

@@ -1,7 +1,14 @@
using System.Collections.Generic;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Primitives
{
/// <summary>
/// Interface for entities which has collection of ndm-primitives
/// </summary>
public interface IHasPrimitives
{
/// <summary>

View File

@@ -31,7 +31,6 @@ namespace StructureHelperLogics.NdmCalculations.Primitives.Logics
private void ProcessPrimitive(IHasPrimitives targetObject, INdmPrimitive primitive)
{
var project = ProgramSetting.CurrentProject;
var newPrimitive = cloningStrategy.Clone(primitive);
if (primitive.NdmElement.HeadMaterial is not null)
{

View File

@@ -8,7 +8,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
/// <summary>
/// Logic for creating of trace entries of primitives
/// </summary>
public class TracePrimitiveFactory : ITraceEntityFactory<INdmPrimitive>
public class TracePrimitiveFactory : ITraceCollectionLogic<INdmPrimitive>
{
const int rowSize = 2;
private List<ITraceLoggerEntry> traceLoggerEntries;
@@ -196,5 +196,11 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
}
return ndmRow;
}
public void AddEntriesToTraceLogger(IShiftTraceLogger traceLogger)
{
var entries = GetTraceEntries();
entries.ForEach(x => traceLogger?.AddEntry(x));
}
}
}