Tests of crack calculator were added
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
@@ -10,10 +11,9 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
public class RebarCrackCalculator : IRebarCrackCalculator
|
||||
{
|
||||
private ICrackSofteningLogic crackSofteningLogic;
|
||||
private ICrackWidthLogic crackWidthLogic = new CrackWidthLogicSP63();
|
||||
private ICrackWidthCalculationLogic crackWidthCalculationLogic;
|
||||
private RebarCrackResult result;
|
||||
private RebarStressResult rebarStressResult;
|
||||
private ICheckInputDataLogic<IRebarCrackCalculatorInputData> checkInputDataLogic;
|
||||
|
||||
public string Name { get; set; }
|
||||
public RebarCrackCalculatorInputData InputData { get; set; }
|
||||
@@ -22,139 +22,89 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
public Action<IResult> ActionToOutputResults { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
public RebarCrackCalculator(ICheckInputDataLogic<IRebarCrackCalculatorInputData> checkInputDataLogic,
|
||||
ICrackWidthCalculationLogic crackWidthCalculationLogic,
|
||||
IShiftTraceLogger? traceLogger)
|
||||
{
|
||||
this.checkInputDataLogic = checkInputDataLogic;
|
||||
this.crackWidthCalculationLogic = crackWidthCalculationLogic;
|
||||
this.TraceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public RebarCrackCalculator()
|
||||
: this(new CheckRebarCrackCalculatorInputDataLogic(),
|
||||
new CrackWidthCalculationLogic(),
|
||||
null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Debug);
|
||||
result = new()
|
||||
{
|
||||
IsValid = true
|
||||
};
|
||||
TraceLogger?.AddMessage($"Rebar primitive {InputData.RebarPrimitive.Name}");
|
||||
PrepareNewResult();
|
||||
if (CheckInputData() != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//double acrc1 = GetCrackWidth()
|
||||
|
||||
|
||||
crackWidthLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
|
||||
try
|
||||
{
|
||||
GetSofteningLogic(InputData.LongRebarData);
|
||||
rebarStressResult = GetRebarStressResult(InputData.LongRebarData);
|
||||
var dataAcrc1 = GetCrackWidthInputData(InputData.LongRebarData, CalcTerms.LongTerm);
|
||||
var dataAcrc3 = GetCrackWidthInputData(InputData.LongRebarData, CalcTerms.ShortTerm);
|
||||
crackWidthLogic.InputData = dataAcrc1;
|
||||
var acrc1 = crackWidthLogic.GetCrackWidth();
|
||||
var longRebarResult = new CrackWidthRebarTupleResult()
|
||||
{
|
||||
CrackWidth = acrc1,
|
||||
UltimateCrackWidth = InputData.UserCrackInputData.UltimateLongCrackWidth,
|
||||
RebarStressResult = rebarStressResult,
|
||||
SofteningFactor = crackSofteningLogic.GetSofteningFactor()
|
||||
};
|
||||
TraceLogger?.AddMessage($"Long crack width acrc = acrc,1 = {acrc1}(m)");
|
||||
TraceLogger?.AddMessage($"Ultimate long crack width acrc,ult = {longRebarResult.UltimateCrackWidth}(m)");
|
||||
TraceCrackResult(longRebarResult);
|
||||
|
||||
|
||||
GetSofteningLogic(InputData.ShortRebarData);
|
||||
rebarStressResult = GetRebarStressResult(InputData.ShortRebarData);
|
||||
var dataAcrc2 = GetCrackWidthInputData(InputData.ShortRebarData, CalcTerms.ShortTerm);
|
||||
|
||||
crackWidthLogic.InputData = dataAcrc3;
|
||||
var acrc3 = crackWidthLogic.GetCrackWidth();
|
||||
crackWidthLogic.InputData = dataAcrc2;
|
||||
var acrc2 = crackWidthLogic.GetCrackWidth();
|
||||
|
||||
double acrcShort = acrc1 + acrc2 - acrc3;
|
||||
TraceLogger?.AddMessage($"Short crack width acrc = acrc,1 + acrc,2 - acrc,3 = {acrc1} + {acrc2} - {acrc3} = {acrcShort}(m)");
|
||||
var shortRebarResult = new CrackWidthRebarTupleResult()
|
||||
{
|
||||
CrackWidth = acrcShort,
|
||||
UltimateCrackWidth = InputData.UserCrackInputData.UltimateShortCrackWidth,
|
||||
RebarStressResult = rebarStressResult,
|
||||
SofteningFactor = crackSofteningLogic.GetSofteningFactor()
|
||||
};
|
||||
TraceCrackResult(shortRebarResult);
|
||||
result.LongTermResult = longRebarResult;
|
||||
result.ShortTermResult = shortRebarResult;
|
||||
ProcessCrackWidthCalculation();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Error of crack width calculation {ex}", TraceLogStatuses.Error);
|
||||
result.IsValid = false;
|
||||
result.Description += "\n" + ex;
|
||||
ProcessIncorrectCalculation(ex);
|
||||
}
|
||||
result.RebarPrimitive = InputData.RebarPrimitive;
|
||||
}
|
||||
|
||||
private void TraceCrackResult(CrackWidthRebarTupleResult rebarResult)
|
||||
private bool CheckInputData()
|
||||
{
|
||||
if (rebarResult.IsCrackLessThanUltimate == false)
|
||||
checkInputDataLogic.InputData = InputData;
|
||||
checkInputDataLogic.TraceLogger = TraceLogger;
|
||||
if (checkInputDataLogic.Check() == true)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Checking crack width is failure, actual crack width acrc = {rebarResult.CrackWidth} > ultimate crack width acrc,ult = {rebarResult.UltimateCrackWidth}", TraceLogStatuses.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceLogger?.AddMessage($"Checking crack width is ok, actual crack width acrc = {rebarResult.CrackWidth} <= ultimate crack width acrc,ult = {rebarResult.UltimateCrackWidth}");
|
||||
return true;
|
||||
}
|
||||
result.IsValid = false;
|
||||
result.Description += checkInputDataLogic.CheckResult;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void GetSofteningLogic(RebarCrackInputData rebarData)
|
||||
private void ProcessIncorrectCalculation(Exception ex)
|
||||
{
|
||||
if (InputData.UserCrackInputData.SetSofteningFactor == true)
|
||||
{
|
||||
crackSofteningLogic = new StabSoftetingLogic(InputData.UserCrackInputData.SofteningFactor)
|
||||
{
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
crackSofteningLogic = new RebarStressSofteningLogic()
|
||||
{
|
||||
RebarPrimitive = InputData.RebarPrimitive,
|
||||
InputData = rebarData,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
};
|
||||
}
|
||||
TraceLogger?.AddMessage($"Error of crack width calculation {ex}", TraceLogStatuses.Error);
|
||||
result.IsValid = false;
|
||||
result.Description += "\n" + ex;
|
||||
}
|
||||
|
||||
private ICrackWidthLogicInputData GetCrackWidthInputData(RebarCrackInputData inputData, CalcTerms calcTerm)
|
||||
private void ProcessCrackWidthCalculation()
|
||||
{
|
||||
|
||||
var factoryInputData = new CrackWidthLogicInputDataFactory(crackSofteningLogic)
|
||||
crackWidthCalculationLogic.TraceLogger = TraceLogger;
|
||||
crackWidthCalculationLogic.InputData = InputData;
|
||||
crackWidthCalculationLogic.Run();
|
||||
if (crackWidthCalculationLogic.Result.IsValid == true)
|
||||
{
|
||||
CalcTerm = calcTerm,
|
||||
InputData = inputData,
|
||||
RebarStrain = rebarStressResult.RebarStrain,
|
||||
ConcreteStrain = rebarStressResult.ConcreteStrain,
|
||||
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
|
||||
result = crackWidthCalculationLogic.Result;
|
||||
return;
|
||||
}
|
||||
result.IsValid = false;
|
||||
result.Description += crackWidthCalculationLogic.Result.Description;
|
||||
}
|
||||
|
||||
private void PrepareNewResult()
|
||||
{
|
||||
result = new()
|
||||
{
|
||||
IsValid = true,
|
||||
Description = string.Empty,
|
||||
};
|
||||
var crackWidthInputData = factoryInputData.GetCrackWidthLogicInputData();
|
||||
return crackWidthInputData;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private RebarStressResult GetRebarStressResult(RebarCrackInputData inputData)
|
||||
{
|
||||
var calculator = new RebarStressCalculator()
|
||||
{
|
||||
ForceTuple = inputData.ForceTuple,
|
||||
NdmCollection = inputData.CrackedNdmCollection,
|
||||
RebarPrimitive = InputData.RebarPrimitive
|
||||
};
|
||||
calculator.Run();
|
||||
var result = calculator.Result as RebarStressResult;
|
||||
if (result.IsValid == false)
|
||||
{
|
||||
string errorString = LoggerStrings.CalculationError + result.Description;
|
||||
TraceLogger?.AddMessage($"Rebar name: {InputData.RebarPrimitive.Name}\n" + errorString, TraceLogStatuses.Error);
|
||||
throw new StructureHelperException(errorString);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user