Tuple crack calculator was changed

This commit is contained in:
Evgeny Redikultsev
2024-05-10 20:27:57 +05:00
parent e75521dc20
commit 871355e07b
29 changed files with 745 additions and 148 deletions

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials
{
public interface ICrackedMaterial
{
bool TensionForULS { get; set; }
bool TensionForSLS { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -7,10 +8,8 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Materials namespace StructureHelperLogics.Models.Materials
{ {
public interface IConcreteLibMaterial : ILibMaterial public interface IConcreteLibMaterial : ILibMaterial, ICrackedMaterial
{ {
bool TensionForULS { get; set; }
bool TensionForSLS { get; set; }
/// <summary> /// <summary>
/// Humidity of concrete /// Humidity of concrete
/// </summary> /// </summary>

View File

@@ -40,7 +40,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
var checkResult = CheckInputData(); var checkResult = CheckInputData();
if (checkResult != "") if (checkResult != string.Empty)
{ {
Result = new ForcesResults() Result = new ForcesResults()
{ {
@@ -49,11 +49,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
}; };
return; return;
} }
else GetCombinations();
{ CalculateResult();
GetCombinations();
CalculateResult();
}
} }
private void CalculateResult() private void CalculateResult()
@@ -199,18 +196,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private string CheckInputData() private string CheckInputData()
{ {
string result = ""; string result = string.Empty;
try if (! Primitives.Any())
{ {
triangulateLogic = new TriangulatePrimitiveLogic() result += "Calculator does not contain any primitives \n";
{
Primitives = Primitives
};
triangulateLogic.CheckPrimitives(Primitives);
}
catch (Exception ex)
{
result += ex;
} }
if (ForceActions.Count == 0) if (ForceActions.Count == 0)
{ {
@@ -222,8 +211,20 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
} }
if (CalcTermsList.Count == 0) if (CalcTermsList.Count == 0)
{ {
result += "Calculator does not contain any duration \n"; 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; return result;
} }

View File

@@ -1,5 +1,7 @@
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -11,22 +13,30 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
public class AverageDiameterLogic : IAverageDiameterLogic public class AverageDiameterLogic : IAverageDiameterLogic
{ {
public IEnumerable<RebarNdm> Rebars { get; set; } public IEnumerable<RebarNdm> Rebars { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public double GetAverageDiameter() public double GetAverageDiameter()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
Check(); Check();
var rebarArea = Rebars var rebarArea = Rebars
.Sum(x => x.Area); .Sum(x => x.Area);
TraceLogger?.AddMessage($"Summary rebar area As = {rebarArea}");
var rebarCount = Rebars.Count(); var rebarCount = Rebars.Count();
TraceLogger?.AddMessage($"Rebar count n = {rebarCount}");
var averageArea = rebarArea / rebarCount; var averageArea = rebarArea / rebarCount;
TraceLogger?.AddMessage($"Average rebar area As = {averageArea}");
var diameter = Math.Sqrt(averageArea / Math.PI); var diameter = Math.Sqrt(averageArea / Math.PI);
TraceLogger?.AddMessage($"Average rebar diameter ds = {diameter}");
return diameter; return diameter;
} }
private void Check() private void Check()
{ {
if (!Rebars.Any()) if (!Rebars.Any())
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": rebars count must be greater then zero"); string errorString = ErrorStrings.DataIsInCorrect + $": rebars count must be greater then zero";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
} }
} }
} }

View File

@@ -1,4 +1,6 @@
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -11,9 +13,12 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
CrackWidthLogicInputDataSP63 inputData; CrackWidthLogicInputDataSP63 inputData;
public ICrackWidthLogicInputData InputData {get;set;} public ICrackWidthLogicInputData InputData {get;set;}
public IShiftTraceLogger? TraceLogger { get; set; }
public double GetCrackWidth() public double GetCrackWidth()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage("Method of crack width calculation based on SP 63.13330.2018");
CheckOptions(); CheckOptions();
//check if strain of concrete greater than strain of rebar //check if strain of concrete greater than strain of rebar
if (inputData.ConcreteStrain > inputData.RebarStrain) { return 0d; } if (inputData.ConcreteStrain > inputData.RebarStrain) { return 0d; }
@@ -24,31 +29,42 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
private void CheckOptions() private void CheckOptions()
{ {
string errorString = string.Empty;
if (InputData is not CrackWidthLogicInputDataSP63) if (InputData is not CrackWidthLogicInputDataSP63)
{ {
throw new StructureHelperException(ErrorStrings.ExpectedWas(typeof(CrackWidthLogicInputDataSP63), InputData.GetType())); errorString = ErrorStrings.ExpectedWas(typeof(CrackWidthLogicInputDataSP63), InputData.GetType());
} }
inputData = InputData as CrackWidthLogicInputDataSP63; inputData = InputData as CrackWidthLogicInputDataSP63;
if (inputData.Length <=0d) if (inputData.Length <=0d)
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": length between cracks L={inputData.Length} must be greate than zero"); errorString = ErrorStrings.DataIsInCorrect + $": length between cracks L={inputData.Length} must be greate than zero";
} }
if (inputData.TermFactor <= 0d) if (inputData.TermFactor <= 0d)
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Term factor {inputData.TermFactor} must be greate than zero"); errorString = ErrorStrings.DataIsInCorrect + $": Term factor {inputData.TermFactor} must be greate than zero";
} }
if (inputData.BondFactor <= 0d) if (inputData.BondFactor <= 0d)
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Bond factor {inputData.BondFactor} must be greate than zero"); errorString = ErrorStrings.DataIsInCorrect + $": Bond factor {inputData.BondFactor} must be greate than zero";
} }
if (inputData.StressStateFactor <= 0d) if (inputData.StressStateFactor <= 0d)
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Bond factor {inputData.StressStateFactor} must be greate than zero"); errorString = ErrorStrings.DataIsInCorrect + $": Bond factor {inputData.StressStateFactor} must be greate than zero";
} }
if (inputData.PsiSFactor <= 0d) if (inputData.PsiSFactor <= 0d)
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": PsiS factor {inputData.PsiSFactor} must be greate than zero"); errorString = ErrorStrings.DataIsInCorrect + $": PsiS factor {inputData.PsiSFactor} must be greate than zero";
} }
if (errorString != string.Empty)
{
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
} }
} }
} }

View File

@@ -0,0 +1,82 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
public class CrackedSectionTriangulationLogic : ICrackedSectionTriangulationLogic
{
const LimitStates limitState = LimitStates.SLS;
const CalcTerms shortTerm = CalcTerms.ShortTerm;
private ITriangulatePrimitiveLogic triangulateLogic;
private string ndmPrimitiveCountMessage;
public IEnumerable<INdmPrimitive> NdmPrimitives { get; private set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public CrackedSectionTriangulationLogic(IEnumerable<INdmPrimitive> ndmPrimitives)
{
NdmPrimitives = ndmPrimitives;
ndmPrimitiveCountMessage = $"Source collection containes {NdmPrimitives.Count()} primitives";
triangulateLogic = new TriangulatePrimitiveLogic
{
Primitives = NdmPrimitives,
LimitState = limitState,
CalcTerm = shortTerm,
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
};
}
public List<INdm> GetNdmCollection()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
triangulateLogic = new TriangulatePrimitiveLogic()
{
LimitState = limitState,
CalcTerm = shortTerm,
Primitives = NdmPrimitives,
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
};
return triangulateLogic.GetNdms();
}
public List<INdm> GetCrackedNdmCollection()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
triangulateLogic = new TriangulatePrimitiveLogic(new MeshCrackedConcreteLogic())
{
LimitState = limitState,
CalcTerm = shortTerm,
Primitives = NdmPrimitives,
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
};
return triangulateLogic.GetNdms();
}
public List<RebarPrimitive> GetRebarPrimitives()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage(ndmPrimitiveCountMessage, TraceLogStatuses.Debug);
List<RebarPrimitive> rebarPrimitives = new();
foreach (var item in NdmPrimitives)
{
if (item is RebarPrimitive rebar)
{
TraceLogger?.AddMessage($"Primitive {rebar.Name} is rebar primitive", TraceLogStatuses.Service);
rebarPrimitives.Add(rebar);
}
}
TraceLogger?.AddMessage($"Obtained {rebarPrimitives.Count} rebar primitives");
return rebarPrimitives;
}
}
}

View File

@@ -1,4 +1,5 @@
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -7,7 +8,7 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
public interface IAverageDiameterLogic public interface IAverageDiameterLogic : ILogic
{ {
IEnumerable<RebarNdm> Rebars { get; set; } IEnumerable<RebarNdm> Rebars { get; set; }
double GetAverageDiameter(); double GetAverageDiameter();

View File

@@ -1,4 +1,5 @@
using System; using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -9,7 +10,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <summary> /// <summary>
/// Logic for calculating width of crack /// Logic for calculating width of crack
/// </summary> /// </summary>
public interface ICrackWidthLogic public interface ICrackWidthLogic : ILogic
{ {
ICrackWidthLogicInputData InputData { get; set; } ICrackWidthLogicInputData InputData { get; set; }
/// <summary> /// <summary>

View File

@@ -0,0 +1,37 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Cracking
{
/// <summary>
/// Logic for obtaining of collection of nms elementary part for regular and fully cracked section
/// </summary>
public interface ICrackedSectionTriangulationLogic : ILogic
{
/// <summary>
/// Source collection of ndm primitives
/// </summary>
IEnumerable<INdmPrimitive> NdmPrimitives { get; }
/// <summary>
/// Returns collection of ndm elementary parts
/// </summary>
/// <returns></returns>
List<INdm> GetNdmCollection();
/// <summary>
/// Returns collection of ndm elementary parts where concrete doesn't work in tension
/// </summary>
/// <returns></returns>
List<INdm> GetCrackedNdmCollection();
/// <summary>
/// Return collection of primitives which contain only rebars
/// </summary>
/// <returns></returns>
List<RebarPrimitive> GetRebarPrimitives();
}
}

View File

@@ -1,5 +1,6 @@
using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -12,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <summary> /// <summary>
/// Logic fo calculating of tensile area of RC crosssection /// Logic fo calculating of tensile area of RC crosssection
/// </summary> /// </summary>
public interface ITensileAreaLogic public interface ITensileAreaLogic : ILogic
{ {
IEnumerable<INdm> NdmCollection { get; set; } IEnumerable<INdm> NdmCollection { get; set; }
IStrainMatrix StrainMatrix { get; set; } IStrainMatrix StrainMatrix { get; set; }

View File

@@ -1,6 +1,10 @@
using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Logics;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperLogics.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -18,6 +22,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
readonly IAverageDiameterLogic diameterLogic; readonly IAverageDiameterLogic diameterLogic;
readonly ITensileAreaLogic tensileAreaLogic; readonly ITensileAreaLogic tensileAreaLogic;
IStressLogic stressLogic;
public IEnumerable<INdm> NdmCollection { get; set; } public IEnumerable<INdm> NdmCollection { get; set; }
public IStrainMatrix StrainMatrix { get; set; } public IStrainMatrix StrainMatrix { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
@@ -26,6 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
this.diameterLogic = diameterLogic; this.diameterLogic = diameterLogic;
this.tensileAreaLogic = tensileAreaLogic; this.tensileAreaLogic = tensileAreaLogic;
stressLogic = new StressLogic();
} }
public LengthBetweenCracksLogicSP63() : public LengthBetweenCracksLogicSP63() :
this this
@@ -34,18 +40,43 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ } { }
public double GetLength() public double GetLength()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
var rebars = NdmCollection var rebars = NdmCollection
.Where(x => x is RebarNdm) .Where(x => x is RebarNdm & stressLogic.GetTotalStrain(StrainMatrix, x) > 0d)
.Select(x => x as RebarNdm); .Select(x => x as RebarNdm);
if (! rebars.Any())
{
string errorString = ErrorStrings.DataIsInCorrect + ": Collection of rebars does not contain any tensile rebars";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
if (TraceLogger is not null)
{
TraceService.TraceNdmCollection(TraceLogger, rebars);
}
var rebarArea = rebars.Sum(x => x.Area * x.StressScale); var rebarArea = rebars.Sum(x => x.Area * x.StressScale);
TraceLogger?.AddMessage($"Summary rebar area As = {rebarArea}");
diameterLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
diameterLogic.Rebars = rebars; diameterLogic.Rebars = rebars;
var rebarDiameter = diameterLogic.GetAverageDiameter(); var rebarDiameter = diameterLogic.GetAverageDiameter();
TraceLogger?.AddMessage($"Average rebar diameter ds = {rebarDiameter}");
tensileAreaLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
tensileAreaLogic.NdmCollection = NdmCollection; tensileAreaLogic.NdmCollection = NdmCollection;
tensileAreaLogic.StrainMatrix = StrainMatrix; tensileAreaLogic.StrainMatrix = StrainMatrix;
var concreteArea = tensileAreaLogic.GetTensileArea(); var concreteArea = tensileAreaLogic.GetTensileArea();
TraceLogger?.AddMessage($"Concrete effective area Ac,eff = {concreteArea}(m^2)");
var length = concreteArea / rebarArea * rebarDiameter; var length = concreteArea / rebarArea * rebarDiameter;
length = new List<double> { length, minDiameterFactor * rebarDiameter, minLength }.Max(); TraceLogger?.AddMessage($"Base length between cracks Lcrc = {concreteArea} / {rebarArea} * {rebarDiameter} = {length}(m)");
length = new List<double> { length, maxDiameterFactor * rebarDiameter, maxLength }.Min(); double minLengthByDiameter = minDiameterFactor * rebarDiameter;
TraceLogger?.AddMessage($"Minimum length by diameter Lcrc = {minDiameterFactor} * {rebarDiameter} = {minLengthByDiameter}(m)");
TraceLogger?.AddMessage($"Minimum length Lcrc = {minLength}");
length = new List<double> { length, minLengthByDiameter, minLength }.Max();
TraceLogger?.AddMessage($"Minimum length Lcrc = max({length}, {minLengthByDiameter}, {minLength}) = {length}(m)");
double maxLengthByDiameter = maxDiameterFactor * rebarDiameter;
TraceLogger?.AddMessage($"Maximum length by diameter Lcrc = {maxDiameterFactor} * {rebarDiameter} = {maxLengthByDiameter}(m)");
TraceLogger?.AddMessage($"Maximum length Lcrc = {maxLength}");
length = new List<double> { length, maxLengthByDiameter, maxLength }.Min();
TraceLogger?.AddMessage($"Maximun length Lcrc = min({length}, {maxLengthByDiameter}, {maxLength}) = {length}(m)");
return length; return length;
} }
} }

View File

@@ -2,7 +2,9 @@
using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Logics; using LoaderCalculator.Logics;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Services.Forces; using StructureHelperCommon.Services.Forces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -16,29 +18,44 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
const double maxConcreteFactor = 0.5d; const double maxConcreteFactor = 0.5d;
const double minConcreteFactor = 0.1d; const double minConcreteFactor = 0.1d;
const double minRebarFactor = 3d; const double minRebarFactor = 9d;
private static IStressLogic stressLogic => new StressLogic(); private static IStressLogic stressLogic => new StressLogic();
public IEnumerable<INdm> NdmCollection { get; set; } public IEnumerable<INdm> NdmCollection { get; set; }
public IStrainMatrix StrainMatrix { get; set; } public IStrainMatrix StrainMatrix { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public double GetTensileArea() public double GetTensileArea()
{ {
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
var rebarCollection = NdmCollection var rebarCollection = NdmCollection
.Where(x => x is RebarNdm); .Where(x => x is RebarNdm & stressLogic.GetTotalStrain(StrainMatrix, x) > 0d);
var rebarArea = rebarCollection. var rebarArea = rebarCollection.
Sum(x => x.Area * x.StressScale); Sum(x => x.Area * x.StressScale);
TraceLogger?.AddMessage($"Summary rebar area As = {rebarArea}");
var concreteCollection = NdmCollection var concreteCollection = NdmCollection
.Where(x => x.Material is ConcreteMaterial); .Where(x => x.Material is ConcreteMaterial);
var concreteArea = concreteCollection var concreteArea = concreteCollection
.Sum(x => x.Area * x.StressScale); .Sum(x => x.Area * x.StressScale);
TraceLogger?.AddMessage($"Concrete area Ac = {concreteArea}");
var concreteTensileArea = concreteCollection var concreteTensileArea = concreteCollection
.Where(x => stressLogic.GetTotalStrainWithPrestrain(StrainMatrix, x) > 0d) .Where(x => stressLogic.GetTotalStrainWithPrestrain(StrainMatrix, x) > 0d)
.Sum(x => x.Area * x.StressScale); .Sum(x => x.Area * x.StressScale);
TraceLogger?.AddMessage($"Concrete tensile area Ac,t = {concreteTensileArea}");
concreteTensileArea = Math.Max(concreteTensileArea, rebarArea * minRebarFactor);
concreteTensileArea = Math.Max(concreteTensileArea, concreteArea * minConcreteFactor);
concreteTensileArea = Math.Min(concreteTensileArea, concreteArea * maxConcreteFactor);
double areaByRebar = rebarArea * minRebarFactor;
TraceLogger?.AddMessage($"Concrete area is considered not less than {minRebarFactor} of area of rebars");
TraceLogger?.AddMessage($"Minimum concrete effective area from area of rebar Ac,eff = {rebarArea} * {minRebarFactor} = {areaByRebar}");
concreteTensileArea = Math.Max(concreteTensileArea, areaByRebar);
double areaByMinConcreteFactor = concreteArea * minConcreteFactor;
TraceLogger?.AddMessage($"Concrete area is considered not less than {minConcreteFactor} of area of rebars");
TraceLogger?.AddMessage($"Minimum concrete effective area Ac,eff = {concreteArea} * {minConcreteFactor} = {areaByMinConcreteFactor}");
concreteTensileArea = Math.Max(concreteTensileArea, areaByMinConcreteFactor);
double areaByMaxConcreteFactor = concreteArea * maxConcreteFactor;
TraceLogger?.AddMessage($"Concrete area is considered not greater than {maxConcreteFactor} of area of rebars");
TraceLogger?.AddMessage($"Maximum concrete effective area Ac,eff = {concreteArea} * {maxConcreteFactor} = {areaByMaxConcreteFactor}");
concreteTensileArea = Math.Min(concreteTensileArea, areaByMaxConcreteFactor);
TraceLogger?.AddMessage($"Concrete effective area Ac,eff = {concreteTensileArea}");
return concreteTensileArea; return concreteTensileArea;
} }
} }

View File

@@ -17,11 +17,13 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
private static readonly ILengthBetweenCracksLogic lengthLogic = new LengthBetweenCracksLogicSP63(); private static readonly ILengthBetweenCracksLogic lengthLogic = new LengthBetweenCracksLogicSP63();
private TupleCrackResult result; private TupleCrackResult result;
private IEnumerable<INdmPrimitive> ndmPrimitives; private IEnumerable<INdmPrimitive> ndmPrimitives;
private ICrackedSectionTriangulationLogic triangulationLogic;
private List<RebarPrimitive>? rebarPrimitives; private List<RebarPrimitive>? rebarPrimitives;
private IEnumerable<INdm> defaultNdm; private IEnumerable<INdm> defaultNdms;
private IEnumerable<INdm> fulyCrackedNdm; private IEnumerable<INdm> fulyCrackedNdms;
private CrackForceResult crackForceResult; private CrackForceResult crackForceResult;
private StrainTuple strainTuple; private StrainTuple longDefaultStrainTuple;
private StrainTuple shortDefaultStrainTuple;
private ITriangulatePrimitiveLogic triangulateLogic; private ITriangulatePrimitiveLogic triangulateLogic;
public string Name { get; set; } public string Name { get; set; }
@@ -37,6 +39,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
try try
{ {
TraceLogger?.AddMessage($"Calculation of crack width by force combination");
ProcessCalculations(); ProcessCalculations();
TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone); TraceLogger?.AddMessage(LoggerStrings.CalculationHasDone);
@@ -46,7 +49,6 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
result.IsValid = false; result.IsValid = false;
result.Description += ex; result.Description += ex;
TraceLogger?.AddMessage(LoggerStrings.CalculationError + ex, TraceLogStatuses.Error); TraceLogger?.AddMessage(LoggerStrings.CalculationError + ex, TraceLogStatuses.Error);
} }
} }
@@ -64,7 +66,10 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
{ {
CheckInputData(); CheckInputData();
Triangulate(); Triangulate();
CalcStrainMatrix(); longDefaultStrainTuple = CalcStrainMatrix(InputData.LongTermTuple, defaultNdms);
shortDefaultStrainTuple = CalcStrainMatrix(InputData.LongTermTuple, defaultNdms);
var longLength = GetLengthBetweenCracks(longDefaultStrainTuple);
var shortLength = GetLengthBetweenCracks(shortDefaultStrainTuple);
CalcCrackForce(); CalcCrackForce();
var crackInputData = GetCrackInputData(); var crackInputData = GetCrackInputData();
var calculator = new RebarCrackCalculator var calculator = new RebarCrackCalculator
@@ -77,63 +82,69 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
crackInputData.RebarPrimitive = item; crackInputData.RebarPrimitive = item;
calculator.Run(); calculator.Run();
var rebarResult = calculator.Result as RebarCrackResult; var rebarResult = calculator.Result as RebarCrackResult;
//if (crackForceResult.IsSectionCracked == false)
//{
// rebarResult.CrackWidth = 0d;
//}
result.RebarResults.Add(rebarResult); result.RebarResults.Add(rebarResult);
} }
} }
private void CalcStrainMatrix() private StrainTuple CalcStrainMatrix(IForceTuple forceTuple, IEnumerable<INdm> ndms)
{ {
IForceTupleInputData inputData = new ForceTupleInputData() { NdmCollection = defaultNdm, Tuple = InputData.LongTermTuple}; IForceTupleInputData inputData = new ForceTupleInputData()
IForceTupleCalculator calculator = new ForceTupleCalculator() { InputData = inputData }; {
NdmCollection = ndms,
Tuple = forceTuple
};
IForceTupleCalculator calculator = new ForceTupleCalculator()
{
InputData = inputData,
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
};
calculator.Run(); calculator.Run();
var forceResult = calculator.Result as IForcesTupleResult; var forceResult = calculator.Result as IForcesTupleResult;
strainTuple = TupleConverter.ConvertToStrainTuple(forceResult.LoaderResults.StrainMatrix); var strain = TupleConverter.ConvertToStrainTuple(forceResult.LoaderResults.StrainMatrix);
return strain;
} }
private RebarCrackInputData GetCrackInputData() private RebarCrackInputData GetCrackInputData()
{ {
lengthLogic.NdmCollection = defaultNdm; lengthLogic.NdmCollection = defaultNdms;
lengthLogic.StrainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(strainTuple); lengthLogic.StrainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(longDefaultStrainTuple);
var length = lengthLogic.GetLength(); var length = lengthLogic.GetLength();
var crackInputData = new RebarCrackInputData var crackInputData = new RebarCrackInputData
{ {
PsiSFactor = crackForceResult.PsiS, PsiSFactor = crackForceResult.PsiS,
Length = length, Length = length,
StrainTuple = strainTuple StrainTuple = longDefaultStrainTuple
}; };
return crackInputData; return crackInputData;
} }
private double GetLengthBetweenCracks(StrainTuple strainTuple)
{
var logic = new LengthBetweenCracksLogicSP63()
{
NdmCollection = defaultNdms,
TraceLogger = TraceLogger
};
logic.StrainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(strainTuple);
return logic.GetLength();
}
private void Triangulate() private void Triangulate()
{ {
ndmPrimitives = InputData.NdmPrimitives; triangulationLogic = new CrackedSectionTriangulationLogic(InputData.NdmPrimitives)
rebarPrimitives = new List<RebarPrimitive>();
foreach (var item in ndmPrimitives)
{ {
if (item is RebarPrimitive)
{
rebarPrimitives.Add(item as RebarPrimitive);
}
}
triangulateLogic = new TriangulatePrimitiveLogic()
{
Primitives = ndmPrimitives,
LimitState = LimitStates.SLS,
CalcTerm = CalcTerms.ShortTerm,
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50) TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
}; };
defaultNdm = triangulateLogic.GetNdms(); rebarPrimitives = triangulationLogic.GetRebarPrimitives();
defaultNdms = triangulationLogic.GetNdmCollection();
fulyCrackedNdms = triangulationLogic.GetCrackedNdmCollection();
} }
private void CalcCrackForce() private void CalcCrackForce()
{ {
var calculator = new CrackForceCalculator(); var calculator = new CrackForceCalculator();
calculator.EndTuple = InputData.LongTermTuple; calculator.EndTuple = InputData.LongTermTuple;
calculator.NdmCollection = defaultNdm; calculator.NdmCollection = defaultNdms;
calculator.Run(); calculator.Run();
crackForceResult = calculator.Result as CrackForceResult; crackForceResult = calculator.Result as CrackForceResult;
} }

View File

@@ -14,18 +14,42 @@ using StructureHelperCommon.Models.Parameters;
namespace StructureHelperLogics.NdmCalculations.Primitives namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
/// <summary>
/// Geometrical primitive which generates ndm elemtntary part
/// </summary>
public interface INdmPrimitive : ISaveable, ICloneable public interface INdmPrimitive : ISaveable, ICloneable
{ {
/// <summary>
/// Name of primitive
/// </summary>
string? Name { get; set; } string? Name { get; set; }
/// <summary>
/// Base point of primitive
/// </summary>
IPoint2D Center { get; } IPoint2D Center { get; }
/// <summary>
/// Host cross-section for primitive
/// </summary>
ICrossSection? CrossSection { get; set; } ICrossSection? CrossSection { get; set; }
/// <summary>
/// Material of primitive
/// </summary>
IHeadMaterial? HeadMaterial { get; set; } IHeadMaterial? HeadMaterial { get; set; }
/// <summary> /// <summary>
/// Flag of triangulation /// Flag of triangulation
/// </summary> /// </summary>
bool Triangulate { get; set; } bool Triangulate { get; set; }
/// <summary>
/// Prestrain assigned from user
/// </summary>
StrainTuple UsersPrestrain { get; } StrainTuple UsersPrestrain { get; }
/// <summary>
/// Prestrain assigned from calculations
/// </summary>
StrainTuple AutoPrestrain { get; } StrainTuple AutoPrestrain { get; }
/// <summary>
/// Visual settings
/// </summary>
IVisualProperty VisualProperty {get; } IVisualProperty VisualProperty {get; }
IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions); IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions);

View File

@@ -9,10 +9,22 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
{ {
public interface IVisualProperty public interface IVisualProperty
{ {
/// <summary>
/// Flag of visibility
/// </summary>
bool IsVisible { get; set; } bool IsVisible { get; set; }
Color Color { get; set; } Color Color { get; set; }
/// <summary>
/// Flag of assigning of color from material or from primitive's settings
/// </summary>
bool SetMaterialColor { get; set; } bool SetMaterialColor { get; set; }
/// <summary>
/// Index by z-coordinate
/// </summary>
int ZIndex { get; set; } int ZIndex { get; set; }
/// <summary>
/// Opacity of filling
/// </summary>
double Opacity { get; set; } double Opacity { get; set; }
} }
} }

View File

@@ -68,13 +68,35 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
} }
public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions) public IEnumerable<INdm> GetNdms(ITriangulationOptions triangulationOptions)
{
List<INdm> ndms = new()
{
GetConcreteNdm(triangulationOptions),
GetRebarNdm(triangulationOptions)
};
return ndms;
}
public RebarNdm GetRebarNdm(ITriangulationOptions triangulationOptions)
{ {
var options = new RebarTriangulationLogicOptions(this) var options = new RebarTriangulationLogicOptions(this)
{ {
triangulationOptions = triangulationOptions triangulationOptions = triangulationOptions
}; };
var logic = new RebarTriangulationLogic(options); var logic = new RebarTriangulationLogic(options);
return logic.GetNdmCollection(); var rebar = logic.GetRebarNdm();
return rebar;
}
public Ndm GetConcreteNdm(ITriangulationOptions triangulationOptions)
{
var options = new RebarTriangulationLogicOptions(this)
{
triangulationOptions = triangulationOptions
};
var logic = new RebarTriangulationLogic(options);
var concrete = logic.GetConcreteNdm();
return concrete;
} }
public List<INamedAreaPoint> GetValuePoints() public List<INamedAreaPoint> GetValuePoints()

View File

@@ -3,8 +3,10 @@ using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Ndms.Transformations; using LoaderCalculator.Data.Ndms.Transformations;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services.Forces; using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.Models.Primitives;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -23,14 +25,20 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
} }
public IEnumerable<INdm> GetNdmCollection() public IEnumerable<INdm> GetNdmCollection()
{ {
var concreteNdm = new Ndm List<INdm> ndmCollection = new();
if (options.HostPrimitive is not null)
{ {
CenterX = options.Center.X, var concreteNdm = GetConcreteNdm();
CenterY = options.Center.Y, ndmCollection.Add(concreteNdm);
Area = options.Area, }
Material = options.HostMaterial.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm),
StressScale = -1d var rebarNdm = GetRebarNdm();
}; ndmCollection.Add(rebarNdm);
return ndmCollection;
}
public RebarNdm GetRebarNdm()
{
var rebarNdm = new RebarNdm var rebarNdm = new RebarNdm
{ {
CenterX = options.Center.X, CenterX = options.Center.X,
@@ -38,9 +46,32 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
Area = options.Area, Area = options.Area,
Material = options.HeadMaterial.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm) Material = options.HeadMaterial.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm)
}; };
List<INdm> ndmCollection = new() { concreteNdm, rebarNdm}; ;
NdmTransform.SetPrestrain(ndmCollection, TupleConverter.ConvertToLoaderStrainMatrix(options.Prestrain)); NdmTransform.SetPrestrain(rebarNdm, TupleConverter.ConvertToLoaderStrainMatrix(options.Prestrain));
return ndmCollection; return rebarNdm;
}
public Ndm GetConcreteNdm()
{
var hostPrimitive = options.HostPrimitive;
var material = hostPrimitive
.HeadMaterial
.GetLoaderMaterial(options.triangulationOptions.LimiteState, options.triangulationOptions.CalcTerm);
var prestrain = ForceTupleService.SumTuples(hostPrimitive.UsersPrestrain,
hostPrimitive.AutoPrestrain)
as StrainTuple;
var concreteNdm = new Ndm
{
CenterX = options.Center.X,
CenterY = options.Center.Y,
Area = options.Area,
Material = material,
StressScale = -1d
};
NdmTransform.SetPrestrain(concreteNdm, TupleConverter.ConvertToLoaderStrainMatrix(prestrain));
return concreteNdm;
} }
public void ValidateOptions(ITriangulationLogicOptions options) public void ValidateOptions(ITriangulationLogicOptions options)

View File

@@ -22,7 +22,8 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
public double Area { get; } public double Area { get; }
public StrainTuple Prestrain { get; set; } public StrainTuple Prestrain { get; set; }
public IHeadMaterial HeadMaterial { get; set; } public IHeadMaterial HeadMaterial { get; set; }
public IHeadMaterial HostMaterial { get; set; } public INdmPrimitive HostPrimitive { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public RebarTriangulationLogicOptions(RebarPrimitive primitive) public RebarTriangulationLogicOptions(RebarPrimitive primitive)
@@ -30,7 +31,7 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
Center = primitive.Center.Clone() as Point2D; Center = primitive.Center.Clone() as Point2D;
Area = primitive.Area; Area = primitive.Area;
HeadMaterial = primitive.HeadMaterial; HeadMaterial = primitive.HeadMaterial;
HostMaterial = primitive.HostPrimitive.HeadMaterial; HostPrimitive = primitive.HostPrimitive;
Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple; Prestrain = ForceTupleService.SumTuples(primitive.UsersPrestrain, primitive.AutoPrestrain) as StrainTuple;
} }
} }

View File

@@ -0,0 +1,47 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
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.Services.NdmPrimitives
{
public class CheckPrimitivesForMeshingLogic : ICheckPrimitivesForMeshingLogic
{
public IEnumerable<INdmPrimitive> Primitives { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public bool Check()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
if (!Primitives.Any())
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
if (!Primitives.Any(x => x.Triangulate == true))
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
foreach (var item in Primitives)
{
if (item.Triangulate == true &
item.HeadMaterial is null)
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
return true;
}
}
}

View File

@@ -0,0 +1,16 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
public interface ICheckPrimitivesForMeshingLogic : ILogic
{
IEnumerable<INdmPrimitive> Primitives { get; set; }
bool Check();
}
}

View File

@@ -0,0 +1,18 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
public interface IMeshHasDivisionLogic : ILogic
{
List<INdm> NdmCollection { get; set; }
IHasDivisionSize Primitive { get; set; }
void MeshHasDivision();
}
}

View File

@@ -0,0 +1,19 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
public interface IMeshPrimitiveLogic : ILogic
{
INdmPrimitive Primitive { get; set; }
ITriangulationOptions TriangulationOptions { get; set; }
List<INdm> MeshPrimitive();
}
}

View File

@@ -11,6 +11,5 @@ namespace StructureHelperLogics.Services.NdmPrimitives
LimitStates LimitState { get; set; } LimitStates LimitState { get; set; }
CalcTerms CalcTerm { get; set; } CalcTerms CalcTerm { get; set; }
List<INdm> GetNdms(); List<INdm> GetNdms();
bool CheckPrimitives(IEnumerable<INdmPrimitive> primitives);
} }
} }

View File

@@ -0,0 +1,98 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
internal class MeshCrackedConcreteLogic : IMeshPrimitiveLogic
{
private IMeshPrimitiveLogic regularMeshLogic;
public List<INdm> NdmCollection { get; set; }
public INdmPrimitive Primitive { get; set; }
public ITriangulationOptions TriangulationOptions { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
List<INdm> IMeshPrimitiveLogic.MeshPrimitive()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
CheckPrimitive();
List<INdm> ndmCollection = new();
if (Primitive.HeadMaterial.HelperMaterial is ICrackedMaterial)
{
TraceLogger?.AddMessage($"Primitive {Primitive.Name} is crackable primitive", TraceLogStatuses.Service);
var newPrimititve = Primitive.Clone() as INdmPrimitive;
SetNewMaterial(newPrimititve);
List<INdm> ndms = GetNdms(newPrimititve);
ndmCollection.AddRange(ndms);
}
else if (Primitive is RebarPrimitive rebar)
{
TraceLogger?.AddMessage($"Primitive {Primitive.Name} is rebar primitive", TraceLogStatuses.Service);
var newPrimititve = rebar.Clone() as RebarPrimitive;
var newHostPrimitive = rebar.HostPrimitive.Clone() as INdmPrimitive;
SetNewMaterial(newHostPrimitive);
newPrimititve.HostPrimitive = newHostPrimitive;
List<INdm> ndms = GetNdms(newPrimititve);
ndmCollection.AddRange(ndms);
}
else
{
TraceLogger?.AddMessage($"Primitive {Primitive.Name} is non-crackable primitive", TraceLogStatuses.Service);
List<INdm> ndms = GetNdms(Primitive);
ndmCollection.AddRange(ndms);
}
return ndmCollection;
}
private void SetNewMaterial(INdmPrimitive? newPrimititve)
{
TraceLogger?.AddMessage($"Process material {newPrimititve.HeadMaterial.Name} has started");
var newMaterial = newPrimititve.HeadMaterial.HelperMaterial.Clone() as ICrackedMaterial;
TraceLogger?.AddMessage($"Set work in tension zone for material {newPrimititve.HeadMaterial.Name}");
newMaterial.TensionForSLS = false;
newPrimititve.HeadMaterial.HelperMaterial = newMaterial as IHelperMaterial;
}
private List<INdm> GetNdms(INdmPrimitive primitive)
{
TraceLogger?.AddMessage($"Triangulation primitive has started");
regularMeshLogic = new MeshPrimitiveLogic()
{
Primitive = primitive,
TriangulationOptions = TriangulationOptions,
TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
};
List<INdm> ndms = regularMeshLogic.MeshPrimitive();
return ndms;
}
private void CheckPrimitive()
{
if (TriangulationOptions.LimiteState is not LimitStates.SLS)
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Limit state for cracking must correspondent limit state of serviceability");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
if (TriangulationOptions.CalcTerm is not CalcTerms.ShortTerm)
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Calc term for cracked concrete must correspondent short term");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
TraceLogger?.AddMessage($"Primitive check is ok");
}
}
}

View File

@@ -0,0 +1,41 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
public class MeshHasDivisionLogic : IMeshHasDivisionLogic
{
public List<INdm> NdmCollection { get; set; }
public IHasDivisionSize Primitive { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public void MeshHasDivision()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
if (Primitive is IHasDivisionSize hasDivision)
{
if (hasDivision.ClearUnderlying == true)
{
TraceLogger?.AddMessage("Removing of background part has started", TraceLogStatuses.Service);
NdmCollection
.RemoveAll(x =>
hasDivision
.IsPointInside(new Point2D()
{
X = x.CenterX,
Y = x.CenterY
}) == true);
}
}
}
}
}

View File

@@ -0,0 +1,34 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Services.NdmPrimitives
{
public class MeshPrimitiveLogic : IMeshPrimitiveLogic
{
public INdmPrimitive Primitive { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public ITriangulationOptions TriangulationOptions { get; set; }
public List<INdm> MeshPrimitive()
{
TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
List<INdm> ndmCollection = new();
var itemNdms = Primitive.GetNdms(TriangulationOptions);
ndmCollection.AddRange(itemNdms);
TraceLogger?.AddMessage($"Triangulation of primitive {Primitive.Name} has finished, {itemNdms.Count()} part(s) were obtained", TraceLogStatuses.Service);
return ndmCollection;
}
}
}

View File

@@ -2,7 +2,10 @@
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models; using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations; using StructureHelperLogics.NdmCalculations.Triangulations;
@@ -10,49 +13,85 @@ namespace StructureHelperLogics.Services.NdmPrimitives
{ {
public class TriangulatePrimitiveLogic : ITriangulatePrimitiveLogic public class TriangulatePrimitiveLogic : ITriangulatePrimitiveLogic
{ {
private IMeshHasDivisionLogic divisionLogic;
private IMeshPrimitiveLogic meshLogic;
private List<INdm> ndmCollection; private List<INdm> ndmCollection;
private ICheckPrimitivesForMeshingLogic checkLogic;
public IEnumerable<INdmPrimitive> Primitives { get; set; } public IEnumerable<INdmPrimitive> Primitives { get; set; }
public LimitStates LimitState { get; set; } public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; } public CalcTerms CalcTerm { get; set; }
public bool ConsiderCracking { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public TriangulatePrimitiveLogic()
public TriangulatePrimitiveLogic(IMeshPrimitiveLogic meshPrimitiveLogic)
{ {
ConsiderCracking = false; meshLogic = meshPrimitiveLogic;
} }
public TriangulatePrimitiveLogic() : this (new MeshPrimitiveLogic()) { }
public List<INdm> GetNdms() public List<INdm> GetNdms()
{ {
TraceLogger?.AddMessage($"Total count of primitives n = {Primitives.Count()}", TraceLogStatuses.Service); TraceLogger?.AddMessage(LoggerStrings.CalculatorType(this), TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Limit state is {LimitState}", TraceLogStatuses.Service); CheckPrimitives();
TraceLogger?.AddMessage($"Calc term is {CalcTerm}", TraceLogStatuses.Service);
var orderedNdmPrimitives = Primitives.OrderBy(x => x.VisualProperty.ZIndex);
ndmCollection = new List<INdm>(); ndmCollection = new List<INdm>();
foreach (var item in orderedNdmPrimitives) SetLogics();
TraceInitialSettings();
TriangulatePrimitives();
return ndmCollection;
}
private void TriangulatePrimitives()
{
var orderedNdmPrimitives = Primitives.OrderBy(x => x.VisualProperty.ZIndex);
foreach (var primitive in orderedNdmPrimitives)
{ {
TraceLogger?.AddMessage($"Triangulation of primitive {item.Name} has started", TraceLogStatuses.Service); TriangulatePrimitive(primitive);
ProcessHasDivision(item);
TriangulatePrimitive(item);
} }
if (TraceLogger is not null) if (TraceLogger is not null)
{ {
TraceService.TraceNdmCollection(TraceLogger, ndmCollection); TraceService.TraceNdmCollection(TraceLogger, ndmCollection);
} }
return ndmCollection; TraceLogger?.AddMessage($"Triangulation of primitives has finished, {ndmCollection.Count} part(s) were obtained", TraceLogStatuses.Service);
} }
private void TriangulatePrimitive(INdmPrimitive item) private void TraceInitialSettings()
{ {
if (item.Triangulate == true) TraceLogger?.AddMessage($"Total count of primitives n = {Primitives.Count()}", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Limit state is {LimitState}", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Calc term is {CalcTerm}", TraceLogStatuses.Service);
}
private void SetLogics()
{
divisionLogic = new MeshHasDivisionLogic()
{ {
var triangulationOptions = new TriangulationOptions() NdmCollection = ndmCollection,
{ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
LimiteState = LimitState, };
CalcTerm = CalcTerm var triangulationOptions = new TriangulationOptions()
}; {
var itemNdms = item.GetNdms(triangulationOptions); LimiteState = LimitState,
ndmCollection.AddRange(itemNdms); CalcTerm = CalcTerm
TraceLogger?.AddMessage($"Triangulation of primitive {item.Name} was finished, {itemNdms.Count()} part(s) were obtained", TraceLogStatuses.Service); };
meshLogic.TriangulationOptions = triangulationOptions;
meshLogic.TraceLogger = TraceLogger?.GetSimilarTraceLogger(50);
}
private void TriangulatePrimitive(INdmPrimitive primitive)
{
TraceLogger?.AddMessage($"Triangulation of primitive {primitive.Name} has started", TraceLogStatuses.Service);
if (primitive is IHasDivisionSize hasDivision)
{
divisionLogic.Primitive = hasDivision;
divisionLogic.MeshHasDivision();
}
if (primitive.Triangulate == true)
{
meshLogic.Primitive = primitive;
var ndms = meshLogic.MeshPrimitive();
ndmCollection.AddRange(ndms);
} }
else else
{ {
@@ -60,45 +99,14 @@ namespace StructureHelperLogics.Services.NdmPrimitives
} }
} }
private void ProcessHasDivision(INdmPrimitive? item) private bool CheckPrimitives()
{ {
if (item is IHasDivisionSize hasDivision) checkLogic = new CheckPrimitivesForMeshingLogic()
{ {
if (hasDivision.ClearUnderlying == true) Primitives = Primitives,
{ TraceLogger = TraceLogger?.GetSimilarTraceLogger(50)
TraceLogger?.AddMessage("Removing of background part has started", TraceLogStatuses.Service); };
ndmCollection checkLogic.Check();
.RemoveAll(x =>
hasDivision
.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true);
}
}
}
public bool CheckPrimitives(IEnumerable<INdmPrimitive> primitives)
{
if (!primitives.Any())
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Count of primitive must be greater than zero");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
if (!primitives.Any(x => x.Triangulate == true))
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": There are not primitives to triangulate");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
foreach (var item in primitives)
{
if (item.Triangulate == true &
item.HeadMaterial is null)
{
string errorMessage = string.Intern(ErrorStrings.DataIsInCorrect + $": Primitive: {item.Name} can't be triangulated since material is null");
TraceLogger?.AddMessage(errorMessage, TraceLogStatuses.Error);
throw new StructureHelperException(errorMessage);
}
}
return true; return true;
} }
} }

View File

@@ -15,7 +15,13 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT
public void Run_ShouldPass(double width, double height, double topDiametr, double bottomDiametr, int widthCount, int heightCount, bool isBuckling, double expectedKx, double expectedKy, double expectedEpsZ) public void Run_ShouldPass(double width, double height, double topDiametr, double bottomDiametr, int widthCount, int heightCount, bool isBuckling, double expectedKx, double expectedKy, double expectedEpsZ)
{ {
//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 IForceCalculator;
calculator.CompressedMember.Buckling = isBuckling; calculator.CompressedMember.Buckling = isBuckling;