Fix beam shear force calculator

This commit is contained in:
Evgeny Redikultsev
2025-05-24 20:26:44 +05:00
parent d108c52cac
commit f127594b5c
53 changed files with 920 additions and 121 deletions

View File

@@ -10,7 +10,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ListBox ItemsSource="{Binding SourceItems}" <ListBox ItemsSource="{Binding SourceItems}"
SelectedItem="{Binding SelectedSourceItem}" SelectedItem="{Binding SelectedSourceItem}"
ItemTemplate="{Binding ItemDataDemplate}"> ItemTemplate="{Binding ItemDataTemplate}">
<!--<InputBindingCollection> <!--<InputBindingCollection>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding AddSelected}"/> <MouseBinding Gesture="LeftDoubleClick" Command="{Binding AddSelected}"/>
</InputBindingCollection>--> </InputBindingCollection>-->
@@ -23,7 +23,7 @@
</StackPanel> </StackPanel>
<ListBox Grid.Column="2" ItemsSource="{Binding TargetItems}" <ListBox Grid.Column="2" ItemsSource="{Binding TargetItems}"
SelectedItem="{Binding SelectedTargetItem}" SelectedItem="{Binding SelectedTargetItem}"
ItemTemplate="{Binding ItemDataDemplate}" ItemTemplate="{Binding ItemDataTemplate}"
> >
<!--<InputBindingCollection> <!--<InputBindingCollection>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding RemoveSelected}"/> <MouseBinding Gesture="LeftDoubleClick" Command="{Binding RemoveSelected}"/>

View File

@@ -12,6 +12,9 @@
<Compile Update="Windows\Arrays\ArrayView.xaml.cs"> <Compile Update="Windows\Arrays\ArrayView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\BeamShears\BeamShearActionResultView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\BeamShears\BeamShearActionView.xaml.cs"> <Compile Update="Windows\BeamShears\BeamShearActionView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@@ -170,6 +173,9 @@
<Page Update="Windows\Arrays\ArrayView.xaml"> <Page Update="Windows\Arrays\ArrayView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\BeamShears\BeamShearActionResultView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\BeamShears\BeamShearActionView.xaml"> <Page Update="Windows\BeamShears\BeamShearActionView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>

View File

@@ -0,0 +1,56 @@
<Window x:Class="StructureHelper.Windows.BeamShears.BeamShearActionResultView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.BeamShears"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
d:DataContext="{d:DesignInstance local:BeamShearActionResultViewModel}"
mc:Ignorable="d"
Title="Shear sections result" Height="450" Width="800" MinHeight="400" MinWidth="600" MaxHeight="900" MaxWidth="1200" WindowStartupLocation="CenterScreen">
<DockPanel>
<ToolBarTray DockPanel.Dock="Top">
<!--<ToolBar Name="Sections">
<Button Style="{DynamicResource ToolButton}" Command="{Binding ShowSectionResultsCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Set prestrain"
IconContent="{StaticResource BeamShear}"
DescriptionText="Set strain from selected combination as auto prestrain (not available if selected result is invalid)"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{StaticResource BeamShear}"/>
</Viewbox>
</Button>
</ToolBar>-->
</ToolBarTray>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<DataGrid x:Name="ResultGrid" IsReadOnly="True" AutoGenerateColumns="False" ItemsSource="{Binding SectionResults}" SelectedItem="{Binding SelectedResult}" >
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding IsValid}" Value="false">
<Setter Property="Background" Value="Pink"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="Valid" Binding="{Binding IsValid}"/>
<DataGridTextColumn Header="Start point" Width="100" Binding="{Binding InputData.InclinedSection.StartCoord, Converter={StaticResource LengthConverter}}"/>
<DataGridTextColumn Header="End point" Width="100" Binding="{Binding InputData.InclinedSection.EndCoord, Converter={StaticResource LengthConverter}}"/>
<DataGridTextColumn Header="Shear force" Width="120" Binding="{Binding InputData.ForceTuple.Qy, Converter={StaticResource ForceConverter}}"/>
<DataGridTextColumn Header="Limit force" Width="120" Binding="{Binding TotalStrength, Converter={StaticResource ForceConverter}}"/>
<DataGridTextColumn Header="Using factor" Width="120" Binding="{Binding FactorOfUsing, Converter={StaticResource PlainDouble}}"/>
<DataGridTextColumn Header="Concrete force" Width="120" Binding="{Binding ConcreteStrength, Converter={StaticResource ForceConverter}}"/>
<DataGridTextColumn Header="Stirrup force" Width="120" Binding="{Binding StirrupStrength, Converter={StaticResource ForceConverter}}"/>
<DataGridTextColumn Header="Description" Width="300" Binding="{Binding Description}"/>
</DataGrid.Columns>
</DataGrid>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResultValidness}" Content="{Binding ValidResultCounter}"/>
</Grid>
</DockPanel>
</Window>

View File

@@ -0,0 +1,36 @@
using StructureHelperLogics.Models.BeamShears;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace StructureHelper.Windows.BeamShears
{
/// <summary>
/// Interaction logic for BeamShearActionResultView.xaml
/// </summary>
public partial class BeamShearActionResultView : Window
{
private BeamShearActionResultViewModel viewModel;
public BeamShearActionResultView(BeamShearActionResultViewModel viewModel)
{
this.viewModel = viewModel;
InitializeComponent();
this.DataContext = this.viewModel;
}
public BeamShearActionResultView(IBeamShearActionResult result) : this (new BeamShearActionResultViewModel(result))
{
}
}
}

View File

@@ -0,0 +1,26 @@
using StructureHelper.Infrastructure;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
using StructureHelperLogics.Models.BeamShears;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.BeamShears
{
public class BeamShearActionResultViewModel : ViewModelBase
{
private IBeamShearActionResult result;
public IBeamShearSectionLogicResult SelectedResult { get; set; }
public List<IBeamShearSectionLogicResult> SectionResults => result.SectionResults;
public ValidResultCounterVM ValidResultCounter { get; }
public BeamShearActionResultViewModel(IBeamShearActionResult result)
{
this.result = result;
ValidResultCounter = new(this.result.SectionResults);
}
}
}

View File

@@ -2,6 +2,9 @@
using StructureHelper.Windows.ViewModels; using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.Models.BeamShears;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace StructureHelper.Windows.BeamShears namespace StructureHelper.Windows.BeamShears
{ {
@@ -25,13 +28,23 @@ namespace StructureHelper.Windows.BeamShears
{ {
ActionSourceTarget.SetTargetItems(inputData.Actions); ActionSourceTarget.SetTargetItems(inputData.Actions);
ActionSourceTarget.SetSourceItems(shearRepository.Actions); ActionSourceTarget.SetSourceItems(shearRepository.Actions);
ActionSourceTarget.ItemDataDemplate = SourceTargetFactory.GetSimpleTemplate(); ActionSourceTarget.ItemDataTemplate = SourceTargetFactory.GetSimpleTemplate();
StirrupSourceTarget.SetTargetItems(inputData.Stirrups); StirrupSourceTarget.SetTargetItems(inputData.Stirrups);
StirrupSourceTarget.SetSourceItems(shearRepository.Stirrups); StirrupSourceTarget.SetSourceItems(shearRepository.Stirrups);
StirrupSourceTarget.ItemDataDemplate = SourceTargetFactory.GetSimpleTemplate(); StirrupSourceTarget.ItemDataTemplate = SourceTargetFactory.GetSimpleTemplate();
SectionSourceTarget.SetTargetItems(inputData.Sections); SectionSourceTarget.SetTargetItems(inputData.Sections);
SectionSourceTarget.SetSourceItems(shearRepository.Sections); SectionSourceTarget.SetSourceItems(shearRepository.Sections);
SectionSourceTarget.ItemDataDemplate = SourceTargetFactory.GetSimpleTemplate(); SectionSourceTarget.ItemDataTemplate = SourceTargetFactory.GetSimpleTemplate();
}
internal void Refresh()
{
inputData.Actions.Clear();
inputData.Actions.AddRange(ActionSourceTarget.GetTargetItems());
inputData.Stirrups.Clear();
inputData.Stirrups.AddRange(StirrupSourceTarget.GetTargetItems());
inputData.Sections.Clear();
inputData.Sections.AddRange(SectionSourceTarget.GetTargetItems());
} }
} }
} }

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.BeamShears" xmlns:local="clr-namespace:StructureHelper.Windows.BeamShears"
d:DataContext="{d:DesignInstance local:BeamShearCalculatorViewModel}" d:DataContext="{d:DesignInstance local:BeamShearCalculatorViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
Title="Beam Shear Calculator" Height="300" Width="350" ResizeMode="NoResize" WindowStartupLocation="CenterScreen"> Title="Beam Shear Calculator" Height="300" Width="350" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Closing="Window_Closing">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
@@ -18,12 +18,14 @@
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/> <RowDefinition Height="25"/>
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="Name"/> <TextBlock Text="Name"/>
<CheckBox Grid.Row="1" Content="Show trace data" IsChecked="{Binding ShowTraceData}"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/> <TextBox Grid.Column="1" Text="{Binding Name}"/>
<TabControl Grid.Row="1" Grid.ColumnSpan="2" DataContext="{Binding InputDataViewModel}"> <TabControl Grid.Row="2" Grid.ColumnSpan="2" DataContext="{Binding InputDataViewModel}">
<TabItem Header="Sections"> <TabItem Header="Sections">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding SectionSourceTarget}"/> <ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding SectionSourceTarget}"/>
</TabItem> </TabItem>

View File

@@ -15,5 +15,10 @@ namespace StructureHelper.Windows.BeamShears
this.viewModel.ParentWindow = this; this.viewModel.ParentWindow = this;
this.DataContext = this.viewModel; this.DataContext = this.viewModel;
} }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
viewModel.Refresh();
}
} }
} }

View File

@@ -1,4 +1,5 @@
using StructureHelper.Windows.ViewModels; using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.Models.BeamShears;
namespace StructureHelper.Windows.BeamShears namespace StructureHelper.Windows.BeamShears
@@ -7,7 +8,7 @@ namespace StructureHelper.Windows.BeamShears
{ {
private readonly IBeamShearRepository shearRepository; private readonly IBeamShearRepository shearRepository;
private readonly IBeamShearCalculator calculator; private readonly IBeamShearCalculator calculator;
private bool showTraceData;
public string Name public string Name
{ {
@@ -18,6 +19,18 @@ namespace StructureHelper.Windows.BeamShears
OnPropertyChanged(nameof(Name)); OnPropertyChanged(nameof(Name));
} }
} }
public bool ShowTraceData
{
get
{
return calculator.ShowTraceData;
}
set
{
calculator.ShowTraceData = value;
OnPropertyChanged(nameof(ShowTraceData));
}
}
public BeamShearCalculatorInputDataViewModel InputDataViewModel { get; } public BeamShearCalculatorInputDataViewModel InputDataViewModel { get; }
public BeamShearCalculatorViewModel(IBeamShearRepository shearRepository, IBeamShearCalculator calculator) public BeamShearCalculatorViewModel(IBeamShearRepository shearRepository, IBeamShearCalculator calculator)
{ {
@@ -25,5 +38,10 @@ namespace StructureHelper.Windows.BeamShears
this.calculator = calculator; this.calculator = calculator;
InputDataViewModel = new(this.shearRepository, this.calculator.InputData); InputDataViewModel = new(this.shearRepository, this.calculator.InputData);
} }
internal void Refresh()
{
InputDataViewModel.Refresh();
}
} }
} }

View File

@@ -6,6 +6,7 @@ using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.Models.BeamShears;
using System; using System;
using System.Windows; using System.Windows;
@@ -18,6 +19,7 @@ namespace StructureHelper.Windows.BeamShears
private object parameter; private object parameter;
private readonly IBeamShearRepository shearRepository; private readonly IBeamShearRepository shearRepository;
private RelayCommand runCommand; private RelayCommand runCommand;
private BeamShearCalculatorUpdateStrategy updateStrategy;
public ICommand Run public ICommand Run
{ {
@@ -69,14 +71,21 @@ namespace StructureHelper.Windows.BeamShears
Window window; Window window;
if (SelectedItem is IBeamShearCalculator beamShearCalculator) if (SelectedItem is IBeamShearCalculator beamShearCalculator)
{ {
var tmpCalculator = beamShearCalculator.Clone() as IBeamShearCalculator;
var viewModel = new BeamShearCalculatorViewModel(shearRepository, beamShearCalculator); var viewModel = new BeamShearCalculatorViewModel(shearRepository, beamShearCalculator);
window = new BeamShearCalculatorView(viewModel); window = new BeamShearCalculatorView(viewModel);
window.ShowDialog();
if (window.DialogResult != true)
{
updateStrategy ??= new BeamShearCalculatorUpdateStrategy();
updateStrategy.Update(beamShearCalculator, tmpCalculator);
}
base.EditMethod(parameter);
} }
else else
{ {
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem)); throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
} }
window.ShowDialog();
} }
private void RunMethod(object param) private void RunMethod(object param)
{ {
@@ -95,12 +104,18 @@ namespace StructureHelper.Windows.BeamShears
if (SelectedItem is IBeamShearCalculator beamShearCalculator) if (SelectedItem is IBeamShearCalculator beamShearCalculator)
{ {
beamShearCalculator.Run(); beamShearCalculator.Run();
var result = beamShearCalculator.Result as IBeamShearCalculatorResult;
Window window = new BeamShearResultView(result);
window.ShowDialog();
if (beamShearCalculator.ShowTraceData == true)
{
TraceDocumentService.ShowDocument(SelectedItem.TraceLogger.TraceLoggerEntries);
}
} }
else else
{ {
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem)); throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
} }
TraceDocumentService.ShowDocument(SelectedItem.TraceLogger.TraceLoggerEntries);
} }
} }
} }

View File

@@ -4,13 +4,8 @@ using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions; using StructureHelperCommon.Models.Forces.BeamShearActions;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Forms;
namespace StructureHelper.Windows.BeamShears namespace StructureHelper.Windows.BeamShears
{ {

View File

@@ -7,18 +7,38 @@
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
d:DataContext="{d:DesignInstance local:BeamShearResultViewModel}" d:DataContext="{d:DesignInstance local:BeamShearResultViewModel}"
mc:Ignorable="d" mc:Ignorable="d"
Title="BeamShearResultView" Height="450" Width="800" MinHeight="400" MinWidth="600" MaxHeight="900" MaxWidth="1200"> Title="Beam Shear Result" Height="450" Width="800" MinHeight="400" MinWidth="600" MaxHeight="900" MaxWidth="1200" WindowStartupLocation="CenterScreen">
<DockPanel> <DockPanel>
<ToolBarTray DockPanel.Dock="Top"> <ToolBarTray DockPanel.Dock="Top">
<ToolBar Name="Sections"> <ToolBar Name="Sections">
<Button Style="{DynamicResource ToolButton}" Command="{Binding SetPrestrainCommand}"> <Button Style="{DynamicResource ToolButton}" Command="{Binding ShowSectionResultsCommand}">
<Button.ToolTip> <Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Set prestrain" <uc:ButtonToolTipEh HeaderText="Show results by sections"
IconContent="{StaticResource Prestrain}" IconContent="{StaticResource BeamShear}"
DescriptionText="Set strain from selected combination as auto prestrain (not available if selected result is invalid)"/> DescriptionText="Shows results fo all sections (include sections with invalid results)"/>
</Button.ToolTip> </Button.ToolTip>
<Viewbox> <Viewbox>
<ContentControl ContentTemplate="{StaticResource Prestrain}"/> <ContentControl ContentTemplate="{StaticResource BeamShear}"/>
</Viewbox>
</Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding ShowDiagramCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Show digram"
IconContent="{StaticResource MomentCurvatureDiagram}"
DescriptionText="Shows diagram for result where inclined section started from support (Note - the most dangerous combinations may be missed)"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{StaticResource MomentCurvatureDiagram}"/>
</Viewbox>
</Button>
<Button Style="{DynamicResource ToolButton}" Command="{Binding ExportToExcelCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Export to Excel"
IconContent="{StaticResource ExportToXLS}"
DescriptionText="Exports results to *.csv file"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{StaticResource ExportToXLS}"/>
</Viewbox> </Viewbox>
</Button> </Button>
</ToolBar> </ToolBar>
@@ -41,6 +61,8 @@
<DataGrid.Columns> <DataGrid.Columns>
<DataGridCheckBoxColumn Header="Valid" Binding="{Binding Path=IsValid}"/> <DataGridCheckBoxColumn Header="Valid" Binding="{Binding Path=IsValid}"/>
<DataGridTextColumn Header="Action" Width="170" Binding="{Binding BeamShearAction.Name}"/> <DataGridTextColumn Header="Action" Width="170" Binding="{Binding BeamShearAction.Name}"/>
<DataGridTextColumn Header="Section" Width="120" Binding="{Binding Section.Name}"/>
<DataGridTextColumn Header="Stirrups" Width="120" Binding="{Binding Stirrup.Name}"/>
<DataGridTextColumn Header="LimitState" Width="70" Binding="{Binding LimitState}"/> <DataGridTextColumn Header="LimitState" Width="70" Binding="{Binding LimitState}"/>
<DataGridTextColumn Header="Duration" Width="70" Binding="{Binding CalcTerm}"/> <DataGridTextColumn Header="Duration" Width="70" Binding="{Binding CalcTerm}"/>
<!--<DataGridTextColumn Header="Moment Mx" Width="90" Binding="{Binding DesignForceTuple.ForceTuple.Mx, Converter={StaticResource MomentConverter}}"/> <!--<DataGridTextColumn Header="Moment Mx" Width="90" Binding="{Binding DesignForceTuple.ForceTuple.Mx, Converter={StaticResource MomentConverter}}"/>

View File

@@ -1,15 +1,22 @@
using StructureHelper.Infrastructure; using StructureHelper.Infrastructure;
using StructureHelper.Services.Exports;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews; using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
using StructureHelperLogics.Models.BeamShears; using StructureHelperLogics.Models.BeamShears;
using StructureHelperLogics.NdmCalculations.Analyses;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.Windows;
using System.Runtime.CompilerServices; using System.Windows.Input;
namespace StructureHelper.Windows.BeamShears namespace StructureHelper.Windows.BeamShears
{ {
public class BeamShearResultViewModel : ViewModelBase public class BeamShearResultViewModel : ViewModelBase
{ {
private IBeamShearCalculatorResult result; private IBeamShearCalculatorResult result;
private RelayCommand showSectionResultsCommand;
private RelayCommand showDiagramCommand;
private RelayCommand exportToExcelCommand;
public IBeamShearActionResult SelectedResult { get; set; } public IBeamShearActionResult SelectedResult { get; set; }
public List<IBeamShearActionResult> ActionResults => result.ActionResults; public List<IBeamShearActionResult> ActionResults => result.ActionResults;
public ValidResultCounterVM ValidResultCounter { get; } public ValidResultCounterVM ValidResultCounter { get; }
@@ -20,5 +27,35 @@ namespace StructureHelper.Windows.BeamShears
ValidResultCounter = new(this.result.ActionResults); ValidResultCounter = new(this.result.ActionResults);
} }
public ICommand ShowSectionResultsCommand => showSectionResultsCommand ??= new RelayCommand(ShowSectionResults, o=>SelectedResult != null);
public ICommand ShowDiagramCommand => showDiagramCommand ??= new RelayCommand(Show2DDiagram, o=>SelectedResult != null);
public ICommand ExportToExcelCommand => exportToExcelCommand ??= new RelayCommand(ExportToExcel, o=>SelectedResult != null);
private void ExportToExcel(object obj)
{
if (SelectedResult is null) { return; }
var inputData = new ExportToFileInputData
{
Filter = "csv |*.csv",
Title = "Save in *.csv File"
};
var logic = new ExportActionResultToCSVLogic(SelectedResult);
var exportService = new ExportToFileService(inputData, logic);
exportService.Export();
}
private void Show2DDiagram(object obj)
{
if (SelectedResult is null) { return; }
var logic = new ShearDiagramLogic(SelectedResult);
logic.ShowWindow();
}
private void ShowSectionResults(object commandParameter)
{
if (SelectedResult is null) { return; }
Window window = new BeamShearActionResultView(SelectedResult);
window.ShowDialog();
}
} }
} }

View File

@@ -0,0 +1,69 @@
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.Models.BeamShears;
using StructureHelperLogics.NdmCalculations.Analyses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.BeamShears
{
public class ExportActionResultToCSVLogic : ExportToCSVLogicBase
{
private IBeamShearActionResult result;
public ExportActionResultToCSVLogic(IBeamShearActionResult result)
{
this.result = result;
}
public override void ExportHeadings()
{
string[] headings =
{
"Limit State",
"Calc duration",
"Section start,m",
"Section end, m",
"Nz, N",
"Qy, N",
"Width, m",
"Effective depth, m",
"Full depth, m",
"Concrete compressive strength, Pa",
"Concrete tensile strength, Pa",
"Limit force, N",
"Concrete force, N",
"Stirrups force, N",
"Description",
};
output.AppendLine(string.Join(separator, headings));
}
public override void ExportBoby()
{
foreach (var item in result.SectionResults)
{
string[] newLine =
{
result.LimitState.ToString(),
result.CalcTerm.ToString(),
item.InputData.InclinedSection.StartCoord.ToString(),
item.InputData.InclinedSection.EndCoord.ToString(),
item.InputData.ForceTuple.Nz.ToString(),
item.InputData.ForceTuple.Qy.ToString(),
item.InputData.InclinedSection.WebWidth.ToString(),
item.InputData.InclinedSection.EffectiveDepth.ToString(),
item.InputData.InclinedSection.FullDepth.ToString(),
item.InputData.InclinedSection.ConcreteCompressionStrength.ToString(),
item.InputData.InclinedSection.ConcreteTensionStrength.ToString(),
item.TotalStrength.ToString(),
item.ConcreteStrength.ToString(),
item.StirrupStrength.ToString(),
item.Description,
};
output.AppendLine(string.Join(separator, newLine));
}
}
}
}

View File

@@ -0,0 +1,81 @@
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.Models.BeamShears;
using System.Collections.Generic;
using System.Linq;
namespace StructureHelper.Windows.BeamShears
{
public class ShearDiagramLogic
{
const string ForceUnitString = "kN";
private IBeamShearActionResult result;
private IUnit unitForce;
public ShearDiagramLogic(IBeamShearActionResult result)
{
this.result = result;
IGetUnitLogic unitLogic = new GetUnitLogic();
unitForce = unitLogic.GetUnit(UnitTypes.Force, ForceUnitString);
}
public void ShowWindow()
{
SafetyProcessor.RunSafeProcess(() =>
{
var seriesList = new List<Series>();
var series = new Series(GetParametersByCurveResult()) { Name = "" };
seriesList.Add(series);
var vm = new GraphViewModel(seriesList);
var wnd = new GraphView(vm);
wnd.ShowDialog();
},
"Errors appeared during showing a graph, see detailed information");
}
private ArrayParameter<double> GetParametersByCurveResult()
{
List<IBeamShearSectionLogicResult> results = result.SectionResults
.Where(x => x.InputData.InclinedSection.StartCoord == 0)
.ToList();
var labels = GetLabels();
var arrayParameter = new ArrayParameter<double>(results.Count(), labels.Count(), labels);
var data = arrayParameter.Data;
for (int i = 0; i < results.Count(); i++)
{
var valueList = new List<double>
{
results[i].InputData.InclinedSection.EndCoord,
results[i].InputData.ForceTuple.Nz * unitForce.Multiplyer,
results[i].InputData.ForceTuple.Qy * unitForce.Multiplyer,
results[i].TotalStrength * unitForce.Multiplyer,
results[i].ConcreteStrength * unitForce.Multiplyer,
results[i].StirrupStrength * unitForce.Multiplyer,
results[i].FactorOfUsing,
};
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
}
return arrayParameter;
}
private List<string> GetLabels()
{
List<string> strings = new()
{
"End coord",
"Nz",
"Qy",
"Qlim",
"Qb",
"Qsw",
"Uf"
};
return strings;
}
}
}

View File

@@ -25,7 +25,7 @@ namespace StructureHelper.Windows.ViewModels
result.SetTargetItems(viewPrimitives); result.SetTargetItems(viewPrimitives);
} }
result.SetSourceItems(sourceViewPrimitives); result.SetSourceItems(sourceViewPrimitives);
result.ItemDataDemplate = GetDataTemplate(ColoredItemTemplate); result.ItemDataTemplate = GetDataTemplate(ColoredItemTemplate);
return result; return result;
} }
@@ -34,7 +34,7 @@ namespace StructureHelper.Windows.ViewModels
var result = new SourceTargetVM<IForceAction>(); var result = new SourceTargetVM<IForceAction>();
result.SetTargetItems(targetCombinations); result.SetTargetItems(targetCombinations);
result.SetSourceItems(allowedCombinations); result.SetSourceItems(allowedCombinations);
result.ItemDataDemplate = GetDataTemplate(SimpleItemTemplate); result.ItemDataTemplate = GetDataTemplate(SimpleItemTemplate);
return result; return result;
} }

View File

@@ -1,13 +1,7 @@
using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Properties;
using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperCommon.Models.Parameters; using StructureHelperCommon.Models.Parameters;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels namespace StructureHelper.Windows.ViewModels
{ {

View File

@@ -1,12 +1,7 @@
using StructureHelper.Infrastructure; using StructureHelper.Infrastructure;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
namespace StructureHelper.Windows.ViewModels namespace StructureHelper.Windows.ViewModels
@@ -24,7 +19,7 @@ namespace StructureHelper.Windows.ViewModels
public TItem SelectedTargetItem { get; set; } public TItem SelectedTargetItem { get; set; }
public ObservableCollection<TItem> SourceItems { get; } public ObservableCollection<TItem> SourceItems { get; }
public ObservableCollection<TItem> TargetItems { get; } public ObservableCollection<TItem> TargetItems { get; }
public DataTemplate ItemDataDemplate { get; set; } public DataTemplate ItemDataTemplate { get; set; }
public RelayCommand AddAll public RelayCommand AddAll
{ {
get get

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IGetFactorLogic : ILogic
{
double GetFactor();
}
}

View File

@@ -11,6 +11,7 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
CheckObject.IsNull(targetObject); CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject); CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name;
InitializeStrategies(); InitializeStrategies();
CheckObject.IsNull(sourceObject.SupportAction); CheckObject.IsNull(sourceObject.SupportAction);
CheckObject.IsNull(targetObject.SupportAction); CheckObject.IsNull(targetObject.SupportAction);

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials.Libraries namespace StructureHelperCommon.Models.Materials.Libraries
{ {
public interface IFactorLogic public interface IMaterialFactorLogic
{ {
List<IMaterialSafetyFactor> SafetyFactors { get; } List<IMaterialSafetyFactor> SafetyFactors { get; }
(double Compressive, double Tensile) GetTotalFactor(LimitStates limitState, CalcTerms calcTerm); (double Compressive, double Tensile) GetTotalFactor(LimitStates limitState, CalcTerms calcTerm);

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials.Libraries namespace StructureHelperCommon.Models.Materials.Libraries
{ {
public class FactorLogic : IFactorLogic public class MaterialFactorLogic : IMaterialFactorLogic
{ {
public List<IMaterialSafetyFactor> SafetyFactors { get; } public List<IMaterialSafetyFactor> SafetyFactors { get; }
public (double Compressive, double Tensile) GetTotalFactor(LimitStates limitState, CalcTerms calcTerm) public (double Compressive, double Tensile) GetTotalFactor(LimitStates limitState, CalcTerms calcTerm)
@@ -21,7 +21,7 @@ namespace StructureHelperCommon.Models.Materials.Libraries
} }
return (compressionVal, tensionVal); return (compressionVal, tensionVal);
} }
public FactorLogic(List<IMaterialSafetyFactor> safetyFactors) public MaterialFactorLogic(List<IMaterialSafetyFactor> safetyFactors)
{ {
SafetyFactors = safetyFactors; SafetyFactors = safetyFactors;
} }

View File

@@ -10,7 +10,7 @@ namespace StructureHelperCommon.Models.Materials
public class MaterialCommonOptionLogic : IMaterialOptionLogic public class MaterialCommonOptionLogic : IMaterialOptionLogic
{ {
private IMaterialLogicOptions options; private IMaterialLogicOptions options;
private FactorLogic factorLogic; private MaterialFactorLogic factorLogic;
public MaterialCommonOptionLogic(IMaterialLogicOptions options) public MaterialCommonOptionLogic(IMaterialLogicOptions options)
{ {
@@ -29,7 +29,7 @@ namespace StructureHelperCommon.Models.Materials
private void ProcessExternalFactors(IMaterialOptions materialOptions) private void ProcessExternalFactors(IMaterialOptions materialOptions)
{ {
factorLogic = new FactorLogic(options.SafetyFactors); factorLogic = new MaterialFactorLogic(options.SafetyFactors);
var strength = factorLogic.GetTotalFactor(options.LimitState, options.CalcTerm); var strength = factorLogic.GetTotalFactor(options.LimitState, options.CalcTerm);
materialOptions.ExternalFactor.Compressive = strength.Compressive; materialOptions.ExternalFactor.Compressive = strength.Compressive;
materialOptions.ExternalFactor.Tensile = strength.Tensile; materialOptions.ExternalFactor.Tensile = strength.Tensile;

View File

@@ -15,6 +15,8 @@ namespace StructureHelperLogics.Models.BeamShears
public string? Description { get; set; } public string? Description { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public LimitStates LimitState { get; set; } public LimitStates LimitState { get; set; }
public IBeamShearSection Section { get; set; }
public IStirrup Stirrup { get; set; }
public CalcTerms CalcTerm { get; set; } public CalcTerms CalcTerm { get; set; }
public IBeamShearAction BeamShearAction { get; set; } public IBeamShearAction BeamShearAction { get; set; }
public List<IBeamShearSectionLogicResult> SectionResults { get; set; } = new(); public List<IBeamShearSectionLogicResult> SectionResults { get; set; } = new();

View File

@@ -1,6 +1,7 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Loggers;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
@@ -18,6 +19,7 @@ namespace StructureHelperLogics.Models.BeamShears
public IResult Result => result; public IResult Result => result;
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public bool ShowTraceData { get; set; } = false;
public BeamShearCalculator(Guid id) public BeamShearCalculator(Guid id)
{ {
@@ -34,6 +36,7 @@ namespace StructureHelperLogics.Models.BeamShears
public void Run() public void Run()
{ {
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
PrepareNewResult(); PrepareNewResult();
//PrepareInputData(); //PrepareInputData();
try try
@@ -82,7 +85,8 @@ namespace StructureHelperLogics.Models.BeamShears
result = new BeamShearCalculatorResult() result = new BeamShearCalculatorResult()
{ {
IsValid = true, IsValid = true,
Description = string.Empty Description = string.Empty,
InputData = InputData
}; };
} }
} }

View File

@@ -2,6 +2,7 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -12,10 +13,10 @@ namespace StructureHelperLogics.Models.BeamShears
{ {
public class BeamShearCalculatorLogic : IGetResultByInputDataLogic<IBeamShearCalculatorInputData, IBeamShearCalculatorResult> public class BeamShearCalculatorLogic : IGetResultByInputDataLogic<IBeamShearCalculatorInputData, IBeamShearCalculatorResult>
{ {
private const LimitStates CollapsLimitState = LimitStates.ULS; private const LimitStates CollapseLimitState = LimitStates.ULS;
private IBeamShearCalculatorResult result; private IBeamShearCalculatorResult result;
private IBeamShearSectionLogic beamShearSectionLogic; private IBeamShearSectionLogic beamShearSectionLogic;
private List<IBeamShearSectionLogicInputData> sectionInputDatas; private List<IBeamShearActionResult> actionResults;
private IBeamShearCalculatorInputData inputData; private IBeamShearCalculatorInputData inputData;
private List<CalcTerms> calcTerms = new() { CalcTerms.LongTerm, CalcTerms.ShortTerm }; private List<CalcTerms> calcTerms = new() { CalcTerms.LongTerm, CalcTerms.ShortTerm };
@@ -29,13 +30,14 @@ namespace StructureHelperLogics.Models.BeamShears
public IBeamShearCalculatorResult GetResultByInputData(IBeamShearCalculatorInputData inputData) public IBeamShearCalculatorResult GetResultByInputData(IBeamShearCalculatorInputData inputData)
{ {
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
this.inputData = inputData; this.inputData = inputData;
PrepareNewResult(); PrepareNewResult();
InitializeStrategies(); InitializeStrategies();
try try
{ {
GetSectionInputDatas(); GetSections();
CalculateResult(); result.ActionResults = actionResults;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -46,20 +48,17 @@ namespace StructureHelperLogics.Models.BeamShears
return result; return result;
} }
private void CalculateResult() private IBeamShearSectionLogicResult CalculateResult(IBeamShearSectionLogicInputData sectionInputData)
{
foreach (var sectionInputData in sectionInputDatas)
{ {
beamShearSectionLogic.InputData = sectionInputData; beamShearSectionLogic.InputData = sectionInputData;
beamShearSectionLogic.Run(); beamShearSectionLogic.Run();
var sectionResult = beamShearSectionLogic.Result as IBeamShearSectionLogicResult; var sectionResult = beamShearSectionLogic.Result as IBeamShearSectionLogicResult;
//result.ActionResults.Add(sectionResult); return sectionResult;
}
} }
private void InitializeStrategies() private void InitializeStrategies()
{ {
beamShearSectionLogic ??= new BeamShearSectionLogic(); beamShearSectionLogic ??= new BeamShearSectionLogic(TraceLogger);
} }
private void PrepareNewResult() private void PrepareNewResult()
@@ -71,40 +70,92 @@ namespace StructureHelperLogics.Models.BeamShears
}; };
} }
private void GetSectionInputDatas() private void GetSections()
{
sectionInputDatas = new();
foreach (var beamShearSection in inputData.Sections)
{
List<IInclinedSection> inclinedSections = GetInclinedSections(beamShearSection);
foreach (var inclinedSection in inclinedSections)
{
GetSections(inclinedSection);
}
}
}
private void GetSections(IInclinedSection inclinedSection)
{
foreach (var stirrup in inputData.Stirrups)
{ {
actionResults = new();
foreach (var beamShearAction in inputData.Actions) foreach (var beamShearAction in inputData.Actions)
{ {
foreach (var calcTerm in calcTerms) foreach (var calcTerm in calcTerms)
{ {
IForceTuple forceTuple = GetForceTupleByShearAction(beamShearAction, inclinedSection, CollapsLimitState, calcTerm); foreach (var section in inputData.Sections)
{
foreach (var stirrup in inputData.Stirrups)
{
List<IInclinedSection> inclinedSections = GetInclinedSections(section);
List<IBeamShearSectionLogicInputData> sectionInputDatas = GetSectionInputDatas(beamShearAction, calcTerm, section, stirrup, inclinedSections);
List<IBeamShearSectionLogicResult> sectionResults = GetSectionResults(sectionInputDatas);
BeamShearActionResult actionResult = GetActionResult(beamShearAction, calcTerm, section, stirrup, sectionResults);
actionResults.Add(actionResult);
}
}
}
}
}
private BeamShearActionResult GetActionResult(IBeamShearAction beamShearAction, CalcTerms calcTerm, IBeamShearSection section, IStirrup stirrup, List<IBeamShearSectionLogicResult> sectionResults)
{
BeamShearActionResult actionResult = PrepareNewActionResult(beamShearAction, calcTerm, section, stirrup);
if (sectionResults.Any(x => x.IsValid == false))
{
actionResult.IsValid = false;
if (actionResult.Description.Length > 0)
{
actionResult.Description += "\n";
}
actionResult.Description += $"There are {sectionResults.Count(x => x.IsValid == false)} invalid section result(s)";
}
actionResult.SectionResults = sectionResults;
return actionResult;
}
private List<IBeamShearSectionLogicResult> GetSectionResults(List<IBeamShearSectionLogicInputData> sectionInputDatas)
{
List<IBeamShearSectionLogicResult> sectionResults = new();
foreach (var item in sectionInputDatas)
{
IBeamShearSectionLogicResult sectionResult = CalculateResult(item);
sectionResults.Add(sectionResult);
}
return sectionResults;
}
private List<IBeamShearSectionLogicInputData> GetSectionInputDatas(IBeamShearAction beamShearAction, CalcTerms calcTerm, IBeamShearSection section, IStirrup stirrup, List<IInclinedSection> inclinedSections)
{
List<IBeamShearSectionLogicInputData> sectionInputDatas = new();
var material = section.Material;
var strength = material.GetStrength(CollapseLimitState, calcTerm);
foreach (var inclinedSection in inclinedSections)
{
inclinedSection.ConcreteCompressionStrength = strength.Compressive;
inclinedSection.ConcreteTensionStrength = strength.Tensile;
IForceTuple forceTuple = GetForceTupleByShearAction(beamShearAction, inclinedSection, CollapseLimitState, calcTerm);
BeamShearSectionLogicInputData newInputData = new(Guid.NewGuid()) BeamShearSectionLogicInputData newInputData = new(Guid.NewGuid())
{ {
InclinedSection = inclinedSection, InclinedSection = inclinedSection,
Stirrup = stirrup, Stirrup = stirrup,
ForceTuple = forceTuple, ForceTuple = forceTuple,
LimitState = CollapsLimitState, LimitState = CollapseLimitState,
CalcTerm = calcTerm CalcTerm = calcTerm
}; };
sectionInputDatas.Add(newInputData); sectionInputDatas.Add(newInputData);
} }
return sectionInputDatas;
} }
}
private static BeamShearActionResult PrepareNewActionResult(IBeamShearAction beamShearAction, CalcTerms calcTerm, IBeamShearSection section, IStirrup stirrup)
{
return new()
{
IsValid = true,
Description = string.Empty,
BeamShearAction = beamShearAction,
LimitState = CollapseLimitState,
CalcTerm = calcTerm,
Section = section,
Stirrup = stirrup
};
} }
private List<IInclinedSection> GetInclinedSections(IBeamShearSection beamShearSection) private List<IInclinedSection> GetInclinedSections(IBeamShearSection beamShearSection)

View File

@@ -6,10 +6,16 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
/// <inheritdoc/>
public class BeamShearCalculatorResult : IBeamShearCalculatorResult public class BeamShearCalculatorResult : IBeamShearCalculatorResult
{ {
/// <inheritdoc/>
public bool IsValid { get; set; } = true; public bool IsValid { get; set; } = true;
/// <inheritdoc/>
public string? Description { get; set; } = string.Empty; public string? Description { get; set; } = string.Empty;
/// <inheritdoc/>
public IBeamShearCalculatorInputData InputData { get; set; }
/// <inheritdoc/>
public List<IBeamShearActionResult> ActionResults { get; set; } = new(); public List<IBeamShearActionResult> ActionResults { get; set; } = new();
} }
} }

View File

@@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public class BeamShearSectionCalculatorResult : IBeamShearSectionLogicResult
{
public bool IsValid { get; set; }
public string? Description { get; set; }
}
}

View File

@@ -1,26 +1,82 @@
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Calculators;
using System; using StructureHelperCommon.Models.Loggers;
using System.Collections.Generic; using StructureHelperLogics.Models.BeamShears.Logics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
public class BeamShearSectionLogic : IBeamShearSectionLogic public class BeamShearSectionLogic : IBeamShearSectionLogic
{ {
private IBeamShearSectionLogicResult result; private BeamShearSectionLogicResult result;
private ConcreteStrengthLogic concreteLogic;
private StirrupStrengthLogic stirrupLogic;
public IBeamShearSectionLogicInputData InputData { get; set; } public IBeamShearSectionLogicInputData InputData { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public BeamShearSectionLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public IResult Result => result; public IResult Result => result;
public void Run() public void Run()
{ {
throw new NotImplementedException(); TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
PrepareNewResult();
InitializeStrategies();
try
{
CalculateResult();
}
catch (Exception ex)
{
result.IsValid = false;
result.Description += ex.Message;
}
}
private void CalculateResult()
{
double concreteStrength = concreteLogic.GetShearStrength();
result.ConcreteStrength = concreteStrength;
double stirrupStrength = stirrupLogic.GetShearStrength();
result.StirrupStrength = stirrupStrength;
double totalStrength = concreteStrength + stirrupStrength;
result.TotalStrength = totalStrength;
double actualShearForce = InputData.ForceTuple.Qy;
if (actualShearForce > totalStrength)
{
result.IsValid = false;
string message = $"Actual shear force Qa = {actualShearForce}(N), greater than bearing capacity Olim = {totalStrength}(N)";
result.Description += message;
TraceLogger?.AddMessage(message, TraceLogStatuses.Error);
}
else
{
string message = $"Actual shear force Qa = {actualShearForce}(N), not greater than bearing capacity Olim = {totalStrength}(N)";
TraceLogger?.AddMessage(message);
}
}
private void InitializeStrategies()
{
var sectionEffectiveness = SectionEffectivenessFactory.GetSheaEffectiveness(BeamShearSectionType.Rectangle);
double longitudinalForce = InputData.ForceTuple.Nz;
concreteLogic = new(sectionEffectiveness, InputData.InclinedSection, longitudinalForce, TraceLogger);
stirrupLogic = new(InputData.Stirrup, InputData.InclinedSection, TraceLogger);
}
private void PrepareNewResult()
{
result = new()
{
IsValid = true,
Description = string.Empty,
InputData = InputData
};
} }
} }
} }

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public class BeamShearSectionLogicResult : IBeamShearSectionLogicResult
{
public bool IsValid { get; set; }
public string? Description { get; set; }
public IBeamShearSectionLogicInputData InputData { get; set; }
public double ConcreteStrength { get; set; }
public double StirrupStrength { get; set; }
public double TotalStrength { get; set; }
public double FactorOfUsing { get => InputData.ForceTuple.Qy / TotalStrength; }
}
}

View File

@@ -14,6 +14,8 @@ namespace StructureHelperLogics.Models.BeamShears
{ {
LimitStates LimitState { get; set; } LimitStates LimitState { get; set; }
CalcTerms CalcTerm { get; set; } CalcTerms CalcTerm { get; set; }
IBeamShearSection Section { get; set; }
IStirrup Stirrup { get; set; }
IBeamShearAction BeamShearAction { get; set; } IBeamShearAction BeamShearAction { get; set; }
List<IBeamShearSectionLogicResult> SectionResults { get; set; } List<IBeamShearSectionLogicResult> SectionResults { get; set; }
} }

View File

@@ -10,5 +10,6 @@ namespace StructureHelperLogics.Models.BeamShears
public interface IBeamShearCalculator : ICalculator public interface IBeamShearCalculator : ICalculator
{ {
IBeamShearCalculatorInputData InputData { get; set; } IBeamShearCalculatorInputData InputData { get; set; }
bool ShowTraceData { get; set; }
} }
} }

View File

@@ -7,8 +7,12 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
/// <summary>
/// Implements group of results for beam shear calculator
/// </summary>
public interface IBeamShearCalculatorResult : IResult public interface IBeamShearCalculatorResult : IResult
{ {
IBeamShearCalculatorInputData InputData {get;set;}
List<IBeamShearActionResult> ActionResults { get; set; } List<IBeamShearActionResult> ActionResults { get; set; }
} }
} }

View File

@@ -9,5 +9,10 @@ namespace StructureHelperLogics.Models.BeamShears
{ {
public interface IBeamShearSectionLogicResult : IResult public interface IBeamShearSectionLogicResult : IResult
{ {
IBeamShearSectionLogicInputData InputData { get; set; }
public double ConcreteStrength { get; set; }
public double StirrupStrength { get; set; }
public double TotalStrength { get; set; }
public double FactorOfUsing { get; }
} }
} }

View File

@@ -24,6 +24,14 @@ namespace StructureHelperLogics.Models.BeamShears
/// Coordinate of end of inclined cross-section /// Coordinate of end of inclined cross-section
/// </summary> /// </summary>
double EndCoord { get; set; } double EndCoord { get; set; }
/// <summary>
/// Strength of concrete in compression, Pa
/// </summary>
double ConcreteCompressionStrength { get; set; }
/// <summary>
/// Strength of concrete in tension, Pa
/// </summary>
double ConcreteTensionStrength { get; set; }
} }
} }

View File

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
/// <summary> /// <summary>
/// Properties of concrete cross-section effectiveness for shear /// Implements properties of concrete cross-section effectiveness for shear
/// </summary> /// </summary>
public interface ISectionEffectiveness public interface ISectionEffectiveness
{ {

View File

@@ -19,5 +19,7 @@ namespace StructureHelperLogics.Models.BeamShears
public double StartCoord { get; set; } public double StartCoord { get; set; }
/// <inheritdoc/> /// <inheritdoc/>
public double EndCoord { get; set; } public double EndCoord { get; set; }
public double ConcreteCompressionStrength { get; set; }
public double ConcreteTensionStrength { get; set; }
} }
} }

View File

@@ -16,6 +16,7 @@ namespace StructureHelperLogics.Models.BeamShears
if (ReferenceEquals(targetObject, sourceObject)) { return; }; if (ReferenceEquals(targetObject, sourceObject)) { return; };
InitializeStrategies(); InitializeStrategies();
hasActionUpdateStrategy?.Update(targetObject, sourceObject); hasActionUpdateStrategy?.Update(targetObject, sourceObject);
hasSectionsUpdateStrategy?.Update(targetObject, sourceObject);
hasStirrupsUpdateStrategy?.Update(targetObject, sourceObject); hasStirrupsUpdateStrategy?.Update(targetObject, sourceObject);
} }

View File

@@ -13,6 +13,7 @@ namespace StructureHelperLogics.Models.BeamShears
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject); CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }; if (ReferenceEquals(targetObject, sourceObject)) { return; };
targetObject.Name = sourceObject.Name; targetObject.Name = sourceObject.Name;
targetObject.ShowTraceData = sourceObject.ShowTraceData;
targetObject.InputData ??= new BeamShearCalculatorInputData(Guid.NewGuid()); targetObject.InputData ??= new BeamShearCalculatorInputData(Guid.NewGuid());
InitializeStrategies(); InitializeStrategies();
inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData); inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);

View File

@@ -1,24 +1,27 @@
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.BeamShears.Logics;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
internal class BeamSectionShearStrengthLogic : IBeamShearStrenghLogic public class ConcreteStrengthLogic : IBeamShearStrenghLogic
{ {
private readonly double longitudinalForce;
private readonly ISectionEffectiveness sectionEffectiveness; private readonly ISectionEffectiveness sectionEffectiveness;
private readonly double concreteStrength;
private readonly IInclinedSection inclinedSection; private readonly IInclinedSection inclinedSection;
private IGetLongitudinalForceFactorLogic getLongitudinalForceFactorLogic;
private double crackLength; private double crackLength;
public BeamSectionShearStrengthLogic( public ConcreteStrengthLogic(
ISectionEffectiveness sectionEffectiveness, ISectionEffectiveness sectionEffectiveness,
double concreteStrength,
IInclinedSection inclinedSection, IInclinedSection inclinedSection,
double longitudinalForce,
IShiftTraceLogger? traceLogger) IShiftTraceLogger? traceLogger)
{ {
this.sectionEffectiveness = sectionEffectiveness; this.sectionEffectiveness = sectionEffectiveness;
this.concreteStrength = concreteStrength;
this.inclinedSection = inclinedSection; this.inclinedSection = inclinedSection;
this.longitudinalForce = longitudinalForce;
TraceLogger = traceLogger; TraceLogger = traceLogger;
} }
@@ -26,18 +29,34 @@ namespace StructureHelperLogics.Models.BeamShears
public double GetShearStrength() public double GetShearStrength()
{ {
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
InitializeStrategies();
TraceLogger?.AddMessage($"Base shape factor = {sectionEffectiveness.BaseShapeFactor}, (dimensionless)"); TraceLogger?.AddMessage($"Base shape factor = {sectionEffectiveness.BaseShapeFactor}, (dimensionless)");
TraceLogger?.AddMessage($"Section shape factor = {sectionEffectiveness.ShapeFactor}, (dimensionless)"); TraceLogger?.AddMessage($"Section shape factor = {sectionEffectiveness.ShapeFactor}, (dimensionless)");
TraceLogger?.AddMessage($"Effective depth = {inclinedSection.EffectiveDepth}, (m)"); TraceLogger?.AddMessage($"Effective depth = {inclinedSection.EffectiveDepth}, (m)");
crackLength = inclinedSection.EndCoord - inclinedSection.StartCoord; crackLength = inclinedSection.EndCoord - inclinedSection.StartCoord;
TraceLogger?.AddMessage($"Crack length = {inclinedSection.EndCoord} - {inclinedSection.StartCoord} = {crackLength}, (m)"); TraceLogger?.AddMessage($"Crack length = {inclinedSection.EndCoord} - {inclinedSection.StartCoord} = {crackLength}, (m)");
RestrictCrackLength(); RestrictCrackLength();
double concreteMoment = sectionEffectiveness.BaseShapeFactor * sectionEffectiveness.ShapeFactor * concreteStrength * inclinedSection.WebWidth * inclinedSection.EffectiveDepth * inclinedSection.EffectiveDepth; SetLongitudinalForce();
double shearStrength = concreteMoment / crackLength; double factorOfLongitudinalForce = getLongitudinalForceFactorLogic.GetFactor();
TraceLogger?.AddMessage($"Factor of longitudinal force = {factorOfLongitudinalForce}, (dimensionless)");
double concreteMoment = sectionEffectiveness.BaseShapeFactor * sectionEffectiveness.ShapeFactor * inclinedSection.ConcreteTensionStrength * inclinedSection.WebWidth * inclinedSection.EffectiveDepth * inclinedSection.EffectiveDepth;
double shearStrength = factorOfLongitudinalForce * concreteMoment / crackLength;
TraceLogger?.AddMessage($"Shear strength of concrete = {shearStrength}, (N)"); TraceLogger?.AddMessage($"Shear strength of concrete = {shearStrength}, (N)");
return shearStrength; return shearStrength;
} }
private void InitializeStrategies()
{
getLongitudinalForceFactorLogic ??= new GetLogitudinalForceFactorLogic(TraceLogger?.GetSimilarTraceLogger(100));
}
private void SetLongitudinalForce()
{
getLongitudinalForceFactorLogic.LongitudinalForce = longitudinalForce;
getLongitudinalForceFactorLogic.InclinedSection = inclinedSection;
}
private void RestrictCrackLength() private void RestrictCrackLength()
{ {
double maxCrackLength = sectionEffectiveness.MaxCrackLengthRatio * inclinedSection.EffectiveDepth; double maxCrackLength = sectionEffectiveness.MaxCrackLengthRatio * inclinedSection.EffectiveDepth;
@@ -49,7 +68,7 @@ namespace StructureHelperLogics.Models.BeamShears
return; return;
} }
double minCrackLength = sectionEffectiveness.MinCrackLengthRatio * inclinedSection.EffectiveDepth; double minCrackLength = sectionEffectiveness.MinCrackLengthRatio * inclinedSection.EffectiveDepth;
if (crackLength > minCrackLength) if (crackLength < minCrackLength)
{ {
TraceLogger?.AddMessage($"Crack length c = {crackLength} is less than minimum crack length = {minCrackLength}"); TraceLogger?.AddMessage($"Crack length c = {crackLength} is less than minimum crack length = {minCrackLength}");
crackLength = minCrackLength; crackLength = minCrackLength;

View File

@@ -51,7 +51,8 @@ namespace StructureHelperLogics.Models.BeamShears
for (int i = 0; i < inputData.StepCount + 1; i++) for (int i = 0; i < inputData.StepCount + 1; i++)
{ {
double endCoord = step * i; double endCoord = step * i;
coordinates.Add(endCoord); double roundedEndCoord = Math.Round(endCoord, 6);
coordinates.Add(roundedEndCoord);
} }
} }
private void Check() private void Check()

View File

@@ -0,0 +1,109 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears.Logics
{
public class GetLogitudinalForceFactorLogic : IGetLongitudinalForceFactorLogic
{
private const double fstRatioInCompression = 1.25;
private const double sndRationInCompression = 0.75;
private double sectionArea;
public IShiftTraceLogger? TraceLogger { get; set; }
public IInclinedSection InclinedSection { get; set; }
public double LongitudinalForce { get; set; }
public GetLogitudinalForceFactorLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public double GetFactor()
{
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage("Logic of calculating of factor of influence of longitudinal force according to SP 63.13330.2018");
Check();
if (LongitudinalForce == 0)
{
TraceLogger?.AddMessage("Longitudinal force is zero", TraceLogStatuses.Service);
return 1;
}
sectionArea = InclinedSection.WebWidth * InclinedSection.FullDepth;
TraceLogger?.AddMessage($"Area of cross-section Ac = {InclinedSection.WebWidth} * {InclinedSection.FullDepth} = {sectionArea}(m^2)");
if (LongitudinalForce < 0)
{
TraceLogger?.AddMessage($"Longitudinal force N={LongitudinalForce}(N) is negative (compression)", TraceLogStatuses.Service);
return GetNegForceResult();
}
else
{
TraceLogger?.AddMessage("Longitudinal force N={LongitudinalForce}(N) is positive (tension)", TraceLogStatuses.Service);
return GetPosForceResult();
}
}
private void Check()
{
if (InclinedSection is null)
{
string errorString = ErrorStrings.DataIsInCorrect + "Inclined section is null";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
if (InclinedSection.WebWidth <= 0 || InclinedSection.FullDepth <= 0)
{
string errorString = ErrorStrings.DataIsInCorrect + $"Inclined section width = {InclinedSection.WebWidth}(m), and full depth = {InclinedSection.FullDepth}, but both of them must be greater than zero";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
}
private double GetPosForceResult()
{
double stressInConcrete = LongitudinalForce / sectionArea;
TraceLogger?.AddMessage($"Average stress in concrete (positive in tension) Sigma = {LongitudinalForce}(N) / {sectionArea}(m^2) = {stressInConcrete}(Pa)");
double concreteStrength = InclinedSection.ConcreteTensionStrength;
TraceLogger?.AddMessage($"Concrete strength Rbt = {concreteStrength}(Pa)");
double stressRatio = stressInConcrete / concreteStrength;
TraceLogger?.AddMessage($"Stress ratio rt = {stressInConcrete} / {concreteStrength} = {stressRatio}(dimensionless)");
double factor = 1 - 0.5 * stressRatio;
factor = Math.Max(factor, 0);
TraceLogger?.AddMessage($"Factor value fi_n = {factor}(dimensionless)");
return factor;
}
private double GetNegForceResult()
{
double stressInConcrete = (-1) * LongitudinalForce / sectionArea;
TraceLogger?.AddMessage($"Average stress in concrete (positive in compression) Sigma = {LongitudinalForce}(N) / {sectionArea}(m^2) = {stressInConcrete}(Pa)");
double concreteStrength = InclinedSection.ConcreteCompressionStrength;
TraceLogger?.AddMessage($"Concrete strength Rb = {concreteStrength}(Pa)");
double stressRatio = stressInConcrete / concreteStrength;
TraceLogger?.AddMessage($"Stress ratio rc = {stressInConcrete} / {concreteStrength} = {stressRatio}(dimensionless)");
double factor;
if (stressRatio < fstRatioInCompression)
{
TraceLogger?.AddMessage($"Stress ratio rc = {stressRatio} < {fstRatioInCompression}");
factor = 1 + stressRatio;
}
else if (stressRatio > sndRationInCompression)
{
factor = 5 * (1 - stressRatio);
factor = Math.Max(factor, 0);
}
else
{
factor = 1;
}
TraceLogger?.AddMessage($"Factor value fi_n = {factor}(dimensionless)");
return factor;
}
}
}

View File

@@ -5,7 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears.Logics
{ {
/// <summary> /// <summary>
/// Implement logic for calculation of bearing capacity of inclined section for shear /// Implement logic for calculation of bearing capacity of inclined section for shear

View File

@@ -0,0 +1,15 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears.Logics
{
public interface IGetLongitudinalForceFactorLogic : IGetFactorLogic
{
public double LongitudinalForce { get; set; }
public IInclinedSection InclinedSection { get; set; }
}
}

View File

@@ -1,6 +1,7 @@
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Services; using StructureHelperCommon.Services;
using StructureHelperLogics.Models.BeamShears.Logics;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia //Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved. //All rights reserved.
@@ -8,14 +9,15 @@ using StructureHelperCommon.Services;
namespace StructureHelperLogics.Models.BeamShears namespace StructureHelperLogics.Models.BeamShears
{ {
/// <inheritdoc/> /// <inheritdoc/>
public class BeamShearStrengthByStirrupDensityLogic : IBeamShearStrenghLogic public class StirrupByDensityStrengthLogic : IBeamShearStrenghLogic
{ {
private const double minStirrupRatio = 0.25;
private readonly IStirrupEffectiveness stirrupEffectiveness; private readonly IStirrupEffectiveness stirrupEffectiveness;
private readonly IStirrupByDensity stirrupByDensity; private readonly IStirrupByDensity stirrupByDensity;
private readonly IInclinedSection inclinedSection; private readonly IInclinedSection inclinedSection;
public BeamShearStrengthByStirrupDensityLogic( public StirrupByDensityStrengthLogic(
IStirrupEffectiveness stirrupEffectiveness, IStirrupEffectiveness stirrupEffectiveness,
IStirrupByDensity stirrupByDensity, IStirrupByDensity stirrupByDensity,
IInclinedSection inclinedSection, IInclinedSection inclinedSection,
@@ -40,8 +42,16 @@ namespace StructureHelperLogics.Models.BeamShears
TraceLogger?.AddMessage($"Max length of crack = {stirrupEffectiveness.MaxCrackLengthRatio} * {inclinedSection.EffectiveDepth} = {maxCrackLength}(m)"); TraceLogger?.AddMessage($"Max length of crack = {stirrupEffectiveness.MaxCrackLengthRatio} * {inclinedSection.EffectiveDepth} = {maxCrackLength}(m)");
double finalCrackLength = Math.Min(crackLength, maxCrackLength); double finalCrackLength = Math.Min(crackLength, maxCrackLength);
TraceLogger?.AddMessage($"Length of crack = Min({crackLength}, {maxCrackLength}) = {finalCrackLength}(m)"); TraceLogger?.AddMessage($"Length of crack = Min({crackLength}, {maxCrackLength}) = {finalCrackLength}(m)");
double strength = stirrupEffectiveness.StirrupShapeFactor * stirrupEffectiveness.StirrupPlacementFactor * finalCrackLength * stirrupByDensity.StirrupDensity; double finalDensity = stirrupEffectiveness.StirrupShapeFactor * stirrupEffectiveness.StirrupPlacementFactor * stirrupByDensity.StirrupDensity;
TraceLogger?.AddMessage($"Bearing capacity of stirrups V = {stirrupEffectiveness.StirrupShapeFactor} * {stirrupEffectiveness.StirrupPlacementFactor} * {finalCrackLength} * {stirrupByDensity.StirrupDensity} = {strength}(N)"); TraceLogger?.AddMessage($"Stirrups design density qsw = {finalDensity}(N/m)");
double concreteDensity = inclinedSection.WebWidth * inclinedSection.ConcreteTensionStrength;
if (finalDensity < minStirrupRatio * concreteDensity)
{
TraceLogger?.AddMessage($"Since stirrups design density qsw = {finalDensity}(N/m) less than {minStirrupRatio} * {concreteDensity}, final density is equal to zero");
finalDensity = 0;
}
double strength = finalDensity * finalCrackLength;
TraceLogger?.AddMessage($"Bearing capacity of stirrups V = {finalDensity} * {finalCrackLength} = {strength}(N)");
TraceLogger?.AddMessage("Calculation has been finished successfully", TraceLogStatuses.Debug); TraceLogger?.AddMessage("Calculation has been finished successfully", TraceLogStatuses.Debug);
return strength; return strength;
} }

View File

@@ -0,0 +1,60 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.Models.BeamShears.Logics
{
public class StirrupByRebarStrengthLogic : IBeamShearStrenghLogic
{
private IStirrupEffectiveness stirrupEffectiveness;
private IStirrupByRebar stirrupByRebar;
private IInclinedSection inclinedSection;
private StirrupByDensityStrengthLogic stirrupDensityStrengthLogic;
private IConvertStrategy<IStirrupByDensity, IStirrupByRebar> convertStrategy;
public IShiftTraceLogger? TraceLogger { get; set; }
public StirrupByRebarStrengthLogic(
IStirrupEffectiveness stirrupEffectiveness,
IStirrupByRebar stirrupByRebar,
IInclinedSection inclinedSection,
StirrupByDensityStrengthLogic stirrupDensityStrengthLogic,
IConvertStrategy<IStirrupByDensity, IStirrupByRebar> convertStrategy,
IShiftTraceLogger? traceLogger)
{
this.stirrupEffectiveness = stirrupEffectiveness;
this.stirrupByRebar = stirrupByRebar;
this.inclinedSection = inclinedSection;
this.stirrupDensityStrengthLogic = stirrupDensityStrengthLogic;
this.convertStrategy = convertStrategy;
TraceLogger = traceLogger;
}
public StirrupByRebarStrengthLogic(
IStirrupEffectiveness stirrupEffectiveness,
IStirrupByRebar stirrupByRebar,
IInclinedSection inclinedSection,
IShiftTraceLogger? traceLogger)
{
this.stirrupEffectiveness = stirrupEffectiveness;
this.stirrupByRebar = stirrupByRebar;
this.inclinedSection = inclinedSection;
TraceLogger = traceLogger;
}
public double GetShearStrength()
{
InitializeStrategies();
double shearStrength = stirrupDensityStrengthLogic.GetShearStrength();
return shearStrength;
}
private void InitializeStrategies()
{
convertStrategy ??= new StirrupByRebarToDensityConvertStrategy(TraceLogger);
IStirrupByDensity stirrupByDensity = convertStrategy.Convert(stirrupByRebar);
stirrupDensityStrengthLogic ??= new(stirrupEffectiveness, stirrupByDensity, inclinedSection, TraceLogger);
}
}
}

View File

@@ -13,6 +13,11 @@ namespace StructureHelperLogics.Models.BeamShears
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; } public IShiftTraceLogger TraceLogger { get; set; }
public StirrupByRebarToDensityConvertStrategy(IShiftTraceLogger traceLogger)
{
TraceLogger = traceLogger;
}
public StirrupByRebarToDensityConvertStrategy(IUpdateStrategy<IStirrup> updateStrategy, IShiftTraceLogger traceLogger) public StirrupByRebarToDensityConvertStrategy(IUpdateStrategy<IStirrup> updateStrategy, IShiftTraceLogger traceLogger)
{ {
this.updateStrategy = updateStrategy; this.updateStrategy = updateStrategy;

View File

@@ -0,0 +1,48 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears.Logics
{
internal class StirrupStrengthLogic : IBeamShearStrenghLogic
{
private IStirrup stirrup;
private IInclinedSection inclinedSection;
private IBeamShearStrenghLogic stirrupDensityStrengthLogic;
public StirrupStrengthLogic(IStirrup stirrup, IInclinedSection inclinedSection, IShiftTraceLogger? traceLogger)
{
this.stirrup = stirrup;
this.inclinedSection = inclinedSection;
TraceLogger = traceLogger;
}
public IShiftTraceLogger? TraceLogger { get; set; }
public double GetShearStrength()
{
var stirrupEffectiveness = StirrupEffectivenessFactory.GetEffectiveness(BeamShearSectionType.Rectangle);
if (stirrup is IStirrupByDensity stirrupByDensity)
{
TraceLogger?.AddMessage("Stirrups type is stirrup by density");
stirrupDensityStrengthLogic = new StirrupByDensityStrengthLogic(stirrupEffectiveness, stirrupByDensity, inclinedSection,TraceLogger);
return stirrupDensityStrengthLogic.GetShearStrength();
}
else if (stirrup is IStirrupByRebar stirrupByRebar)
{
TraceLogger?.AddMessage("Stirrups type is stirrup by rebar");
stirrupDensityStrengthLogic = new StirrupByRebarStrengthLogic(stirrupEffectiveness, stirrupByRebar, inclinedSection, TraceLogger);
return stirrupDensityStrengthLogic.GetShearStrength();
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
}
}
}
}

View File

@@ -17,7 +17,7 @@ namespace StructureHelperLogics.Models.Materials
private readonly List<IMaterialLogic> materialLogics; private readonly List<IMaterialLogic> materialLogics;
private LMBuilders.ConcreteOptions lmOptions; private LMBuilders.ConcreteOptions lmOptions;
private IMaterialOptionLogic optionLogic; private IMaterialOptionLogic optionLogic;
private IFactorLogic factorLogic => new FactorLogic(SafetyFactors); private IMaterialFactorLogic factorLogic => new MaterialFactorLogic(SafetyFactors);
private LMLogic.ITrueStrengthLogic strengthLogic; private LMLogic.ITrueStrengthLogic strengthLogic;
private IUpdateStrategy<IConcreteLibMaterial> updateStrategy = new ConcreteLibUpdateStrategy(); private IUpdateStrategy<IConcreteLibMaterial> updateStrategy = new ConcreteLibUpdateStrategy();

View File

@@ -72,7 +72,7 @@ namespace StructureHelperLogics.Models.Materials
{ {
const double gammaF2Max = 0.9d; const double gammaF2Max = 0.9d;
double gammaF2; double gammaF2;
IFactorLogic factorLogic = new FactorLogic(SafetyFactors); IMaterialFactorLogic factorLogic = new MaterialFactorLogic(SafetyFactors);
var factors = factorLogic.GetTotalFactor(LimitStates.ULS, CalcTerms.ShortTerm); var factors = factorLogic.GetTotalFactor(LimitStates.ULS, CalcTerms.ShortTerm);
var rf = TensileStrength * factors.Tensile; var rf = TensileStrength * factors.Tensile;
var epsUlt = rf / Modulus; var epsUlt = rf / Modulus;

View File

@@ -18,7 +18,7 @@ namespace StructureHelperLogics.Models.Materials
{ {
IMaterial material = new Material(); IMaterial material = new Material();
material.InitModulus = elasticMaterial.Modulus; material.InitModulus = elasticMaterial.Modulus;
IFactorLogic factorLogic = new FactorLogic(elasticMaterial.SafetyFactors); IMaterialFactorLogic factorLogic = new MaterialFactorLogic(elasticMaterial.SafetyFactors);
var factors = factorLogic.GetTotalFactor(limitState, calcTerm); var factors = factorLogic.GetTotalFactor(limitState, calcTerm);
parameters = new List<double>() parameters = new List<double>()
{ {

View File

@@ -18,7 +18,7 @@ namespace StructureHelperLogics.Models.Materials
{ {
const MaterialTypes materialType = MaterialTypes.Reinforcement; const MaterialTypes materialType = MaterialTypes.Reinforcement;
private IFactorLogic factorLogic => new FactorLogic(SafetyFactors); private IMaterialFactorLogic factorLogic => new MaterialFactorLogic(SafetyFactors);
private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic; private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic;
private readonly List<IMaterialLogic> materialLogics; private readonly List<IMaterialLogic> materialLogics;

View File

@@ -15,7 +15,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
private Mock<IStirrupByDensity> _mockStirrupByDensity; private Mock<IStirrupByDensity> _mockStirrupByDensity;
private Mock<IInclinedSection> _mockInclinedSection; private Mock<IInclinedSection> _mockInclinedSection;
private Mock<IShiftTraceLogger> _mockTraceLogger; private Mock<IShiftTraceLogger> _mockTraceLogger;
private BeamShearStrengthByStirrupDensityLogic _beamShearStrength; private StirrupByDensityStrengthLogic _beamShearStrength;
[SetUp] [SetUp]
public void Setup() public void Setup()
@@ -25,7 +25,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
_mockInclinedSection = new Mock<IInclinedSection>(); _mockInclinedSection = new Mock<IInclinedSection>();
_mockTraceLogger = new Mock<IShiftTraceLogger>(); _mockTraceLogger = new Mock<IShiftTraceLogger>();
_beamShearStrength = new BeamShearStrengthByStirrupDensityLogic( _beamShearStrength = new StirrupByDensityStrengthLogic(
_mockStirrupEffectiveness.Object, _mockStirrupEffectiveness.Object,
_mockStirrupByDensity.Object, _mockStirrupByDensity.Object,
_mockInclinedSection.Object, _mockInclinedSection.Object,
@@ -61,7 +61,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
public void GetShearStrength_ThrowsException_WhenDependenciesAreNull() public void GetShearStrength_ThrowsException_WhenDependenciesAreNull()
{ {
// Arrange // Arrange
var invalidInstance = new BeamShearStrengthByStirrupDensityLogic( var invalidInstance = new StirrupByDensityStrengthLogic(
_mockStirrupEffectiveness.Object, _mockStirrupEffectiveness.Object,
null, // Invalid null, // Invalid
_mockInclinedSection.Object, _mockInclinedSection.Object,