Force calculator was changed

This commit is contained in:
RedikultsevEvg
2024-07-27 21:29:26 +05:00
parent 45a87fe7a6
commit 09b53ac4e3
33 changed files with 670 additions and 491 deletions

View File

@@ -12,86 +12,95 @@
<Style x:Key="cbStyle" TargetType="CheckBox"> <Style x:Key="cbStyle" TargetType="CheckBox">
<Setter Property="Margin" Value="0,5,0,5"/> <Setter Property="Margin" Value="0,5,0,5"/>
</Style> </Style>
<DataTemplate x:Key="InputDataTemplate">
<TabControl>
<TabItem Header="General">
<StackPanel>
<GroupBox Header="Limit States">
<StackPanel>
<CheckBox Style="{StaticResource cbStyle}" Content="Ultimate Limit State" IsChecked="{Binding ULS}"/>
<CheckBox Style="{StaticResource cbStyle}" Content="Serviceability Limit State" IsChecked="{Binding SLS}"/>
</StackPanel>
</GroupBox>
<GroupBox Header="Duration">
<StackPanel>
<CheckBox Style="{StaticResource cbStyle}" Content="Short Term" IsChecked="{Binding ShortTerm}"/>
<CheckBox Style="{StaticResource cbStyle}" Content="Long Term" IsChecked="{Binding LongTerm}"/>
</StackPanel>
</GroupBox>
</StackPanel>
</TabItem>
<TabItem Header="Forces">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding CombinationViewModel}"/>
</TabItem>
<TabItem Header="Primitives">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding PrimitivesViewModel}"/>
</TabItem>
<TabItem Header="S-Order">
<Grid DataContext="{Binding SecondOrder}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Consider second order effects"/>
<TextBlock Grid.Row="1" Text="Geometry length"/>
<TextBlock Grid.Row="2" Text="Buckling factor x-axis"/>
<TextBlock Grid.Row="3" Text="Buckling factor y-axis"/>
<CheckBox Grid.Column="1" IsChecked="{Binding Buckling}"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding GeometryLength, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding LengthFactorX, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding LengthFactorY, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
</Grid>
</TabItem>
<TabItem Header="Iterations">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Required Accuracy" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Margin="5,5,5,5" Text="{Binding IterationAccuracy, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="1" Text="Maximum Iteration Count" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5" Text="{Binding MaxIterationCount, ValidatesOnDataErrors=True}"/>
</Grid>
</TabItem>
</TabControl>
</DataTemplate>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="35"/> <RowDefinition Height="35"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TabControl> <Grid>
<TabItem Header="General"> <Grid.RowDefinitions>
<StackPanel> <RowDefinition Height="25"/>
<Grid> <RowDefinition/>
<Grid.ColumnDefinitions> </Grid.RowDefinitions>
<ColumnDefinition Width="100"/> <Grid>
<ColumnDefinition Width="300"/> <Grid.ColumnDefinitions>
</Grid.ColumnDefinitions> <ColumnDefinition Width="100"/>
<TextBlock Text="Name"/> <ColumnDefinition Width="300"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/> </Grid.ColumnDefinitions>
</Grid> <TextBlock Text="Name"/>
<GroupBox Header="Limit States"> <TextBox Grid.Column="1" Text="{Binding Name}"/>
<StackPanel> </Grid>
<CheckBox Style="{StaticResource cbStyle}" Content="Ultimate Limit State" IsChecked="{Binding ULS}"/> <ContentControl Grid.Row="1" ContentTemplate="{StaticResource InputDataTemplate}" Content="{Binding InputData}" />
<CheckBox Style="{StaticResource cbStyle}" Content="Serviceability Limit State" IsChecked="{Binding SLS}"/> </Grid>
</StackPanel>
</GroupBox>
<GroupBox Header="Duration">
<StackPanel>
<CheckBox Style="{StaticResource cbStyle}" Content="Short Term" IsChecked="{Binding ShortTerm}"/>
<CheckBox Style="{StaticResource cbStyle}" Content="Long Term" IsChecked="{Binding LongTerm}"/>
</StackPanel>
</GroupBox>
</StackPanel>
</TabItem>
<TabItem Header="Forces">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding CombinationViewModel}"/>
</TabItem>
<TabItem Header="Primitives">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding PrimitivesViewModel}"/>
</TabItem>
<TabItem Header="S-Order">
<Grid DataContext="{Binding SecondOrder}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Consider second order effects"/>
<TextBlock Grid.Row="1" Text="Geometry length"/>
<TextBlock Grid.Row="2" Text="Buckling factor x-axis"/>
<TextBlock Grid.Row="3" Text="Buckling factor y-axis"/>
<CheckBox Grid.Column="1" IsChecked="{Binding Buckling}"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding GeometryLength, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding LengthFactorX, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding LengthFactorY, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
</Grid>
</TabItem>
<TabItem Header="Iterations">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Required Accuracy" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Margin="5,5,5,5" Text="{Binding IterationAccuracy, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="1" Text="Maximum Iteration Count" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5" Text="{Binding MaxIterationCount, ValidatesOnDataErrors=True}"/>
</Grid>
</TabItem>
</TabControl>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/> <ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid> </Grid>
</Window> </Window>

View File

@@ -408,7 +408,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
this.forceCalculator = forceCalculator; this.forceCalculator = forceCalculator;
forcesResults = forceCalculator.Result as IForcesResults; forcesResults = forceCalculator.Result as IForcesResults;
ndmPrimitives = forceCalculator.Primitives; ndmPrimitives = forceCalculator.InputData.Primitives;
} }
private void ShowIsoField() private void ShowIsoField()

View File

@@ -0,0 +1,82 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
public class ForceCalculatorInputDataVM : ViewModelBase
{
private ForceInputData inputData;
SecondOrderViewModel secondOrderViewModel;
public double IterationAccuracy
{
get { return inputData.Accuracy.IterationAccuracy; }
set { inputData.Accuracy.IterationAccuracy = value; }
}
public int MaxIterationCount
{
get { return inputData.Accuracy.MaxIterationCount; }
set { inputData.Accuracy.MaxIterationCount = value; }
}
public SecondOrderViewModel SecondOrder => secondOrderViewModel;
public bool ULS { get; set; }
public bool SLS { get; set; }
public bool ShortTerm { get; set; }
public bool LongTerm { get; set; }
public SourceTargetVM<IForceAction> CombinationViewModel { get; }
public SourceTargetVM<PrimitiveBase> PrimitivesViewModel { get; private set; }
public ForceCalculatorInputDataVM(ForceInputData inputData, IEnumerable<INdmPrimitive> allowedPrimitives, IEnumerable<IForceAction> allowedCombinations)
{
this.inputData = inputData;
secondOrderViewModel = new SecondOrderViewModel(this.inputData.CompressedMember);
CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(allowedCombinations, this.inputData.ForceActions);
PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(allowedPrimitives, this.inputData.Primitives);
InputRefresh();
}
public void InputRefresh()
{
ULS = inputData.LimitStatesList.Contains(LimitStates.ULS);
SLS = inputData.LimitStatesList.Contains(LimitStates.SLS);
ShortTerm = inputData.CalcTermsList.Contains(CalcTerms.ShortTerm);
LongTerm = inputData.CalcTermsList.Contains(CalcTerms.LongTerm);
}
public void Refresh()
{
var combinations = CombinationViewModel.GetTargetItems();
inputData.ForceActions.Clear();
foreach (var item in combinations)
{
inputData.ForceActions.Add(item);
}
inputData.Primitives.Clear();
foreach (var item in PrimitivesViewModel.GetTargetItems())
{
inputData.Primitives.Add(item.GetNdmPrimitive());
}
inputData.LimitStatesList.Clear();
if (ULS == true) { inputData.LimitStatesList.Add(LimitStates.ULS); }
if (SLS == true) { inputData.LimitStatesList.Add(LimitStates.SLS); }
inputData.CalcTermsList.Clear();
if (ShortTerm == true) { inputData.CalcTermsList.Add(CalcTerms.ShortTerm); }
if (LongTerm == true) { inputData.CalcTermsList.Add(CalcTerms.LongTerm); }
}
}
}

View File

@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -16,7 +17,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
public class ForceCalculatorViewModel : OkCancelViewModelBase public class ForceCalculatorViewModel : OkCancelViewModelBase
{ {
ForceCalculator forcesCalculator; ForceCalculator forcesCalculator;
SecondOrderViewModel secondOrderViewModel;
public string Name public string Name
{ {
@@ -24,64 +24,17 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
set { forcesCalculator.Name = value; } set { forcesCalculator.Name = value; }
} }
public double IterationAccuracy public ForceCalculatorInputDataVM InputData { get; }
{
get { return forcesCalculator.Accuracy.IterationAccuracy; }
set { forcesCalculator.Accuracy.IterationAccuracy = value;}
}
public int MaxIterationCount
{
get { return forcesCalculator.Accuracy.MaxIterationCount; }
set { forcesCalculator.Accuracy.MaxIterationCount = value; }
}
public SecondOrderViewModel SecondOrder => secondOrderViewModel;
public bool ULS { get; set; }
public bool SLS { get; set; }
public bool ShortTerm { get; set; }
public bool LongTerm { get; set; }
public SourceTargetVM<IForceAction> CombinationViewModel { get; }
public SourceTargetVM<PrimitiveBase> PrimitivesViewModel { get; private set; }
public ForceCalculatorViewModel(IEnumerable<INdmPrimitive> allowedPrimitives, IEnumerable<IForceAction> allowedCombinations, ForceCalculator forcesCalculator) public ForceCalculatorViewModel(IEnumerable<INdmPrimitive> allowedPrimitives, IEnumerable<IForceAction> allowedCombinations, ForceCalculator forcesCalculator)
{ {
this.forcesCalculator = forcesCalculator; this.forcesCalculator = forcesCalculator;
secondOrderViewModel = new SecondOrderViewModel(this.forcesCalculator.CompressedMember); InputData = new ForceCalculatorInputDataVM(this.forcesCalculator.InputData, allowedPrimitives, allowedCombinations);
CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(allowedCombinations, this.forcesCalculator.ForceActions);
PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(allowedPrimitives, this.forcesCalculator.Primitives);
InputRefresh();
} }
public void InputRefresh() internal void Refresh()
{ {
ULS = forcesCalculator.LimitStatesList.Contains(LimitStates.ULS); InputData.Refresh();
SLS = forcesCalculator.LimitStatesList.Contains(LimitStates.SLS);
ShortTerm = forcesCalculator.CalcTermsList.Contains(CalcTerms.ShortTerm);
LongTerm = forcesCalculator.CalcTermsList.Contains(CalcTerms.LongTerm);
}
public void Refresh()
{
var combinations = CombinationViewModel.GetTargetItems();
forcesCalculator.ForceActions.Clear();
foreach (var item in combinations)
{
forcesCalculator.ForceActions.Add(item);
}
forcesCalculator.Primitives.Clear();
foreach (var item in PrimitivesViewModel.GetTargetItems())
{
forcesCalculator.Primitives.Add(item.GetNdmPrimitive());
}
forcesCalculator.LimitStatesList.Clear();
if (ULS == true) { forcesCalculator.LimitStatesList.Add(LimitStates.ULS); }
if (SLS == true) { forcesCalculator.LimitStatesList.Add(LimitStates.SLS); }
forcesCalculator.CalcTermsList.Clear();
if (ShortTerm == true) { forcesCalculator.CalcTermsList.Add(CalcTerms.ShortTerm); }
if (LongTerm == true) { forcesCalculator.CalcTermsList.Add(CalcTerms.LongTerm); }
} }
} }
} }

View File

@@ -95,9 +95,9 @@ namespace StructureHelper.Windows.ViewModels.Forces
var calcRepository = repository.CalculatorsList; var calcRepository = repository.CalculatorsList;
foreach (var calc in calcRepository) foreach (var calc in calcRepository)
{ {
if (calc is IForceCalculator) if (calc is ForceCalculator forceCalculator)
{ {
var forceCombinations = calc as IHasForceCombinations; var forceCombinations = forceCalculator.InputData as IHasForceCombinations;
result = DeleteActionFromHost(result, calc, forceCombinations); result = DeleteActionFromHost(result, calc, forceCombinations);
} }
else if (calc is CrackCalculator calculator) else if (calc is CrackCalculator calculator)

View File

@@ -60,7 +60,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void AddCrackCalculator() private void AddCrackCalculator()
{ {
var inputData = new CrackInputData(); var inputData = new CrackInputData();
var calculator = new CrackCalculator(inputData, new CheckCrackCalculatorInputDataLogic(inputData)) var calculator = new CrackCalculator(inputData)
{ {
Name = "New crack calculator", Name = "New crack calculator",
TraceLogger = new ShiftTraceLogger(), TraceLogger = new ShiftTraceLogger(),

View File

@@ -136,9 +136,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
repository.Primitives.Remove(ndmPrimitive); repository.Primitives.Remove(ndmPrimitive);
foreach (var calc in repository.CalculatorsList) foreach (var calc in repository.CalculatorsList)
{ {
if (calc is IForceCalculator) if (calc is ForceCalculator forceCalculator)
{ {
var forceCalc = calc as IHasPrimitives; var forceCalc = forceCalculator.InputData as IHasPrimitives;
forceCalc.Primitives.Remove(ndmPrimitive); forceCalc.Primitives.Remove(ndmPrimitive);
} }
else if (calc is LimitCurvesCalculator calculator) else if (calc is LimitCurvesCalculator calculator)

View File

@@ -7,8 +7,8 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces namespace StructureHelperCommon.Infrastructures.Interfaces
{ {
public interface ICheckInputDataLogic : ICheckLogic public interface ICheckInputDataLogic<TInputData> : ICheckLogic where TInputData : IInputData
{ {
IInputData InputData { get; set; } TInputData InputData { get; set; }
} }
} }

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IDecorator<T> where T : class
{
T SourceValue { get; }
T GetModifiedValue();
}
}

View File

@@ -4,6 +4,7 @@ using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Templates.RCs; using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Analyses; using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Cracking; using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System; using System;
@@ -58,10 +59,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
foreach (var calculator in calculators) foreach (var calculator in calculators)
{ {
if (calculator is IHasForceCombinations) if (calculator is ForceCalculator forceCalculator)
{ {
var forceCalculator = calculator as IHasForceCombinations; forceCalculator.InputData.ForceActions.AddRange(combinations);
forceCalculator.ForceActions.AddRange(combinations);
} }
if (calculator is CrackCalculator crackCalculator) if (calculator is CrackCalculator crackCalculator)
{ {
@@ -73,10 +73,9 @@ namespace StructureHelperLogics.Models.Templates.CrossSections.RCs
{ {
foreach (var calculator in calculators) foreach (var calculator in calculators)
{ {
if (calculator is IHasPrimitives) if (calculator is ForceCalculator forceCalculator)
{ {
var primitiveCalculator = calculator as IHasPrimitives; forceCalculator.InputData.Primitives.AddRange(primitives);
primitiveCalculator.Primitives.AddRange(primitives);
} }
if (calculator is CrackCalculator crackCalculator) if (calculator is CrackCalculator crackCalculator)
{ {

View File

@@ -0,0 +1,55 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
internal class CheckForceCalculatorInputData : ICheckInputDataLogic<ForceInputData>
{
public ForceInputData InputData { get; set; }
public string CheckResult { get; private set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckForceCalculatorInputData(ForceInputData inputData)
{
InputData = inputData;
CheckResult = string.Empty;
}
public bool Check()
{
bool result = true;
CheckResult = string.Empty;
if (!InputData.Primitives.Any())
{
CheckResult += "Calculator does not contain any primitives \n";
result = false;
}
if (!InputData.ForceActions.Any())
{
CheckResult += "Calculator does not contain any forces \n";
result = false;
}
if (!InputData.LimitStatesList.Any())
{
CheckResult += "Calculator does not contain any limit states \n";
result = false;
}
if (!InputData.CalcTermsList.Any())
{
CheckResult += "Calculator does not contain any calc term \n";
result = false;
}
return result;
}
}
}

View File

@@ -1,297 +1,76 @@
using LoaderCalculator.Data.Ndms; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers; using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Sections;
using StructureHelperCommon.Models.Sections.Logics;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics; using StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics;
using StructureHelperLogics.NdmCalculations.Buckling;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
public class ForceCalculator : IForceCalculator, IHasActionByResult public class ForceCalculator : ICalculator, IHasActionByResult
{ {
static readonly ForceCalculatorUpdateStrategy updateStrategy = new(); private IUpdateStrategy<ForceCalculator> updateStrategy = new ForceCalculatorUpdateStrategy();
private readonly IForceTupleCalculator forceTupleCalculator; private ICheckInputDataLogic<ForceInputData> checkInputDataLogic;
private ForcesResults result; private IForceCalculatorLogic forceCalculatorLogic;
private IProcessorLogic<IForceTuple> eccentricityLogic;
private ForceTupleBucklingLogic bucklingLogic;
private ITriangulatePrimitiveLogic triangulateLogic;
public string Name { get; set; } public string Name { get; set; }
public List<LimitStates> LimitStatesList { get; private set; } public ForceInputData InputData {get;set;}
public List<CalcTerms> CalcTermsList { get; private set; }
public List<IForceAction> ForceActions { get; private set; }
public List<INdmPrimitive> Primitives { get; private set; }
public IResult Result { get; private set; }
public ICompressedMember CompressedMember { get; private set; }
public IAccuracy Accuracy { get; set; }
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
public Action<IResult> ActionToOutputResults { get; set; } public Action<IResult> ActionToOutputResults { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public IResult Result { get; private set; }
public void Run() public void Run()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
var checkResult = CheckInputData(); checkInputDataLogic = new CheckForceCalculatorInputData(InputData);
if (checkResult != string.Empty) checkInputDataLogic.TraceLogger?.GetSimilarTraceLogger(50);
if (checkInputDataLogic.Check() != true)
{ {
Result = new ForcesResults() Result = new ForcesResults()
{ {
IsValid = false, IsValid = false,
Description = checkResult Description = checkInputDataLogic.CheckResult
}; };
return; return;
} }
GetCombinations(); if (ActionToOutputResults is not null)
CalculateResult(); {
forceCalculatorLogic.ActionToOutputResults = ActionToOutputResults;
}
forceCalculatorLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
Result = forceCalculatorLogic.GetForcesResults();
} }
private void CalculateResult() private void GetResult()
{ {
result = new ForcesResults() throw new NotImplementedException();
{
IsValid = true
};
foreach (var combination in ForceCombinationLists)
{
foreach (var tuple in combination.DesignForces)
{
var limitState = tuple.LimitState;
var calcTerm = tuple.CalcTerm;
if (LimitStatesList.Contains(limitState) & CalcTermsList.Contains(calcTerm))
{
IForcesTupleResult tupleResult;
try
{
tupleResult = ProcessNdmResult(combination, tuple);
}
catch(Exception ex)
{
tupleResult = new ForcesTupleResult()
{
IsValid = false,
Description = string.Empty + ex,
DesignForceTuple = tuple
};
}
result.ForcesResultList.Add(tupleResult);
ActionToOutputResults?.Invoke(result);
}
}
}
Result = result;
} }
private IForcesTupleResult ProcessNdmResult(IForceCombinationList combination, IDesignForceTuple tuple) public ForceCalculator(ForceInputData inputData,
ICheckInputDataLogic<ForceInputData> checkInputDataLogic,
IForceCalculatorLogic forceCalculatorLogic,
IUpdateStrategy<ForceCalculator> updateStrategy
)
{ {
IForcesTupleResult tupleResult; this.InputData = inputData;
LimitStates limitState = tuple.LimitState; this.checkInputDataLogic = checkInputDataLogic;
CalcTerms calcTerm = tuple.CalcTerm; this.forceCalculatorLogic = forceCalculatorLogic;
triangulateLogic = new TriangulatePrimitiveLogic() this.updateStrategy = updateStrategy;
{
Primitives = Primitives,
LimitState = limitState,
CalcTerm = calcTerm,
TraceLogger = TraceLogger
};
var ndms = triangulateLogic.GetNdms();
IPoint2D point2D;
IProcessorLogic<IForceTuple> forcelogic = new ForceTupleCopier(tuple.ForceTuple);
if (combination.SetInGravityCenter == true)
{
var (Cx, Cy) = LoaderCalculator.Logics.Geometry.GeometryOperations.GetGravityCenter(ndms);
point2D = new Point2D() { X = Cx, Y = Cy };
forcelogic = new ForceTupleMoveToPointDecorator(forcelogic) { Point2D = point2D};
}
var newTuple = forcelogic.GetValue();
TraceLogger?.AddMessage("Input force combination");
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple));
if (CompressedMember.Buckling == true)
{
if (newTuple.Nz >= 0d)
{
TraceLogger?.AddMessage(string.Format("Second order effect is not considered as Nz={0} >= 0", newTuple.Nz));
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
}
else
{
tupleResult = ProcessCompressedMember(combination, tuple, ndms, newTuple);
}
}
else
{
if (newTuple.Nz < 0d)
{
string message = string.Format("Second order effect is not considered, despite force Nz={0}", newTuple.Nz);
TraceLogger?.AddMessage(message, TraceLogStatuses.Warning);
}
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
}
return tupleResult;
} }
private IForcesTupleResult ProcessCompressedMember(IForceCombinationList combination, IDesignForceTuple tuple, List<INdm> ndms, IForceTuple newTuple) public ForceCalculator(ForceInputData inputData) :
{ this(inputData,
IForcesTupleResult tupleResult; new CheckForceCalculatorInputData(inputData),
LimitStates limitState = tuple.LimitState; new ForceCalculatorLogic(inputData),
CalcTerms calcTerm = tuple.CalcTerm; new ForceCalculatorUpdateStrategy())
TraceLogger?.AddMessage("Get eccentricity for full load");
eccentricityLogic = new ProcessEccentricity(CompressedMember, ndms, newTuple)
{
TraceLogger = TraceLogger ?? null
};
newTuple = eccentricityLogic.GetValue();
var buclingInputData = new BucklingInputData()
{
Combination = combination,
LimitState = limitState,
CalcTerm = calcTerm,
Ndms = ndms,
ForceTuple = newTuple
};
bucklingLogic = new ForceTupleBucklingLogic(buclingInputData)
{
CompressedMember = CompressedMember,
Accuracy = Accuracy,
Primitives = Primitives,
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
};
var buckResult = bucklingLogic.GetForceTupleByBuckling();
if (buckResult.IsValid == true)
{
newTuple = buckResult.Value;
}
else
{
return new ForcesTupleResult()
{
IsValid = false,
DesignForceTuple = tuple,
Description = buckResult.Description,
};
}
TraceLogger?.AddMessage(string.Intern("Result of second order was obtained succesfully, new force combination was obtained"));
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
return tupleResult;
}
private IForcesTupleResult GetForceResult(LimitStates limitState, CalcTerms calcTerm, List<INdm> ndms, IForceTuple newTuple)
{
TraceLogger?.AddMessage("Calculation of cross-section is started");
var tupleResult = GetPrimitiveStrainMatrix(ndms, newTuple, Accuracy);
tupleResult.DesignForceTuple.LimitState = limitState;
tupleResult.DesignForceTuple.CalcTerm = calcTerm;
tupleResult.DesignForceTuple.ForceTuple = newTuple;
return tupleResult;
}
private string CheckInputData()
{
string result = string.Empty;
if (! Primitives.Any())
{
result += "Calculator does not contain any primitives \n";
}
if (ForceActions.Count == 0)
{
result += "Calculator does not contain any forces \n";
}
if (LimitStatesList.Count == 0)
{
result += "Calculator does not contain any limit states \n";
}
if (CalcTermsList.Count == 0)
{
result += "Calculator does not contain any calc term \n";
}
//try
//{
// triangulateLogic = new TriangulatePrimitiveLogic()
// {
// Primitives = Primitives
// };
// triangulateLogic.CheckPrimitives(Primitives);
//}
//catch (Exception ex)
//{
// result += ex;
//}
return result;
}
public ForceCalculator(IForceTupleCalculator forceTupleCalculator)
{
this.forceTupleCalculator = forceTupleCalculator;
SetDefaultProperties();
}
public ForceCalculator() : this(new ForceTupleCalculator())
{ {
} }
private void SetDefaultProperties() public ForceCalculator() : this(new ForceInputData()) { }
{
ForceActions = new List<IForceAction>();
Primitives = new List<INdmPrimitive>();
CompressedMember = new CompressedMember()
{
Buckling = false
};
Accuracy = new Accuracy()
{
IterationAccuracy = 0.001d,
MaxIterationCount = 1000
};
LimitStatesList = new List<LimitStates>()
{
LimitStates.ULS,
LimitStates.SLS
};
CalcTermsList = new List<CalcTerms>()
{
CalcTerms.ShortTerm,
CalcTerms.LongTerm
};
}
private void GetCombinations()
{
ForceCombinationLists = new List<IForceCombinationList>();
foreach (var item in ForceActions)
{
ForceCombinationLists.Add(item.GetCombinations());
}
}
private IForcesTupleResult GetPrimitiveStrainMatrix(IEnumerable<INdm> ndmCollection, IForceTuple tuple, IAccuracy accuracy)
{
var inputData = new ForceTupleInputData()
{
NdmCollection = ndmCollection,
Tuple = tuple,
Accuracy = accuracy
};
var calculator = forceTupleCalculator.Clone() as IForceTupleCalculator;
calculator.InputData = inputData;
if (TraceLogger is not null)
{
calculator.TraceLogger = TraceLogger.GetSimilarTraceLogger();
}
calculator.Run();
return calculator.Result as IForcesTupleResult;
}
public object Clone() public object Clone()
{ {
var newCalculator = new ForceCalculator(); var newCalculator = new ForceCalculator(new ForceInputData());
updateStrategy.Update(newCalculator, this); updateStrategy.Update(newCalculator, this);
return newCalculator; return newCalculator;
} }

View File

@@ -0,0 +1,42 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Sections;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class ForceCalculatorInputDataUpdateStrategy : IUpdateStrategy<ForceInputData>
{
private IUpdateStrategy<IAccuracy> accuracyUpdateStrategy;
private IUpdateStrategy<ICompressedMember> compressedMemberUpdateStrategy;
public ForceCalculatorInputDataUpdateStrategy(IUpdateStrategy<IAccuracy> accuracyUpdateStrategy, IUpdateStrategy<ICompressedMember> compressedMemberUpdateStrategy)
{
this.accuracyUpdateStrategy = accuracyUpdateStrategy;
this.compressedMemberUpdateStrategy = compressedMemberUpdateStrategy;
}
public ForceCalculatorInputDataUpdateStrategy() : this(new AccuracyUpdateStrategy(), new CompressedMemberUpdateStrategy()) { }
public void Update(ForceInputData targetObject, ForceInputData sourceObject)
{
if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.CompareTypes(targetObject, sourceObject);
targetObject.Accuracy ??= new Accuracy();
accuracyUpdateStrategy.Update(targetObject.Accuracy, sourceObject.Accuracy);
targetObject.CompressedMember ??= new CompressedMember();
compressedMemberUpdateStrategy.Update(targetObject.CompressedMember, sourceObject.CompressedMember);
targetObject.LimitStatesList.Clear();
targetObject.LimitStatesList.AddRange(sourceObject.LimitStatesList);
targetObject.CalcTermsList.Clear();
targetObject.CalcTermsList.AddRange(sourceObject.CalcTermsList);
targetObject.Primitives.Clear();
targetObject.Primitives.AddRange(sourceObject.Primitives);
targetObject.ForceActions.Clear();
targetObject.ForceActions.AddRange(sourceObject.ForceActions);
}
}
}

View File

@@ -0,0 +1,209 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Sections;
using StructureHelperCommon.Models.Sections.Logics;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Buckling;
using StructureHelperLogics.Services.NdmPrimitives;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class ForceCalculatorLogic : IForceCalculatorLogic
{
private ForcesResults result;
private IProcessorLogic<IForceTuple> eccentricityLogic;
private ForceTupleBucklingLogic bucklingLogic;
private ITriangulatePrimitiveLogic triangulateLogic;
public ForceInputData InputData { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public Action<IResult> ActionToOutputResults { get; set; }
public ForceCalculatorLogic(ForceInputData inputData)
{
InputData = inputData;
}
public ForcesResults GetForcesResults()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
GetCombinations();
CalculateResult();
return result;
}
private void CalculateResult()
{
result = new ForcesResults()
{
IsValid = true
};
foreach (var combination in InputData.ForceCombinationLists)
{
foreach (var tuple in combination.DesignForces)
{
var limitState = tuple.LimitState;
var calcTerm = tuple.CalcTerm;
if (InputData.LimitStatesList.Contains(limitState) & InputData.CalcTermsList.Contains(calcTerm))
{
IForcesTupleResult tupleResult;
try
{
tupleResult = ProcessNdmResult(combination, tuple);
}
catch (Exception ex)
{
tupleResult = new ForcesTupleResult()
{
IsValid = false,
Description = string.Empty + ex,
DesignForceTuple = tuple
};
}
result.ForcesResultList.Add(tupleResult);
ActionToOutputResults?.Invoke(result);
}
}
}
}
private IForcesTupleResult ProcessNdmResult(IForceCombinationList combination, IDesignForceTuple tuple)
{
IForcesTupleResult tupleResult;
LimitStates limitState = tuple.LimitState;
CalcTerms calcTerm = tuple.CalcTerm;
triangulateLogic = new TriangulatePrimitiveLogic()
{
Primitives = InputData.Primitives,
LimitState = limitState,
CalcTerm = calcTerm,
TraceLogger = TraceLogger
};
var ndms = triangulateLogic.GetNdms();
IPoint2D point2D;
IProcessorLogic<IForceTuple> forcelogic = new ForceTupleCopier(tuple.ForceTuple);
if (combination.SetInGravityCenter == true)
{
var (Cx, Cy) = LoaderCalculator.Logics.Geometry.GeometryOperations.GetGravityCenter(ndms);
point2D = new Point2D() { X = Cx, Y = Cy };
forcelogic = new ForceTupleMoveToPointDecorator(forcelogic) { Point2D = point2D };
}
var newTuple = forcelogic.GetValue();
TraceLogger?.AddMessage("Input force combination");
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple));
if (InputData.CompressedMember.Buckling == true)
{
if (newTuple.Nz >= 0d)
{
TraceLogger?.AddMessage(string.Format("Second order effect is not considered as Nz={0} >= 0", newTuple.Nz));
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
}
else
{
tupleResult = ProcessCompressedMember(combination, tuple, ndms, newTuple);
}
}
else
{
if (newTuple.Nz < 0d)
{
string message = string.Format("Second order effect is not considered, despite force Nz={0}", newTuple.Nz);
TraceLogger?.AddMessage(message, TraceLogStatuses.Warning);
}
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
}
return tupleResult;
}
private IForcesTupleResult ProcessCompressedMember(IForceCombinationList combination, IDesignForceTuple tuple, List<INdm> ndms, IForceTuple newTuple)
{
IForcesTupleResult tupleResult;
LimitStates limitState = tuple.LimitState;
CalcTerms calcTerm = tuple.CalcTerm;
TraceLogger?.AddMessage("Get eccentricity for full load");
eccentricityLogic = new ProcessEccentricity(InputData.CompressedMember, ndms, newTuple)
{
TraceLogger = TraceLogger ?? null
};
newTuple = eccentricityLogic.GetValue();
var buclingInputData = new BucklingInputData()
{
Combination = combination,
LimitState = limitState,
CalcTerm = calcTerm,
Ndms = ndms,
ForceTuple = newTuple
};
bucklingLogic = new ForceTupleBucklingLogic(buclingInputData)
{
CompressedMember = InputData.CompressedMember,
Accuracy = InputData.Accuracy,
Primitives = InputData.Primitives,
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
};
var buckResult = bucklingLogic.GetForceTupleByBuckling();
if (buckResult.IsValid == true)
{
newTuple = buckResult.Value;
}
else
{
return new ForcesTupleResult()
{
IsValid = false,
DesignForceTuple = tuple,
Description = buckResult.Description,
};
}
string message = string.Intern("Result of second order was obtained succesfully, new force combination was obtained");
TraceLogger?.AddMessage(message);
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
return tupleResult;
}
private IForcesTupleResult GetForceResult(LimitStates limitState, CalcTerms calcTerm, List<INdm> ndms, IForceTuple newTuple)
{
TraceLogger?.AddMessage("Calculation of cross-section is started");
var tupleResult = GetPrimitiveStrainMatrix(ndms, newTuple, InputData.Accuracy);
tupleResult.DesignForceTuple.LimitState = limitState;
tupleResult.DesignForceTuple.CalcTerm = calcTerm;
tupleResult.DesignForceTuple.ForceTuple = newTuple;
return tupleResult;
}
private void GetCombinations()
{
InputData.ForceCombinationLists = new List<IForceCombinationList>();
foreach (var item in InputData.ForceActions)
{
InputData.ForceCombinationLists.Add(item.GetCombinations());
}
}
private IForcesTupleResult GetPrimitiveStrainMatrix(IEnumerable<INdm> ndmCollection, IForceTuple tuple, IAccuracy accuracy)
{
var inputData = new ForceTupleInputData()
{
NdmCollection = ndmCollection,
Tuple = tuple,
Accuracy = accuracy
};
var calculator = new ForceTupleCalculator();
calculator.InputData = inputData;
if (TraceLogger is not null)
{
calculator.TraceLogger = TraceLogger.GetSimilarTraceLogger();
}
calculator.Run();
return calculator.Result as IForcesTupleResult;
}
}
}

View File

@@ -1,6 +1,10 @@
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Sections;
using StructureHelperLogics.Models.Calculations.CalculationProperties; using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.NdmCalculations.Primitives;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -9,11 +13,40 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
public class ForceInputData : IForceInputData public class ForceInputData : IInputData, IHasPrimitives, IHasForceCombinations
{ {
public IEnumerable<IForceCombinationList> ForceCombinationLists { get; set; } public List<LimitStates> LimitStatesList { get; private set; }
public IEnumerable<LimitStates> LimitStates { get; set; } public List<CalcTerms> CalcTermsList { get; private set; }
public IEnumerable<CalcTerms> CalcTerms { get; set; } public List<IForceAction> ForceActions { get; private set; }
public IIterationProperty IterationProperty { get; } public List<INdmPrimitive> Primitives { get; private set; }
public ICompressedMember CompressedMember { get; set; }
public IAccuracy Accuracy { get; set; }
public List<IForceCombinationList> ForceCombinationLists { get; set; }
public ForceInputData()
{
ForceActions = new List<IForceAction>();
ForceCombinationLists = new List<IForceCombinationList>();
Primitives = new List<INdmPrimitive>();
CompressedMember = new CompressedMember()
{
Buckling = false
};
Accuracy = new Accuracy()
{
IterationAccuracy = 0.001d,
MaxIterationCount = 1000
};
LimitStatesList = new List<LimitStates>()
{
LimitStates.ULS,
LimitStates.SLS
};
CalcTermsList = new List<CalcTerms>()
{
CalcTerms.ShortTerm,
CalcTerms.LongTerm
};
}
} }
} }

View File

@@ -1,18 +0,0 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Sections;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public interface IForceCalculator : ICalculator, IHasPrimitives, IHasForceCombinations
{
List<CalcTerms> CalcTermsList { get; }
List<LimitStates> LimitStatesList { get; }
ICompressedMember CompressedMember { get; }
IAccuracy Accuracy { get; set; }
List<IForceCombinationList> ForceCombinationLists { get;}
}
}

View File

@@ -0,0 +1,16 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public interface IForceCalculatorLogic : ILogic, IHasActionByResult
{
ForceInputData InputData { get; set; }
ForcesResults GetForcesResults();
}
}

View File

@@ -1,15 +0,0 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using System.Collections.Generic;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public interface IForceInputData
{
IEnumerable<CalcTerms> CalcTerms { get; set; }
IEnumerable<IForceCombinationList> ForceCombinationLists { get; set; }
IIterationProperty IterationProperty { get; }
IEnumerable<LimitStates> LimitStates { get; set; }
}
}

View File

@@ -4,24 +4,20 @@ using StructureHelperCommon.Models.Sections;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{ {
public class ForceCalculatorUpdateStrategy : IUpdateStrategy<IForceCalculator> public class ForceCalculatorUpdateStrategy : IUpdateStrategy<ForceCalculator>
{ {
static readonly AccuracyUpdateStrategy accuracyUpdateStrategy = new(); private readonly IUpdateStrategy<ForceInputData> inputDataUpdateStrategy;
static readonly CompressedMemberUpdateStrategy compressedMemberUpdateStrategy = new(); public ForceCalculatorUpdateStrategy(IUpdateStrategy<ForceInputData> inputDataUpdateStrategy)
public void Update(IForceCalculator targetObject, IForceCalculator sourceObject) {
this.inputDataUpdateStrategy = inputDataUpdateStrategy;
}
public ForceCalculatorUpdateStrategy() : this(new ForceCalculatorInputDataUpdateStrategy()) { }
public void Update(ForceCalculator targetObject, ForceCalculator sourceObject)
{ {
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name; targetObject.Name = sourceObject.Name;
targetObject.LimitStatesList.Clear(); targetObject.InputData ??= new ForceInputData();
targetObject.LimitStatesList.AddRange(sourceObject.LimitStatesList); inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);
targetObject.CalcTermsList.Clear();
targetObject.CalcTermsList.AddRange(sourceObject.CalcTermsList);
accuracyUpdateStrategy.Update(targetObject.Accuracy, sourceObject.Accuracy);
compressedMemberUpdateStrategy.Update(targetObject.CompressedMember, sourceObject.CompressedMember);
targetObject.Primitives.Clear();
targetObject.Primitives.AddRange(sourceObject.Primitives);
targetObject.ForceActions.Clear();
targetObject.ForceActions.AddRange(sourceObject.ForceActions);
} }
} }
} }

View File

@@ -21,9 +21,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Logics
{ {
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
CheckObject.CompareTypes(targetObject, sourceObject); CheckObject.CompareTypes(targetObject, sourceObject);
if (targetObject is IForceCalculator target) if (targetObject is ForceCalculator target)
{ {
new ForceCalculatorUpdateStrategy().Update(target, (IForceCalculator)sourceObject); new ForceCalculatorUpdateStrategy().Update(target, (ForceCalculator)sourceObject);
} }
else if (targetObject is LimitCurvesCalculator limitCurves) else if (targetObject is LimitCurvesCalculator limitCurves)
{ {

View File

@@ -10,31 +10,23 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
public class CheckTupleCalculatorInputData : ICheckInputDataLogic public class CheckTupleCalculatorInputData : ICheckInputDataLogic<TupleCrackInputData>
{ {
private string checkResult; private string checkResult;
private TupleCrackInputData inputData;
private bool result; private bool result;
public IInputData InputData public TupleCrackInputData InputData { get; set; }
{
get => inputData; set
{
if (value is TupleCrackInputData data)
{
inputData = data;
}
else
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
}
}
}
public string CheckResult => checkResult; public string CheckResult => checkResult;
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public CheckTupleCalculatorInputData(TupleCrackInputData inputData)
{
InputData = inputData;
}
public bool Check() public bool Check()
{ {
result = true; result = true;

View File

@@ -23,19 +23,22 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
private CrackResult result; private CrackResult result;
private IGetTupleInputDatasLogic datasLogic; private IGetTupleInputDatasLogic datasLogic;
private CrackCalculatorUpdateStrategy updateStrategy = new(); private CrackCalculatorUpdateStrategy updateStrategy = new();
private ICheckInputDataLogic checkInputDataLogic; private ICheckInputDataLogic<CrackInputData> checkInputDataLogic;
public string Name { get; set; } public string Name { get; set; }
public CrackInputData InputData { get; set; } public CrackInputData InputData { get; set; }
public IResult Result => result; public IResult Result => result;
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public CrackCalculator(CrackInputData inputData, ICheckInputDataLogic checkInputDataLogic) public CrackCalculator(CrackInputData inputData, ICheckInputDataLogic<CrackInputData> checkInputDataLogic)
{ {
InputData = inputData; InputData = inputData;
this.checkInputDataLogic = checkInputDataLogic; this.checkInputDataLogic = checkInputDataLogic;
Name = string.Empty;
} }
public CrackCalculator(CrackInputData inputData) : this(inputData, new CheckCrackCalculatorInputDataLogic(inputData)) { }
public object Clone() public object Clone()
{ {
CrackInputData crackInputData = new CrackInputData(); CrackInputData crackInputData = new CrackInputData();

View File

@@ -10,7 +10,13 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
public class CrackCalculatorUpdateStrategy : IUpdateStrategy<CrackCalculator> public class CrackCalculatorUpdateStrategy : IUpdateStrategy<CrackCalculator>
{ {
private CrackInputDataUpdateStrategy crackInputDataUpdateStrategy => new(); private IUpdateStrategy<CrackInputData> inputDataUpdateStrategy;
public CrackCalculatorUpdateStrategy(IUpdateStrategy<CrackInputData> inputDataUpdateStrategy)
{
this.inputDataUpdateStrategy = inputDataUpdateStrategy;
}
public CrackCalculatorUpdateStrategy() : this(new CrackInputDataUpdateStrategy()) { }
public void Update(CrackCalculator targetObject, CrackCalculator sourceObject) public void Update(CrackCalculator targetObject, CrackCalculator sourceObject)
{ {
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
@@ -18,7 +24,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
targetObject.Name = sourceObject.Name; targetObject.Name = sourceObject.Name;
targetObject.InputData ??= new(); targetObject.InputData ??= new();
crackInputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData); inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);
} }
} }
} }

View File

@@ -16,7 +16,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public List<INdmPrimitive> Primitives { get; private set; } public List<INdmPrimitive> Primitives { get; private set; }
/// <inheritdoc/> /// <inheritdoc/>
public List<IForceAction> ForceActions { get; private set; } public List<IForceAction> ForceActions { get; private set; }
public UserCrackInputData UserCrackInputData { get; private set; } public UserCrackInputData UserCrackInputData { get; set; }
public CrackInputData() public CrackInputData()
{ {
Primitives = new(); Primitives = new();

View File

@@ -10,7 +10,16 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
public class CrackInputDataUpdateStrategy : IUpdateStrategy<CrackInputData> public class CrackInputDataUpdateStrategy : IUpdateStrategy<CrackInputData>
{ {
private UserCrackInputDataUpdateStrategy userCrackInputDataUpdateStrategy => new(); private IUpdateStrategy<UserCrackInputData> userCrackInputDataUpdateStrategy;
public CrackInputDataUpdateStrategy(IUpdateStrategy<UserCrackInputData> userCrackInputDataUpdateStrategy)
{
this.userCrackInputDataUpdateStrategy = userCrackInputDataUpdateStrategy;
}
public CrackInputDataUpdateStrategy() : this(new UserCrackInputDataUpdateStrategy())
{
}
public void Update(CrackInputData targetObject, CrackInputData sourceObject) public void Update(CrackInputData targetObject, CrackInputData sourceObject)
{ {
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
@@ -19,7 +28,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
targetObject.ForceActions.AddRange(sourceObject.ForceActions); targetObject.ForceActions.AddRange(sourceObject.ForceActions);
targetObject.Primitives.Clear(); targetObject.Primitives.Clear();
targetObject.Primitives.AddRange(sourceObject.Primitives); targetObject.Primitives.AddRange(sourceObject.Primitives);
targetObject.UserCrackInputData ??= new UserCrackInputData();
userCrackInputDataUpdateStrategy.Update(targetObject.UserCrackInputData, sourceObject.UserCrackInputData); userCrackInputDataUpdateStrategy.Update(targetObject.UserCrackInputData, sourceObject.UserCrackInputData);
} }
} }

View File

@@ -13,6 +13,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
/// <inheritdoc/>
public class CrackedSectionTriangulationLogic : ICrackedSectionTriangulationLogic public class CrackedSectionTriangulationLogic : ICrackedSectionTriangulationLogic
{ {
const LimitStates limitState = LimitStates.SLS; const LimitStates limitState = LimitStates.SLS;
@@ -35,6 +36,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50) TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
}; };
} }
/// <inheritdoc/>
public List<INdm> GetNdmCollection() public List<INdm> GetNdmCollection()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
@@ -48,6 +50,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
}; };
return triangulateLogic.GetNdms(); return triangulateLogic.GetNdms();
} }
/// <inheritdoc/>
public List<INdm> GetCrackedNdmCollection() public List<INdm> GetCrackedNdmCollection()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
@@ -62,6 +65,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
return triangulateLogic.GetNdms(); return triangulateLogic.GetNdms();
} }
/// <inheritdoc/>
public List<RebarPrimitive> GetRebarPrimitives() public List<RebarPrimitive> GetRebarPrimitives()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
@@ -79,6 +83,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
return rebarPrimitives; return rebarPrimitives;
} }
/// <inheritdoc/>
public List<INdm> GetElasticNdmCollection() public List<INdm> GetElasticNdmCollection()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);

View File

@@ -79,6 +79,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
} }
catch (Exception ex) catch (Exception ex)
{ {
TraceLogger?.AddMessage($"Error of crack width calculation {ex}", TraceLogStatuses.Error);
result.IsValid = false; result.IsValid = false;
result.Description += "\n" + ex; result.Description += "\n" + ex;
} }

View File

@@ -9,6 +9,7 @@ using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Services.Forces; using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services.NdmPrimitives; using StructureHelperLogics.Services.NdmPrimitives;
//Copyright (c) 2024 Redikultsev Evgeny, Ekaterinburg, Russia //Copyright (c) 2024 Redikultsev Evgeny, Ekaterinburg, Russia
@@ -18,6 +19,8 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
public class TupleCrackCalculator : ICalculator public class TupleCrackCalculator : ICalculator
{ {
private const CalcTerms crackingTerm = CalcTerms.ShortTerm;
private const LimitStates crackingLimitState = LimitStates.SLS;
private static readonly ILengthBetweenCracksLogic lengthLogic = new LengthBetweenCracksLogicSP63(); private static readonly ILengthBetweenCracksLogic lengthLogic = new LengthBetweenCracksLogicSP63();
private TupleCrackResult result; private TupleCrackResult result;
private ICrackedSectionTriangulationLogic triangulationLogic; private ICrackedSectionTriangulationLogic triangulationLogic;
@@ -143,6 +146,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
IEnumerable<INdm> crackableNdmsLoc = null; IEnumerable<INdm> crackableNdmsLoc = null;
IEnumerable<INdm> crackedNdmsLoc = null; IEnumerable<INdm> crackedNdmsLoc = null;
INdm concreteNdmUnderRebar;
RebarPrimitive rebarCopy = null; RebarPrimitive rebarCopy = null;
lock (locker) lock (locker)
{ {
@@ -151,6 +155,11 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
var triangulationLogicLoc = new CrackedSectionTriangulationLogic(InputData.Primitives); var triangulationLogicLoc = new CrackedSectionTriangulationLogic(InputData.Primitives);
crackableNdmsLoc = triangulationLogicLoc.GetNdmCollection(); crackableNdmsLoc = triangulationLogicLoc.GetNdmCollection();
crackedNdmsLoc = triangulationLogicLoc.GetCrackedNdmCollection(); crackedNdmsLoc = triangulationLogicLoc.GetCrackedNdmCollection();
//concreteNdmUnderRebar = rebarCopy.GetConcreteNdm(new TriangulationOptions()
//{ CalcTerm = crackingTerm,
// LimiteState = crackingLimitState });
//concreteNdmUnderRebar.StressScale = 1d;
//crackableNdmsLoc = new List<INdm>() { concreteNdmUnderRebar};
} }
var longRebarData = new RebarCrackInputData() var longRebarData = new RebarCrackInputData()
@@ -162,7 +171,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
}; };
var shortRebarData = new RebarCrackInputData() var shortRebarData = new RebarCrackInputData()
{ {
CrackableNdmCollection = crackableNdms, CrackableNdmCollection = crackableNdmsLoc,
CrackedNdmCollection = crackedNdms, CrackedNdmCollection = crackedNdms,
ForceTuple = InputData.ShortTermTuple.Clone() as ForceTuple, ForceTuple = InputData.ShortTermTuple.Clone() as ForceTuple,
Length = shortLength Length = shortLength

View File

@@ -8,17 +8,17 @@ namespace StructureHelperLogics.Services.NdmCalculations
public static class InterpolateService public static class InterpolateService
{ {
static readonly CompressedMemberUpdateStrategy compressedMemberUpdateStrategy = new(); static readonly CompressedMemberUpdateStrategy compressedMemberUpdateStrategy = new();
public static ForceCalculator InterpolateForceCalculator(IForceCalculator source, InterpolateTuplesResult interpolateTuplesResult) public static ForceCalculator InterpolateForceCalculator(ForceCalculator source, InterpolateTuplesResult interpolateTuplesResult)
{ {
ForceCalculator calculator = new ForceCalculator(); ForceCalculator calculator = new ForceCalculator();
calculator.LimitStatesList.Clear(); calculator.InputData.LimitStatesList.Clear();
calculator.LimitStatesList.Add(interpolateTuplesResult.StartTuple.LimitState); calculator.InputData.LimitStatesList.Add(interpolateTuplesResult.StartTuple.LimitState);
calculator.CalcTermsList.Clear(); calculator.InputData.CalcTermsList.Clear();
calculator.CalcTermsList.Add(interpolateTuplesResult.FinishTuple.CalcTerm); calculator.InputData.CalcTermsList.Add(interpolateTuplesResult.FinishTuple.CalcTerm);
compressedMemberUpdateStrategy.Update(calculator.CompressedMember, source.CompressedMember); compressedMemberUpdateStrategy.Update(calculator.InputData.CompressedMember, source.InputData.CompressedMember);
calculator.Accuracy = source.Accuracy; calculator.InputData.Accuracy = source.InputData.Accuracy;
calculator.Primitives.AddRange(source.Primitives); calculator.InputData.Primitives.AddRange(source.InputData.Primitives);
calculator.ForceActions.Clear(); calculator.InputData.ForceActions.Clear();
var forceTuples = ForceTupleService.InterpolateDesignTuple(interpolateTuplesResult.FinishTuple, interpolateTuplesResult.StartTuple, interpolateTuplesResult.StepCount); var forceTuples = ForceTupleService.InterpolateDesignTuple(interpolateTuplesResult.FinishTuple, interpolateTuplesResult.StartTuple, interpolateTuplesResult.StepCount);
foreach (var forceTuple in forceTuples) foreach (var forceTuple in forceTuples)
{ {
@@ -31,12 +31,12 @@ namespace StructureHelperLogics.Services.NdmCalculations
combination.DesignForces.Add(forceTuple); combination.DesignForces.Add(forceTuple);
combination.ForcePoint.X = 0; combination.ForcePoint.X = 0;
combination.ForcePoint.Y = 0; combination.ForcePoint.Y = 0;
calculator.ForceActions.Add(combination); calculator.InputData.ForceActions.Add(combination);
} }
return calculator; return calculator;
} }
public static IForceCalculator InterpolateForceCalculator(IForceCalculator forceCalculator, IDesignForceTuple finishDesignTuple, object startDesignTuple, object stepCount) public static ForceCalculator InterpolateForceCalculator(ForceCalculator forceCalculator, IDesignForceTuple finishDesignTuple, object startDesignTuple, object stepCount)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -23,8 +23,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
HeightCount = heightCount HeightCount = heightCount
}; };
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var calculator = newSection.SectionRepository.CalculatorsList[0] as IForceCalculator; var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator;
calculator.CompressedMember.Buckling = isBuckling; calculator.InputData.CompressedMember.Buckling = isBuckling;
//Act //Act
calculator.Run(); calculator.Run();
var result = calculator.Result as IForcesResults; var result = calculator.Result as IForcesResults;
@@ -48,8 +48,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
//Arrange //Arrange
var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount };
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var calculator = newSection.SectionRepository.CalculatorsList[0] as IForceCalculator; var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator;
calculator.CompressedMember.Buckling = isBuckling; calculator.InputData.CompressedMember.Buckling = isBuckling;
//Act //Act
calculator.Run(); calculator.Run();
var result = calculator.Result as IForcesResults; var result = calculator.Result as IForcesResults;
@@ -65,8 +65,8 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
//Arrange //Arrange
var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount };
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var calculator = newSection.SectionRepository.CalculatorsList[0] as IForceCalculator; var calculator = newSection.SectionRepository.CalculatorsList[0] as ForceCalculator;
calculator.CompressedMember.Buckling = false; calculator.InputData.CompressedMember.Buckling = false;
calculator.Run(); calculator.Run();
var ndmPrimitives = newSection.SectionRepository.Primitives; var ndmPrimitives = newSection.SectionRepository.Primitives;
var result = calculator.Result as IForcesResults; var result = calculator.Result as IForcesResults;