Fix removing primitives

This commit is contained in:
Evgeny Redikultsev
2025-12-07 18:36:50 +05:00
parent 70bfd065c4
commit 681ab17781
32 changed files with 697 additions and 224 deletions

View File

@@ -10,7 +10,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
/// <summary>
/// Input data fo roce tuple calculator
/// </summary>
public interface IForceCalculatorInputData : IInputData, ISaveable, IHasPrimitives, IHasForceActions
public interface IForceCalculatorInputData : IInputData, ISaveable, IHasForcesAndPrimitives
{
/// <summary>
/// Accuracy of calculating

View File

@@ -24,6 +24,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private Calculator calculator;
private ILoaderResults calcResult;
private IStressLogic stressLogic = new StressLogic();
private IStressPointsLogic stressPointsLogic;
private IStressPointsLogic StressPointsLogic => stressPointsLogic ??= new StressPointsLogic();
public IForceTupleInputData InputData { get; set; }
@@ -138,10 +140,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
List<INdm> overStrainedNdms = new();
foreach (var ndm in InputData.NdmCollection)
{
var strain = stressLogic.GetTotalStrain(calcResult.ForceStrainPair.StrainMatrix, ndm);
if (strain < ndm.Material.LimitNegativeStrain || strain > ndm.Material.LimitPositiveStrain)
IStrainMatrix strainMatrix = calcResult.ForceStrainPair.StrainMatrix;
var strains = StressPointsLogic.GetTotalStrains(strainMatrix, ndm);
if (strains.Min() < ndm.Material.LimitNegativeStrain || strains.Max() > ndm.Material.LimitPositiveStrain)
{
TraceLogger?.AddMessage($"Elementary part x = {ndm.CenterX}, y = {ndm.CenterY} has strain epsilon = {strain}, positive limit strain epsilon+,max = {ndm.Material.LimitPositiveStrain}, negative limit strain epsilon-,min = {ndm.Material.LimitNegativeStrain}", TraceLogStatuses.Warning);
TraceLogger?.AddMessage($"Elementary part x = {ndm.CenterX}, y = {ndm.CenterY} has max strain epsilon,max = {strains.Max()}, min strain epsilon,min = {strains.Min()}, positive limit strain epsilon+,max = {ndm.Material.LimitPositiveStrain}, negative limit strain epsilon-,min = {ndm.Material.LimitNegativeStrain}", TraceLogStatuses.Warning);
overStrainedNdms.Add(ndm);
}
};

View File

@@ -1,6 +1,5 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
@@ -8,7 +7,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.Curvatures
/// <summary>
/// Input data for calculator of curvature of cross-section
/// </summary>
public interface ICurvatureCalculatorInputData : IInputData, ISaveable, IHasForceActions, IHasPrimitives
public interface ICurvatureCalculatorInputData : IInputData, ISaveable, IHasForcesAndPrimitives
{
IDeflectionFactor DeflectionFactor { get; set; }
bool ConsiderSofteningFactor { get; set; }

View File

@@ -8,7 +8,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams
/// <summary>
/// Implements input data for Value diagram calculator
/// </summary>
public interface IValueDiagramCalculatorInputData : ISaveable, IInputData, IHasForceActions, IHasPrimitives
public interface IValueDiagramCalculatorInputData : ISaveable, IInputData, IHasForcesAndPrimitives
{
IStateCalcTermPair StateTermPair { get; set; }
/// <summary>

View File

@@ -11,7 +11,7 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
/// <summary>
/// Input data for crack calculator
/// </summary>
public interface ICrackCalculatorInputData : IInputData, IHasPrimitives, IHasForceActions, ISaveable
public interface ICrackCalculatorInputData : IInputData, IHasForcesAndPrimitives, ISaveable
{
/// <summary>
/// Used difined data for crack width calculation

View File

@@ -0,0 +1,11 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public interface IHasForcesAndPrimitives : IHasPrimitives, IHasForceActions
{
}
}

View File

@@ -0,0 +1,61 @@
using netDxf.Entities;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.Curvatures;
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class CrossSectionRepositoryCheckLogic : CheckEntityLogic<ICrossSectionRepository>
{
private bool result;
private
ICheckEntityLogic<IHasForcesAndPrimitives> primitivesCheckLogic;
ICheckEntityLogic<IHasForcesAndPrimitives> PrimitivesCheckLogic => primitivesCheckLogic ??= new RepositoryHasForcesAndPrimitivesCheckLogic(Entity) { TraceLogger = TraceLogger};
public override bool Check()
{
result = true;
CheckObject.ThrowIfNull(Entity);
foreach (var item in Entity.Calculators)
{
if (item is IForceCalculator forceCalculator)
{
ProcessCalculatorInputData(forceCalculator.InputData);
}
else if (item is ICrackCalculator crackCalculator)
{
ProcessCalculatorInputData(crackCalculator.InputData);
}
else if (item is IValueDiagramCalculator valueDiagramCalculator)
{
ProcessCalculatorInputData(valueDiagramCalculator.InputData);
}
else if (item is ICurvatureCalculator curvatureCalculator)
{
ProcessCalculatorInputData(curvatureCalculator.InputData);
}
else
{
// skip
}
}
return result;
}
private void ProcessCalculatorInputData(IHasForcesAndPrimitives inputData)
{
PrimitivesCheckLogic.Entity = inputData;
if (PrimitivesCheckLogic.Check() == false)
{
CheckResult += "\n" + PrimitivesCheckLogic.CheckResult;
result = false;
}
}
}
}

View File

@@ -0,0 +1,38 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class RepositoryHasForcesAndPrimitivesCheckLogic : CheckEntityLogic<IHasForcesAndPrimitives>
{
ICheckEntityLogic<IHasPrimitives> primitivesCheckLogic;
ICheckEntityLogic<IHasPrimitives> PrimitivesCheckLogic => primitivesCheckLogic ??= new RepositoryHasPrimitivesCheckLogic(Repository) { TraceLogger = TraceLogger };
public ICrossSectionRepository Repository { get; }
public RepositoryHasForcesAndPrimitivesCheckLogic(ICrossSectionRepository repository)
{
Repository = repository;
}
public override bool Check()
{
CheckObject.ThrowIfNull(Repository);
CheckObject.ThrowIfNull(Entity);
bool result = true;
PrimitivesCheckLogic.Entity = Entity;
if (PrimitivesCheckLogic.Check() == false)
{
CheckResult += "\n";
CheckResult += PrimitivesCheckLogic.CheckResult;
result = false;
}
return result;
}
}
}

View File

@@ -0,0 +1,35 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.CrossSections;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.NdmCalculations.Primitives
{
public class RepositoryHasPrimitivesCheckLogic : CheckEntityLogic<IHasPrimitives>
{
public ICrossSectionRepository Repository { get; }
public RepositoryHasPrimitivesCheckLogic(ICrossSectionRepository crossSectionRepository)
{
Repository = crossSectionRepository;
}
public override bool Check()
{
bool result = true;
CheckObject.ThrowIfNull(Repository);
CheckObject.ThrowIfNull(Entity);
foreach (var primitive in Entity.Primitives)
{
if (! Repository.Primitives.Contains(primitive))
{
TraceMessage($"Repository does not contain primitive Id = {primitive.Id}, Name = {primitive.Name}");
result = false;
}
}
return result;
}
}
}