Change curvature calculator
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperCommon.Services.Units;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<DataTemplate x:Key="DeflectionTextBox">
|
||||
<TextBlock Grid.Row="0" Text="{Binding Deflection, Converter={StaticResource LengthConverter}, ConverterParameter='Fixed2'}" HorizontalAlignment="Right">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsDeflectionLessThanUltimate}" Value="false">
|
||||
<Setter Property="Background" Value="{StaticResource WarningColorBrush}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="DeflectionGrid">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentControl ContentTemplate="{StaticResource DeflectionTextBox}" Content="{Binding LongTermResult}"/>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource DeflectionTextBox}" Content="{Binding ShortTermResult}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
@@ -8,6 +8,13 @@
|
||||
d:DataContext="{d:DesignInstance local:CurvatureCalculatorResultViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Result of calculation of curvatures and deflections" Height="450" Width="800" MinHeight="300" MinWidth="600" MaxHeight="800" MaxWidth="1000" WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/Windows/CalculationWindows/CalculatorsViews/Curvatures/Curvature.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<DockPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -27,7 +34,7 @@
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Header="Valid" Binding="{Binding Path=IsValid}"/>
|
||||
<DataGridTextColumn Header="Action name" Binding="{Binding InputData.TupleName}" Width="120"/>
|
||||
<DataGridTextColumn Header="Action name" Binding="{Binding InputData.ForcePair.Name}" Width="120"/>
|
||||
<DataGridTemplateColumn Header="Combination term" Width="120">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
@@ -50,8 +57,8 @@
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{Binding InputData.LongTermTuple.Mx, Converter={StaticResource MomentConverter}}" HorizontalAlignment="Right" />
|
||||
<TextBlock Grid.Row="1" Text="{Binding InputData.ShortTermTuple.Mx, Converter={StaticResource MomentConverter}}" HorizontalAlignment="Right" />
|
||||
<TextBlock Grid.Row="0" Text="{Binding InputData.ForcePair.LongForceTuple.Mx, Converter={StaticResource MomentConverter}}" HorizontalAlignment="Right" />
|
||||
<TextBlock Grid.Row="1" Text="{Binding InputData.ForcePair.FullForceTuple.Mx, Converter={StaticResource MomentConverter}}" HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
@@ -64,8 +71,8 @@
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{Binding InputData.LongTermTuple.My, Converter={StaticResource MomentConverter}}" HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Row="1" Text="{Binding InputData.ShortTermTuple.My, Converter={StaticResource MomentConverter}}" HorizontalAlignment="Right" />
|
||||
<TextBlock Grid.Row="0" Text="{Binding InputData.ForcePair.LongForceTuple.My, Converter={StaticResource MomentConverter}}" HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Row="1" Text="{Binding InputData.ForcePair.FullForceTuple.My, Converter={StaticResource MomentConverter}}" HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
@@ -78,23 +85,100 @@
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{Binding InputData.LongTermTuple.Nz, Converter={StaticResource ForceConverter}}" HorizontalAlignment="Right" />
|
||||
<TextBlock Grid.Row="1" Text="{Binding InputData.ShortTermTuple.Nz, Converter={StaticResource ForceConverter}}" HorizontalAlignment="Right" />
|
||||
<TextBlock Grid.Row="0" Text="{Binding InputData.ForcePair.LongForceTuple.Nz, Converter={StaticResource ForceConverter}}" HorizontalAlignment="Right" />
|
||||
<TextBlock Grid.Row="1" Text="{Binding InputData.ForcePair.FullForceTuple.Nz, Converter={StaticResource ForceConverter}}" HorizontalAlignment="Right" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="Crack width" Width="80">
|
||||
<DataGridTemplateColumn Header="delta X" Width="80">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl ContentTemplate="{StaticResource CrackGrid}" Content="{Binding}"/>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentControl ContentTemplate="{StaticResource DeflectionTextBox}" Content="{Binding ForceCalculatorResult.SectionResult.LongTermResult.DeflectionMy}"/>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource DeflectionTextBox}" Content="{Binding ForceCalculatorResult.SectionResult.ShortTermResult.DeflectionMy}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="Description" Width="300" Binding="{Binding Description}"/>
|
||||
<DataGridTemplateColumn Header="delta Y" Width="80">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentControl ContentTemplate="{StaticResource DeflectionTextBox}" Content="{Binding ForceCalculatorResult.SectionResult.LongTermResult.DeflectionMx}"/>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource DeflectionTextBox}" Content="{Binding ForceCalculatorResult.SectionResult.ShortTermResult.DeflectionMx}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="delta Z" Width="80">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentControl ContentTemplate="{StaticResource DeflectionTextBox}" Content="{Binding ForceCalculatorResult.SectionResult.LongTermResult.DeflectionNz}"/>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource DeflectionTextBox}" Content="{Binding ForceCalculatorResult.SectionResult.ShortTermResult.DeflectionNz}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="kx" Width="80">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding ForceCalculatorResult.SectionResult.LongTermResult.DeflectionMx.Curvature, Converter={StaticResource Curvature}}"/>
|
||||
<TextBlock Grid.Row="1" Text="{Binding ForceCalculatorResult.SectionResult.ShortTermResult.DeflectionMx.Curvature, Converter={StaticResource Curvature}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="ky" Width="80">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding ForceCalculatorResult.SectionResult.LongTermResult.DeflectionMy.Curvature, Converter={StaticResource Curvature}}"/>
|
||||
<TextBlock Grid.Row="1" Text="{Binding ForceCalculatorResult.SectionResult.ShortTermResult.DeflectionMy.Curvature, Converter={StaticResource Curvature}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="epsz" Width="80">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding ForceCalculatorResult.SectionResult.LongTermResult.DeflectionNz.Curvature}"/>
|
||||
<TextBlock Grid.Row="1" Text="{Binding ForceCalculatorResult.SectionResult.ShortTermResult.DeflectionNz.Curvature}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="Description" Width="300" Binding="{Binding ForceCalculatorResult.Description}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<TextBlock Grid.Row="1" Text="{Binding CrackResult.Description}"/>
|
||||
<TextBlock Grid.Row="1" Text="{Binding Result.Description}"/>
|
||||
<ContentControl Grid.Row="2" ContentTemplate="{StaticResource ResultValidness}" Content="{Binding ValidResultCounter}"/>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
|
||||
@@ -9,6 +9,26 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.Curvatures
|
||||
public class CurvatureForceCalculatorResultViewModel : ViewModelBase
|
||||
{
|
||||
private readonly ICurvatureForceCalculatorResult resultModel;
|
||||
private ICurvatureForceCalculatorInputData inputData;
|
||||
|
||||
public bool IsValid
|
||||
{
|
||||
get
|
||||
{
|
||||
return resultModel.IsValid;
|
||||
}
|
||||
set
|
||||
{
|
||||
resultModel.IsValid = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ICurvatureForceCalculatorInputData InputData
|
||||
{
|
||||
get => resultModel.InputData;
|
||||
}
|
||||
|
||||
public ICurvatureForceCalculatorResult ForceCalculatorResult => resultModel;
|
||||
|
||||
public CurvatureForceCalculatorResultViewModel(ICurvatureForceCalculatorResult resultModel)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,8 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
private IEnumerable<INdmPrimitive> selectedNdmPrimitives;
|
||||
private IEnumerable<INdm> ndms;
|
||||
private IReport isoFieldReport;
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
|
||||
|
||||
@@ -315,7 +317,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
{
|
||||
foreach (var item in ndmPrimitives)
|
||||
{
|
||||
ForceTupleService.CopyProperties(wnd.StrainTuple, item.NdmElement.AutoPrestrain);
|
||||
ForceTupleServiceLogic.CopyProperties(wnd.StrainTuple, item.NdmElement.AutoPrestrain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
using StructureHelper.Windows.UserControls;
|
||||
using StructureHelper.Windows.ViewModels.Materials;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace StructureHelper.Windows.Forces
|
||||
{
|
||||
@@ -24,6 +11,8 @@ namespace StructureHelper.Windows.Forces
|
||||
public partial class ForceInterpolationControl : UserControl
|
||||
{
|
||||
private ForceTupleInterpolationViewModel? properties;
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
public ForceTupleInterpolationViewModel? Properties
|
||||
{
|
||||
@@ -41,16 +30,16 @@ namespace StructureHelper.Windows.Forces
|
||||
private void StartValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
var obj = (MultiplyDouble)sender;
|
||||
var tmpTuple = ForceTupleService.MultiplyTupleByFactor(Properties.StartDesignForce, obj.DoubleFactor);
|
||||
ForceTupleService.CopyProperties(tmpTuple, Properties.StartDesignForce, 1d);
|
||||
var tmpTuple = ForceTupleServiceLogic.MultiplyTupleByFactor(Properties.StartDesignForce, obj.DoubleFactor);
|
||||
ForceTupleServiceLogic.CopyProperties(tmpTuple, Properties.StartDesignForce, 1d);
|
||||
Properties.RefreshStartTuple();
|
||||
}
|
||||
|
||||
private void FinishValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
var obj = (MultiplyDouble)sender;
|
||||
var tmpTuple = ForceTupleService.MultiplyTupleByFactor(Properties.FinishDesignForce, obj.DoubleFactor);
|
||||
ForceTupleService.CopyProperties(tmpTuple, Properties.FinishDesignForce, 1d);
|
||||
var tmpTuple = ForceTupleServiceLogic.MultiplyTupleByFactor(Properties.FinishDesignForce, obj.DoubleFactor);
|
||||
ForceTupleServiceLogic.CopyProperties(tmpTuple, Properties.FinishDesignForce, 1d);
|
||||
Properties.RefreshFinishTuple();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
{
|
||||
StrainTuple SourceTuple;
|
||||
private double coefficient;
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
public double Coefficient
|
||||
{
|
||||
@@ -35,7 +37,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
public StrainTuple GetStrainTuple()
|
||||
{
|
||||
var result = new StrainTuple();
|
||||
ForceTupleService.CopyProperties(SourceTuple, result, coefficient);
|
||||
ForceTupleServiceLogic.CopyProperties(SourceTuple, result, coefficient);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace StructureHelperCommon.Models.Forces
|
||||
public class ForceCombinationList : IForceCombinationList
|
||||
{
|
||||
readonly IUpdateStrategy<IAction> updateStrategy = new ActionUpdateStrategy();
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
@@ -80,7 +82,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
var forceTupleList = DesignForces.Where(x => x.LimitState == limitState & x.CalcTerm == calcTerm);
|
||||
foreach (var item in forceTupleList)
|
||||
{
|
||||
designForceTuple.ForceTuple = ForceTupleService.SumTuples(designForceTuple.ForceTuple, item.ForceTuple) as ForceTuple;
|
||||
designForceTuple.ForceTuple = ForceTupleServiceLogic.SumTuples(designForceTuple.ForceTuple, item.ForceTuple) as ForceTuple;
|
||||
}
|
||||
result.DesignForces.Add(designForceTuple);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace StructureHelperCommon.Models.Forces
|
||||
public class ForceTuple : IForceTuple
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> updateStrategy = new ForceTupleUpdateStrategy();
|
||||
private static IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private static IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
@@ -54,7 +56,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
public static ForceTuple operator +(ForceTuple first) => first;
|
||||
public static ForceTuple operator +(ForceTuple first, ForceTuple second)
|
||||
{
|
||||
return ForceTupleService.SumTuples(first, second) as ForceTuple;
|
||||
return ForceTupleServiceLogic.SumTuples(first, second) as ForceTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,16 @@ namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ForceActionUpdateStrategy : IUpdateStrategy<IForceAction>
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceAction> forceActionUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IForceFactoredList> factorUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy;
|
||||
private readonly IUpdateStrategy<IForceCombinationFromFile> fileCombinationUpdateStrategy;
|
||||
private IUpdateStrategy<IForceAction> forceUpdateStrategy;
|
||||
private IUpdateStrategy<IDesignForcePair> pairUpdateStrategy;
|
||||
private IUpdateStrategy<IForceFactoredList> factorUpdateStrategy;
|
||||
private IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy;
|
||||
private IUpdateStrategy<IForceCombinationFromFile> fileCombinationUpdateStrategy;
|
||||
private IUpdateStrategy<IForceAction> ForceUpdateStrategy => forceUpdateStrategy ??= new ForceActionBaseUpdateStrategy();
|
||||
private IUpdateStrategy<IDesignForcePair> PairUpdateStrategy => pairUpdateStrategy ??= new ForcePairUpdateStrategy();
|
||||
private IUpdateStrategy<IForceFactoredList> FactorUpdateStrategy => factorUpdateStrategy ??= new ForceFactoredListUpdateStrategy();
|
||||
private IUpdateStrategy<IForceCombinationList> ForceListUpdateStrategy => forceListUpdateStrategy ??= new ForceCombinationListUpdateStrategy();
|
||||
private IUpdateStrategy<IForceCombinationFromFile> FileCombinationUpdateStrategy => fileCombinationUpdateStrategy ??= new ForceCombinationFromFileUpdateStrategy();
|
||||
|
||||
public ForceActionUpdateStrategy(
|
||||
IUpdateStrategy<IForceAction> forceActionUpdateStrategy,
|
||||
@@ -22,20 +27,14 @@ namespace StructureHelperCommon.Models.Forces
|
||||
IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy,
|
||||
IUpdateStrategy<IForceCombinationFromFile> fileCombinationUpdateStrategy)
|
||||
{
|
||||
this.forceActionUpdateStrategy = forceActionUpdateStrategy;
|
||||
this.forcePairUpdateStrategy = forcePairUpdateStrategy;
|
||||
this.forceUpdateStrategy = forceActionUpdateStrategy;
|
||||
this.pairUpdateStrategy = forcePairUpdateStrategy;
|
||||
this.factorUpdateStrategy = factorUpdateStrategy;
|
||||
this.forceListUpdateStrategy = forceListUpdateStrategy;
|
||||
this.fileCombinationUpdateStrategy = fileCombinationUpdateStrategy;
|
||||
}
|
||||
|
||||
public ForceActionUpdateStrategy() : this(
|
||||
new ForceActionBaseUpdateStrategy(),
|
||||
new ForcePairUpdateStrategy(),
|
||||
new ForceFactoredListUpdateStrategy(),
|
||||
new ForceCombinationListUpdateStrategy(),
|
||||
new ForceCombinationFromFileUpdateStrategy()
|
||||
)
|
||||
public ForceActionUpdateStrategy()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -45,27 +44,31 @@ namespace StructureHelperCommon.Models.Forces
|
||||
CheckObject.ThrowIfNull(targetObject);
|
||||
CheckObject.ThrowIfNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
forceActionUpdateStrategy.Update(targetObject, sourceObject);
|
||||
ForceUpdateStrategy.Update(targetObject, sourceObject);
|
||||
UpdateChildProperties(targetObject, sourceObject);
|
||||
}
|
||||
|
||||
private void UpdateChildProperties(IForceAction targetObject, IForceAction sourceObject)
|
||||
{
|
||||
if (sourceObject.GetType() != targetObject.GetType())
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ExpectedWas(targetObject.GetType(), sourceObject.GetType() + $": source object type is not {targetObject.GetType()}"));
|
||||
}
|
||||
if (targetObject is IDesignForcePair pair)
|
||||
{
|
||||
forcePairUpdateStrategy.Update(pair, (IDesignForcePair)sourceObject);
|
||||
PairUpdateStrategy.Update(pair, (IDesignForcePair)sourceObject);
|
||||
}
|
||||
else if (targetObject is IForceFactoredList combination)
|
||||
{
|
||||
factorUpdateStrategy.Update(combination, (IForceFactoredList)sourceObject);
|
||||
FactorUpdateStrategy.Update(combination, (IForceFactoredList)sourceObject);
|
||||
}
|
||||
else if (targetObject is IForceCombinationList forceCombinationList)
|
||||
{
|
||||
forceListUpdateStrategy.Update(forceCombinationList, (IForceCombinationList)sourceObject);
|
||||
ForceListUpdateStrategy.Update(forceCombinationList, (IForceCombinationList)sourceObject);
|
||||
}
|
||||
else if (targetObject is IForceCombinationFromFile fileCombination)
|
||||
{
|
||||
fileCombinationUpdateStrategy.Update(fileCombination, (IForceCombinationFromFile)sourceObject);
|
||||
FileCombinationUpdateStrategy.Update(fileCombination, (IForceCombinationFromFile)sourceObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace StructureHelperCommon.Models.Forces.Logics
|
||||
private IForceTuple? fullSLSTuple;
|
||||
private List<LimitStates> limitStates = new() { LimitStates.ULS, LimitStates.SLS };
|
||||
private List<CalcTerms> calcTerms = new() { CalcTerms.ShortTerm, CalcTerms.LongTerm };
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
public IForceTuple? SourceForceTuple { get; set; }
|
||||
public IFactoredCombinationProperty? CombinationProperty { get; set; }
|
||||
@@ -45,7 +47,7 @@ namespace StructureHelperCommon.Models.Forces.Logics
|
||||
{
|
||||
factor /= CombinationProperty.ULSFactor;
|
||||
}
|
||||
fullSLSTuple = ForceTupleService.MultiplyTupleByFactor(SourceForceTuple, factor);
|
||||
fullSLSTuple = ForceTupleServiceLogic.MultiplyTupleByFactor(SourceForceTuple, factor);
|
||||
}
|
||||
|
||||
private void Check()
|
||||
@@ -84,7 +86,7 @@ namespace StructureHelperCommon.Models.Forces.Logics
|
||||
private void ProcessCalcTerm(LimitStates limitState, double stateFactor, CalcTerms calcTerm)
|
||||
{
|
||||
var factor = calcTerm is CalcTerms.ShortTerm ? 1d : CombinationProperty.LongTermFactor;
|
||||
IForceTuple forceTuple = ForceTupleService.MultiplyTupleByFactor(fullSLSTuple, stateFactor * factor);
|
||||
IForceTuple forceTuple = ForceTupleServiceLogic.MultiplyTupleByFactor(fullSLSTuple, stateFactor * factor);
|
||||
var designForceTuple = new DesignForceTuple
|
||||
{
|
||||
LimitState = limitState,
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace StructureHelperCommon.Models.Forces.Logics
|
||||
public class GetForceTupleByFactoredTupleLogic : IGetForceTupleByFactoredTupleLogic
|
||||
{
|
||||
private IGetLoadFactor getFactorLogic;
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
public GetForceTupleByFactoredTupleLogic(IGetLoadFactor getFactorLogic)
|
||||
{
|
||||
@@ -36,7 +38,7 @@ namespace StructureHelperCommon.Models.Forces.Logics
|
||||
CalcTerm = CalcTerm
|
||||
};
|
||||
double factor = getFactorLogic.GetFactor();
|
||||
return ForceTupleService.MultiplyTupleByFactor(FactoredForceTuple.ForceTuple, factor);
|
||||
return ForceTupleServiceLogic.MultiplyTupleByFactor(FactoredForceTuple.ForceTuple, factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace StructureHelperCommon.Models.Forces
|
||||
public class StrainTuple : IForceTuple
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> updateStrategy = new ForceTupleUpdateStrategy();
|
||||
private static IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private static IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
/// <inheritdoc/>
|
||||
public Guid Id { get; }
|
||||
/// <inheritdoc/>
|
||||
@@ -53,7 +55,7 @@ namespace StructureHelperCommon.Models.Forces
|
||||
public static StrainTuple operator +(StrainTuple first) => first;
|
||||
public static StrainTuple operator +(StrainTuple first, ForceTuple second)
|
||||
{
|
||||
return ForceTupleService.SumTuples(first, second) as StrainTuple;
|
||||
return ForceTupleServiceLogic.SumTuples(first, second) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,15 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace StructureHelperCommon.Services.Forces
|
||||
{
|
||||
internal static class ForceActionService
|
||||
public static class ForceActionService
|
||||
{
|
||||
private static IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private static IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public static List<IDesignForcePair> ConvertCombinationToPairs(IForceCombinationList combinations)
|
||||
{
|
||||
var resultList = new List<IDesignForcePair>();
|
||||
@@ -24,7 +22,7 @@ namespace StructureHelperCommon.Services.Forces
|
||||
for (int i = 0; i < calcTerms.Count; i++)
|
||||
{
|
||||
var forceTupleList = combinations.DesignForces.Where(x => x.LimitState == limitState && x.CalcTerm == calcTerms[i]).Select(x => x.ForceTuple);
|
||||
var sumLongTuple = ForceTupleService.MergeTupleCollection(forceTupleList);
|
||||
var sumLongTuple = ForceTupleServiceLogic.MergeTupleCollection(forceTupleList);
|
||||
tuples[i] = sumLongTuple;
|
||||
}
|
||||
var pair = new DesignForcePair()
|
||||
@@ -52,7 +50,7 @@ namespace StructureHelperCommon.Services.Forces
|
||||
{
|
||||
var stateFactor = limitState is LimitStates.SLS ? 1d : combinations.CombinationProperty.ULSFactor;
|
||||
var termFactor = calcTerms[i] == CalcTerms.ShortTerm ? 1d : combinations.CombinationProperty.LongTermFactor;
|
||||
var forceTupleList = ForceTupleService.MultiplyTupleByFactor(combinations.ForceTuples[0], stateFactor * termFactor);
|
||||
var forceTupleList = ForceTupleServiceLogic.MultiplyTupleByFactor(combinations.ForceTuples[0], stateFactor * termFactor);
|
||||
tuples[i] = forceTupleList;
|
||||
}
|
||||
var pair = new DesignForcePair()
|
||||
@@ -72,15 +70,13 @@ namespace StructureHelperCommon.Services.Forces
|
||||
public static List<IDesignForcePair> ConvertCombinationToPairs(IForceAction forceAction)
|
||||
{
|
||||
var resultList = new List<IDesignForcePair>();
|
||||
if (forceAction is IForceCombinationList)
|
||||
if (forceAction is IForceCombinationList combinationList)
|
||||
{
|
||||
var item = forceAction as IForceCombinationList;
|
||||
resultList.AddRange(ConvertCombinationToPairs(item));
|
||||
resultList.AddRange(ConvertCombinationToPairs(combinationList));
|
||||
}
|
||||
else if (forceAction is IForceFactoredList)
|
||||
else if (forceAction is IForceFactoredList forceFactoredList)
|
||||
{
|
||||
var item = forceAction as IForceFactoredList;
|
||||
resultList.AddRange(ConvertCombinationToPairs(item));
|
||||
resultList.AddRange(ConvertCombinationToPairs(forceFactoredList));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace StructureHelperCommon.Services.Forces
|
||||
{
|
||||
public static class ForceTupleService
|
||||
public class ForceTupleServiceLogic : IForceTupleServiceLogic
|
||||
{
|
||||
/// <summary>
|
||||
/// Copy properties from target to source
|
||||
@@ -14,13 +13,13 @@ namespace StructureHelperCommon.Services.Forces
|
||||
/// <param name="source">Source tuple</param>
|
||||
/// <param name="target">Target tuple</param>
|
||||
/// <param name="factor">factor</param>
|
||||
public static void CopyProperties(IForceTuple source, IForceTuple target, double factor = 1d)
|
||||
public void CopyProperties(IForceTuple source, IForceTuple target, double factor = 1d)
|
||||
{
|
||||
CheckTuples(source, target);
|
||||
target.Clear();
|
||||
SumTupleToTarget(source, target, factor);
|
||||
}
|
||||
public static IForceTuple SumTuples(IForceTuple first, IForceTuple second, double factor = 1d)
|
||||
public IForceTuple SumTuples(IForceTuple first, IForceTuple second, double factor = 1d)
|
||||
{
|
||||
CheckTuples(first, second);
|
||||
IForceTuple result = GetNewTupleSameType(first);
|
||||
@@ -28,14 +27,15 @@ namespace StructureHelperCommon.Services.Forces
|
||||
SumTupleToTarget(second, result, factor);
|
||||
return result;
|
||||
}
|
||||
public static IForceTuple MergeTupleCollection(IEnumerable<IForceTuple> tupleCollection)
|
||||
public IForceTuple MergeTupleCollection(IEnumerable<IForceTuple> tupleCollection)
|
||||
{
|
||||
CheckTupleCollection(tupleCollection);
|
||||
var result = GetNewTupleSameType(tupleCollection.First());
|
||||
foreach (var item in tupleCollection)
|
||||
{
|
||||
SumTuples(result, item);
|
||||
};
|
||||
result = SumTuples(result, item);
|
||||
}
|
||||
;
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -44,13 +44,13 @@ namespace StructureHelperCommon.Services.Forces
|
||||
/// <param name="forceTuple">Source force tuple</param>
|
||||
/// <param name="factor">Factor which tuple multyplies by</param>
|
||||
/// <returns></returns>
|
||||
public static IForceTuple MultiplyTupleByFactor(IForceTuple forceTuple, double factor)
|
||||
public IForceTuple MultiplyTupleByFactor(IForceTuple forceTuple, double factor)
|
||||
{
|
||||
var result = GetNewTupleSameType(forceTuple);
|
||||
CopyProperties(forceTuple, result, factor);
|
||||
return result;
|
||||
}
|
||||
public static IForceTuple InterpolateTuples(IForceTuple startTuple, IForceTuple endTuple, double coefficient = 0.5d)
|
||||
public IForceTuple InterpolateTuples(IForceTuple startTuple, IForceTuple endTuple, double coefficient = 0.5d)
|
||||
{
|
||||
if (startTuple is null) startTuple = GetNewTupleSameType(endTuple);
|
||||
else { CheckTuples(startTuple, endTuple); }
|
||||
@@ -58,7 +58,7 @@ namespace StructureHelperCommon.Services.Forces
|
||||
return SumTuples(startTuple, deltaTuple, coefficient);
|
||||
}
|
||||
|
||||
public static List<IForceTuple> InterpolateTuples(IForceTuple startTuple, IForceTuple endTuple, int stepCount)
|
||||
public List<IForceTuple> InterpolateTuples(IForceTuple startTuple, IForceTuple endTuple, int stepCount)
|
||||
{
|
||||
var tuples = new List<IForceTuple>();
|
||||
double step = 1d / stepCount;
|
||||
@@ -70,11 +70,11 @@ namespace StructureHelperCommon.Services.Forces
|
||||
return tuples;
|
||||
}
|
||||
|
||||
public static List<IDesignForceTuple> InterpolateDesignTuple(IDesignForceTuple startDesignForce, IDesignForceTuple finishDesignForce, int stepCount = 10)
|
||||
public List<IDesignForceTuple> InterpolateDesignTuple(IDesignForceTuple startDesignForce, IDesignForceTuple finishDesignForce, int stepCount = 10)
|
||||
{
|
||||
if (startDesignForce.LimitState != finishDesignForce.LimitState) throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid);
|
||||
if (startDesignForce.CalcTerm != finishDesignForce.CalcTerm) throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid);
|
||||
var tuples =new List<IDesignForceTuple>();
|
||||
var tuples = new List<IDesignForceTuple>();
|
||||
double step = 1d / stepCount;
|
||||
for (int i = 0; i <= stepCount; i++)
|
||||
{
|
||||
@@ -83,7 +83,8 @@ namespace StructureHelperCommon.Services.Forces
|
||||
{
|
||||
LimitState = finishDesignForce.LimitState,
|
||||
CalcTerm = finishDesignForce.CalcTerm,
|
||||
ForceTuple = currentTuple };
|
||||
ForceTuple = currentTuple
|
||||
};
|
||||
tuples.Add(currentDesignTuple);
|
||||
}
|
||||
return tuples;
|
||||
@@ -94,7 +95,7 @@ namespace StructureHelperCommon.Services.Forces
|
||||
/// <param name="source">Source tuple</param>
|
||||
/// <param name="target">Target tuple</param>
|
||||
/// <param name="factor">Factor which source tuple will be multiplied by (1d is default value)</param>
|
||||
public static void SumTupleToTarget(IForceTuple source, IForceTuple target, double factor = 1d)
|
||||
public void SumTupleToTarget(IForceTuple source, IForceTuple target, double factor = 1d)
|
||||
{
|
||||
target.Mx += source.Mx * factor;
|
||||
target.My += source.My * factor;
|
||||
@@ -103,7 +104,7 @@ namespace StructureHelperCommon.Services.Forces
|
||||
target.Qy += source.Qy * factor;
|
||||
target.Mz += source.Mz * factor;
|
||||
}
|
||||
private static void CheckTuples(IForceTuple first, IForceTuple second)
|
||||
private void CheckTuples(IForceTuple first, IForceTuple second)
|
||||
{
|
||||
if (first.GetType() != second.GetType())
|
||||
{
|
||||
@@ -111,18 +112,18 @@ namespace StructureHelperCommon.Services.Forces
|
||||
$": Type of first parameter (type = {first.GetType()}) doesn't corespond second parameter type ({second.GetType()})");
|
||||
}
|
||||
}
|
||||
private static void CheckTupleCollection(IEnumerable<IForceTuple> tupleCollection)
|
||||
private void CheckTupleCollection(IEnumerable<IForceTuple> tupleCollection)
|
||||
{
|
||||
if (tupleCollection.Count() == 0)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Collection is Empty");
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Collection is Empty");
|
||||
}
|
||||
foreach (var item in tupleCollection)
|
||||
{
|
||||
CheckTuples(tupleCollection.First(), item);
|
||||
}
|
||||
}
|
||||
private static IForceTuple GetNewTupleSameType(IForceTuple first)
|
||||
private IForceTuple GetNewTupleSameType(IForceTuple first)
|
||||
{
|
||||
IForceTuple result;
|
||||
if (first is ForceTuple) { result = new ForceTuple(); }
|
||||
@@ -0,0 +1,17 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelperCommon.Services.Forces
|
||||
{
|
||||
public interface IForceTupleServiceLogic
|
||||
{
|
||||
void CopyProperties(IForceTuple source, IForceTuple target, double factor = 1);
|
||||
List<IDesignForceTuple> InterpolateDesignTuple(IDesignForceTuple startDesignForce, IDesignForceTuple finishDesignForce, int stepCount = 10);
|
||||
IForceTuple InterpolateTuples(IForceTuple startTuple, IForceTuple endTuple, double coefficient = 0.5);
|
||||
List<IForceTuple> InterpolateTuples(IForceTuple startTuple, IForceTuple endTuple, int stepCount);
|
||||
IForceTuple MergeTupleCollection(IEnumerable<IForceTuple> tupleCollection);
|
||||
IForceTuple MultiplyTupleByFactor(IForceTuple forceTuple, double factor);
|
||||
IForceTuple SumTuples(IForceTuple first, IForceTuple second, double factor = 1);
|
||||
void SumTupleToTarget(IForceTuple source, IForceTuple target, double factor = 1);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models.Parameters;
|
||||
using StructureHelperCommon.Services.Units;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace StructureHelperCommon.Services.Units
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
private IDirectShearForceLogicInputData inputData;
|
||||
private ISumForceByShearLoadLogic summaryForceLogic;
|
||||
private ICheckInputDataLogic<IDirectShearForceLogicInputData> checkInputDataLogic;
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
@@ -38,7 +40,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
Check();
|
||||
IForceTuple externalTuple = CalculateExternalForceTuple();
|
||||
IForceTuple internalTuple = CalculateInternalForceTuple();
|
||||
IForceTuple totalTuple = ForceTupleService.SumTuples(internalTuple, externalTuple);
|
||||
IForceTuple totalTuple = ForceTupleServiceLogic.SumTuples(internalTuple, externalTuple);
|
||||
TraceLogger?.AddMessage($"Total longitudinal force = {totalTuple.Nz}(N)");
|
||||
TraceLogger?.AddMessage($"Total shear force = {totalTuple.Qy}(N)");
|
||||
return totalTuple;
|
||||
@@ -83,7 +85,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
TraceLogger?.AddMessage($"End of inclined section a,end = {inputData.InclinedSection.EndCoord}(m)");
|
||||
ForceTuple summarySpanShearForce = GetSummarySpanShearForce(beamShearAxisAction.ShearLoads);
|
||||
TraceLogger?.AddMessage($"Summary span shear force deltaQ = {summarySpanShearForce.Qy}(N)");
|
||||
IForceTuple shearForce = ForceTupleService.SumTuples(supportShearForce, summarySpanShearForce);
|
||||
IForceTuple shearForce = ForceTupleServiceLogic.SumTuples(supportShearForce, summarySpanShearForce);
|
||||
TraceLogger?.AddMessage($"Summary shear force at the end of inclined section Q = {shearForce.Qy}(N)");
|
||||
return shearForce;
|
||||
}
|
||||
@@ -94,7 +96,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
foreach (var spanLoad in spanLoads)
|
||||
{
|
||||
IForceTuple summarySpanLoad = summaryForceLogic.GetSumShearForce(spanLoad, inputData.InclinedSection.StartCoord, inputData.InclinedSection.EndCoord);
|
||||
ForceTupleService.SumTupleToTarget(summarySpanLoad, summarySpanShearForce);
|
||||
ForceTupleServiceLogic.SumTupleToTarget(summarySpanLoad, summarySpanShearForce);
|
||||
}
|
||||
return summarySpanShearForce;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
private IGetLoadFactor getFactorLogic;
|
||||
private IGetDirectShearForceLogic getDirectShearForceLogic;
|
||||
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
public IShearForceLogicInputData InputData { get;}
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
@@ -38,7 +40,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
InitializeStrategies();
|
||||
double factor = getFactorLogic.GetFactor();
|
||||
IForceTuple directShearForce = getDirectShearForceLogic.CalculateShearForceTuple();
|
||||
IForceTuple shearForce = ForceTupleService.MultiplyTupleByFactor(directShearForce,factor);
|
||||
IForceTuple shearForce = ForceTupleServiceLogic.MultiplyTupleByFactor(directShearForce,factor);
|
||||
return shearForce;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
public class SumConcentratedForceLogic : ISumForceByShearLoadLogic
|
||||
{
|
||||
private ICoordinateByLevelLogic coordinateByLevelLogic;
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
@@ -70,7 +72,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
{
|
||||
double loadFactor = GetLoadFactor(concentratedForce);
|
||||
double sumFactor = concentratedForce.LoadRatio * loadFactor;
|
||||
totalLoad = ForceTupleService.MultiplyTupleByFactor(concentratedForce.ForceValue, sumFactor);
|
||||
totalLoad = ForceTupleServiceLogic.MultiplyTupleByFactor(concentratedForce.ForceValue, sumFactor);
|
||||
TraceLogger?.AddMessage($"Total load Q,tot = {concentratedForce.ForceValue.Qy}(N) * {concentratedForce.LoadRatio} * {loadFactor} = {totalLoad}(N)");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
public class SumDistributedLoadLogic : ISumForceByShearLoadLogic
|
||||
{
|
||||
private ICoordinateByLevelLogic coordinateByLevelLogic;
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
@@ -61,7 +63,7 @@ namespace StructureHelperLogics.Models.BeamShears
|
||||
TraceLogger?.AddMessage($"Total length L,tot = {loadEndCoord}(m) - {loadStartCoord}(m) = {loadLength}(m)");
|
||||
double loadFactor = GetLoadFactor(distributedLoad);
|
||||
double sumFactor = distributedLoad.LoadRatio * loadLength * loadFactor;
|
||||
IForceTuple totalLoad = ForceTupleService.MultiplyTupleByFactor(distributedLoad.LoadValue, sumFactor);
|
||||
IForceTuple totalLoad = ForceTupleServiceLogic.MultiplyTupleByFactor(distributedLoad.LoadValue, sumFactor);
|
||||
TraceLogger?.AddMessage($"Total load Q,tot = {distributedLoad.LoadValue.Qy}(N/m) * {distributedLoad.LoadRatio} * {loadLength}(m) * {loadFactor} = {totalLoad.Qy}(N)");
|
||||
return totalLoad;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
@@ -41,6 +38,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
|
||||
public void Run()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
|
||||
PrepareNewResult();
|
||||
if (CheckInputData() == false) {return;}
|
||||
GetResultByLogic();
|
||||
|
||||
@@ -10,6 +10,13 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
public class CurvatureForceCalculator : ICurvatureForceCalculator
|
||||
{
|
||||
private CurvatureForceCalculatorResult result;
|
||||
private ICurvatureTermCalculator calculator;
|
||||
|
||||
public CurvatureForceCalculator(IShiftTraceLogger? traceLogger)
|
||||
{
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public ICurvatureForceCalculatorInputData InputData { get; set; }
|
||||
|
||||
public IResult Result => result;
|
||||
@@ -25,39 +32,36 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
|
||||
public void Run()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
|
||||
PrepareResult();
|
||||
if (CheckForCracks(InputData.ShortTermTuple, CalcTerms.ShortTerm) || CheckForCracks(InputData.ShortTermTuple, CalcTerms.ShortTerm))
|
||||
try
|
||||
{
|
||||
ProcessCrackedSection();
|
||||
if (CheckForCracks(InputData.ForcePair.FullForceTuple, CalcTerms.ShortTerm) || CheckForCracks(InputData.ForcePair.LongForceTuple, CalcTerms.ShortTerm))
|
||||
{
|
||||
TraceLogger?.AddMessage($"Section is cracked");
|
||||
calculator = new CurvatureTermCrackedCalculator(TraceLogger) { InputData = InputData };
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceLogger?.AddMessage($"Section is not cracked");
|
||||
calculator = new CurvatureTermUncrackedCalculator(TraceLogger) { InputData = InputData };
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
ProcessUncrackedSection();
|
||||
result.IsValid = false;
|
||||
result.Description += ex.Message;
|
||||
result.Description += $"\n Check bearing capacity for action {InputData.ForcePair.Name}, probably section has been collapsed";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessCrackedSection()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void ProcessUncrackedSection()
|
||||
{
|
||||
CurvatureTermCalculatorInputData inputData = new()
|
||||
{
|
||||
Primitives = InputData.Primitives,
|
||||
DeflectionFactor = InputData.DeflectionFactor
|
||||
};
|
||||
var calculator = new CurvatureTermUncrackedCalculator() { InputData = inputData };
|
||||
inputData.ForceTuple = InputData.LongTermTuple;
|
||||
inputData.CalculationTerm = CalcTerms.LongTerm;
|
||||
calculator.Run();
|
||||
var calcResult = calculator.Result as CurvatureTermCalculatorResult;
|
||||
var calcResult = calculator.Result as ICurvatureSectionResult;
|
||||
if (calcResult.IsValid == false)
|
||||
{
|
||||
result.IsValid = false;
|
||||
}
|
||||
result.LongTermResult = calcResult;
|
||||
result.SectionResult = calcResult;
|
||||
}
|
||||
|
||||
private bool CheckForCracks(IForceTuple forceTuple, CalcTerms calcTerm)
|
||||
@@ -81,7 +85,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
|
||||
private void PrepareResult()
|
||||
{
|
||||
result = new();
|
||||
result = new()
|
||||
{
|
||||
InputData = InputData,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class CurvatureForceCalculatorInputData : ICurvatureForceCalculatorInputData
|
||||
{
|
||||
public IForceTuple LongTermTuple { get; set; }
|
||||
public IForceTuple ShortTermTuple { get; set; }
|
||||
public IDesignForcePair ForcePair { get; set; }
|
||||
public List<INdmPrimitive> Primitives { get; set; } = [];
|
||||
public IDeflectionFactor DeflectionFactor { get; set; }
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
public class CurvatureForceCalculatorResult : ICurvatureForceCalculatorResult
|
||||
{
|
||||
public ICurvatureForceCalculatorInputData InputData { get; set; }
|
||||
public ICurvatureTermCalculatorResult LongTermResult { get; set; }
|
||||
public ICurvatureTermCalculatorResult ShortTermResult { get; set; }
|
||||
public ICurvatureSectionResult SectionResult { get; set; }
|
||||
public bool IsValid { get; set; } = true;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class CurvatureSectionResult : ICurvatureSectionResult
|
||||
{
|
||||
public ICurvatureForceCalculatorResult InputData { get; set; }
|
||||
public ICurvatureTermResult LongTermResult { get; set; }
|
||||
public ICurvatureTermResult ShortTermResult { get; set; }
|
||||
public bool IsValid { get; set; } = true;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class CurvatureTermCalcualtor : ICurvatureTermCalculator
|
||||
{
|
||||
private ICurvatureTermCalculatorResult result;
|
||||
public ICurvatureTermCalculatorInputData InputData { get; set; }
|
||||
|
||||
public IResult Result => result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public Guid Id { get; }
|
||||
|
||||
public CurvatureTermCalcualtor(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class CurvatureTermCalculatorResult : ICurvatureTermCalculatorResult
|
||||
{
|
||||
public ICurvatureTermCalculatorInputData InputData { get; set; }
|
||||
public IForceTuple CurvatureValues { get; set; }
|
||||
public IForceTuple Deflections { get; set; }
|
||||
public bool IsValid { get; set; } = true;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Cracking;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class CurvatureTermCrackedCalculator : ICurvatureTermCalculator
|
||||
{
|
||||
private CurvatureSectionResult result;
|
||||
private IGetTermDeflectionLogic deflectionLogic;
|
||||
private IGetTermDeflectionLogic DeflectionLogic => deflectionLogic ??= new GetTermDeflectionLogic(TraceLogger);
|
||||
private ICrackedSectionTriangulationLogic triangulationLogic;
|
||||
private List<INdm> crackableNdms;
|
||||
|
||||
public CurvatureTermCrackedCalculator(IShiftTraceLogger? traceLogger)
|
||||
{
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public ICurvatureForceCalculatorInputData InputData { get; set; }
|
||||
|
||||
public IResult Result => result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public Guid Id => throw new NotImplementedException();
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
|
||||
DeflectionLogic.DeflectionFactor = InputData.DeflectionFactor;
|
||||
PrepareNewResult();
|
||||
TraceLogger?.AddMessage($"Long term calculation");
|
||||
Triangulate(CalcTerms.LongTerm);
|
||||
ICrackForceResult? longCalcResult = GetCrackedResult(InputData.ForcePair.LongForceTuple);
|
||||
if (result.IsValid == false) { return; }
|
||||
DeflectionLogic.LongCurvature = longCalcResult.ReducedStrainTuple;
|
||||
result.LongTermResult = DeflectionLogic.GetLongResult();
|
||||
TraceLogger?.AddMessage($"Short term calculation");
|
||||
Triangulate(CalcTerms.ShortTerm);
|
||||
ICrackForceResult? shortFullCalcResult = GetCrackedResult(InputData.ForcePair.FullForceTuple);
|
||||
if (result.IsValid == false) { return; }
|
||||
DeflectionLogic.ShortFullCurvature = shortFullCalcResult.ReducedStrainTuple;
|
||||
ICrackForceResult? shortLongCalcResult = GetCrackedResult(InputData.ForcePair.LongForceTuple);
|
||||
if (result.IsValid == false) { return; }
|
||||
DeflectionLogic.ShortLongCurvature = shortLongCalcResult.ReducedStrainTuple;
|
||||
result.ShortTermResult = DeflectionLogic.GetShortResult();
|
||||
}
|
||||
|
||||
private ICrackForceResult GetCrackedResult(IForceTuple forceTuple)
|
||||
{
|
||||
CrackForceCalculatorInputData inputData = new()
|
||||
{
|
||||
EndTuple = forceTuple,
|
||||
CheckedNdmCollection = crackableNdms,
|
||||
SectionNdmCollection = crackableNdms,
|
||||
};
|
||||
CrackForceBynarySearchCalculator calculator = new()
|
||||
{
|
||||
InputData = inputData,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
calculator.Run();
|
||||
var longCalcResult = calculator.Result as ICrackForceResult;
|
||||
if (longCalcResult.IsValid == false)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += longCalcResult.Description;
|
||||
}
|
||||
|
||||
return longCalcResult;
|
||||
}
|
||||
|
||||
private void Triangulate(CalcTerms calcTerm)
|
||||
{
|
||||
triangulationLogic = new CrackedSectionTriangulationLogic(InputData.Primitives, calcTerm)
|
||||
{
|
||||
//TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
crackableNdms = triangulationLogic.GetNdmCollection();
|
||||
}
|
||||
|
||||
private void PrepareNewResult()
|
||||
{
|
||||
result = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class CurvatureTermResult : ICurvatureTermResult
|
||||
{
|
||||
public bool IsValid { get; set; } = true;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
public IDeflectionResult DeflectionMx { get; set; } = new DeflectionResult();
|
||||
public IDeflectionResult DeflectionMy { get; set; } = new DeflectionResult();
|
||||
public IDeflectionResult DeflectionNz { get; set; } = new DeflectionResult();
|
||||
}
|
||||
}
|
||||
@@ -6,18 +6,23 @@ using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class CurvatureTermUncrackedCalculator : ICurvatureTermCalculator
|
||||
{
|
||||
private CurvatureTermCalculatorResult result;
|
||||
private List<INdm> ndms;
|
||||
private CurvatureSectionResult result;
|
||||
private IGetTermDeflectionLogic deflectionLogic;
|
||||
private IGetTermDeflectionLogic DeflectionLogic => deflectionLogic ??= new GetTermDeflectionLogic(TraceLogger);
|
||||
private List<INdm> longTermNdms;
|
||||
private List<INdm> shortTermNdms;
|
||||
|
||||
public ICurvatureTermCalculatorInputData InputData { get; set; }
|
||||
public CurvatureTermUncrackedCalculator(IShiftTraceLogger? traceLogger)
|
||||
{
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public ICurvatureForceCalculatorInputData InputData { get; set; }
|
||||
|
||||
public IResult Result => result;
|
||||
|
||||
@@ -37,29 +42,30 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
Calculate();
|
||||
}
|
||||
|
||||
private void TriangulatePrimitives()
|
||||
{
|
||||
longTermNdms = TriangulatePrimitives(CalcTerms.LongTerm);
|
||||
shortTermNdms = TriangulatePrimitives(CalcTerms.ShortTerm);
|
||||
}
|
||||
|
||||
private void Calculate()
|
||||
{
|
||||
try
|
||||
{
|
||||
var inputData = new ForceTupleInputData()
|
||||
{
|
||||
NdmCollection = ndms,
|
||||
ForceTuple = InputData.ForceTuple
|
||||
};
|
||||
var calculator = new ForceTupleCalculator()
|
||||
{
|
||||
InputData = inputData,
|
||||
};
|
||||
calculator.Run();
|
||||
var calcResult = calculator.Result as IForceTupleCalculatorResult;
|
||||
if (calcResult.IsValid != true)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += calcResult.Description;
|
||||
return;
|
||||
}
|
||||
result.CurvatureValues = ForceTupleConverter.ConvertToForceTuple(calcResult.LoaderResults.StrainMatrix);
|
||||
ConvertCurvaturesToDeflections();
|
||||
DeflectionLogic.DeflectionFactor = InputData.DeflectionFactor;
|
||||
IForceTupleCalculatorResult? longCalcResult = GetCalculatorResult(longTermNdms, InputData.ForcePair.LongForceTuple);
|
||||
if (CheckCalcResul(longCalcResult) == false) { return; }
|
||||
DeflectionLogic.LongCurvature = ForceTupleConverter.ConvertToForceTuple(longCalcResult.LoaderResults.StrainMatrix);
|
||||
result.LongTermResult = DeflectionLogic.GetLongResult();
|
||||
|
||||
IForceTupleCalculatorResult? shortFullCalcResult = GetCalculatorResult(shortTermNdms, InputData.ForcePair.FullForceTuple);
|
||||
if (CheckCalcResul(shortFullCalcResult) == false) { return; }
|
||||
DeflectionLogic.ShortFullCurvature = ForceTupleConverter.ConvertToForceTuple(shortFullCalcResult.LoaderResults.StrainMatrix);
|
||||
|
||||
IForceTupleCalculatorResult? shortLongCalcResult = GetCalculatorResult(shortTermNdms, InputData.ForcePair.LongForceTuple);
|
||||
if (CheckCalcResul(shortLongCalcResult) == false) { return; }
|
||||
DeflectionLogic.ShortLongCurvature = ForceTupleConverter.ConvertToForceTuple(shortLongCalcResult.LoaderResults.StrainMatrix);
|
||||
result.ShortTermResult = DeflectionLogic.GetShortResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -68,26 +74,45 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
}
|
||||
}
|
||||
|
||||
private void ConvertCurvaturesToDeflections()
|
||||
private bool CheckCalcResul(IForceTupleCalculatorResult? calcResult)
|
||||
{
|
||||
ForceTuple deflections = new();
|
||||
double spanLength = InputData.DeflectionFactor.SpanLength;
|
||||
deflections.Mx = InputData.DeflectionFactor.DeflectionFactors.Mx * result.CurvatureValues.Mx * spanLength * spanLength;
|
||||
deflections.My = InputData.DeflectionFactor.DeflectionFactors.My * result.CurvatureValues.My * spanLength * spanLength;
|
||||
deflections.Nz = InputData.DeflectionFactor.DeflectionFactors.Nz * result.CurvatureValues.Nz * spanLength;
|
||||
result.Deflections = deflections;
|
||||
if (calcResult.IsValid != true)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += calcResult.Description;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void TriangulatePrimitives()
|
||||
private IForceTupleCalculatorResult? GetCalculatorResult(List<INdm> ndms, IForceTuple forceTuple)
|
||||
{
|
||||
var inputData = new ForceTupleInputData()
|
||||
{
|
||||
NdmCollection = ndms,
|
||||
ForceTuple = forceTuple
|
||||
};
|
||||
var calculator = new ForceTupleCalculator()
|
||||
{
|
||||
InputData = inputData,
|
||||
};
|
||||
calculator.Run();
|
||||
var calcResult = calculator.Result as IForceTupleCalculatorResult;
|
||||
return calcResult;
|
||||
}
|
||||
|
||||
|
||||
private List<INdm> TriangulatePrimitives(CalcTerms calcTerm)
|
||||
{
|
||||
|
||||
var triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = InputData.Primitives,
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = InputData.CalculationTerm,
|
||||
CalcTerm = calcTerm,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
ndms = triangulateLogic.GetNdms();
|
||||
return triangulateLogic.GetNdms();
|
||||
}
|
||||
|
||||
private void PrepareNewResult()
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class DeflectionResult : IDeflectionResult
|
||||
{
|
||||
public double UltimateDeflection { get; set; } = 0.0;
|
||||
public double Curvature { get; set; } = 0.0;
|
||||
public double Deflection { get; set; } = 0.0;
|
||||
|
||||
public bool IsDeflectionLessThanUltimate => Math.Abs(Deflection) <= Math.Abs(UltimateDeflection);
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public interface ICurvatureForceCalculatorInputData : IInputData, IHasPrimitives
|
||||
{
|
||||
IForceTuple LongTermTuple { get; set; }
|
||||
IForceTuple ShortTermTuple { get; set; }
|
||||
IDesignForcePair ForcePair {get;set;}
|
||||
IDeflectionFactor DeflectionFactor { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
public interface ICurvatureForceCalculatorResult : IResult
|
||||
{
|
||||
ICurvatureForceCalculatorInputData InputData { get; set; }
|
||||
ICurvatureTermCalculatorResult LongTermResult { get; set; }
|
||||
ICurvatureTermCalculatorResult ShortTermResult { get; set; }
|
||||
ICurvatureSectionResult SectionResult { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public interface ICurvatureSectionResult : IResult
|
||||
{
|
||||
ICurvatureForceCalculatorResult InputData { get; set; }
|
||||
ICurvatureTermResult LongTermResult { get; set; }
|
||||
ICurvatureTermResult ShortTermResult { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,6 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public interface ICurvatureTermCalculator : ILogicCalculator
|
||||
{
|
||||
ICurvatureTermCalculatorInputData InputData { get; set; }
|
||||
ICurvatureForceCalculatorInputData InputData { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public interface ICurvatureTermCalculatorResult : IResult
|
||||
{
|
||||
ICurvatureTermCalculatorInputData InputData { get; set; }
|
||||
IForceTuple CurvatureValues { get; set; }
|
||||
IForceTuple Deflections { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public interface ICurvatureTermResult : IResult
|
||||
{
|
||||
IDeflectionResult DeflectionMx { get; set; }
|
||||
IDeflectionResult DeflectionMy { get; set; }
|
||||
IDeflectionResult DeflectionNz { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public interface IDeflectionResult
|
||||
{
|
||||
double UltimateDeflection { get; set; }
|
||||
double Curvature { get; set; }
|
||||
double Deflection { get; set; }
|
||||
bool IsDeflectionLessThanUltimate { get; }
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
TraceLogger = traceLogger;
|
||||
CheckRebarPrimitiveLogic checkRebarPrimitiveLogic = new()
|
||||
{
|
||||
CheckRebarHostMaterial = false,
|
||||
CheckRebarPlacement = false
|
||||
CheckRebarHostMaterial = true,
|
||||
CheckRebarPlacement = true
|
||||
};
|
||||
primitivesCheckLogic = new HasPrimitivesCheckLogic(TraceLogger, checkRebarPrimitiveLogic);
|
||||
}
|
||||
@@ -39,12 +39,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
TraceMessage(errorString);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
if (Entity.Primitives is null || !Entity.Primitives.Any())
|
||||
if (Entity.Primitives is null || Entity.Primitives.Count == 0)
|
||||
{
|
||||
TraceMessage("Calculator does not contain any primitives");
|
||||
result = false;
|
||||
}
|
||||
if (Entity.ForceActions is null || !Entity.ForceActions.Any())
|
||||
if (Entity.ForceActions is null || Entity.ForceActions.Count == 0)
|
||||
{
|
||||
TraceMessage("Calculator does not contain any forces");
|
||||
result = false;
|
||||
|
||||
@@ -3,36 +3,88 @@ using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class CurvatureCalculatorInputDataUpdateStrategy : IParentUpdateStrategy<ICurvatureCalculatorInputData>
|
||||
/// <summary>
|
||||
/// Provides an update strategy for <see cref="ICurvatureCalculatorInputData"/>,
|
||||
/// allowing transfer of child collections and nested objects from a source
|
||||
/// instance to a target instance.
|
||||
/// </summary>
|
||||
public class CurvatureCalculatorInputDataUpdateStrategy
|
||||
: IParentUpdateStrategy<ICurvatureCalculatorInputData>
|
||||
{
|
||||
private IUpdateStrategy<IDeflectionFactor> deflectionUpdateStrategy;
|
||||
private IUpdateStrategy<IDeflectionFactor> DeflectionUpdateStrategy => deflectionUpdateStrategy ??= new DeflectionFactorUpdateStrategy();
|
||||
private IUpdateStrategy<IDeflectionFactor>? _deflectionUpdateStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the strategy used to update the <see cref="IDeflectionFactor"/> object.
|
||||
/// Lazily initialized to <see cref="DeflectionFactorUpdateStrategy"/> if none supplied.
|
||||
/// </summary>
|
||||
private IUpdateStrategy<IDeflectionFactor> DeflectionUpdateStrategy =>
|
||||
_deflectionUpdateStrategy ??= new DeflectionFactorUpdateStrategy();
|
||||
|
||||
/// <summary>
|
||||
/// When true, the children's data (collections and nested objects)
|
||||
/// will be updated from the source. Defaults to true.
|
||||
/// </summary>
|
||||
public bool UpdateChildren { get; set; } = true;
|
||||
|
||||
public void Update(ICurvatureCalculatorInputData targetObject, ICurvatureCalculatorInputData sourceObject)
|
||||
/// <summary>
|
||||
/// Creates a new instance of the update strategy.
|
||||
/// </summary>
|
||||
/// <param name="deflectionUpdateStrategy">
|
||||
/// Optional custom update strategy for <see cref="IDeflectionFactor"/>.
|
||||
/// </param>
|
||||
public CurvatureCalculatorInputDataUpdateStrategy(
|
||||
IUpdateStrategy<IDeflectionFactor>? deflectionUpdateStrategy = null)
|
||||
{
|
||||
CheckObject.ThrowIfNull(sourceObject, nameof(sourceObject));
|
||||
CheckObject.ThrowIfNull(targetObject, nameof(targetObject));
|
||||
if (ReferenceEquals(targetObject, sourceObject))
|
||||
_deflectionUpdateStrategy = deflectionUpdateStrategy;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Update(ICurvatureCalculatorInputData target, ICurvatureCalculatorInputData source)
|
||||
{
|
||||
CheckObject.ThrowIfNull(source, nameof(source));
|
||||
CheckObject.ThrowIfNull(target, nameof(target));
|
||||
|
||||
if (ReferenceEquals(target, source))
|
||||
return;
|
||||
|
||||
if (UpdateChildren == true)
|
||||
if (UpdateChildren)
|
||||
{
|
||||
CheckProperties(targetObject, sourceObject);
|
||||
targetObject.Primitives.Clear();
|
||||
targetObject.Primitives.AddRange(sourceObject.Primitives);
|
||||
targetObject.ForceActions.Clear();
|
||||
targetObject.ForceActions.AddRange(sourceObject.ForceActions);
|
||||
ValidateChildProperties(target, source);
|
||||
UpdateCollections(target, source);
|
||||
DeflectionUpdateStrategy.Update(target.DeflectionFactor, source.DeflectionFactor);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckProperties(ICurvatureCalculatorInputData targetObject, ICurvatureCalculatorInputData sourceObject)
|
||||
/// <summary>
|
||||
/// Validates that all required child properties are not null.
|
||||
/// </summary>
|
||||
private static void ValidateChildProperties(
|
||||
ICurvatureCalculatorInputData target,
|
||||
ICurvatureCalculatorInputData source)
|
||||
{
|
||||
CheckObject.ThrowIfNull(sourceObject.Primitives);
|
||||
CheckObject.ThrowIfNull(targetObject.Primitives);
|
||||
CheckObject.ThrowIfNull(sourceObject.ForceActions);
|
||||
CheckObject.ThrowIfNull(targetObject.ForceActions);
|
||||
CheckObject.ThrowIfNull(source.Primitives, nameof(source.Primitives));
|
||||
CheckObject.ThrowIfNull(target.Primitives, nameof(target.Primitives));
|
||||
|
||||
CheckObject.ThrowIfNull(source.ForceActions, nameof(source.ForceActions));
|
||||
CheckObject.ThrowIfNull(target.ForceActions, nameof(target.ForceActions));
|
||||
|
||||
CheckObject.ThrowIfNull(source.DeflectionFactor, nameof(source.DeflectionFactor));
|
||||
CheckObject.ThrowIfNull(target.DeflectionFactor, nameof(target.DeflectionFactor));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the target collections with copies of the source collections.
|
||||
/// </summary>
|
||||
private static void UpdateCollections(
|
||||
ICurvatureCalculatorInputData target,
|
||||
ICurvatureCalculatorInputData source)
|
||||
{
|
||||
target.Primitives.Clear();
|
||||
target.Primitives.AddRange(source.Primitives);
|
||||
|
||||
target.ForceActions.Clear();
|
||||
target.ForceActions.AddRange(source.ForceActions);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Sections;
|
||||
using StructureHelperCommon.Models.Sections.Logics;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
private const LimitStates limitState = LimitStates.SLS;
|
||||
private CurvatureCalculatorResult result;
|
||||
private ICurvatureForceCalculator forceCalculator;
|
||||
private ICurvatureForceCalculator ForceCalculator => forceCalculator ??= new CurvatureForceCalculator();
|
||||
private ICurvatureForceCalculator ForceCalculator => forceCalculator ??= new CurvatureForceCalculator(TraceLogger);
|
||||
private IPoint2D gravityCenter;
|
||||
|
||||
public ICurvatureCalculatorInputData InputData { get; set; }
|
||||
@@ -27,6 +28,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
|
||||
public void Run()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Bending deflection is calculated by expression delta = S * k * L ^ 2");
|
||||
TraceLogger?.AddMessage($"Longitudinal deflection is calculated by expression delta = S * k * L");
|
||||
PrepareNewResult();
|
||||
SetGravityCenter();
|
||||
try
|
||||
@@ -44,30 +48,37 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
foreach (var action in InputData.ForceActions)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculation for action {action.Name} has been started");
|
||||
var combinationList = action.GetCombinations();
|
||||
foreach (var combination in combinationList)
|
||||
{
|
||||
var longTuple = combination.DesignForces.Single(x => x.LimitState == limitState && x.CalcTerm == CalcTerms.LongTerm).ForceTuple;
|
||||
var shortTuple = combination.DesignForces.Single(x => x.LimitState == limitState && x.CalcTerm == CalcTerms.ShortTerm).ForceTuple;
|
||||
if (action.SetInGravityCenter == true)
|
||||
TraceLogger?.AddMessage($"Totally {combination.DesignForces.Count} combinations has been extracted successfully");
|
||||
var pairList = ForceActionService.ConvertCombinationToPairs(combination).Where(x => x.LimitState == limitState).ToList();
|
||||
foreach (var pair in pairList)
|
||||
{
|
||||
IProcessorLogic<IForceTuple> forceLogic = new ForceTupleCopier(longTuple);
|
||||
forceLogic = new ForceTupleMoveToPointDecorator(forceLogic) { Point2D = gravityCenter };
|
||||
longTuple = forceLogic.GetValue();
|
||||
forceLogic = new ForceTupleCopier(shortTuple);
|
||||
forceLogic = new ForceTupleMoveToPointDecorator(forceLogic) { Point2D = gravityCenter };
|
||||
shortTuple = forceLogic.GetValue();
|
||||
pair.Name = action.Name;
|
||||
TraceLogger?.AddMessage($"Calculation for combination of force {pair.Name} has been started");
|
||||
if (action.SetInGravityCenter == true)
|
||||
{
|
||||
IProcessorLogic<IForceTuple> forceLogic = new ForceTupleCopier(pair.LongForceTuple);
|
||||
forceLogic = new ForceTupleMoveToPointDecorator(forceLogic) { Point2D = gravityCenter };
|
||||
pair.LongForceTuple = forceLogic.GetValue();
|
||||
forceLogic = new ForceTupleCopier(pair.FullForceTuple);
|
||||
forceLogic = new ForceTupleMoveToPointDecorator(forceLogic) { Point2D = gravityCenter };
|
||||
pair.FullForceTuple = forceLogic.GetValue();
|
||||
}
|
||||
CurvatureForceCalculatorInputData forceInputData = new()
|
||||
{
|
||||
ForcePair = pair,
|
||||
Primitives = InputData.Primitives,
|
||||
DeflectionFactor = InputData.DeflectionFactor
|
||||
};
|
||||
ForceCalculator.InputData = forceInputData;
|
||||
ForceCalculator.Run();
|
||||
ICurvatureForceCalculatorResult forceResult = (ICurvatureForceCalculatorResult)ForceCalculator.Result;
|
||||
result.ForceCalculatorResults.Add(forceResult);
|
||||
}
|
||||
CurvatureForceCalculatorInputData forceInputData = new()
|
||||
{
|
||||
LongTermTuple = longTuple,
|
||||
ShortTermTuple = shortTuple,
|
||||
Primitives = InputData.Primitives,
|
||||
DeflectionFactor = InputData.DeflectionFactor
|
||||
};
|
||||
ForceCalculator.InputData = forceInputData;
|
||||
ForceCalculator.Run();
|
||||
result.ForceCalculatorResults.Add((ICurvatureForceCalculatorResult)ForceCalculator.Result);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public class GetDeflectionByCurvatureLogic : IGetDeflectionByCurvatureLogic
|
||||
{
|
||||
public GetDeflectionByCurvatureLogic(IShiftTraceLogger traceLogger)
|
||||
{
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public ICurvatureTermResult GetDeflection(IForceTuple curvature, IDeflectionFactor factor)
|
||||
{
|
||||
double L = factor.SpanLength;
|
||||
TraceLogger?.AddMessage($"Span length L = {L}(m)");
|
||||
|
||||
var result = new CurvatureTermResult();
|
||||
|
||||
result.DeflectionMx = ComputeDeflection(
|
||||
axisName: "X",
|
||||
curvature: curvature.Mx,
|
||||
k: factor.DeflectionFactors.Mx,
|
||||
ultimate: factor.MaxDeflections.Mx,
|
||||
spanLength: L,
|
||||
isQuadratic: true);
|
||||
|
||||
result.DeflectionMy = ComputeDeflection(
|
||||
axisName: "Y",
|
||||
curvature: curvature.My,
|
||||
k: factor.DeflectionFactors.My,
|
||||
ultimate: factor.MaxDeflections.My,
|
||||
spanLength: L,
|
||||
isQuadratic: true);
|
||||
|
||||
result.DeflectionNz = ComputeDeflection(
|
||||
axisName: "Z",
|
||||
curvature: curvature.Nz,
|
||||
k: factor.DeflectionFactors.Nz,
|
||||
ultimate: factor.MaxDeflections.Nz,
|
||||
spanLength: L,
|
||||
isQuadratic: false);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private DeflectionResult ComputeDeflection(
|
||||
string axisName,
|
||||
double curvature,
|
||||
double k,
|
||||
double ultimate,
|
||||
double spanLength,
|
||||
bool isQuadratic)
|
||||
{
|
||||
double deflection = isQuadratic
|
||||
? k * curvature * spanLength * spanLength
|
||||
: k * curvature * spanLength;
|
||||
|
||||
string formula = isQuadratic
|
||||
? $"{k} * {curvature} * ({spanLength})^2"
|
||||
: $"{k} * {curvature} * {spanLength}";
|
||||
|
||||
TraceLogger?.AddMessage(
|
||||
$"Deflection along {axisName} axis = {formula} = {deflection}(m)");
|
||||
|
||||
return new DeflectionResult
|
||||
{
|
||||
Curvature = curvature,
|
||||
UltimateDeflection = ultimate,
|
||||
Deflection = deflection
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides logic for calculating long-term and short-term deflection terms
|
||||
/// based on curvature values and deflection factors. Uses an underlying
|
||||
/// <see cref="IGetDeflectionByCurvatureLogic"/> to compute the deflection
|
||||
/// for a given curvature state.
|
||||
/// </summary>
|
||||
public class GetTermDeflectionLogic : IGetTermDeflectionLogic
|
||||
{
|
||||
private IGetDeflectionByCurvatureLogic deflectionLogic;
|
||||
private IGetDeflectionByCurvatureLogic DeflectionLogic => deflectionLogic ??= new GetDeflectionByCurvatureLogic(TraceLogger);
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
|
||||
public IForceTuple LongCurvature { get; set; }
|
||||
public IForceTuple ShortLongCurvature { get; set; }
|
||||
public IForceTuple ShortFullCurvature { get; set; }
|
||||
public IDeflectionFactor DeflectionFactor { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public GetTermDeflectionLogic(IShiftTraceLogger traceLogger)
|
||||
{
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public GetTermDeflectionLogic(IGetDeflectionByCurvatureLogic deflectionLogic, IForceTupleServiceLogic forceTupleServiceLogic, IShiftTraceLogger? traceLogger)
|
||||
{
|
||||
this.deflectionLogic = deflectionLogic;
|
||||
this.forceTupleServiceLogic = forceTupleServiceLogic;
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public ICurvatureTermResult GetLongResult()
|
||||
{
|
||||
TraceCurvature(LongCurvature);
|
||||
ICurvatureTermResult longTermDeflection = DeflectionLogic.GetDeflection(LongCurvature, DeflectionFactor);
|
||||
return longTermDeflection;
|
||||
}
|
||||
|
||||
private void TraceCurvature(IForceTuple curvature)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Curvature kx = {curvature.Mx}(1/m), ky = {curvature.My}(1/m), epsz = {curvature.Nz}(dimensionless)");
|
||||
}
|
||||
|
||||
public ICurvatureTermResult GetShortResult()
|
||||
{
|
||||
var deltaShortCurvature = ForceTupleServiceLogic.SumTuples(ShortFullCurvature, ShortLongCurvature, -1);
|
||||
var shortCurvature = ForceTupleServiceLogic.SumTuples(LongCurvature, deltaShortCurvature);
|
||||
TraceCurvature(shortCurvature);
|
||||
ICurvatureTermResult shortTermDeflection = DeflectionLogic.GetDeflection(shortCurvature, DeflectionFactor);
|
||||
return shortTermDeflection;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public interface IGetDeflectionByCurvatureLogic : ILogic
|
||||
{
|
||||
ICurvatureTermResult GetDeflection(IForceTuple curvature, IDeflectionFactor DeflectionFactor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
|
||||
{
|
||||
public interface IGetTermDeflectionLogic : ILogic
|
||||
{
|
||||
IDeflectionFactor DeflectionFactor { get; set; }
|
||||
/// <summary>
|
||||
/// Curvature of cross-section form long term load with long term properties of material
|
||||
/// </summary>
|
||||
IForceTuple LongCurvature { get; set; }
|
||||
/// <summary>
|
||||
/// Curvature of cross-section form long term load with short term properties of material
|
||||
/// </summary>
|
||||
IForceTuple ShortLongCurvature { get; set; }
|
||||
/// <summary>
|
||||
/// Curvature of cross-section form short term load with short term properties of material
|
||||
/// </summary>
|
||||
IForceTuple ShortFullCurvature { get; set; }
|
||||
ICurvatureTermResult GetLongResult();
|
||||
ICurvatureTermResult GetShortResult();
|
||||
}
|
||||
}
|
||||
@@ -11,18 +11,24 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackForceBynarySearchCalculator : ICrackForceCalculator
|
||||
{
|
||||
private CrackForceResult result;
|
||||
private IIsSectionCrackedByFactorLogic crackedByFactorLogic;
|
||||
private ICheckInputDataLogic<ICrackForceCalculatorInputData> checkInputDataLogic;
|
||||
ExpSofteningLogic softeningLogic = new();
|
||||
static readonly CrackStrainLogic crackStrainLogic = new();
|
||||
static readonly SofteningFactorLogic softeningFactorLogic = new();
|
||||
IForceTupleCalculator forceTupleCalculator;
|
||||
private CrackForceResult result;
|
||||
private ExpSofteningLogic softeningLogic = new();
|
||||
private readonly CrackStrainLogic crackStrainLogic = new();
|
||||
private readonly SofteningFactorLogic softeningFactorLogic = new();
|
||||
private IForceTupleCalculator forceTupleCalculator = new ForceTupleCalculator();
|
||||
private FindParameterCalculator parameterCalculator;
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
|
||||
public string Name { get; set; }
|
||||
public ICrackForceCalculatorInputData InputData { get; set; }
|
||||
public Accuracy Accuracy { get; set; }
|
||||
public Accuracy Accuracy { get; set; } = new Accuracy()
|
||||
{
|
||||
IterationAccuracy = 0.0001d,
|
||||
MaxIterationCount = 10000
|
||||
};
|
||||
public IResult Result => result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
@@ -36,15 +42,11 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
this.crackedByFactorLogic = crackedByFactorLogic;
|
||||
this.checkInputDataLogic = checkInputDataLogic;
|
||||
Accuracy ??= new Accuracy()
|
||||
{
|
||||
IterationAccuracy = 0.0001d,
|
||||
MaxIterationCount = 10000
|
||||
};
|
||||
forceTupleCalculator = new ForceTupleCalculator();
|
||||
InputData = new CrackForceCalculatorInputData();
|
||||
}
|
||||
public CrackForceBynarySearchCalculator() : this(new IsSectionCrackedByFactorLogic(), new CheckCrackForceCalculatorInputDataLogic())
|
||||
public CrackForceBynarySearchCalculator() : this(
|
||||
new IsSectionCrackedByFactorLogic(),
|
||||
new CheckCrackForceCalculatorInputDataLogic())
|
||||
{
|
||||
|
||||
}
|
||||
@@ -54,17 +56,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
if (CheckInputData() == false) { return; }
|
||||
parameterCalculator = new FindParameterCalculator();
|
||||
parameterCalculator.InputData.Predicate = crackedByFactorLogic.IsSectionCracked;
|
||||
if (TraceLogger is not null)
|
||||
{
|
||||
forceTupleCalculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(100);
|
||||
parameterCalculator.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
|
||||
crackedByFactorLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(150);
|
||||
}
|
||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Start force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(InputData.StartTuple));
|
||||
TraceLogger?.AddMessage($"Actual (end) force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(InputData.EndTuple));
|
||||
SetCalculatorsTraceLoggers();
|
||||
TraceInputData();
|
||||
crackedByFactorLogic.IsSectionCrackedByForceLogic = new IsSectionCrackedByForceLogic()
|
||||
{
|
||||
CheckedNdmCollection = InputData.CheckedNdmCollection,
|
||||
@@ -74,24 +67,34 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
crackedByFactorLogic.EndTuple = InputData.EndTuple;
|
||||
try
|
||||
{
|
||||
CheckInputData();
|
||||
bool IsSectionCrackedInZeroForce = crackedByFactorLogic.IsSectionCracked(0d);
|
||||
if (IsSectionCrackedInZeroForce == true)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Crack is appeared in start force combination", TraceLogStatuses.Warning);
|
||||
SectionCrackedAtStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += ex;
|
||||
result.Description +="\n" + ex.Message;
|
||||
return;
|
||||
}
|
||||
if (crackedByFactorLogic.IsSectionCracked(0d) == true)
|
||||
try
|
||||
{
|
||||
TraceLogger?.AddMessage($"Crack is appeared in start force combination", TraceLogStatuses.Warning);
|
||||
SectionCrackedAtStart();
|
||||
return;
|
||||
bool isSectionCrackedUndefFullForce = crackedByFactorLogic.IsSectionCracked(1d);
|
||||
if (isSectionCrackedUndefFullForce == false)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Crack is not appeared from actual (end) force combination", TraceLogStatuses.Warning);
|
||||
SectionIsNotCracked();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (crackedByFactorLogic.IsSectionCracked(1d) == false)
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Crack is not appeared from actual (end) force combination", TraceLogStatuses.Warning);
|
||||
SectionIsNotCracked();
|
||||
result.IsValid = false;
|
||||
result.Description += "\n" + ex.Message;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,6 +112,22 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
}
|
||||
}
|
||||
|
||||
private void TraceInputData()
|
||||
{
|
||||
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
|
||||
TraceLogger?.AddMessage($"Start force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(InputData.StartTuple));
|
||||
TraceLogger?.AddMessage($"Actual (end) force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(InputData.EndTuple));
|
||||
}
|
||||
|
||||
private void SetCalculatorsTraceLoggers()
|
||||
{
|
||||
forceTupleCalculator.TraceLogger = TraceLogger?.GetSimilarTraceLogger(100);
|
||||
parameterCalculator.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
|
||||
crackedByFactorLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(150);
|
||||
}
|
||||
|
||||
private void PrepareNewResult()
|
||||
{
|
||||
result = new CrackForceResult();
|
||||
@@ -125,7 +144,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
}
|
||||
softeningLogic.ForceRatio = factorOfCrackAppearance;
|
||||
var psiS = softeningLogic.GetSofteningFactor();
|
||||
var tupleOfCrackApeearence = ForceTupleService.InterpolateTuples(InputData.StartTuple, InputData.EndTuple, factorOfCrackAppearance);
|
||||
var tupleOfCrackApeearence = ForceTupleServiceLogic.InterpolateTuples(InputData.StartTuple, InputData.EndTuple, factorOfCrackAppearance);
|
||||
TraceLogger?.AddMessage($"Crack is appeared in force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tupleOfCrackApeearence));
|
||||
var reducedStrainTuple = GetReducedStrainTuple(factorOfCrackAppearance, psiS);
|
||||
@@ -158,7 +177,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
private IForceTuple GetReducedStrainTuple(double factorOfCrackAppearance, double softeningFactor)
|
||||
{
|
||||
const double notCrackedForceFactor = 0.99d;
|
||||
var notCrackedForceTuple = ForceTupleService.InterpolateTuples(InputData.StartTuple, InputData.EndTuple, factorOfCrackAppearance * notCrackedForceFactor) as ForceTuple;
|
||||
var notCrackedForceTuple = ForceTupleServiceLogic.InterpolateTuples(InputData.StartTuple, InputData.EndTuple, factorOfCrackAppearance * notCrackedForceFactor) as ForceTuple;
|
||||
var crackAppearanceStrainTuple = GetStrainTuple(notCrackedForceTuple);
|
||||
var actualStrainTuple = GetStrainTuple(InputData.EndTuple);
|
||||
crackStrainLogic.BeforeCrackingTuple = crackAppearanceStrainTuple;
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public class CrackForceCalculatorInputData : ICrackForceCalculatorInputData
|
||||
{
|
||||
public IForceTuple StartTuple { get; set; }
|
||||
public IForceTuple EndTuple { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IForceTuple StartTuple { get; set; } = new ForceTuple();
|
||||
/// <inheritdoc/>
|
||||
public IForceTuple EndTuple { get; set; } = new ForceTuple();
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<INdm> CheckedNdmCollection { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<INdm> SectionNdmCollection { get; set; }
|
||||
|
||||
public CrackForceCalculatorInputData()
|
||||
{
|
||||
StartTuple = new ForceTuple();
|
||||
EndTuple = new ForceTuple();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,15 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
internal class CrackStrainLogic : ICrackStrainLogic
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public IForceTuple BeforeCrackingTuple { get; set; }
|
||||
public IForceTuple AfterCrackingTuple { get; set; }
|
||||
public double SofteningFactor { get; set; }
|
||||
|
||||
public IForceTuple GetCrackedStrainTuple()
|
||||
{
|
||||
var strainTuple = ForceTupleService.InterpolateTuples(BeforeCrackingTuple, AfterCrackingTuple, SofteningFactor) as StrainTuple;
|
||||
var strainTuple = ForceTupleServiceLogic.InterpolateTuples(BeforeCrackingTuple, AfterCrackingTuple, SofteningFactor) as StrainTuple;
|
||||
return strainTuple;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,8 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.Services.NdmPrimitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
@@ -17,29 +11,26 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
public class CrackedSectionTriangulationLogic : ICrackedSectionTriangulationLogic
|
||||
{
|
||||
const LimitStates limitState = LimitStates.SLS;
|
||||
const CalcTerms shortTerm = CalcTerms.ShortTerm;
|
||||
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
private string ndmPrimitiveCountMessage;
|
||||
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
public IEnumerable<INdmPrimitive> NdmPrimitives { get; private set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public CrackedSectionTriangulationLogic(IEnumerable<INdmPrimitive> ndmPrimitives)
|
||||
public CrackedSectionTriangulationLogic(IEnumerable<INdmPrimitive> ndmPrimitives, CalcTerms calcTerm)
|
||||
{
|
||||
NdmPrimitives = ndmPrimitives;
|
||||
CalcTerm = calcTerm;
|
||||
ndmPrimitiveCountMessage = $"Source collection containes {NdmPrimitives.Count()} primitives";
|
||||
triangulateLogic = new TriangulatePrimitiveLogic
|
||||
{
|
||||
Primitives = NdmPrimitives,
|
||||
LimitState = limitState,
|
||||
CalcTerm = shortTerm,
|
||||
CalcTerm = CalcTerm,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
}
|
||||
public CrackedSectionTriangulationLogic()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public List<INdm> GetNdmCollection()
|
||||
{
|
||||
@@ -48,7 +39,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
LimitState = limitState,
|
||||
CalcTerm = shortTerm,
|
||||
CalcTerm = CalcTerm,
|
||||
Primitives = NdmPrimitives,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
@@ -62,7 +53,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
triangulateLogic = new TriangulatePrimitiveLogic(new MeshCrackedConcreteLogic())
|
||||
{
|
||||
LimitState = limitState,
|
||||
CalcTerm = shortTerm,
|
||||
CalcTerm = CalcTerm,
|
||||
Primitives = NdmPrimitives,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
@@ -95,7 +86,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
triangulateLogic = new TriangulatePrimitiveLogic(new MeshElasticLogic())
|
||||
{
|
||||
LimitState = limitState,
|
||||
CalcTerm = shortTerm,
|
||||
CalcTerm = CalcTerm,
|
||||
Primitives = NdmPrimitives,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class IsSectionCrackedByFactorLogic : IIsSectionCrackedByFactorLogic
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public IIsSectionCrackedByForceLogic IsSectionCrackedByForceLogic { get; set; }
|
||||
public IForceTuple StartTuple { get; set; }
|
||||
public IForceTuple EndTuple { get; set; }
|
||||
@@ -31,7 +33,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
public bool IsSectionCracked(double factor)
|
||||
{
|
||||
IsSectionCrackedByForceLogic.TraceLogger ??= TraceLogger?.GetSimilarTraceLogger(50);
|
||||
var actualTuple = ForceTupleService.InterpolateTuples(StartTuple, EndTuple, factor);
|
||||
var actualTuple = ForceTupleServiceLogic.InterpolateTuples(StartTuple, EndTuple, factor);
|
||||
IsSectionCrackedByForceLogic.ForceTuple = actualTuple;
|
||||
return IsSectionCrackedByForceLogic.IsSectionCracked();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
@@ -21,10 +15,10 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
this.triangulationLogicLoc = triangulationLogicLoc;
|
||||
}
|
||||
|
||||
public RebarCrackInputDataFactory(TupleCrackInputData inputData) : this (new CrackedSectionTriangulationLogic(inputData.Primitives))
|
||||
{
|
||||
//public RebarCrackInputDataFactory(TupleCrackInputData inputData) : this (new CrackedSectionTriangulationLogic(inputData.Primitives))
|
||||
//{
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
public RebarCrackInputDataFactory()
|
||||
{
|
||||
@@ -45,7 +39,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
|
||||
rebarCopy = Rebar.Clone() as RebarNdmPrimitive;
|
||||
rebarCopy.NdmElement.HeadMaterial = rebarCopy.NdmElement.HeadMaterial.Clone() as IHeadMaterial;
|
||||
triangulationLogicLoc = new CrackedSectionTriangulationLogic(InputData.Primitives);
|
||||
triangulationLogicLoc = new CrackedSectionTriangulationLogic(InputData.Primitives, CalcTerms.ShortTerm);
|
||||
crackableNdmsLoc = triangulationLogicLoc.GetNdmCollection();
|
||||
crackedNdmsLoc = triangulationLogicLoc.GetCrackedNdmCollection();
|
||||
|
||||
|
||||
@@ -18,10 +18,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
private const CalcTerms crackingTerm = CalcTerms.ShortTerm;
|
||||
private const LimitStates crackingLimitState = LimitStates.SLS;
|
||||
private ILengthBetweenCracksLogic lengthLogic;
|
||||
private TupleCrackResult result;
|
||||
private ICrackedSectionTriangulationLogic triangulationLogic;
|
||||
private ITupleRebarsCrackSolver solver;
|
||||
private List<IRebarNdmPrimitive>? rebarPrimitives;
|
||||
private IEnumerable<INdm> crackableNdms;
|
||||
private IEnumerable<INdm> crackedNdms;
|
||||
@@ -32,6 +30,11 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
private double longLength;
|
||||
private double shortLength;
|
||||
private ICheckInputDataLogic<TupleCrackInputData> checkInputDataLogic;
|
||||
private ILengthBetweenCracksLogic lengthLogic;
|
||||
private ITupleRebarsCrackSolver crackSolver;
|
||||
private ICheckInputDataLogic<TupleCrackInputData> CheckInputDataLogic => checkInputDataLogic ??= new CheckTupleCalculatorInputDataLogic();
|
||||
private ILengthBetweenCracksLogic LengthLogic => lengthLogic ??= new LengthBetweenCracksLogicSP63();
|
||||
private ITupleRebarsCrackSolver CrackSolver => crackSolver ??= new TupleRebarsCrackSolver();
|
||||
|
||||
public TupleCrackInputData InputData { get; set; }
|
||||
public IResult Result => result;
|
||||
@@ -46,16 +49,10 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
this.checkInputDataLogic = checkInputDataLogic;
|
||||
this.lengthLogic = lengthLogic;
|
||||
this.triangulationLogic = triangulationLogic;
|
||||
this.solver = solver;
|
||||
this.crackSolver = solver;
|
||||
}
|
||||
|
||||
public TupleCrackCalculator() : this (new CheckTupleCalculatorInputDataLogic(),
|
||||
new LengthBetweenCracksLogicSP63(),
|
||||
new CrackedSectionTriangulationLogic(),
|
||||
new TupleRebarsCrackSolver())
|
||||
{
|
||||
|
||||
}
|
||||
public TupleCrackCalculator() { }
|
||||
|
||||
public void Run()
|
||||
{
|
||||
@@ -139,19 +136,19 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
private void SolveRebarResult()
|
||||
{
|
||||
result.RebarResults.Clear();
|
||||
solver.Rebars = rebarPrimitives;
|
||||
solver.InputData = InputData;
|
||||
solver.LongLength = longLength;
|
||||
solver.ShortLength = shortLength;
|
||||
solver.TraceLogger = TraceLogger?.GetSimilarTraceLogger(0);
|
||||
solver.Run();
|
||||
if (solver.IsResultValid == false)
|
||||
CrackSolver.Rebars = rebarPrimitives;
|
||||
CrackSolver.InputData = InputData;
|
||||
CrackSolver.LongLength = longLength;
|
||||
CrackSolver.ShortLength = shortLength;
|
||||
CrackSolver.TraceLogger = TraceLogger?.GetSimilarTraceLogger(0);
|
||||
CrackSolver.Run();
|
||||
if (CrackSolver.IsResultValid == false)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += solver.Description;
|
||||
result.Description += CrackSolver.Description;
|
||||
return;
|
||||
}
|
||||
result.RebarResults.AddRange(solver.Result);
|
||||
result.RebarResults.AddRange(CrackSolver.Result);
|
||||
}
|
||||
|
||||
private StrainTuple CalcStrainMatrix(ForceTuple forceTuple, IEnumerable<INdm> ndms)
|
||||
@@ -181,15 +178,15 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
|
||||
private double GetLengthBetweenCracks(StrainTuple strainTuple)
|
||||
{
|
||||
lengthLogic.NdmCollection = elasticNdms;
|
||||
lengthLogic.TraceLogger = TraceLogger;
|
||||
lengthLogic.StrainMatrix = ForceTupleConverter.ConvertToLoaderStrainMatrix(strainTuple);
|
||||
return lengthLogic.GetLength();
|
||||
LengthLogic.NdmCollection = elasticNdms;
|
||||
LengthLogic.TraceLogger = TraceLogger;
|
||||
LengthLogic.StrainMatrix = ForceTupleConverter.ConvertToLoaderStrainMatrix(strainTuple);
|
||||
return LengthLogic.GetLength();
|
||||
}
|
||||
|
||||
private void Triangulate()
|
||||
{
|
||||
triangulationLogic = new CrackedSectionTriangulationLogic(InputData.Primitives)
|
||||
triangulationLogic = new CrackedSectionTriangulationLogic(InputData.Primitives, crackingTerm)
|
||||
{
|
||||
//TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
@@ -201,12 +198,12 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
|
||||
private bool CheckInputData()
|
||||
{
|
||||
checkInputDataLogic.InputData = InputData;
|
||||
if (checkInputDataLogic.Check() == false)
|
||||
CheckInputDataLogic.InputData = InputData;
|
||||
if (CheckInputDataLogic.Check() == false)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += checkInputDataLogic.CheckResult;
|
||||
TraceLogger?.AddMessage($"Input data is not correct: {checkInputDataLogic.CheckResult}", TraceLogStatuses.Error);
|
||||
result.Description += CheckInputDataLogic.CheckResult;
|
||||
TraceLogger?.AddMessage($"Input data is not correct: {CheckInputDataLogic.CheckResult}", TraceLogStatuses.Error);
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
|
||||
@@ -4,17 +4,28 @@ using StructureHelperCommon.Models.Materials;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for checking of propertis of rebar
|
||||
/// </summary>
|
||||
public class CheckRebarPrimitiveLogic : ICheckEntityLogic<IRebarNdmPrimitive>
|
||||
{
|
||||
private string checkResult;
|
||||
private bool result;
|
||||
|
||||
/// <summary>
|
||||
/// True if checking of rebar placement inside its host is required
|
||||
/// </summary>
|
||||
public bool CheckRebarPlacement { get; set; } = true;
|
||||
/// <summary>
|
||||
/// True if rebar must has its host
|
||||
/// </summary>
|
||||
public bool CheckRebarHostMaterial { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Rebar primitive
|
||||
/// </summary>
|
||||
public IRebarNdmPrimitive Entity { get; set; }
|
||||
|
||||
public string CheckResult => checkResult;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public CheckRebarPrimitiveLogic(IShiftTraceLogger traceLogger)
|
||||
|
||||
@@ -33,6 +33,11 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
}
|
||||
|
||||
public HasPrimitivesCheckLogic(IShiftTraceLogger? traceLogger)
|
||||
{
|
||||
TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
result = true;
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public class CircleTriangulationLogicOptions : IShapeTriangulationLogicOptions
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public ICircleShape Circle { get;}
|
||||
|
||||
public IPoint2D Center { get; set; }
|
||||
@@ -32,7 +34,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
Circle = new CircleShape() { Diameter = primitive.Width };
|
||||
DivisionSize = primitive.DivisionSize;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
Prestrain = ForceTupleServiceLogic.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public class LinePolygonTriangulationLogicOption : IShapeTriangulationLogicOptions
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public IPoint2D Center { get; set; }
|
||||
public IDivisionSize DivisionSize { get; set; }
|
||||
public ITriangulationOptions TriangulationOptions { get; set; }
|
||||
@@ -29,7 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
TriangulationOptions = triangulationOptions;
|
||||
Shape = primitive.Shape;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
Prestrain = ForceTupleServiceLogic.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
/// </summary>
|
||||
public class PointTriangulationLogicOptions : ITriangulationLogicOptions
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public ITriangulationOptions TriangulationOptions { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
@@ -29,7 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
Center = primitive.Center.Clone() as Point2D;
|
||||
Area = primitive.Area;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
Prestrain = ForceTupleServiceLogic.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
internal class RebarTriangulationLogic : ITriangulationLogic
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
private readonly RebarTriangulationLogicOptions options;
|
||||
public RebarTriangulationLogic(ITriangulationLogicOptions options)
|
||||
{
|
||||
@@ -60,7 +62,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
.HeadMaterial
|
||||
.GetLoaderMaterial(options.TriangulationOptions.LimiteState, options.TriangulationOptions.CalcTerm);
|
||||
|
||||
var prestrain = ForceTupleService.SumTuples(hostPrimitive.NdmElement.UsersPrestrain,
|
||||
var prestrain = ForceTupleServiceLogic.SumTuples(hostPrimitive.NdmElement.UsersPrestrain,
|
||||
hostPrimitive.NdmElement.AutoPrestrain)
|
||||
as StrainTuple;
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
public class RebarTriangulationLogicOptions : ITriangulationLogicOptions
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public ITriangulationOptions TriangulationOptions { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
@@ -32,7 +34,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
Area = primitive.Area;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
HostPrimitive = primitive.HostPrimitive;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
Prestrain = ForceTupleServiceLogic.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
/// <inheritdoc />
|
||||
public class RectangleTriangulationLogicOptions : IShapeTriangulationLogicOptions
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
/// <inheritdoc />
|
||||
public IPoint2D Center { get; set; }
|
||||
/// <inheritdoc />
|
||||
@@ -41,7 +43,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
DivisionSize.NdmMaxSize = primitive.DivisionSize.NdmMaxSize;
|
||||
DivisionSize.NdmMinDivision = primitive.DivisionSize.NdmMinDivision;
|
||||
HeadMaterial = primitive.NdmElement.HeadMaterial;
|
||||
Prestrain = ForceTupleService.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
Prestrain = ForceTupleServiceLogic.SumTuples(primitive.NdmElement.UsersPrestrain, primitive.NdmElement.AutoPrestrain) as StrainTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace StructureHelperLogics.Services.NdmCalculations
|
||||
public static class InterpolateService
|
||||
{
|
||||
static readonly CompressedMemberUpdateStrategy compressedMemberUpdateStrategy = new();
|
||||
private static IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private static IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
public static ForceCalculator InterpolateForceCalculator(IForceCalculator source, IStateCalcTermPair stateCalcTermPair, InterpolateTuplesResult interpolateTuplesResult)
|
||||
{
|
||||
ForceCalculator calculator = new ForceCalculator();
|
||||
@@ -21,7 +23,7 @@ namespace StructureHelperLogics.Services.NdmCalculations
|
||||
calculator.InputData.Primitives.AddRange(source.InputData.Primitives);
|
||||
calculator.InputData.ForceActions.Clear();
|
||||
calculator.InputData.CheckStrainLimit = source.InputData.CheckStrainLimit;
|
||||
var forceTuples = ForceTupleService.InterpolateTuples(interpolateTuplesResult.StartTuple, interpolateTuplesResult.FinishTuple, interpolateTuplesResult.StepCount);
|
||||
var forceTuples = ForceTupleServiceLogic.InterpolateTuples(interpolateTuplesResult.StartTuple, interpolateTuplesResult.FinishTuple, interpolateTuplesResult.StepCount);
|
||||
foreach (var forceTuple in forceTuples)
|
||||
{
|
||||
var combination = new ForceCombinationList()
|
||||
|
||||
@@ -104,12 +104,12 @@ namespace StructureHelperLogics.Services.NdmPrimitives
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
if (TriangulationOptions.CalcTerm is not CalcTerms.ShortTerm)
|
||||
{
|
||||
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Calc term for cracked concrete must correspondent short term");
|
||||
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorMessage);
|
||||
}
|
||||
//if (TriangulationOptions.CalcTerm is not CalcTerms.ShortTerm)
|
||||
//{
|
||||
// string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Calc term for cracked concrete must correspondent short term");
|
||||
// TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
|
||||
// throw new StructureHelperException(errorMessage);
|
||||
//}
|
||||
TraceLogger?.AddMessage($"Primitive check is ok");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
|
||||
{
|
||||
public class RCSectionsTest
|
||||
{
|
||||
private IForceTupleServiceLogic forceTupleServiceLogic;
|
||||
private IForceTupleServiceLogic ForceTupleServiceLogic => forceTupleServiceLogic ??= new ForceTupleServiceLogic();
|
||||
[TestCase(0.4d, 0.6d, 0.012d, 0.025d, 2, 2, false, -0.00068593466107645337d, -0.0030411189808055242d, 0.00034289928716916179d)]
|
||||
public void Run_ShouldPass(double width, double height, double topDiametr, double bottomDiametr, int widthCount, int heightCount, bool isBuckling, double expectedKx, double expectedKy, double expectedEpsZ)
|
||||
{
|
||||
@@ -75,7 +77,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
|
||||
//Act
|
||||
foreach (var item in ndmPrimitives)
|
||||
{
|
||||
ForceTupleService.CopyProperties(source, item.NdmElement.AutoPrestrain);
|
||||
ForceTupleServiceLogic.CopyProperties(source, item.NdmElement.AutoPrestrain);
|
||||
}
|
||||
calculator.Run();
|
||||
var result2 = calculator.Result as IForceCalculatorResult;
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
|
||||
namespace StructureHelperTests.UnitTests.Curvatures
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
public class CurvatureCalculatorInputDataUpdateStrategyTests
|
||||
{
|
||||
private Mock<IUpdateStrategy<IDeflectionFactor>> _deflectionUpdateMock;
|
||||
private CurvatureCalculatorInputDataUpdateStrategy _strategy;
|
||||
|
||||
private Mock<ICurvatureCalculatorInputData> _targetMock;
|
||||
private Mock<ICurvatureCalculatorInputData> _sourceMock;
|
||||
|
||||
private List<INdmPrimitive> _targetPrimitives;
|
||||
private List<INdmPrimitive> _sourcePrimitives;
|
||||
|
||||
private List<IForceAction> _targetForces;
|
||||
private List<IForceAction> _sourceForces;
|
||||
|
||||
private Mock<IDeflectionFactor> _targetDeflectionFactorMock;
|
||||
private Mock<IDeflectionFactor> _sourceDeflectionFactorMock;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_deflectionUpdateMock = new Mock<IUpdateStrategy<IDeflectionFactor>>();
|
||||
|
||||
_strategy = new CurvatureCalculatorInputDataUpdateStrategy(_deflectionUpdateMock.Object);
|
||||
|
||||
// Mock target and source ICurvatureCalculatorInputData
|
||||
_targetMock = new Mock<ICurvatureCalculatorInputData>();
|
||||
_sourceMock = new Mock<ICurvatureCalculatorInputData>();
|
||||
|
||||
_targetPrimitives = new List<INdmPrimitive> { new Mock<INdmPrimitive>().Object };
|
||||
_sourcePrimitives = new List<INdmPrimitive> { new Mock<INdmPrimitive>().Object, new Mock<INdmPrimitive>().Object };
|
||||
|
||||
_targetForces = new List<IForceAction> { new Mock<IForceAction>().Object };
|
||||
_sourceForces = new List<IForceAction> { new Mock<IForceAction>().Object, new Mock<IForceAction>().Object };
|
||||
|
||||
_targetDeflectionFactorMock = new Mock<IDeflectionFactor>();
|
||||
_sourceDeflectionFactorMock = new Mock<IDeflectionFactor>();
|
||||
|
||||
_targetMock.SetupGet(x => x.Primitives).Returns(_targetPrimitives);
|
||||
_targetMock.SetupGet(x => x.ForceActions).Returns(_targetForces);
|
||||
_targetMock.SetupGet(x => x.DeflectionFactor).Returns(_targetDeflectionFactorMock.Object);
|
||||
|
||||
_sourceMock.SetupGet(x => x.Primitives).Returns(_sourcePrimitives);
|
||||
_sourceMock.SetupGet(x => x.ForceActions).Returns(_sourceForces);
|
||||
_sourceMock.SetupGet(x => x.DeflectionFactor).Returns(_sourceDeflectionFactorMock.Object);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// TEST 1 — Basic update copies collections and calls DeflectionFactor update
|
||||
// ---------------------------------------------------------
|
||||
[Test]
|
||||
public void Update_ShouldCopyCollections_AndCallDeflectionUpdate()
|
||||
{
|
||||
// Act
|
||||
_strategy.Update(_targetMock.Object, _sourceMock.Object);
|
||||
|
||||
// Assert — target collections replaced by source
|
||||
Assert.That(_targetPrimitives, Is.EqualTo(_sourcePrimitives));
|
||||
Assert.That(_targetForces, Is.EqualTo(_sourceForces));
|
||||
|
||||
// DeflectionFactor update called
|
||||
_deflectionUpdateMock.Verify(x =>
|
||||
x.Update(_targetDeflectionFactorMock.Object, _sourceDeflectionFactorMock.Object), Times.Once);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// TEST 2 — Should throw if target is null
|
||||
// ---------------------------------------------------------
|
||||
[Test]
|
||||
public void Update_ShouldThrow_WhenTargetIsNull()
|
||||
{
|
||||
Assert.Throws<StructureHelperException>(() =>
|
||||
_strategy.Update(null!, _sourceMock.Object));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// TEST 3 — Should throw if source is null
|
||||
// ---------------------------------------------------------
|
||||
[Test]
|
||||
public void Update_ShouldThrow_WhenSourceIsNull()
|
||||
{
|
||||
Assert.Throws<StructureHelperException>(() =>
|
||||
_strategy.Update(_targetMock.Object, null!));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// TEST 4 — Should not update if source and target are the same
|
||||
// ---------------------------------------------------------
|
||||
[Test]
|
||||
public void Update_ShouldNotCallDeflectionUpdate_WhenSourceAndTargetSame()
|
||||
{
|
||||
_strategy.Update(_targetMock.Object, _targetMock.Object);
|
||||
|
||||
_deflectionUpdateMock.Verify(x =>
|
||||
x.Update(It.IsAny<IDeflectionFactor>(), It.IsAny<IDeflectionFactor>()), Times.Never);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// TEST 5 — Should skip children if UpdateChildren = false
|
||||
// ---------------------------------------------------------
|
||||
[Test]
|
||||
public void Update_ShouldSkipChildren_WhenUpdateChildrenFalse()
|
||||
{
|
||||
_strategy.UpdateChildren = false;
|
||||
|
||||
_strategy.Update(_targetMock.Object, _sourceMock.Object);
|
||||
|
||||
_deflectionUpdateMock.Verify(x =>
|
||||
x.Update(It.IsAny<IDeflectionFactor>(), It.IsAny<IDeflectionFactor>()), Times.Never);
|
||||
|
||||
// Collections unchanged
|
||||
Assert.That(_targetPrimitives, Is.Not.EqualTo(_sourcePrimitives));
|
||||
Assert.That(_targetForces, Is.Not.EqualTo(_sourceForces));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
|
||||
namespace StructureHelperTests.UnitTests.Curvatures
|
||||
{
|
||||
|
||||
|
||||
[TestFixture]
|
||||
public class GetDeflectionByCurvatureLogicTests
|
||||
{
|
||||
private Mock<IShiftTraceLogger> _logger;
|
||||
private GetDeflectionByCurvatureLogic _logic;
|
||||
private Mock<IForceTuple> _curvature;
|
||||
private Mock<IDeflectionFactor> _factor;
|
||||
private Mock<IForceTuple> _k;
|
||||
private Mock<IForceTuple> _max;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_logger = new Mock<IShiftTraceLogger>();
|
||||
_logic = new GetDeflectionByCurvatureLogic(_logger.Object);
|
||||
|
||||
_curvature = new Mock<IForceTuple>();
|
||||
_factor = new Mock<IDeflectionFactor>();
|
||||
_k = new Mock<IForceTuple>();
|
||||
_max = new Mock<IForceTuple>();
|
||||
|
||||
_factor.Setup(f => f.DeflectionFactors).Returns(_k.Object);
|
||||
_factor.Setup(f => f.MaxDeflections).Returns(_max.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDeflection_ComputesDeflectionMxCorrectly()
|
||||
{
|
||||
_factor.Setup(f => f.SpanLength).Returns(5.0);
|
||||
_k.Setup(f => f.Mx).Returns(2.0);
|
||||
_curvature.Setup(c => c.Mx).Returns(3.0);
|
||||
_max.Setup(m => m.Mx).Returns(10.0);
|
||||
|
||||
var result = _logic.GetDeflection(_curvature.Object, _factor.Object);
|
||||
|
||||
// Expected: k * curvature * L^2 = 2 * 3 * 25 = 150
|
||||
Assert.That(result.DeflectionMx.Deflection, Is.EqualTo(150.0));
|
||||
Assert.That(result.DeflectionMx.Curvature, Is.EqualTo(3.0));
|
||||
Assert.That(result.DeflectionMx.UltimateDeflection, Is.EqualTo(10.0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDeflection_ComputesDeflectionMyCorrectly()
|
||||
{
|
||||
_factor.Setup(f => f.SpanLength).Returns(4.0);
|
||||
_k.Setup(f => f.My).Returns(1.5);
|
||||
_curvature.Setup(c => c.My).Returns(2.0);
|
||||
_max.Setup(m => m.My).Returns(7.0);
|
||||
|
||||
var result = _logic.GetDeflection(_curvature.Object, _factor.Object);
|
||||
|
||||
// Expected: 1.5 * 2 * 16 = 48
|
||||
Assert.That(result.DeflectionMy.Deflection, Is.EqualTo(48.0));
|
||||
Assert.That(result.DeflectionMy.Curvature, Is.EqualTo(2.0));
|
||||
Assert.That(result.DeflectionMy.UltimateDeflection, Is.EqualTo(7.0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDeflection_ComputesDeflectionNzCorrectly()
|
||||
{
|
||||
_factor.Setup(f => f.SpanLength).Returns(10.0);
|
||||
_k.Setup(f => f.Nz).Returns(1.2);
|
||||
_curvature.Setup(c => c.Nz).Returns(4.0);
|
||||
_max.Setup(m => m.Nz).Returns(5.0);
|
||||
|
||||
var result = _logic.GetDeflection(_curvature.Object, _factor.Object);
|
||||
|
||||
// Expected: 1.2 * 4 * 10 = 48
|
||||
Assert.That(result.DeflectionNz.Deflection, Is.EqualTo(48.0));
|
||||
Assert.That(result.DeflectionNz.Curvature, Is.EqualTo(4.0));
|
||||
Assert.That(result.DeflectionNz.UltimateDeflection, Is.EqualTo(5.0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDeflection_LogsSpanLength()
|
||||
{
|
||||
_factor.Setup(f => f.SpanLength).Returns(6.0);
|
||||
|
||||
_logic.GetDeflection(_curvature.Object, _factor.Object);
|
||||
|
||||
_logger.Verify(l => l.AddMessage("Span length L = 6(m)"), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDeflection_LogsAllDeflectionsInCorrectFormat()
|
||||
{
|
||||
_factor.Setup(f => f.SpanLength).Returns(3.0);
|
||||
_k.Setup(f => f.Mx).Returns(2);
|
||||
_k.Setup(f => f.My).Returns(3);
|
||||
_k.Setup(f => f.Nz).Returns(4);
|
||||
|
||||
_curvature.Setup(c => c.Mx).Returns(1.0);
|
||||
_curvature.Setup(c => c.My).Returns(2.0);
|
||||
_curvature.Setup(c => c.Nz).Returns(3.0);
|
||||
|
||||
_max.Setup(m => m.Mx).Returns(0);
|
||||
_max.Setup(m => m.My).Returns(0);
|
||||
_max.Setup(m => m.Nz).Returns(0);
|
||||
|
||||
_logic.GetDeflection(_curvature.Object, _factor.Object);
|
||||
|
||||
_logger.Verify(l =>
|
||||
l.AddMessage("Deflection along X axis = 2 * 1 * (3)^2 = 18(m)"),
|
||||
Times.Once);
|
||||
|
||||
_logger.Verify(l =>
|
||||
l.AddMessage("Deflection along Y axis = 3 * 2 * (3)^2 = 54(m)"),
|
||||
Times.Once);
|
||||
|
||||
_logger.Verify(l =>
|
||||
l.AddMessage("Deflection along Z axis = 4 * 3 * 3 = 36(m)"),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDeflection_ZeroCurvature_ProducesZeroDeflection()
|
||||
{
|
||||
_factor.Setup(f => f.SpanLength).Returns(10);
|
||||
_k.Setup(f => f.Mx).Returns(5);
|
||||
_curvature.Setup(c => c.Mx).Returns(0);
|
||||
|
||||
var result = _logic.GetDeflection(_curvature.Object, _factor.Object);
|
||||
|
||||
Assert.That(result.DeflectionMx.Deflection, Is.EqualTo(0));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
|
||||
namespace StructureHelperTests.UnitTests.Curvatures
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
public class GetTermDeflectionLogicTests
|
||||
{
|
||||
private Mock<IGetDeflectionByCurvatureLogic> _deflectionLogicMock;
|
||||
private Mock<IForceTupleServiceLogic> _forceTupleServiceMock;
|
||||
private Mock<IShiftTraceLogger> _loggerMock;
|
||||
private Mock<IDeflectionFactor> _deflectionFactorMock;
|
||||
|
||||
private Mock<IForceTuple> _longCurvatureMock;
|
||||
private Mock<IForceTuple> _shortLongCurvatureMock;
|
||||
private Mock<IForceTuple> _shortFullCurvatureMock;
|
||||
private Mock<ICurvatureTermResult> _expectedResultMock;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_deflectionLogicMock = new Mock<IGetDeflectionByCurvatureLogic>();
|
||||
_forceTupleServiceMock = new Mock<IForceTupleServiceLogic>();
|
||||
_loggerMock = new Mock<IShiftTraceLogger>();
|
||||
_deflectionFactorMock = new Mock<IDeflectionFactor>();
|
||||
|
||||
_longCurvatureMock = new Mock<IForceTuple>();
|
||||
_shortLongCurvatureMock = new Mock<IForceTuple>();
|
||||
_shortFullCurvatureMock = new Mock<IForceTuple>();
|
||||
_expectedResultMock = new Mock<ICurvatureTermResult>();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// TEST 1 — GetLongResult should call deflection logic
|
||||
// ---------------------------------------------------------
|
||||
[Test]
|
||||
public void GetLongResult_ShouldCallDeflectionLogic_AndReturnResult()
|
||||
{
|
||||
// Arrange
|
||||
var logic = new GetTermDeflectionLogic(
|
||||
_deflectionLogicMock.Object,
|
||||
_forceTupleServiceMock.Object,
|
||||
_loggerMock.Object)
|
||||
{
|
||||
LongCurvature = _longCurvatureMock.Object,
|
||||
DeflectionFactor = _deflectionFactorMock.Object
|
||||
};
|
||||
|
||||
_deflectionLogicMock
|
||||
.Setup(x => x.GetDeflection(_longCurvatureMock.Object, _deflectionFactorMock.Object))
|
||||
.Returns(_expectedResultMock.Object);
|
||||
|
||||
// Act
|
||||
var result = logic.GetLongResult();
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(_expectedResultMock.Object));
|
||||
_deflectionLogicMock.Verify(x => x.GetDeflection(_longCurvatureMock.Object, _deflectionFactorMock.Object),
|
||||
Times.Once);
|
||||
|
||||
_loggerMock.Verify(x => x.AddMessage(It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// TEST 2 — GetShortResult should compute curvature and call deflection logic
|
||||
// ---------------------------------------------------------
|
||||
[Test]
|
||||
public void GetShortResult_ShouldComputeShortCurvature_AndReturnDeflection()
|
||||
{
|
||||
// Arrange
|
||||
var deltaCurvatureMock = new Mock<IForceTuple>().Object;
|
||||
var shortCurvatureMock = new Mock<IForceTuple>().Object;
|
||||
|
||||
var logic = new GetTermDeflectionLogic(
|
||||
_deflectionLogicMock.Object,
|
||||
_forceTupleServiceMock.Object,
|
||||
_loggerMock.Object)
|
||||
{
|
||||
LongCurvature = _longCurvatureMock.Object,
|
||||
ShortFullCurvature = _shortFullCurvatureMock.Object,
|
||||
ShortLongCurvature = _shortLongCurvatureMock.Object,
|
||||
DeflectionFactor = _deflectionFactorMock.Object
|
||||
};
|
||||
|
||||
_forceTupleServiceMock
|
||||
.Setup(x => x.SumTuples(_shortFullCurvatureMock.Object, _shortLongCurvatureMock.Object, -1))
|
||||
.Returns(deltaCurvatureMock);
|
||||
|
||||
_forceTupleServiceMock
|
||||
.Setup(x => x.SumTuples(_longCurvatureMock.Object, deltaCurvatureMock))
|
||||
.Returns(shortCurvatureMock);
|
||||
|
||||
_deflectionLogicMock
|
||||
.Setup(x => x.GetDeflection(shortCurvatureMock, _deflectionFactorMock.Object))
|
||||
.Returns(_expectedResultMock.Object);
|
||||
|
||||
// Act
|
||||
var result = logic.GetShortResult();
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(_expectedResultMock.Object));
|
||||
|
||||
_forceTupleServiceMock.Verify(x =>
|
||||
x.SumTuples(_shortFullCurvatureMock.Object, _shortLongCurvatureMock.Object, -1), Times.Once);
|
||||
|
||||
_forceTupleServiceMock.Verify(x =>
|
||||
x.SumTuples(_longCurvatureMock.Object, deltaCurvatureMock), Times.Once);
|
||||
|
||||
_deflectionLogicMock.Verify(x =>
|
||||
x.GetDeflection(shortCurvatureMock, _deflectionFactorMock.Object), Times.Once);
|
||||
|
||||
// Trace should run once for the final curvature
|
||||
_loggerMock.Verify(x => x.AddMessage(It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user