Add curvature calculator
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||
{
|
||||
public class CalculatorViewModel : ViewModelBase
|
||||
{
|
||||
private ICalculator calcualtor;
|
||||
|
||||
public bool ShowTraceData
|
||||
{
|
||||
get => calcualtor.ShowTraceData;
|
||||
set
|
||||
{
|
||||
calcualtor.ShowTraceData = value;
|
||||
OnPropertyChanged(nameof(ShowTraceData));
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get => calcualtor.Name;
|
||||
set
|
||||
{
|
||||
calcualtor.Name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
|
||||
public CalculatorViewModel(ICalculator calcualtor)
|
||||
{
|
||||
this.calcualtor = calcualtor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||
static IGetUnitLogic unitLogic = new GetUnitLogic();
|
||||
static readonly CrackForceBynarySearchCalculator calculator = new();
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
private IUnit unitForce = unitLogic.GetUnit(UnitTypes.Force);
|
||||
private IUnit unitMoment = unitLogic.GetUnit(UnitTypes.Moment);
|
||||
private IUnit unitCurvature = unitLogic.GetUnit(UnitTypes.Curvature);
|
||||
|
||||
private List<IExtendedForceTupleCalculatorResult> ValidTupleList { get; set; }
|
||||
ArrayParameter<double> arrayParameter;
|
||||
@@ -67,11 +70,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||
{
|
||||
List<string> labels = GetCrackLabels();
|
||||
arrayParameter = new ArrayParameter<double>(ValidTupleList.Count(), labels);
|
||||
CalculateWithCrack(ValidTupleList,
|
||||
NdmPrimitives,
|
||||
unitLogic.GetUnit(UnitTypes.Force),
|
||||
unitLogic.GetUnit(UnitTypes.Moment),
|
||||
unitLogic.GetUnit(UnitTypes.Curvature));
|
||||
CalculateWithCrack(ValidTupleList, NdmPrimitives);
|
||||
}
|
||||
|
||||
public void ShowWindow()
|
||||
@@ -92,31 +91,19 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||
"Errors appeared during showing a graph, see detailed information");
|
||||
}
|
||||
|
||||
private void CalculateWithCrack(List<IExtendedForceTupleCalculatorResult> validTupleList, IEnumerable<INdmPrimitive> ndmPrimitives, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
|
||||
private void CalculateWithCrack(List<IExtendedForceTupleCalculatorResult> validTupleList, IEnumerable<INdmPrimitive> ndmPrimitives)
|
||||
{
|
||||
var data = arrayParameter.Data;
|
||||
for (int i = 0; i < validTupleList.Count(); i++)
|
||||
{
|
||||
var valueList = new List<double>
|
||||
{
|
||||
validTupleList[i].ForcesTupleResult.ForceTuple.Mx * unitMoment.Multiplyer,
|
||||
validTupleList[i].ForcesTupleResult.ForceTuple.My * unitMoment.Multiplyer,
|
||||
validTupleList[i].ForcesTupleResult.ForceTuple.Nz * unitForce.Multiplyer
|
||||
};
|
||||
calculator.InputData.EndTuple = validTupleList[i].ForcesTupleResult.ForceTuple;
|
||||
var limitState = validTupleList[i].StateCalcTermPair.LimitState;
|
||||
var calcTerm = validTupleList[i].StateCalcTermPair.CalcTerm;
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = limitState,
|
||||
CalcTerm = calcTerm,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
GetTriangulationLogic(ndmPrimitives, limitState, calcTerm);
|
||||
var ndms = triangulateLogic.GetNdms();
|
||||
calculator.InputData.CheckedNdmCollection = calculator.InputData.SectionNdmCollection = ndms;
|
||||
calculator.Run();
|
||||
var result = (CrackForceResult)calculator.Result;
|
||||
var result = (ICrackForceResult)calculator.Result;
|
||||
if (result.IsValid == false)
|
||||
{
|
||||
MessageBox.Show(
|
||||
@@ -126,29 +113,51 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
||||
MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
valueList.Add(result.CrackedStrainTuple.Mx);
|
||||
valueList.Add(result.CrackedStrainTuple.My);
|
||||
valueList.Add(result.CrackedStrainTuple.Nz);
|
||||
|
||||
valueList.Add(result.ReducedStrainTuple.Mx);
|
||||
valueList.Add(result.ReducedStrainTuple.My);
|
||||
valueList.Add(result.ReducedStrainTuple.Nz);
|
||||
|
||||
valueList.Add(result.SofteningFactors.Mx);
|
||||
valueList.Add(result.SofteningFactors.My);
|
||||
valueList.Add(result.SofteningFactors.Nz);
|
||||
|
||||
valueList.Add(result.PsiS);
|
||||
|
||||
IExtendedForceTupleCalculatorResult extendedForceTupleCalculatorResult = validTupleList[i];
|
||||
List<double> valueList = GetValueList(result, extendedForceTupleCalculatorResult);
|
||||
for (int j = 0; j < valueList.Count; j++)
|
||||
{
|
||||
data[i, j] = valueList[j];
|
||||
}
|
||||
|
||||
SetProgress?.Invoke(i);
|
||||
}
|
||||
}
|
||||
|
||||
private List<double> GetValueList(ICrackForceResult result, IExtendedForceTupleCalculatorResult extendedForceTupleCalculatorResult)
|
||||
{
|
||||
var valueList = new List<double>
|
||||
{
|
||||
extendedForceTupleCalculatorResult.ForcesTupleResult.ForceTuple.Mx * unitMoment.Multiplyer,
|
||||
extendedForceTupleCalculatorResult.ForcesTupleResult.ForceTuple.My * unitMoment.Multiplyer,
|
||||
extendedForceTupleCalculatorResult.ForcesTupleResult.ForceTuple.Nz * unitForce.Multiplyer
|
||||
};
|
||||
valueList.Add(result.CrackedStrainTuple.Mx);
|
||||
valueList.Add(result.CrackedStrainTuple.My);
|
||||
valueList.Add(result.CrackedStrainTuple.Nz);
|
||||
|
||||
valueList.Add(result.ReducedStrainTuple.Mx);
|
||||
valueList.Add(result.ReducedStrainTuple.My);
|
||||
valueList.Add(result.ReducedStrainTuple.Nz);
|
||||
|
||||
valueList.Add(result.SofteningFactors.Mx);
|
||||
valueList.Add(result.SofteningFactors.My);
|
||||
valueList.Add(result.SofteningFactors.Nz);
|
||||
|
||||
valueList.Add(result.PsiS);
|
||||
return valueList;
|
||||
}
|
||||
|
||||
private void GetTriangulationLogic(IEnumerable<INdmPrimitive> ndmPrimitives, LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = limitState,
|
||||
CalcTerm = calcTerm,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
}
|
||||
|
||||
private static List<string> GetCrackLabels()
|
||||
{
|
||||
const string crc = "Crc";
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.Curvatures
|
||||
{
|
||||
public class CurvatureCalculatorInputDataViewModel : ViewModelBase
|
||||
{
|
||||
private ICurvatureCalculatorInputData inputData;
|
||||
private double deflectionFactor;
|
||||
private double spanLength;
|
||||
|
||||
public double DeflectionFactor
|
||||
{
|
||||
get => inputData.DeflectionFactor;
|
||||
set
|
||||
{
|
||||
inputData.DeflectionFactor = Math.Max(value, 0.0);
|
||||
OnPropertyChanged(nameof(DeflectionFactor));
|
||||
}
|
||||
}
|
||||
|
||||
public double SpanLength
|
||||
{
|
||||
get => inputData.SpanLength;
|
||||
set
|
||||
{
|
||||
inputData.SpanLength = Math.Max(value, 0.0);
|
||||
OnPropertyChanged(nameof(SpanLength));
|
||||
}
|
||||
}
|
||||
|
||||
public SourceTargetVM<IForceAction> CombinationViewModel { get; }
|
||||
public SourceTargetVM<PrimitiveBase> PrimitivesViewModel { get; }
|
||||
|
||||
public CurvatureCalculatorInputDataViewModel(ICurvatureCalculatorInputData inputData, ICrossSectionRepository repository)
|
||||
{
|
||||
this.inputData = inputData;
|
||||
CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(repository.ForceActions, inputData.ForceActions);
|
||||
PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(repository.Primitives, inputData.Primitives);
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.Curvatures.CurvatureCalculatorView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.Curvatures"
|
||||
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
|
||||
d:DataContext="{d:DesignInstance local:CurvatureCalculatorViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Curvature Calculator" Height="250" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TabControl>
|
||||
<TabItem Header="Main">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Name"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding CalculatorViewModel.Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Show trace data"/>
|
||||
<CheckBox Grid.Column="1" Grid.Row="1" Margin="0,3" IsChecked="{Binding CalculatorViewModel.ShowTraceData}"/>
|
||||
<TextBlock Grid.Row="2" Text="Deflection factor"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding InputDataViewModel.DeflectionFactor, Converter={StaticResource PlainDouble}}"/>
|
||||
<TextBlock Grid.Row="3" Text="Span length"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding InputDataViewModel.SpanLength, Converter={StaticResource LengthConverter}}"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Forces">
|
||||
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding InputDataViewModel.CombinationViewModel}"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Primitives">
|
||||
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding InputDataViewModel.PrimitivesViewModel}"/>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.Curvatures
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для CurvatureCalculatorView.xaml
|
||||
/// </summary>
|
||||
public partial class CurvatureCalculatorView : Window
|
||||
{
|
||||
private CurvatureCalculatorViewModel viewModel;
|
||||
public CurvatureCalculatorView(CurvatureCalculatorViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
viewModel.ParentWindow = this;
|
||||
this.viewModel = viewModel;
|
||||
this.DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.Curvatures
|
||||
{
|
||||
public class CurvatureCalculatorViewModel : OkCancelViewModelBase
|
||||
{
|
||||
private ICurvatureCalculator curvatureCalculator;
|
||||
public CalculatorViewModel CalculatorViewModel { get; private set; }
|
||||
public CurvatureCalculatorInputDataViewModel InputDataViewModel { get; private set; }
|
||||
|
||||
public CurvatureCalculatorViewModel(ICurvatureCalculator calculator, ICrossSectionRepository repository)
|
||||
{
|
||||
this.curvatureCalculator = calculator;
|
||||
CalculatorViewModel = new CalculatorViewModel(calculator);
|
||||
InputDataViewModel = new(calculator.InputData, repository);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
InputDataViewModel.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagr
|
||||
public StateCalcTermPairViewModel StateCalcTermPairViewModel { get; }
|
||||
public ValueDiagramsViewModel ValueDiagramsViewModel { get; }
|
||||
|
||||
public ValueDiagramCalculatorInputDataViewModel(ICrossSectionRepository repository, IValueDiagramCalculatorInputData inputData)
|
||||
public ValueDiagramCalculatorInputDataViewModel(IValueDiagramCalculatorInputData inputData, ICrossSectionRepository repository)
|
||||
{
|
||||
this.inputData = inputData;
|
||||
this.repository = repository;
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Name"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Name}"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding CalculatorViewModel.Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Show trace data"/>
|
||||
<CheckBox Grid.Column="1" Grid.Row="1" Margin="0,3" IsChecked="{Binding ShowTraceData}"/>
|
||||
<CheckBox Grid.Column="1" Grid.Row="1" Margin="0,3" IsChecked="{Binding CalculatorViewModel.ShowTraceData}"/>
|
||||
<TextBlock Grid.Row="2" Text="Limit state"/>
|
||||
<ComboBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding InputDataViewModel.StateCalcTermPairViewModel.LimitStatesCollection}" SelectedItem="{Binding InputDataViewModel.StateCalcTermPairViewModel.LimitState}"/>
|
||||
<TextBlock Grid.Row="3" Text="Calc term"/>
|
||||
|
||||
@@ -7,31 +7,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagr
|
||||
public class ValueDiagramCalculatorViewModel : OkCancelViewModelBase
|
||||
{
|
||||
private IValueDiagramCalculator valueDiagramCalculator;
|
||||
|
||||
public bool ShowTraceData
|
||||
{
|
||||
get => valueDiagramCalculator.ShowTraceData;
|
||||
set
|
||||
{
|
||||
valueDiagramCalculator.ShowTraceData = value;
|
||||
OnPropertyChanged(nameof(ShowTraceData));
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get => valueDiagramCalculator.Name;
|
||||
set
|
||||
{
|
||||
valueDiagramCalculator.Name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
|
||||
public CalculatorViewModel CalculatorViewModel { get; private set; }
|
||||
public ValueDiagramCalculatorInputDataViewModel InputDataViewModel { get; set; }
|
||||
|
||||
public ValueDiagramCalculatorViewModel(ICrossSectionRepository repository, IValueDiagramCalculator valueDiagramCalculator)
|
||||
{
|
||||
this.valueDiagramCalculator = valueDiagramCalculator;
|
||||
InputDataViewModel = new(repository, valueDiagramCalculator.InputData);
|
||||
CalculatorViewModel = new(valueDiagramCalculator);
|
||||
InputDataViewModel = new(valueDiagramCalculator.InputData, repository);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
|
||||
Reference in New Issue
Block a user