CrackedCalculator and TriangulationLogic were changed
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackCalculator : ICalculator
|
||||
{
|
||||
const LimitStates limitState = LimitStates.SLS;
|
||||
const CalcTerms longTerm = CalcTerms.LongTerm;
|
||||
const CalcTerms shortTerm = CalcTerms.ShortTerm;
|
||||
|
||||
private CrackResult result;
|
||||
private IGetTupleInputDatasLogic datasLogic;
|
||||
private CrackCalculatorUpdateStrategy updateStrategy = new();
|
||||
|
||||
public string Name { get; set; }
|
||||
public CrackInputData InputData { get; set; }
|
||||
public IResult Result => result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public CrackCalculator(CrackInputData inputData)
|
||||
{
|
||||
InputData = inputData;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newItem = new CrackCalculator(new CrackInputData());
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
PrepareNewResult();
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
|
||||
try
|
||||
{
|
||||
ProcessCalculations();
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += ex;
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationError + ex, TraceLogStatuses.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessCalculations()
|
||||
{
|
||||
datasLogic = new GetTupleInputDatasLogic(InputData.Primitives, InputData.ForceActions)
|
||||
{
|
||||
LimitState = limitState,
|
||||
LongTerm = longTerm,
|
||||
ShortTerm = shortTerm,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
var datas = datasLogic.GetTupleInputDatas();
|
||||
foreach (var data in datas)
|
||||
{
|
||||
var calculator = new TupleCrackCalculator()
|
||||
{
|
||||
InputData = data,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
calculator.Run();
|
||||
var calcResult = calculator.Result as TupleCrackResult;
|
||||
result.TupleResults.Add(calcResult);
|
||||
}
|
||||
}
|
||||
|
||||
private void PrepareNewResult()
|
||||
{
|
||||
result = new CrackResult
|
||||
{
|
||||
IsValid = true,
|
||||
Description = string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackCalculatorUpdateStrategy : IUpdateStrategy<CrackCalculator>
|
||||
{
|
||||
private CrackInputDataUpdateStrategy inputDataUpdateStrategy => new();
|
||||
public void Update(CrackCalculator targetObject, CrackCalculator sourceObject)
|
||||
{
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.InputData ??= new();
|
||||
inputDataUpdateStrategy.Update(targetObject.InputData, sourceObject.InputData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackInputData : IInputData, IHasPrimitives, IHasForceCombinations
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public List<INdmPrimitive> Primitives { get; private set; }
|
||||
/// <inheritdoc/>
|
||||
public List<IForceAction> ForceActions { get; private set; }
|
||||
public CrackInputData()
|
||||
{
|
||||
Primitives = new();
|
||||
ForceActions = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackInputDataUpdateStrategy : IUpdateStrategy<CrackInputData>
|
||||
{
|
||||
public void Update(CrackInputData targetObject, CrackInputData sourceObject)
|
||||
{
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.ForceActions.Clear();
|
||||
targetObject.ForceActions.AddRange(sourceObject.ForceActions);
|
||||
targetObject.Primitives.Clear();
|
||||
targetObject.Primitives.AddRange(sourceObject.Primitives);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackResult : IResult
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public List<TupleCrackResult> TupleResults {get;set;}
|
||||
public CrackResult()
|
||||
{
|
||||
TupleResults = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class GetTupleInputDatasLogic : IGetTupleInputDatasLogic
|
||||
{
|
||||
public List<IForceAction> ForceActions { get; set; }
|
||||
public List<INdmPrimitive> Primitives { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms LongTerm { get; set; }
|
||||
public CalcTerms ShortTerm { get; set; }
|
||||
|
||||
public GetTupleInputDatasLogic(List<INdmPrimitive> primitives, List<IForceAction> forceActions)
|
||||
{
|
||||
Primitives = primitives;
|
||||
ForceActions = forceActions;
|
||||
}
|
||||
|
||||
public List<TupleCrackInputData> GetTupleInputDatas()
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
|
||||
|
||||
List<TupleCrackInputData> resultList = new();
|
||||
CheckInputData();
|
||||
foreach (var action in ForceActions)
|
||||
{
|
||||
var tuple = GetTuplesByActions(action);
|
||||
if (tuple.isValid == false)
|
||||
{
|
||||
resultList.Add(new TupleCrackInputData()
|
||||
{
|
||||
IsValid = false,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
resultList.Add(new TupleCrackInputData()
|
||||
{
|
||||
IsValid = true,
|
||||
LongTermTuple = tuple.LongTuple,
|
||||
ShortTermTuple = tuple.ShortTuple,
|
||||
NdmPrimitives = Primitives
|
||||
});
|
||||
}
|
||||
}
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private void CheckInputData()
|
||||
{
|
||||
if (ForceActions is null)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force action is null", TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": {nameof(ForceActions)} is null");
|
||||
}
|
||||
}
|
||||
|
||||
private (bool isValid, IForceTuple? LongTuple, IForceTuple? ShortTuple) GetTuplesByActions(IForceAction action)
|
||||
{
|
||||
IForceTuple longTuple, shortTuple;
|
||||
var combinations = action.GetCombinations().DesignForces;
|
||||
try
|
||||
{
|
||||
longTuple = GetTupleByCombination(combinations, LimitState, LongTerm);
|
||||
TraceLogger?.AddMessage("Long term force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(longTuple));
|
||||
shortTuple = GetTupleByCombination(combinations, LimitState, ShortTerm);
|
||||
TraceLogger?.AddMessage("Short term force combination");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(longTuple));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage("Force combination is not obtained: \n" + ex, TraceLogStatuses.Error);
|
||||
return (false, null, null);
|
||||
}
|
||||
return (true, longTuple, shortTuple);
|
||||
}
|
||||
|
||||
private static IForceTuple GetTupleByCombination(List<IDesignForceTuple> combinations, LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
return combinations
|
||||
.Where(x => x.LimitState == limitState & x.CalcTerm == calcTerm)
|
||||
.Single()
|
||||
.ForceTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public interface IGetTupleInputDatasLogic : ILogic, IHasPrimitives, IHasForceCombinations
|
||||
{
|
||||
LimitStates LimitState { get; set; }
|
||||
CalcTerms LongTerm { get; set; }
|
||||
CalcTerms ShortTerm { get; set; }
|
||||
List<TupleCrackInputData> GetTupleInputDatas();
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,10 @@ using StructureHelperCommon.Models.Calculators;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthSimpleCalculator : ICalculator
|
||||
public class RebarCrackCalculator : ICalculator
|
||||
{
|
||||
ICrackWidthLogic crackWidthLogic = new CrackWidthLogicSP63();
|
||||
CrackWidthSimpleCalculatorResult result;
|
||||
RebarCrackResult result;
|
||||
public string Name { get; set; }
|
||||
public ICrackWidthSimpleCalculatorInputData InputData { get; set; }
|
||||
public IResult Result => result;
|
||||
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthSimpleCalculatorInputData : ICrackWidthSimpleCalculatorInputData
|
||||
public class RebarCrackInputData : ICrackWidthSimpleCalculatorInputData
|
||||
{
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
public StrainTuple StrainTuple { get; set; }
|
||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthSimpleCalculatorResult : IResult
|
||||
public class RebarCrackResult : IResult
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
public string Description { get; set; }
|
||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Loggers;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
@@ -11,37 +12,54 @@ using StructureHelperLogics.Services.NdmPrimitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthCalculator : ICalculator
|
||||
public class TupleCrackCalculator : ICalculator
|
||||
{
|
||||
private static readonly ILengthBetweenCracksLogic lengthLogic = new LengthBetweenCracksLogicSP63();
|
||||
private CrackWidthCalculatorResult result;
|
||||
private TupleCrackResult result;
|
||||
private IEnumerable<INdmPrimitive> ndmPrimitives;
|
||||
private List<RebarPrimitive>? rebarPrimitives;
|
||||
private IEnumerable<INdm> ndmCollection;
|
||||
private IEnumerable<INdm> defaultNdm;
|
||||
private IEnumerable<INdm> fulyCrackedNdm;
|
||||
private CrackForceResult crackForceResult;
|
||||
private StrainTuple strainTuple;
|
||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||
|
||||
public string Name { get; set; }
|
||||
public CrackWidthCalculatorInputData InputData { get; set; }
|
||||
public TupleCrackInputData InputData { get; set; }
|
||||
public IResult Result => result;
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public void Run()
|
||||
{
|
||||
result = new() { IsValid = true, Description = ""};
|
||||
PrepareNewResult();
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
|
||||
|
||||
try
|
||||
{
|
||||
ProcessCalculations();
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.IsValid = false;
|
||||
result.Description += ex;
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculationError + ex, TraceLogStatuses.Error);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PrepareNewResult()
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
IsValid = true,
|
||||
Description = string.Empty
|
||||
};
|
||||
}
|
||||
|
||||
private void ProcessCalculations()
|
||||
{
|
||||
CheckInputData();
|
||||
@@ -49,12 +67,16 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
CalcStrainMatrix();
|
||||
CalcCrackForce();
|
||||
var crackInputData = GetCrackInputData();
|
||||
var calculator = new CrackWidthSimpleCalculator { InputData = crackInputData };
|
||||
var calculator = new RebarCrackCalculator
|
||||
{
|
||||
InputData = crackInputData,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
foreach (var item in rebarPrimitives)
|
||||
{
|
||||
crackInputData.RebarPrimitive = item;
|
||||
calculator.Run();
|
||||
var rebarResult = calculator.Result as CrackWidthSimpleCalculatorResult;
|
||||
var rebarResult = calculator.Result as RebarCrackResult;
|
||||
//if (crackForceResult.IsSectionCracked == false)
|
||||
//{
|
||||
// rebarResult.CrackWidth = 0d;
|
||||
@@ -65,19 +87,19 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
|
||||
private void CalcStrainMatrix()
|
||||
{
|
||||
IForceTupleInputData inputData = new ForceTupleInputData() { NdmCollection = ndmCollection, Tuple = InputData.LongTermTuple};
|
||||
IForceTupleInputData inputData = new ForceTupleInputData() { NdmCollection = defaultNdm, Tuple = InputData.LongTermTuple};
|
||||
IForceTupleCalculator calculator = new ForceTupleCalculator() { InputData = inputData };
|
||||
calculator.Run();
|
||||
var forceResult = calculator.Result as IForcesTupleResult;
|
||||
strainTuple = TupleConverter.ConvertToStrainTuple(forceResult.LoaderResults.StrainMatrix);
|
||||
}
|
||||
|
||||
private CrackWidthSimpleCalculatorInputData GetCrackInputData()
|
||||
private RebarCrackInputData GetCrackInputData()
|
||||
{
|
||||
lengthLogic.NdmCollection = ndmCollection;
|
||||
lengthLogic.NdmCollection = defaultNdm;
|
||||
lengthLogic.StrainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(strainTuple);
|
||||
var length = lengthLogic.GetLength();
|
||||
var crackInputData = new CrackWidthSimpleCalculatorInputData
|
||||
var crackInputData = new RebarCrackInputData
|
||||
{
|
||||
PsiSFactor = crackForceResult.PsiS,
|
||||
Length = length,
|
||||
@@ -97,14 +119,21 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
rebarPrimitives.Add(item as RebarPrimitive);
|
||||
}
|
||||
}
|
||||
ndmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitStates.SLS, CalcTerms.ShortTerm);
|
||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||
{
|
||||
Primitives = ndmPrimitives,
|
||||
LimitState = LimitStates.SLS,
|
||||
CalcTerm = CalcTerms.ShortTerm,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
defaultNdm = triangulateLogic.GetNdms();
|
||||
}
|
||||
|
||||
private void CalcCrackForce()
|
||||
{
|
||||
var calculator = new CrackForceCalculator();
|
||||
calculator.EndTuple = InputData.LongTermTuple;
|
||||
calculator.NdmCollection = ndmCollection;
|
||||
calculator.NdmCollection = defaultNdm;
|
||||
calculator.Run();
|
||||
crackForceResult = calculator.Result as CrackForceResult;
|
||||
}
|
||||
@@ -10,10 +10,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthCalculatorInputData : IInputData
|
||||
public class TupleCrackInputData : IInputData
|
||||
{
|
||||
public IForceTuple LongTermTuple { get; set; }
|
||||
public IForceTuple ShortTermTuple { get; set; }
|
||||
public List<INdmPrimitive> NdmPrimitives {get;set;}
|
||||
public bool IsValid { get; set; }
|
||||
public IForceTuple? LongTermTuple { get; set; }
|
||||
public IForceTuple? ShortTermTuple { get; set; }
|
||||
public List<INdmPrimitive>? NdmPrimitives {get;set;}
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class CrackWidthCalculatorResult : IResult
|
||||
public class TupleCrackResult : IResult
|
||||
{
|
||||
public bool IsValid { get; set; }
|
||||
public string Description { get; set; }
|
||||
public IForceTuple LongTermTuple { get; set; }
|
||||
public IForceTuple ShortTermTuple { get; set; }
|
||||
public bool IsCracked { get; set; }
|
||||
public List<CrackWidthSimpleCalculatorResult> RebarResults { get; set; }
|
||||
public List<RebarCrackResult> RebarResults { get; set; }
|
||||
public double MaxLongTermCrackWidth => IsCracked? RebarResults.Select(x => x.LongTermResult.CrackWidth).Max() : 0d;
|
||||
public double MaxShortTermCrackWidth => IsCracked? RebarResults.Select(x => x.ShortTermResult.CrackWidth).Max() : 0d;
|
||||
|
||||
public CrackWidthCalculatorResult()
|
||||
public TupleCrackResult()
|
||||
{
|
||||
RebarResults = new List<CrackWidthSimpleCalculatorResult>();
|
||||
RebarResults = new ();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user